[PATCH] D32341: Fix a bug that warnings generated with -M or -MM flags

2017-04-21 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 96273.
yamaguchi added a comment.

Add testcase.


https://reviews.llvm.org/D32341

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/m_and_mm.c


Index: test/Driver/m_and_mm.c
===
--- test/Driver/m_and_mm.c
+++ test/Driver/m_and_mm.c
@@ -1,3 +1,7 @@
 // RUN: %clang -### \
 // RUN:   -M -MM %s 2> %t
 // RUN: not grep '"-sys-header-deps"' %t
+
+// RUN: %clang -M -MM %s 2> %t
+// RUN: not grep "warning" %t
+#warning "This warning shouldn't shop up with -M and -MM"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -980,6 +980,7 @@
 DepTarget = Args.MakeArgString(llvm::sys::path::filename(P));
   }
 
+  CmdArgs.push_back("-w");
   CmdArgs.push_back("-MT");
   SmallString<128> Quoted;
   QuoteTarget(DepTarget, Quoted);


Index: test/Driver/m_and_mm.c
===
--- test/Driver/m_and_mm.c
+++ test/Driver/m_and_mm.c
@@ -1,3 +1,7 @@
 // RUN: %clang -### \
 // RUN:   -M -MM %s 2> %t
 // RUN: not grep '"-sys-header-deps"' %t
+
+// RUN: %clang -M -MM %s 2> %t
+// RUN: not grep "warning" %t
+#warning "This warning shouldn't shop up with -M and -MM"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -980,6 +980,7 @@
 DepTarget = Args.MakeArgString(llvm::sys::path::filename(P));
   }
 
+  CmdArgs.push_back("-w");
   CmdArgs.push_back("-MT");
   SmallString<128> Quoted;
   QuoteTarget(DepTarget, Quoted);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31856: Headers: Make the type of SIZE_MAX the same as size_t

2017-04-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/test/Headers/stdint-typeof-MINMAX.cpp:1
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only 
-triple=aarch64-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only 
-triple=arm-none-none

dexonsmith wrote:
> I copied the `-ffreestanding` out of test/Preprocessor/stdint.c, but I'm 
> wondering if it even serves a purpose here... if not, we could make the RUN 
> lines shorter (and fit 80 columns without breaking in two).
Without -ffreestanding, you're testing the contents of /usr/include/stdint.h 
rather than the compiler's builtin header.


https://reviews.llvm.org/D31856



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


[PATCH] D32386: [libcxx] [test] Avoid P0138R2, direct-list-init of fixed enums from integers.

2017-04-21 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT created this revision.

[libcxx] [test] Avoid P0138R2, direct-list-init of fixed enums from integers.

This C++17 Core Language feature isn't necessary when testing std::byte.
It's a minor convenience, but it limits test coverage to very new compilers.

(I encountered this because C1XX currently has a bug in this feature, and our 
Clang/C2 is still 3.8 and missing this feature. But these tests had UNSUPPORTED 
comments knocking out several versions of Clang, so the impact isn't just 
limited to us.)


https://reviews.llvm.org/D32386

Files:
  test/std/language.support/support.types/byteops/and.assign.pass.cpp
  test/std/language.support/support.types/byteops/and.pass.cpp
  test/std/language.support/support.types/byteops/lshift.assign.pass.cpp
  test/std/language.support/support.types/byteops/lshift.fail.cpp
  test/std/language.support/support.types/byteops/lshift.pass.cpp
  test/std/language.support/support.types/byteops/not.pass.cpp
  test/std/language.support/support.types/byteops/or.assign.pass.cpp
  test/std/language.support/support.types/byteops/or.pass.cpp
  test/std/language.support/support.types/byteops/rshift.assign.pass.cpp
  test/std/language.support/support.types/byteops/rshift.fail.cpp
  test/std/language.support/support.types/byteops/rshift.pass.cpp
  test/std/language.support/support.types/byteops/to_integer.fail.cpp
  test/std/language.support/support.types/byteops/to_integer.pass.cpp
  test/std/language.support/support.types/byteops/xor.assign.pass.cpp
  test/std/language.support/support.types/byteops/xor.pass.cpp

Index: test/std/language.support/support.types/byteops/xor.pass.cpp
===
--- test/std/language.support/support.types/byteops/xor.pass.cpp
+++ test/std/language.support/support.types/byteops/xor.pass.cpp
@@ -11,16 +11,13 @@
 #include 
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
 
 // constexpr byte operator^(byte l, byte r) noexcept;
 
 int main () {
-	constexpr std::byte b1{1};
-	constexpr std::byte b8{8};
-	constexpr std::byte b9{9};
+	constexpr std::byte b1{static_cast(1)};
+	constexpr std::byte b8{static_cast(8)};
+	constexpr std::byte b9{static_cast(9)};
 
 	static_assert(noexcept(b1 ^ b8), "" );
 
Index: test/std/language.support/support.types/byteops/xor.assign.pass.cpp
===
--- test/std/language.support/support.types/byteops/xor.assign.pass.cpp
+++ test/std/language.support/support.types/byteops/xor.assign.pass.cpp
@@ -11,9 +11,6 @@
 #include 
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
 
 // constexpr byte& operator ^=(byte l, byte r) noexcept;
 
@@ -26,9 +23,9 @@
 
 int main () {
 	std::byte b;  // not constexpr, just used in noexcept check
-	constexpr std::byte b1{1};
-	constexpr std::byte b8{8};
-	constexpr std::byte b9{9};
+	constexpr std::byte b1{static_cast(1)};
+	constexpr std::byte b8{static_cast(8)};
+	constexpr std::byte b9{static_cast(9)};
 
 	static_assert(noexcept(b ^= b), "" );
 
Index: test/std/language.support/support.types/byteops/to_integer.pass.cpp
===
--- test/std/language.support/support.types/byteops/to_integer.pass.cpp
+++ test/std/language.support/support.types/byteops/to_integer.pass.cpp
@@ -11,18 +11,15 @@
 #include 
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
 
 // template 
 //constexpr IntegerType to_integer(byte b) noexcept;
 // This function shall not participate in overload resolution unless 
 //   is_integral_v is true.
 
 int main () {
-	constexpr std::byte b1{1};
-	constexpr std::byte b3{3};
+	constexpr std::byte b1{static_cast(1)};
+	constexpr std::byte b3{static_cast(3)};
 	
 	static_assert(noexcept(std::to_integer(b1)), "" );
 	static_assert(std::is_same(b1))>::value, "" );
Index: test/std/language.support/support.types/byteops/to_integer.fail.cpp
===
--- test/std/language.support/support.types/byteops/to_integer.fail.cpp
+++ test/std/language.support/support.types/byteops/to_integer.fail.cpp
@@ -11,16 +11,13 @@
 #include 
 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// The following compilers don't like "std::byte b1{1}"
-// UNSUPPORTED: clang-3.5, clang-3.6, clang-3.7, clang-3.8
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0
 
 // template 
 //constexpr IntegerType to_integer(byte b) noexcept;
 // This function s

[PATCH] D31856: Headers: Make the type of SIZE_MAX the same as size_t

2017-04-21 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/test/Headers/stdint-typeof-MINMAX.cpp:1
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only 
-triple=aarch64-none-none
+// RUN: %clang_cc1 %s -ffreestanding -std=c++1z -fsyntax-only 
-triple=arm-none-none

I copied the `-ffreestanding` out of test/Preprocessor/stdint.c, but I'm 
wondering if it even serves a purpose here... if not, we could make the RUN 
lines shorter (and fit 80 columns without breaking in two).


https://reviews.llvm.org/D31856



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


[PATCH] D31856: Headers: Make the type of SIZE_MAX the same as size_t

2017-04-21 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith updated this revision to Diff 96269.
dexonsmith added a comment.

Thanks Eli and Richard.

Given that, I've thrown in fixes for `INTMAX_MIN`, `INTMAX_MAX`, `UINTMAX_MAX`, 
`INTMAX_C()`, and `UINTMAX_C()`, as well as fixing the typedefs for `intptr_t`, 
`uintptr_t`, `intmax_t`, and `uintmax_t`.

For the static assert type tests, I've explicitly added RUN lines for all the 
targets tested in test/Preprocessor/stdint.c.

I left out removing `__INTPTR_WIDTH__`, etc., since I wondered if the CHECK 
lines for their values were useful on their own.  We could kill those in a 
follow-up though.


https://reviews.llvm.org/D31856

Files:
  clang/lib/Headers/stdint.h
  clang/test/Headers/stdint-typeof-MINMAX.cpp
  clang/test/Preprocessor/stdint.c

Index: clang/test/Preprocessor/stdint.c
===
--- clang/test/Preprocessor/stdint.c
+++ clang/test/Preprocessor/stdint.c
@@ -28,8 +28,8 @@
 // ARM:typedef int8_t int_fast8_t;
 // ARM:typedef uint8_t uint_fast8_t;
 //
-// ARM:typedef int32_t intptr_t;
-// ARM:typedef uint32_t uintptr_t;
+// ARM:typedef long int intptr_t;
+// ARM:typedef long unsigned int uintptr_t;
 // 
 // ARM:typedef long long int intmax_t;
 // ARM:typedef long long unsigned int uintmax_t;
@@ -74,9 +74,9 @@
 // ARM:INT_FAST64_MAX_ 9223372036854775807LL
 // ARM:UINT_FAST64_MAX_ 18446744073709551615ULL
 //
-// ARM:INTPTR_MIN_ (-2147483647 -1)
-// ARM:INTPTR_MAX_ 2147483647
-// ARM:UINTPTR_MAX_ 4294967295U
+// ARM:INTPTR_MIN_ (-2147483647L -1)
+// ARM:INTPTR_MAX_ 2147483647L
+// ARM:UINTPTR_MAX_ 4294967295UL
 // ARM:PTRDIFF_MIN_ (-2147483647 -1)
 // ARM:PTRDIFF_MAX_ 2147483647
 // ARM:SIZE_MAX_ 4294967295U
@@ -136,8 +136,8 @@
 // I386:typedef int8_t int_fast8_t;
 // I386:typedef uint8_t uint_fast8_t;
 //
-// I386:typedef int32_t intptr_t;
-// I386:typedef uint32_t uintptr_t;
+// I386:typedef int intptr_t;
+// I386:typedef unsigned int uintptr_t;
 //
 // I386:typedef long long int intmax_t;
 // I386:typedef long long unsigned int uintmax_t;
@@ -243,8 +243,8 @@
 // MIPS:typedef int8_t int_fast8_t;
 // MIPS:typedef uint8_t uint_fast8_t;
 //
-// MIPS:typedef int32_t intptr_t;
-// MIPS:typedef uint32_t uintptr_t;
+// MIPS:typedef long int intptr_t;
+// MIPS:typedef long unsigned int uintptr_t;
 //
 // MIPS:typedef long long int intmax_t;
 // MIPS:typedef long long unsigned int uintmax_t;
@@ -289,9 +289,9 @@
 // MIPS:INT_FAST64_MAX_ 9223372036854775807LL
 // MIPS:UINT_FAST64_MAX_ 18446744073709551615ULL
 //
-// MIPS:INTPTR_MIN_ (-2147483647 -1)
-// MIPS:INTPTR_MAX_ 2147483647
-// MIPS:UINTPTR_MAX_ 4294967295U
+// MIPS:INTPTR_MIN_ (-2147483647L -1)
+// MIPS:INTPTR_MAX_ 2147483647L
+// MIPS:UINTPTR_MAX_ 4294967295UL
 // MIPS:PTRDIFF_MIN_ (-2147483647 -1)
 // MIPS:PTRDIFF_MAX_ 2147483647
 // MIPS:SIZE_MAX_ 4294967295U
@@ -350,8 +350,8 @@
 // MIPS64:typedef int8_t int_fast8_t;
 // MIPS64:typedef uint8_t uint_fast8_t;
 //
-// MIPS64:typedef int64_t intptr_t;
-// MIPS64:typedef uint64_t uintptr_t;
+// MIPS64:typedef long int intptr_t;
+// MIPS64:typedef long unsigned int uintptr_t;
 //
 // MIPS64:typedef long int intmax_t;
 // MIPS64:typedef long unsigned int uintmax_t;
@@ -450,8 +450,8 @@
 // MSP430:typedef int8_t int_fast8_t;
 // MSP430:typedef uint8_t uint_fast8_t;
 //
-// MSP430:typedef int16_t intptr_t;
-// MSP430:typedef uint16_t uintptr_t;
+// MSP430:typedef int intptr_t;
+// MSP430:typedef unsigned int uintptr_t;
 //
 // MSP430:typedef long long int intmax_t;
 // MSP430:typedef long long unsigned int uintmax_t;
@@ -557,8 +557,8 @@
 // PPC64:typedef int8_t int_fast8_t;
 // PPC64:typedef uint8_t uint_fast8_t;
 //
-// PPC64:typedef int64_t intptr_t;
-// PPC64:typedef uint64_t uintptr_t;
+// PPC64:typedef long int intptr_t;
+// PPC64:typedef long unsigned int uintptr_t;
 //
 // PPC64:typedef long int intmax_t;
 // PPC64:typedef long unsigned int uintmax_t;
@@ -664,8 +664,8 @@
 // PPC64-NETBSD:typedef int8_t int_fast8_t;
 // PPC64-NETBSD:typedef uint8_t uint_fast8_t;
 //
-// PPC64-NETBSD:typedef int64_t intptr_t;
-// PPC64-NETBSD:typedef uint64_t uintptr_t;
+// PPC64-NETBSD:typedef long int intptr_t;
+// PPC64-NETBSD:typedef long unsigned int uintptr_t;
 //
 // PPC64-NETBSD:typedef long long int intmax_t;
 // PPC64-NETBSD:typedef long long unsigned int uintmax_t;
@@ -710,12 +710,12 @@
 // PPC64-NETBSD:INT_FAST64_MAX_ 9223372036854775807LL
 // PPC64-NETBSD:UINT_FAST64_MAX_ 18446744073709551615ULL
 //
-// PPC64-NETBSD:INTPTR_MIN_ (-9223372036854775807LL -1)
-// PPC64-NETBSD:INTPTR_MAX_ 9223372036854775807LL
-// PPC64-NETBSD:UINTPTR_MAX_ 18446744073709551615ULL
-// PPC64-NETBSD:PTRDIFF_MIN_ (-9223372036854775807LL -1)
-// PPC64-NETBSD:PTRDIFF_MAX_ 9223372036854775807LL
-// PPC64-NETBSD:SIZE_MAX_ 18446744073709551615ULL
+// PPC64-NETBSD:INTPTR_MIN_ (-9223372036854775807L -1)
+// PPC64-NETBSD:INTPTR_MAX_ 9223372036854775807L
+// PPC64-NETBSD:UINTPTR_MAX_ 18446744073709551615UL
+// PPC64-NETBSD:PTRDIFF_MIN_ (-9223372036854775807L -1)
+// PPC64-NETBSD:PTR

r301066 - Rearrange some Modules TS testcases into test/CXX/modules-ts.

2017-04-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Apr 21 19:47:53 2017
New Revision: 301066

URL: http://llvm.org/viewvc/llvm-project?rev=301066&view=rev
Log:
Rearrange some Modules TS testcases into test/CXX/modules-ts.

Added:
cfe/trunk/test/CXX/modules-ts/
cfe/trunk/test/CXX/modules-ts/basic/
cfe/trunk/test/CXX/modules-ts/basic/basic.link/
cfe/trunk/test/CXX/modules-ts/basic/basic.link/module-declaration.cpp
  - copied, changed from r301056, 
cfe/trunk/test/Parser/cxx-modules-import.cpp
cfe/trunk/test/CXX/modules-ts/codegen-basics.cppm
  - copied unchanged from r301056, cfe/trunk/test/CodeGenCXX/modules-ts.cppm
cfe/trunk/test/CXX/modules-ts/dcl.dcl/
cfe/trunk/test/CXX/modules-ts/dcl.dcl/dcl.module/
cfe/trunk/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/
cfe/trunk/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/
cfe/trunk/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.import/p1.cpp
  - copied, changed from r301056, 
cfe/trunk/test/Parser/cxx-modules-import.cpp
cfe/trunk/test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/
Removed:
cfe/trunk/test/CodeGenCXX/modules-ts.cppm
cfe/trunk/test/Parser/cxx-modules-import.cpp

Copied: cfe/trunk/test/CXX/modules-ts/basic/basic.link/module-declaration.cpp 
(from r301056, cfe/trunk/test/Parser/cxx-modules-import.cpp)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/modules-ts/basic/basic.link/module-declaration.cpp?p2=cfe/trunk/test/CXX/modules-ts/basic/basic.link/module-declaration.cpp&p1=cfe/trunk/test/Parser/cxx-modules-import.cpp&r1=301056&r2=301066&rev=301066&view=diff
==
--- cfe/trunk/test/Parser/cxx-modules-import.cpp (original)
+++ cfe/trunk/test/CXX/modules-ts/basic/basic.link/module-declaration.cpp Fri 
Apr 21 19:47:53 2017
@@ -1,3 +1,5 @@
+// Tests for module-declaration syntax.
+//
 // RUN: rm -rf %t
 // RUN: mkdir -p %t
 // RUN: echo 'export module x; int a, b;' > %t/x.cppm
@@ -6,55 +8,48 @@
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface %t/x.cppm -o 
%t/x.pcm
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -emit-module-interface 
-fmodule-file=%t/x.pcm %t/x.y.cppm -o %t/x.y.pcm
 //
+// Module implementation for unknown and known module. (The former is 
ill-formed.)
+// FIXME: TEST=1 should fail because we don't have an interface for module z.
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm 
-verify %s \
 // RUN:-DTEST=1 -DEXPORT= -DPARTITION= -DMODULE_NAME=z
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm 
-verify %s \
 // RUN:-DTEST=2 -DEXPORT= -DPARTITION= -DMODULE_NAME=x
+//
+// Module interface for unknown and known module. (The latter is ill-formed 
due to
+// redefinition.)
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm 
-verify %s \
 // RUN:-DTEST=3 -DEXPORT=export -DPARTITION= -DMODULE_NAME=z
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm 
-verify %s \
-// RUN:-DTEST=4 -DEXPORT=export -DPARTITION=partition 
-DMODULE_NAME=z
+// RUN:-DTEST=4 -DEXPORT=export -DPARTITION= -DMODULE_NAME=x
+//
+// Defining a module partition.
+// RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm 
-verify %s \
+// RUN:-DTEST=5 -DEXPORT=export -DPARTITION=partition 
-DMODULE_NAME=z
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm 
-verify %s \
-// RUN:-DTEST=5 -DEXPORT= -DPARTITION=elderberry -DMODULE_NAME=z
+// RUN:-DTEST=6 -DEXPORT= -DPARTITION=partition -DMODULE_NAME=z
+//
+// Miscellaneous syntax.
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm 
-verify %s \
-// RUN:-DTEST=1 -DEXPORT= -DPARTITION= -DMODULE_NAME='z [[]]'
+// RUN:-DTEST=7 -DEXPORT= -DPARTITION=elderberry -DMODULE_NAME=z
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm 
-verify %s \
-// RUN:-DTEST=6 -DEXPORT= -DPARTITION= -DMODULE_NAME='z [[fancy]]'
+// RUN:-DTEST=8 -DEXPORT= -DPARTITION= -DMODULE_NAME='z [[]]'
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm 
-verify %s \
-// RUN:-DTEST=7 -DEXPORT= -DPARTITION= -DMODULE_NAME='z 
[[maybe_unused]]'
+// RUN:-DTEST=9 -DEXPORT= -DPARTITION= -DMODULE_NAME='z [[fancy]]'
 // RUN: %clang_cc1 -std=c++1z -fmodules-ts -I%t -fmodule-file=%t/x.y.pcm 
-verify %s \
-// RUN:-DTEST=8 -DEXPORT= -DPARTITION=partition -DMODULE_NAME=z
+// RUN:-DTEST=10 -DEXPORT= -DPARTITION= -DMODULE_NAME='z 
[[maybe_unused]]'
 
 EXPORT module PARTITION MODULE_NAME;
-#if TEST == 3 || TEST == 4
-// ok, building object code for module interface
-#elif TEST == 5
-// expected-error@-4 {{expected ';'}} expected-error@-4 {{requires a type 
specifier}}
+#if TEST == 4
+// expected-error@-2 {{redefinition of module 

[PATCH] D32199: [TySan] A Type Sanitizer (Clang)

2017-04-21 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel updated this revision to Diff 96264.
hfinkel added a comment.

Output metadata to provide the types of globals (similar to how Clang marks 
globals for asan).


https://reviews.llvm.org/D32199

Files:
  include/clang/Basic/Sanitizers.def
  include/clang/Driver/SanitizerArgs.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenTBAA.cpp
  lib/CodeGen/SanitizerMetadata.cpp
  lib/CodeGen/SanitizerMetadata.h
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/Linux.cpp
  lib/Lex/PPMacroExpansion.cpp
  test/CodeGen/sanitize-type-attr.cpp
  test/Driver/sanitizer-ld.c

Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -181,6 +181,18 @@
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ \
+// RUN: -fsanitize=type \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-TYSAN-LINUX-CXX %s
+//
+// CHECK-TYSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-TYSAN-LINUX-CXX-NOT: stdc++
+// CHECK-TYSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tysan-x86_64.a" "-no-whole-archive"
+// CHECK-TYSAN-LINUX-CXX: stdc++
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ \
 // RUN: -fsanitize=memory \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
Index: test/CodeGen/sanitize-type-attr.cpp
===
--- /dev/null
+++ test/CodeGen/sanitize-type-attr.cpp
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -fsanitize=type | FileCheck -check-prefix=TYSAN %s
+// RUN: echo "src:%s" | sed -e 's/\\//g' > %t
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -fsanitize=type -fsanitize-blacklist=%t | FileCheck -check-prefix=BL %s
+
+// The sanitize_type attribute should be attached to functions
+// when TypeSanitizer is enabled, unless no_sanitize("type") attribute
+// is present.
+
+// WITHOUT:  NoTYSAN1{{.*}}) [[NOATTR:#[0-9]+]]
+// BL:  NoTYSAN1{{.*}}) [[NOATTR:#[0-9]+]]
+// TYSAN:  NoTYSAN1{{.*}}) [[NOATTR:#[0-9]+]]
+__attribute__((no_sanitize("type")))
+int NoTYSAN1(int *a) { return *a; }
+
+// WITHOUT:  NoTYSAN2{{.*}}) [[NOATTR]]
+// BL:  NoTYSAN2{{.*}}) [[NOATTR]]
+// TYSAN:  NoTYSAN2{{.*}}) [[NOATTR]]
+__attribute__((no_sanitize("type")))
+int NoTYSAN2(int *a);
+int NoTYSAN2(int *a) { return *a; }
+
+// WITHOUT:  NoTYSAN3{{.*}}) [[NOATTR:#[0-9]+]]
+// BL:  NoTYSAN3{{.*}}) [[NOATTR:#[0-9]+]]
+// TYSAN:  NoTYSAN3{{.*}}) [[NOATTR:#[0-9]+]]
+__attribute__((no_sanitize("type")))
+int NoTYSAN3(int *a) { return *a; }
+
+// WITHOUT:  TYSANOk{{.*}}) [[NOATTR]]
+// BL:  TYSANOk{{.*}}) [[NOATTR]]
+// TYSAN: TYSANOk{{.*}}) [[WITH:#[0-9]+]]
+int TYSANOk(int *a) { return *a; }
+
+// WITHOUT:  TemplateTYSANOk{{.*}}) [[NOATTR]]
+// BL:  TemplateTYSANOk{{.*}}) [[NOATTR]]
+// TYSAN: TemplateTYSANOk{{.*}}) [[WITH]]
+template
+int TemplateTYSANOk() { return i; }
+
+// WITHOUT:  TemplateNoTYSAN{{.*}}) [[NOATTR]]
+// BL:  TemplateNoTYSAN{{.*}}) [[NOATTR]]
+// TYSAN: TemplateNoTYSAN{{.*}}) [[NOATTR]]
+template
+__attribute__((no_sanitize("type")))
+int TemplateNoTYSAN() { return i; }
+
+int force_instance = TemplateTYSANOk<42>()
+   + TemplateNoTYSAN<42>();
+
+// Check that __cxx_global_var_init* get the sanitize_type attribute.
+int global1 = 0;
+int global2 = *(int*)((char*)&global1+1);
+// WITHOUT: @__cxx_global_var_init{{.*}}[[NOATTR:#[0-9]+]]
+// BL: @__cxx_global_var_init{{.*}}[[NOATTR:#[0-9]+]]
+// TYSAN: @__cxx_global_var_init{{.*}}[[WITH:#[0-9]+]]
+
+// Make sure that we don't add globals to the list for which we don't have a
+// specific type description.
+struct SX { int a, b; };
+SX sx;
+
+// WITHOUT: attributes [[NOATTR]] = { noinline nounwind{{.*}} }
+
+// BL: attributes [[NOATTR]] = { noinline nounwind{{.*}} }
+
+// TYSAN: attributes [[NOATTR]] = { noinline nounwind{{.*}} }
+// TYSAN: attributes [[WITH]] = { noinline nounwind sanitize_type{{.*}} }
+
+// TYSAN-DAG: !llvm.tysan.globals = !{[[G1MD:![0-9]+]], [[G2MD:![0-9]+]], [[G3MD:![0-9]+]]}
+// TYSAN-DAG: [[G1MD]] = !{i32* @force_instance, [[INTMD:![0-9]+]]}
+// TYSAN-DAG: [[INTMD]] = !{!"int",
+// TYSAN-DAG: [[G2MD]] = !{i32* @global1, [[INTMD]]}
+// TYSAN-DAG: [[G3MD]] = !{i32* @global2, [[INTMD]]}
+// TYSAN-DAG: Simple C++ TBAA
+
Index: lib/Lex/PPMacroExpansion.cpp
=

[PATCH] D31542: [clang-tidy] Extend readability-container-size-empty to add comparisons to newly-constructed objects

2017-04-21 Thread Josh Zimmerman via Phabricator via cfe-commits
joshz added a comment.

Are there any further changes I should make, or is this good to submit now?

Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D31542



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


r301063 - Move Split DWARF handling to an MC option/command line argument rather than using metadata

2017-04-21 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Apr 21 18:35:36 2017
New Revision: 301063

URL: http://llvm.org/viewvc/llvm-project?rev=301063&view=rev
Log:
Move Split DWARF handling to an MC option/command line argument rather than 
using metadata

Since Split DWARF needs to name the actual .dwo file that is generated,
it can't be known at the time the llvm::Module is produced as it may be
merged with other Modules before the object is generated and that object
may be generated with any name.

By passing the Split DWARF file name when LLVM is producing object code
the .dwo file name in the object file can match correctly.

The support for Split DWARF for implicit modules remains the same -
using metadata to store the dwo name and dwo id so that potentially
multiple skeleton CUs referring to different dwo files can be generated
from one llvm::Module.

Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/split-debug-filename.c
cfe/trunk/test/Driver/split-debug.c

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=301063&r1=301062&r2=301063&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Apr 21 18:35:36 2017
@@ -573,6 +573,8 @@ def fblocks_runtime_optional : Flag<["-"
   HelpText<"Weakly link in the blocks runtime">;
 def fexternc_nounwind : Flag<["-"], "fexternc-nounwind">,
   HelpText<"Assume all functions with C linkage do not unwind">;
+def enable_split_dwarf : Flag<["-"], "enable-split-dwarf">,
+  HelpText<"Use split dwarf/Fission">;
 def split_dwarf_file : Separate<["-"], "split-dwarf-file">,
   HelpText<"File name to use for split dwarf debug info output">;
 def fno_wchar : Flag<["-"], "fno-wchar">,

Modified: cfe/trunk/include/clang/Frontend/CodeGenOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CodeGenOptions.def?rev=301063&r1=301062&r2=301063&view=diff
==
--- cfe/trunk/include/clang/Frontend/CodeGenOptions.def (original)
+++ cfe/trunk/include/clang/Frontend/CodeGenOptions.def Fri Apr 21 18:35:36 2017
@@ -199,6 +199,7 @@ CODEGENOPT(DebugTypeExtRefs, 1, 0) ///<
 CODEGENOPT(DebugExplicitImport, 1, 0)  ///< Whether or not debug info should
///< contain explicit imports for
///< anonymous namespaces
+CODEGENOPT(EnableSplitDwarf, 1, 0) ///< Whether to enable split DWARF
 CODEGENOPT(SplitDwarfInlining, 1, 1) ///< Whether to include inlining info in 
the
  ///< skeleton CU to allow for 
symbolication
 ///< of inline stack frames without .dwo 
files.

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=301063&r1=301062&r2=301063&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Apr 21 18:35:36 2017
@@ -407,6 +407,8 @@ static void initTargetOptions(llvm::Targ
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
 
+  if (CodeGenOpts.EnableSplitDwarf)
+Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
   Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
   Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
   Options.MCOptions.MCUseDwarfDirectory = !CodeGenOpts.NoDwarfDirectoryAsm;

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=301063&r1=301062&r2=301063&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 21 18:35:36 2017
@@ -528,12 +528,14 @@ void CGDebugInfo::CreateCompileUnit() {
   // Create new compile unit.
   // FIXME - Eliminate TheCU.
   TheCU = DBuilder.createCompileUnit(
-  LangTag, DBuilder.createFile(remapDIPath(MainFileName),
-   remapDIPath(getCurrentDirname()), CSKind,
-   Checksum),
+  LangTag,
+  DBuilder.createFile(remapDIPath(MainFileName),
+  remapDIPath(getCurrentDirname()), CSKind, Checksum),
   Producer, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers,
-  CGM.getCodeGenOpts().SplitDwarfF

[PATCH] D32064: [asan] Disable ASan global-GC depending on the target and compiler flags

2017-04-21 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D32064



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


[PATCH] D32064: [asan] Disable ASan global-GC depending on the target and compiler flags

2017-04-21 Thread Evgeniy Stepanov via Phabricator via cfe-commits
eugenis added a comment.

PTAL


Repository:
  rL LLVM

https://reviews.llvm.org/D32064



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


[PATCH] D32064: [asan] Disable ASan global-GC depending on the target and compiler flags

2017-04-21 Thread Evgeniy Stepanov via Phabricator via cfe-commits
eugenis updated this revision to Diff 96263.

Repository:
  rL LLVM

https://reviews.llvm.org/D32064

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/asan-globals-gc.cpp


Index: test/CodeGen/asan-globals-gc.cpp
===
--- /dev/null
+++ test/CodeGen/asan-globals-gc.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple 
x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple 
x86_64-windows-msvc -fdata-sections %s | FileCheck %s --check-prefix=WITH-GC
+
+int global;
+
+// WITH-GC-NOT: call void @__asan_register_globals
+// WITHOUT-GC: call void @__asan_register_globals
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -129,16 +129,20 @@
 // that we add to the PassManagerBuilder.
 class PassManagerBuilderWrapper : public PassManagerBuilder {
 public:
-  PassManagerBuilderWrapper(const CodeGenOptions &CGOpts,
+  PassManagerBuilderWrapper(const Triple &TargetTriple,
+const CodeGenOptions &CGOpts,
 const LangOptions &LangOpts)
-  : PassManagerBuilder(), CGOpts(CGOpts), LangOpts(LangOpts) {}
+  : PassManagerBuilder(), TargetTriple(TargetTriple), CGOpts(CGOpts),
+LangOpts(LangOpts) {}
+  const Triple &getTargetTriple() const { return TargetTriple; }
   const CodeGenOptions &getCGOpts() const { return CGOpts; }
   const LangOptions &getLangOpts() const { return LangOpts; }
+
 private:
+  const Triple &TargetTriple;
   const CodeGenOptions &CGOpts;
   const LangOptions &LangOpts;
 };
-
 }
 
 static void addObjCARCAPElimPass(const PassManagerBuilder &Builder, 
PassManagerBase &PM) {
@@ -185,16 +189,36 @@
   PM.add(createSanitizerCoverageModulePass(Opts));
 }
 
+// Check if ASan should use GC-friendly instrumentation for globals.
+// First of all, there is no point if -fdata-sections is off (expect for MachO,
+// where this is not a factor). Also, on ELF this feature requires an assembler
+// extension that only works with -integrated-as at the moment.
+static bool asanUseGlobalsGC(const Triple &T, const CodeGenOptions &CGOpts) {
+  switch (T.getObjectFormat()) {
+  case Triple::MachO:
+return true;
+  case Triple::COFF:
+return CGOpts.DataSections;
+  case Triple::ELF:
+return CGOpts.DataSections && !CGOpts.DisableIntegratedAS;
+  default:
+return false;
+  }
+}
+
 static void addAddressSanitizerPasses(const PassManagerBuilder &Builder,
   legacy::PassManagerBase &PM) {
   const PassManagerBuilderWrapper &BuilderWrapper =
   static_cast(Builder);
+  const Triple &T = BuilderWrapper.getTargetTriple();
   const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
   bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::Address);
   bool UseAfterScope = CGOpts.SanitizeAddressUseAfterScope;
+  bool UseGlobalsGC = asanUseGlobalsGC(T, CGOpts);
   PM.add(createAddressSanitizerFunctionPass(/*CompileKernel*/ false, Recover,
 UseAfterScope));
-  PM.add(createAddressSanitizerModulePass(/*CompileKernel*/false, Recover));
+  PM.add(createAddressSanitizerModulePass(/*CompileKernel*/ false, Recover,
+  UseGlobalsGC));
 }
 
 static void addKernelAddressSanitizerPasses(const PassManagerBuilder &Builder,
@@ -434,16 +458,16 @@
   if (CodeGenOpts.DisableLLVMPasses)
 return;
 
-  PassManagerBuilderWrapper PMBuilder(CodeGenOpts, LangOpts);
-
   // Figure out TargetLibraryInfo.  This needs to be added to MPM and FPM
   // manually (and not via PMBuilder), since some passes (eg. InstrProfiling)
   // are inserted before PMBuilder ones - they'd get the default-constructed
   // TLI with an unknown target otherwise.
   Triple TargetTriple(TheModule->getTargetTriple());
   std::unique_ptr TLII(
   createTLII(TargetTriple, CodeGenOpts));
 
+  PassManagerBuilderWrapper PMBuilder(TargetTriple, CodeGenOpts, LangOpts);
+
   // At O0 and O1 we only run the always inliner which is more efficient. At
   // higher optimization levels we run the normal inliner.
   if (CodeGenOpts.OptimizationLevel <= 1) {


Index: test/CodeGen/asan-globals-gc.cpp
===
--- /dev/null
+++ test/CodeGen/asan-globals-gc.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc -fdata-sections %s | FileCheck %s --check-prefix=WITH-GC
+
+int global;
+
+// WITH-GC-NOT: call void @__asan_register_globals
+// WITHOUT-GC: call void @__asan_register_globals
Index: lib/CodeGen/BackendUtil.cpp
==

[PATCH] D31561: cmath: Skip Libc for integral types in isinf, etc.

2017-04-21 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith closed this revision.
dexonsmith added a comment.

Committed in r301060.


https://reviews.llvm.org/D31561



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


[libcxx] r301060 - cmath: Skip Libc for integral types in isinf, etc.

2017-04-21 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Fri Apr 21 18:14:55 2017
New Revision: 301060

URL: http://llvm.org/viewvc/llvm-project?rev=301060&view=rev
Log:
cmath: Skip Libc for integral types in isinf, etc.

For std::isinf, the standard requires effectively calling isinf as
double from Libc for integral types. But integral types are never
infinite; we don't need to call Libc to return false.

Also short-circuit other functions where Libc won't have interesting
answers: signbit, fpclassify, isfinite, isnan, and isnormal.

I added correctness tests for integral types since we're no longer
deferring to Libc.

In review it was pointed out that in future revisions of the C++
standard we may add more types to std::is_arithmetic (e.g.,
std::is_fixed_point).  I'll leave it to a future commit to hack this to
allow using math functions on those.  We'll need to change things like
__libcpp_fpclassify anyway, so I'm not sure anything here would really
be future-proof.

https://reviews.llvm.org/D31561
rdar://problem/31361223

Modified:
libcxx/trunk/include/math.h
libcxx/trunk/test/std/numerics/c.math/cmath.pass.cpp

Modified: libcxx/trunk/include/math.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/math.h?rev=301060&r1=301059&r2=301060&view=diff
==
--- libcxx/trunk/include/math.h (original)
+++ libcxx/trunk/include/math.h Fri Apr 21 18:14:55 2017
@@ -307,6 +307,7 @@ long doubletruncl(long double x);
 extern "C++" {
 
 #include 
+#include 
 
 // signbit
 
@@ -324,22 +325,50 @@ __libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if::value, bool>::type
+typename std::enable_if::value, bool>::type
 signbit(_A1 __lcpp_x) _NOEXCEPT
 {
 return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x);
 }
 
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
+signbit(_A1 __lcpp_x) _NOEXCEPT
+{ return __lcpp_x < 0; }
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
+signbit(_A1) _NOEXCEPT
+{ return false; }
+
 #elif defined(_LIBCPP_MSVCRT)
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if::value, bool>::type
+typename std::enable_if::value, bool>::type
 signbit(_A1 __lcpp_x) _NOEXCEPT
 {
   return ::signbit(static_cast::type>(__lcpp_x));
 }
 
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+std::is_integral<_A1>::value && std::is_signed<_A1>::value, bool>::type
+signbit(_A1 __lcpp_x) _NOEXCEPT
+{ return __lcpp_x < 0; }
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+std::is_integral<_A1>::value && !std::is_signed<_A1>::value, bool>::type
+signbit(_A1) _NOEXCEPT
+{ return false; }
+
 #endif  // signbit
 
 // fpclassify
@@ -358,22 +387,34 @@ __libcpp_fpclassify(_A1 __lcpp_x) _NOEXC
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if::value, int>::type
+typename std::enable_if::value, int>::type
 fpclassify(_A1 __lcpp_x) _NOEXCEPT
 {
 return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x);
 }
 
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if::value, int>::type
+fpclassify(_A1 __lcpp_x) _NOEXCEPT
+{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
+
 #elif defined(_LIBCPP_MSVCRT)
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if::value, int>::type
+typename std::enable_if::value, bool>::type
 fpclassify(_A1 __lcpp_x) _NOEXCEPT
 {
   return ::fpclassify(static_cast::type>(__lcpp_x));
 }
 
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if::value, int>::type
+fpclassify(_A1 __lcpp_x) _NOEXCEPT
+{ return __lcpp_x == 0 ? FP_ZERO : FP_NORMAL; }
+
 #endif  // fpclassify
 
 // isfinite
@@ -392,12 +433,22 @@ __libcpp_isfinite(_A1 __lcpp_x) _NOEXCEP
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if::value, bool>::type
+typename std::enable_if<
+std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
+bool>::type
 isfinite(_A1 __lcpp_x) _NOEXCEPT
 {
 return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x);
 }
 
+template 
+inline _LIBCPP_INLINE_VISIBILITY
+typename std::enable_if<
+std::is_arithmetic<_A1>::value && !std::numeric_limits<_A1>::has_infinity,
+bool>::type
+isfinite(_A1) _NOEXCEPT
+{ return true; }
+
 #endif  // isfinite
 
 // isinf
@@ -416,12 +467,22 @@ __libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-typename std::enable_if::value, bool>::type
+typename std::enable_if<
+std::is_arithmetic<_A1>::value && std::numeric_limits<_A1>::has_infinity,
+bool>::type
 isinf(_A1 __lcpp_x) _NOEXCEPT
 {
 return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x);
 }
 
+template 
+inline _L

[PATCH] D31561: cmath: Skip Libc for integral types in isinf, etc.

2017-04-21 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Since I haven't heard from Marshall and Hal's fine with the less-future-proof 
std::is_floating_point, I'll commit that and we can iterate in tree.  Just 
running tests.


https://reviews.llvm.org/D31561



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


[PATCH] D32385: [libcxx] Implement LWG 2900 "The copy and move constructors of optional are not constexpr"

2017-04-21 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter created this revision.

.. by injecting base classes that differentiate between trivial/non-trivial 
implementation of each copy/move constructor/assignment. This actually goes a 
bit beyond the PR by also making the copy/move assignment operators trivial 
when the base type has corresponding trivial construction and assignment.


https://reviews.llvm.org/D32385

Files:
  include/optional
  test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
  test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp

Index: test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -10,7 +10,10 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(optional&& rhs);
+// constexpr optional(const optional&& rhs);
+//   If is_trivially_move_constructible_v is true,
+//this constructor shall be a constexpr constructor.
+
 
 #include 
 #include 
@@ -131,6 +134,31 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+{
+struct T {
+constexpr T(int) {}
+T(T&&) = default;
+};
+optional o1{};
+optional o2 = std::move(o1);
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = std::move(o3);
+static_cast(o4);
+}
+return true;
+}
 
 int main()
 {
@@ -198,4 +226,7 @@
 {
 test_reference_extension();
 }
+{
+static_assert(test_constexpr(), "");
+}
 }
Index: test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
===
--- test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -10,7 +10,9 @@
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // 
 
-// optional(const optional& rhs);
+// constexpr optional(const optional& rhs);
+//   If is_trivially_copy_constructible_v is true,
+//this constructor shall be a constexpr constructor.
 
 #include 
 #include 
@@ -104,6 +106,31 @@
 #endif
 }
 
+constexpr bool test_constexpr()
+{
+{
+using T = int;
+optional o1{};
+optional o2 = o1;
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = o3;
+static_cast(o4);
+}
+{
+struct T {
+constexpr T(int) {}
+};
+optional o1{};
+optional o2 = o1;
+static_cast(o2);
+optional o3{T{42}};
+optional o4 = o3;
+static_cast(o4);
+}
+return true;
+}
+
 int main()
 {
 test();
@@ -152,4 +179,7 @@
 {
 test_reference_extension();
 }
+{
+static_assert(test_constexpr(), "");
+}
 }
Index: include/optional
===
--- include/optional
+++ include/optional
@@ -436,46 +436,118 @@
 }
 };
 
-template ::value>
-struct __optional_storage;
-
-template 
-struct __optional_storage<_Tp, true> : __optional_storage_base<_Tp>
+template ::value>
+struct __optional_copy_base : __optional_storage_base<_Tp>
 {
 using __optional_storage_base<_Tp>::__optional_storage_base;
 };
 
 template 
-struct __optional_storage<_Tp, false> : __optional_storage_base<_Tp>
+struct __optional_copy_base<_Tp, false> : __optional_storage_base<_Tp>
 {
-using value_type = _Tp;
 using __optional_storage_base<_Tp>::__optional_storage_base;
 
 _LIBCPP_INLINE_VISIBILITY
-__optional_storage() = default;
+__optional_copy_base() = default;
 
 _LIBCPP_INLINE_VISIBILITY
-__optional_storage(const __optional_storage& __opt)
+__optional_copy_base(const __optional_copy_base& __opt)
 {
 this->__construct_from(__opt);
 }
 
 _LIBCPP_INLINE_VISIBILITY
-__optional_storage(__optional_storage&& __opt)
+__optional_copy_base(__optional_copy_base&&) = default;
+_LIBCPP_INLINE_VISIBILITY
+__optional_copy_base& operator=(const __optional_copy_base&) = default;
+_LIBCPP_INLINE_VISIBILITY
+__optional_copy_base& operator=(__optional_copy_base&&) = default;
+};
+
+template ::value>
+struct __optional_move_base : __optional_copy_base<_Tp>
+{
+using __optional_copy_base<_Tp>::__optional_copy_base;
+};
+
+template 
+struct __optional_move_base<_Tp, false> : __optional_copy_base<_Tp>
+{
+using value_type = _Tp;
+using __optional_copy_base<_Tp>::__optional_copy_base;
+
+_LIBCPP_INLINE_VISIBILITY
+__optional_move_base() = default;
+_LIBCPP_IN

r301056 - P0629R0: Switch to latest proposal for distinguishing module interface from implementation.

2017-04-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Apr 21 17:39:18 2017
New Revision: 301056

URL: http://llvm.org/viewvc/llvm-project?rev=301056&view=rev
Log:
P0629R0: Switch to latest proposal for distinguishing module interface from 
implementation.

This switches from the prototype syntax in P0273R0 ('module' and 'module
implementation') to the consensus syntax 'export module' and 'module'.

In passing, drop the "module declaration must be first" enforcement, since EWG
seems to have changed its mind on that.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGenCXX/modules-ts.cppm
cfe/trunk/test/Driver/modules-ts.cpp
cfe/trunk/test/Parser/cxx-modules-import.cpp
cfe/trunk/test/Parser/cxx-modules-interface.cppm
cfe/trunk/test/SemaCXX/modules-ts.cppm

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=301056&r1=301055&r2=301056&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri Apr 21 17:39:18 
2017
@@ -1114,14 +1114,12 @@ def err_pragma_cannot_end_force_cuda_hos
 } // end of Parse Issue category.
 
 let CategoryName = "Modules Issue" in {
-def err_expected_module_interface_decl : Error<
-  "expected module declaration at start of module interface">;
 def err_unexpected_module_decl : Error<
-  "module declaration must be the first declaration in the translation unit">;
+  "module declaration can only appear at the top level">;
 def err_module_expected_ident : Error<
-  "expected a module name after module%select{| import}0">;
-def err_unexpected_module_kind : Error<
-  "unexpected module kind %0; expected 'implementation' or 'partition'">;
+  "expected a module name after '%select{module|import}0'">;
+def err_module_implementation_partition : Error<
+  "module partition must be declared 'export'">;
 def err_attribute_not_module_attr : Error<
   "%0 attribute cannot be applied to a module">;
 def err_attribute_not_import_attr : Error<

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=301056&r1=301055&r2=301056&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Apr 21 17:39:18 
2017
@@ -8801,9 +8801,11 @@ def err_invalid_type_for_program_scope_v
 }
 
 let CategoryName = "Modules Issue" in {
+def err_module_decl_in_module_map_module : Error<
+  "'module' declaration found while building module from module map">;
 def err_module_interface_implementation_mismatch : Error<
-  "%select{'module'|'module partition'|'module implementation'}0 declaration "
-  "found while %select{not |not |}0building module interface">;
+  "missing 'export' specifier in 'module' declaration while "
+  "building module interface">;
 def err_current_module_name_mismatch : Error<
   "module name '%0' specified on command line does not match name of module">;
 def err_module_redefinition : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=301056&r1=301055&r2=301056&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Apr 21 17:39:18 2017
@@ -1934,7 +1934,8 @@ public:
 
   /// The parser has processed a module-declaration that begins the definition
   /// of a module interface or implementation.
-  DeclGroupPtrTy ActOnModuleDecl(SourceLocation ModuleLoc, ModuleDeclKind MDK,
+  DeclGroupPtrTy ActOnModuleDecl(SourceLocation StartLoc,
+ SourceLocation ModuleLoc, ModuleDeclKind MDK,
  ModuleIdPath Path);
 
   /// \brief The parser has processed a module import declaration.

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=301056&r1=301055&r2=301056&view=diff
==
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Fri Apr 21 17:39:18 2017
@@ -534,23 +534,6 @@ void Parser::LateTemplateParserCleanupCa
 }
 
 bool Parser::ParseFirstTopLevelDecl(DeclGroupPtrTy &Result) {
-  // C++ Modules TS: module-declaration must be the first declaration in the
-  // file. (There can be no preceding preprocessor directives, but we expect
-  // the lexer to check that.)

[libcxx] r301055 - Expand test coverage for LWG2857

2017-04-21 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Fri Apr 21 17:38:59 2017
New Revision: 301055

URL: http://llvm.org/viewvc/llvm-project?rev=301055&view=rev
Log:
Expand test coverage for LWG2857

* Cover optional's emplace-from-initializer_list overload

* Verify that any::emplace and optional::emplace return a reference to the 
correct type even for throwing cases.

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

Modified:
libcxx/trunk/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp

Modified: 
libcxx/trunk/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp?rev=301055&r1=301054&r2=301055&view=diff
==
--- 
libcxx/trunk/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp 
Fri Apr 21 17:38:59 2017
@@ -44,7 +44,7 @@ void test_emplace_type() {
 
 auto &v = a.emplace();
 static_assert( std::is_same_v, "" );
-   assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assert(Type::count == 1);
@@ -60,7 +60,7 @@ void test_emplace_type() {
 
 auto &v = a.emplace(101);
 static_assert( std::is_same_v, "" );
-   assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assert(Type::count == 1);
@@ -76,7 +76,7 @@ void test_emplace_type() {
 
 auto &v = a.emplace(-1, 42, -1);
 static_assert( std::is_same_v, "" );
-   assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assert(Type::count == 1);
@@ -97,7 +97,7 @@ void test_emplace_type_tracked() {
 assert(Tracked::count == 1);
 auto &v = a.emplace();
 static_assert( std::is_same_v, "" );
-   assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assertArgsMatch(a);
@@ -107,7 +107,7 @@ void test_emplace_type_tracked() {
 assert(Tracked::count == 1);
 auto &v = a.emplace(-1, 42, -1);
 static_assert( std::is_same_v, "" );
-   assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assertArgsMatch(a);
@@ -118,7 +118,7 @@ void test_emplace_type_tracked() {
 assert(Tracked::count == 1);
 auto &v = a.emplace({-1, 42, -1});
 static_assert( std::is_same_v, "" );
-   assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assertArgsMatch>(a);
@@ -129,7 +129,7 @@ void test_emplace_type_tracked() {
 assert(Tracked::count == 1);
 auto &v = a.emplace({-1, 42, -1}, x);
 static_assert( std::is_same_v, "" );
-   assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assertArgsMatch, int&>(a);
@@ -159,7 +159,8 @@ void test_emplace_throws()
 std::any a(small{42});
 assert(small::count == 1);
 try {
-a.emplace(101);
+auto &v = a.emplace(101);
+static_assert( std::is_same_v, "" );
 assert(false);
 } catch (int const&) {
 }
@@ -169,7 +170,8 @@ void test_emplace_throws()
 std::any a(small{42});
 assert(small::count == 1);
 try {
-a.emplace({1, 2, 3}, 101);
+auto &v = a.emplace({1, 2, 3}, 101);
+static_assert( std::is_same_v, "" );
 assert(false);
 } catch (int const&) {
 }
@@ -180,7 +182,8 @@ void test_emplace_throws()
 std::any a(large{42});
 assert(large::count == 1);
 try {
-a.emplace(101);
+auto &v = a.emplace(101);
+static_assert( std::is_same_v, "" );
 assert(false);
 } catch (int const&) {
 }
@@ -190,7 +193,8 @@ void test_emplace_throws()
 std::any a(large{42});
 assert(large::count == 1);
 try {
-a.emplace({1, 2, 3}, 101);
+auto &v = a.emplace({1, 2, 3}, 101);
+static_assert( std::is_same_v, "" );
 assert(false);
 } catch (int const&) {
 }

Modified: 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilitie

[PATCH] D32106: [libcxx][test] Expand LWG2857 coverage

2017-04-21 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL301055: Expand test coverage for LWG2857 (authored by 
CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D32106?vs=95368&id=96260#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32106

Files:
  libcxx/trunk/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp
  
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
  
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp

Index: libcxx/trunk/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp
===
--- libcxx/trunk/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp
+++ libcxx/trunk/test/std/utilities/any/any.class/any.modifiers/emplace.pass.cpp
@@ -44,7 +44,7 @@
 
 auto &v = a.emplace();
 static_assert( std::is_same_v, "" );
-		assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assert(Type::count == 1);
@@ -60,7 +60,7 @@
 
 auto &v = a.emplace(101);
 static_assert( std::is_same_v, "" );
-		assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assert(Type::count == 1);
@@ -76,7 +76,7 @@
 
 auto &v = a.emplace(-1, 42, -1);
 static_assert( std::is_same_v, "" );
-		assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assert(Type::count == 1);
@@ -97,7 +97,7 @@
 assert(Tracked::count == 1);
 auto &v = a.emplace();
 static_assert( std::is_same_v, "" );
-		assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assertArgsMatch(a);
@@ -107,7 +107,7 @@
 assert(Tracked::count == 1);
 auto &v = a.emplace(-1, 42, -1);
 static_assert( std::is_same_v, "" );
-		assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assertArgsMatch(a);
@@ -118,7 +118,7 @@
 assert(Tracked::count == 1);
 auto &v = a.emplace({-1, 42, -1});
 static_assert( std::is_same_v, "" );
-		assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assertArgsMatch>(a);
@@ -129,7 +129,7 @@
 assert(Tracked::count == 1);
 auto &v = a.emplace({-1, 42, -1}, x);
 static_assert( std::is_same_v, "" );
-		assert(&v == std::any_cast(&a));
+assert(&v == std::any_cast(&a));
 
 assert(Tracked::count == 0);
 assertArgsMatch, int&>(a);
@@ -159,7 +159,8 @@
 std::any a(small{42});
 assert(small::count == 1);
 try {
-a.emplace(101);
+auto &v = a.emplace(101);
+static_assert( std::is_same_v, "" );
 assert(false);
 } catch (int const&) {
 }
@@ -169,7 +170,8 @@
 std::any a(small{42});
 assert(small::count == 1);
 try {
-a.emplace({1, 2, 3}, 101);
+auto &v = a.emplace({1, 2, 3}, 101);
+static_assert( std::is_same_v, "" );
 assert(false);
 } catch (int const&) {
 }
@@ -180,7 +182,8 @@
 std::any a(large{42});
 assert(large::count == 1);
 try {
-a.emplace(101);
+auto &v = a.emplace(101);
+static_assert( std::is_same_v, "" );
 assert(false);
 } catch (int const&) {
 }
@@ -190,7 +193,8 @@
 std::any a(large{42});
 assert(large::count == 1);
 try {
-a.emplace({1, 2, 3}, 101);
+auto &v = a.emplace({1, 2, 3}, 101);
+static_assert( std::is_same_v, "" );
 assert(false);
 } catch (int const&) {
 }
Index: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
===
--- libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
+++ libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace.pass.cpp
@@ -254,7 +254,9 @@
 {
 assert(static_cast(opt) == true);
 assert(Y::dtor_called == false);
-opt.emplace(1);
+auto &v = opt.emplace(1);
+static_assert( std::is_same_v, "" );
+assert(false);
 }
 catch (int i)
 {
Index: libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
===
--- libcxx/trunk/test/std/utilities/optional/opti

[PATCH] D31830: Emit invariant.group.barrier when using union field

2017-04-21 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 96255.
Prazek added a comment.

- format


https://reviews.llvm.org/D31830

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenCXX/strict-vtable-pointers.cpp

Index: test/CodeGenCXX/strict-vtable-pointers.cpp
===
--- test/CodeGenCXX/strict-vtable-pointers.cpp
+++ test/CodeGenCXX/strict-vtable-pointers.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -disable-llvm-passes -O2 -emit-llvm -o %t.ll
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -std=c++11 -disable-llvm-passes -O2 -emit-llvm -o %t.ll
 // RUN: FileCheck --check-prefix=CHECK-CTORS %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-NEW %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-DTORS %s < %t.ll
@@ -180,6 +180,82 @@
 // CHECK-CTORS-NOT: @llvm.invariant.group.barrier(
 // CHECK-CTORS-LABEL: {{^}}}
 
+struct A {
+  virtual void foo();
+};
+struct B : A {
+  virtual void foo();
+};
+
+union U {
+  A a;
+  B b;
+};
+
+void changeToB(U *u);
+void changeToA(U *u);
+
+void g2(A *a) {
+  a->foo();
+}
+// We have to guard access to union fields with invariant.group, because
+// it is very easy to skip the barrier with unions. In this example the inlined
+// g2 will produce loads with the same !invariant.group metadata, and
+// u->a and u->b would use the same pointer.
+// CHECK-NEW-LABEL: define void @_Z14UnionsBarriersP1U
+void UnionsBarriers(U *u) {
+  // CHECK-NEW: call void @_Z9changeToBP1U(
+  changeToB(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z2g2P1A(%struct.A*
+  g2(&u->b);
+  // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* %6)
+  changeToA(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // call void @_Z2g2P1A(%struct.A* %a)
+  g2(&u->a);
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+}
+
+struct HoldingVirtuals {
+  A a;
+};
+
+struct Empty {};
+struct AnotherEmpty {
+  Empty e;
+};
+union NoVptrs {
+  int a;
+  AnotherEmpty empty;
+};
+void take(AnotherEmpty &);
+
+// CHECK-NEW-LABEL: noBarriers
+void noBarriers(NoVptrs &noVptrs) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  noVptrs.a += 42;
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR12AnotherEmpty(
+  take(noVptrs.empty);
+}
+
+union U2 {
+  HoldingVirtuals h;
+  int z;
+};
+void take(HoldingVirtuals &);
+
+// CHECK-NEW-LABEL: define void @_Z15UnionsBarriers2R2U2
+void UnionsBarriers2(U2 &u) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  u.z += 42;
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR15HoldingVirtuals(
+  take(u.h);
+}
 
 /** DTORS **/
 // CHECK-DTORS-LABEL: define linkonce_odr void @_ZN10StaticBaseD2Ev(
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -3513,6 +3513,22 @@
   return CGF.Builder.CreateStructGEP(base, idx, offset, field->getName());
 }
 
+static bool hasAnyVptr(const CXXRecordDecl *RD, const ASTContext &Context) {
+  if (RD->isDynamicClass())
+return true;
+
+  for (const FieldDecl *Field : RD->fields()) {
+QualType FieldType = Context.getBaseElementType(Field->getType());
+const RecordType *RT = FieldType->getAs();
+if (!RT)
+  continue;
+auto *FieldClassDecl = cast(RT->getDecl());
+if (hasAnyVptr(FieldClassDecl, Context))
+  return true;
+  }
+  return false;
+}
+
 LValue CodeGenFunction::EmitLValueForField(LValue base,
const FieldDecl *field) {
   AlignmentSource fieldAlignSource =
@@ -3552,6 +3568,15 @@
 assert(!type->isReferenceType() && "union has reference member");
 // TODO: handle path-aware TBAA for union.
 TBAAPath = false;
+
+const auto *RD = field->getType().getTypePtr()->getAsCXXRecordDecl();
+if (CGM.getCodeGenOpts().StrictVTablePointers &&
+CGM.getCodeGenOpts().OptimizationLevel > 0 && RD &&
+hasAnyVptr(RD, getContext()))
+  // Because unions can easily skip invariant.barriers, we need to add
+  // a barrier every time CXXRecord field with vptr is referenced.
+  addr = Address(Builder.CreateInvariantGroupBarrier(addr.getPointer()),
+ addr.getAlignment());
   } else {
 // For structs, we GEP to the field that the record layout suggests.
 addr = emitAddrOfFieldStorage(*this, addr, field);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31830: Emit invariant.group.barrier when using union field

2017-04-21 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek marked 6 inline comments as done.
Prazek added a comment.

For now I will check if it has any vptrs. It will be probably soon stored in 
the CXXRecordDecl because it will be used much more frequently when generating 
barriers for pointer casts.


https://reviews.llvm.org/D31830



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


[PATCH] D31830: Emit invariant.group.barrier when using union field

2017-04-21 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek updated this revision to Diff 96254.
Prazek added a comment.

- Checking for vptrs


https://reviews.llvm.org/D31830

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGenCXX/strict-vtable-pointers.cpp

Index: test/CodeGenCXX/strict-vtable-pointers.cpp
===
--- test/CodeGenCXX/strict-vtable-pointers.cpp
+++ test/CodeGenCXX/strict-vtable-pointers.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -disable-llvm-passes -O2 -emit-llvm -o %t.ll
+// RUN: %clang_cc1 %s -I%S -triple=x86_64-apple-darwin10 -fstrict-vtable-pointers -std=c++11 -disable-llvm-passes -O2 -emit-llvm -o %t.ll
 // RUN: FileCheck --check-prefix=CHECK-CTORS %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-NEW %s < %t.ll
 // RUN: FileCheck --check-prefix=CHECK-DTORS %s < %t.ll
@@ -180,6 +180,80 @@
 // CHECK-CTORS-NOT: @llvm.invariant.group.barrier(
 // CHECK-CTORS-LABEL: {{^}}}
 
+struct A {
+  virtual void foo();
+};
+struct B : A {
+  virtual void foo();
+};
+
+union U {
+  A a;
+  B b;
+};
+
+void changeToB(U *u);
+void changeToA(U *u);
+
+void g2(A *a) {
+  a->foo();
+}
+// We have to guard access to union fields with invariant.group, because
+// it is very easy to skip the barrier with unions. In this example the inlined
+// g2 will produce loads with the same !invariant.group metadata, and
+// u->a and u->b would use the same pointer.
+// CHECK-NEW-LABEL: define void @_Z14UnionsBarriersP1U
+void UnionsBarriers(U *u) {
+  // CHECK-NEW: call void @_Z9changeToBP1U(
+  changeToB(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z2g2P1A(%struct.A*
+  g2(&u->b);
+  // CHECK-NEW: call void @_Z9changeToAP1U(%union.U* %6)
+  changeToA(u);
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // call void @_Z2g2P1A(%struct.A* %a)
+  g2(&u->a);
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+}
+
+struct HoldingVirtuals {
+  A a;
+};
+
+struct Empty {};
+struct AnotherEmpty { Empty e; };
+union NoVptrs {
+  int a;
+  AnotherEmpty empty;
+};
+void take(AnotherEmpty &);
+
+// CHECK-NEW-LABEL: noBarriers
+void noBarriers(NoVptrs &noVptrs) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  noVptrs.a += 42;
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR12AnotherEmpty(
+  take(noVptrs.empty);
+}
+
+union U2 {
+  HoldingVirtuals h;
+  int z;
+};
+void take(HoldingVirtuals &);
+
+// CHECK-NEW-LABEL: define void @_Z15UnionsBarriers2R2U2
+void UnionsBarriers2(U2 &u) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: 42
+  u.z += 42;
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: call void @_Z4takeR15HoldingVirtuals(
+  take(u.h);
+}
 
 /** DTORS **/
 // CHECK-DTORS-LABEL: define linkonce_odr void @_ZN10StaticBaseD2Ev(
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -3513,6 +3513,22 @@
   return CGF.Builder.CreateStructGEP(base, idx, offset, field->getName());
 }
 
+static bool hasAnyVptr(const CXXRecordDecl *RD, const ASTContext &Context) {
+  if (RD->isDynamicClass())
+return true;
+
+  for (const FieldDecl *Field : RD->fields()) {
+QualType FieldType = Context.getBaseElementType(Field->getType());
+const RecordType* RT = FieldType->getAs();
+if (!RT)
+  continue;
+auto *FieldClassDecl = cast(RT->getDecl());
+if (hasAnyVptr(FieldClassDecl, Context))
+  return true;
+  }
+  return false;
+}
+
 LValue CodeGenFunction::EmitLValueForField(LValue base,
const FieldDecl *field) {
   AlignmentSource fieldAlignSource =
@@ -3552,6 +3568,15 @@
 assert(!type->isReferenceType() && "union has reference member");
 // TODO: handle path-aware TBAA for union.
 TBAAPath = false;
+
+const auto *RD = field->getType().getTypePtr()->getAsCXXRecordDecl();
+if (CGM.getCodeGenOpts().StrictVTablePointers &&
+CGM.getCodeGenOpts().OptimizationLevel > 0 &&
+RD && hasAnyVptr(RD, getContext()))
+  // Because unions can easily skip invariant.barriers, we need to add
+  // a barrier every time CXXRecord field with vptr is referenced.
+  addr = Address(Builder.CreateInvariantGroupBarrier(addr.getPointer()),
+ addr.getAlignment());
   } else {
 // For structs, we GEP to the field that the record layout suggests.
 addr = emitAddrOfFieldStorage(*this, addr, field);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32378: Insert invariant.group.barrier for pointers comparisons

2017-04-21 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/CodeGen/CGExprScalar.cpp:3066-3067
+} else { // Unsigned integers and pointers.
+  if (CGF.CGM.getCodeGenOpts().StrictVTablePointers &&
+  CGF.CGM.getCodeGenOpts().OptimizationLevel > 0) {
+// Based on comparisons of pointers to dynamic objects, the optimizer

I think we need to do this regardless of optimization level -- if we LTO 
together a -O0 translation unit with a -O2 translation unit, we still need this 
protection for the comparisons in the -O0 TU.

(IIRC we chose to make -fstrict-vtable-pointers an IR-level ABI break, but we 
shouldn't do the same thing for optimization level.)


https://reviews.llvm.org/D32378



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


r301051 - [index] Take into account the category's external_symbol attr for namespacing its methods

2017-04-21 Thread Argyrios Kyrtzidis via cfe-commits
Author: akirtzidis
Date: Fri Apr 21 17:27:06 2017
New Revision: 301051

URL: http://llvm.org/viewvc/llvm-project?rev=301051&view=rev
Log:
[index] Take into account the category's external_symbol attr for namespacing 
its methods

Modified:
cfe/trunk/include/clang/Index/USRGeneration.h
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/test/Index/Core/external-source-symbol-attr.m

Modified: cfe/trunk/include/clang/Index/USRGeneration.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/USRGeneration.h?rev=301051&r1=301050&r2=301051&view=diff
==
--- cfe/trunk/include/clang/Index/USRGeneration.h (original)
+++ cfe/trunk/include/clang/Index/USRGeneration.h Fri Apr 21 17:27:06 2017
@@ -31,7 +31,8 @@ bool generateUSRForDecl(const Decl *D, S
 
 /// \brief Generate a USR fragment for an Objective-C class.
 void generateUSRForObjCClass(StringRef Cls, raw_ostream &OS,
- StringRef ExtSymbolDefinedIn = "");
+ StringRef ExtSymbolDefinedIn = "",
+ StringRef CategoryContextExtSymbolDefinedIn = "");
 
 /// \brief Generate a USR fragment for an Objective-C class category.
 void generateUSRForObjCCategory(StringRef Cls, StringRef Cat, raw_ostream &OS,
@@ -58,6 +59,9 @@ void generateUSRForObjCProtocol(StringRe
 void generateUSRForGlobalEnum(StringRef EnumName, raw_ostream &OS,
   StringRef ExtSymbolDefinedIn = "");
 
+/// Generate a USR fragment for an enum constant.
+void generateUSRForEnumConstant(StringRef EnumConstantName, raw_ostream &OS);
+
 /// \brief Generate a USR for a macro, including the USR prefix.
 ///
 /// \returns true on error, false on success.

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=301051&r1=301050&r2=301051&view=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Fri Apr 21 17:27:06 2017
@@ -88,7 +88,8 @@ public:
   void VisitNamespaceAliasDecl(const NamespaceAliasDecl *D);
   void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D);
   void VisitClassTemplateDecl(const ClassTemplateDecl *D);
-  void VisitObjCContainerDecl(const ObjCContainerDecl *CD);
+  void VisitObjCContainerDecl(const ObjCContainerDecl *CD,
+  const ObjCCategoryDecl *CatD = nullptr);
   void VisitObjCMethodDecl(const ObjCMethodDecl *MD);
   void VisitObjCPropertyDecl(const ObjCPropertyDecl *D);
   void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
@@ -138,8 +139,10 @@ public:
   /// itself.
 
   /// Generate a USR for an Objective-C class.
-  void GenObjCClass(StringRef cls, StringRef ext) {
-generateUSRForObjCClass(cls, Out, ext);
+  void GenObjCClass(StringRef cls, StringRef ExtSymDefinedIn,
+StringRef CategoryContextExtSymbolDefinedIn) {
+generateUSRForObjCClass(cls, Out, ExtSymDefinedIn,
+CategoryContextExtSymbolDefinedIn);
   }
 
   /// Generate a USR for an Objective-C class category.
@@ -383,7 +386,16 @@ void USRGenerator::VisitObjCMethodDecl(c
   IgnoreResults = true;
   return;
 }
-Visit(ID);
+auto getCategoryContext = [](const ObjCMethodDecl *D) ->
+const ObjCCategoryDecl * {
+  if (auto *CD = dyn_cast(D->getDeclContext()))
+return CD;
+  if (auto *ICD = dyn_cast(D->getDeclContext()))
+return ICD->getCategoryDecl();
+  return nullptr;
+};
+auto *CD = getCategoryContext(D);
+VisitObjCContainerDecl(ID, CD);
   }
   // Ideally we would use 'GenObjCMethod', but this is such a hot path
   // for Objective-C code that we don't want to use
@@ -392,13 +404,15 @@ void USRGenerator::VisitObjCMethodDecl(c
   << DeclarationName(D->getSelector());
 }
 
-void USRGenerator::VisitObjCContainerDecl(const ObjCContainerDecl *D) {
+void USRGenerator::VisitObjCContainerDecl(const ObjCContainerDecl *D,
+  const ObjCCategoryDecl *CatD) {
   switch (D->getKind()) {
 default:
   llvm_unreachable("Invalid ObjC container.");
 case Decl::ObjCInterface:
 case Decl::ObjCImplementation:
-  GenObjCClass(D->getName(), GetExternalSourceContainer(D));
+  GenObjCClass(D->getName(), GetExternalSourceContainer(D),
+   GetExternalSourceContainer(CatD));
   break;
 case Decl::ObjCCategory: {
   const ObjCCategoryDecl *CD = cast(D);
@@ -896,10 +910,26 @@ void USRGenerator::VisitTemplateArgument
 // USR generation functions.
 
//===--===//
 
+static void combineClassAndCategoryExtContainers(StringRef ClsSymDefinedIn,
+ StringRef CatS

[PATCH] D32378: Insert invariant.group.barrier for pointers comparsons

2017-04-21 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek created this revision.

This code was wrongly devirtualized before:

  A* a = new A;
  a->foo();
  A* b = new(a) B;
  
  if (a == b)
b->foo();

Now we insert barrier before comparing dynamic pointers.


https://reviews.llvm.org/D32378

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGenCXX/strict-vtable-pointers.cpp

Index: test/CodeGenCXX/strict-vtable-pointers.cpp
===
--- test/CodeGenCXX/strict-vtable-pointers.cpp
+++ test/CodeGenCXX/strict-vtable-pointers.cpp
@@ -237,6 +237,62 @@
   take(u.h);
 }
 
+// CHECK-NEW-LABEL: define void @_Z7comparev()
+void compare() {
+  A *a = new A;
+  a->foo();
+  // CHECK-NEW: call i8* @llvm.invariant.group.barrier(i8*
+  A *b = new (a) B;
+
+  // CHECK-NEW: %[[a:.*]] = call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: %[[a2:.*]] = bitcast i8* %[[a]] to %struct.A*
+  // CHECK-NEW: %[[b:.*]] = call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: %[[b2:.*]] = bitcast i8* %[[b]] to %struct.A*
+  // CHECK-NEW: %cmp = icmp eq %struct.A* %[[a2]], %[[b2]]
+  if (a == b)
+b->foo();
+}
+
+// CHECK-NEW-LABEL: compare2
+bool compare2(A *a, A *a2) {
+  // CHECK-NEW: %[[a:.*]] = call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: %[[a2:.*]] = bitcast i8* %[[a]] to %struct.A*
+  // CHECK-NEW: %[[b:.*]] = call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: %[[b2:.*]] = bitcast i8* %[[b]] to %struct.A*
+  // CHECK-NEW: %cmp = icmp ult %struct.A* %[[a2]], %[[b2]]
+  return a < a2;
+}
+// CHECK-NEW-LABEL: compareIntPointers
+bool compareIntPointers(int *a, int *b) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier
+  return a == b;
+}
+
+struct HoldingOtherVirtuals {
+  B b;
+};
+
+// There is no need to add barriers for comparision of pointer to classes
+// that are not dynamic.
+// CHECK-NEW-LABEL: compare5
+bool compare5(HoldingOtherVirtuals *a, HoldingOtherVirtuals *b) {
+  // CHECK-NEW-NOT: call i8* @llvm.invariant.group.barrier
+  return a == b;
+}
+
+struct X;
+// We have to also introduce the barriers if comparing pointers to incomplete
+// objects
+// CHECK-NEW-LABEL: define zeroext i1 @_Z8compare4P1XS0_
+bool compare4(X *x, X *x2) {
+  // CHECK-NEW: %[[x:.*]] = call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: %[[xp:.*]] = bitcast i8* %[[x]] to %struct.X*
+  // CHECK-NEW: %[[x2:.*]] = call i8* @llvm.invariant.group.barrier(i8*
+  // CHECK-NEW: %[[x2p:.*]] = bitcast i8* %[[x2]] to %struct.X*
+  // CHECK-NEW: %cmp = icmp eq %struct.X* %[[xp]], %[[x2p]]
+  return x == x2;
+}
+
 /** DTORS **/
 // CHECK-DTORS-LABEL: define linkonce_odr void @_ZN10StaticBaseD2Ev(
 // CHECK-DTORS-NOT: call i8* @llvm.invariant.group.barrier(
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -1698,7 +1698,7 @@
   }
 
   case CK_IntToOCLSampler:
-return CGF.CGM.createOpenCLIntToSamplerConversion(E, CGF);
+return CGF.CGM.createOpenCLIntToSamplerConversion(E, CGF);
 
   } // end of switch
 
@@ -3062,8 +3062,20 @@
   Result = Builder.CreateFCmp(FCmpOpc, LHS, RHS, "cmp");
 } else if (LHSTy->hasSignedIntegerRepresentation()) {
   Result = Builder.CreateICmp(SICmpOpc, LHS, RHS, "cmp");
-} else {
-  // Unsigned integers and pointers.
+} else { // Unsigned integers and pointers.
+  if (CGF.CGM.getCodeGenOpts().StrictVTablePointers &&
+  CGF.CGM.getCodeGenOpts().OptimizationLevel > 0) {
+// Based on comparisons of pointers to dynamic objects, the optimizer
+// can replace one pointer with another. This might result in
+// replacing pointer after barrier to pointer before barrier,
+// resulting in invalid devirtualization.
+if (auto *RD = LHSTy->getPointeeCXXRecordDecl())
+  if (!RD->isCompleteDefinition() || RD->isDynamicClass())
+LHS = Builder.CreateInvariantGroupBarrier(LHS);
+if (auto *RD = RHSTy->getPointeeCXXRecordDecl())
+  if (!RD->isCompleteDefinition() || RD->isDynamicClass())
+RHS = Builder.CreateInvariantGroupBarrier(RHS);
+  }
   Result = Builder.CreateICmp(UICmpOpc, LHS, RHS, "cmp");
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32064: [asan] Disable ASan global-GC depending on the target and compiler flags

2017-04-21 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

I think the only functional change here is for COFF, so you can add a CodeGen 
test that checks that metadata globals are created only if `-fdata-sections` is 
passed.


Repository:
  rL LLVM

https://reviews.llvm.org/D32064



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


[PATCH] D31856: Headers: Make the type of SIZE_MAX the same as size_t

2017-04-21 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D31856#733845, @efriedma wrote:

> We normally use stdint.h from the host C library, rather than our own 
> version; this file is only relevant in -ffreestanding mode.  So it should be 
> safe to change.


Agreed; r89237 (and nearby changes: r89221, r89224, r89226) are simply wrong. 
We cannot determine the correct types from the bitwidth alone; there may be 
multiple types with the relevant width and we must pick the right one. If we 
back out all of those changes and instead use the correct types as provided by 
`__*_TYPE__`, we should be able to remove the `__*_WIDTH__` macros too.


https://reviews.llvm.org/D31856



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


[PATCH] D32064: [asan] Disable ASan global-GC depending on the target and compiler flags

2017-04-21 Thread Evgeniy Stepanov via Phabricator via cfe-commits
eugenis added a comment.

what kind of test?


Repository:
  rL LLVM

https://reviews.llvm.org/D32064



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


[PATCH] D32371: Add comments to the diagnostic kinds in Diagnostic.td.

2017-04-21 Thread JohnniesnatoEB via Phabricator via cfe-commits
Johnniesnato added a comment.

0day Scene Albums House, Club, Dance, Minimal, Psy-Trance, Dubstep 
http://0daymusic.org


https://reviews.llvm.org/D32371



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


[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests

2017-04-21 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp:46
+std::gcd(static_cast(0), static_cast(0)))>::value, "");
+const bool result = static_cast>(out) ==
+std::gcd(static_cast(in1), static_cast(in2));

Is there a reason to recompute the type here rather than using `Output`?


https://reviews.llvm.org/D32309



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


[PATCH] D32064: [asan] Disable ASan global-GC depending on the target and compiler flags

2017-04-21 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Please add a test case.


Repository:
  rL LLVM

https://reviews.llvm.org/D32064



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


[PATCH] D32372: Arrays of unknown bound in constant expressions

2017-04-21 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

This needs testcases (the one from your summary plus the ones in my comments 
above would be good).




Comment at: lib/AST/ExprConstant.cpp:2622
   // Next subobject is an array element.
-  const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(ObjType);
-  assert(CAT && "vla in literal type?");
+  uint64_t actualIndex;
+  const ArrayType *AT = Info.Ctx.getAsArrayType(ObjType); // non-null by 
assumption

I think this should be named `ArrayBound` or similar.



Comment at: lib/AST/ExprConstant.cpp:2625-2626
+  if (I == 0) {
+/* we're dealing with the complete array object, which may have been 
declared
+   without a bound */
+actualIndex = Sub.MostDerivedArraySize;

Use line comments, start with capital letter, end with period, please.



Comment at: lib/AST/ExprConstant.cpp:2627
+   without a bound */
+actualIndex = Sub.MostDerivedArraySize;
+assert(Sub.MostDerivedIsArrayElement && "Complete object is an array, 
but isn't?");

This will not be the correct bound in general. This field is the array size of 
the *innermost* non-base-class subobject described by the designator, not the 
outermost one.

You could compute the correct bound here by going back to the `ValueDecl*` in 
the `CompleteObject` and checking its most recent declaration, but I think it 
would be preferable to do that when computing the type in `findCompleteObject` 
instead.

(It might seem possible to map to the most recent `VarDecl` when evaluating the 
`DeclRefExpr` instead, but that actually won't work in general, for cases like:

```
extern int arr[];
constexpr int *p = arr; // computes APValue referring to first declaration of 
'arr'
int arr[3];
constexpr int *q = p + 1; // should be accepted
```

... but `findCompleteObject` will happen late enough.)



Comment at: lib/AST/ExprConstant.cpp:5652-5653
 return false;
-} else {
+}
+else {
   Result.set(SubExpr, Info.CurrentCall->Index);

Per LLVM coding style, `else` goes on the same line as `}`.



Comment at: lib/AST/ExprConstant.cpp:5666
+else if (auto decl = Result.Base.dyn_cast()) {
+  // make sure to consider the completed type.
+  if (auto CAT = Info.Ctx.getAsConstantArrayType(cast(

Comments should start with a capital letter.



Comment at: lib/AST/ExprConstant.cpp:5670-5673
+  else {
+Result.Designator.setInvalid();
+CCEDiag(SubExpr, diag::note_constexpr_array_unknown_bound_decay);
+  }

Please suppress this diagnostic when 
`Info.checkingPotentialConstantExpression()`, since the expression is still 
potentially a constant expression. Example:

```
extern int arr[];
constexpr int *f() { return arr + 3; }
int arr[5];
constexpr int *p = f();
```

Here, when we check that the body of `f()` is valid, we need to ignore the fact 
that we don't know the array bound, since it could become known later.



Comment at: lib/AST/ExprConstant.cpp:5676
 else
   Result.Designator.setInvalid();
 return true;

We should produce a `CCEDiag` along this path too. (This happens for VLAs.)


https://reviews.llvm.org/D32372



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


[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests

2017-04-21 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal updated this revision to Diff 96231.
BillyONeal added a comment.

Stephan had some code review comments :)


https://reviews.llvm.org/D32309

Files:
  test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
  test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp

Index: test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
===
--- test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
+++ test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
@@ -11,12 +11,13 @@
 // 
 
 // template
-// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
+// constexpr common_type_t<_M,_N> lcm(_M __m, _N __n)
 
 #include 
 #include 
+#include 
 #include 
-#include 
+#include 
 
 constexpr struct {
   int x;
@@ -34,21 +35,29 @@
 };
 
 template 
-constexpr bool test0(Input1 in1, Input2 in2, Output out)
+constexpr bool test0(int in1, int in2, int out)
 {
-static_assert((std::is_same::value), "" );
-static_assert((std::is_same::value), "" );
-return out == std::lcm(in1, in2) ? true : (std::abort(), false);
+static_assert(std::is_same(0), static_cast(0)))>::value, "");
+static_assert(std::is_same(0), static_cast(0)))>::value, "");
+const bool result = static_cast>(out) ==
+std::lcm(static_cast(in1), static_cast(in2));
+if (!result) {
+std::abort();
+}
+
+return result;
 }
 
 
 template 
 constexpr bool do_test(int = 0)
 {
-using S1 = typename std::make_signed::type;
-using S2 = typename std::make_signed::type;
-using U1 = typename std::make_unsigned::type;
-using U2 = typename std::make_unsigned::type;
+using S1 = std::make_signed_t;
+using S2 = std::make_signed_t;
+using U1 = std::make_unsigned_t;
+using U2 = std::make_unsigned_t;
 bool accumulate = true;
 for (auto TC : Cases) {
 { // Test with two signed types
@@ -101,15 +110,15 @@
 assert(do_test(non_cce));
 assert(do_test(non_cce));
 
-static_assert(do_test< int8_t>(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
 
-assert(do_test< int8_t>(non_cce));
-assert(do_test(non_cce));
-assert(do_test(non_cce));
-assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
+assert(do_test(non_cce));
 
 static_assert(do_test(), "");
 static_assert(do_test(), "");
@@ -131,9 +140,9 @@
 
 //  LWG#2837
 {
-auto res1 = std::lcm((int64_t)1234, (int32_t)-2147483648);
-(void) std::lcm(INT_MIN, 2);	// this used to trigger UBSAN
-static_assert( std::is_same::type>::value, "");
+auto res1 = std::lcm(static_cast(1234), INT32_MIN);
+(void)std::lcm(INT_MIN, 2UL);	// this used to trigger UBSAN
+static_assert(std::is_same::value, "");
 	assert(res1 == 1324997410816LL);
 }
 }
Index: test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
===
--- test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
+++ test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
@@ -16,8 +16,9 @@
 
 #include 
 #include 
+#include 
 #include // for rand()
-#include 
+#include 
 
 constexpr struct {
   int x;
@@ -36,21 +37,29 @@
 
 
 template 
-constexpr bool test0(Input1 in1, Input2 in2, Output out)
+constexpr bool test0(int in1, int in2, int out)
 {
-static_assert((std::is_same::value), "" );
-static_assert((std::is_same::value), "" );
-return out == std::gcd(in1, in2) ? true : (std::abort(), false);
+static_assert(std::is_same(0), static_cast(0)))>::value, "");
+static_assert(std::is_same(0), static_cast(0)))>::value, "");
+const bool result = static_cast>(out) ==
+std::gcd(static_cast(in1), static_cast(in2));
+if (!result) {
+std::abort();
+}
+
+return result;
 }
 
 
 template 
 constexpr bool do_test(int = 0)
 {
-using S1 = typename std::make_signed::type;
-using S2 = typename std::make_signed::type;
-using U1 = typename std::make_unsigned::type;
-using U2 = typename std::make_unsigned::type;
+using S1 = std::make_signed_t;
+using S2 = std::make_signed_t;
+using U1 = std::make_unsigned_t;
+using U2 = std::make_unsigned_t;
 bool accumulate = true;
 for (auto TC : Cases) {
 { // Test with two signed types
@@ -103,15 +112,15 @@
 assert(do_test(non_cce));
 assert(do_test(non_cce));
 
-static_assert(do_test< int8_t>(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
-static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
+static_assert(do_test(), "");
 
-assert(do_test< int8_t>(non_cce));
-assert(

[PATCH] D32371: Add comments to the diagnostic kinds in Diagnostic.td.

2017-04-21 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis marked an inline comment as done.
thakis added a comment.

r301039, thanks.


https://reviews.llvm.org/D32371



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


r301039 - Add comments to the diagnostic kinds in Diagnostic.td.

2017-04-21 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Apr 21 15:55:00 2017
New Revision: 301039

URL: http://llvm.org/viewvc/llvm-project?rev=301039&view=rev
Log:
Add comments to the diagnostic kinds in Diagnostic.td.

https://reviews.llvm.org/D32371

Modified:
cfe/trunk/include/clang/Basic/Diagnostic.td

Modified: cfe/trunk/include/clang/Basic/Diagnostic.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.td?rev=301039&r1=301038&r2=301039&view=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.td (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.td Fri Apr 21 15:55:00 2017
@@ -12,6 +12,8 @@
 //
 
//===--===//
 
+// See the Internals Manual, section The Diagnostics Subsystem for an overview.
+
 // Define the diagnostic severities.
 class Severity {
   string Name = N;
@@ -100,10 +102,20 @@ class SuppressInSystemHeader {
 class Error : Diagnostic, 
SFINAEFailure {
   bit ShowInSystemHeader = 1;
 }
+// Warnings default to on (but can be default-off'd with DefaultIgnore).
+// This is used for warnings about questionable code; warnings about
+// accepted language extensions should use Extension or ExtWarn below instead.
 class Warning   : Diagnostic;
+// Remarks can be turned on with -R flags and provide commentary, e.g. on
+// optimizer decisions.
 class Remark: Diagnostic;
+// Extensions are warnings about accepted language extensions.
+// Extension warnings are default-off but enabled by -pedantic.
 class Extension : Diagnostic;
+// ExtWarns are warnings about accepted language extensions.
+// ExtWarn warnings are default-on.
 class ExtWarn   : Diagnostic;
+// Notes can provide supplementary information on errors, warnings, and 
remarks.
 class Note  : Diagnostic;
 
 


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


[PATCH] D32234: [Clangd] Support Authority-less URIs

2017-04-21 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle-ericsson added a comment.

Thanks a lot!


Repository:
  rL LLVM

https://reviews.llvm.org/D32234



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


[PATCH] D32371: Add comments to the diagnostic kinds in Diagnostic.td.

2017-04-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

Highly useful I'd say!

lgtm




Comment at: include/clang/Basic/Diagnostic.td:113
+// Extensions are warnings about accepted language extensions that are
+// default-off but enabled by -pedantic.
 class Extension : Diagnostic;

Nit: On first glance, one might parse this as the accepted language extensions 
being enabled by -pedantic, not the warnings. Maybe spell it out: "about 
accepted language extensions. The warnings are default-off bug enabled by 
-pedantic."


https://reviews.llvm.org/D32371



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


[PATCH] D32064: [asan] Disable ASan global-GC depending on the target and compiler flags

2017-04-21 Thread Evgeniy Stepanov via Phabricator via cfe-commits
eugenis updated this revision to Diff 96227.
eugenis added a comment.

Reverted back to using pass constructor argument.


Repository:
  rL LLVM

https://reviews.llvm.org/D32064

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -129,16 +129,20 @@
 // that we add to the PassManagerBuilder.
 class PassManagerBuilderWrapper : public PassManagerBuilder {
 public:
-  PassManagerBuilderWrapper(const CodeGenOptions &CGOpts,
+  PassManagerBuilderWrapper(const Triple &TargetTriple,
+const CodeGenOptions &CGOpts,
 const LangOptions &LangOpts)
-  : PassManagerBuilder(), CGOpts(CGOpts), LangOpts(LangOpts) {}
+  : PassManagerBuilder(), TargetTriple(TargetTriple), CGOpts(CGOpts),
+LangOpts(LangOpts) {}
+  const Triple &getTargetTriple() const { return TargetTriple; }
   const CodeGenOptions &getCGOpts() const { return CGOpts; }
   const LangOptions &getLangOpts() const { return LangOpts; }
+
 private:
+  const Triple &TargetTriple;
   const CodeGenOptions &CGOpts;
   const LangOptions &LangOpts;
 };
-
 }
 
 static void addObjCARCAPElimPass(const PassManagerBuilder &Builder, 
PassManagerBase &PM) {
@@ -185,16 +189,36 @@
   PM.add(createSanitizerCoverageModulePass(Opts));
 }
 
+// Check if ASan should use GC-friendly instrumentation for globals.
+// First of all, there is no point if -fdata-sections is off (expect for MachO,
+// where this is not a factor). Also, on ELF this feature requires an assembler
+// extension that only works with -integrated-as at the moment.
+static bool asanUseGlobalsGC(const Triple &T, const CodeGenOptions &CGOpts) {
+  switch (T.getObjectFormat()) {
+  case Triple::MachO:
+return true;
+  case Triple::COFF:
+return CGOpts.DataSections;
+  case Triple::ELF:
+return CGOpts.DataSections && !CGOpts.DisableIntegratedAS;
+  default:
+return false;
+  }
+}
+
 static void addAddressSanitizerPasses(const PassManagerBuilder &Builder,
   legacy::PassManagerBase &PM) {
   const PassManagerBuilderWrapper &BuilderWrapper =
   static_cast(Builder);
+  const Triple &T = BuilderWrapper.getTargetTriple();
   const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts();
   bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::Address);
   bool UseAfterScope = CGOpts.SanitizeAddressUseAfterScope;
+  bool UseGlobalsGC = asanUseGlobalsGC(T, CGOpts);
   PM.add(createAddressSanitizerFunctionPass(/*CompileKernel*/ false, Recover,
 UseAfterScope));
-  PM.add(createAddressSanitizerModulePass(/*CompileKernel*/false, Recover));
+  PM.add(createAddressSanitizerModulePass(/*CompileKernel*/ false, Recover,
+  UseGlobalsGC));
 }
 
 static void addKernelAddressSanitizerPasses(const PassManagerBuilder &Builder,
@@ -434,16 +458,16 @@
   if (CodeGenOpts.DisableLLVMPasses)
 return;
 
-  PassManagerBuilderWrapper PMBuilder(CodeGenOpts, LangOpts);
-
   // Figure out TargetLibraryInfo.  This needs to be added to MPM and FPM
   // manually (and not via PMBuilder), since some passes (eg. InstrProfiling)
   // are inserted before PMBuilder ones - they'd get the default-constructed
   // TLI with an unknown target otherwise.
   Triple TargetTriple(TheModule->getTargetTriple());
   std::unique_ptr TLII(
   createTLII(TargetTriple, CodeGenOpts));
 
+  PassManagerBuilderWrapper PMBuilder(TargetTriple, CodeGenOpts, LangOpts);
+
   // At O0 and O1 we only run the always inliner which is more efficient. At
   // higher optimization levels we run the normal inliner.
   if (CodeGenOpts.OptimizationLevel <= 1) {


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -129,16 +129,20 @@
 // that we add to the PassManagerBuilder.
 class PassManagerBuilderWrapper : public PassManagerBuilder {
 public:
-  PassManagerBuilderWrapper(const CodeGenOptions &CGOpts,
+  PassManagerBuilderWrapper(const Triple &TargetTriple,
+const CodeGenOptions &CGOpts,
 const LangOptions &LangOpts)
-  : PassManagerBuilder(), CGOpts(CGOpts), LangOpts(LangOpts) {}
+  : PassManagerBuilder(), TargetTriple(TargetTriple), CGOpts(CGOpts),
+LangOpts(LangOpts) {}
+  const Triple &getTargetTriple() const { return TargetTriple; }
   const CodeGenOptions &getCGOpts() const { return CGOpts; }
   const LangOptions &getLangOpts() const { return LangOpts; }
+
 private:
+  const Triple &TargetTriple;
   const CodeGenOptions &CGOpts;
   const LangOptions &LangOpts;
 };
-
 }
 
 static void addObjCARCAPElimPass(const PassManagerBuilder &Builder, PassManagerBase &PM) {
@@ -185,16 +189,36 @@
   PM.add(createSanitizerCoverageModulePass(O

[PATCH] D32372: Arrays of unknown bound in constant expressions

2017-04-21 Thread Robert Haberlach via Phabricator via cfe-commits
Arcoth created this revision.

Arrays of unknown bound are subject to some bugs in constant expressions.

const extern int arr[];
constexpr int f(int i) {return arr[i];}
constexpr int arr[] {1, 2, 3};
int main() {constexpr int x = f(2);}

This is spuriously rejected. On the other hand,

extern const int arr[];
constexpr int const* p = arr + 2;

compiles. The standard will presumably incorporate a rule that forbids 
array-to-pointer conversions on arrays of unknown bound (unless they are 
completed at the point of evaluation, as in the first
example). The proposed changes reflect this idea.


https://reviews.llvm.org/D32372

Files:
  include/clang/Basic/DiagnosticASTKinds.td
  lib/AST/ExprConstant.cpp

Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -495,7 +495,7 @@
 // FIXME: Force the precision of the source value down so we don't
 // print digits which are usually useless (we don't really care here if
 // we truncate a digit by accident in edge cases).  Ideally,
-// APFloat::toString would automatically print the shortest 
+// APFloat::toString would automatically print the shortest
 // representation which rounds to the correct value, but it's a bit
 // tricky to implement.
 unsigned precision =
@@ -720,7 +720,7 @@
   private:
 OptionalDiagnostic Diag(SourceLocation Loc, diag::kind DiagId,
 unsigned ExtraNotes, bool IsCCEDiag) {
-
+
   if (EvalStatus.Diag) {
 // If we have a prior diagnostic, it will be noting that the expression
 // isn't a constant expression. This diagnostic is more important,
@@ -773,7 +773,7 @@
   unsigned ExtraNotes = 0) {
   return Diag(Loc, DiagId, ExtraNotes, false);
 }
-
+
 OptionalDiagnostic FFDiag(const Expr *E, diag::kind DiagId
   = diag::note_invalid_subexpr_in_const_expr,
 unsigned ExtraNotes = 0) {
@@ -2619,10 +2619,23 @@
 LastField = nullptr;
 if (ObjType->isArrayType()) {
   // Next subobject is an array element.
-  const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(ObjType);
-  assert(CAT && "vla in literal type?");
+  uint64_t actualIndex;
+  const ArrayType *AT = Info.Ctx.getAsArrayType(ObjType); // non-null by assumption
+  if (I == 0) {
+/* we're dealing with the complete array object, which may have been declared
+   without a bound */
+actualIndex = Sub.MostDerivedArraySize;
+assert(Sub.MostDerivedIsArrayElement && "Complete object is an array, but isn't?");
+  }
+  else {
+/* ... the array must have been given a bound
+([dcl.array]/3 for both subarrays and members). */
+auto CAT = dyn_cast(AT);
+assert(CAT && "vla in literal type?");
+actualIndex = CAT->getSize().getZExtValue();
+  }
   uint64_t Index = Sub.Entries[I].ArrayIndex;
-  if (CAT->getSize().ule(Index)) {
+  if (actualIndex <= Index) {
 // Note, it should not be possible to form a pointer with a valid
 // designator which points more than one past the end of the array.
 if (Info.getLangOpts().CPlusPlus11)
@@ -2633,7 +2646,7 @@
 return handler.failed();
   }
 
-  ObjType = CAT->getElementType();
+  ObjType = AT->getElementType();
 
   // An array object is represented as either an Array APValue or as an
   // LValue which refers to a string literal.
@@ -4098,13 +4111,13 @@
 
   if (Info.getLangOpts().CPlusPlus11) {
 const FunctionDecl *DiagDecl = Definition ? Definition : Declaration;
-
+
 // If this function is not constexpr because it is an inherited
 // non-constexpr constructor, diagnose that directly.
 auto *CD = dyn_cast(DiagDecl);
 if (CD && CD->isInheritingConstructor()) {
   auto *Inherited = CD->getInheritedConstructor().getConstructor();
-  if (!Inherited->isConstexpr()) 
+  if (!Inherited->isConstexpr())
 DiagDecl = CD = Inherited;
 }
 
@@ -4635,7 +4648,7 @@
   return false;
 This = &ThisVal;
 Args = Args.slice(1);
-  } else if (MD && MD->isLambdaStaticInvoker()) {   
+  } else if (MD && MD->isLambdaStaticInvoker()) {
 // Map the static invoker for the lambda back to the call operator.
 // Conveniently, we don't have to slice out the 'this' argument (as is
 // being done for the non-static case), since a static member function
@@ -4670,7 +4683,7 @@
   FD = LambdaCallOp;
   }
 
-  
+
 } else
   return Error(E);
 
@@ -5501,7 +5514,7 @@
   // Update 'Result' to refer to the data member/field of the closure object
   // that represents the '*this' capture.
   if (!HandleLValueMember(Info, E, Result,
- Info.CurrentCall->Lambda

[PATCH] D32371: Add comments to the diagnostic kinds in Diagnostic.td.

2017-04-21 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Not sure if this is useful, but this is where I always check first.


https://reviews.llvm.org/D32371



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


[PATCH] D32371: Add comments to the diagnostic kinds in Diagnostic.td.

2017-04-21 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.

https://reviews.llvm.org/D32371

Files:
  include/clang/Basic/Diagnostic.td


Index: include/clang/Basic/Diagnostic.td
===
--- include/clang/Basic/Diagnostic.td
+++ include/clang/Basic/Diagnostic.td
@@ -12,6 +12,8 @@
 //
 
//===--===//
 
+// See the Internals Manual, section The Diagnostics Subsystem for an overview.
+
 // Define the diagnostic severities.
 class Severity {
   string Name = N;
@@ -100,10 +102,20 @@
 class Error : Diagnostic, 
SFINAEFailure {
   bit ShowInSystemHeader = 1;
 }
+// Warnings default to on (but can be default-off'd with DefaultIgnore).
+// This is used for warnings about questionable code; warnings about
+// accepted language extensions should use Extension or ExtWarn below instead.
 class Warning   : Diagnostic;
+// Remarks can be turned on with -R flags and provide commentary, e.g. on
+// optimizer decisions.
 class Remark: Diagnostic;
+// Extensions are warnings about accepted language extensions that are
+// default-off but enabled by -pedantic.
 class Extension : Diagnostic;
+// ExtWarns are warnings about accepted language extensions that are
+// default-on.
 class ExtWarn   : Diagnostic;
+// Notes can provide supplementary information on errors, warnings, and 
remarks.
 class Note  : Diagnostic;
 
 


Index: include/clang/Basic/Diagnostic.td
===
--- include/clang/Basic/Diagnostic.td
+++ include/clang/Basic/Diagnostic.td
@@ -12,6 +12,8 @@
 //
 //===--===//
 
+// See the Internals Manual, section The Diagnostics Subsystem for an overview.
+
 // Define the diagnostic severities.
 class Severity {
   string Name = N;
@@ -100,10 +102,20 @@
 class Error : Diagnostic, SFINAEFailure {
   bit ShowInSystemHeader = 1;
 }
+// Warnings default to on (but can be default-off'd with DefaultIgnore).
+// This is used for warnings about questionable code; warnings about
+// accepted language extensions should use Extension or ExtWarn below instead.
 class Warning   : Diagnostic;
+// Remarks can be turned on with -R flags and provide commentary, e.g. on
+// optimizer decisions.
 class Remark: Diagnostic;
+// Extensions are warnings about accepted language extensions that are
+// default-off but enabled by -pedantic.
 class Extension : Diagnostic;
+// ExtWarns are warnings about accepted language extensions that are
+// default-on.
 class ExtWarn   : Diagnostic;
+// Notes can provide supplementary information on errors, warnings, and remarks.
 class Note  : Diagnostic;
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32043: [Driver] Load all necessary default sanitizer blacklists

2017-04-21 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

In https://reviews.llvm.org/D32043#728427, @pcc wrote:

> This seems reasonable to me, although it's unfortunate that the design of the 
> sanitizer blacklist feature does not (at present) allow different blacklists 
> for different sanitizers.


IMO this might be a real problem. If we load multiple default blacklists, 
diagnostics which appear when compiling with one sanitizer could disappear when 
another sanitizer is enabled.

So long as we don't allow different blacklists for different sanitizers, maybe 
there should just be one default sanitizer blacklist file.

Specifically, we'd look for "sanitizer_blacklist.txt" in the resource dir. If 
we find it, load it (regardless of which sanitizers are enabled) and we're 
done. If we don't find it, fall back to the behavior in this patch (check if a 
sanitizer is enabled, then try to load its blacklist). Wdyt?


https://reviews.llvm.org/D32043



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


[PATCH] D32369: [ms] Give -Wmicrosoft-enum-forward-reference a chance to fire in clang-cl, PR32736

2017-04-21 Thread Nico Weber via Phabricator via cfe-commits
thakis closed this revision.
thakis added a comment.

r301032, thanks.


https://reviews.llvm.org/D32369



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


r301032 - [ms] Give -Wmicrosoft-enum-forward-reference a chance to fire in clang-cl, PR32736

2017-04-21 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Apr 21 15:12:26 2017
New Revision: 301032

URL: http://llvm.org/viewvc/llvm-project?rev=301032&view=rev
Log:
[ms] Give -Wmicrosoft-enum-forward-reference a chance to fire in clang-cl, 
PR32736

clang-cl sets MicrosoftCompat. In that mode, we always give enums a fixed
underlying type, and for enums with fixed underlying type we never enter the
block that tries to emit ext_ms_forward_ref_enum. Fix this by requiring an
explicit underlying type when we're skipping this diagnostic.

We had a test for this warning, but it only ran in C++98 mode. clang-cl always
enables -std=c++14, so MicrosoftCompatibiliy-cxx98.cpp is a fairly useless
test. Fold it into MicrosoftCompatibility.cpp -- that way, the test checks if
-Wmicrosoft-enum-forward-reference can fire in clang-cl builds.

https://reviews.llvm.org/D32369

Removed:
cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=301032&r1=301031&r2=301032&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Apr 21 15:12:26 2017
@@ -13523,7 +13523,8 @@ CreateNewDecl:
 // If this is an undefined enum, warn.
 if (TUK != TUK_Definition && !Invalid) {
   TagDecl *Def;
-  if ((getLangOpts().CPlusPlus11 || getLangOpts().ObjC2) &&
+  if (!EnumUnderlyingIsImplicit &&
+  (getLangOpts().CPlusPlus11 || getLangOpts().ObjC2) &&
   cast(New)->isFixed()) {
 // C++0x: 7.2p2: opaque-enum-declaration.
 // Conflicts are diagnosed above. Do nothing.

Removed: cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp?rev=301031&view=auto
==
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility-cxx98.cpp (removed)
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++98 
-Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
-
-
-//MSVC allows forward enum declaration
-enum ENUM; // expected-warning {{forward references to 'enum' types are a 
Microsoft extension}}
-ENUM *var = 0; 
-ENUM var2 = (ENUM)3;
-enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types 
are a Microsoft extension}}
-
-typedef void (*FnPtrTy)();
-void (*PR23733_1)() = static_cast((void *)0); // expected-warning 
{{static_cast between pointer-to-function and pointer-to-object is a Microsoft 
extension}}
-void (*PR23733_2)() = FnPtrTy((void *)0);
-void (*PR23733_3)() = (FnPtrTy)((void *)0);
-void (*PR23733_4)() = reinterpret_cast((void *)0);
-
-long function_prototype(int a);
-long (*function_ptr)(int a);
-
-void function_to_voidptr_conv() {
-  void *a1 = function_prototype;  // expected-warning {{implicit conversion 
between pointer-to-function and pointer-to-object is a Microsoft extension}}
-  void *a2 = &function_prototype; // expected-warning {{implicit conversion 
between pointer-to-function and pointer-to-object is a Microsoft extension}}
-  void *a3 = function_ptr;// expected-warning {{implicit conversion 
between pointer-to-function and pointer-to-object is a Microsoft extension}}
-}

Modified: cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp?rev=301032&r1=301031&r2=301032&view=diff
==
--- cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftCompatibility.cpp Fri Apr 21 15:12:26 2017
@@ -224,6 +224,15 @@ template void function_missing_typename<
 
 }
 
+//MSVC allows forward enum declaration
+enum ENUM; // expected-warning {{forward references to 'enum' types are a 
Microsoft extension}}
+ENUM *var = 0; 
+ENUM var2 = (ENUM)3;
+enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types 
are a Microsoft extension}}
+
+enum ENUM1 { kA };
+enum ENUM1;  // This way round is fine.
+
 enum ENUM2 {
ENUM2_a = (enum ENUM2) 4,
ENUM2_b = 0x9FFF, // expected-warning {{enumerator value is not 
representable in the underlying type 'int'}}
@@ -269,3 +278,18 @@ void g() {
   f(0xi64);
 }
 }
+
+typedef void (*FnPtrTy)();
+void (*PR23733_1)() = static_cast((void *)0); // expected-warning 
{{static_cast between pointer-to-function and pointer-to-object is a Microsoft 
extension}}
+void (*PR23733_2)() = FnPtrTy((void *)0);
+void (*PR23733_3)() = (FnPtrTy)((void *)0);
+void (*PR23733_4)() = reinterpret_cast((void *)0);
+
+long function_prototype

[PATCH] D32369: [ms] Give -Wmicrosoft-enum-forward-reference a chance to fire in clang-cl, PR32736

2017-04-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D32369



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


[PATCH] D32369: [ms] Give -Wmicrosoft-enum-forward-reference a chance to fire in clang-cl, PR32736

2017-04-21 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.

clang-cl sets MicrosoftCompat. In that mode, we always give enums a fixed 
underlying type, and for enums with fixed underlying type we never enter the 
block that tries to emit ext_ms_forward_ref_enum. Fix this by requiring an 
explicit  underlying type when we're skipping this diagnostic.

We had a test for this warning, but it only ran in C++98 mode. clang-cl always 
enables -std=c++14, so MicrosoftCompatibiliy-cxx98.cpp is a fairly useless 
test. Fold it into MicrosoftCompatibility.cpp -- that way, the test checks if 
-Wmicrosoft-enum-forward-reference can fire in clang-cl builds.


https://reviews.llvm.org/D32369

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
  test/SemaCXX/MicrosoftCompatibility.cpp


Index: test/SemaCXX/MicrosoftCompatibility.cpp
===
--- test/SemaCXX/MicrosoftCompatibility.cpp
+++ test/SemaCXX/MicrosoftCompatibility.cpp
@@ -224,6 +224,15 @@
 
 }
 
+//MSVC allows forward enum declaration
+enum ENUM; // expected-warning {{forward references to 'enum' types are a 
Microsoft extension}}
+ENUM *var = 0; 
+ENUM var2 = (ENUM)3;
+enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types 
are a Microsoft extension}}
+
+enum ENUM1 { kA };
+enum ENUM1;  // This way round is fine.
+
 enum ENUM2 {
ENUM2_a = (enum ENUM2) 4,
ENUM2_b = 0x9FFF, // expected-warning {{enumerator value is not 
representable in the underlying type 'int'}}
@@ -269,3 +278,18 @@
   f(0xi64);
 }
 }
+
+typedef void (*FnPtrTy)();
+void (*PR23733_1)() = static_cast((void *)0); // expected-warning 
{{static_cast between pointer-to-function and pointer-to-object is a Microsoft 
extension}}
+void (*PR23733_2)() = FnPtrTy((void *)0);
+void (*PR23733_3)() = (FnPtrTy)((void *)0);
+void (*PR23733_4)() = reinterpret_cast((void *)0);
+
+long function_prototype(int a);
+long (*function_ptr)(int a);
+
+void function_to_voidptr_conv() {
+  void *a1 = function_prototype;  // expected-warning {{implicit conversion 
between pointer-to-function and pointer-to-object is a Microsoft extension}}
+  void *a2 = &function_prototype; // expected-warning {{implicit conversion 
between pointer-to-function and pointer-to-object is a Microsoft extension}}
+  void *a3 = function_ptr;// expected-warning {{implicit conversion 
between pointer-to-function and pointer-to-object is a Microsoft extension}}
+}
Index: test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
===
--- test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
+++ test/SemaCXX/MicrosoftCompatibility-cxx98.cpp
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++98 
-Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
-
-
-//MSVC allows forward enum declaration
-enum ENUM; // expected-warning {{forward references to 'enum' types are a 
Microsoft extension}}
-ENUM *var = 0; 
-ENUM var2 = (ENUM)3;
-enum ENUM1* var3 = 0;// expected-warning {{forward references to 'enum' types 
are a Microsoft extension}}
-
-typedef void (*FnPtrTy)();
-void (*PR23733_1)() = static_cast((void *)0); // expected-warning 
{{static_cast between pointer-to-function and pointer-to-object is a Microsoft 
extension}}
-void (*PR23733_2)() = FnPtrTy((void *)0);
-void (*PR23733_3)() = (FnPtrTy)((void *)0);
-void (*PR23733_4)() = reinterpret_cast((void *)0);
-
-long function_prototype(int a);
-long (*function_ptr)(int a);
-
-void function_to_voidptr_conv() {
-  void *a1 = function_prototype;  // expected-warning {{implicit conversion 
between pointer-to-function and pointer-to-object is a Microsoft extension}}
-  void *a2 = &function_prototype; // expected-warning {{implicit conversion 
between pointer-to-function and pointer-to-object is a Microsoft extension}}
-  void *a3 = function_ptr;// expected-warning {{implicit conversion 
between pointer-to-function and pointer-to-object is a Microsoft extension}}
-}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -13523,7 +13523,8 @@
 // If this is an undefined enum, warn.
 if (TUK != TUK_Definition && !Invalid) {
   TagDecl *Def;
-  if ((getLangOpts().CPlusPlus11 || getLangOpts().ObjC2) &&
+  if (!EnumUnderlyingIsImplicit &&
+  (getLangOpts().CPlusPlus11 || getLangOpts().ObjC2) &&
   cast(New)->isFixed()) {
 // C++0x: 7.2p2: opaque-enum-declaration.
 // Conflicts are diagnosed above. Do nothing.


Index: test/SemaCXX/MicrosoftCompatibility.cpp
===
--- test/SemaCXX/MicrosoftCompatibility.cpp
+++ test/SemaCXX/MicrosoftCompatibility.cpp
@@ -224,6 +224,15 @@
 
 }
 
+//MSVC allows forward enum declaration
+enum ENUM; // expected-warning {{forward references to 'enum' types

[PATCH] D32341: Fix a bug that warnings generated with -M or -MM flags

2017-04-21 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Could you add a test case?


https://reviews.llvm.org/D32341



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


[PATCH] D31739: Add markup for libc++ dylib availability

2017-04-21 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

@mclow.lists you mentioned on IRC you may have some suggestions to make this 
less noisy? Do you still plan to review?


https://reviews.llvm.org/D31739



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


[PATCH] D32263: Preprocessor: Suppress -Wnonportable-include-path for header maps

2017-04-21 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

s/Eli/Eric/


https://reviews.llvm.org/D32263



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


[PATCH] D32263: Preprocessor: Suppress -Wnonportable-include-path for header maps

2017-04-21 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith updated this revision to Diff 96201.
dexonsmith added a comment.

Thanks for the review, Eli.

I've changed `IsModule` to be a required `bool*` parameter.  Setting the 
default to `nullptr` looked confusing at call sites.


https://reviews.llvm.org/D32263

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap
  clang/test/Preprocessor/Inputs/nonportable-hmaps/headers/foo/Foo.h
  clang/test/Preprocessor/nonportable-include-with-hmap.c

Index: clang/test/Preprocessor/nonportable-include-with-hmap.c
===
--- /dev/null
+++ clang/test/Preprocessor/nonportable-include-with-hmap.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -Eonly\
+// RUN:   -I%S/Inputs/nonportable-hmaps/foo.hmap \
+// RUN:   -I%S/Inputs/nonportable-hmaps  \
+// RUN:   %s -verify
+//
+// foo.hmap contains: Foo/Foo.h -> headers/foo/Foo.h
+//
+// Header search of "Foo/Foo.h" follows this path:
+//  1. Look for "Foo/Foo.h".
+//  2. Find "Foo/Foo.h" in "nonportable-hmaps/foo.hmap".
+//  3. Look for "headers/foo/Foo.h".
+//  4. Find "headers/foo/Foo.h" in "nonportable-hmaps".
+//  5. Return.
+//
+// There is nothing nonportable; -Wnonportable-include-path should not fire.
+#include "Foo/Foo.h" // expected-no-diagnostics
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -508,7 +508,7 @@
   const DirectoryLookup *CurDir;
   const FileEntry *File =
   LookupFile(FilenameTok.getLocation(), Filename, isAngled, nullptr,
- nullptr, CurDir, nullptr, nullptr, nullptr);
+ nullptr, CurDir, nullptr, nullptr, nullptr, nullptr);
   if (!File) {
 if (!SuppressIncludeNotFoundError)
   Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -1422,7 +1422,7 @@
   const DirectoryLookup *CurDir;
   const FileEntry *File =
   PP.LookupFile(FilenameLoc, Filename, isAngled, LookupFrom, LookupFromFile,
-CurDir, nullptr, nullptr, nullptr);
+CurDir, nullptr, nullptr, nullptr, nullptr);
 
   // Get the result value.  A result of true means the file exists.
   return File != nullptr;
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -752,16 +752,11 @@
 }
 
 const FileEntry *Preprocessor::LookupFile(
-SourceLocation FilenameLoc,
-StringRef Filename,
-bool isAngled,
-const DirectoryLookup *FromDir,
-const FileEntry *FromFile,
-const DirectoryLookup *&CurDir,
-SmallVectorImpl *SearchPath,
+SourceLocation FilenameLoc, StringRef Filename, bool isAngled,
+const DirectoryLookup *FromDir, const FileEntry *FromFile,
+const DirectoryLookup *&CurDir, SmallVectorImpl *SearchPath,
 SmallVectorImpl *RelativePath,
-ModuleMap::KnownHeader *SuggestedModule,
-bool SkipCache) {
+ModuleMap::KnownHeader *SuggestedModule, bool *IsMapped, bool SkipCache) {
   Module *RequestingModule = getModuleForLocation(FilenameLoc);
   bool RequestingModuleIsModuleInterface = !SourceMgr.isInMainFile(FilenameLoc);
 
@@ -819,7 +814,7 @@
 while (const FileEntry *FE = HeaderInfo.LookupFile(
Filename, FilenameLoc, isAngled, TmpFromDir, TmpCurDir,
Includers, SearchPath, RelativePath, RequestingModule,
-   SuggestedModule, SkipCache)) {
+   SuggestedModule, /*IsMapped=*/nullptr, SkipCache)) {
   // Keep looking as if this file did a #include_next.
   TmpFromDir = TmpCurDir;
   ++TmpFromDir;
@@ -835,7 +830,7 @@
   // Do a standard file entry lookup.
   const FileEntry *FE = HeaderInfo.LookupFile(
   Filename, FilenameLoc, isAngled, FromDir, CurDir, Includers, SearchPath,
-  RelativePath, RequestingModule, SuggestedModule, SkipCache,
+  RelativePath, RequestingModule, SuggestedModule, IsMapped, SkipCache,
   BuildSystemModule);
   if (FE) {
 if (SuggestedModule && !LangOpts.AsmPreprocessor)
@@ -1783,6 +1778,7 @@
   }
 
   // Search include directories.
+  bool IsMapped = false;
   const DirectoryLookup *CurDir;
   SmallString<1024> SearchPath;
   SmallString<1024> RelativePath;
@@ -1801,7 +1797,7 @@
   FilenameLoc, LangOpts.MSVCCompat ? NormalizedPath.c_str() : Filename,
   isAngled, LookupFrom, LookupFromFile, CurDir,
   Callbacks ? &SearchPa

[PATCH] D32084: AMDGPU/GFX9: Set +fast-fmaf for >=gfx900 unless -cl-denorms-are-zero is set

2017-04-21 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl abandoned this revision.
kzhuravl added a comment.

Abandoned in favor of https://reviews.llvm.org/D32363.


https://reviews.llvm.org/D32084



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


[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

It may be good idea to add check for arguments which taken from C++ containers 
like std::string, std::string_view, etc.


Repository:
  rL LLVM

https://reviews.llvm.org/D32346



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


[PATCH] D32263: Preprocessor: Suppress -Wnonportable-include-path for header maps

2017-04-21 Thread Eric Niebler via Phabricator via cfe-commits
eric_niebler added inline comments.



Comment at: clang/include/clang/Lex/HeaderSearch.h:401
+  }
+
   /// \brief Look up a subframework for the specified \#include file.

Why not just add a `, bool *IsMapped = nullptr` parameter to the existing 
`LookupFile`?


https://reviews.llvm.org/D32263



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


[PATCH] D31739: Add markup for libc++ dylib availability

2017-04-21 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

@mclow.lists you mentioned on IRC you may have some suggestions to make this 
less noisy? Do you still plan to review?


https://reviews.llvm.org/D31739



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


[PATCH] D32084: AMDGPU/GFX9: Set +fast-fmaf for >=gfx900 unless -cl-denorms-are-zero is set

2017-04-21 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: lib/Basic/Targets.cpp:2208-2210
+  TargetOpts.Features.push_back(
+  (Twine(hasFullSpeedFMAF32(TargetOpts.CPU) &&
+  !CGOpts.FlushDenorm ? '+' : '-') + Twine("fast-fmaf")).str());

We glue fast-fmaf to the specific subtargets, so I don't think you can actually 
turn it and off. It has this nonsensical behavior where it assumes if you 
disable a subtarget feature for the processors you aren't actually targeting 
the processor at all. I think a dedicated new feature might be needed


https://reviews.llvm.org/D32084



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


[PATCH] D31856: Headers: Make the type of SIZE_MAX the same as size_t

2017-04-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

We normally use stdint.h from the host C library, rather than our own version; 
this file is only relevant in -ffreestanding mode.  So it should be safe to 
change.


https://reviews.llvm.org/D31856



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


[PATCH] D32333: [clang-tidy] Update IdentifierNamingCheck to remove extra leading/trailing underscores

2017-04-21 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes updated this revision to Diff 96181.
jtbandes added a comment.

Cleanup


https://reviews.llvm.org/D32333

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming.cpp


Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -175,6 +175,9 @@
   int member2 = 2;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private 
member 'member2'
 // CHECK-FIXES: {{^}}  int __member2 = 2;{{$}}
+  int _memberWithExtraUnderscores_ = 42;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private 
member '_memberWithExtraUnderscores_'
+// CHECK-FIXES: {{^}}  int __memberWithExtraUnderscores = 42;{{$}}
 
 private:
 int private_member = 3;
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -262,6 +262,11 @@
   else
 Matches = false;
 
+  // Ensure the name doesn't have any extra underscores beyond those specified
+  // in the prefix and suffix.
+  if (Name.startswith("_") || Name.endswith("_"))
+Matches = false;
+
   if (Style.Case && !Matchers[static_cast(*Style.Case)].match(Name))
 Matches = false;
 
@@ -367,10 +372,12 @@
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
-  return Style.Prefix +
- fixupWithCase(Name, Style.Case.getValueOr(
- IdentifierNamingCheck::CaseType::CT_AnyCase)) 
+
- Style.Suffix;
+  const std::string Fixed = fixupWithCase(
+  Name, 
Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
+  StringRef Mid = StringRef(Fixed).trim("_");
+  if (Mid.size() == 0)
+Mid = "_";
+  return (Style.Prefix + Mid + Style.Suffix).str();
 }
 
 static StyleKind findStyleKind(


Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -175,6 +175,9 @@
   int member2 = 2;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member 'member2'
 // CHECK-FIXES: {{^}}  int __member2 = 2;{{$}}
+  int _memberWithExtraUnderscores_ = 42;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member '_memberWithExtraUnderscores_'
+// CHECK-FIXES: {{^}}  int __memberWithExtraUnderscores = 42;{{$}}
 
 private:
 int private_member = 3;
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -262,6 +262,11 @@
   else
 Matches = false;
 
+  // Ensure the name doesn't have any extra underscores beyond those specified
+  // in the prefix and suffix.
+  if (Name.startswith("_") || Name.endswith("_"))
+Matches = false;
+
   if (Style.Case && !Matchers[static_cast(*Style.Case)].match(Name))
 Matches = false;
 
@@ -367,10 +372,12 @@
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
-  return Style.Prefix +
- fixupWithCase(Name, Style.Case.getValueOr(
- IdentifierNamingCheck::CaseType::CT_AnyCase)) +
- Style.Suffix;
+  const std::string Fixed = fixupWithCase(
+  Name, Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
+  StringRef Mid = StringRef(Fixed).trim("_");
+  if (Mid.size() == 0)
+Mid = "_";
+  return (Style.Prefix + Mid + Style.Suffix).str();
 }
 
 static StyleKind findStyleKind(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32333: [clang-tidy] Update IdentifierNamingCheck to remove extra leading/trailing underscores

2017-04-21 Thread Jacob Bandes-Storch via Phabricator via cfe-commits
jtbandes updated this revision to Diff 96180.
jtbandes edited the summary of this revision.
jtbandes added a comment.

Remove unnecessary checks for empty prefix/suffix


https://reviews.llvm.org/D32333

Files:
  clang-tidy/readability/IdentifierNamingCheck.cpp
  test/clang-tidy/readability-identifier-naming.cpp


Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -175,6 +175,9 @@
   int member2 = 2;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private 
member 'member2'
 // CHECK-FIXES: {{^}}  int __member2 = 2;{{$}}
+  int _memberWithExtraUnderscores_ = 42;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private 
member '_memberWithExtraUnderscores_'
+// CHECK-FIXES: {{^}}  int __memberWithExtraUnderscores = 42;{{$}}
 
 private:
 int private_member = 3;
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -262,6 +262,13 @@
   else
 Matches = false;
 
+  // Ensure the name doesn't have any extra underscores beyond those specified
+  // in the prefix and suffix.
+  if (Name.startswith("_"))
+Matches = false;
+  if (Name.endswith("_"))
+Matches = false;
+
   if (Style.Case && !Matchers[static_cast(*Style.Case)].match(Name))
 Matches = false;
 
@@ -367,10 +374,12 @@
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
-  return Style.Prefix +
- fixupWithCase(Name, Style.Case.getValueOr(
- IdentifierNamingCheck::CaseType::CT_AnyCase)) 
+
- Style.Suffix;
+  const std::string Fixed = fixupWithCase(
+  Name, 
Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
+  StringRef Mid = StringRef(Fixed).trim("_");
+  if (Mid.size() == 0)
+Mid = "_";
+  return (Style.Prefix + Mid + Style.Suffix).str();
 }
 
 static StyleKind findStyleKind(


Index: test/clang-tidy/readability-identifier-naming.cpp
===
--- test/clang-tidy/readability-identifier-naming.cpp
+++ test/clang-tidy/readability-identifier-naming.cpp
@@ -175,6 +175,9 @@
   int member2 = 2;
 // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member 'member2'
 // CHECK-FIXES: {{^}}  int __member2 = 2;{{$}}
+  int _memberWithExtraUnderscores_ = 42;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for private member '_memberWithExtraUnderscores_'
+// CHECK-FIXES: {{^}}  int __memberWithExtraUnderscores = 42;{{$}}
 
 private:
 int private_member = 3;
Index: clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -262,6 +262,13 @@
   else
 Matches = false;
 
+  // Ensure the name doesn't have any extra underscores beyond those specified
+  // in the prefix and suffix.
+  if (Name.startswith("_"))
+Matches = false;
+  if (Name.endswith("_"))
+Matches = false;
+
   if (Style.Case && !Matchers[static_cast(*Style.Case)].match(Name))
 Matches = false;
 
@@ -367,10 +374,12 @@
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
-  return Style.Prefix +
- fixupWithCase(Name, Style.Case.getValueOr(
- IdentifierNamingCheck::CaseType::CT_AnyCase)) +
- Style.Suffix;
+  const std::string Fixed = fixupWithCase(
+  Name, Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
+  StringRef Mid = StringRef(Fixed).trim("_");
+  if (Mid.size() == 0)
+Mid = "_";
+  return (Style.Prefix + Mid + Style.Suffix).str();
 }
 
 static StyleKind findStyleKind(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-21 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added inline comments.



Comment at: clang/test/Index/print-type.cpp:118
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] 
[typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] 
[canonicaltype=outer::Qux, int>] 
[canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] 
[type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] 
[type=int] [typekind=Int]] [isPOD=1]
 // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]

arphaman wrote:
> Hmm, that's an interesting change. I assume the test passed prior to this 
> patch, right? Did this output change purely because of the change in 
> `GetTemplateArguments`?
Yup, that's right. This makes the type and the canonical type match in this 
case. In this case we lose a tiny bit of information (mainly, that the template 
argument was used through a typedef), but the alternative is to lose 
information about default template parameters, which seems worse to me (and is 
a regression, while template argument packs haven't been inspectionable until 
libclang 4.0).


https://reviews.llvm.org/D32348



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


[PATCH] D30805: [OpenCL] Add intel_reqd_sub_group_size attribute support

2017-04-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Sure! LGTM!


https://reviews.llvm.org/D30805



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


[PATCH] D30268: Avoid copy of __atoms when char_type is char

2017-04-21 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added inline comments.



Comment at: libcxx/include/locale:891
 
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE
 // signed

EricWF wrote:
> Would it be possible to reduce the amount of duplicate code between the two 
> implementations? Currently it seems like there is a lot.
Sorry for the late response, I have tried to minimize the duplication.


https://reviews.llvm.org/D30268



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


[PATCH] D30268: Avoid copy of __atoms when char_type is char

2017-04-21 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya updated this revision to Diff 96159.
hiraditya added a comment.

Minimized the diff by putting #ifdefs inside the function.


https://reviews.llvm.org/D30268

Files:
  libcxx/include/__config
  libcxx/include/locale

Index: libcxx/include/locale
===
--- libcxx/include/locale
+++ libcxx/include/locale
@@ -380,19 +380,57 @@
 struct __num_get
 : protected __num_get_base
 {
-static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
 static string __stage2_float_prep(ios_base& __iob, _CharT* __atoms, _CharT& __decimal_point,
   _CharT& __thousands_sep);
-static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
-  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
-  unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
+
 static int __stage2_float_loop(_CharT __ct, bool& __in_units, char& __exp,
char* __a, char*& __a_end,
_CharT __decimal_point, _CharT __thousands_sep,
const string& __grouping, unsigned* __g,
unsigned*& __g_end, unsigned& __dc, _CharT* __atoms);
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE
+static string __stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep);
+static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+  unsigned* __g, unsigned*& __g_end, _CharT* __atoms);
+
+#else
+static string __stage2_int_prep(ios_base& __iob, _CharT& __thousands_sep)
+{
+locale __loc = __iob.getloc();
+const numpunct<_CharT>& __np = use_facet >(__loc);
+__thousands_sep = __np.thousands_sep();
+return __np.grouping();
+}
+
+const _CharT* __do_widen(ios_base& __iob, _CharT* __atoms) const
+{
+  return __do_widen_p(__iob, __atoms);
+}
+
+
+static int __stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+  unsigned* __g, unsigned*& __g_end, const _CharT* __atoms);
+private:
+template
+const T* __do_widen_p(ios_base& __iob, T* __atoms) const
+{
+  locale __loc = __iob.getloc();
+  use_facet >(__loc).widen(__src, __src + 26, __atoms);
+  return __atoms;
+}
+
+const char* __do_widen_p(ios_base& __iob, char* __atoms) const
+{
+  (void)__iob;
+  (void)__atoms;
+  return __src;
+}
+#endif
 };
 
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE
 template 
 string
 __num_get<_CharT>::__stage2_int_prep(ios_base& __iob, _CharT* __atoms, _CharT& __thousands_sep)
@@ -403,6 +441,7 @@
 __thousands_sep = __np.thousands_sep();
 return __np.grouping();
 }
+#endif
 
 template 
 string
@@ -419,9 +458,17 @@
 
 template 
 int
+#ifndef _LIBCPP_ABI_OPTIMIZED_LOCALE
 __num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
   unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
   unsigned* __g, unsigned*& __g_end, _CharT* __atoms)
+#else
+__num_get<_CharT>::__stage2_int_loop(_CharT __ct, int __base, char* __a, char*& __a_end,
+  unsigned& __dc, _CharT __thousands_sep, const string& __grouping,
+  unsigned* __g, unsigned*& __g_end, const _CharT* __atoms)
+
+#endif
+
 {
 if (__a_end == __a && (__ct == __atoms[24] || __ct == __atoms[25]))
 {
@@ -857,9 +904,15 @@
 // Stage 1
 int __base = this->__get_base(__iob);
 // Stage 2
-char_type __atoms[26];
 char_type __thousands_sep;
+#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE
+char_type __atoms1[26];
+const char_type *__atoms = this->__do_widen(__iob, __atoms1);
+string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
+#else
+char_type __atoms[26];
 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
+#endif
 string __buf;
 __buf.resize(__buf.capacity());
 char* __a = &__buf[0];
@@ -907,9 +960,15 @@
 // Stage 1
 int __base = this->__get_base(__iob);
 // Stage 2
-char_type __atoms[26];
 char_type __thousands_sep;
+#ifdef _LIBCPP_ABI_OPTIMIZED_LOCALE
+char_type __atoms1[26];
+const char_type *__atoms = this->__do_widen(__iob, __atoms1);
+string __grouping = this->__stage2_int_prep(__iob, __thousands_sep);
+#else
+char_type __atoms[26];
 string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep);
+#endif
 string __buf;
 __buf.resize(__buf.capacity());
 char* __a = &__buf[0];
Index: libcxx/include/__config
===
--- libcxx/include/

[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: clang/test/Index/print-type.cpp:118
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] 
[typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] 
[canonicaltype=outer::Qux, int>] 
[canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] 
[type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] 
[type=int] [typekind=Int]] [isPOD=1]
 // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]

Hmm, that's an interesting change. I assume the test passed prior to this 
patch, right? Did this output change purely because of the change in 
`GetTemplateArguments`?


https://reviews.llvm.org/D32348



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


[PATCH] D32238: [Clangd] Failed to decode params using 1.x-compatible request message

2017-04-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300991: [Clangd] Failed to decode params using 
1.x-compatible request message (authored by d0k).

Changed prior to commit:
  https://reviews.llvm.org/D32238?vs=95811&id=96153#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32238

Files:
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/test/clangd/completion.test


Index: clang-tools-extra/trunk/test/clangd/completion.test
===
--- clang-tools-extra/trunk/test/clangd/completion.test
+++ clang-tools-extra/trunk/test/clangd/completion.test
@@ -30,6 +30,17 @@
 # CHECK-DAG: {"label":"bb","kind":5}
 # CHECK-DAG: {"label":"ccc","kind":5}
 # CHECK: ]}
+
+Content-Length: 172
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"uri":"file:///main.cpp","position":{"line":3,"character":5}}}
+# Test params parsing in the presence of a 1.x-compatible client (inlined 
"uri")
+#
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[
+# CHECK-DAG: {"label":"a","kind":5}
+# CHECK-DAG: {"label":"bb","kind":5}
+# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK: ]}
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
Index: clang-tools-extra/trunk/clangd/Protocol.cpp
===
--- clang-tools-extra/trunk/clangd/Protocol.cpp
+++ clang-tools-extra/trunk/clangd/Protocol.cpp
@@ -648,7 +648,7 @@
 auto *Value =
 dyn_cast_or_null(NextKeyValue.getValue());
 if (!Value)
-  return llvm::None;
+  continue;
 
 llvm::SmallString<10> Storage;
 if (KeyValue == "textDocument") {


Index: clang-tools-extra/trunk/test/clangd/completion.test
===
--- clang-tools-extra/trunk/test/clangd/completion.test
+++ clang-tools-extra/trunk/test/clangd/completion.test
@@ -30,6 +30,17 @@
 # CHECK-DAG: {"label":"bb","kind":5}
 # CHECK-DAG: {"label":"ccc","kind":5}
 # CHECK: ]}
+
+Content-Length: 172
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"uri":"file:///main.cpp","position":{"line":3,"character":5}}}
+# Test params parsing in the presence of a 1.x-compatible client (inlined "uri")
+#
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[
+# CHECK-DAG: {"label":"a","kind":5}
+# CHECK-DAG: {"label":"bb","kind":5}
+# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK: ]}
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
Index: clang-tools-extra/trunk/clangd/Protocol.cpp
===
--- clang-tools-extra/trunk/clangd/Protocol.cpp
+++ clang-tools-extra/trunk/clangd/Protocol.cpp
@@ -648,7 +648,7 @@
 auto *Value =
 dyn_cast_or_null(NextKeyValue.getValue());
 if (!Value)
-  return llvm::None;
+  continue;
 
 llvm::SmallString<10> Storage;
 if (KeyValue == "textDocument") {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r300991 - [Clangd] Failed to decode params using 1.x-compatible request message

2017-04-21 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Apr 21 10:51:23 2017
New Revision: 300991

URL: http://llvm.org/viewvc/llvm-project?rev=300991&view=rev
Log:
[Clangd] Failed to decode params using 1.x-compatible request message

textDocument/completion sends a TextDocumentPositionParams message in the 2.x
and 3.x. But in 1.x it was instead a TextDocumentPosition with inlined
parameters. This means that the "uri" field is at the top level and not in
textDocument. Because of this, some clients that maintain compability with 1.x
have both uri and textDocument.uri. Clangd, however, early returns in the
presence of anything but 'textDocument' or 'position' which prevents a client
compatible with both 3.x and 1.x to work correctly. If Clangd was a bit more
permissive (no early return), clients implementing all the versions of the
protocol would work.

Patch by Marc-Andre Laperle!

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

Modified:
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/test/clangd/completion.test

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=300991&r1=300990&r2=300991&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Fri Apr 21 10:51:23 2017
@@ -648,7 +648,7 @@ TextDocumentPositionParams::parse(llvm::
 auto *Value =
 dyn_cast_or_null(NextKeyValue.getValue());
 if (!Value)
-  return llvm::None;
+  continue;
 
 llvm::SmallString<10> Storage;
 if (KeyValue == "textDocument") {

Modified: clang-tools-extra/trunk/test/clangd/completion.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/completion.test?rev=300991&r1=300990&r2=300991&view=diff
==
--- clang-tools-extra/trunk/test/clangd/completion.test (original)
+++ clang-tools-extra/trunk/test/clangd/completion.test Fri Apr 21 10:51:23 2017
@@ -30,6 +30,17 @@ Content-Length: 146
 # CHECK-DAG: {"label":"bb","kind":5}
 # CHECK-DAG: {"label":"ccc","kind":5}
 # CHECK: ]}
+
+Content-Length: 172
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"uri":"file:///main.cpp","position":{"line":3,"character":5}}}
+# Test params parsing in the presence of a 1.x-compatible client (inlined 
"uri")
+#
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[
+# CHECK-DAG: {"label":"a","kind":5}
+# CHECK-DAG: {"label":"bb","kind":5}
+# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK: ]}
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}


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


[PATCH] D32234: [Clangd] Support Authority-less URIs

2017-04-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300990: [Clangd] Support Authority-less URIs (authored by 
d0k).

Changed prior to commit:
  https://reviews.llvm.org/D32234?vs=95809&id=96152#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32234

Files:
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/test/clangd/completion.test


Index: clang-tools-extra/trunk/test/clangd/completion.test
===
--- clang-tools-extra/trunk/test/clangd/completion.test
+++ clang-tools-extra/trunk/test/clangd/completion.test
@@ -20,6 +20,16 @@
 # CHECK-DAG: {"label":"bb","kind":5}
 # CHECK-DAG: {"label":"ccc","kind":5}
 # CHECK: ]}
+Content-Length: 146
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:/main.cpp"},"position":{"line":3,"character":5}}}
+# Test authority-less URI
+#
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[
+# CHECK-DAG: {"label":"a","kind":5}
+# CHECK-DAG: {"label":"bb","kind":5}
+# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK: ]}
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
Index: clang-tools-extra/trunk/clangd/Protocol.cpp
===
--- clang-tools-extra/trunk/clangd/Protocol.cpp
+++ clang-tools-extra/trunk/clangd/Protocol.cpp
@@ -25,6 +25,8 @@
   URI Result;
   Result.uri = uri;
   uri.consume_front("file://");
+  // Also trim authority-less URIs
+  uri.consume_front("file:");
   // For Windows paths e.g. /X:
   if (uri.size() > 2 && uri[0] == '/' && uri[2] == ':')
 uri.consume_front("/");


Index: clang-tools-extra/trunk/test/clangd/completion.test
===
--- clang-tools-extra/trunk/test/clangd/completion.test
+++ clang-tools-extra/trunk/test/clangd/completion.test
@@ -20,6 +20,16 @@
 # CHECK-DAG: {"label":"bb","kind":5}
 # CHECK-DAG: {"label":"ccc","kind":5}
 # CHECK: ]}
+Content-Length: 146
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:/main.cpp"},"position":{"line":3,"character":5}}}
+# Test authority-less URI
+#
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[
+# CHECK-DAG: {"label":"a","kind":5}
+# CHECK-DAG: {"label":"bb","kind":5}
+# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK: ]}
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
Index: clang-tools-extra/trunk/clangd/Protocol.cpp
===
--- clang-tools-extra/trunk/clangd/Protocol.cpp
+++ clang-tools-extra/trunk/clangd/Protocol.cpp
@@ -25,6 +25,8 @@
   URI Result;
   Result.uri = uri;
   uri.consume_front("file://");
+  // Also trim authority-less URIs
+  uri.consume_front("file:");
   // For Windows paths e.g. /X:
   if (uri.size() > 2 && uri[0] == '/' && uri[2] == ':')
 uri.consume_front("/");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r300990 - [Clangd] Support Authority-less URIs

2017-04-21 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Apr 21 10:51:18 2017
New Revision: 300990

URL: http://llvm.org/viewvc/llvm-project?rev=300990&view=rev
Log:
[Clangd] Support Authority-less URIs

Clangd strips URIs by removing the file:// part but some clients can send file:
which is also valid according to RFC 3896. For example, if a client sends
file:///home/user, it gets converted to /home/user but if a client sends
file:/home/user, it is left untouched and problems arise.

Patch by Marc-Andre Laperle!

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

Modified:
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/test/clangd/completion.test

Modified: clang-tools-extra/trunk/clangd/Protocol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Protocol.cpp?rev=300990&r1=300989&r2=300990&view=diff
==
--- clang-tools-extra/trunk/clangd/Protocol.cpp (original)
+++ clang-tools-extra/trunk/clangd/Protocol.cpp Fri Apr 21 10:51:18 2017
@@ -25,6 +25,8 @@ URI URI::fromUri(llvm::StringRef uri) {
   URI Result;
   Result.uri = uri;
   uri.consume_front("file://");
+  // Also trim authority-less URIs
+  uri.consume_front("file:");
   // For Windows paths e.g. /X:
   if (uri.size() > 2 && uri[0] == '/' && uri[2] == ':')
 uri.consume_front("/");

Modified: clang-tools-extra/trunk/test/clangd/completion.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/completion.test?rev=300990&r1=300989&r2=300990&view=diff
==
--- clang-tools-extra/trunk/test/clangd/completion.test (original)
+++ clang-tools-extra/trunk/test/clangd/completion.test Fri Apr 21 10:51:18 2017
@@ -20,6 +20,16 @@ Content-Length: 148
 # CHECK-DAG: {"label":"bb","kind":5}
 # CHECK-DAG: {"label":"ccc","kind":5}
 # CHECK: ]}
+Content-Length: 146
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:/main.cpp"},"position":{"line":3,"character":5}}}
+# Test authority-less URI
+#
+# CHECK: {"jsonrpc":"2.0","id":1,"result":[
+# CHECK-DAG: {"label":"a","kind":5}
+# CHECK-DAG: {"label":"bb","kind":5}
+# CHECK-DAG: {"label":"ccc","kind":5}
+# CHECK: ]}
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}


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


[PATCH] D32234: [Clangd] Support Authority-less URIs

2017-04-21 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added a comment.

Still looking good. Will commit this soon.


https://reviews.llvm.org/D32234



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


[PATCH] D32234: [Clangd] Support Authority-less URIs

2017-04-21 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle-ericsson added a comment.

Benjamin, I added a test, do you still think it's OK? Thanks!


https://reviews.llvm.org/D32234



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


[PATCH] D32238: [Clangd] Failed to decode params using 1.x-compatible request message

2017-04-21 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle-ericsson added a comment.

Could you commit it? I don't have commit access :) Thanks!


https://reviews.llvm.org/D32238



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


[PATCH] D32351: [Tooling][libclang] Remove unused CompilationDatabase::MappedSources

2017-04-21 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer added a comment.

lg from my side. It would be good to wait until Manuel is back though, I think 
he had plans for extending this interface at some point.


https://reviews.llvm.org/D32351



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


r300988 - [OpenCL] Fix semantic check of ndrange_t for device_side_enqueue.

2017-04-21 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Fri Apr 21 10:13:24 2017
New Revision: 300988

URL: http://llvm.org/viewvc/llvm-project?rev=300988&view=rev
Log:
[OpenCL] Fix semantic check of ndrange_t for device_side_enqueue.

Check unqualified type for ndrange argument in device_side_enqueue so
device_side_enqueue accept const and volatile qualified ndranges.

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

Patch by Dmitry Borisenkov!


Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaOpenCL/cl20-device-side-enqueue.cl

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=300988&r1=300987&r2=300988&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Apr 21 10:13:24 2017
@@ -408,7 +408,7 @@ static bool SemaOpenCLBuiltinEnqueueKern
   }
 
   // Third argument is always an ndrange_t type.
-  if (Arg2->getType().getAsString() != "ndrange_t") {
+  if (Arg2->getType().getUnqualifiedType().getAsString() != "ndrange_t") {
 S.Diag(TheCall->getArg(2)->getLocStart(),
diag::err_opencl_enqueue_kernel_expected_type)
 << "'ndrange_t'";

Modified: cfe/trunk/test/SemaOpenCL/cl20-device-side-enqueue.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/cl20-device-side-enqueue.cl?rev=300988&r1=300987&r2=300988&view=diff
==
--- cfe/trunk/test/SemaOpenCL/cl20-device-side-enqueue.cl (original)
+++ cfe/trunk/test/SemaOpenCL/cl20-device-side-enqueue.cl Fri Apr 21 10:13:24 
2017
@@ -1,12 +1,14 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify 
-pedantic -fsyntax-only -Wconversion -DWCONV
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32 -DQUALS=
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32 -DQUALS="const volatile"
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify 
-pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify 
-pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
 
 typedef struct {int a;} ndrange_t;
 // Diagnostic tests for different overloads of enqueue_kernel from Table 
6.13.17.1 of OpenCL 2.0 Spec.
 kernel void enqueue_kernel_tests() {
   queue_t default_queue;
   unsigned flags = 0;
-  ndrange_t ndrange;
+  QUALS ndrange_t ndrange;
   clk_event_t evt;
   clk_event_t event_wait_list;
   clk_event_t event_wait_list2[] = {evt, evt};


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


[PATCH] D30691: [analyzer] Support for naive cross translational unit analysis

2017-04-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked 6 inline comments as done and an inline comment as not done.
xazax.hun added a comment.

In https://reviews.llvm.org/D30691#731617, @zaks.anna wrote:

> I agree that scan-build or scan-build-py integration is an important issue to 
> resolve here. What I envision is that users will just call scan-build and 
> pass -whole-project as an option to it. Everything else will happen 
> automagically:)


We had a skype meeting with Laszlo. He had no objections adding this to 
scan-build-py.

> Another concern is dumping the ASTs to the disk. There are really 2 concerns 
> here. First one is the high disk usage, which is a blocker for having higher 
> adoption. Second is that I am not sure how complete and reliable AST 
> serialization and deserialization are. Are those components used for 
> something else that is running in production or are we just utilizing 
> -ast-dump, which is used for debugging? I do not quite understand why AST 
> serialization is needed at all. Can we instead recompile the translation 
> units on demand into a separate ASTContext and then ASTImport?

According to our measurements there are some optimization possibilities in the 
serialized AST format. Even though it might not get us an order of magnitude 
improvement, it can be still very significant. The main reason, why the AST 
dumps are so large: duplicated AST parts from the headers. Once modules are 
supported and utilized, the size could be reduced once again significantly.
The serialization/deserialization of AST nodes should be very reliable. The 
same mechanisms are used for precompiled headers and modules.

AST serialization is there to avoid the time overhead of reparsing translation 
units. This can be a big win for translation units that have metaprograms. 
Technically, I can not see any obstackles in reparsing a translation unit on 
demand, but we did not measure how much slower would that be. 
Having a serialized format could also make it possible to only load fragmets of 
the AST into the memory instead of the whole translation unit. (This feature is 
currently not utilized by this patch.)




Comment at: include/clang/AST/Decl.h:53
 class VarTemplateDecl;
+class CompilerInstance;
 

dcoughlin wrote:
> Is this needed? It seems like a layering violation.
Good catch, this is redundant. I will remove this in the next patch. 



Comment at: include/clang/AST/Mangle.h:59
+  // the static analyzer.
+  bool ShouldForceMangleProto;
 

dcoughlin wrote:
> I'm pretty worried about using C++ mangling for C functions. It doesn't ever 
> seem appropriate to do so and it sounds like it is papering over problems 
> with the design.
> 
> Some questions:
> - How do you handle when two translation units have different C functions 
> with the same type signatures? Is there a collision? This can arise because 
> of two-level namespacing or when building multiple targets with the same CTU 
> directory.
> - How do you handle when a C function has the same signature as a C++ 
> function. Is there a collision when you mangle the C function?
I agree that using C++ mangling for C+ is not the nicest solution, and I had to 
circumvent a problem in the name mangler for C prototypes.

In case a mangled name is found in multiple source files, it will not be 
imported. This is the way how collisions handled regardless of being C or C++ 
functions. 
The target arch is appended to the mangled name to support the cross 
compilation scenario. Currently we do not add the full triple, but this could 
be done.

An alternative solution would be to use USRs instead of mangled names but we 
did not explore this option in depth yet. 



Comment at: lib/AST/ASTContext.cpp:1481
+  assert(!FD->hasBody() && "FD has a definition in current translation unit!");
+  if (!FD->getType()->getAs())
+return nullptr; // Cannot even mangle that.

a.sidorin wrote:
> This needs a FIXME because currently many functions cannot be analyzed 
> because of it.
What do you mean here?


https://reviews.llvm.org/D30691



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


[PATCH] D31739: Add markup for libc++ dylib availability

2017-04-21 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: utils/libcxx/test/config.py:387
+self.config.available_features.add(
+'with_system_cxx_lib=%s' % component)
 

mehdi_amini wrote:
> jroelofs wrote:
> > Is it worth filtering out `none` and `unknown`, as they're often repeated, 
> > and you can't tell which part of the triple they came from?
> > 
> > Consider: `arm-none-linux-gnueabi` vs `arm-none-none-eabi`.
> > 
> > Or would it be better to include some marker in the features to say which 
> > part of the triple it came from, eg:
> > 
> > ```
> >   - with_system_cxx_lib=arch:arm
> >   - with_system_cxx_lib=vendor:none
> >   - with_system_cxx_lib=os:linux
> >   - with_system_cxx_lib=sys:gnueabi
> > ```
> I like this idea! 
> It seems like orthogonal to the availability introduced here, so it'd belong 
> to a separate patch I think.
sounds fine to me!


https://reviews.llvm.org/D31739



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


[PATCH] D29659: [OpenMP] Add flag for disabling the default generation of relocatable OpenMP target code for NVIDIA GPUs.

2017-04-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rL LLVM

https://reviews.llvm.org/D29659



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


[PATCH] D29659: [OpenMP] Add flag for disabling the default generation of relocatable OpenMP target code for NVIDIA GPUs.

2017-04-21 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 96144.
gtbercea added a comment.

Refactor if condition.


Repository:
  rL LLVM

https://reviews.llvm.org/D29659

Files:
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -608,6 +608,23 @@
 
 /// ###
 
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device 
using OpenMP - disable it.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-fnoopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-NORELO %s
+
+// CHK-PTXAS-NORELO-NOT: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device 
using OpenMP
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
+
+// CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s 
intermediate files.
 // RUN:   %clang -### -fopenmp=libomp 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes 
%s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -295,7 +295,10 @@
 CmdArgs.push_back(Args.MakeArgString(A));
 
   // In OpenMP we need to generate relocatable code.
-  if (JA.isOffloading(Action::OFK_OpenMP))
+  if (JA.isOffloading(Action::OFK_OpenMP) &&
+  Args.hasFlag(options::OPT_fopenmp_relocatable_target,
+   options::OPT_fnoopenmp_relocatable_target,
+   /*Default=*/ true))
 CmdArgs.push_back("-c");
 
   const char *Exec;
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1260,6 +1260,10 @@
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
 def fopenmp_dump_offload_linker_script : Flag<["-"], 
"fopenmp-dump-offload-linker-script">, Group, 
   Flags<[NoArgumentUnused]>;
+def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">, 
Group, Flags<[CC1Option, NoArgumentUnused]>,
+  HelpText<"OpenMP target code is compiled as relocatable using the -c flag. 
For OpenMP targets the code is relocatable by default.">;
+def fnoopenmp_relocatable_target : Flag<["-"], 
"fnoopenmp-relocatable-target">, Group, Flags<[CC1Option, 
NoArgumentUnused]>,
+  HelpText<"Do not compile OpenMP target code as relocatable.">;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
 def force__cpusubtype__ALL : Flag<["-"], "force_cpusubtype_ALL">;


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -608,6 +608,23 @@
 
 /// ###
 
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP - disable it.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fnoopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-NORELO %s
+
+// CHK-PTXAS-NORELO-NOT: ptxas{{.*}}" "-c"
+
+/// ###
+
+/// PTXAS is passed -c flag by default when offloading to an NVIDIA device using OpenMP
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-RELO %s
+
+// CHK-PTXAS-RELO: ptxas{{.*}}" "-c"
+
+/// ###
+
 /// Check -fopenmp-is-device is also passed when generating the *.i and *.s intermediate files.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=powerpc64le-ibm-linux-gnu -save-temps -no-canonical-prefixes %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-IS-DEVICE %s
Index:

[PATCH] D32298: [clang-format] Replace IncompleteFormat by a struct with Line

2017-04-21 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300985: [clang-format] Replace IncompleteFormat by a struct 
with Line (authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D32298?vs=96131&id=96141#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32298

Files:
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/Format.cpp
  cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
  cfe/trunk/lib/Format/UnwrappedLineFormatter.h
  cfe/trunk/test/Format/incomplete.cpp
  cfe/trunk/tools/clang-format/ClangFormat.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp
  cfe/trunk/unittests/Format/FormatTestComments.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp
  cfe/trunk/unittests/Format/FormatTestObjC.cpp
  cfe/trunk/unittests/Format/FormatTestSelective.cpp

Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -1512,6 +1512,18 @@
 cleanupAroundReplacements(StringRef Code, const tooling::Replacements &Replaces,
   const FormatStyle &Style);
 
+/// \brief Represents the status of a formatting attempt.
+struct FormattingAttemptStatus {
+  /// \brief A value of ``false`` means that any of the affected ranges were not
+  /// formatted due to a non-recoverable syntax error.
+  bool FormatComplete = true;
+
+  /// \brief If ``FormatComplete`` is false, ``Line`` records a one-based
+  /// original line number at which a syntax error might have occurred. This is
+  /// based on a best-effort analysis and could be imprecise.
+  unsigned Line = 0;
+};
+
 /// \brief Reformats the given \p Ranges in \p Code.
 ///
 /// Each range is extended on either end to its next bigger logic unit, i.e.
@@ -1521,13 +1533,20 @@
 /// Returns the ``Replacements`` necessary to make all \p Ranges comply with
 /// \p Style.
 ///
-/// If ``IncompleteFormat`` is non-null, its value will be set to true if any
-/// of the affected ranges were not formatted due to a non-recoverable syntax
-/// error.
+/// If ``Status`` is non-null, its value will be populated with the status of
+/// this formatting attempt. See \c FormattingAttemptStatus.
 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
ArrayRef Ranges,
StringRef FileName = "",
-   bool *IncompleteFormat = nullptr);
+   FormattingAttemptStatus *Status = nullptr);
+
+/// \brief Same as above, except if ``IncompleteFormat`` is non-null, its value
+/// will be set to true if any of the affected ranges were not formatted due to
+/// a non-recoverable syntax error.
+tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
+   ArrayRef Ranges,
+   StringRef FileName,
+   bool *IncompleteFormat);
 
 /// \brief Clean up any erroneous/redundant code in the given \p Ranges in \p
 /// Code.
Index: cfe/trunk/test/Format/incomplete.cpp
===
--- cfe/trunk/test/Format/incomplete.cpp
+++ cfe/trunk/test/Format/incomplete.cpp
@@ -1,6 +1,6 @@
 // RUN: grep -Ev "// *[A-Z-]+:" %s | clang-format -style=LLVM -cursor=0 \
 // RUN:   | FileCheck -strict-whitespace %s
-// CHECK: {{"IncompleteFormat": true}}
+// CHECK: {{"IncompleteFormat": true, "Line": 2}}
 // CHECK: {{^int\ \i;$}}
  inti;
 // CHECK: {{^f  \( g  \(;$}}
Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.h
===
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.h
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.h
@@ -32,9 +32,11 @@
  WhitespaceManager *Whitespaces,
  const FormatStyle &Style,
  const AdditionalKeywords &Keywords,
- bool *IncompleteFormat)
+ const SourceManager &SourceMgr,
+ FormattingAttemptStatus *Status)
   : Indenter(Indenter), Whitespaces(Whitespaces), Style(Style),
-Keywords(Keywords), IncompleteFormat(IncompleteFormat) {}
+Keywords(Keywords), SourceMgr(SourceMgr),
+Status(Status) {}
 
   /// \brief Format the current block and return the penalty.
   unsigned format(const SmallVectorImpl &Lines,
@@ -63,7 +65,8 @@
   WhitespaceManager *Whitespaces;
   const FormatStyle &Style;
   const AdditionalKeywords &Keywords;
-  bool *IncompleteFormat;
+  const SourceManager &SourceMgr;
+  FormattingAttemptStatus *Status;
 };
 } // end namespace format
 } // end namespace clang
Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
+++ cfe/trunk/lib/For

r300985 - [clang-format] Replace IncompleteFormat by a struct with Line

2017-04-21 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Fri Apr 21 09:35:20 2017
New Revision: 300985

URL: http://llvm.org/viewvc/llvm-project?rev=300985&view=rev
Log:
[clang-format] Replace IncompleteFormat by a struct with Line

Summary: This patch replaces the boolean IncompleteFormat that is used to 
notify the client if an unrecoverable syntax error occurred by a struct that 
also contains a line number.

Reviewers: djasper

Reviewed By: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/lib/Format/UnwrappedLineFormatter.h
cfe/trunk/test/Format/incomplete.cpp
cfe/trunk/tools/clang-format/ClangFormat.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Format/FormatTestComments.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp
cfe/trunk/unittests/Format/FormatTestSelective.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=300985&r1=300984&r2=300985&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Fri Apr 21 09:35:20 2017
@@ -1512,6 +1512,18 @@ llvm::Expected
 cleanupAroundReplacements(StringRef Code, const tooling::Replacements 
&Replaces,
   const FormatStyle &Style);
 
+/// \brief Represents the status of a formatting attempt.
+struct FormattingAttemptStatus {
+  /// \brief A value of ``false`` means that any of the affected ranges were 
not
+  /// formatted due to a non-recoverable syntax error.
+  bool FormatComplete = true;
+
+  /// \brief If ``FormatComplete`` is false, ``Line`` records a one-based
+  /// original line number at which a syntax error might have occurred. This is
+  /// based on a best-effort analysis and could be imprecise.
+  unsigned Line = 0;
+};
+
 /// \brief Reformats the given \p Ranges in \p Code.
 ///
 /// Each range is extended on either end to its next bigger logic unit, i.e.
@@ -1521,13 +1533,20 @@ cleanupAroundReplacements(StringRef Code
 /// Returns the ``Replacements`` necessary to make all \p Ranges comply with
 /// \p Style.
 ///
-/// If ``IncompleteFormat`` is non-null, its value will be set to true if any
-/// of the affected ranges were not formatted due to a non-recoverable syntax
-/// error.
+/// If ``Status`` is non-null, its value will be populated with the status of
+/// this formatting attempt. See \c FormattingAttemptStatus.
 tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
ArrayRef Ranges,
StringRef FileName = "",
-   bool *IncompleteFormat = nullptr);
+   FormattingAttemptStatus *Status = nullptr);
+
+/// \brief Same as above, except if ``IncompleteFormat`` is non-null, its value
+/// will be set to true if any of the affected ranges were not formatted due to
+/// a non-recoverable syntax error.
+tooling::Replacements reformat(const FormatStyle &Style, StringRef Code,
+   ArrayRef Ranges,
+   StringRef FileName,
+   bool *IncompleteFormat);
 
 /// \brief Clean up any erroneous/redundant code in the given \p Ranges in \p
 /// Code.

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=300985&r1=300984&r2=300985&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Fri Apr 21 09:35:20 2017
@@ -908,8 +908,8 @@ private:
 class Formatter : public TokenAnalyzer {
 public:
   Formatter(const Environment &Env, const FormatStyle &Style,
-bool *IncompleteFormat)
-  : TokenAnalyzer(Env, Style), IncompleteFormat(IncompleteFormat) {}
+FormattingAttemptStatus *Status)
+  : TokenAnalyzer(Env, Style), Status(Status) {}
 
   tooling::Replacements
   analyze(TokenAnnotator &Annotator,
@@ -931,7 +931,7 @@ public:
   Env.getSourceManager(), Whitespaces, 
Encoding,
   BinPackInconclusiveFunctions);
 UnwrappedLineFormatter(&Indenter, &Whitespaces, Style, 
Tokens.getKeywords(),
-   IncompleteFormat)
+   Env.getSourceManager(), Status)
 .format(AnnotatedLines);
 for (const auto &R : Whitespaces.generateReplacements())
   if (Result.add(R))
@@ -1013,7 +1013,7 @@ private:
   }
 
   bool BinPackInconclusiveFunctions;
-  bool *IncompleteFormat;
+  FormattingAttemptStatus *Status;
 };
 
 // This class clean up the 

r300983 - [clang-format] Clang-tidy cleanup of NamespaceEndCommentFixerTest.cpp, NFC

2017-04-21 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Fri Apr 21 09:30:01 2017
New Revision: 300983

URL: http://llvm.org/viewvc/llvm-project?rev=300983&view=rev
Log:
[clang-format] Clang-tidy cleanup of NamespaceEndCommentFixerTest.cpp, NFC

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

Modified: cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp?rev=300983&r1=300982&r2=300983&view=diff
==
--- cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp (original)
+++ cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp Fri Apr 21 
09:30:01 2017
@@ -23,7 +23,7 @@ class NamespaceEndCommentsFixerTest : pu
 protected:
   std::string
   fixNamespaceEndComments(llvm::StringRef Code,
-  std::vector Ranges,
+  const std::vector &Ranges,
   const FormatStyle &Style = getLLVMStyle()) {
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");


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


[PATCH] D32346: [clang-tidy] New readability check for strlen argument

2017-04-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

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




Comment at: docs/clang-tidy/checks/readability-strlen-argument.rst:6
+
+This checker will detect addition in strlen() argument. Example code:
+

JonasToth wrote:
> Could you please add a little more motivational text to it?
> As I understand it, the wanted goal is to get the length of a substring, 
> denoted as `char*`. Am I right?
> You could give a more fully code example showing the equivalence.
> 
> `const char* = "Some super nice string"; `
Please use check, not checker. Please enclose strlen() into ``.


Repository:
  rL LLVM

https://reviews.llvm.org/D32346



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


[PATCH] D32298: [clang-format] Replace IncompleteFormat by a struct with Line

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

Sounds good.


https://reviews.llvm.org/D32298



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


r300982 - [clang-format] Clang-tidy cleanup of CleanupTest.cpp, NFC

2017-04-21 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Fri Apr 21 09:21:21 2017
New Revision: 300982

URL: http://llvm.org/viewvc/llvm-project?rev=300982&view=rev
Log:
[clang-format] Clang-tidy cleanup of CleanupTest.cpp, NFC

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

Modified: cfe/trunk/unittests/Format/CleanupTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CleanupTest.cpp?rev=300982&r1=300981&r2=300982&view=diff
==
--- cfe/trunk/unittests/Format/CleanupTest.cpp (original)
+++ cfe/trunk/unittests/Format/CleanupTest.cpp Fri Apr 21 09:21:21 2017
@@ -292,7 +292,7 @@ protected:
   }
 
   inline std::string apply(StringRef Code,
-   const tooling::Replacements Replaces) {
+   const tooling::Replacements &Replaces) {
 auto CleanReplaces = cleanupAroundReplacements(Code, Replaces, Style);
 EXPECT_TRUE(static_cast(CleanReplaces))
 << llvm::toString(CleanReplaces.takeError()) << "\n";
@@ -302,8 +302,7 @@ protected:
   }
 
   inline std::string formatAndApply(StringRef Code,
-const tooling::Replacements Replaces) {
-
+const tooling::Replacements &Replaces) {
 auto CleanReplaces = cleanupAroundReplacements(Code, Replaces, Style);
 EXPECT_TRUE(static_cast(CleanReplaces))
 << llvm::toString(CleanReplaces.takeError()) << "\n";


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


[PATCH] D32298: [clang-format] Replace IncompleteFormat by a struct with Line

2017-04-21 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: include/clang/Format/Format.h:1524
+  /// best-effort analysis, and could be imprecise.
+  unsigned Line = 0;
+};

krasimir wrote:
> djasper wrote:
> > Hm. Something we might need to be thinking about here is whether this 
> > should be the line before or after formatting. So specifically, if I format:
> > 
> >   int a
> >   = 1;
> >   f(
> > 
> > Then, this gets reformatted to:
> > 
> >   int a = 1;
> >   f(
> > 
> > Would we want the Line to be 2 or 3?
> I'd go with the original line, because I think it might be more useful and 
> because it's easier to implement.
Even better: the line after formatting is functionally dependent on the line 
before formatting and the replacements. I see two use-cases: clients that 
refuse to format in case of syntax error, then they can just use the original 
line, and clients that apply the partial replacements, which can compute the 
line after formatting from them and the original line.


https://reviews.llvm.org/D32298



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


r300981 - [PR32667] -Wdocumentation should allow @param/@returns for fields/variables

2017-04-21 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Fri Apr 21 09:17:49 2017
New Revision: 300981

URL: http://llvm.org/viewvc/llvm-project?rev=300981&view=rev
Log:
[PR32667] -Wdocumentation should allow @param/@returns for fields/variables
that have a function/block pointer type

This commit improves the -Wdocumentation warning by making sure that @param and
@returns commands won't trigger warnings when used for fields, variables,
or properties whose type is a function/block pointer type. The
function/block pointer type must be specified directly with the declaration,
and when a typedef is used the warning is still emitted.

In the future we might also want to handle the std::function type as well.

rdar://24978538

Modified:
cfe/trunk/include/clang/AST/CommentSema.h
cfe/trunk/lib/AST/Comment.cpp
cfe/trunk/lib/AST/CommentSema.cpp
cfe/trunk/test/Sema/warn-documentation.cpp
cfe/trunk/test/Sema/warn-documentation.m

Modified: cfe/trunk/include/clang/AST/CommentSema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CommentSema.h?rev=300981&r1=300980&r2=300981&view=diff
==
--- cfe/trunk/include/clang/AST/CommentSema.h (original)
+++ cfe/trunk/include/clang/AST/CommentSema.h Fri Apr 21 09:17:49 2017
@@ -208,6 +208,10 @@ public:
   /// \returns \c true if declaration that this comment is attached to declares
   /// a function pointer.
   bool isFunctionPointerVarDecl();
+  /// \returns \c true if the declaration that this comment is attached to
+  /// declares a variable or a field whose type is a function or a block
+  /// pointer.
+  bool isFunctionOrBlockPointerVarLikeDecl();
   bool isFunctionOrMethodVariadic();
   bool isObjCMethodDecl();
   bool isObjCPropertyDecl();

Modified: cfe/trunk/lib/AST/Comment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Comment.cpp?rev=300981&r1=300980&r2=300981&view=diff
==
--- cfe/trunk/lib/AST/Comment.cpp (original)
+++ cfe/trunk/lib/AST/Comment.cpp Fri Apr 21 09:17:49 2017
@@ -280,8 +280,25 @@ void DeclInfo::fill() {
   case Decl::EnumConstant:
   case Decl::ObjCIvar:
   case Decl::ObjCAtDefsField:
+  case Decl::ObjCProperty: {
+const TypeSourceInfo *TSI;
+if (const auto *VD = dyn_cast(CommentDecl))
+  TSI = VD->getTypeSourceInfo();
+else if (const auto *PD = dyn_cast(CommentDecl))
+  TSI = PD->getTypeSourceInfo();
+else
+  TSI = nullptr;
+if (TSI) {
+  TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
+  FunctionTypeLoc FTL;
+  if (getFunctionTypeLoc(TL, FTL)) {
+ParamVars = FTL.getParams();
+ReturnType = FTL.getReturnLoc().getType();
+  }
+}
 Kind = VariableKind;
 break;
+  }
   case Decl::Namespace:
 Kind = NamespaceKind;
 break;

Modified: cfe/trunk/lib/AST/CommentSema.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/CommentSema.cpp?rev=300981&r1=300980&r2=300981&view=diff
==
--- cfe/trunk/lib/AST/CommentSema.cpp (original)
+++ cfe/trunk/lib/AST/CommentSema.cpp Fri Apr 21 09:17:49 2017
@@ -86,7 +86,7 @@ ParamCommandComment *Sema::actOnParamCom
   new (Allocator) ParamCommandComment(LocBegin, LocEnd, CommandID,
   CommandMarker);
 
-  if (!isFunctionDecl())
+  if (!isFunctionDecl() && !isFunctionOrBlockPointerVarLikeDecl())
 Diag(Command->getLocation(),
  diag::warn_doc_param_not_attached_to_a_function_decl)
   << CommandMarker
@@ -584,7 +584,7 @@ void Sema::checkReturnsCommand(const Blo
 
   assert(ThisDeclInfo && "should not call this check on a bare comment");
 
-  if (isFunctionDecl()) {
+  if (isFunctionDecl() || isFunctionOrBlockPointerVarLikeDecl()) {
 if (ThisDeclInfo->ReturnType->isVoidType()) {
   unsigned DiagKind;
   switch (ThisDeclInfo->CommentDecl->getKind()) {
@@ -844,6 +844,30 @@ bool Sema::isFunctionPointerVarDecl() {
   return false;
 }
 
+bool Sema::isFunctionOrBlockPointerVarLikeDecl() {
+  if (!ThisDeclInfo)
+return false;
+  if (!ThisDeclInfo->IsFilled)
+inspectThisDecl();
+  if (ThisDeclInfo->getKind() != DeclInfo::VariableKind ||
+  !ThisDeclInfo->CurrentDecl)
+return false;
+  QualType QT;
+  if (const auto *VD = dyn_cast(ThisDeclInfo->CurrentDecl))
+QT = VD->getType();
+  else if (const auto *PD =
+   dyn_cast(ThisDeclInfo->CurrentDecl))
+QT = PD->getType();
+  else
+return false;
+  // We would like to warn about the 'returns'/'param' commands for
+  // variables that don't directly specify the function type, so type aliases
+  // can be ignored.
+  if (QT->getAs())
+return false;
+  return QT->isFunctionPointerType() || QT->isBlockPointerType();
+}
+
 bool Sema::isObjCPropertyDecl() {
   if (!ThisDeclInfo)
 return false;

Modified: cfe/trunk/test/Sema/warn-documentation.c

[PATCH] D32351: [Tooling, libclang] Remove unused CompilationDatabase::MappedSources

2017-04-21 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a subscriber: klimek.

This field is never assigned to and it's only ever read from libclang.
This patch removes it and adapts libclang to return constants.


https://reviews.llvm.org/D32351

Files:
  include/clang/Tooling/CompilationDatabase.h
  tools/libclang/CXCompilationDatabase.cpp


Index: tools/libclang/CXCompilationDatabase.cpp
===
--- tools/libclang/CXCompilationDatabase.cpp
+++ tools/libclang/CXCompilationDatabase.cpp
@@ -145,36 +145,23 @@
 unsigned
 clang_CompileCommand_getNumMappedSources(CXCompileCommand CCmd)
 {
-  if (!CCmd)
-return 0;
-
-  return static_cast(CCmd)->MappedSources.size();
+  // Left here for backward compatibility. No mapped sources exists in the C++
+  // backend anymore.
+  return 0;
 }
 
 CXString
 clang_CompileCommand_getMappedSourcePath(CXCompileCommand CCmd, unsigned I)
 {
-  if (!CCmd)
-return cxstring::createNull();
-
-  CompileCommand *Cmd = static_cast(CCmd);
-
-  if (I >= Cmd->MappedSources.size())
-return cxstring::createNull();
-
-  return cxstring::createRef(Cmd->MappedSources[I].first.c_str());
+  // Left here for backward compatibility. No mapped sources exists in the C++
+  // backend anymore.
+  return cxstring::createNull();
 }
 
 CXString
 clang_CompileCommand_getMappedSourceContent(CXCompileCommand CCmd, unsigned I)
 {
-  if (!CCmd)
-return cxstring::createNull();
-
-  CompileCommand *Cmd = static_cast(CCmd);
-
-  if (I >= Cmd->MappedSources.size())
-return cxstring::createNull();
-
-  return cxstring::createRef(Cmd->MappedSources[I].second.c_str());
+  // Left here for backward compatibility. No mapped sources exists in the C++
+  // backend anymore.
+  return cxstring::createNull();
 }
Index: include/clang/Tooling/CompilationDatabase.h
===
--- include/clang/Tooling/CompilationDatabase.h
+++ include/clang/Tooling/CompilationDatabase.h
@@ -60,16 +60,6 @@
 
   /// The output file associated with the command.
   std::string Output;
-
-  /// \brief An optional mapping from each file's path to its content for all
-  /// files needed for the compilation that are not available via the file
-  /// system.
-  ///
-  /// Note that a tool implementation is required to fall back to the file
-  /// system if a source file is not provided in the mapped sources, as
-  /// compilation databases will usually not provide all files in mapped 
sources
-  /// for performance reasons.
-  std::vector > MappedSources;
 };
 
 /// \brief Interface for compilation databases.


Index: tools/libclang/CXCompilationDatabase.cpp
===
--- tools/libclang/CXCompilationDatabase.cpp
+++ tools/libclang/CXCompilationDatabase.cpp
@@ -145,36 +145,23 @@
 unsigned
 clang_CompileCommand_getNumMappedSources(CXCompileCommand CCmd)
 {
-  if (!CCmd)
-return 0;
-
-  return static_cast(CCmd)->MappedSources.size();
+  // Left here for backward compatibility. No mapped sources exists in the C++
+  // backend anymore.
+  return 0;
 }
 
 CXString
 clang_CompileCommand_getMappedSourcePath(CXCompileCommand CCmd, unsigned I)
 {
-  if (!CCmd)
-return cxstring::createNull();
-
-  CompileCommand *Cmd = static_cast(CCmd);
-
-  if (I >= Cmd->MappedSources.size())
-return cxstring::createNull();
-
-  return cxstring::createRef(Cmd->MappedSources[I].first.c_str());
+  // Left here for backward compatibility. No mapped sources exists in the C++
+  // backend anymore.
+  return cxstring::createNull();
 }
 
 CXString
 clang_CompileCommand_getMappedSourceContent(CXCompileCommand CCmd, unsigned I)
 {
-  if (!CCmd)
-return cxstring::createNull();
-
-  CompileCommand *Cmd = static_cast(CCmd);
-
-  if (I >= Cmd->MappedSources.size())
-return cxstring::createNull();
-
-  return cxstring::createRef(Cmd->MappedSources[I].second.c_str());
+  // Left here for backward compatibility. No mapped sources exists in the C++
+  // backend anymore.
+  return cxstring::createNull();
 }
Index: include/clang/Tooling/CompilationDatabase.h
===
--- include/clang/Tooling/CompilationDatabase.h
+++ include/clang/Tooling/CompilationDatabase.h
@@ -60,16 +60,6 @@
 
   /// The output file associated with the command.
   std::string Output;
-
-  /// \brief An optional mapping from each file's path to its content for all
-  /// files needed for the compilation that are not available via the file
-  /// system.
-  ///
-  /// Note that a tool implementation is required to fall back to the file
-  /// system if a source file is not provided in the mapped sources, as
-  /// compilation databases will usually not provide all files in mapped sources
-  /// for performance reasons.
-  std::vector > MappedSources;
 };
 
 /// \brief Interface for compilation databases.
___
cfe-commits

[PATCH] D32199: [TySan] A Type Sanitizer (Clang)

2017-04-21 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel updated this revision to Diff 96135.
hfinkel retitled this revision from "[TBAASan] A TBAA Sanitizer (Clang)" to 
"[TySan] A Type Sanitizer (Clang)".
hfinkel edited the summary of this revision.
hfinkel added a comment.

Rename TBAASanitizer -> TypeSanitizer


https://reviews.llvm.org/D32199

Files:
  include/clang/Basic/Sanitizers.def
  include/clang/Driver/SanitizerArgs.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenTBAA.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChains/CommonArgs.cpp
  lib/Driver/ToolChains/Linux.cpp
  lib/Lex/PPMacroExpansion.cpp
  test/CodeGen/sanitize-type-attr.cpp
  test/Driver/sanitizer-ld.c

Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -181,6 +181,18 @@
 
 // RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ \
+// RUN: -fsanitize=type \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-TYSAN-LINUX-CXX %s
+//
+// CHECK-TYSAN-LINUX-CXX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-TYSAN-LINUX-CXX-NOT: stdc++
+// CHECK-TYSAN-LINUX-CXX: "-whole-archive" "{{.*}}libclang_rt.tysan-x86_64.a" "-no-whole-archive"
+// CHECK-TYSAN-LINUX-CXX: stdc++
+
+// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target x86_64-unknown-linux -fuse-ld=ld -stdlib=platform -lstdc++ \
 // RUN: -fsanitize=memory \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
Index: test/CodeGen/sanitize-type-attr.cpp
===
--- /dev/null
+++ test/CodeGen/sanitize-type-attr.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck -check-prefix=WITHOUT %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -fsanitize=type | FileCheck -check-prefix=TYSAN %s
+// RUN: echo "src:%s" | sed -e 's/\\//g' > %t
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s -fsanitize=type -fsanitize-blacklist=%t | FileCheck -check-prefix=BL %s
+
+// The sanitize_type attribute should be attached to functions
+// when TypeSanitizer is enabled, unless no_sanitize("type") attribute
+// is present.
+
+// WITHOUT:  NoTYSAN1{{.*}}) [[NOATTR:#[0-9]+]]
+// BL:  NoTYSAN1{{.*}}) [[NOATTR:#[0-9]+]]
+// TYSAN:  NoTYSAN1{{.*}}) [[NOATTR:#[0-9]+]]
+__attribute__((no_sanitize("type")))
+int NoTYSAN1(int *a) { return *a; }
+
+// WITHOUT:  NoTYSAN2{{.*}}) [[NOATTR]]
+// BL:  NoTYSAN2{{.*}}) [[NOATTR]]
+// TYSAN:  NoTYSAN2{{.*}}) [[NOATTR]]
+__attribute__((no_sanitize("type")))
+int NoTYSAN2(int *a);
+int NoTYSAN2(int *a) { return *a; }
+
+// WITHOUT:  NoTYSAN3{{.*}}) [[NOATTR:#[0-9]+]]
+// BL:  NoTYSAN3{{.*}}) [[NOATTR:#[0-9]+]]
+// TYSAN:  NoTYSAN3{{.*}}) [[NOATTR:#[0-9]+]]
+__attribute__((no_sanitize("type")))
+int NoTYSAN3(int *a) { return *a; }
+
+// WITHOUT:  TYSANOk{{.*}}) [[NOATTR]]
+// BL:  TYSANOk{{.*}}) [[NOATTR]]
+// TYSAN: TYSANOk{{.*}}) [[WITH:#[0-9]+]]
+int TYSANOk(int *a) { return *a; }
+
+// WITHOUT:  TemplateTYSANOk{{.*}}) [[NOATTR]]
+// BL:  TemplateTYSANOk{{.*}}) [[NOATTR]]
+// TYSAN: TemplateTYSANOk{{.*}}) [[WITH]]
+template
+int TemplateTYSANOk() { return i; }
+
+// WITHOUT:  TemplateNoTYSAN{{.*}}) [[NOATTR]]
+// BL:  TemplateNoTYSAN{{.*}}) [[NOATTR]]
+// TYSAN: TemplateNoTYSAN{{.*}}) [[NOATTR]]
+template
+__attribute__((no_sanitize("type")))
+int TemplateNoTYSAN() { return i; }
+
+int force_instance = TemplateTYSANOk<42>()
+   + TemplateNoTYSAN<42>();
+
+// Check that __cxx_global_var_init* get the sanitize_type attribute.
+int global1 = 0;
+int global2 = *(int*)((char*)&global1+1);
+// WITHOUT: @__cxx_global_var_init{{.*}}[[NOATTR:#[0-9]+]]
+// BL: @__cxx_global_var_init{{.*}}[[NOATTR:#[0-9]+]]
+// TYSAN: @__cxx_global_var_init{{.*}}[[WITH:#[0-9]+]]
+
+// WITHOUT: attributes [[NOATTR]] = { noinline nounwind{{.*}} }
+
+// BL: attributes [[NOATTR]] = { noinline nounwind{{.*}} }
+
+// TYSAN: attributes [[NOATTR]] = { noinline nounwind{{.*}} }
+// TYSAN: attributes [[WITH]] = { noinline nounwind sanitize_type{{.*}} }
+
+// TYSAN: Simple C++ TBAA
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -1137,6 +1137,7 @@
   .Case("dataflow_sanitizer", LangOpts.Sanitize.has(SanitizerKind::DataFlow))
   .Case("efficiency_sanitizer",
 LangOpts.Sanitize.hasOneOf(SanitizerKind::Efficiency))
+  .Case("type_sanitizer", LangOpts.Sanitize.has(SanitizerKind::Type))
   // Objective-C features
   .Case("objc_arr", LangOpts.ObjCAutoRefCount) // FIXME: REMOVE

[PATCH] D32238: [Clangd] Failed to decode params using 1.x-compatible request message

2017-04-21 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

lg


https://reviews.llvm.org/D32238



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


[PATCH] D32350: [Analyzer] Exception Checker

2017-04-21 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
Herald added a subscriber: mgorny.

This is an old checker used only internally until now. The original author is 
Bence Babati, I added him as a subscriber.

The checker checks whather exceptions escape the main() function, destructors. 
functions with exception specifications not containing the exception or 
functions specially marked by an option.

I did not change the name of the checker, but maybe ExceptionEscape or 
UncaughtException would be more suitable.

I am not sure whether Clang Static Analyzer is the right place for this checker 
since it only walks the AST. Maybe it should be reimplemented Clang-Tidy, but 
there we would need a new matcher that walks the call chain recursively. (As 
far as I know, we cannot write iterative matcher expressions.)


https://reviews.llvm.org/D32350

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/ExceptionMisuseChecker.cpp
  test/Analysis/exception-misuse.cpp

Index: test/Analysis/exception-misuse.cpp
===
--- /dev/null
+++ test/Analysis/exception-misuse.cpp
@@ -0,0 +1,247 @@
+// RUN: %clang_analyze_cc1 -std=c++11 -fcxx-exceptions -analyzer-checker=core,cplusplus,alpha.cplusplus.ExceptionMisuse -analyzer-config alpha.cplusplus.ExceptionMisuse:enabled_functions="test2;test3;test4;f;g" -analyzer-config alpha.cplusplus.ExceptionMisuse:ignored_exceptions="E1;E2" %s -verify
+
+struct X {
+~X() {
+try {
+try {
+} catch (int& a) {
+throw 42;
+}
+} catch (...) {
+}
+}
+};
+
+struct Y {
+char data;
+
+Y(Y&&) { // expected-warning{{This function should not throw}}
+throw data;
+}
+
+Y& operator=(Y&&) { // expected-warning{{This function should not throw}}
+throw data;
+}
+
+~Y() {  // expected-warning{{This function should not throw}}
+// nesting
+if (data == 'A') throw data;
+bar();
+}
+void bar();
+};
+
+struct MyExceptionBase {};
+struct MyException : public MyExceptionBase {};
+
+void control_func() {
+throw 1024;
+}
+void dummy_func();
+void proxy_func() {
+control_func();
+throw "MyException";
+}
+
+struct Z {
+void control() { throw 'Z'; }
+
+~Z() { // expected-warning{{This function should not throw}}
+try {
+proxy_func();
+} catch (int& a) {
+} catch (...) {
+throw;
+}
+}
+};
+
+void testFn() {
+try {
+try {
+try {
+MyException myexce;
+throw myexce;
+} catch (int a) {
+dummy_func();
+throw;
+}
+} catch (MyException m) {
+}
+} catch (...) {
+}
+}
+
+struct base {};
+struct buffer : public base {};
+
+struct P {
+~P() {
+try {
+testFn();
+throw 44;
+} catch (int& a) {
+} catch (...) {
+}
+}
+};
+
+struct V {
+~V() { // expected-warning{{This function should not throw}}
+try {
+try {
+MyException myexce;
+throw myexce;
+} catch (int a) {
+dummy_func();
+}
+} catch (const MyExceptionBase& m) {
+throw;
+} catch (buffer) {
+} catch (base) {
+proxy_func();
+} catch (int& a) {
+} catch (int* a) {
+} catch (...) {
+}
+}
+};
+
+struct W {
+~W() { // expected-warning{{This function should not throw}}
+try {
+try {
+int a = 44;
+throw a;
+double d = 4.44;
+throw d;
+testFn();
+} catch (...) {
+throw;
+}
+} catch (int a) {
+
+} catch (...) {
+throw;
+}
+}
+};
+
+struct Q {
+Q(bool b) { _b = b; }
+~Q() {
+try {
+buffer b;
+if (_b) throw b;
+} catch (...) {
+}
+}
+
+  private:
+bool _b;
+};
+
+namespace N {
+void swap(int&, int&) { throw 5; } // expected-warning{{This function should not throw}}
+
+struct S {
+void swap(S& other) { throw 5; } // expected-warning{{This function should not throw}}
+};
+}
+
+int test1() throw() { // expected-warning{{This function should not throw}}
+throw 7;
+return 0;
+}
+
+void fun2();
+int test2() { // expected-warning{{This function should not throw}}
+fun2();
+return 0;
+}
+void fun2() { throw 7; }
+
+namespace test3Ns {
+  void fun3() { throw 7; }
+  void f() { fun3(); } // expected-warning{{This function should not throw}}
+}
+
+class A {};
+class B {};
+class C {};
+
+int test4() { // expected-warning{{This function should not throw}}
+try {
+throw A();
+} catch (B b)

Re: [llvm-dev] Permissions for llvm-mirror - Setting up Libc++ Appveyor builders

2017-04-21 Thread Mike Edwards via cfe-commits
Hi,
Fragmentation of the bots is not ideal.  While I totally understand Eric's
reasoning for doing so, and am delighted to see  another Windows bot
helping to ensure quality code, I think this is a bit of a slippery slope.
We already have the main Buildbots, Green Dragon, Chapuni's Bots, a myriad
of private bots and now this new bot.  I don't think it is reasonable to
ask people to have to visit several different places to check if their
commit broke something.  Anecdotally, I find many people will only look at
lab.llvm.org:8011.  They will check Green Dragon if they get an email and
then only if the email does not get lost in the noise.  Some folks are
regular users of bb.pgr.jp but the actual number or regular visitors I
don't know.

Perhaps it would be a more beneficial discussion to talk about putting
together some type of portal which displays results from all the CI systems
in one place?  I for one would love an interface which would be able to
show any given commit and how is has performed across the board.  Something
like this could possibly allow for anyone to stand up a bot or CI
infrastructure of their choosing and then have that system integrated in a
common reporting platform so it is useful and accessible to everyone.

Thoughts?

-Mike

On Thu, Apr 20, 2017 at 7:22 PM, Mehdi Amini via llvm-dev <
llvm-...@lists.llvm.org> wrote:

>
> On Apr 20, 2017, at 7:03 PM, Eric Fiselier  wrote:
>
>
>
> On Thu, Apr 20, 2017 at 4:55 PM, Mehdi Amini 
> wrote:
>
>>
>> On Apr 20, 2017, at 12:30 PM, Eric Fiselier  wrote:
>>
>>
>>
>> On Thu, Apr 20, 2017 at 11:06 AM, Mehdi Amini 
>> wrote:
>>
>>>
>>> On Apr 20, 2017, at 12:39 AM, Eric Fiselier  wrote:
>>>
>>>
>>>
>>> On Wed, Apr 19, 2017 at 11:19 PM, Mehdi Amini 
>>> wrote:
>>>
 What would be the status of these buildbots? Is it for your private
 usage?

>>>
>>> I intend for them to be public Windows buildbots for libc++.
>>>
>>>
>>>
>>> I’m not sure it’d be OK to send blame email to contributors based on
>>> this though.
>>>
>>
>> I don't see why not (at least once the bot is stable). Can you elaborate?
>>
>>
>> I don’t think there is a precedent for having a bot that does not
>> checkout from SVN and email using the canonical SVN revision number.
>>
>
> I understand share your concern about the emails using nonsensical git
> hashes as opposed to SVN revision numbers.
> Apart from that I have no idea why the version control used by the CI
> matters. It should have to effect on the build or the results.
>
>
> I don’t know, but other people may have other concern that I don’t
> necessarily anticipate..
>
>
>
>>
>> So it does not seems like a given to me  (not that I’m against it) and
>> would require a discussion on the mailing-list first IMO.
>>
>
> We might as well continue having it now since it's been started. I'll
> re-raise the issue in a month or so when the bot is
> actually stable enough to consider sending emails.
>
>
> I think it deserve a separate thread to deal with this, so that the thread
> title help making sure no-one miss the discussion.
>
> —
> Mehdi
>
>
> ___
> LLVM Developers mailing list
> llvm-...@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32298: [clang-format] Replace IncompleteFormat by a struct with Line

2017-04-21 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: include/clang/Format/Format.h:1524
+  /// best-effort analysis, and could be imprecise.
+  unsigned Line = 0;
+};

djasper wrote:
> Hm. Something we might need to be thinking about here is whether this should 
> be the line before or after formatting. So specifically, if I format:
> 
>   int a
>   = 1;
>   f(
> 
> Then, this gets reformatted to:
> 
>   int a = 1;
>   f(
> 
> Would we want the Line to be 2 or 3?
I'd go with the original line, because I think it might be more useful and 
because it's easier to implement.


https://reviews.llvm.org/D32298



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


[PATCH] D32298: [clang-format] Replace IncompleteFormat by a struct with Line

2017-04-21 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 96131.
krasimir added a comment.

- Refactor tests


https://reviews.llvm.org/D32298

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineFormatter.h
  test/Format/incomplete.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestComments.cpp
  unittests/Format/FormatTestJS.cpp
  unittests/Format/FormatTestObjC.cpp
  unittests/Format/FormatTestSelective.cpp

Index: unittests/Format/FormatTestSelective.cpp
===
--- unittests/Format/FormatTestSelective.cpp
+++ unittests/Format/FormatTestSelective.cpp
@@ -24,10 +24,10 @@
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-bool IncompleteFormat = false;
+FormattingAttemptStatus Status;
 tooling::Replacements Replaces =
-reformat(Style, Code, Ranges, "", &IncompleteFormat);
-EXPECT_FALSE(IncompleteFormat) << Code << "\n\n";
+reformat(Style, Code, Ranges, "", &Status);
+EXPECT_TRUE(Status.FormatComplete) << Code << "\n\n";
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
 DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -33,23 +33,24 @@
 Style.Language = FormatStyle::LK_ObjC;
   }
 
-  enum IncompleteCheck {
-IC_ExpectComplete,
-IC_ExpectIncomplete,
-IC_DoNotCheck
+  enum StatusCheck {
+SC_ExpectComplete,
+SC_ExpectIncomplete,
+SC_DoNotCheck
   };
 
   std::string format(llvm::StringRef Code,
- IncompleteCheck CheckIncomplete = IC_ExpectComplete) {
+ StatusCheck CheckComplete = SC_ExpectComplete) {
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(0, Code.size()));
-bool IncompleteFormat = false;
+FormattingAttemptStatus Status;
 tooling::Replacements Replaces =
-reformat(Style, Code, Ranges, "", &IncompleteFormat);
-if (CheckIncomplete != IC_DoNotCheck) {
-  bool ExpectedIncompleteFormat = CheckIncomplete == IC_ExpectIncomplete;
-  EXPECT_EQ(ExpectedIncompleteFormat, IncompleteFormat) << Code << "\n\n";
+reformat(Style, Code, Ranges, "", &Status);
+if (CheckComplete != SC_DoNotCheck) {
+  bool ExpectedCompleteFormat = CheckComplete == SC_ExpectComplete;
+  EXPECT_EQ(ExpectedCompleteFormat, Status.FormatComplete)
+  << Code << "\n\n";
 }
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
@@ -62,7 +63,7 @@
   }
 
   void verifyIncompleteFormat(StringRef Code) {
-EXPECT_EQ(Code.str(), format(test::messUp(Code), IC_ExpectIncomplete));
+EXPECT_EQ(Code.str(), format(test::messUp(Code), SC_ExpectIncomplete));
   }
 
   FormatStyle Style;
Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -24,10 +24,10 @@
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-bool IncompleteFormat = false;
+FormattingAttemptStatus Status;
 tooling::Replacements Replaces =
-reformat(Style, Code, Ranges, "", &IncompleteFormat);
-EXPECT_FALSE(IncompleteFormat);
+reformat(Style, Code, Ranges, "", &Status);
+EXPECT_TRUE(Status.FormatComplete);
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
 DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -29,24 +29,25 @@
 
 class FormatTestComments : public ::testing::Test {
 protected:
-  enum IncompleteCheck {
-IC_ExpectComplete,
-IC_ExpectIncomplete,
-IC_DoNotCheck
+  enum StatusCheck {
+SC_ExpectComplete,
+SC_ExpectIncomplete,
+SC_DoNotCheck
   };
 
   std::string format(llvm::StringRef Code,
  const FormatStyle &Style = getLLVMStyle(),
- IncompleteCheck CheckIncomplete = IC_ExpectComplete) {
+ StatusCheck CheckComplete = SC_ExpectComplete) {
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(0, Code.size()));
-bool IncompleteFormat = false;
+FormattingAttemptStatus Status;
 tooling::Replacements Replaces =
-reformat(Style, Code

[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-21 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio updated this revision to Diff 96130.
emilio added a comment.

Full diff, thanks @arphaman :)


https://reviews.llvm.org/D32348

Files:
  clang/test/Index/print-type.cpp
  clang/tools/libclang/CXType.cpp


Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -147,16 +147,16 @@
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
-  if (const auto *Specialization = Type->getAs())
-return Specialization->template_arguments();
-
   if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
 const auto *TemplateDecl =
   dyn_cast(RecordDecl);
 if (TemplateDecl)
   return TemplateDecl->getTemplateArgs().asArray();
   }
 
+  if (const auto *Specialization = Type->getAs())
+return Specialization->template_arguments();
+
   return None;
 }
 
Index: clang/test/Index/print-type.cpp
===
--- clang/test/Index/print-type.cpp
+++ clang/test/Index/print-type.cpp
@@ -71,6 +71,11 @@
 Specialization& > templRefParam;
 auto autoTemplRefParam = templRefParam;
 
+template
+struct DefaultedTypeExample {};
+
+typedef DefaultedTypeExample DefaultedTypeAlias;
+
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
@@ -115,7 +120,7 @@
 // CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] 
[typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] 
[canonicaltype=outer::Qux, int>] 
[canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] 
[type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] 
[type=int] [typekind=Int]] [isPOD=1]
+// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo] 
[typekind=Record] [type=int] [typekind=Int]] [canonicaltype=outer::Qux, int>] [canonicaltypekind=Record] 
[canonicaltemplateargs/4= [type=int] [typekind=Int] [type=char *] 
[typekind=Pointer] [type=outer::Foo] [typekind=Record] [type=int] 
[typekind=Int]] [isPOD=1]
 // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: FunctionTemplate=tbar:36:3 [type=T (int)] [typekind=FunctionProto] 
[canonicaltype=type-parameter-0-0 (int)] [canonicaltypekind=FunctionProto] 
[resulttype=T] [resulttypekind=Unexposed] [isPOD=0]
@@ -177,3 +182,4 @@
 // CHECK: VarDecl=autoTemplRefParam:72:6 (Definition) 
[type=Specialization &>] [typekind=Auto] [templateargs/1= 
[type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: UnexposedExpr=templRefParam:71:40 [type=const 
Specialization &>] [typekind=Unexposed] const 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=const Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: DeclRefExpr=templRefParam:71:40 
[type=Specialization &>] [typekind=Unexposed] 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
+// CHECK: TypedefDecl=DefaultedTypeAlias:77:35 (Definition) 
[type=DefaultedTypeAlias] [typekind=Typedef] [templateargs/2= [type=int] 
[typekind=Int] [type=int] [typekind=Int]] 
[canonicaltype=DefaultedTypeExample] [canonicaltypekind=Record] 
[canonicaltemplateargs/2= [type=int] [typekind=Int] [type=int] [typekind=Int]] 
[isPOD=0]


Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -147,16 +147,16 @@
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
-  if (const auto *Specialization = Type->getAs())
-return Specialization->template_arguments();
-
   if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
 const auto *TemplateDecl =
   dyn_cast(RecordDecl);
 if (TemplateDecl)
   return TemplateDecl->getTemplateArgs().asArray();
   }
 
+  if (const auto 

[PATCH] D32298: [clang-format] Replace IncompleteFormat by a struct with Line

2017-04-21 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 96129.
krasimir marked 5 inline comments as done.
krasimir added a comment.

- Changed IncompleteFormat to FormatComplete


https://reviews.llvm.org/D32298

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineFormatter.h
  test/Format/incomplete.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/FormatTestComments.cpp
  unittests/Format/FormatTestJS.cpp
  unittests/Format/FormatTestObjC.cpp
  unittests/Format/FormatTestSelective.cpp

Index: unittests/Format/FormatTestSelective.cpp
===
--- unittests/Format/FormatTestSelective.cpp
+++ unittests/Format/FormatTestSelective.cpp
@@ -24,10 +24,10 @@
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-bool IncompleteFormat = false;
+FormattingAttemptStatus Status;
 tooling::Replacements Replaces =
-reformat(Style, Code, Ranges, "", &IncompleteFormat);
-EXPECT_FALSE(IncompleteFormat) << Code << "\n\n";
+reformat(Style, Code, Ranges, "", &Status);
+EXPECT_TRUE(Status.FormatComplete) << Code << "\n\n";
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
 DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -44,12 +44,13 @@
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(0, Code.size()));
-bool IncompleteFormat = false;
+FormattingAttemptStatus Status;
 tooling::Replacements Replaces =
-reformat(Style, Code, Ranges, "", &IncompleteFormat);
+reformat(Style, Code, Ranges, "", &Status);
 if (CheckIncomplete != IC_DoNotCheck) {
   bool ExpectedIncompleteFormat = CheckIncomplete == IC_ExpectIncomplete;
-  EXPECT_EQ(ExpectedIncompleteFormat, IncompleteFormat) << Code << "\n\n";
+  EXPECT_EQ(ExpectedIncompleteFormat, !Status.FormatComplete)
+  << Code << "\n\n";
 }
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -24,10 +24,10 @@
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(Offset, Length));
-bool IncompleteFormat = false;
+FormattingAttemptStatus Status;
 tooling::Replacements Replaces =
-reformat(Style, Code, Ranges, "", &IncompleteFormat);
-EXPECT_FALSE(IncompleteFormat);
+reformat(Style, Code, Ranges, "", &Status);
+EXPECT_TRUE(Status.FormatComplete);
 auto Result = applyAllReplacements(Code, Replaces);
 EXPECT_TRUE(static_cast(Result));
 DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
Index: unittests/Format/FormatTestComments.cpp
===
--- unittests/Format/FormatTestComments.cpp
+++ unittests/Format/FormatTestComments.cpp
@@ -41,12 +41,13 @@
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(0, Code.size()));
-bool IncompleteFormat = false;
+FormattingAttemptStatus Status;
 tooling::Replacements Replaces =
-reformat(Style, Code, Ranges, "", &IncompleteFormat);
+reformat(Style, Code, Ranges, "", &Status);
 if (CheckIncomplete != IC_DoNotCheck) {
   bool ExpectedIncompleteFormat = CheckIncomplete == IC_ExpectIncomplete;
-  EXPECT_EQ(ExpectedIncompleteFormat, IncompleteFormat) << Code << "\n\n";
+  EXPECT_EQ(ExpectedIncompleteFormat, !Status.FormatComplete)
+  << Code << "\n\n";
 }
 ReplacementCount = Replaces.size();
 auto Result = applyAllReplacements(Code, Replaces);
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -42,12 +42,13 @@
 DEBUG(llvm::errs() << "---\n");
 DEBUG(llvm::errs() << Code << "\n\n");
 std::vector Ranges(1, tooling::Range(0, Code.size()));
-bool IncompleteFormat = false;
+FormattingAttemptStatus Status;
 tooling::Replacements Replaces =
-reformat(Style, Code, Ranges, "", &IncompleteFormat);
+reformat(Style, Code, Ranges, "", &Status);
 if (CheckIncomplete != IC_DoNotCheck) {
   bool ExpectedIncompleteFormat = CheckIncomplete == IC_ExpectIncomplete;
-  EXPECT_EQ(ExpectedIncompleteFormat, IncompleteFormat) << Code <

[PATCH] D32342: Changed llvm/CMakeLists.txt and added relative path to llvm doxygen

2017-04-21 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 96128.
yamaguchi added a comment.

Modified README.txt.
I thought its good to specify where the html is.


https://reviews.llvm.org/D32342

Files:
  docs/CMakeLists.txt
  docs/README.txt
  docs/doxygen.cfg.in

Index: docs/doxygen.cfg.in
===
--- docs/doxygen.cfg.in
+++ docs/doxygen.cfg.in
@@ -58,7 +58,7 @@
 # entered, it will be relative to the location where doxygen was started. If
 # left blank the current directory will be used.
 
-OUTPUT_DIRECTORY   = @abs_top_builddir@/docs/doxygen
+OUTPUT_DIRECTORY   = @abs_top_builddir@/doxygen
 
 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
 # directories (in 2 levels) under the output directory of each output format and
@@ -132,7 +132,7 @@
 # shortest path that makes the file name unique will be used
 # The default value is: YES.
 
-FULL_PATH_NAMES= NO
+FULL_PATH_NAMES= YES
 
 # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
 # Stripping is only done if one of the specified strings matches the left-hand
@@ -144,16 +144,17 @@
 # will be relative from the directory where doxygen is started.
 # This tag requires that the tag FULL_PATH_NAMES is set to YES.
 
-STRIP_FROM_PATH= ../..
+STRIP_FROM_PATH= @abs_top_srcdir@/..
 
 # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
 # path mentioned in the documentation of a class, which tells the reader which
 # header file to include in order to use a class. If left blank only the name of
 # the header file containing the class definition is used. Otherwise one should
 # specify the list of include paths that are normally passed to the compiler
 # using the -I flag.
 
-STRIP_FROM_INC_PATH=
+STRIP_FROM_INC_PATH= @abs_top_srcdir@/../include
+STRIP_FROM_INC_PATH+= @abs_top_srcdir@/../lib
 
 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
 # less readable) file names. This can be useful is your file systems doesn't
@@ -513,7 +514,7 @@
 # files with double quotes in the documentation rather than with sharp brackets.
 # The default value is: NO.
 
-FORCE_LOCAL_INCLUDES   = NO
+FORCE_LOCAL_INCLUDES   = YES
 
 # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
 # documentation for inline members.
@@ -743,9 +744,9 @@
 # spaces.
 # Note: If this tag is empty the current directory is searched.
 
-INPUT  = @abs_top_srcdir@/include \
- @abs_top_srcdir@/lib \
- @abs_top_srcdir@/docs/doxygen-mainpage.dox
+INPUT  = @abs_top_srcdir@/../include \
+ @abs_top_srcdir@/../lib \
+ @abs_top_srcdir@/doxygen-mainpage.dox
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -813,7 +814,7 @@
 # that contain example code fragments that are included (see the \include
 # command).
 
-EXAMPLE_PATH   = @abs_top_srcdir@/examples
+EXAMPLE_PATH   = @abs_top_srcdir@/../examples
 
 # If the value of the EXAMPLE_PATH tag contains directories, you can use the
 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
@@ -833,7 +834,7 @@
 # that contain images that are to be included in the documentation (see the
 # \image command).
 
-IMAGE_PATH = @abs_top_srcdir@/docs/img
+IMAGE_PATH = @abs_top_srcdir@/img
 
 # The INPUT_FILTER tag can be used to specify a program that doxygen should
 # invoke to filter for each input file. Doxygen will invoke the filter program
Index: docs/README.txt
===
--- docs/README.txt
+++ docs/README.txt
@@ -51,3 +51,18 @@
 
 cd docs/
 make -f Makefile.sphinx linkcheck
+
+Doxygen page Output
+==
+
+Install doxygen  and dot2tex .
+
+cd 
+cmake -DLLVM_ENABLE_DOXYGEN=On 
+make doxygen-llvm # for LLVM docs
+make doxygen-clang # for clang docs
+
+It will generate html in
+
+/docs/doxygen/html # for LLVM docs
+/tools/clang/docs/doxygen/html # for clang docs
Index: docs/CMakeLists.txt
===
--- docs/CMakeLists.txt
+++ docs/CMakeLists.txt
@@ -1,8 +1,8 @@
 
 if (DOXYGEN_FOUND)
 if (LLVM_ENABLE_DOXYGEN)
-  set(abs_top_srcdir ${LLVM_MAIN_SRC_DIR})
-  set(abs_top_builddir ${LLVM_BINARY_DIR})
+  set(abs_top_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
+  set(abs_top_builddir ${CMAKE_CURRENT_BINARY_DIR})
   
   if (HAVE_DOT)
 set(DOT ${LLVM_PATH_DOT})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-com

[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Please post the diff with full context (git diff -U).


Repository:
  rL LLVM

https://reviews.llvm.org/D32348



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


[PATCH] D32348: [libclang] Check for a record declaration before a template specialization.

2017-04-21 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio created this revision.
emilio added a project: clang-c.

This allows us to see the default template parameters too.

This is a regression in clang 4.0, so uplifting to a dot release would be neat 
(but not required, I guess).

The regression was caused by https://reviews.llvm.org/D26663.

Fixes bug 32539 (https://bugs.llvm.org//show_bug.cgi?id=32539).


Repository:
  rL LLVM

https://reviews.llvm.org/D32348

Files:
  clang/test/Index/print-type.cpp
  clang/tools/libclang/CXType.cpp


Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -147,9 +147,6 @@
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
-  if (const auto *Specialization = Type->getAs())
-return Specialization->template_arguments();
-
   if (const auto *RecordDecl = Type->getAsCXXRecordDecl()) {
 const auto *TemplateDecl =
   dyn_cast(RecordDecl);
@@ -157,6 +154,9 @@
   return TemplateDecl->getTemplateArgs().asArray();
   }
 
+  if (const auto *Specialization = Type->getAs())
+return Specialization->template_arguments();
+
   return None;
 }
 
Index: clang/test/Index/print-type.cpp
===
--- clang/test/Index/print-type.cpp
+++ clang/test/Index/print-type.cpp
@@ -71,6 +71,11 @@
 Specialization& > templRefParam;
 auto autoTemplRefParam = templRefParam;
 
+template
+struct DefaultedTypeExample {};
+
+typedef DefaultedTypeExample DefaultedTypeAlias;
+
 // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
 // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
 // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid] 
[isPOD=0]
@@ -115,7 +120,7 @@
 // CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
-// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=Foo] 
[typekind=Unexposed] [type=outer::inner::Bar::FooType] [typekind=Typedef]] 
[canonicaltype=outer::Qux, int>] 
[canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int] [typekind=Int] 
[type=char *] [typekind=Pointer] [type=outer::Foo] [typekind=Record] 
[type=int] [typekind=Int]] [isPOD=1]
+// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux, 
outer::inner::Bar::FooType>] [typekind=Unexposed] [templateargs/4= [type=int] 
[typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo] 
[typekind=Record] [type=int] [typekind=Int]] [canonicaltype=outer::Qux, int>] [canonicaltypekind=Record] 
[canonicaltemplateargs/4= [type=int] [typekind=Int] [type=char *] 
[typekind=Pointer] [type=outer::Foo] [typekind=Record] [type=int] 
[typekind=Int]] [isPOD=1]
 // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: FunctionTemplate=tbar:36:3 [type=T (int)] [typekind=FunctionProto] 
[canonicaltype=type-parameter-0-0 (int)] [canonicaltypekind=FunctionProto] 
[resulttype=T] [resulttypekind=Unexposed] [isPOD=0]
@@ -177,3 +182,4 @@
 // CHECK: VarDecl=autoTemplRefParam:72:6 (Definition) 
[type=Specialization &>] [typekind=Auto] [templateargs/1= 
[type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: UnexposedExpr=templRefParam:71:40 [type=const 
Specialization &>] [typekind=Unexposed] const 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=const Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
 // CHECK: DeclRefExpr=templRefParam:71:40 
[type=Specialization &>] [typekind=Unexposed] 
[templateargs/1= [type=Specialization &] [typekind=LValueReference]] 
[canonicaltype=Specialization &>] 
[canonicaltypekind=Record] [canonicaltemplateargs/1= [type=Specialization 
&] [typekind=LValueReference]] [isPOD=1]
+// CHECK: TypedefDecl=DefaultedTypeAlias:77:35 (Definition) 
[type=DefaultedTypeAlias] [typekind=Typedef] [templateargs/2= [type=int] 
[typekind=Int] [type=int] [typekind=Int]] 
[canonicaltype=DefaultedTypeExample] [canonicaltypekind=Record] 
[canonicaltemplateargs/2= [type=int] [typekind=Int] [type=int] [typekind=Int]] 
[isPOD=0]


Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -147,9 +147,6 @@
 static Optional>
 GetTemplateArguments(QualType Type) {
   assert(!Type.isNull());
-  if (const auto *Specialization = Type->getAs())
-  

[PATCH] D32342: Changed llvm/CMakeLists.txt and added relative path to llvm doxygen

2017-04-21 Thread Yuka Takahashi via Phabricator via cfe-commits
yamaguchi updated this revision to Diff 96124.
yamaguchi retitled this revision from "Fixed llvm/CMakeLists.txt which doesn't 
generate proper MakeFiles and added relative path to llvm doxygen" to "Changed 
llvm/CMakeLists.txt and added relative path to llvm doxygen".
yamaguchi added a comment.

Edit README.txt.


https://reviews.llvm.org/D32342

Files:
  docs/CMakeLists.txt
  docs/README.txt
  docs/doxygen.cfg.in

Index: docs/doxygen.cfg.in
===
--- docs/doxygen.cfg.in
+++ docs/doxygen.cfg.in
@@ -58,7 +58,7 @@
 # entered, it will be relative to the location where doxygen was started. If
 # left blank the current directory will be used.
 
-OUTPUT_DIRECTORY   = @abs_top_builddir@/docs/doxygen
+OUTPUT_DIRECTORY   = @abs_top_builddir@/doxygen
 
 # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-
 # directories (in 2 levels) under the output directory of each output format and
@@ -132,7 +132,7 @@
 # shortest path that makes the file name unique will be used
 # The default value is: YES.
 
-FULL_PATH_NAMES= NO
+FULL_PATH_NAMES= YES
 
 # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
 # Stripping is only done if one of the specified strings matches the left-hand
@@ -144,16 +144,17 @@
 # will be relative from the directory where doxygen is started.
 # This tag requires that the tag FULL_PATH_NAMES is set to YES.
 
-STRIP_FROM_PATH= ../..
+STRIP_FROM_PATH= @abs_top_srcdir@/..
 
 # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
 # path mentioned in the documentation of a class, which tells the reader which
 # header file to include in order to use a class. If left blank only the name of
 # the header file containing the class definition is used. Otherwise one should
 # specify the list of include paths that are normally passed to the compiler
 # using the -I flag.
 
-STRIP_FROM_INC_PATH=
+STRIP_FROM_INC_PATH= @abs_top_srcdir@/../include
+STRIP_FROM_INC_PATH+= @abs_top_srcdir@/../lib
 
 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
 # less readable) file names. This can be useful is your file systems doesn't
@@ -513,7 +514,7 @@
 # files with double quotes in the documentation rather than with sharp brackets.
 # The default value is: NO.
 
-FORCE_LOCAL_INCLUDES   = NO
+FORCE_LOCAL_INCLUDES   = YES
 
 # If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
 # documentation for inline members.
@@ -743,9 +744,9 @@
 # spaces.
 # Note: If this tag is empty the current directory is searched.
 
-INPUT  = @abs_top_srcdir@/include \
- @abs_top_srcdir@/lib \
- @abs_top_srcdir@/docs/doxygen-mainpage.dox
+INPUT  = @abs_top_srcdir@/../include \
+ @abs_top_srcdir@/../lib \
+ @abs_top_srcdir@/doxygen-mainpage.dox
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -813,7 +814,7 @@
 # that contain example code fragments that are included (see the \include
 # command).
 
-EXAMPLE_PATH   = @abs_top_srcdir@/examples
+EXAMPLE_PATH   = @abs_top_srcdir@/../examples
 
 # If the value of the EXAMPLE_PATH tag contains directories, you can use the
 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
@@ -833,7 +834,7 @@
 # that contain images that are to be included in the documentation (see the
 # \image command).
 
-IMAGE_PATH = @abs_top_srcdir@/docs/img
+IMAGE_PATH = @abs_top_srcdir@/img
 
 # The INPUT_FILTER tag can be used to specify a program that doxygen should
 # invoke to filter for each input file. Doxygen will invoke the filter program
Index: docs/README.txt
===
--- docs/README.txt
+++ docs/README.txt
@@ -51,3 +51,13 @@
 
 cd docs/
 make -f Makefile.sphinx linkcheck
+
+Doxygen page Output
+==
+
+Install doxygen and dot2tex .
+
+cd 
+cmake -DLLVM_ENABLE_DOXYGEN=On 
+make doxygen-llvm # for LLVM docs
+make doxygen-clang #for clang docs
Index: docs/CMakeLists.txt
===
--- docs/CMakeLists.txt
+++ docs/CMakeLists.txt
@@ -1,8 +1,8 @@
 
 if (DOXYGEN_FOUND)
 if (LLVM_ENABLE_DOXYGEN)
-  set(abs_top_srcdir ${LLVM_MAIN_SRC_DIR})
-  set(abs_top_builddir ${LLVM_BINARY_DIR})
+  set(abs_top_srcdir ${CMAKE_CURRENT_SOURCE_DIR})
+  set(abs_top_builddir ${CMAKE_CURRENT_BINARY_DIR})
   
   if (HAVE_DOT)
 set(DOT ${LLVM_PATH_DOT})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] [libclang] Check for a record declaration before a template specialization.

2017-04-21 Thread Emilio Cobos Álvarez via cfe-commits
On Fri, Apr 21, 2017 at 01:49:24PM +0100, Alex L wrote:
> Hi,
> 
> On 21 April 2017 at 12:55, Emilio Cobos Álvarez via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> 
> > This allows us to get the default template parameters too.
> >
> > This patch was submitted also as https://reviews.llvm.org/D31732, but I
> > see no
> > reference to it in cfe-commits or llvm-commits, so I guess it got lost?
> >
> 
> You have to add cfe-commits as subscribers to the Phabricator patch,
> otherwise it won't show up in the mailing list. I would recommend you to
> close the old one revision and create a new one on Phabricator, this way
> we'll get the entire patch history on cfe-commits.

I see, newbie mistake, whoops :)

Will do, thank you!

 -- Emilio

> 
> Alex
> 
> 
> >
> > This fixes bug 32539.
> >
> > Signed-off-by: Emilio Cobos Álvarez 
> > ---
> >  clang/test/Index/print-type.cpp | 8 +++-
> >  clang/tools/libclang/CXType.cpp | 6 +++---
> >  2 files changed, 10 insertions(+), 4 deletions(-)
> >
> > diff --git a/clang/test/Index/print-type.cpp
> > b/clang/test/Index/print-type.cpp
> > index 108ba53c80b..ff150f7dd61 100644
> > --- a/clang/test/Index/print-type.cpp
> > +++ b/clang/test/Index/print-type.cpp
> > @@ -71,6 +71,11 @@ struct Specialization;
> >  Specialization& > templRefParam;
> >  auto autoTemplRefParam = templRefParam;
> >
> > +template
> > +struct DefaultedTypeExample {};
> > +
> > +typedef DefaultedTypeExample DefaultedTypeAlias;
> > +
> >  // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
> >  // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid]
> > [isPOD=0]
> >  // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid]
> > [isPOD=0]
> > @@ -115,7 +120,7 @@ auto autoTemplRefParam = templRefParam;
> >  // CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0]
> >  // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
> >  // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
> > -// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux > Foo, outer::inner::Bar::FooType>] [typekind=Unexposed]
> > [templateargs/4= [type=int] [typekind=Int] [type=char *] [typekind=Pointer]
> > [type=Foo] [typekind=Unexposed] [type=outer::inner::Bar::FooType]
> > [typekind=Typedef]] [canonicaltype=outer::Qux,
> > int>] [canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int]
> > [typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo]
> > [typekind=Record] [type=int] [typekind=Int]] [isPOD=1]
> > +// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux > Foo, outer::inner::Bar::FooType>] [typekind=Unexposed]
> > [templateargs/4= [type=int] [typekind=Int] [type=char *] [typekind=Pointer]
> > [type=outer::Foo] [typekind=Record] [type=int] [typekind=Int]]
> > [canonicaltype=outer::Qux, int>]
> > [canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int]
> > [typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo]
> > [typekind=Record] [type=int] [typekind=Int]] [isPOD=1]
> >  // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]
> >  // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
> >  // CHECK: FunctionTemplate=tbar:36:3 [type=T (int)]
> > [typekind=FunctionProto] [canonicaltype=type-parameter-0-0 (int)]
> > [canonicaltypekind=FunctionProto] [resulttype=T]
> > [resulttypekind=Unexposed] [isPOD=0]
> > @@ -177,3 +182,4 @@ auto autoTemplRefParam = templRefParam;
> >  // CHECK: VarDecl=autoTemplRefParam:72:6 (Definition)
> > [type=Specialization &>] [typekind=Auto]
> > [templateargs/1= [type=Specialization &] [typekind=LValueReference]]
> > [canonicaltype=Specialization &>]
> > [canonicaltypekind=Record] [canonicaltemplateargs/1=
> > [type=Specialization &] [typekind=LValueReference]] [isPOD=1]
> >  // CHECK: UnexposedExpr=templRefParam:71:40 [type=const
> > Specialization &>] [typekind=Unexposed] const
> > [templateargs/1= [type=Specialization &] [typekind=LValueReference]]
> > [canonicaltype=const Specialization &>]
> > [canonicaltypekind=Record] [canonicaltemplateargs/1=
> > [type=Specialization &] [typekind=LValueReference]] [isPOD=1]
> >  // CHECK: DeclRefExpr=templRefParam:71:40 
> > [type=Specialization
> > &>] [typekind=Unexposed] [templateargs/1= [type=Specialization &]
> > [typekind=LValueReference]] 
> > [canonicaltype=Specialization
> > &>] [canonicaltypekind=Record] [canonicaltemplateargs/1=
> > [type=Specialization &] [typekind=LValueReference]] [isPOD=1]
> > +// CHECK: TypedefDecl=DefaultedTypeAlias:77:35 (Definition)
> > [type=DefaultedTypeAlias] [typekind=Typedef] [templateargs/2= [type=int]
> > [typekind=Int] [type=int] [typekind=Int]] 
> > [canonicaltype=DefaultedTypeExample > int>] [canonicaltypekind=Record] [canonicaltemplateargs/2= [type=int]
> > [typekind=Int] [type=int] [typekind=Int]] [isPOD=0]
> > diff --git a/clang/tools/libclang/CXType.cpp
> > b/clang/tools/libclang/CXType.cpp
> > index 16e993e2ac0..fce7ef2c0d8 100644
> > --- a/clang/tools/libclang/CXType.cpp
>

[PATCH] D31709: [NFC] Refactor DiagnosticRenderer to use FullSourceLoc

2017-04-21 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 added a comment.

Thanks for your comments Reid. Please find my responses inline. I'll spin a new 
patch addressing your comments soonish.




Comment at: include/clang/Basic/SourceLocation.h:336
 
+  bool hasManager() const { return SrcMgr != nullptr; }
   /// \pre This FullSourceLoc has an associated SourceManager.

rnk wrote:
> SrcMgr is only non-null when the location is invalid, right? Can you do 
> something like:
>   bool hasManager() const {
> bool R = SrcMgr != nullptr;
> assert(R == isValid() && "FullSourceLoc has location but no manager");
> return R;
>   }
That makes sense, and seems like a good sanity check. I'll run regressions to 
make sure nothing insane is going on anywhere.



Comment at: lib/Basic/SourceLocation.cpp:25
 
+namespace clang {
 void PrettyStackTraceLoc::print(raw_ostream &OS) const {

rnk wrote:
> This doesn't seem necessary, you aren't defining any free functions, right?
I might have done in a previous iteration, resulting in linker errors which 
this fixed. I'll try again without. :)



Comment at: lib/Frontend/DiagnosticRenderer.cpp:139
 void DiagnosticRenderer::emitStoredDiagnostic(StoredDiagnostic &Diag) {
-  emitDiagnostic(Diag.getLocation(), Diag.getLevel(), Diag.getMessage(),
- Diag.getRanges(), Diag.getFixIts(),
- Diag.getLocation().isValid() ? 
&Diag.getLocation().getManager()
-  : nullptr,
- &Diag);
+  emitDiagnostic(
+  Diag.getLocation().isValid()

rnk wrote:
> I think `Diag.getLocation()` is already a FullSourceLoc, no need to check it.
Quite right, good catch!



Comment at: lib/Frontend/DiagnosticRenderer.cpp:512
   // Produce a stack of macro backtraces.
-  SmallVector LocationStack;
+  SmallVector LocationStack;
   unsigned IgnoredEnd = 0;

rnk wrote:
> This seems inefficient, it wastes space on `SourceManager` pointers that will 
> all be the same.
True, but it does make the rest of this function more readable. I'd prefer to 
leave it as is. Maybe just reducing the SmallVector size to, say, 4, to take up 
less stack space?


https://reviews.llvm.org/D31709



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


Re: [PATCH] [libclang] Check for a record declaration before a template specialization.

2017-04-21 Thread Alex L via cfe-commits
Hi,

On 21 April 2017 at 12:55, Emilio Cobos Álvarez via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> This allows us to get the default template parameters too.
>
> This patch was submitted also as https://reviews.llvm.org/D31732, but I
> see no
> reference to it in cfe-commits or llvm-commits, so I guess it got lost?
>

You have to add cfe-commits as subscribers to the Phabricator patch,
otherwise it won't show up in the mailing list. I would recommend you to
close the old one revision and create a new one on Phabricator, this way
we'll get the entire patch history on cfe-commits.

Alex


>
> This fixes bug 32539.
>
> Signed-off-by: Emilio Cobos Álvarez 
> ---
>  clang/test/Index/print-type.cpp | 8 +++-
>  clang/tools/libclang/CXType.cpp | 6 +++---
>  2 files changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/clang/test/Index/print-type.cpp
> b/clang/test/Index/print-type.cpp
> index 108ba53c80b..ff150f7dd61 100644
> --- a/clang/test/Index/print-type.cpp
> +++ b/clang/test/Index/print-type.cpp
> @@ -71,6 +71,11 @@ struct Specialization;
>  Specialization& > templRefParam;
>  auto autoTemplRefParam = templRefParam;
>
> +template
> +struct DefaultedTypeExample {};
> +
> +typedef DefaultedTypeExample DefaultedTypeAlias;
> +
>  // RUN: c-index-test -test-print-type %s -std=c++14 | FileCheck %s
>  // CHECK: Namespace=outer:1:11 (Definition) [type=] [typekind=Invalid]
> [isPOD=0]
>  // CHECK: ClassTemplate=Foo:4:8 (Definition) [type=] [typekind=Invalid]
> [isPOD=0]
> @@ -115,7 +120,7 @@ auto autoTemplRefParam = templRefParam;
>  // CHECK: TemplateRef=Baz:9:8 [type=] [typekind=Invalid] [isPOD=0]
>  // CHECK: IntegerLiteral= [type=int] [typekind=Int] [isPOD=1]
>  // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
> -// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux Foo, outer::inner::Bar::FooType>] [typekind=Unexposed]
> [templateargs/4= [type=int] [typekind=Int] [type=char *] [typekind=Pointer]
> [type=Foo] [typekind=Unexposed] [type=outer::inner::Bar::FooType]
> [typekind=Typedef]] [canonicaltype=outer::Qux,
> int>] [canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int]
> [typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo]
> [typekind=Record] [type=int] [typekind=Int]] [isPOD=1]
> +// CHECK: FieldDecl=qux:29:38 (Definition) [type=Qux Foo, outer::inner::Bar::FooType>] [typekind=Unexposed]
> [templateargs/4= [type=int] [typekind=Int] [type=char *] [typekind=Pointer]
> [type=outer::Foo] [typekind=Record] [type=int] [typekind=Int]]
> [canonicaltype=outer::Qux, int>]
> [canonicaltypekind=Record] [canonicaltemplateargs/4= [type=int]
> [typekind=Int] [type=char *] [typekind=Pointer] [type=outer::Foo]
> [typekind=Record] [type=int] [typekind=Int]] [isPOD=1]
>  // CHECK: TemplateRef=Qux:12:8 [type=] [typekind=Invalid] [isPOD=0]
>  // CHECK: TemplateRef=Foo:4:8 [type=] [typekind=Invalid] [isPOD=0]
>  // CHECK: FunctionTemplate=tbar:36:3 [type=T (int)]
> [typekind=FunctionProto] [canonicaltype=type-parameter-0-0 (int)]
> [canonicaltypekind=FunctionProto] [resulttype=T]
> [resulttypekind=Unexposed] [isPOD=0]
> @@ -177,3 +182,4 @@ auto autoTemplRefParam = templRefParam;
>  // CHECK: VarDecl=autoTemplRefParam:72:6 (Definition)
> [type=Specialization &>] [typekind=Auto]
> [templateargs/1= [type=Specialization &] [typekind=LValueReference]]
> [canonicaltype=Specialization &>]
> [canonicaltypekind=Record] [canonicaltemplateargs/1=
> [type=Specialization &] [typekind=LValueReference]] [isPOD=1]
>  // CHECK: UnexposedExpr=templRefParam:71:40 [type=const
> Specialization &>] [typekind=Unexposed] const
> [templateargs/1= [type=Specialization &] [typekind=LValueReference]]
> [canonicaltype=const Specialization &>]
> [canonicaltypekind=Record] [canonicaltemplateargs/1=
> [type=Specialization &] [typekind=LValueReference]] [isPOD=1]
>  // CHECK: DeclRefExpr=templRefParam:71:40 
> [type=Specialization
> &>] [typekind=Unexposed] [templateargs/1= [type=Specialization &]
> [typekind=LValueReference]] [canonicaltype=Specialization
> &>] [canonicaltypekind=Record] [canonicaltemplateargs/1=
> [type=Specialization &] [typekind=LValueReference]] [isPOD=1]
> +// CHECK: TypedefDecl=DefaultedTypeAlias:77:35 (Definition)
> [type=DefaultedTypeAlias] [typekind=Typedef] [templateargs/2= [type=int]
> [typekind=Int] [type=int] [typekind=Int]] 
> [canonicaltype=DefaultedTypeExample int>] [canonicaltypekind=Record] [canonicaltemplateargs/2= [type=int]
> [typekind=Int] [type=int] [typekind=Int]] [isPOD=0]
> diff --git a/clang/tools/libclang/CXType.cpp
> b/clang/tools/libclang/CXType.cpp
> index 16e993e2ac0..fce7ef2c0d8 100644
> --- a/clang/tools/libclang/CXType.cpp
> +++ b/clang/tools/libclang/CXType.cpp
> @@ -147,9 +147,6 @@ static inline CXTranslationUnit GetTU(CXType CT) {
>  static Optional>
>  GetTemplateArguments(QualType Type) {
>assert(!Type.isNull());
> -  if (const auto *Specialization = Type->getAs<
> TemplateSpecializationType>())
> -return Specialization->template_arguments(

  1   2   >