[libcxx] r321717 - Creating release_60 branch off revision 321711

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 06:54:46 2018
New Revision: 321717

URL: http://llvm.org/viewvc/llvm-project?rev=321717=rev
Log:
Creating release_60 branch off revision 321711

Added:
libcxx/branches/release_60/   (props changed)
  - copied from r321711, libcxx/trunk/

Propchange: libcxx/branches/release_60/
--
svn:mergeinfo = /libcxx/branches/apple:136569-137939


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


[libcxxabi] r321718 - Creating release_60 branch off revision 321711

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 06:54:46 2018
New Revision: 321718

URL: http://llvm.org/viewvc/llvm-project?rev=321718=rev
Log:
Creating release_60 branch off revision 321711

Added:
libcxxabi/branches/release_60/
  - copied from r321711, libcxxabi/trunk/

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


[PATCH] D39457: [OPENMP] Current status of OpenMP support.

2018-01-03 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D39457#961824, @Hahnfeld wrote:

> @hfinkel I think you requested this documentation on the mailing list. Can 
> you take a look if it matches your expectations so we can get this bundled in 
> the 6.0 release?


Yes, this looks good. Thank you.


Repository:
  rC Clang

https://reviews.llvm.org/D39457



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


r321705 - UserManual: Update with the latest clang-cl flags

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 05:20:25 2018
New Revision: 321705

URL: http://llvm.org/viewvc/llvm-project?rev=321705=rev
Log:
UserManual: Update with the latest clang-cl flags

Modified:
cfe/trunk/docs/UsersManual.rst

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=321705=321704=321705=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed Jan  3 05:20:25 2018
@@ -2732,6 +2732,7 @@ Execute ``clang-cl /?`` to see a list of
   /Gd Set __cdecl as a default calling convention
   /GF-Disable string pooling
   /GR-Disable emission of RTTI data
+  /Gregcall   Set __regcall as a default calling convention
   /GR Enable emission of RTTI data
   /Gr Set __fastcall as a default calling convention
   /GS-Disable buffer security check
@@ -2788,7 +2789,7 @@ Execute ``clang-cl /?`` to see a list of
   /W2 Enable -Wall
   /W3 Enable -Wall
   /W4 Enable -Wall and -Wextra
-  /Wall   Enable -Wall and -Wextra
+  /Wall   Enable -Weverything
   /WX-Do not treat warnings as errors
   /WX Treat warnings as errors
   /w  Disable all warnings
@@ -2845,6 +2846,8 @@ Execute ``clang-cl /?`` to see a list of
   Disable specified features of coverage 
instrumentation for Sanitizers
   -fno-sanitize-memory-track-origins
   Disable origins tracking in MemorySanitizer
+  -fno-sanitize-memory-use-after-dtor
+  Disable use-after-destroy detection in 
MemorySanitizer
   -fno-sanitize-recover=
   Disable recovery for specified sanitizers
   -fno-sanitize-stats Disable sanitizer statistics gathering.
@@ -2875,6 +2878,8 @@ Execute ``clang-cl /?`` to see a list of
   Path to blacklist file for sanitizers
   -fsanitize-cfi-cross-dso
   Enable control flow integrity (CFI) checks for 
cross-DSO calls.
+  -fsanitize-cfi-icall-generalize-pointers
+  Generalize pointers in CFI indirect call type 
signature checks
   -fsanitize-coverage=
   Specify the type of coverage instrumentation for 
Sanitizers
   -fsanitize-memory-track-origins=
@@ -2898,6 +2903,7 @@ Execute ``clang-cl /?`` to see a list of
   -fsanitize=  Turn on runtime checks for various forms of 
undefined or suspicious
   behavior. See user manual for available checks
   -fstandalone-debug  Emit full debug info for all types used by the 
program
+  -fwhole-program-vtables Enables whole-program vtable optimization. 
Requires -flto
   -gcodeview  Generate CodeView debug information
   -gline-tables-only  Emit debug line number tables only
   -miamcu Use Intel MCU ABI
@@ -2906,6 +2912,7 @@ Execute ``clang-cl /?`` to see a list of
   -Qunused-arguments  Don't emit warning for unused driver arguments
   -R  Enable the specified remark
   --target=Generate code for the given target
+  --version   Print version information
   -v  Show commands to run and use verbose output
   -W Enable the specified warning
   -XclangPass  to the clang compiler


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


[PATCH] D41486: [OpenMP][Clang] Add missing argument to runtime functions.

2018-01-03 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea abandoned this revision.
gtbercea added a comment.

Functionality already landed. See previous comment.


Repository:
  rL LLVM

https://reviews.llvm.org/D41486



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


[PATCH] D41661: [clangd] Don't navigate to forward class declaration when go to definition.

2018-01-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 128516.
hokein added a comment.

Use getDefinition to simply the code.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41661

Files:
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -203,6 +203,18 @@
 #define MACRO 2
 #undef macro
   )cpp",
+
+  R"cpp(// Forward class declaration
+class Foo;
+[[class Foo {}]];
+F^oo* foo();
+  )cpp",
+
+  R"cpp(// Function declaration
+void foo();
+void g() { f^oo(); }
+[[void foo() {}]]
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -14,6 +14,20 @@
 using namespace llvm;
 namespace {
 
+// Get the definition from a given declaration `D`.
+// Return nullptr if no definition is found, or the declaration type of `D` is
+// not supported.
+const Decl* GetDefinition(const Decl* D) {
+  assert(D);
+  if (const auto *TD = dyn_cast(D))
+return TD->getDefinition();
+  else if (const auto *VD = dyn_cast(D))
+return VD->getDefinition();
+  else if (const auto *FD = dyn_cast(D))
+return FD->getDefinition();
+  return nullptr;
+}
+
 /// Finds declarations locations that a given source location refers to.
 class DeclarationAndMacrosFinder : public index::IndexDataConsumer {
   std::vector Decls;
@@ -50,8 +64,18 @@
   ArrayRef Relations, FileID FID,
   unsigned Offset,
   index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
-if (isSearchedLocation(FID, Offset))
-  Decls.push_back(D);
+if (isSearchedLocation(FID, Offset)) {
+  // Find and add definition declarations (for GoToDefinition).
+  // We don't use parameter `D`, as Parameter `D` is the canonical
+  // declaration, which is the first declaration of a redeclarable
+  // declaration, and it could be a forward declaration.
+  if (const auto* Def = GetDefinition(D)) {
+Decls.push_back(Def);
+  } else {
+// Couldn't find a definition, fall back to use `D`.
+Decls.push_back(D);
+  }
+}
 return true;
   }
 


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -203,6 +203,18 @@
 #define MACRO 2
 #undef macro
   )cpp",
+
+  R"cpp(// Forward class declaration
+class Foo;
+[[class Foo {}]];
+F^oo* foo();
+  )cpp",
+
+  R"cpp(// Function declaration
+void foo();
+void g() { f^oo(); }
+[[void foo() {}]]
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -14,6 +14,20 @@
 using namespace llvm;
 namespace {
 
+// Get the definition from a given declaration `D`.
+// Return nullptr if no definition is found, or the declaration type of `D` is
+// not supported.
+const Decl* GetDefinition(const Decl* D) {
+  assert(D);
+  if (const auto *TD = dyn_cast(D))
+return TD->getDefinition();
+  else if (const auto *VD = dyn_cast(D))
+return VD->getDefinition();
+  else if (const auto *FD = dyn_cast(D))
+return FD->getDefinition();
+  return nullptr;
+}
+
 /// Finds declarations locations that a given source location refers to.
 class DeclarationAndMacrosFinder : public index::IndexDataConsumer {
   std::vector Decls;
@@ -50,8 +64,18 @@
   ArrayRef Relations, FileID FID,
   unsigned Offset,
   index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
-if (isSearchedLocation(FID, Offset))
-  Decls.push_back(D);
+if (isSearchedLocation(FID, Offset)) {
+  // Find and add definition declarations (for GoToDefinition).
+  // We don't use parameter `D`, as Parameter `D` is the canonical
+  // declaration, which is the first declaration of a redeclarable
+  // declaration, and it could be a forward declaration.
+  if (const auto* Def = GetDefinition(D)) {
+Decls.push_back(Def);
+  } else {
+// Couldn't find a definition, fall back to use `D`.
+Decls.push_back(D);
+  }
+}
 return true;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r321697 - [libclang] Support querying whether a declaration is invalid

2018-01-03 Thread Hans Wennborg via cfe-commits
I don't, but reverting your change made the test pass again.

I was able to reproduce locally by adding -target
ppc64le-unknown-linux to the run-line in test/Index/opencl-types.cl.

On Wed, Jan 3, 2018 at 3:23 PM, Ivan Donchevskii  wrote:
> Hi!
> I saw it but I don't see an issue in this change. Do you have an idea why
> that happened?
>
> 
> From: hwennb...@google.com  on behalf of Hans Wennborg
> 
> Sent: Wednesday, January 3, 2018 3:21:52 PM
> To: Ivan Donchevskii
> Cc: cfe-commits
> Subject: Re: r321697 - [libclang] Support querying whether a declaration is
> invalid
>
> This caused failures on the buildbots. I've reverted it and the
> commits that depended on it in r321708. See that commit message for
> more details.
>
> On Wed, Jan 3, 2018 at 10:49 AM, Ivan Donchevskii via cfe-commits
>  wrote:
>> Author: yvvan
>> Date: Wed Jan  3 01:49:31 2018
>> New Revision: 321697
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=321697=rev
>> Log:
>> [libclang] Support querying whether a declaration is invalid
>>
>> This is useful for e.g. highlighting purposes in an IDE.
>>
>> Patch by Nikolai Kosjar.
>>
>> Differential Revision: https://reviews.llvm.org/D40072
>>
>> Modified:
>> cfe/trunk/include/clang-c/Index.h
>> cfe/trunk/test/Index/print-type-size.cpp
>> cfe/trunk/tools/c-index-test/c-index-test.c
>> cfe/trunk/tools/libclang/CIndex.cpp
>> cfe/trunk/tools/libclang/libclang.exports
>>
>> Modified: cfe/trunk/include/clang-c/Index.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=321697=321696=321697=diff
>>
>> ==
>> --- cfe/trunk/include/clang-c/Index.h (original)
>> +++ cfe/trunk/include/clang-c/Index.h Wed Jan  3 01:49:31 2018
>> @@ -29,13 +29,13 @@
>>   * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking
>> changes.
>>   *
>>   * The policy about the libclang API was always to keep it source and ABI
>> - * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
>> - */
>> -#define CINDEX_VERSION_MAJOR 0
>> -#define CINDEX_VERSION_MINOR 45
>> -
>> -#define CINDEX_VERSION_ENCODE(major, minor) ( \
>> -  ((major) * 1)   \
>> + * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
>> + */
>> +#define CINDEX_VERSION_MAJOR 0
>> +#define CINDEX_VERSION_MINOR 46
>> +
>> +#define CINDEX_VERSION_ENCODE(major, minor) ( \
>> +  ((major) * 1)   \
>>  + ((minor) * 1))
>>
>>  #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
>> @@ -2638,12 +2638,22 @@ CINDEX_LINKAGE enum CXCursorKind clang_g
>>
>>  /**
>>   * \brief Determine whether the given cursor kind represents a
>> declaration.
>> - */
>> -CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
>> -
>> -/**
>> - * \brief Determine whether the given cursor kind represents a simple
>> - * reference.
>> + */
>> +CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
>> +
>> +/**
>> + * \brief Determine whether the given declaration is invalid.
>> + *
>> + * A declaration is invalid if it could not be parsed successfully.
>> + *
>> + * \returns non-zero if the cursor represents a declaration and it is
>> + * invalid, otherwise NULL.
>> + */
>> +CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
>> +
>> +/**
>> + * \brief Determine whether the given cursor kind represents a simple
>> + * reference.
>>   *
>>   * Note that other kinds of cursors (such as expressions) can also refer
>> to
>>   * other cursors. Use clang_getCursorReferenced() to determine whether a
>>
>> Modified: cfe/trunk/test/Index/print-type-size.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-size.cpp?rev=321697=321696=321697=diff
>>
>> ==
>> --- cfe/trunk/test/Index/print-type-size.cpp (original)
>> +++ cfe/trunk/test/Index/print-type-size.cpp Wed Jan  3 01:49:31 2018
>> @@ -1,14 +1,14 @@
>>  // from SemaCXX/class-layout.cpp
>>  // RUN: c-index-test -test-print-type-size %s -target x86_64-pc-linux-gnu
>> | FileCheck -check-prefix=CHECK64 %s
>>  // RUN: c-index-test -test-print-type-size %s -target i386-apple-darwin9
>> | FileCheck -check-prefix=CHECK32 %s
>> -
>> -namespace basic {
>> -
>> -// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) [type=void]
>> [typekind=Void]
>> -// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) [type=void]
>> [typekind=Void]
>> -void v;
>> -
>> -// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *]
>> [typekind=Pointer] [sizeof=8] [alignof=8]
>> +
>> +namespace basic {
>> +
>> +// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) (invalid) [type=void]
>> [typekind=Void]
>> +// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) (invalid) [type=void]
>> [typekind=Void]
>> +void v;

Re: r321697 - [libclang] Support querying whether a declaration is invalid

2018-01-03 Thread Ivan Donchevskii via cfe-commits
Ok, I've asked Nikolai to recheck it on Linux and re-commited the rolled back 
change which is not connected with the failing one.


From: hwennb...@google.com  on behalf of Hans Wennborg 

Sent: Wednesday, January 3, 2018 3:27:48 PM
To: Ivan Donchevskii; cfe-commits
Subject: Re: r321697 - [libclang] Support querying whether a declaration is 
invalid

I don't, but reverting your change made the test pass again.

I was able to reproduce locally by adding -target
ppc64le-unknown-linux to the run-line in test/Index/opencl-types.cl.

On Wed, Jan 3, 2018 at 3:23 PM, Ivan Donchevskii  wrote:
> Hi!
> I saw it but I don't see an issue in this change. Do you have an idea why
> that happened?
>
> 
> From: hwennb...@google.com  on behalf of Hans Wennborg
> 
> Sent: Wednesday, January 3, 2018 3:21:52 PM
> To: Ivan Donchevskii
> Cc: cfe-commits
> Subject: Re: r321697 - [libclang] Support querying whether a declaration is
> invalid
>
> This caused failures on the buildbots. I've reverted it and the
> commits that depended on it in r321708. See that commit message for
> more details.
>
> On Wed, Jan 3, 2018 at 10:49 AM, Ivan Donchevskii via cfe-commits
>  wrote:
>> Author: yvvan
>> Date: Wed Jan  3 01:49:31 2018
>> New Revision: 321697
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=321697=rev
>> Log:
>> [libclang] Support querying whether a declaration is invalid
>>
>> This is useful for e.g. highlighting purposes in an IDE.
>>
>> Patch by Nikolai Kosjar.
>>
>> Differential Revision: https://reviews.llvm.org/D40072
>>
>> Modified:
>> cfe/trunk/include/clang-c/Index.h
>> cfe/trunk/test/Index/print-type-size.cpp
>> cfe/trunk/tools/c-index-test/c-index-test.c
>> cfe/trunk/tools/libclang/CIndex.cpp
>> cfe/trunk/tools/libclang/libclang.exports
>>
>> Modified: cfe/trunk/include/clang-c/Index.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=321697=321696=321697=diff
>>
>> ==
>> --- cfe/trunk/include/clang-c/Index.h (original)
>> +++ cfe/trunk/include/clang-c/Index.h Wed Jan  3 01:49:31 2018
>> @@ -29,13 +29,13 @@
>>   * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking
>> changes.
>>   *
>>   * The policy about the libclang API was always to keep it source and ABI
>> - * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
>> - */
>> -#define CINDEX_VERSION_MAJOR 0
>> -#define CINDEX_VERSION_MINOR 45
>> -
>> -#define CINDEX_VERSION_ENCODE(major, minor) ( \
>> -  ((major) * 1)   \
>> + * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
>> + */
>> +#define CINDEX_VERSION_MAJOR 0
>> +#define CINDEX_VERSION_MINOR 46
>> +
>> +#define CINDEX_VERSION_ENCODE(major, minor) ( \
>> +  ((major) * 1)   \
>>  + ((minor) * 1))
>>
>>  #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
>> @@ -2638,12 +2638,22 @@ CINDEX_LINKAGE enum CXCursorKind clang_g
>>
>>  /**
>>   * \brief Determine whether the given cursor kind represents a
>> declaration.
>> - */
>> -CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
>> -
>> -/**
>> - * \brief Determine whether the given cursor kind represents a simple
>> - * reference.
>> + */
>> +CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
>> +
>> +/**
>> + * \brief Determine whether the given declaration is invalid.
>> + *
>> + * A declaration is invalid if it could not be parsed successfully.
>> + *
>> + * \returns non-zero if the cursor represents a declaration and it is
>> + * invalid, otherwise NULL.
>> + */
>> +CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
>> +
>> +/**
>> + * \brief Determine whether the given cursor kind represents a simple
>> + * reference.
>>   *
>>   * Note that other kinds of cursors (such as expressions) can also refer
>> to
>>   * other cursors. Use clang_getCursorReferenced() to determine whether a
>>
>> Modified: cfe/trunk/test/Index/print-type-size.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-size.cpp?rev=321697=321696=321697=diff
>>
>> ==
>> --- cfe/trunk/test/Index/print-type-size.cpp (original)
>> +++ cfe/trunk/test/Index/print-type-size.cpp Wed Jan  3 01:49:31 2018
>> @@ -1,14 +1,14 @@
>>  // from SemaCXX/class-layout.cpp
>>  // RUN: c-index-test -test-print-type-size %s -target x86_64-pc-linux-gnu
>> | FileCheck -check-prefix=CHECK64 %s
>>  // RUN: c-index-test -test-print-type-size %s -target i386-apple-darwin9
>> | FileCheck -check-prefix=CHECK32 %s
>> -
>> -namespace basic {
>> -
>> -// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) [type=void]
>> [typekind=Void]
>> -// CHECK32: 

[PATCH] D39050: Add index-while-building support to Clang

2018-01-03 Thread Eric Liu via Phabricator via cfe-commits
ioeric requested changes to this revision.
ioeric added a comment.
This revision now requires changes to proceed.

(I think I forgot to update the patch status :)


https://reviews.llvm.org/D39050



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


Re: r321697 - [libclang] Support querying whether a declaration is invalid

2018-01-03 Thread Hans Wennborg via cfe-commits
This caused failures on the buildbots. I've reverted it and the
commits that depended on it in r321708. See that commit message for
more details.

On Wed, Jan 3, 2018 at 10:49 AM, Ivan Donchevskii via cfe-commits
 wrote:
> Author: yvvan
> Date: Wed Jan  3 01:49:31 2018
> New Revision: 321697
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321697=rev
> Log:
> [libclang] Support querying whether a declaration is invalid
>
> This is useful for e.g. highlighting purposes in an IDE.
>
> Patch by Nikolai Kosjar.
>
> Differential Revision: https://reviews.llvm.org/D40072
>
> Modified:
> cfe/trunk/include/clang-c/Index.h
> cfe/trunk/test/Index/print-type-size.cpp
> cfe/trunk/tools/c-index-test/c-index-test.c
> cfe/trunk/tools/libclang/CIndex.cpp
> cfe/trunk/tools/libclang/libclang.exports
>
> Modified: cfe/trunk/include/clang-c/Index.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=321697=321696=321697=diff
> ==
> --- cfe/trunk/include/clang-c/Index.h (original)
> +++ cfe/trunk/include/clang-c/Index.h Wed Jan  3 01:49:31 2018
> @@ -29,13 +29,13 @@
>   * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
>   *
>   * The policy about the libclang API was always to keep it source and ABI
> - * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
> - */
> -#define CINDEX_VERSION_MAJOR 0
> -#define CINDEX_VERSION_MINOR 45
> -
> -#define CINDEX_VERSION_ENCODE(major, minor) ( \
> -  ((major) * 1)   \
> + * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
> + */
> +#define CINDEX_VERSION_MAJOR 0
> +#define CINDEX_VERSION_MINOR 46
> +
> +#define CINDEX_VERSION_ENCODE(major, minor) ( \
> +  ((major) * 1)   \
>  + ((minor) * 1))
>
>  #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
> @@ -2638,12 +2638,22 @@ CINDEX_LINKAGE enum CXCursorKind clang_g
>
>  /**
>   * \brief Determine whether the given cursor kind represents a declaration.
> - */
> -CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
> -
> -/**
> - * \brief Determine whether the given cursor kind represents a simple
> - * reference.
> + */
> +CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
> +
> +/**
> + * \brief Determine whether the given declaration is invalid.
> + *
> + * A declaration is invalid if it could not be parsed successfully.
> + *
> + * \returns non-zero if the cursor represents a declaration and it is
> + * invalid, otherwise NULL.
> + */
> +CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
> +
> +/**
> + * \brief Determine whether the given cursor kind represents a simple
> + * reference.
>   *
>   * Note that other kinds of cursors (such as expressions) can also refer to
>   * other cursors. Use clang_getCursorReferenced() to determine whether a
>
> Modified: cfe/trunk/test/Index/print-type-size.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-size.cpp?rev=321697=321696=321697=diff
> ==
> --- cfe/trunk/test/Index/print-type-size.cpp (original)
> +++ cfe/trunk/test/Index/print-type-size.cpp Wed Jan  3 01:49:31 2018
> @@ -1,14 +1,14 @@
>  // from SemaCXX/class-layout.cpp
>  // RUN: c-index-test -test-print-type-size %s -target x86_64-pc-linux-gnu | 
> FileCheck -check-prefix=CHECK64 %s
>  // RUN: c-index-test -test-print-type-size %s -target i386-apple-darwin9 | 
> FileCheck -check-prefix=CHECK32 %s
> -
> -namespace basic {
> -
> -// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) [type=void] [typekind=Void]
> -// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) [type=void] [typekind=Void]
> -void v;
> -
> -// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *] 
> [typekind=Pointer] [sizeof=8] [alignof=8]
> +
> +namespace basic {
> +
> +// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) (invalid) [type=void] 
> [typekind=Void]
> +// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) (invalid) [type=void] 
> [typekind=Void]
> +void v;
> +
> +// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *] 
> [typekind=Pointer] [sizeof=8] [alignof=8]
>  // CHECK32: VarDecl=v1:[[@LINE+1]]:7 (Definition) [type=void *] 
> [typekind=Pointer] [sizeof=4] [alignof=4]
>  void *v1;
>
>
> Modified: cfe/trunk/tools/c-index-test/c-index-test.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=321697=321696=321697=diff
> ==
> --- cfe/trunk/tools/c-index-test/c-index-test.c (original)
> +++ cfe/trunk/tools/c-index-test/c-index-test.c Wed Jan  3 01:49:31 2018
> @@ -809,12 +809,14 @@ static void PrintCursor(CXCursor Cursor,
>  if (clang_EnumDecl_isScoped(Cursor))
>printf(" (scoped)");
>  if 

Re: [clang-tools-extra] r321363 - [clang-tidy] Adding Fuchsia checker for overloaded operators

2018-01-03 Thread Alexander Kornienko via cfe-commits
There was a recent bug report related to this check. Could you take a look?
http://llvm.org/PR35803

On Fri, Dec 22, 2017 at 5:52 PM, Julie Hockett via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: juliehockett
> Date: Fri Dec 22 08:52:25 2017
> New Revision: 321363
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321363=rev
> Log:
> [clang-tidy] Adding Fuchsia checker for overloaded operators
>
> Adds a check to the Fuchsia module to warn if an operator is overloaded,
> except move and copy operators.
>
> See https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md for
> reference.
>
> Differential Revision: https://reviews.llvm.org/D41363
>
> Added:
> clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
> clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.h
> clang-tools-extra/trunk/docs/clang-tidy/checks/fuchsia-
> overloaded-operator.rst
> clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-
> operator.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
> clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
> clang-tools-extra/trunk/docs/ReleaseNotes.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/fuchsia/CMakeLists.txt?rev=321363=
> 321362=321363=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/fuchsia/CMakeLists.txt Fri Dec 22
> 08:52:25 2017
> @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS support)
>  add_clang_library(clangTidyFuchsiaModule
>DefaultArgumentsCheck.cpp
>FuchsiaTidyModule.cpp
> +  OverloadedOperatorCheck.cpp
>VirtualInheritanceCheck.cpp
>
>LINK_LIBS
>
> Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp?rev=
> 321363=321362=321363=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/fuchsia/FuchsiaTidyModule.cpp Fri
> Dec 22 08:52:25 2017
> @@ -11,6 +11,7 @@
>  #include "../ClangTidyModule.h"
>  #include "../ClangTidyModuleRegistry.h"
>  #include "DefaultArgumentsCheck.h"
> +#include "OverloadedOperatorCheck.h"
>  #include "VirtualInheritanceCheck.h"
>
>  using namespace clang::ast_matchers;
> @@ -25,6 +26,8 @@ public:
>void addCheckFactories(ClangTidyCheckFactories )
> override {
>  CheckFactories.registerCheck(
>  "fuchsia-default-arguments");
> +CheckFactories.registerCheck(
> +"fuchsia-overloaded-operator");
>  CheckFactories.registerCheck(
>  "fuchsia-virtual-inheritance");
>}
>
> Added: clang-tools-extra/trunk/clang-tidy/fuchsia/
> OverloadedOperatorCheck.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp?rev=321363=auto
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
> (added)
> +++ clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
> Fri Dec 22 08:52:25 2017
> @@ -0,0 +1,39 @@
> +//===--- OverloadedOperatorCheck.cpp - clang-tidy
> --===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===--
> ===//
> +
> +#include "OverloadedOperatorCheck.h"
> +
> +using namespace clang::ast_matchers;
> +
> +namespace clang {
> +namespace tidy {
> +namespace fuchsia {
> +
> +AST_MATCHER(FunctionDecl, isFuchsiaOverloadedOperator) {
> +  if (const auto *CXXMethodNode = dyn_cast()) {
> +if (CXXMethodNode->isCopyAssignmentOperator() ||
> +CXXMethodNode->isMoveAssignmentOperator())
> +  return false;
> +  }
> +  return Node.isOverloadedOperator();
> +}
> +
> +void OverloadedOperatorCheck::registerMatchers(MatchFinder *Finder) {
> +  Finder->addMatcher(functionDecl(isFuchsiaOverloadedOperator())
> .bind("decl"),
> + this);
> +}
> +
> +void OverloadedOperatorCheck::check(const MatchFinder::MatchResult
> ) {
> +  if (const auto *D = Result.Nodes.getNodeAs("decl"))
> +diag(D->getLocStart(), "cannot overload %0") << D;
> +}
> +
> +} // namespace fuchsia
> +} // namespace tidy
> +} // namespace clang
>
> Added: clang-tools-extra/trunk/clang-tidy/fuchsia/
> OverloadedOperatorCheck.h
> URL: 

[libunwind] r321724 - Creating release_60 branch off revision 321711

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 06:54:55 2018
New Revision: 321724

URL: http://llvm.org/viewvc/llvm-project?rev=321724=rev
Log:
Creating release_60 branch off revision 321711

Added:
libunwind/branches/release_60/
  - copied from r321711, libunwind/trunk/

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


[PATCH] D41711: [docs] Mention support for Windows/ARM64 in the release notes

2018-01-03 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321788: [docs] Mention support for Windows/ARM64 in the 
release notes (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41711?vs=128555=128596#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41711

Files:
  cfe/branches/release_60/docs/ReleaseNotes.rst


Index: cfe/branches/release_60/docs/ReleaseNotes.rst
===
--- cfe/branches/release_60/docs/ReleaseNotes.rst
+++ cfe/branches/release_60/docs/ReleaseNotes.rst
@@ -168,8 +168,8 @@
 Windows Support
 ---
 
-Clang's support for building native Windows programs ...
-
+- Clang now has initial, preliminary support for targeting Windows on
+  ARM64.
 
 C Language Changes in Clang
 ---


Index: cfe/branches/release_60/docs/ReleaseNotes.rst
===
--- cfe/branches/release_60/docs/ReleaseNotes.rst
+++ cfe/branches/release_60/docs/ReleaseNotes.rst
@@ -168,8 +168,8 @@
 Windows Support
 ---
 
-Clang's support for building native Windows programs ...
-
+- Clang now has initial, preliminary support for targeting Windows on
+  ARM64.
 
 C Language Changes in Clang
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41668: [clangd] Add static index for the global code completion.

2018-01-03 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/ClangdLSPServer.h:40
+  bool BuildDynamicSymbolIndex,
+  std::unique_ptr GlobalIdx);
 

We are calling this global index and static index in the patch. I think we 
should be consistent with the naming. Generally, I think this is static index, 
which might be global index or, say, a set of symbols for test purpose, so I am 
inclined to static index.



Comment at: clangd/CodeComplete.cpp:583
 
-  Items->isIncomplete = !Index.fuzzyFind(Ctx, Req, [&](const Symbol ) {
-Items->items.push_back(indexCompletionItem(Sym, Filter, SSInfo));
-  });
+  // FIXME: figure out a way to merge the symbols from dynamic index and static
+  // index.

I would suggest also addressing this `FIXME` in this patch, or at least make it 
possible to tell from which index source a candidate comes on the client side. 
Simple concatenation from both indexes would make the results hard to 
interpret, especially when we don't have a good merging algorithm at this point.



Comment at: clangd/CodeComplete.h:72
+  /// Static index for project-wide global symbols. It is set by the clangd
+  /// client.
+  /// The static index is loaded and built only once when clangd is being

`clangd client` is a confusing term? Do you mean clangd library users? Also, I 
think this field is only set internally by clangd in this patch.



Comment at: clangd/CodeComplete.h:74
+  /// The static index is loaded and built only once when clangd is being
+  /// launched.
+  const SymbolIndex *StaticIndex = nullptr;

This depends on users, so I would drop this line.



Comment at: clangd/index/MemIndex.cpp:56
 
+std::unique_ptr BuildMemIndex(SymbolSlab::Builder Slab) {
+  struct Snapshot {

s/Slab/Builder/?

Any reason not to pass in a `SymbolSlab` directly?



Comment at: clangd/index/MemIndex.h:39
 
+std::unique_ptr BuildMemIndex(SymbolSlab::Builder Slab);
+

I'd make this a factory method and call it `Build`.



Comment at: clangd/tool/ClangdMain.cpp:119
 
+static llvm::cl::opt GlobalIndexFile(
+"global-index-file",

Maybe `YamlSymbolFile` or something similar without "global"? Yaml could 
potentially be used for other static indexes.



Comment at: unittests/clangd/CodeCompleteTests.cpp:487
 
+TEST(CompletionTest, StaticIndex) {
+  clangd::CodeCompleteOptions Opts;

We should also have a test where results come from both static index and ast 
index.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41668



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


[PATCH] D41668: [clangd] Add static index for the global code completion.

2018-01-03 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

You have mentioned that YAML data source is experimental only  in the patch 
summary, but we should also mention this in the code.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41668



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


[PATCH] D41005: Reuse preamble even if an unsaved file does not exist

2018-01-03 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

No regression in tests on Windows with and without extra patch ([PATCH] Use 
file path instead of uniqueID)


Repository:
  rC Clang

https://reviews.llvm.org/D41005



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


[PATCH] D41512: [Sema] -Wtautological-constant-compare is too good. Cripple it.

2018-01-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321691: [Sema] -Wtautological-constant-compare is too good. 
Cripple it. (authored by lebedevri, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41512?vs=128470=128494#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41512

Files:
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/test/Sema/compare.c
  cfe/trunk/test/Sema/tautological-constant-compare.c
  cfe/trunk/test/Sema/tautological-constant-enum-compare.c
  cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c
  cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.cpp
  cfe/trunk/test/Sema/tautological-unsigned-zero-compare.c
  cfe/trunk/test/SemaCXX/compare.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5946,15 +5946,15 @@
 def warn_unsigned_always_true_comparison : Warning<
   "result of comparison of %select{%3|unsigned expression}0 %2 "
   "%select{unsigned expression|%3}0 is always %4">,
-  InGroup;
+  InGroup, DefaultIgnore;
 def warn_unsigned_enum_always_true_comparison : Warning<
   "result of comparison of %select{%3|unsigned enum expression}0 %2 "
   "%select{unsigned enum expression|%3}0 is always %4">,
-  InGroup;
+  InGroup, DefaultIgnore;
 def warn_tautological_constant_compare : Warning<
   "result of comparison %select{%3|%1}0 %2 "
   "%select{%1|%3}0 is always %4">,
-  InGroup;
+  InGroup, DefaultIgnore;
 
 def warn_mixed_sign_comparison : Warning<
   "comparison of integers of different signs: %0 and %1">,
Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -435,12 +435,16 @@
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
 def StrncatSize : DiagGroup<"strncat-size">;
+def TautologicalTypeLimitCompare : DiagGroup<"tautological-type-limit-compare">;
 def TautologicalUnsignedZeroCompare : DiagGroup<"tautological-unsigned-zero-compare">;
 def TautologicalUnsignedEnumZeroCompare : DiagGroup<"tautological-unsigned-enum-zero-compare">;
+def TautologicalInRangeCompare : DiagGroup<"tautological-constant-in-range-compare",
+   [TautologicalTypeLimitCompare,
+TautologicalUnsignedZeroCompare,
+TautologicalUnsignedEnumZeroCompare]>;
 def TautologicalOutOfRangeCompare : DiagGroup<"tautological-constant-out-of-range-compare">;
 def TautologicalConstantCompare : DiagGroup<"tautological-constant-compare",
-[TautologicalUnsignedZeroCompare,
- TautologicalUnsignedEnumZeroCompare,
+[TautologicalInRangeCompare,
  TautologicalOutOfRangeCompare]>;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
@@ -715,6 +719,7 @@
 def Move : DiagGroup<"move", [PessimizingMove, RedundantMove, SelfMove]>;
 
 def Extra : DiagGroup<"extra", [
+TautologicalInRangeCompare,
 MissingFieldInitializers,
 IgnoredQualifiers,
 InitializerOverrides,
Index: cfe/trunk/test/SemaCXX/compare.cpp
===
--- cfe/trunk/test/SemaCXX/compare.cpp
+++ cfe/trunk/test/SemaCXX/compare.cpp
@@ -1,7 +1,7 @@
 // Force x86-64 because some of our heuristics are actually based
 // on integer sizes.
 
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare -Wtautological-constant-in-range-compare -std=c++11 %s
 
 int test0(long a, unsigned long b) {
   enum EnumA {A};
Index: cfe/trunk/test/Sema/tautological-constant-compare.c
===
--- cfe/trunk/test/Sema/tautological-constant-compare.c
+++ cfe/trunk/test/Sema/tautological-constant-compare.c
@@ -1,7 +1,13 @@
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -DTEST -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wno-tautological-constant-compare -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -DTEST -verify -x c++ %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wno-tautological-constant-compare -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only 

r321691 - [Sema] -Wtautological-constant-compare is too good. Cripple it.

2018-01-03 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Wed Jan  3 00:45:19 2018
New Revision: 321691

URL: http://llvm.org/viewvc/llvm-project?rev=321691=rev
Log:
[Sema] -Wtautological-constant-compare is too good. Cripple it.

Summary:
The diagnostic was mostly introduced in D38101 by me, as a reaction to wasting 
a lot of time, see [[ 
https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20171009/206427.html | 
mail ]].
However, the diagnostic is pretty dumb. While it works with no false-positives,
there are some questionable cases that are diagnosed when one would argue that 
they should not be.

The common complaint is that it diagnoses the comparisons between an `int` and
`long` when compiling for a 32-bit target as tautological, but not when
compiling for 64-bit targets. The underlying problem is obvious: data model.
In most cases, 64-bit target is `LP64` (`int` is 32-bit, `long` and pointer are
64-bit), and the 32-bit target is `ILP32` (`int`, `long`, and pointer are 
32-bit).

I.e. the common pattern is: (pseudocode)
```
#include 
#include 
int main() {
  using T1 = long;
  using T2 = int;

  T1 r;
  if (r < std::numeric_limits::min()) {}
  if (r > std::numeric_limits::max()) {}
}
```
As an example, D39149 was trying to fix this diagnostic in libc++, and it was 
not well-received.

This *could* be "fixed", by changing the diagnostics logic to something like
`if the types of the values being compared are different, but are of the same 
size, then do diagnose`,
and i even attempted to do so in D39462, but as @rjmccall rightfully commented,
that implementation is incomplete to say the least.

So to stop causing trouble, and avoid contaminating upcoming release, lets do 
this workaround:
* move these three diags (`warn_unsigned_always_true_comparison`, 
`warn_unsigned_enum_always_true_comparison`, 
`warn_tautological_constant_compare`) into it's own 
`-Wtautological-constant-in-range-compare`
* Disable them by default
* Make them part of `-Wextra`
* Additionally, give `warn_tautological_constant_compare` it's own flag 
`-Wtautological-type-limit-compare`.
  I'm not happy about that name, but i can't come up with anything better.

This way all three of them can be enabled/disabled either altogether, or 
one-by-one.

Reviewers: aaron.ballman, rsmith, smeenai, rjmccall, rnk, mclow.lists, dim

Reviewed By: aaron.ballman, rsmith, dim

Subscribers: thakis, compnerd, mehdi_amini, dim, hans, cfe-commits, rjmccall

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/test/Sema/compare.c
cfe/trunk/test/Sema/tautological-constant-compare.c
cfe/trunk/test/Sema/tautological-constant-enum-compare.c
cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c
cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.cpp
cfe/trunk/test/Sema/tautological-unsigned-zero-compare.c
cfe/trunk/test/SemaCXX/compare.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=321691=321690=321691=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jan  3 00:45:19 2018
@@ -435,12 +435,16 @@ def StringCompare : DiagGroup<"string-co
 def StringPlusInt : DiagGroup<"string-plus-int">;
 def StringPlusChar : DiagGroup<"string-plus-char">;
 def StrncatSize : DiagGroup<"strncat-size">;
+def TautologicalTypeLimitCompare : 
DiagGroup<"tautological-type-limit-compare">;
 def TautologicalUnsignedZeroCompare : 
DiagGroup<"tautological-unsigned-zero-compare">;
 def TautologicalUnsignedEnumZeroCompare : 
DiagGroup<"tautological-unsigned-enum-zero-compare">;
+def TautologicalInRangeCompare : 
DiagGroup<"tautological-constant-in-range-compare",
+   [TautologicalTypeLimitCompare,
+TautologicalUnsignedZeroCompare,
+
TautologicalUnsignedEnumZeroCompare]>;
 def TautologicalOutOfRangeCompare : 
DiagGroup<"tautological-constant-out-of-range-compare">;
 def TautologicalConstantCompare : DiagGroup<"tautological-constant-compare",
-[TautologicalUnsignedZeroCompare,
- 
TautologicalUnsignedEnumZeroCompare,
+[TautologicalInRangeCompare,
  TautologicalOutOfRangeCompare]>;
 def TautologicalPointerCompare : DiagGroup<"tautological-pointer-compare">;
 def TautologicalOverlapCompare : DiagGroup<"tautological-overlap-compare">;
@@ -715,6 +719,7 @@ def IntToPointerCast : DiagGroup<"int-to
 def Move : DiagGroup<"move", [PessimizingMove, RedundantMove, SelfMove]>;
 
 

r321695 - [libclang] Add clang_getFileContents to libclang.exports

2018-01-03 Thread Ivan Donchevskii via cfe-commits
Author: yvvan
Date: Wed Jan  3 01:17:08 2018
New Revision: 321695

URL: http://llvm.org/viewvc/llvm-project?rev=321695=rev
Log:
[libclang] Add clang_getFileContents to libclang.exports

This is the follow up patch for rL319881 which introduced
the function but did not put it into .exports file.

Modified:
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/tools/libclang/libclang.exports
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/libclang.exports?rev=321695=321694=321695=diff
==
--- cfe/trunk/tools/libclang/libclang.exports (original)
+++ cfe/trunk/tools/libclang/libclang.exports Wed Jan  3 01:17:08 2018
@@ -220,6 +220,7 @@ clang_getExceptionSpecificationType
 clang_getFieldDeclBitWidth
 clang_getExpansionLocation
 clang_getFile
+clang_getFileContents
 clang_getFileLocation
 clang_getFileName
 clang_getFileTime


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


r321697 - [libclang] Support querying whether a declaration is invalid

2018-01-03 Thread Ivan Donchevskii via cfe-commits
Author: yvvan
Date: Wed Jan  3 01:49:31 2018
New Revision: 321697

URL: http://llvm.org/viewvc/llvm-project?rev=321697=rev
Log:
[libclang] Support querying whether a declaration is invalid

This is useful for e.g. highlighting purposes in an IDE.

Patch by Nikolai Kosjar.

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

Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/print-type-size.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=321697=321696=321697=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Jan  3 01:49:31 2018
@@ -29,13 +29,13 @@
  * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
  *
  * The policy about the libclang API was always to keep it source and ABI
- * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
- */
-#define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 45
-
-#define CINDEX_VERSION_ENCODE(major, minor) ( \
-  ((major) * 1)   \
+ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
+ */
+#define CINDEX_VERSION_MAJOR 0
+#define CINDEX_VERSION_MINOR 46
+
+#define CINDEX_VERSION_ENCODE(major, minor) ( \
+  ((major) * 1)   \
 + ((minor) * 1))
 
 #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
@@ -2638,12 +2638,22 @@ CINDEX_LINKAGE enum CXCursorKind clang_g
 
 /**
  * \brief Determine whether the given cursor kind represents a declaration.
- */
-CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
-
-/**
- * \brief Determine whether the given cursor kind represents a simple
- * reference.
+ */
+CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
+
+/**
+ * \brief Determine whether the given declaration is invalid.
+ *
+ * A declaration is invalid if it could not be parsed successfully.
+ *
+ * \returns non-zero if the cursor represents a declaration and it is
+ * invalid, otherwise NULL.
+ */
+CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
+
+/**
+ * \brief Determine whether the given cursor kind represents a simple
+ * reference.
  *
  * Note that other kinds of cursors (such as expressions) can also refer to
  * other cursors. Use clang_getCursorReferenced() to determine whether a

Modified: cfe/trunk/test/Index/print-type-size.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-size.cpp?rev=321697=321696=321697=diff
==
--- cfe/trunk/test/Index/print-type-size.cpp (original)
+++ cfe/trunk/test/Index/print-type-size.cpp Wed Jan  3 01:49:31 2018
@@ -1,14 +1,14 @@
 // from SemaCXX/class-layout.cpp
 // RUN: c-index-test -test-print-type-size %s -target x86_64-pc-linux-gnu | 
FileCheck -check-prefix=CHECK64 %s
 // RUN: c-index-test -test-print-type-size %s -target i386-apple-darwin9 | 
FileCheck -check-prefix=CHECK32 %s
-
-namespace basic {
-
-// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) [type=void] [typekind=Void]
-// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) [type=void] [typekind=Void]
-void v;
-
-// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *] 
[typekind=Pointer] [sizeof=8] [alignof=8]
+
+namespace basic {
+
+// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) (invalid) [type=void] 
[typekind=Void]
+// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) (invalid) [type=void] 
[typekind=Void]
+void v;
+
+// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *] 
[typekind=Pointer] [sizeof=8] [alignof=8]
 // CHECK32: VarDecl=v1:[[@LINE+1]]:7 (Definition) [type=void *] 
[typekind=Pointer] [sizeof=4] [alignof=4]
 void *v1;
 

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=321697=321696=321697=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Wed Jan  3 01:49:31 2018
@@ -809,12 +809,14 @@ static void PrintCursor(CXCursor Cursor,
 if (clang_EnumDecl_isScoped(Cursor))
   printf(" (scoped)");
 if (clang_Cursor_isVariadic(Cursor))
-  printf(" (variadic)");
-if (clang_Cursor_isObjCOptional(Cursor))
-  printf(" (@optional)");
-
-switch (clang_getCursorExceptionSpecificationType(Cursor))
-{
+  printf(" (variadic)");
+if (clang_Cursor_isObjCOptional(Cursor))
+  printf(" (@optional)");
+if (clang_isInvalidDeclaration(Cursor))
+  printf(" (invalid)");
+
+switch (clang_getCursorExceptionSpecificationType(Cursor))
+{
   case 

[PATCH] D40072: [libclang] Support querying whether a declaration is invalid

2018-01-03 Thread Ivan Donchevskii via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321697: [libclang] Support querying whether a declaration is 
invalid (authored by yvvan, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D40072?vs=128491=128497#toc

Repository:
  rC Clang

https://reviews.llvm.org/D40072

Files:
  include/clang-c/Index.h
  test/Index/print-type-size.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp
  tools/libclang/libclang.exports

Index: test/Index/print-type-size.cpp
===
--- test/Index/print-type-size.cpp
+++ test/Index/print-type-size.cpp
@@ -1,14 +1,14 @@
 // from SemaCXX/class-layout.cpp
 // RUN: c-index-test -test-print-type-size %s -target x86_64-pc-linux-gnu | FileCheck -check-prefix=CHECK64 %s
 // RUN: c-index-test -test-print-type-size %s -target i386-apple-darwin9 | FileCheck -check-prefix=CHECK32 %s
-
-namespace basic {
-
-// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) [type=void] [typekind=Void]
-// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) [type=void] [typekind=Void]
-void v;
-
-// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *] [typekind=Pointer] [sizeof=8] [alignof=8]
+
+namespace basic {
+
+// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) (invalid) [type=void] [typekind=Void]
+// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) (invalid) [type=void] [typekind=Void]
+void v;
+
+// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *] [typekind=Pointer] [sizeof=8] [alignof=8]
 // CHECK32: VarDecl=v1:[[@LINE+1]]:7 (Definition) [type=void *] [typekind=Pointer] [sizeof=4] [alignof=4]
 void *v1;
 
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -5418,12 +5418,21 @@
 
 unsigned clang_isDeclaration(enum CXCursorKind K) {
   return (K >= CXCursor_FirstDecl && K <= CXCursor_LastDecl) ||
- (K >= CXCursor_FirstExtraDecl && K <= CXCursor_LastExtraDecl);
-}
-
-unsigned clang_isReference(enum CXCursorKind K) {
-  return K >= CXCursor_FirstRef && K <= CXCursor_LastRef;
-}
+ (K >= CXCursor_FirstExtraDecl && K <= CXCursor_LastExtraDecl);
+}
+
+unsigned clang_isInvalidDeclaration(CXCursor C) {
+  if (clang_isDeclaration(C.kind)) {
+if (const Decl *D = getCursorDecl(C))
+  return D->isInvalidDecl();
+  }
+
+  return 0;
+}
+
+unsigned clang_isReference(enum CXCursorKind K) {
+  return K >= CXCursor_FirstRef && K <= CXCursor_LastRef;
+}
 
 unsigned clang_isExpression(enum CXCursorKind K) {
   return K >= CXCursor_FirstExpr && K <= CXCursor_LastExpr;
Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -288,12 +288,13 @@
 clang_index_setClientContainer
 clang_index_setClientEntity
 clang_isAttribute
-clang_isConstQualifiedType
-clang_isCursorDefinition
-clang_isDeclaration
-clang_isExpression
-clang_isFileMultipleIncludeGuarded
-clang_isFunctionTypeVariadic
+clang_isConstQualifiedType
+clang_isCursorDefinition
+clang_isDeclaration
+clang_isInvalidDeclaration
+clang_isExpression
+clang_isFileMultipleIncludeGuarded
+clang_isFunctionTypeVariadic
 clang_isInvalid
 clang_isPODType
 clang_isPreprocessing
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -809,12 +809,14 @@
 if (clang_EnumDecl_isScoped(Cursor))
   printf(" (scoped)");
 if (clang_Cursor_isVariadic(Cursor))
-  printf(" (variadic)");
-if (clang_Cursor_isObjCOptional(Cursor))
-  printf(" (@optional)");
-
-switch (clang_getCursorExceptionSpecificationType(Cursor))
-{
+  printf(" (variadic)");
+if (clang_Cursor_isObjCOptional(Cursor))
+  printf(" (@optional)");
+if (clang_isInvalidDeclaration(Cursor))
+  printf(" (invalid)");
+
+switch (clang_getCursorExceptionSpecificationType(Cursor))
+{
   case CXCursor_ExceptionSpecificationKind_None:
 break;
 
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -29,13 +29,13 @@
  * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
  *
  * The policy about the libclang API was always to keep it source and ABI
- * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
- */
-#define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 45
-
-#define CINDEX_VERSION_ENCODE(major, minor) ( \
-  ((major) * 1)   \
+ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
+ */
+#define CINDEX_VERSION_MAJOR 0
+#define CINDEX_VERSION_MINOR 46
+
+#define CINDEX_VERSION_ENCODE(major, minor) ( \
+  ((major) * 1)  

[PATCH] D40561: [libclang] Fix cursors for functions with trailing return type

2018-01-03 Thread Ivan Donchevskii via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321698: [libclang] Fix cursors for functions with trailing 
return type (authored by yvvan, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D40561?vs=124576=128499#toc

Repository:
  rC Clang

https://reviews.llvm.org/D40561

Files:
  test/Index/annotate-tokens.cpp
  tools/libclang/CIndex.cpp

Index: test/Index/annotate-tokens.cpp
===
--- test/Index/annotate-tokens.cpp
+++ test/Index/annotate-tokens.cpp
@@ -34,13 +34,15 @@
 }
 
 class C {
-  ~C();
-};
-
-// RUN: c-index-test -test-annotate-tokens=%s:1:1:38:1 %s -fno-delayed-template-parsing | FileCheck %s
-// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition)
-// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition)
-// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition)
+  ~C();
+};
+
+auto test5(X) -> X;
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:41:1 %s -std=c++14 -fno-delayed-template-parsing | FileCheck %s
+// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition)
+// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition)
+// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition)
 // CHECK: Punctuation: "}" [1:15 - 1:16] StructDecl=bonk:1:8 (Definition)
 // CHECK: Punctuation: ";" [1:16 - 1:17]
 // CHECK: Keyword: "void" [2:1 - 2:5] FunctionDecl=test:2:6 (Definition)
@@ -181,12 +183,20 @@
 // CHECK: Punctuation: "(" [29:18 - 29:19] CXXMethod=foo:29:15 (Definition)
 // CHECK: Punctuation: ")" [29:19 - 29:20] CXXMethod=foo:29:15 (Definition)
 // CHECK: Punctuation: "{" [29:21 - 29:22] CompoundStmt=
-// CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt=
-// CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3
-// CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3
-
-// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test -test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2
-// CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt=
+// CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt=
+// CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3
+// CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3
+// CHECK: Keyword: "auto" [40:1 - 40:5] FunctionDecl=test5:40:6
+// CHECK: Identifier: "test5" [40:6 - 40:11] FunctionDecl=test5:40:6
+// CHECK: Punctuation: "(" [40:11 - 40:12] FunctionDecl=test5:40:6
+// CHECK: Identifier: "X" [40:12 - 40:13] TypeRef=struct X:7:8
+// CHECK: Punctuation: ")" [40:13 - 40:14] FunctionDecl=test5:40:6
+// CHECK: Punctuation: "->" [40:15 - 40:17] FunctionDecl=test5:40:6
+// CHECK: Identifier: "X" [40:18 - 40:19] TypeRef=struct X:7:8
+// CHECK: Punctuation: ";" [40:19 - 40:20]
+
+// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test -test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2
+// CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt=
 // CHECK2: Punctuation: "(" [32:6 - 32:7] IfStmt=
 // CHECK2: Keyword: "int" [32:7 - 32:10] VarDecl=p:32:11 (Definition)
 // CHECK2: Identifier: "p" [32:11 - 32:12] VarDecl=p:32:11 (Definition)
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -782,12 +782,22 @@
 if (VisitNestedNameSpecifierLoc(QualifierLoc))
   return true;
 
-  return false;
-}
-
-/// \brief Compare two base or member initializers based on their source order.
-static int CompareCXXCtorInitializers(CXXCtorInitializer *const *X,
-  CXXCtorInitializer *const *Y) {
+  return false;
+}
+
+static bool HasTrailingReturnType(FunctionDecl *ND) {
+  const QualType Ty = ND->getType();
+  if (const FunctionType *AFT = Ty->getAs()) {
+if (const FunctionProtoType *FT = dyn_cast(AFT))
+  return FT->hasTrailingReturn();
+  }
+
+  return false;
+}
+
+/// \brief Compare two base or member initializers based on their source order.
+static int CompareCXXCtorInitializers(CXXCtorInitializer *const *X,
+  CXXCtorInitializer *const *Y) {
   return (*X)->getSourceOrder() - (*Y)->getSourceOrder();
 }
 
@@ -801,20 +811,22 @@
 
   if (TypeSourceInfo *TSInfo = ND->getTypeSourceInfo()) {
 // Visit the function declaration's syntactic components in the order
-// written. This requires a bit of work.
-TypeLoc TL = TSInfo->getTypeLoc().IgnoreParens();
-FunctionTypeLoc FTL = TL.getAs();
-
-// If we have a function declared directly (without the use of a typedef),
-// visit just the return type. Otherwise, just visit the function's type
-// now.
-if ((FTL && !isa(ND) && Visit(FTL.getReturnLoc())) ||
-(!FTL && Visit(TL)))
-  return true;
-
-// Visit the nested-name-specifier, if present.
-if (NestedNameSpecifierLoc QualifierLoc = ND->getQualifierLoc())

r321698 - [libclang] Fix cursors for functions with trailing return type

2018-01-03 Thread Ivan Donchevskii via cfe-commits
Author: yvvan
Date: Wed Jan  3 02:04:37 2018
New Revision: 321698

URL: http://llvm.org/viewvc/llvm-project?rev=321698=rev
Log:
[libclang] Fix cursors for functions with trailing return type

For the function declaration

auto foo5(Foo) -> Foo;
the parameter tokens were mapped to cursors representing the
FunctionDecl:

Keyword: "auto" [1:1 - 1:5] FunctionDecl=test5:1:6
Identifier: "test5" [1:6 - 1:11] FunctionDecl=test5:1:6
Punctuation: "(" [1:11 - 1:12] FunctionDecl=test5:1:6
Identifier: "X" [1:12 - 1:13] FunctionDecl=test5:1:6 // Ops, not a TypeRef
Punctuation: ")" [1:13 - 1:14] FunctionDecl=test5:1:6
Punctuation: "->" [1:15 - 1:17] FunctionDecl=test5:1:6
Identifier: "X" [1:18 - 1:19] TypeRef=struct X:7:8
Punctuation: ";" [1:19 - 1:20]

Fix this by ensuring that the trailing return type is not visited as
first.

Patch by Nikolai Kosjar.

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

Modified:
cfe/trunk/test/Index/annotate-tokens.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/annotate-tokens.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.cpp?rev=321698=321697=321698=diff
==
--- cfe/trunk/test/Index/annotate-tokens.cpp (original)
+++ cfe/trunk/test/Index/annotate-tokens.cpp Wed Jan  3 02:04:37 2018
@@ -34,13 +34,15 @@ void test4() {
 }
 
 class C {
-  ~C();
-};
-
-// RUN: c-index-test -test-annotate-tokens=%s:1:1:38:1 %s 
-fno-delayed-template-parsing | FileCheck %s
-// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition)
-// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition)
-// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition)
+  ~C();
+};
+
+auto test5(X) -> X;
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:41:1 %s -std=c++14 
-fno-delayed-template-parsing | FileCheck %s
+// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition)
+// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition)
+// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition)
 // CHECK: Punctuation: "}" [1:15 - 1:16] StructDecl=bonk:1:8 (Definition)
 // CHECK: Punctuation: ";" [1:16 - 1:17]
 // CHECK: Keyword: "void" [2:1 - 2:5] FunctionDecl=test:2:6 (Definition)
@@ -181,12 +183,20 @@ class C {
 // CHECK: Punctuation: "(" [29:18 - 29:19] CXXMethod=foo:29:15 (Definition)
 // CHECK: Punctuation: ")" [29:19 - 29:20] CXXMethod=foo:29:15 (Definition)
 // CHECK: Punctuation: "{" [29:21 - 29:22] CompoundStmt=
-// CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt=
-// CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3
-// CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3
-
-// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test 
-test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2
-// CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt=
+// CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt=
+// CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3
+// CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3
+// CHECK: Keyword: "auto" [40:1 - 40:5] FunctionDecl=test5:40:6
+// CHECK: Identifier: "test5" [40:6 - 40:11] FunctionDecl=test5:40:6
+// CHECK: Punctuation: "(" [40:11 - 40:12] FunctionDecl=test5:40:6
+// CHECK: Identifier: "X" [40:12 - 40:13] TypeRef=struct X:7:8
+// CHECK: Punctuation: ")" [40:13 - 40:14] FunctionDecl=test5:40:6
+// CHECK: Punctuation: "->" [40:15 - 40:17] FunctionDecl=test5:40:6
+// CHECK: Identifier: "X" [40:18 - 40:19] TypeRef=struct X:7:8
+// CHECK: Punctuation: ";" [40:19 - 40:20]
+
+// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test 
-test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2
+// CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt=
 // CHECK2: Punctuation: "(" [32:6 - 32:7] IfStmt=
 // CHECK2: Keyword: "int" [32:7 - 32:10] VarDecl=p:32:11 (Definition)
 // CHECK2: Identifier: "p" [32:11 - 32:12] VarDecl=p:32:11 (Definition)

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=321698=321697=321698=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Jan  3 02:04:37 2018
@@ -782,12 +782,22 @@ bool CursorVisitor::VisitDeclaratorDecl(
 if (VisitNestedNameSpecifierLoc(QualifierLoc))
   return true;
 
-  return false;
-}
-
-/// \brief Compare two base or member initializers based on their source order.
-static int CompareCXXCtorInitializers(CXXCtorInitializer *const *X,
-  CXXCtorInitializer *const *Y) {
+  return false;
+}
+
+static bool HasTrailingReturnType(FunctionDecl *ND) {
+  const QualType Ty = ND->getType();
+  if (const FunctionType *AFT = Ty->getAs()) {
+if (const FunctionProtoType *FT = dyn_cast(AFT))
+  return 

[PATCH] D41661: [clangd] Don't navigate to forward class declaration when go to definition.

2018-01-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

With more test, it turns out that `ASTNode.OrigD` is not always pointed to the 
definition, so we can't rely on `D` or `ASTNode.OrigD` :(.

I revised the way of checking definition, it should works for major cases. 
Please review it again.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41661



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


[PATCH] D41661: [clangd] Don't navigate to forward class declaration when go to definition.

2018-01-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 128501.
hokein marked an inline comment as done.
hokein added a comment.

- Revise the way of checking definition.
- Add a test for function declaration.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41661

Files:
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -203,6 +203,18 @@
 #define MACRO 2
 #undef macro
   )cpp",
+
+  R"cpp(// Forward class declaration
+class Foo;
+[[class Foo {}]];
+F^oo* foo();
+  )cpp",
+
+  R"cpp(// Function declaration
+void foo();
+void g() { f^oo(); }
+[[void foo() {}]]
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -14,6 +14,16 @@
 using namespace llvm;
 namespace {
 
+bool IsDefinition(const Decl* D) {
+  if (const auto *TD = dyn_cast(D))
+return TD->isThisDeclarationADefinition();
+  else if (const auto *VD = dyn_cast(D))
+return VD->isThisDeclarationADefinition();
+  else if (const auto *FD = dyn_cast(D))
+return FD->isThisDeclarationADefinition();
+  return false;
+}
+
 /// Finds declarations locations that a given source location refers to.
 class DeclarationAndMacrosFinder : public index::IndexDataConsumer {
   std::vector Decls;
@@ -50,8 +60,20 @@
   ArrayRef Relations, FileID FID,
   unsigned Offset,
   index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
-if (isSearchedLocation(FID, Offset))
-  Decls.push_back(D);
+if (isSearchedLocation(FID, Offset)) {
+  // Find and add definition declarations (for GoToDefinition).
+  // We don't use parameter `D`, as Parameter `D` is the canonical
+  // declaration, which is the first declaration of a redeclarable
+  // declaration, and it could be a forward declaration.
+  auto Def = std::find_if(D->redecls_begin(), D->redecls_end(),
+  [](const Decl *D) { return IsDefinition(D); });
+  if (Def != D->redecls_end()) {
+Decls.push_back(*Def);
+  } else {
+// Couldn't find a definition, fall back to use `D`.
+Decls.push_back(D);
+  }
+}
 return true;
   }
 


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -203,6 +203,18 @@
 #define MACRO 2
 #undef macro
   )cpp",
+
+  R"cpp(// Forward class declaration
+class Foo;
+[[class Foo {}]];
+F^oo* foo();
+  )cpp",
+
+  R"cpp(// Function declaration
+void foo();
+void g() { f^oo(); }
+[[void foo() {}]]
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -14,6 +14,16 @@
 using namespace llvm;
 namespace {
 
+bool IsDefinition(const Decl* D) {
+  if (const auto *TD = dyn_cast(D))
+return TD->isThisDeclarationADefinition();
+  else if (const auto *VD = dyn_cast(D))
+return VD->isThisDeclarationADefinition();
+  else if (const auto *FD = dyn_cast(D))
+return FD->isThisDeclarationADefinition();
+  return false;
+}
+
 /// Finds declarations locations that a given source location refers to.
 class DeclarationAndMacrosFinder : public index::IndexDataConsumer {
   std::vector Decls;
@@ -50,8 +60,20 @@
   ArrayRef Relations, FileID FID,
   unsigned Offset,
   index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
-if (isSearchedLocation(FID, Offset))
-  Decls.push_back(D);
+if (isSearchedLocation(FID, Offset)) {
+  // Find and add definition declarations (for GoToDefinition).
+  // We don't use parameter `D`, as Parameter `D` is the canonical
+  // declaration, which is the first declaration of a redeclarable
+  // declaration, and it could be a forward declaration.
+  auto Def = std::find_if(D->redecls_begin(), D->redecls_end(),
+  [](const Decl *D) { return IsDefinition(D); });
+  if (Def != D->redecls_end()) {
+Decls.push_back(*Def);
+  } else {
+// Couldn't find a definition, fall back to use `D`.
+Decls.push_back(D);
+  }
+}
 return true;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41005: Reuse preamble even if an unsaved file does not exist

2018-01-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: include/clang/Frontend/ASTUnit.h:193
   /// some number of calls.
-  unsigned PreambleRebuildCounter;
+  unsigned PreambleRebuildCountdownCounter;
+

NIT: Maybe shorten to `PreambleRebuildCountdown`?
It's not a great name, but a bit shorter than now and seems to convey the same 
meaning.



Comment at: unittests/Frontend/PCHPreambleTest.cpp:130
+  std::string MainName = "//./main.cpp";
+  AddFile(MainName, "#include \"//./header1.h\"\n"
+"int main() { return ZERO; }");

NIT: Maybe use raw string literals? Escpated string are hard to read.
E.g., 

```R"cpp(
#include "//./header1.h"
int main() { return ZERO; }
)cpp"
```



Comment at: unittests/Frontend/PCHPreambleTest.cpp:133
+
+  std::unique_ptr AST(ParseAST(MainName));
+  ASSERT_TRUE(AST.get());

Are we testing the right thing here?

We're testing that preamble does not get rebuild when some header that was 
previously unresolved when seen inside `#include` directive is now added to the 
filesystem. That is actually a bug, we should rebuild the preamble in that case.

We should probably call `RemapFile` before calling `ParseAST` instead and make 
sure it's properly resolved.
```
  AddFile(MainName, ...);
  // We don't call AddFile for the header at this point, so that it does not 
exist on the filesystem.
  RemapFile(Header1, "#define ZERO 0\n");

  std::unique_ptr AST(ParseAST(MainName));
  // Also assert that there were no compiler errors? (I.e. file was resolved 
properly)
  //  

  // Now the file is on the filesystem, call reparse and check that we reused 
the preamble.
  AddFile(Header1, "#define ZERO 0\n");
  ASSERT_TRUE(ReparseAST(AST));
  ASSERT_EQ(AST->getPreambleCounter(), 1U);
```


Repository:
  rC Clang

https://reviews.llvm.org/D41005



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


r321700 - Fix line endings.

2018-01-03 Thread Ivan Donchevskii via cfe-commits
Author: yvvan
Date: Wed Jan  3 02:33:21 2018
New Revision: 321700

URL: http://llvm.org/viewvc/llvm-project?rev=321700=rev
Log:
Fix line endings.

Modified:
cfe/trunk/test/Index/annotate-tokens.cpp
cfe/trunk/test/Index/print-type-size.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/annotate-tokens.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-tokens.cpp?rev=321700=321699=321700=diff
==
--- cfe/trunk/test/Index/annotate-tokens.cpp (original)
+++ cfe/trunk/test/Index/annotate-tokens.cpp Wed Jan  3 02:33:21 2018
@@ -34,15 +34,15 @@ void test4() {
 }
 
 class C {
-  ~C();
-};
-
-auto test5(X) -> X;
-
-// RUN: c-index-test -test-annotate-tokens=%s:1:1:41:1 %s -std=c++14 
-fno-delayed-template-parsing | FileCheck %s
-// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition)
-// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition)
-// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition)
+  ~C();
+};
+
+auto test5(X) -> X;
+
+// RUN: c-index-test -test-annotate-tokens=%s:1:1:41:1 %s -std=c++14 
-fno-delayed-template-parsing | FileCheck %s
+// CHECK: Keyword: "struct" [1:1 - 1:7] StructDecl=bonk:1:8 (Definition)
+// CHECK: Identifier: "bonk" [1:8 - 1:12] StructDecl=bonk:1:8 (Definition)
+// CHECK: Punctuation: "{" [1:13 - 1:14] StructDecl=bonk:1:8 (Definition)
 // CHECK: Punctuation: "}" [1:15 - 1:16] StructDecl=bonk:1:8 (Definition)
 // CHECK: Punctuation: ";" [1:16 - 1:17]
 // CHECK: Keyword: "void" [2:1 - 2:5] FunctionDecl=test:2:6 (Definition)
@@ -183,20 +183,20 @@ auto test5(X) -> X;
 // CHECK: Punctuation: "(" [29:18 - 29:19] CXXMethod=foo:29:15 (Definition)
 // CHECK: Punctuation: ")" [29:19 - 29:20] CXXMethod=foo:29:15 (Definition)
 // CHECK: Punctuation: "{" [29:21 - 29:22] CompoundStmt=
-// CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt=
-// CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3
-// CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3
-// CHECK: Keyword: "auto" [40:1 - 40:5] FunctionDecl=test5:40:6
-// CHECK: Identifier: "test5" [40:6 - 40:11] FunctionDecl=test5:40:6
-// CHECK: Punctuation: "(" [40:11 - 40:12] FunctionDecl=test5:40:6
-// CHECK: Identifier: "X" [40:12 - 40:13] TypeRef=struct X:7:8
-// CHECK: Punctuation: ")" [40:13 - 40:14] FunctionDecl=test5:40:6
-// CHECK: Punctuation: "->" [40:15 - 40:17] FunctionDecl=test5:40:6
-// CHECK: Identifier: "X" [40:18 - 40:19] TypeRef=struct X:7:8
-// CHECK: Punctuation: ";" [40:19 - 40:20]
-
-// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test 
-test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2
-// CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt=
+// CHECK: Punctuation: "}" [29:22 - 29:23] CompoundStmt=
+// CHECK: Punctuation: "~" [37:3 - 37:4] CXXDestructor=~C:37:3
+// CHECK: Identifier: "C" [37:4 - 37:5] CXXDestructor=~C:37:3
+// CHECK: Keyword: "auto" [40:1 - 40:5] FunctionDecl=test5:40:6
+// CHECK: Identifier: "test5" [40:6 - 40:11] FunctionDecl=test5:40:6
+// CHECK: Punctuation: "(" [40:11 - 40:12] FunctionDecl=test5:40:6
+// CHECK: Identifier: "X" [40:12 - 40:13] TypeRef=struct X:7:8
+// CHECK: Punctuation: ")" [40:13 - 40:14] FunctionDecl=test5:40:6
+// CHECK: Punctuation: "->" [40:15 - 40:17] FunctionDecl=test5:40:6
+// CHECK: Identifier: "X" [40:18 - 40:19] TypeRef=struct X:7:8
+// CHECK: Punctuation: ";" [40:19 - 40:20]
+
+// RUN: env LIBCLANG_DISABLE_CRASH_RECOVERY=1 c-index-test 
-test-annotate-tokens=%s:32:1:32:13 %s | FileCheck %s -check-prefix=CHECK2
+// CHECK2: Keyword: "if" [32:3 - 32:5] IfStmt=
 // CHECK2: Punctuation: "(" [32:6 - 32:7] IfStmt=
 // CHECK2: Keyword: "int" [32:7 - 32:10] VarDecl=p:32:11 (Definition)
 // CHECK2: Identifier: "p" [32:11 - 32:12] VarDecl=p:32:11 (Definition)

Modified: cfe/trunk/test/Index/print-type-size.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type-size.cpp?rev=321700=321699=321700=diff
==
--- cfe/trunk/test/Index/print-type-size.cpp (original)
+++ cfe/trunk/test/Index/print-type-size.cpp Wed Jan  3 02:33:21 2018
@@ -1,14 +1,14 @@
 // from SemaCXX/class-layout.cpp
 // RUN: c-index-test -test-print-type-size %s -target x86_64-pc-linux-gnu | 
FileCheck -check-prefix=CHECK64 %s
 // RUN: c-index-test -test-print-type-size %s -target i386-apple-darwin9 | 
FileCheck -check-prefix=CHECK32 %s
-
-namespace basic {
-
-// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) (invalid) [type=void] 
[typekind=Void]
-// CHECK32: VarDecl=v:[[@LINE+1]]:6 (Definition) (invalid) [type=void] 
[typekind=Void]
-void v;
-
-// CHECK64: VarDecl=v1:[[@LINE+2]]:7 (Definition) [type=void *] 
[typekind=Pointer] [sizeof=8] [alignof=8]
+
+namespace basic {
+
+// CHECK64: VarDecl=v:[[@LINE+2]]:6 (Definition) (invalid) [type=void] 
[typekind=Void]

[PATCH] D41661: [clangd] Don't navigate to forward class declaration when go to definition.

2018-01-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/XRefs.cpp:68
+  // declaration, and it could be a forward declaration.
+  auto Def = std::find_if(D->redecls_begin(), D->redecls_end(),
+  [](const Decl *D) { return IsDefinition(D); });

That seems like a useful helper on its own, maybe create a helper called `Decl* 
getDefinition(Decl* D)` and use it instead?
It's implementation can be as short as the one we currently have for 
`IsDefinition`, since all interesting `Decl` types have `getDefinition` method.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41661



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


r321701 - Fix more line endings.

2018-01-03 Thread Ivan Donchevskii via cfe-commits
Author: yvvan
Date: Wed Jan  3 02:40:11 2018
New Revision: 321701

URL: http://llvm.org/viewvc/llvm-project?rev=321701=rev
Log:
Fix more line endings.

Modified:
cfe/trunk/include/clang-c/Index.h

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=321701=321700=321701=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Jan  3 02:40:11 2018
@@ -29,13 +29,13 @@
  * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.
  *
  * The policy about the libclang API was always to keep it source and ABI
- * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
- */
-#define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 46
-
-#define CINDEX_VERSION_ENCODE(major, minor) ( \
-  ((major) * 1)   \
+ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
+ */
+#define CINDEX_VERSION_MAJOR 0
+#define CINDEX_VERSION_MINOR 46
+
+#define CINDEX_VERSION_ENCODE(major, minor) ( \
+  ((major) * 1)   \
 + ((minor) * 1))
 
 #define CINDEX_VERSION CINDEX_VERSION_ENCODE( \
@@ -2638,22 +2638,22 @@ CINDEX_LINKAGE enum CXCursorKind clang_g
 
 /**
  * \brief Determine whether the given cursor kind represents a declaration.
- */
-CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
-
-/**
- * \brief Determine whether the given declaration is invalid.
- *
- * A declaration is invalid if it could not be parsed successfully.
- *
- * \returns non-zero if the cursor represents a declaration and it is
- * invalid, otherwise NULL.
- */
-CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
-
-/**
- * \brief Determine whether the given cursor kind represents a simple
- * reference.
+ */
+CINDEX_LINKAGE unsigned clang_isDeclaration(enum CXCursorKind);
+
+/**
+ * \brief Determine whether the given declaration is invalid.
+ *
+ * A declaration is invalid if it could not be parsed successfully.
+ *
+ * \returns non-zero if the cursor represents a declaration and it is
+ * invalid, otherwise NULL.
+ */
+CINDEX_LINKAGE unsigned clang_isInvalidDeclaration(CXCursor);
+
+/**
+ * \brief Determine whether the given cursor kind represents a simple
+ * reference.
  *
  * Note that other kinds of cursors (such as expressions) can also refer to
  * other cursors. Use clang_getCursorReferenced() to determine whether a


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


[PATCH] D41668: [clangd] Add static index for the global code completion.

2018-01-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/tool/ClangdMain.cpp:122
+llvm::cl::desc(
+"YAML-format global symbol file to build the static index. It is only "
+"available when 'enable-index-based-completion' is enabled."),

Let's also add a mention here in the documentation that the option is 
experimental, will be removed in the future and users should not rely on it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41668



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


[PATCH] D41345: [clangd] Add more symbol information for code completion.

2018-01-03 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 128505.
ioeric added a comment.

- Merge with origin/master. Use Arena for symbol details.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41345

Files:
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/index/FileIndex.cpp
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  clangd/index/SymbolYAML.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -9,7 +9,6 @@
 
 #include "index/SymbolCollector.h"
 #include "index/SymbolYAML.h"
-#include "clang/Index/IndexingAction.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/FileSystemOptions.h"
 #include "clang/Basic/VirtualFileSystem.h"
@@ -26,11 +25,21 @@
 #include 
 #include 
 
+using testing::AllOf;
 using testing::Eq;
 using testing::Field;
 using testing::UnorderedElementsAre;
 
 // GMock helpers for matching Symbol.
+MATCHER_P(Labeled, Label, "") { return arg.CompletionLabel == Label; }
+MATCHER_P(Detail, D, "") { return arg.Detail.CompletionDetail == D; }
+MATCHER_P(Doc, D, "") { return arg.Detail.Documentation == D; }
+MATCHER_P(Plain, Text, "") {
+  return arg.CompletionPlainInsertText == Text;
+}
+MATCHER_P(Snippet, S, "") {
+  return arg.CompletionSnippetInsertText == S;
+}
 MATCHER_P(QName, Name, "") {
   return (arg.Scope + (arg.Scope.empty() ? "" : "::") + arg.Name).str() == Name;
 }
@@ -109,6 +118,38 @@
 QName("f1"), QName("f2")));
 }
 
+TEST_F(SymbolCollectorTest, SymbolWithDocumentation) {
+  const std::string Main = R"(
+namespace nx {
+/// Foo comment.
+int ff(int x, double y) { return 0; }
+}
+  )";
+  runSymbolCollector(/*Header=*/"", Main);
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(QName("nx"),
+   AllOf(QName("nx::ff"),
+ Labeled("ff(int x, double y)"),
+ Detail("int"), Doc("Foo comment.";
+}
+
+TEST_F(SymbolCollectorTest, PlainAndSnippet) {
+  const std::string Main = R"(
+namespace nx {
+void f() {}
+int ff(int x, double y) { return 0; }
+}
+  )";
+  runSymbolCollector(/*Header=*/"", Main);
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAre(
+  QName("nx"),
+  AllOf(QName("nx::f"), Labeled("f()"), Plain("f"), Snippet("f()")),
+  AllOf(QName("nx::ff"), Labeled("ff(int x, double y)"), Plain("ff"),
+Snippet("ff(${1:int x}, ${2:double y})";
+}
+
 TEST_F(SymbolCollectorTest, YAMLConversions) {
   const std::string YAML1 = R"(
 ---
@@ -122,6 +163,12 @@
   StartOffset: 0
   EndOffset:   1
   FilePath:/path/foo.h
+CompletionLabel:'Foo1-label'
+CompletionFilterText:'filter'
+CompletionPlainInsertText:'plain'
+Detail:
+  Documentation:'Foo doc'
+  CompletionDetail:'int'
 ...
 )";
   const std::string YAML2 = R"(
@@ -136,15 +183,21 @@
   StartOffset: 10
   EndOffset:   12
   FilePath:/path/foo.h
+CompletionLabel:'Foo2-label'
+CompletionFilterText:'filter'
+CompletionPlainInsertText:'plain'
+CompletionSnippetInsertText:'snippet'
 ...
 )";
 
   auto Symbols1 = SymbolFromYAML(YAML1);
-  EXPECT_THAT(Symbols1,
-  UnorderedElementsAre(QName("clang::Foo1")));
+  EXPECT_THAT(Symbols1, UnorderedElementsAre(
+AllOf(QName("clang::Foo1"), Labeled("Foo1-label"),
+  Doc("Foo doc"), Detail("int";
   auto Symbols2 = SymbolFromYAML(YAML2);
-  EXPECT_THAT(Symbols2,
-  UnorderedElementsAre(QName("clang::Foo2")));
+  EXPECT_THAT(Symbols2, UnorderedElementsAre(AllOf(QName("clang::Foo2"),
+   Labeled("Foo2-label"),
+   Doc(""), Detail("";
 
   std::string ConcatenatedYAML =
   SymbolToYAML(Symbols1) + SymbolToYAML(Symbols2);
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -68,6 +68,8 @@
 MATCHER_P(Labeled, Label, "") { return arg.label == Label; }
 MATCHER_P(Kind, K, "") { return arg.kind == K; }
 MATCHER_P(Filter, F, "") { return arg.filterText == F; }
+MATCHER_P(Doc, D, "") { return arg.documentation == D; }
+MATCHER_P(Detail, D, "") { return arg.detail == D; }
 MATCHER_P(PlainText, Text, "") {
   return arg.insertTextFormat == clangd::InsertTextFormat::PlainText &&
  arg.insertText == Text;
@@ -472,6 +474,7 @@
   Sym.Name = QName.substr(Pos + 2);
   Sym.Scope = QName.substr(0, 

[PATCH] D41537: Optionally add code completion results for arrow instead of dot

2018-01-03 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 128509.
yvvan added a comment.

Update CIndex minor version, add call to libclang.exports


https://reviews.llvm.org/D41537

Files:
  include/clang-c/Index.h
  include/clang/Sema/CodeCompleteConsumer.h
  include/clang/Sema/CodeCompleteOptions.h
  lib/Frontend/ASTUnit.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  lib/Sema/SemaCodeComplete.cpp
  test/Index/complete-arrow-for-dot.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndexCodeCompletion.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -173,6 +173,7 @@
 clang_getCompletionNumAnnotations
 clang_getCompletionParent
 clang_getCompletionPriority
+clang_getCompletionRequiresDotToArrowCorrection
 clang_getCursor
 clang_getCursorAvailability
 clang_getCursorCompletionString
Index: tools/libclang/CIndexCodeCompletion.cpp
===
--- tools/libclang/CIndexCodeCompletion.cpp
+++ tools/libclang/CIndexCodeCompletion.cpp
@@ -238,6 +238,16 @@
   return cxstring::createRef(CCStr->getBriefComment());
 }
 
+unsigned
+clang_getCompletionRequiresDotToArrowCorrection(CXCompletionString completion_string) {
+  CodeCompletionString *CCStr = (CodeCompletionString *)completion_string;
+
+  if (!CCStr)
+return false;
+
+  return CCStr->requiresDotToArrowCorrection();
+}
+
 namespace {
 
 /// \brief The CXCodeCompleteResults structure we allocate internally;
@@ -643,13 +653,13 @@
   ArrayRef unsaved_files,
   unsigned options) {
   bool IncludeBriefComments = options & CXCodeComplete_IncludeBriefComments;
+  bool TryArrowInsteadOfDot = options & CXCodeComplete_TryArrowInsteadOfDot;
 
 #ifdef UDP_CODE_COMPLETION_LOGGER
 #ifdef UDP_CODE_COMPLETION_LOGGER_PORT
   const llvm::TimeRecord  =  llvm::TimeRecord::getCurrentTime();
 #endif
 #endif
-
   bool EnableLogging = getenv("LIBCLANG_CODE_COMPLETION_LOGGING") != nullptr;
 
   if (cxtu::isNotUsableTU(TU)) {
@@ -689,6 +699,7 @@
   // Create a code-completion consumer to capture the results.
   CodeCompleteOptions Opts;
   Opts.IncludeBriefComments = IncludeBriefComments;
+  Opts.TryArrowInsteadOfDot = TryArrowInsteadOfDot;
   CaptureCompletionResults Capture(Opts, *Results, );
 
   // Perform completion.
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -2229,7 +2229,13 @@
 fprintf(file, "(brief comment: %s)", BriefCommentCString);
   }
   clang_disposeString(BriefComment);
-  
+
+  unsigned RequiresDotToArrowCorrection =
+  clang_getCompletionRequiresDotToArrowCorrection(
+  completion_result->CompletionString);
+  if (RequiresDotToArrowCorrection) {
+fprintf(file, " (requires correction: \".\" to \"->\")");
+  }
   fprintf(file, "\n");
 }
 
@@ -2326,6 +2332,8 @@
 completionOptions |= CXCodeComplete_IncludeCodePatterns;
   if (getenv("CINDEXTEST_COMPLETION_BRIEF_COMMENTS"))
 completionOptions |= CXCodeComplete_IncludeBriefComments;
+  if (getenv("CINDEXTEST_COMPLETION_TRY_ARROW_INSTEAD_OF_DOT"))
+completionOptions |= CXCodeComplete_TryArrowInsteadOfDot;
   
   if (timing_only)
 input += strlen("-code-completion-timing=");
Index: test/Index/complete-arrow-for-dot.cpp
===
--- /dev/null
+++ test/Index/complete-arrow-for-dot.cpp
@@ -0,0 +1,29 @@
+struct X {
+  void doSomething();
+
+  int field;
+};
+
+void X::doSomething() {
+  // RUN: c-index-test -code-completion-at=%s:10:8 %s | FileCheck %s
+  // RUN: env CINDEXTEST_COMPLETION_TRY_ARROW_INSTEAD_OF_DOT=1 c-index-test -code-completion-at=%s:10:8 %s | FileCheck -check-prefix=CHECK-WITH-CORRECTION %s
+  this.;
+}
+
+// CHECK-NOT: CXXMethod:{ResultType void}{TypedText doSomething}{LeftParen (}{RightParen )} (34) (requires correction: "." to "->")
+// CHECK-NOT: FieldDecl:{ResultType int}{TypedText field} (35) (requires correction: "." to "->")
+// CHECK-NOT: CXXMethod:{ResultType X &}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (79) (requires correction: "." to "->")
+// CHECK-NOT: CXXMethod:{ResultType X &}{TypedText operator=}{LeftParen (}{Placeholder X &&}{RightParen )} (79) (requires correction: "." to "->")
+// CHECK-NOT: StructDecl:{TypedText X}{Text ::} (75) (requires correction: "." to "->")
+// CHECK-NOT: CXXDestructor:{ResultType void}{TypedText ~X}{LeftParen (}{RightParen )} (79) (requires correction: "." to "->")
+// CHECK: Completion contexts:
+// CHECK: Dot member access
+
+// CHECK-WITH-CORRECTION: CXXMethod:{ResultType void}{TypedText doSomething}{LeftParen (}{RightParen )} (34) (requires correction: "." to "->")
+// CHECK-WITH-CORRECTION: FieldDecl:{ResultType int}{TypedText field} (35) 

[PATCH] D41698: [DebugInfo] Enable debug information for C99 VLA types

2018-01-03 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: echristo, aprantl, dexonsmith, clayborg, pcc, 
kristof.beyls.
Herald added a subscriber: JDevlieghere.

This patch enables debugging of C99 VLA types by generating more precise
LLVM Debug metadata, using the extended DISubrange 'count' field that
takes a DIVariable.

  

This should implement:

  Bug 30553: Debug info generated for arrays is not what GDB expects (not as 
good as GCC's)

https://bugs.llvm.org/show_bug.cgi?id=30553


https://reviews.llvm.org/D41698

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/debug-info-vla.c
  test/CodeGenCXX/debug-info-vla.cpp

Index: test/CodeGenCXX/debug-info-vla.cpp
===
--- test/CodeGenCXX/debug-info-vla.cpp
+++ test/CodeGenCXX/debug-info-vla.cpp
@@ -13,8 +13,10 @@
 // CHECK: [[ELEM_TYPE]] = !{[[NOCOUNT:.*]]}
 // CHECK: [[NOCOUNT]] = !DISubrange(count: -1)
 //
+// CHECK: [[VAR:![0-9]+]] = !DILocalVariable(name: "vla_expr"
 // CHECK: !DICompositeType(tag: DW_TAG_array_type,
 // CHECK-NOT:   size:
 // CHECK-SAME:  elements: [[ELEM_TYPE:![0-9]+]]
-// CHECK: [[ELEM_TYPE]] = !{[[THREE:.*]], [[NOCOUNT]]}
+// CHECK: [[ELEM_TYPE]] = !{[[THREE:.*]], [[VARRANGE:![0-9]+]]}
 // CHECK: [[THREE]] = !DISubrange(count: 3)
+// CHECK: [[VARRANGE]] = !DISubrange(count: [[VAR]])
Index: test/CodeGen/debug-info-vla.c
===
--- test/CodeGen/debug-info-vla.c
+++ test/CodeGen/debug-info-vla.c
@@ -2,9 +2,11 @@
 
 void testVLAwithSize(int s)
 {
-// CHECK: dbg.declare
-// CHECK: dbg.declare({{.*}}, metadata ![[VAR:.*]], metadata !DIExpression())
-// CHECK: ![[VAR]] = !DILocalVariable(name: "vla",{{.*}} line: [[@LINE+1]]
+// CHECK-DAG: dbg.declare({{.*}} %vla_expr, metadata ![[VLAEXPR:[0-9]+]]
+// CHECK-DAG: dbg.declare({{.*}} %vla, metadata ![[VAR:[0-9]+]]
+// CHECK-DAG: ![[VLAEXPR]] = !DILocalVariable(name: "vla_expr"
+// CHECK-DAG: ![[VAR]] = !DILocalVariable(name: "vla",{{.*}} line: [[@LINE+2]]
+// CHECK-DAG: !DISubrange(count: ![[VLAEXPR]])
   int vla[s];
   int i;
   for (i = 0; i < s; i++) {
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2193,6 +2193,12 @@
   /// This function can be called with a null (unreachable) insert point.
   void EmitVariablyModifiedType(QualType Ty);
 
+  /// getVLAElements1D returns the number of elements for a single dimension
+  /// for the given array type.
+  std::pair
+  getVLAElements1D(const VariableArrayType *vla);
+  std::pair getVLAElements1D(QualType vla);
+
   /// getVLASize - Returns an LLVM value that corresponds to the size,
   /// in non-variably-sized elements, of a variable length array type,
   /// plus that largest non-variably-sized element type.  Assumes that
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -1948,6 +1948,21 @@
   return std::pair(numElements, elementType);
 }
 
+std::pair
+CodeGenFunction::getVLAElements1D(QualType type) {
+  const VariableArrayType *vla = getContext().getAsVariableArrayType(type);
+  assert(vla && "type was not a variable array type!");
+  return getVLAElements1D(vla);
+}
+
+std::pair
+CodeGenFunction::getVLAElements1D(const VariableArrayType *Vla) {
+  llvm::Value *VlaSize = VLASizeMap[Vla->getSizeExpr()];
+  assert(VlaSize && "no size for VLA!");
+  assert(VlaSize->getType() == SizeTy);
+  return std::pair(VlaSize, Vla->getElementType());
+}
+
 void CodeGenFunction::EmitVariablyModifiedType(QualType type) {
   assert(type->isVariablyModifiedType() &&
  "Must pass variably modified type to EmitVLASizes!");
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -975,6 +975,10 @@
   if (Ty->isVariablyModifiedType())
 EmitVariablyModifiedType(Ty);
 
+  auto *DI = getDebugInfo();
+  bool EmitDebugInfo = DI && CGM.getCodeGenOpts().getDebugInfo() >=
+ codegenoptions::LimitedDebugInfo;
+
   Address address = Address::invalid();
   if (Ty->isConstantSizeType()) {
 bool NRVO = getLangOpts().ElideConstructors &&
@@ -1116,20 +1120,60 @@
 
 // Allocate memory for the array.
 address = CreateTempAlloca(llvmTy, alignment, "vla", elementCount);
+
+// If we have debug info enabled, describe the VLA dimensions properly.
+if (EmitDebugInfo) {
+  QualType Type1D = Ty;
+  while (getContext().getAsVariableArrayType(Type1D)) {
+llvm::Value *ElementCount1D;
+QualType ElementType1D;
+

[PATCH] D41345: [clangd] Add more symbol information for code completion.

2018-01-03 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/index/Index.h:122
+
+  llvm::Optional Detail;
+

sammccall wrote:
> ioeric wrote:
> > sammccall wrote:
> > > I think you probably want a raw pointer rather than optional:
> > >  - reduce the size of the struct when it's absent
> > >  - make it inheritance-friendly so we can hang index-specific info off it
> > > (raw pointer rather than unique_ptr because it's owned by a slab not by 
> > > malloc, but unique_ptr is ok for now)
> > > 
> > This is not easy for now with `unique_ptr` because of this line :( 
> > https://github.com/llvm-mirror/clang-tools-extra/blob/3565d1a1a692fc9f5c21e634b470535da2bb4d25/clangd/index/SymbolYAML.cpp#L141).
> >  
> > 
> > This shouldn't be an issue when we have the optimized symbol slab, where we 
> > store raw pointers. And we would probably want to serialize the whole slab 
> > instead of the individual symbols anyway.
> > 
> > > reduce the size of the struct when it's absent
> > `llvm::Optional` doesn't take much more space, so the size should be fine.
> > 
> > > make it inheritance-friendly so we can hang index-specific info off it
> > Could you elaborate on `index-specific info`? It's unclear to me how this 
> > would be used.
> > This is not easy for now with unique_ptr because of this line
> Oh no, somehow i missed this during review.
> We shouldn't be relying on symbols being copyable. I'll try to work out how 
> to fix this and delete the copy constructor.
> 
> > This shouldn't be an issue when we have the optimized symbol slab, where we 
> > store raw pointers.
> Sure. That's not a big monolithic/mysterous thing though, storing the details 
> in the slab can be done in this patch... If you think it'll be easier once 
> strings are arena-based, then maybe we should delay this patch until that's 
> done, rather than make that work bigger.
> 
> > And we would probably want to serialize the whole slab instead of the 
> > individual symbols anyway.
> This i'm less sure about, but I don't think it matters.
> 
> > llvm::Optional doesn't take much more space, so the size should be fine.
> Optional takes the same size as the details itself (plus one bool). This is 
> fairly small for now, but I think a major point of Details is to expand it in 
> the future?
> 
> > Could you elaborate on index-specific info? It's unclear to me how this 
> > would be used.
> Yeah, this is something we talked about in the meeting with Marc-Andre but 
> it's not really obvious - what's the point of allowing Details to be extended 
> if clangd has to consume it?
> 
> It sounded like he might have use cases for using index infrastructure 
> outside clangd. We might also have google-internal index features we want 
> (matching generated code to proto fields?). I'm not really sure how 
> compelling this argument is.
Thanks for the allocator change!

`Details` now contains just stringrefs. I wonder how much we want it to be 
inherit-friendly at this point, as the size is relatively small now. If you 
think this is a better way to go, I'll make the structure contain strings and 
store the whole structure in arena. This would require some tweaks for yamls 
tho but shouldn't be hard. 



Comment at: clangd/index/SymbolCollector.h:25
 // changed.
 class SymbolCollector : public index::IndexDataConsumer {
 public:

sammccall wrote:
> can you add a comment to the class indicating that it needs to be used for 
> one TU and then thrown away? This seems unfortunate but is probably simpler 
> than the alternative. It also seems to be a new restriction with this patch.
How about re-initializing the allocator for each new AST in `intialize`? 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41345



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


[PATCH] D41668: [clangd] Add static index for the global code completion.

2018-01-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 128513.
hokein marked 8 inline comments as done.
hokein added a comment.

Address review comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41668

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/index/MemIndex.cpp
  clangd/index/MemIndex.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/CodeCompleteTests.cpp

Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -453,12 +453,6 @@
 
 std::unique_ptr simpleIndexFromSymbols(
 std::vector> Symbols) {
-  auto I = llvm::make_unique();
-  struct Snapshot {
-SymbolSlab Slab;
-std::vector Pointers;
-  };
-  auto Snap = std::make_shared();
   SymbolSlab::Builder Slab;
   for (const auto  : Symbols) {
 Symbol Sym;
@@ -475,13 +469,7 @@
 Sym.SymInfo.Kind = Pair.second;
 Slab.insert(Sym);
   }
-  Snap->Slab = std::move(Slab).build();
-  for (auto  : Snap->Slab)
-Snap->Pointers.push_back();
-  auto S = std::shared_ptr(std::move(Snap),
->Pointers);
-  I->build(std::move(S));
-  return std::move(I);
+  return MemIndex::build(std::move(Slab).build());
 }
 
 TEST(CompletionTest, NoIndex) {
@@ -496,6 +484,35 @@
   EXPECT_THAT(Results.items, Has("No"));
 }
 
+TEST(CompletionTest, StaticIndex) {
+  clangd::CodeCompleteOptions Opts;
+  auto I = simpleIndexFromSymbols({{"ns::XYZ", index::SymbolKind::Class}});
+  Opts.StaticIndex = I.get();
+
+  auto Results = completions(R"cpp(
+  void f() { ::ns::^ }
+  )cpp",
+ Opts);
+  EXPECT_THAT(Results.items, Has("XYZ", CompletionItemKind::Class));
+}
+
+TEST(CompletionTest, StaticAndDynamicIndex) {
+  clangd::CodeCompleteOptions Opts;
+  auto StaticIdx =
+  simpleIndexFromSymbols({{"ns::XYZ", index::SymbolKind::Class}});
+  Opts.StaticIndex = StaticIdx.get();
+  auto DynamicIdx =
+  simpleIndexFromSymbols({{"ns::foo", index::SymbolKind::Function}});
+  Opts.Index = DynamicIdx.get();
+
+  auto Results = completions(R"cpp(
+  void f() { ::ns::^ }
+  )cpp",
+ Opts);
+  EXPECT_THAT(Results.items, Has("XYZ", CompletionItemKind::Class));
+  EXPECT_THAT(Results.items, Has("foo", CompletionItemKind::Function));
+}
+
 TEST(CompletionTest, SimpleIndexBased) {
   clangd::CodeCompleteOptions Opts;
   auto I = simpleIndexFromSymbols({{"ns::XYZ", index::SymbolKind::Class},
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -11,6 +11,7 @@
 #include "JSONRPCDispatcher.h"
 #include "Path.h"
 #include "Trace.h"
+#include "index/SymbolYAML.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -26,7 +27,24 @@
 
 namespace {
 enum class PCHStorageFlag { Disk, Memory };
+
+// Build an in-memory static index for global symbols from a YAML-format file.
+// The size of global symbols should be relatively small, so that all symbols
+// can be managed in memory.
+std::unique_ptr BuildStaticIndex(llvm::StringRef YamlSymbolFile) {
+  auto Buffer = llvm::MemoryBuffer::getFile(YamlSymbolFile);
+  if (!Buffer) {
+llvm::errs() << "Can't open " << YamlSymbolFile << "\n";
+return nullptr;
+  }
+  auto Slab = SymbolFromYAML(Buffer.get()->getBuffer());
+  SymbolSlab::Builder SymsBuilder;
+  for (auto Sym : Slab)
+SymsBuilder.insert(Sym);
+
+  return MemIndex::build(std::move(SymsBuilder).build());
 }
+} // namespace
 
 static llvm::cl::opt CompileCommandsDir(
 "compile-commands-dir",
@@ -97,6 +115,15 @@
 "use index built from symbols in opened files"),
 llvm::cl::init(false), llvm::cl::Hidden);
 
+static llvm::cl::opt YamlSymbolFile(
+"yaml-symbol-file",
+llvm::cl::desc(
+"YAML-format global symbol file to build the static index. It is only "
+"available when 'enable-index-based-completion' is enabled.\n"
+"WARNING: This option is experimental only, and will be removed "
+"eventually. Don't rely on it."),
+llvm::cl::init(""), llvm::cl::Hidden);
+
 int main(int argc, char *argv[]) {
   llvm::cl::ParseCommandLineOptions(argc, argv, "clangd");
 
@@ -182,13 +209,16 @@
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
 
+  std::unique_ptr StaticIdx;
+  if (EnableIndexBasedCompletion && !YamlSymbolFile.empty())
+StaticIdx = BuildStaticIndex(YamlSymbolFile);
   clangd::CodeCompleteOptions CCOpts;
   CCOpts.EnableSnippets = EnableSnippets;
   CCOpts.IncludeIneligibleResults = IncludeIneligibleResults;
   // Initialize and run ClangdLSPServer.
   

[PATCH] D41668: [clangd] Add static index for the global code completion.

2018-01-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the comments.




Comment at: clangd/ClangdLSPServer.h:40
+  bool BuildDynamicSymbolIndex,
+  std::unique_ptr GlobalIdx);
 

ioeric wrote:
> We are calling this global index and static index in the patch. I think we 
> should be consistent with the naming. Generally, I think this is static 
> index, which might be global index or, say, a set of symbols for test 
> purpose, so I am inclined to static index.
+1 static index -- I forgot to rename the global index.



Comment at: clangd/CodeComplete.cpp:583
 
-  Items->isIncomplete = !Index.fuzzyFind(Ctx, Req, [&](const Symbol ) {
-Items->items.push_back(indexCompletionItem(Sym, Filter, SSInfo));
-  });
+  // FIXME: figure out a way to merge the symbols from dynamic index and static
+  // index.

ioeric wrote:
> I would suggest also addressing this `FIXME` in this patch, or at least make 
> it possible to tell from which index source a candidate comes on the client 
> side. Simple concatenation from both indexes would make the results hard to 
> interpret, especially when we don't have a good merging algorithm at this 
> point.
The FIXME is mainly about the merging algorithm.

I still prefer to a follow-up on telling the client from which index source a 
completion item comes. I can foresee we might need to add an new field (like 
`Source`) in the `CompleitionItem`. Let's keep this patch simple at the moment.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41668



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


[PATCH] D38124: Hide some symbols to avoid a crash on shutdown when using code coverage

2018-01-03 Thread Marco Romano via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT321703: Hide some symbols to avoid a crash on shutdown 
when using code coverage (authored by marco, committed by ).
Herald added subscribers: Sanitizers, llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D38124?vs=122077=128514#toc

Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D38124

Files:
  lib/profile/GCDAProfiling.c
  test/profile/Inputs/instrprof-dlopen-dlclose-main.c
  test/profile/instrprof-dlopen-dlclose-gcov.test

Index: lib/profile/GCDAProfiling.c
===
--- lib/profile/GCDAProfiling.c
+++ lib/profile/GCDAProfiling.c
@@ -228,6 +228,7 @@
  * profiling enabled will emit to a different file. Only one file may be
  * started at a time.
  */
+COMPILER_RT_VISIBILITY
 void llvm_gcda_start_file(const char *orig_filename, const char version[4],
   uint32_t checksum) {
   const char *mode = "r+b";
@@ -295,6 +296,7 @@
 /* Given an array of pointers to counters (counters), increment the n-th one,
  * where we're also given a pointer to n (predecessor).
  */
+COMPILER_RT_VISIBILITY
 void llvm_gcda_increment_indirect_counter(uint32_t *predecessor,
   uint64_t **counters) {
   uint64_t *counter;
@@ -317,6 +319,7 @@
 #endif
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcda_emit_function(uint32_t ident, const char *function_name,
  uint32_t func_checksum, uint8_t use_extra_checksum,
  uint32_t cfg_checksum) {
@@ -343,6 +346,7 @@
 write_string(function_name);
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) {
   uint32_t i;
   uint64_t *old_ctrs = NULL;
@@ -394,6 +398,7 @@
 #endif
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcda_summary_info() {
   const uint32_t obj_summary_len = 9; /* Length for gcov compatibility. */
   uint32_t i;
@@ -447,6 +452,7 @@
 #endif
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcda_end_file() {
   /* Write out EOF record. */
   if (output_file) {
@@ -472,6 +478,7 @@
 #endif
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_register_writeout_function(writeout_fn fn) {
   struct writeout_fn_node *new_node = malloc(sizeof(struct writeout_fn_node));
   new_node->fn = fn;
@@ -485,6 +492,7 @@
   }
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_writeout_files(void) {
   struct writeout_fn_node *curr = writeout_fn_head;
 
@@ -494,6 +502,7 @@
   }
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_delete_writeout_function_list(void) {
   while (writeout_fn_head) {
 struct writeout_fn_node *node = writeout_fn_head;
@@ -504,6 +513,7 @@
   writeout_fn_head = writeout_fn_tail = NULL;
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_register_flush_function(flush_fn fn) {
   struct flush_fn_node *new_node = malloc(sizeof(struct flush_fn_node));
   new_node->fn = fn;
@@ -517,6 +527,7 @@
   }
 }
 
+COMPILER_RT_VISIBILITY
 void __gcov_flush() {
   struct flush_fn_node *curr = flush_fn_head;
 
@@ -526,6 +537,7 @@
   }
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_delete_flush_function_list(void) {
   while (flush_fn_head) {
 struct flush_fn_node *node = flush_fn_head;
@@ -536,6 +548,7 @@
   flush_fn_head = flush_fn_tail = NULL;
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcov_init(writeout_fn wfn, flush_fn ffn) {
   static int atexit_ran = 0;
 
Index: test/profile/Inputs/instrprof-dlopen-dlclose-main.c
===
--- test/profile/Inputs/instrprof-dlopen-dlclose-main.c
+++ test/profile/Inputs/instrprof-dlopen-dlclose-main.c
@@ -0,0 +1,26 @@
+#include 
+#include 
+#include 
+
+int main(int argc, char *argv[]) {
+  dlerror();
+  void *f1_handle = dlopen("func.shared", RTLD_LAZY | RTLD_GLOBAL);
+  if (f1_handle == NULL) {
+fprintf(stderr, "unable to open 'func.shared': %s\n", dlerror());
+return EXIT_FAILURE;
+  }
+
+  void *f2_handle = dlopen("func2.shared", RTLD_LAZY | RTLD_GLOBAL);
+  if (f2_handle == NULL) {
+fprintf(stderr, "unable to open 'func2.shared': %s\n", dlerror());
+return EXIT_FAILURE;
+  }
+
+  if (dlclose(f2_handle) != 0) {
+fprintf(stderr, "unable to close 'func2.shared': %s\n", dlerror());
+return EXIT_FAILURE;
+  }
+
+  return EXIT_SUCCESS;
+}
+
Index: test/profile/instrprof-dlopen-dlclose-gcov.test
===
--- test/profile/instrprof-dlopen-dlclose-gcov.test
+++ test/profile/instrprof-dlopen-dlclose-gcov.test
@@ -0,0 +1,6 @@
+RUN: mkdir -p %t.d
+RUN: %clang --coverage -o %t.d/func.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func.c
+RUN: %clang --coverage -o %t.d/func2.shared -fPIC -shared %S/Inputs/instrprof-dlopen-func2.c
+RUN: %clang --coverage -o %t -fPIC -rpath %t.d %S/Inputs/instrprof-dlopen-dlclose-main.c
+
+RUN: %run %t

[PATCH] D38124: Hide some symbols to avoid a crash on shutdown when using code coverage

2018-01-03 Thread Marco Castelluccio via Phabricator via cfe-commits
marco-c added a comment.

The change was already positively reviewed with the request for a test, which 
has been written since then.


Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D38124



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


[PATCH] D41668: [clangd] Add static index for the global code completion.

2018-01-03 Thread Eric Liu via Phabricator via cfe-commits
ioeric added inline comments.



Comment at: clangd/CodeComplete.cpp:583
 
-  Items->isIncomplete = !Index.fuzzyFind(Ctx, Req, [&](const Symbol ) {
-Items->items.push_back(indexCompletionItem(Sym, Filter, SSInfo));
-  });
+  // FIXME: figure out a way to merge the symbols from dynamic index and static
+  // index.

hokein wrote:
> ioeric wrote:
> > I would suggest also addressing this `FIXME` in this patch, or at least 
> > make it possible to tell from which index source a candidate comes on the 
> > client side. Simple concatenation from both indexes would make the results 
> > hard to interpret, especially when we don't have a good merging algorithm 
> > at this point.
> The FIXME is mainly about the merging algorithm.
> 
> I still prefer to a follow-up on telling the client from which index source a 
> completion item comes. I can foresee we might need to add an new field (like 
> `Source`) in the `CompleitionItem`. Let's keep this patch simple at the 
> moment.
I don't think we need additional field for this. We could manipulate the label 
or detail of the completion item (e.g. adding a tag), which shouldn't be too 
much extra work for this patch. IMO, concatenated results might easily be more 
confusing than useful for our testing purpose at this point, given no merging 
algorithm.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41668



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


r321775 - PR35815: Separate out the ns-consumed diagnostic into an error and

2018-01-03 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jan  3 15:52:42 2018
New Revision: 321775

URL: http://llvm.org/viewvc/llvm-project?rev=321775=rev
Log:
PR35815: Separate out the ns-consumed diagnostic into an error and
a warning

This commit separates out the warn_nsconsumed_attribute_mismatch and
warn_nsreturns_retained_attribute_mismatch diagnostic into a warning and error.
This is needed to avoid a module import regression introduced by r313717 that
turned these errors into warnings and started promoting them only when needed,
which caused an error when importing a module as it had different warning
settings.

rdar://36265651

Added:
cfe/trunk/test/SemaObjC/Inputs/module.map
cfe/trunk/test/SemaObjC/ns-consumed-error-not-warning.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=321775=321774=321775=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Wed Jan  3 15:52:42 
2018
@@ -8300,12 +8300,16 @@ def err_c99_array_usage_cxx : Error<
   "feature, not permitted in C++">;
 def err_type_unsupported : Error<
   "%0 is not supported on this target">;
-def warn_nsconsumed_attribute_mismatch : Warning<
+def err_nsconsumed_attribute_mismatch : Error<
   "overriding method has mismatched ns_consumed attribute on its"
-  " parameter">, InGroup;
-def warn_nsreturns_retained_attribute_mismatch : Warning<
+  " parameter">;
+def err_nsreturns_retained_attribute_mismatch : Error<
   "overriding method has mismatched ns_returns_%select{not_retained|retained}0"
-  " attributes">, InGroup;
+  " attributes">;
+def warn_nsconsumed_attribute_mismatch : Warning<
+  err_nsconsumed_attribute_mismatch.Text>, InGroup;
+def warn_nsreturns_retained_attribute_mismatch : Warning<
+  err_nsreturns_retained_attribute_mismatch.Text>, InGroup;
   
 def note_getter_unavailable : Note<
   "or because setter is declared here, but no getter method %0 is found">;

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=321775=321774=321775=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Jan  3 15:52:42 2018
@@ -156,23 +156,23 @@ void Sema::CheckObjCMethodOverride(ObjCM
   Diag(Overridden->getLocation(), 
diag::note_related_result_type_overridden);
   }
-  if (getLangOpts().ObjCAutoRefCount) {
-Diags.setSeverity(diag::warn_nsreturns_retained_attribute_mismatch,
-  diag::Severity::Error, SourceLocation());
-Diags.setSeverity(diag::warn_nsconsumed_attribute_mismatch,
-  diag::Severity::Error, SourceLocation());
-  }
 
   if ((NewMethod->hasAttr() !=
Overridden->hasAttr())) {
 Diag(NewMethod->getLocation(),
- diag::warn_nsreturns_retained_attribute_mismatch) << 1;
+ getLangOpts().ObjCAutoRefCount
+ ? diag::err_nsreturns_retained_attribute_mismatch
+ : diag::warn_nsreturns_retained_attribute_mismatch)
+<< 1;
 Diag(Overridden->getLocation(), diag::note_previous_decl) << "method";
   }
   if ((NewMethod->hasAttr() !=
Overridden->hasAttr())) {
 Diag(NewMethod->getLocation(),
- diag::warn_nsreturns_retained_attribute_mismatch) << 0;
+ getLangOpts().ObjCAutoRefCount
+ ? diag::err_nsreturns_retained_attribute_mismatch
+ : diag::warn_nsreturns_retained_attribute_mismatch)
+<< 0;
 Diag(Overridden->getLocation(), diag::note_previous_decl)  << "method";
   }
 
@@ -185,7 +185,10 @@ void Sema::CheckObjCMethodOverride(ObjCM
 ParmVarDecl *newDecl = (*ni);
 if (newDecl->hasAttr() !=
 oldDecl->hasAttr()) {
-  Diag(newDecl->getLocation(), diag::warn_nsconsumed_attribute_mismatch);
+  Diag(newDecl->getLocation(),
+   getLangOpts().ObjCAutoRefCount
+   ? diag::err_nsconsumed_attribute_mismatch
+   : diag::warn_nsconsumed_attribute_mismatch);
   Diag(oldDecl->getLocation(), diag::note_previous_decl) << "parameter";
 }
 

Added: cfe/trunk/test/SemaObjC/Inputs/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/Inputs/module.map?rev=321775=auto
==
--- cfe/trunk/test/SemaObjC/Inputs/module.map (added)
+++ cfe/trunk/test/SemaObjC/Inputs/module.map Wed Jan  3 15:52:42 2018
@@ -0,0 +1,3 @@
+module empty {
+  header "empty.h"
+}

Added: cfe/trunk/test/SemaObjC/ns-consumed-error-not-warning.m
URL: 

Re: trivial_abi

2018-01-03 Thread Richard Smith via cfe-commits
On 3 January 2018 at 15:24, John McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Jan 3, 2018, at 5:53 PM, Richard Smith  wrote:
> On 3 January 2018 at 14:29, John McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> On Jan 3, 2018, at 5:12 PM, Richard Smith  wrote:
>>
>> On 2 January 2018 at 20:55, John McCall via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> On Jan 2, 2018, at 10:43 PM, Richard Smith 
>>> wrote:
>>>
>>> On 2 January 2018 at 19:02, John McCall via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>

 On Jan 2, 2018, at 9:15 PM, Akira Hatanaka  wrote:



 On Jan 2, 2018, at 4:56 PM, Richard Smith via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

 On 2 January 2018 at 15:33, John McCall via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Hey, Richard et al.  Akira and I were talking about the right ABI rule
> for deciding can-pass-in-registers-ness for structs in the presence of
> trivial_abi, and I think I like Akira's approach but wanted to get your
> input.
>
> The current definition in Itanium is:
>
>   *non-trivial for the purposes of calls*
>
> A type is considered non-trivial for the purposes of calls if:
>
>- it has a non-trivial copy constructor, move constructor, or
>destructor, or
>
> I'm assuming we're implicitly excluding deleted functions here. (I'd
 prefer to make that explicit; this has been the source of a number of ABI
 mismatches.)

>
>- all of its copy and move constructors are deleted.
>
>
> I'd suggest modifying this to:
>
> A type is considered non-trivial for the purposes of calls if:
> - if has a copy constructor, move constructor, or destructor which is
> non-trivial for the purposes of calls, or
> - all of its copy and move constructors are deleted and it does not
> have the trivial_abi attribute.
>
> A copy/move constructor is considered trivial for the purposes of
> calls if:
> - it is user-provided and
> - the class has the trivial_abi attribute and
> - a defaulted definition of the constructor would be trivial for the
> purposes of calls; or
>

 We'd need to say what happens if the function in question cannot
 validly be defaulted for any of the reasons in [dcl.fct.def.default]. Do we
 try to infer whether it's a copy or move constructor, and use the rules for
 a defaulted copy or move constructor? Or do we just say that's never
 trivial for the purposes of calls? Or something else? Eg:

 struct [[clang::trivial_abi]] A {
   A(A && = make());
 };

 Here, A::A(A&&) cannot validly be defaulted. Is A trivial for the
 purpose of calls? Likewise:

 struct [[clang::trivial_abi]] B {
   B(...);
 };
 struct C {
   volatile B b;
 };

 Here, C's copy constructor calls B::B(...). Is C trivial for the
 purpose of calls? (OK, Clang crashes on that example today. But still...)

 I'd be uncomfortable making the rules in [dcl.fct.def.default] part of
 the ABI; they seem to be changing relatively frequently. Perhaps we could
 say "if the function is a copy constructor ([class.copy.ctor]/1), then
 consider what an implicitly-declared defaulted copy constructor would do;
 if it's a move constructor ([class.copy.ctor]/2), then consider what an
 implicitly-declared defaulted move constructor would do; otherwise, it's
 not trivial for the purpose of calls". That'd mean A is trivial for the
 purpose of calls and C is not, which I think is probably the right answer.

 - it is not user-provided and
> - the class has no virtual functions and no virtual base classes, and
> - the constructor used to copy/move each direct base class subobject
> is trivial for the purposes of calls, and
> - for each non-static data member that is of class type (or array
> thereof), the constructor selected to copy/move that member is trivial for
> the purposes of calls.
>
> A destructor is considered trivial for the purposes of calls if:
> - it is not user-provided or the class has the trivial_abi attribute,
> and
> - the destructor is not virtual, and
> - all of the direct base classes of its class have destructors that
> are trivial for the purposes of calls, and
> - for all of the non-static data members of its class that are of
> class type (or array thereof), each such class is trivial for the purposes
> of calls.
>
> These definitions are intended to follow [class.copy.ctor]p11 and
> [class.dtor]p6 except for the special rules applicable to trivial_abi
> classes.
>

 If I could rephrase: a *tor is considered trivial for for 

r321776 - Fix test to use -S instead of -c so it doesn't unnecessarily run the assembler.

2018-01-03 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Wed Jan  3 16:16:57 2018
New Revision: 321776

URL: http://llvm.org/viewvc/llvm-project?rev=321776=rev
Log:
Fix test to use -S instead of -c so it doesn't unnecessarily run the assembler.

Reviewed by Paul Robinson


Modified:
cfe/trunk/test/Driver/config-file.c

Modified: cfe/trunk/test/Driver/config-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/config-file.c?rev=321776=321775=321776=diff
==
--- cfe/trunk/test/Driver/config-file.c (original)
+++ cfe/trunk/test/Driver/config-file.c Wed Jan  3 16:16:57 2018
@@ -7,7 +7,7 @@
 
 //--- Config file (full path) in output of -###
 //
-// RUN: %clang --config %S/Inputs/config-1.cfg -c %s -### 2>&1 | FileCheck %s 
-check-prefix CHECK-HHH
+// RUN: %clang --config %S/Inputs/config-1.cfg -S %s -### 2>&1 | FileCheck %s 
-check-prefix CHECK-HHH
 // CHECK-HHH: Configuration file: {{.*}}Inputs{{.}}config-1.cfg
 // CHECK-HHH: -Werror
 // CHECK-HHH: -std=c99
@@ -15,7 +15,7 @@
 
 //--- Config file (full path) in output of -v
 //
-// RUN: %clang --config %S/Inputs/config-1.cfg -c %s -o /dev/null -v 2>&1 | 
FileCheck %s -check-prefix CHECK-V
+// RUN: %clang --config %S/Inputs/config-1.cfg -S %s -o /dev/null -v 2>&1 | 
FileCheck %s -check-prefix CHECK-V
 // CHECK-V: Configuration file: {{.*}}Inputs{{.}}config-1.cfg
 // CHECK-V: -Werror
 // CHECK-V: -std=c99
@@ -23,7 +23,7 @@
 
 //--- Config file in output of -###
 //
-// RUN: %clang --config-system-dir=%S/Inputs --config-user-dir= --config 
config-1.cfg -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-HHH2
+// RUN: %clang --config-system-dir=%S/Inputs --config-user-dir= --config 
config-1.cfg -S %s -### 2>&1 | FileCheck %s -check-prefix CHECK-HHH2
 // CHECK-HHH2: Configuration file: {{.*}}Inputs{{.}}config-1.cfg
 // CHECK-HHH2: -Werror
 // CHECK-HHH2: -std=c99
@@ -31,7 +31,7 @@
 
 //--- Config file in output of -v
 //
-// RUN: %clang --config-system-dir=%S/Inputs --config-user-dir= --config 
config-1.cfg -c %s -o /dev/null -v 2>&1 | FileCheck %s -check-prefix CHECK-V2
+// RUN: %clang --config-system-dir=%S/Inputs --config-user-dir= --config 
config-1.cfg -S %s -o /dev/null -v 2>&1 | FileCheck %s -check-prefix CHECK-V2
 // CHECK-V2: Configuration file: {{.*}}Inputs{{.}}config-1.cfg
 // CHECK-V2: -Werror
 // CHECK-V2: -std=c99
@@ -39,21 +39,21 @@
 
 //--- Nested config files
 //
-// RUN: %clang --config-system-dir=%S/Inputs --config-user-dir= --config 
config-2.cfg -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-NESTED
+// RUN: %clang --config-system-dir=%S/Inputs --config-user-dir= --config 
config-2.cfg -S %s -### 2>&1 | FileCheck %s -check-prefix CHECK-NESTED
 // CHECK-NESTED: Configuration file: {{.*}}Inputs{{.}}config-2.cfg
 // CHECK-NESTED: -Wundefined-func-template
 
-// RUN: %clang --config-system-dir=%S/Inputs --config-user-dir= --config 
config-2.cfg -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-NESTED2
+// RUN: %clang --config-system-dir=%S/Inputs --config-user-dir= --config 
config-2.cfg -S %s -### 2>&1 | FileCheck %s -check-prefix CHECK-NESTED2
 // CHECK-NESTED2: Configuration file: {{.*}}Inputs{{.}}config-2.cfg
 // CHECK-NESTED2: -Wundefined-func-template
 
 
-// RUN: %clang --config %S/Inputs/config-2a.cfg -c %s -### 2>&1 | FileCheck %s 
-check-prefix CHECK-NESTEDa
+// RUN: %clang --config %S/Inputs/config-2a.cfg -S %s -### 2>&1 | FileCheck %s 
-check-prefix CHECK-NESTEDa
 // CHECK-NESTEDa: Configuration file: {{.*}}Inputs{{.}}config-2a.cfg
 // CHECK-NESTEDa: -isysroot
 // CHECK-NESTEDa-SAME: /opt/data
 
-// RUN: %clang --config-system-dir=%S/Inputs --config-user-dir= --config 
config-2a.cfg -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-NESTED2a
+// RUN: %clang --config-system-dir=%S/Inputs --config-user-dir= --config 
config-2a.cfg -S %s -### 2>&1 | FileCheck %s -check-prefix CHECK-NESTED2a
 // CHECK-NESTED2a: Configuration file: {{.*}}Inputs{{.}}config-2a.cfg
 // CHECK-NESTED2a: -isysroot
 // CHECK-NESTED2a-SAME: /opt/data
@@ -61,12 +61,12 @@
 
 //--- Unused options in config file do not produce warnings
 //
-// RUN: %clang --config %S/Inputs/config-4.cfg -c %s -o /dev/null -v 2>&1 | 
FileCheck %s -check-prefix CHECK-UNUSED
+// RUN: %clang --config %S/Inputs/config-4.cfg -S %s -o /dev/null -v 2>&1 | 
FileCheck %s -check-prefix CHECK-UNUSED
 // CHECK-UNUSED-NOT: argument unused during compilation:
 
 
 //--- User directory is searched first.
 //
-// RUN: %clang --config-system-dir=%S/Inputs/config 
--config-user-dir=%S/Inputs/config2 --config config-4 -c %s -o /dev/null -v 
2>&1 | FileCheck %s -check-prefix CHECK-PRECEDENCE
+// RUN: %clang --config-system-dir=%S/Inputs/config 
--config-user-dir=%S/Inputs/config2 --config config-4 -S %s -o /dev/null -v 
2>&1 | FileCheck %s -check-prefix CHECK-PRECEDENCE
 // CHECK-PRECEDENCE: Configuration file: 
{{.*}}Inputs{{.}}config2{{.}}config-4.cfg
 // CHECK-PRECEDENCE: -Wall


___
cfe-commits 

r321777 - PR35028: Retain duplicate alignas attributes in template instantiation.

2018-01-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jan  3 17:02:18 2018
New Revision: 321777

URL: http://llvm.org/viewvc/llvm-project?rev=321777=rev
Log:
PR35028: Retain duplicate alignas attributes in template instantiation.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/SemaTemplate/alignas.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=321777=321776=321777=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Jan  3 17:02:18 2018
@@ -552,6 +552,7 @@ def Aligned : InheritableAttr {
   Keyword<"_Alignas">]>,
Accessor<"isDeclspec",[Declspec<"align">]>];
   let Documentation = [Undocumented];
+  let DuplicatesAllowedWhileMerging = 1;
 }
 
 def AlignValue : Attr {

Modified: cfe/trunk/test/SemaTemplate/alignas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/alignas.cpp?rev=321777=321776=321777=diff
==
--- cfe/trunk/test/SemaTemplate/alignas.cpp (original)
+++ cfe/trunk/test/SemaTemplate/alignas.cpp Wed Jan  3 17:02:18 2018
@@ -21,3 +21,14 @@ struct C { char a[16]; };
 
 static_assert(sizeof(my_union) == 16, "");
 static_assert(alignof(my_union) == 8, "");
+
+namespace PR35028 {
+  template struct alignas(X) alignas(long long) 
alignas(long double) alignas(Alignment) Aligned {
+union {
+  long long align1;
+  long double align2;
+  char data[sizeof(X)];
+};
+  };
+  Aligned a;
+}


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


[PATCH] D41720: [clang-tidy] Add a -show-color flag.

2018-01-03 Thread Ian Tessier via Phabricator via cfe-commits
itessier created this revision.
itessier added a project: clang-tools-extra.
Herald added a subscriber: xazax.hun.

This change will allow enabling of colour diagnostics when not directly running 
within a terminal, but colour output is possible. For example, if stdout is 
being captured and redirected to a real terminal.


https://reviews.llvm.org/D41720

Files:
  clang-tidy/ClangTidy.cpp
  clang-tidy/ClangTidyOptions.cpp
  clang-tidy/ClangTidyOptions.h
  clang-tidy/tool/ClangTidyMain.cpp


Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -146,6 +146,12 @@
cl::init("none"),
cl::cat(ClangTidyCategory));
 
+static cl::opt ShowColor("show-color", cl::desc(R"(
+Show color diagnostics. If not specified,
+defaults to on when a color-capable terminal
+is detected.)"),
+   cl::ValueOptional, cl::cat(ClangTidyCategory));
+
 static cl::opt ListChecks("list-checks", cl::desc(R"(
 List all enabled checks and exit. Use with
 -checks=* to list all available checks.
@@ -304,6 +310,7 @@
   DefaultOptions.SystemHeaders = SystemHeaders;
   DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
   DefaultOptions.FormatStyle = FormatStyle;
+  DefaultOptions.ShowColor = ShowColor;
   DefaultOptions.User = llvm::sys::Process::GetEnv("USER");
   // USERNAME is used on Windows.
   if (!DefaultOptions.User)
@@ -322,6 +329,8 @@
 OverrideOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
   if (FormatStyle.getNumOccurrences() > 0)
 OverrideOptions.FormatStyle = FormatStyle;
+  if (ShowColor.getNumOccurrences() > 0)
+OverrideOptions.ShowColor = ShowColor;
 
   if (!Config.empty()) {
 if (llvm::ErrorOr ParsedConfig =
Index: clang-tidy/ClangTidyOptions.h
===
--- clang-tidy/ClangTidyOptions.h
+++ clang-tidy/ClangTidyOptions.h
@@ -89,6 +89,9 @@
   /// See clang-format documentation for more about configuring format style.
   llvm::Optional FormatStyle;
 
+  /// \brief Show color diagnostics.
+  llvm::Optional ShowColor;
+
   /// \brief Specifies the name or e-mail of the user running clang-tidy.
   ///
   /// This option is used, for example, to place the correct user name in 
TODO()
Index: clang-tidy/ClangTidyOptions.cpp
===
--- clang-tidy/ClangTidyOptions.cpp
+++ clang-tidy/ClangTidyOptions.cpp
@@ -88,6 +88,7 @@
 IO.mapOptional("HeaderFilterRegex", Options.HeaderFilterRegex);
 IO.mapOptional("AnalyzeTemporaryDtors", Options.AnalyzeTemporaryDtors);
 IO.mapOptional("FormatStyle", Options.FormatStyle);
+IO.mapOptional("ShowColor", Options.ShowColor);
 IO.mapOptional("User", Options.User);
 IO.mapOptional("CheckOptions", NOpts->Options);
 IO.mapOptional("ExtraArgs", Options.ExtraArgs);
@@ -149,6 +150,7 @@
   overrideValue(Result.SystemHeaders, Other.SystemHeaders);
   overrideValue(Result.AnalyzeTemporaryDtors, Other.AnalyzeTemporaryDtors);
   overrideValue(Result.FormatStyle, Other.FormatStyle);
+  overrideValue(Result.ShowColor, Other.ShowColor);
   overrideValue(Result.User, Other.User);
   mergeVectors(Result.ExtraArgs, Other.ExtraArgs);
   mergeVectors(Result.ExtraArgsBefore, Other.ExtraArgsBefore);
Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -96,7 +96,11 @@
   DiagPrinter),
 SourceMgr(Diags, Files), Context(Context), ApplyFixes(ApplyFixes),
 TotalFixes(0), AppliedFixes(0), WarningsAsErrors(0) {
-DiagOpts->ShowColors = llvm::sys::Process::StandardOutHasColors();
+if (Context.getOptions().ShowColor.hasValue()) {
+  DiagOpts->ShowColors = Context.getOptions().ShowColor.getValue();
+} else {
+  DiagOpts->ShowColors = llvm::sys::Process::StandardOutHasColors();
+}
 DiagPrinter->BeginSourceFile(LangOpts);
   }
 


Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -146,6 +146,12 @@
cl::init("none"),
cl::cat(ClangTidyCategory));
 
+static cl::opt ShowColor("show-color", cl::desc(R"(
+Show color diagnostics. If not specified,
+defaults to on when a color-capable terminal
+is detected.)"),
+   cl::ValueOptional, cl::cat(ClangTidyCategory));
+
 static cl::opt ListChecks("list-checks", cl::desc(R"(
 List all enabled checks and exit. Use with
 -checks=* to list all available checks.
@@ -304,6 +310,7 @@
   DefaultOptions.SystemHeaders = SystemHeaders;
   DefaultOptions.AnalyzeTemporaryDtors = AnalyzeTemporaryDtors;
   

Re: r321395 - [ODRHash] Support ODR violation detection in functions.

2018-01-03 Thread Richard Trieu via cfe-commits
Vedant,

I'm looking into it.

On Wed, Jan 3, 2018 at 11:12 AM, Vedant Kumar  wrote:

> Oops, the build log was too big to attach. Resending with just the bot
> link, then:
> http://lab.llvm.org:8080/green/view/Experimental/job/
> clang-stage2-coverage-R/2193/consoleText
>
> vedant
>
> On Jan 3, 2018, at 11:09 AM, Vedant Kumar  wrote:
>
> Hi Richard,
>
> This commit is causing an unexpected build failure in the stage2
> modules-enabled coverage bot. I've attached the build log. Here's the error:
>
> [3685/3899] 
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-compiler/bin/clang++
>-DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
> -D__STDC_LIMIT_MACROS -Itools/lld/COFF 
> -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/COFF
>  
> -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/include
>  -Itools/lld/include -I/usr/include/libxml2 -Iinclude 
> -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include 
> -fPIC -fvisibility-inlines-hidden -Werror=date-time 
> -Werror=unguarded-availability-new -std=c++11 -fmodules 
> -fmodules-cache-path=/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-build/module.cache
>  -fcxx-modules -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
> -Wmissing-field-initializers -pedantic -Wno-long-long 
> -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor 
> -Wstring-conversion -fcolor-diagnostics 
> -fprofile-instr-generate='/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-build/profiles/%6m.profraw'
>  -fcoverage-mapping -O3 -DNDEBUG-fno-exceptions -fno-rtti -MMD -MT 
> tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o -MF 
> tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o.d -o 
> tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o -c 
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/COFF/PDB.cpp
> FAILED: tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-compiler/bin/clang++
>-DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
> -D__STDC_LIMIT_MACROS -Itools/lld/COFF 
> -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/COFF
>  
> -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/include
>  -Itools/lld/include -I/usr/include/libxml2 -Iinclude 
> -I/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include 
> -fPIC -fvisibility-inlines-hidden -Werror=date-time 
> -Werror=unguarded-availability-new -std=c++11 -fmodules 
> -fmodules-cache-path=/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-build/module.cache
>  -fcxx-modules -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
> -Wmissing-field-initializers -pedantic -Wno-long-long 
> -Wcovered-switch-default -Wnon-virtual-dtor -Wdelete-non-virtual-dtor 
> -Wstring-conversion -fcolor-diagnostics 
> -fprofile-instr-generate='/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/clang-build/profiles/%6m.profraw'
>  -fcoverage-mapping -O3 -DNDEBUG-fno-exceptions -fno-rtti -MMD -MT 
> tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o -MF 
> tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o.d -o 
> tools/lld/COFF/CMakeFiles/lldCOFF.dir/PDB.cpp.o -c 
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/COFF/PDB.cpp
> In module 'std' imported from 
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/lld/COFF/Config.h:16:
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-compiler/include/c++/v1/list:389:10:
>  error: 'std::__1::operator==' has different definitions in different 
> modules; definition in module 'std.list' first difference is function body
> bool operator==(const __list_iterator& __x, const __list_iterator& __y)
> ~^~
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-compiler/include/c++/v1/list:389:10:
>  note: but in 'std.list' found a different body
> bool operator==(const __list_iterator& __x, const __list_iterator& __y)
> ~^~
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-compiler/include/c++/v1/list:394:11:
>  error: 'std::__1::operator!=' has different definitions in different 
> modules; definition in module 'std.list' first difference is function body
>  bool operator!=(const __list_iterator& __x, const __list_iterator& __y)
>  ~^~
> /Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/host-compiler/include/c++/v1/list:394:11:
>  note: but in 'std.list' found a different body
>  bool operator!=(const __list_iterator& __x, const __list_iterator& __y)
>  

[PATCH] D41713: [Myriad] Remove invalidated -elf flag for MoviAsm

2018-01-03 Thread Walter Lee via Phabricator via cfe-commits
waltl created this revision.
waltl added a reviewer: jyknight.

The flag has been deprecated, and is becoming invalid in the latest
MDK.


https://reviews.llvm.org/D41713

Files:
  clang/lib/Driver/ToolChains/Myriad.cpp
  clang/test/Driver/myriad-toolchain.c


Index: clang/test/Driver/myriad-toolchain.c
===
--- clang/test/Driver/myriad-toolchain.c
+++ clang/test/Driver/myriad-toolchain.c
@@ -41,7 +41,7 @@
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
 // MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" 
"-mcpu=myriad2.2" "-isystem" "somewhere" "-I" "common"
 // MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad2.2" 
"-noSPrefixing" "-a"
-// MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
+// MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common"
 
 // RUN: %clang -target shave-myriad -c -### %s -DEFINE_ME -UNDEFINE_ME 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DEFINES
Index: clang/lib/Driver/ToolChains/Myriad.cpp
===
--- clang/lib/Driver/ToolChains/Myriad.cpp
+++ clang/lib/Driver/ToolChains/Myriad.cpp
@@ -107,7 +107,6 @@
 CmdArgs.push_back(
 Args.MakeArgString(std::string("-i:") + A->getValue(0)));
   }
-  CmdArgs.push_back("-elf"); // Output format.
   CmdArgs.push_back(II.getFilename());
   CmdArgs.push_back(
   Args.MakeArgString(std::string("-o:") + Output.getFilename()));


Index: clang/test/Driver/myriad-toolchain.c
===
--- clang/test/Driver/myriad-toolchain.c
+++ clang/test/Driver/myriad-toolchain.c
@@ -41,7 +41,7 @@
 // RUN:   | FileCheck %s -check-prefix=MOVICOMPILE
 // MOVICOMPILE: moviCompile{{(.exe)?}}" "-S" "-fno-exceptions" "-DMYRIAD2" "-mcpu=myriad2.2" "-isystem" "somewhere" "-I" "common"
 // MOVICOMPILE: moviAsm{{(.exe)?}}" "-no6thSlotCompression" "-cv:myriad2.2" "-noSPrefixing" "-a"
-// MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common" "-elf"
+// MOVICOMPILE: "-yippee" "-i:somewhere" "-i:common"
 
 // RUN: %clang -target shave-myriad -c -### %s -DEFINE_ME -UNDEFINE_ME 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=DEFINES
Index: clang/lib/Driver/ToolChains/Myriad.cpp
===
--- clang/lib/Driver/ToolChains/Myriad.cpp
+++ clang/lib/Driver/ToolChains/Myriad.cpp
@@ -107,7 +107,6 @@
 CmdArgs.push_back(
 Args.MakeArgString(std::string("-i:") + A->getValue(0)));
   }
-  CmdArgs.push_back("-elf"); // Output format.
   CmdArgs.push_back(II.getFilename());
   CmdArgs.push_back(
   Args.MakeArgString(std::string("-o:") + Output.getFilename()));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41711: [docs] Mention support for Windows/ARM64 in the release notes

2018-01-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D41711#966983, @rnk wrote:

> We should also discuss LLD and PDBs here. That's made huge progress since 5.0.


Nevermind, we have LLD release notes for that.


Repository:
  rC Clang

https://reviews.llvm.org/D41711



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


Re: trivial_abi

2018-01-03 Thread John McCall via cfe-commits

> On Jan 3, 2018, at 5:12 PM, Richard Smith  wrote:
> 
> On 2 January 2018 at 20:55, John McCall via cfe-commits 
> > wrote:
>> On Jan 2, 2018, at 10:43 PM, Richard Smith > > wrote:
>> 
>> On 2 January 2018 at 19:02, John McCall via cfe-commits 
>> > wrote:
>> 
>>> On Jan 2, 2018, at 9:15 PM, Akira Hatanaka >> > wrote:
>>> 
>>> 
>>> 
 On Jan 2, 2018, at 4:56 PM, Richard Smith via cfe-commits 
 > wrote:
 
 On 2 January 2018 at 15:33, John McCall via cfe-commits 
 > wrote:
 Hey, Richard et al.  Akira and I were talking about the right ABI rule for 
 deciding can-pass-in-registers-ness for structs in the presence of 
 trivial_abi, and I think I like Akira's approach but wanted to get your 
 input.
 
 The current definition in Itanium is:
 
   non-trivial for the purposes of calls <>
  <>
 A type is considered non-trivial for the purposes of calls if:
 
 it has a non-trivial copy constructor, move constructor, or destructor, or
  <>
 I'm assuming we're implicitly excluding deleted functions here. (I'd 
 prefer to make that explicit; this has been the source of a number of ABI 
 mismatches.)
 all of its copy and move constructors are deleted.
  <>
 
 I'd suggest modifying this to:
 
A type is considered non-trivial for the purposes of calls if:
- if has a copy constructor, move constructor, or destructor 
 which is non-trivial for the purposes of calls, or
- all of its copy and move constructors are deleted and it does 
 not have the trivial_abi attribute.
 
A copy/move constructor is considered trivial for the purposes of calls 
 if:
- it is user-provided and
- the class has the trivial_abi attribute and
- a defaulted definition of the constructor would be 
 trivial for the purposes of calls; or
 
 We'd need to say what happens if the function in question cannot validly 
 be defaulted for any of the reasons in [dcl.fct.def.default]. Do we try to 
 infer whether it's a copy or move constructor, and use the rules for a 
 defaulted copy or move constructor? Or do we just say that's never trivial 
 for the purposes of calls? Or something else? Eg:
 
 struct [[clang::trivial_abi]] A {
   A(A && = make());
 };
 
 Here, A::A(A&&) cannot validly be defaulted. Is A trivial for the purpose 
 of calls? Likewise:
 
 struct [[clang::trivial_abi]] B {
   B(...);
 };
 struct C {
   volatile B b;
 };
 
 Here, C's copy constructor calls B::B(...). Is C trivial for the purpose 
 of calls? (OK, Clang crashes on that example today. But still...)
 
 I'd be uncomfortable making the rules in [dcl.fct.def.default] part of the 
 ABI; they seem to be changing relatively frequently. Perhaps we could say 
 "if the function is a copy constructor ([class.copy.ctor]/1), then 
 consider what an implicitly-declared defaulted copy constructor would do; 
 if it's a move constructor ([class.copy.ctor]/2), then consider what an 
 implicitly-declared defaulted move constructor would do; otherwise, it's 
 not trivial for the purpose of calls". That'd mean A is trivial for the 
 purpose of calls and C is not, which I think is probably the right answer.
 
- it is not user-provided and
- the class has no virtual functions and no virtual 
 base classes, and
- the constructor used to copy/move each direct base 
 class subobject is trivial for the purposes of calls, and
- for each non-static data member that is of class type 
 (or array thereof), the constructor selected to copy/move that member is 
 trivial for the purposes of calls.
 
A destructor is considered trivial for the purposes of calls if:
- it is not user-provided or the class has the trivial_abi 
 attribute, and
- the destructor is not virtual, and
- all of the direct base classes of its class have destructors 
 that are trivial for the purposes of calls, and
- for all of the non-static data members of its class that are 
 of class type (or array thereof), each such class is trivial for the 
 purposes of calls.
 
These definitions are intended to follow [class.copy.ctor]p11 and 
 [class.dtor]p6 except for the special rules applicable to 

[PATCH] D41545: Replace cp -a in various Clang tests

2018-01-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast updated this revision to Diff 128584.
hubert.reinterpretcast added a comment.

Use cp -R, which is sufficient instead of cp -RPp


Repository:
  rC Clang

https://reviews.llvm.org/D41545

Files:
  test/Modules/crash-vfs-path-emptydir-entries.m
  test/Modules/crash-vfs-path-symlink-component.m
  test/Modules/crash-vfs-path-symlink-topheader.m
  test/Modules/crash-vfs-umbrella-frameworks.m
  test/VFS/umbrella-framework-import-skipnonexist.m


Index: test/VFS/umbrella-framework-import-skipnonexist.m
===
--- test/VFS/umbrella-framework-import-skipnonexist.m
+++ test/VFS/umbrella-framework-import-skipnonexist.m
@@ -5,7 +5,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/vdir %t/outdir %t/cache
-// RUN: cp -a %S/Inputs/Bar.framework %t/outdir/
+// RUN: cp -R %S/Inputs/Bar.framework %t/outdir/
 //
 // RUN: sed -e "s:VDIR:%t/vdir:g" -e "s:OUT_DIR:%t/outdir:g" 
%S/Inputs/bar-headers.yaml > %t/vdir/bar-headers.yaml
 // RUN: rm -f %t/outdir/Bar.framework/Headers/B.h
Index: test/Modules/crash-vfs-umbrella-frameworks.m
===
--- test/Modules/crash-vfs-umbrella-frameworks.m
+++ test/Modules/crash-vfs-umbrella-frameworks.m
@@ -5,7 +5,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t
-// RUN: cp -a %S/Inputs/crash-recovery/Frameworks %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/Frameworks %t/i/
 // RUN: mkdir -p %t/i/Frameworks/A.framework/Frameworks
 // RUN: ln -s ../../B.framework 
%t/i/Frameworks/A.framework/Frameworks/B.framework
 
Index: test/Modules/crash-vfs-path-symlink-topheader.m
===
--- test/Modules/crash-vfs-path-symlink-topheader.m
+++ test/Modules/crash-vfs-path-symlink-topheader.m
@@ -8,7 +8,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t %t/sysroot
-// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/usr %t/i/
 // RUN: rm -f %t/i/usr/include/pthread_impl.h
 // RUN: ln -s pthread/pthread_impl.h %t/i/usr/include/pthread_impl.h
 
Index: test/Modules/crash-vfs-path-symlink-component.m
===
--- test/Modules/crash-vfs-path-symlink-component.m
+++ test/Modules/crash-vfs-path-symlink-component.m
@@ -8,7 +8,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t %t/sysroot
-// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/usr %t/i/
 // RUN: ln -s include/tcl-private %t/i/usr/x
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
Index: test/Modules/crash-vfs-path-emptydir-entries.m
===
--- test/Modules/crash-vfs-path-emptydir-entries.m
+++ test/Modules/crash-vfs-path-emptydir-entries.m
@@ -8,7 +8,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t %t/sysroot
-// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/usr %t/i/
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
 // RUN: %clang -fsyntax-only %s -I %/t/i -isysroot %/t/sysroot/ \


Index: test/VFS/umbrella-framework-import-skipnonexist.m
===
--- test/VFS/umbrella-framework-import-skipnonexist.m
+++ test/VFS/umbrella-framework-import-skipnonexist.m
@@ -5,7 +5,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/vdir %t/outdir %t/cache
-// RUN: cp -a %S/Inputs/Bar.framework %t/outdir/
+// RUN: cp -R %S/Inputs/Bar.framework %t/outdir/
 //
 // RUN: sed -e "s:VDIR:%t/vdir:g" -e "s:OUT_DIR:%t/outdir:g" %S/Inputs/bar-headers.yaml > %t/vdir/bar-headers.yaml
 // RUN: rm -f %t/outdir/Bar.framework/Headers/B.h
Index: test/Modules/crash-vfs-umbrella-frameworks.m
===
--- test/Modules/crash-vfs-umbrella-frameworks.m
+++ test/Modules/crash-vfs-umbrella-frameworks.m
@@ -5,7 +5,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t
-// RUN: cp -a %S/Inputs/crash-recovery/Frameworks %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/Frameworks %t/i/
 // RUN: mkdir -p %t/i/Frameworks/A.framework/Frameworks
 // RUN: ln -s ../../B.framework %t/i/Frameworks/A.framework/Frameworks/B.framework
 
Index: test/Modules/crash-vfs-path-symlink-topheader.m
===
--- test/Modules/crash-vfs-path-symlink-topheader.m
+++ test/Modules/crash-vfs-path-symlink-topheader.m
@@ -8,7 +8,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t %t/sysroot
-// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/usr %t/i/
 // RUN: rm -f %t/i/usr/include/pthread_impl.h
 // RUN: ln -s pthread/pthread_impl.h %t/i/usr/include/pthread_impl.h
 
Index: test/Modules/crash-vfs-path-symlink-component.m
===
--- 

[libcxx] r321725 - Update version to 7.0.0svn: cmake, include files and docs

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 07:40:29 2018
New Revision: 321725

URL: http://llvm.org/viewvc/llvm-project?rev=321725=rev
Log:
Update version to 7.0.0svn: cmake, include files and docs

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/docs/conf.py
libcxx/trunk/include/__config
libcxx/trunk/include/__libcpp_version

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=321725=321724=321725=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Wed Jan  3 07:40:29 2018
@@ -23,7 +23,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   project(libcxx CXX C)
 
   set(PACKAGE_NAME libcxx)
-  set(PACKAGE_VERSION 6.0.0svn)
+  set(PACKAGE_VERSION 7.0.0svn)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 

Modified: libcxx/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/conf.py?rev=321725=321724=321725=diff
==
--- libcxx/trunk/docs/conf.py (original)
+++ libcxx/trunk/docs/conf.py Wed Jan  3 07:40:29 2018
@@ -47,9 +47,9 @@ copyright = u'2011-2017, LLVM Project'
 # built documents.
 #
 # The short X.Y version.
-version = '6.0'
+version = '7.0'
 # The full version, including alpha/beta/rc tags.
-release = '6.0'
+release = '7.0'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=321725=321724=321725=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Wed Jan  3 07:40:29 2018
@@ -33,7 +33,7 @@
 #define _GNUC_VER_NEW 0
 #endif
 
-#define _LIBCPP_VERSION 6000
+#define _LIBCPP_VERSION 7000
 
 #ifndef _LIBCPP_ABI_VERSION
 #define _LIBCPP_ABI_VERSION 1

Modified: libcxx/trunk/include/__libcpp_version
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__libcpp_version?rev=321725=321724=321725=diff
==
--- libcxx/trunk/include/__libcpp_version (original)
+++ libcxx/trunk/include/__libcpp_version Wed Jan  3 07:40:29 2018
@@ -1 +1 @@
-6000
+7000


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


[libcxxabi] r321726 - Update version to 7.0.0svn

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 07:42:34 2018
New Revision: 321726

URL: http://llvm.org/viewvc/llvm-project?rev=321726=rev
Log:
Update version to 7.0.0svn

Modified:
libcxxabi/trunk/CMakeLists.txt

Modified: libcxxabi/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/CMakeLists.txt?rev=321726=321725=321726=diff
==
--- libcxxabi/trunk/CMakeLists.txt (original)
+++ libcxxabi/trunk/CMakeLists.txt Wed Jan  3 07:42:34 2018
@@ -21,7 +21,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   project(libcxxabi CXX C)
 
   set(PACKAGE_NAME libcxxabi)
-  set(PACKAGE_VERSION 6.0.0svn)
+  set(PACKAGE_VERSION 7.0.0svn)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


[libunwind] r321741 - Drop 'svn' suffix from the version number.

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 08:58:46 2018
New Revision: 321741

URL: http://llvm.org/viewvc/llvm-project?rev=321741=rev
Log:
Drop 'svn' suffix from the version number.

Modified:
libunwind/branches/release_60/CMakeLists.txt

Modified: libunwind/branches/release_60/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/branches/release_60/CMakeLists.txt?rev=321741=321740=321741=diff
==
--- libunwind/branches/release_60/CMakeLists.txt (original)
+++ libunwind/branches/release_60/CMakeLists.txt Wed Jan  3 08:58:46 2018
@@ -79,7 +79,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   set(PACKAGE_NAME libunwind)
-  set(PACKAGE_VERSION 5.0.0svn)
+  set(PACKAGE_VERSION 6.0.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


[libcxxabi] r321739 - Drop 'svn' suffix from the version number.

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 08:58:21 2018
New Revision: 321739

URL: http://llvm.org/viewvc/llvm-project?rev=321739=rev
Log:
Drop 'svn' suffix from the version number.

Modified:
libcxxabi/branches/release_60/CMakeLists.txt

Modified: libcxxabi/branches/release_60/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/branches/release_60/CMakeLists.txt?rev=321739=321738=321739=diff
==
--- libcxxabi/branches/release_60/CMakeLists.txt (original)
+++ libcxxabi/branches/release_60/CMakeLists.txt Wed Jan  3 08:58:21 2018
@@ -21,7 +21,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   project(libcxxabi CXX C)
 
   set(PACKAGE_NAME libcxxabi)
-  set(PACKAGE_VERSION 6.0.0svn)
+  set(PACKAGE_VERSION 6.0.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


[libcxx] r321740 - Drop 'svn' suffix from the version number.

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 08:58:30 2018
New Revision: 321740

URL: http://llvm.org/viewvc/llvm-project?rev=321740=rev
Log:
Drop 'svn' suffix from the version number.

Modified:
libcxx/branches/release_60/CMakeLists.txt

Modified: libcxx/branches/release_60/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/branches/release_60/CMakeLists.txt?rev=321740=321739=321740=diff
==
--- libcxx/branches/release_60/CMakeLists.txt (original)
+++ libcxx/branches/release_60/CMakeLists.txt Wed Jan  3 08:58:30 2018
@@ -23,7 +23,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   project(libcxx CXX C)
 
   set(PACKAGE_NAME libcxx)
-  set(PACKAGE_VERSION 6.0.0svn)
+  set(PACKAGE_VERSION 6.0.0)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


r321728 - Update docs version and clear release notes for 7.0.0

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 07:49:39 2018
New Revision: 321728

URL: http://llvm.org/viewvc/llvm-project?rev=321728=rev
Log:
Update docs version and clear release notes for 7.0.0

Modified:
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/docs/conf.py

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=321728=321727=321728=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Jan  3 07:49:39 2018
@@ -1,5 +1,5 @@
 ===
-Clang 6.0.0 (In-Progress) Release Notes
+Clang 7.0.0 (In-Progress) Release Notes
 ===
 
 .. contents::
@@ -10,7 +10,7 @@ Written by the `LLVM Team `_.
 
@@ -18,7 +18,7 @@ Introduction
 
 
 This document contains the release notes for the Clang C/C++/Objective-C
-frontend, part of the LLVM Compiler Infrastructure, release 6.0.0. Here we
+frontend, part of the LLVM Compiler Infrastructure, release 7.0.0. Here we
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
 general LLVM release notes, see `the LLVM
@@ -35,7 +35,7 @@ main Clang web page, this document appli
 the current one. To see the release notes for a specific release, please
 see the `releases page `_.
 
-What's New in Clang 6.0.0?
+What's New in Clang 7.0.0?
 ==
 
 Some of the major new features and improvements to Clang are listed
@@ -51,86 +51,17 @@ Major New Features
 Improvements to Clang's diagnostics
 ^^^
 
-- ``-Wpragma-pack`` is a new warning that warns in the following cases:
-
-  - When a translation unit is missing terminating ``#pragma pack (pop)``
-directives.
-
-  - When leaving an included file that changes the current alignment value,
-i.e. when the alignment before ``#include`` is different to the alignment
-after ``#include``.
-
-  - ``-Wpragma-pack-suspicious-include`` (disabled by default) warns on an
-``#include`` when the included file contains structures or unions affected 
by
-a non-default alignment that has been specified using a ``#pragma pack``
-directive prior to the ``#include``.
-
-- ``-Wobjc-messaging-id`` is a new, non-default warning that warns about
-  message sends to unqualified ``id`` in Objective-C. This warning is useful
-  for projects that would like to avoid any potential future compiler
-  errors/warnings, as the system frameworks might add a method with the same
-  selector which could make the message send to ``id`` ambiguous.
-
-- ``-Wtautological-compare`` now warns when comparing an unsigned integer and 0
-  regardless of whether the constant is signed or unsigned."
-
-- ``-Wtautological-compare`` now warns about comparing a signed integer and 0
-  when the signed integer is coerced to an unsigned type for the comparison.
-  ``-Wsign-compare`` was adjusted not to warn in this case.
-
-- ``-Wtautological-constant-compare`` is a new warning that warns on
-  tautological comparisons between integer variable of the type ``T`` and the
-  largest/smallest possible integer constant of that same type.
-
-- For C code, ``-Wsign-compare``, ``-Wsign-conversion``,
-  ``-Wtautological-constant-compare`` and
-  ``-Wtautological-constant-out-of-range-compare`` were adjusted to use the
-  underlying datatype of ``enum``.
-
-- ``-Wnull-pointer-arithmetic`` now warns about performing pointer arithmetic
-  on a null pointer. Such pointer arithmetic has an undefined behavior if the
-  offset is nonzero. It also now warns about arithmetic on a null pointer
-  treated as a cast from integer to pointer (GNU extension).
-
-- ``-Wzero-as-null-pointer-constant`` was adjusted not to warn on null pointer
-  constants that originate from system macros, except ``NULL`` macro.
+- ...
 
 Non-comprehensive list of changes in this release
 -
 
-- Bitrig OS was merged back into OpenBSD, so Bitrig support has been
-  removed from Clang/LLVM.
-
-- The default value of _MSC_VER was raised from 1800 to 1911, making it
-  compatible with the Visual Studio 2015 and 2017 C++ standard library headers.
-  Users should generally expect this to be regularly raised to match the most
-  recently released version of the Visual C++ compiler.
-
-- clang now defaults to ``.init_array`` if no gcc installation can be found.
-  If a gcc installation is found, it still prefers ``.ctors`` if the found
-  gcc is older than 4.7.0.
-
-- The new builtin preprocessor 

[PATCH] D37014: [clang-tidy] Add a checker to remove useless intermediate variables before return statements with comparisons

2018-01-03 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added inline comments.



Comment at: clang-tidy/readability/UnnecessaryIntermediateVarCheck.cpp:376
+// expression wouldn't really benefit readability. Therefore we abort.
+if (NewReturnLength > MaximumLineLength) {
+  return;

lebedev.ri wrote:
> Is there really no way to format the fixes, and *then* check the line length?
> ```
> $ clang-tidy --help
> ...
>   -format-style=   - 
>  Style for formatting code around applied 
> fixes:
>- 'none' (default) turns off formatting
>- 'file' (literally 'file', not a 
> placeholder)
>  uses .clang-format file in the closest 
> parent
>  directory
>- '{  }' specifies options inline, 
> e.g.
>  -format-style='{BasedOnStyle: llvm, 
> IndentWidth: 8}'
>- 'llvm', 'google', 'webkit', 'mozilla'
>  See clang-format documentation for the 
> up-to-date
>  information about formatting styles and 
> options.
>  This option overrides the 'FormatStyle` 
> option in
>  .clang-tidy file, if any.
> ...
> ```
> so `clang-tidy` is at least aware of `clang-format`.
I think this is doable since I see this in the code:

https://code.woboq.org/llvm/clang-tools-extra/clang-tidy/ClangTidy.cpp.html#199

That leads me to think that we can have this before applying the fixes and in 
case the fix after re-format has a line that violates our rule it gets dropped. 
I'm gonna update the patch with this new addon.


https://reviews.llvm.org/D37014



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


[libunwind] r321743 - Update PACKAGE_VERSION to 7.0.0svn

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 08:59:48 2018
New Revision: 321743

URL: http://llvm.org/viewvc/llvm-project?rev=321743=rev
Log:
Update PACKAGE_VERSION to 7.0.0svn

Modified:
libunwind/trunk/CMakeLists.txt

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=321743=321742=321743=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Wed Jan  3 08:59:48 2018
@@ -79,7 +79,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURR
   endif()
 
   set(PACKAGE_NAME libunwind)
-  set(PACKAGE_VERSION 5.0.0svn)
+  set(PACKAGE_VERSION 7.0.0svn)
   set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
   set(PACKAGE_BUGREPORT "llvm-b...@lists.llvm.org")
 


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


[PATCH] D41698: [DebugInfo] Enable debug information for C99 VLA types

2018-01-03 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

It would be awesome if you could also add an end-to-end test to the 
debuginfo-tests repository so we can verify that this actually works in LLDB 
and GDB.




Comment at: lib/CodeGen/CGDebugInfo.cpp:2358
+if (auto *SizeNode = getVLASizeExpressionForType(EltTy))
+  Subscripts.push_back(DBuilder.getOrCreateSubrange(0, SizeNode));
+else

perhaps write sizeNode/Count to a variable, so you don't have to duplicate the 
expression?



Comment at: lib/CodeGen/CGDebugInfo.cpp:3473
   CGBuilderTy ) {
+  llvm::Optional Optional;
+  EmitDeclare(VD, Storage, ArgNo, Optional, Builder);

Could this function be replaced by a default argument instead?



Comment at: lib/CodeGen/CGDebugInfo.h:86
+  /// represented by instantiated Metadata nodes.
+  llvm::SmallDenseMap SizeExprCache;
+

I'm expecting VLA's to not be very common, should we use a regular DenseMap 
instead?



Comment at: lib/CodeGen/CGDebugInfo.h:317
+  llvm::Metadata *getVLASizeExpressionForType(QualType Ty) {
+if (SizeExprCache.count(Ty))
+  return SizeExprCache[Ty];

This is performing the lookup twice. If you use .find() instead it will be more 
efficient. We also don't use accessor functions like this for any of the other 
caches. If you think that they help, perhaps make this more generic and useful 
for all caches?



Comment at: lib/CodeGen/CGDebugInfo.h:404
+  void EmitDeclareOfAutoVariable(const VarDecl *Decl, llvm::Value *AI,
+ llvm::Optional 
,
+ CGBuilderTy );

do we need the qualifier on Optional?



Comment at: lib/CodeGen/CGDecl.cpp:1125
+// If we have debug info enabled, describe the VLA dimensions properly.
+if (EmitDebugInfo) {
+  QualType Type1D = Ty;

Please move this code into a member function of CGDebugInfo.



Comment at: lib/CodeGen/CGDecl.cpp:1137
+  // Allocate memory for the address of the vla expression
+  // We can use this for debugging purposes
+  auto SizeExprAddr = CreateDefaultAlignTempAlloca(

`.`



Comment at: lib/CodeGen/CodeGenFunction.cpp:1963
+  assert(VlaSize->getType() == SizeTy);
+  return std::pair(VlaSize, Vla->getElementType());
+}

`return {VlaSize, Vla->getElementType()};`


https://reviews.llvm.org/D41698



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


[clang-tools-extra] r321730 - Docs, release notes: update version to 7.0.0

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 07:53:24 2018
New Revision: 321730

URL: http://llvm.org/viewvc/llvm-project?rev=321730=rev
Log:
Docs, release notes: update version to 7.0.0

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

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=321730=321729=321730=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Wed Jan  3 07:53:24 2018
@@ -1,5 +1,5 @@
 ===
-Extra Clang Tools 6.0.0 (In-Progress) Release Notes
+Extra Clang Tools 7.0.0 (In-Progress) Release Notes
 ===
 
 .. contents::
@@ -10,7 +10,7 @@ Written by the `LLVM Team `_.
 
@@ -18,7 +18,7 @@ Introduction
 
 
 This document contains the release notes for the Extra Clang Tools, part of the
-Clang release 6.0.0. Here we describe the status of the Extra Clang Tools in
+Clang release 7.0.0. Here we describe the status of the Extra Clang Tools in
 some detail, including major improvements from the previous release and new
 feature work. All LLVM releases may be downloaded from the `LLVM releases web
 site `_.
@@ -32,7 +32,7 @@ main Clang web page, this document appli
 the current one. To see the release notes for a specific release, please
 see the `releases page `_.
 
-What's New in Extra Clang Tools 6.0.0?
+What's New in Extra Clang Tools 7.0.0?
 ==
 
 Some of the major new features and improvements to Extra Clang Tools are listed
@@ -57,230 +57,7 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- New module `fuchsia` for Fuchsia style checks.
-
-- New module `objc` for Objective-C style checks.
-
-- New `android-cloexec-accept
-  
`_ 
check
-
-  Detects usage of ``accept()``.
-
-- New `android-cloexec-accept4
-  
`_ 
check
-
-  Checks if the required file flag ``SOCK_CLOEXEC`` is present in the argument 
of
-  ``accept4()``.
-
-- New `android-cloexec-dup
-  `_ 
check
-
-  Detects usage of ``dup()``.
-
-- New `android-cloexec-epoll-create
-  
`_
 check
-
-  Detects usage of ``epoll_create()``.
-
-- New `android-cloexec-epoll-create1
-  
`_
 check
-
-  Checks if the required file flag ``EPOLL_CLOEXEC`` is present in the 
argument of
-  ``epoll_create1()``.
-
-- New `android-cloexec-inotify-init
-  
`_
 check
-
-  Detects usage of ``inotify_init()``.
-
-- New `android-cloexec-inotify-init1
-  
`_
 check
-
-  Checks if the required file flag ``IN_CLOEXEC`` is present in the argument of
-  ``inotify_init1()``.
-
-- New `android-cloexec-memfd_create
-  
`_
 check
-
-  Checks if the required file flag ``MFD_CLOEXEC`` is present in the argument
-  of ``memfd_create()``.
-
-- New `bugprone-copy-constructor-init
-  
`_
 check
-
-  Finds copy constructors which don't call the copy constructor of the base 
class.
-
-- New `bugprone-integer-division
-  
`_
 check
-
-  Finds cases where integer division in a floating point context is likely to
-  cause unintended loss of precision.
-
-- New `bugprone-misplaced-operator-in-strlen-in-alloc
-  
`_
 check
-
-  Finds cases where ``1`` is added to the string in the argument to
-  ``strlen()``, ``strnlen()``, ``strnlen_s()``, ``wcslen()``, ``wcsnlen()``, 
and
-  ``wcsnlen_s()`` instead of the result and the value is used as an argument to
-  a memory allocation function (``malloc()``, ``calloc()``, ``realloc()``,
-  ``alloca()``) or the ``new[]`` operator in `C++`.
-
-- New 

[libunwind] r321732 - Update docs version to 7.0

2018-01-03 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Jan  3 07:58:08 2018
New Revision: 321732

URL: http://llvm.org/viewvc/llvm-project?rev=321732=rev
Log:
Update docs version to 7.0

Modified:
libunwind/trunk/docs/conf.py

Modified: libunwind/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/docs/conf.py?rev=321732=321731=321732=diff
==
--- libunwind/trunk/docs/conf.py (original)
+++ libunwind/trunk/docs/conf.py Wed Jan  3 07:58:08 2018
@@ -47,9 +47,9 @@ copyright = u'2011-2017, LLVM Project'
 # built documents.
 #
 # The short X.Y version.
-version = '6.0'
+version = '7.0'
 # The full version, including alpha/beta/rc tags.
-release = '6.0'
+release = '7.0'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


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


[PATCH] D41708: [clang-tidy] Update fuchsia-overloaded-operator to check for valid loc

2018-01-03 Thread Julie Hockett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE321762: [clang-tidy] Update fuchsia-overloaded-operator to 
check for valid loc (authored by juliehockett, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41708?vs=128548=128563#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41708

Files:
  clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
  test/clang-tidy/fuchsia-overloaded-operator.cpp


Index: clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
===
--- clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
+++ clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
@@ -30,8 +30,12 @@
 }
 
 void OverloadedOperatorCheck::check(const MatchFinder::MatchResult ) {
-  if (const auto *D = Result.Nodes.getNodeAs("decl"))
-diag(D->getLocStart(), "cannot overload %0") << D;
+  const auto *D = Result.Nodes.getNodeAs("decl");
+  assert(D && "No FunctionDecl captured!");
+  
+  SourceLocation Loc = D->getLocStart();
+  if (Loc.isValid())
+diag(Loc, "cannot overload %0") << D;
 }
 
 } // namespace fuchsia
Index: test/clang-tidy/fuchsia-overloaded-operator.cpp
===
--- test/clang-tidy/fuchsia-overloaded-operator.cpp
+++ test/clang-tidy/fuchsia-overloaded-operator.cpp
@@ -16,3 +16,6 @@
 
 A operator-(const A , const A );
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator-' 
[fuchsia-overloaded-operator]
+
+void operator delete(void*, void*) throw();
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator delete' 
[fuchsia-overloaded-operator]


Index: clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
===
--- clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
+++ clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
@@ -30,8 +30,12 @@
 }
 
 void OverloadedOperatorCheck::check(const MatchFinder::MatchResult ) {
-  if (const auto *D = Result.Nodes.getNodeAs("decl"))
-diag(D->getLocStart(), "cannot overload %0") << D;
+  const auto *D = Result.Nodes.getNodeAs("decl");
+  assert(D && "No FunctionDecl captured!");
+  
+  SourceLocation Loc = D->getLocStart();
+  if (Loc.isValid())
+diag(Loc, "cannot overload %0") << D;
 }
 
 } // namespace fuchsia
Index: test/clang-tidy/fuchsia-overloaded-operator.cpp
===
--- test/clang-tidy/fuchsia-overloaded-operator.cpp
+++ test/clang-tidy/fuchsia-overloaded-operator.cpp
@@ -16,3 +16,6 @@
 
 A operator-(const A , const A );
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator-' [fuchsia-overloaded-operator]
+
+void operator delete(void*, void*) throw();
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator delete' [fuchsia-overloaded-operator]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41711: [docs] Mention support for Windows/ARM64 in the release notes

2018-01-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

We should also discuss LLD and PDBs here. That's made huge progress since 5.0.


Repository:
  rC Clang

https://reviews.llvm.org/D41711



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


Re: [clang-tools-extra] r321762 - [clang-tidy] Update fuchsia-overloaded-operator to check for valid loc

2018-01-03 Thread Aaron Ballman via cfe-commits
Hans, I'd like to nominate this patch for the 6.0 branch. It fixes a
failing assertion with new functionality; without this fix, anyone
enabling this check and including a STL header that transitively
includes  (which is most of them) will hit the assertion.

Thanks!

~Aaron

On Wed, Jan 3, 2018 at 5:10 PM, Julie Hockett via cfe-commits
 wrote:
> Author: juliehockett
> Date: Wed Jan  3 14:10:11 2018
> New Revision: 321762
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321762=rev
> Log:
> [clang-tidy] Update fuchsia-overloaded-operator to check for valid loc
>
> Updating fuchsia-overloaded-operator check to not issue warnings for
> invalid locations.
>
> Fixes PR35803.
>
> Differential Revision: https://reviews.llvm.org/D41708
>
> Modified:
> clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
> clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp
>
> Modified: 
> clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp?rev=321762=321761=321762=diff
> ==
> --- clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp 
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp 
> Wed Jan  3 14:10:11 2018
> @@ -30,8 +30,12 @@ void OverloadedOperatorCheck::registerMa
>  }
>
>  void OverloadedOperatorCheck::check(const MatchFinder::MatchResult ) {
> -  if (const auto *D = Result.Nodes.getNodeAs("decl"))
> -diag(D->getLocStart(), "cannot overload %0") << D;
> +  const auto *D = Result.Nodes.getNodeAs("decl");
> +  assert(D && "No FunctionDecl captured!");
> +
> +  SourceLocation Loc = D->getLocStart();
> +  if (Loc.isValid())
> +diag(Loc, "cannot overload %0") << D;
>  }
>
>  } // namespace fuchsia
>
> Modified: 
> clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp?rev=321762=321761=321762=diff
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp 
> (original)
> +++ clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp 
> Wed Jan  3 14:10:11 2018
> @@ -16,3 +16,6 @@ public:
>
>  A operator-(const A , const A );
>  // CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator-' 
> [fuchsia-overloaded-operator]
> +
> +void operator delete(void*, void*) throw();
> +// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator delete' 
> [fuchsia-overloaded-operator]
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

2018-01-03 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 128575.
v.g.vassilev marked 4 inline comments as done.
v.g.vassilev added a comment.

Address comments:

- Fix style;
- Do not potentially deserialize a specialization in debug mode.


https://reviews.llvm.org/D41416

Files:
  include/clang/AST/DeclTemplate.h
  lib/AST/DeclTemplate.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp

Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -162,22 +162,57 @@
   Record.AddSourceLocation(typeParams->getRAngleLoc());
 }
 
-/// Add to the record the first declaration from each module file that
-/// provides a declaration of D. The intent is to provide a sufficient
-/// set such that reloading this set will load all current redeclarations.
-void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
-  llvm::MapVector Firsts;
+/// Collect the first declaration from each module file that provides a
+/// declaration of D.
+void CollectFirstDeclFromEachModule(const Decl *D, bool IncludeLocal,
+llvm::MapVector ) {
+
   // FIXME: We can skip entries that we know are implied by others.
   for (const Decl *R = D->getMostRecentDecl(); R; R = R->getPreviousDecl()) {
 if (R->isFromASTFile())
   Firsts[Writer.Chain->getOwningModuleFile(R)] = R;
 else if (IncludeLocal)
   Firsts[nullptr] = R;
   }
+}
+
+/// Add to the record the first declaration from each module file that
+/// provides a declaration of D. The intent is to provide a sufficient
+/// set such that reloading this set will load all current redeclarations.
+void AddFirstDeclFromEachModule(const Decl *D, bool IncludeLocal) {
+  llvm::MapVector Firsts;
+  CollectFirstDeclFromEachModule(D, IncludeLocal, Firsts);
+
   for (const auto  : Firsts)
 Record.AddDeclRef(F.second);
 }
 
+/// Add to the record the first template specialization from each module
+/// file that provides a declaration of D. We store the DeclId and an
+/// ODRHash of the template arguments of D which should provide enough
+/// information to load D only if the template instantiator needs it.
+void AddFirstSpecializationDeclFromEachModule(const Decl *D,
+  bool IncludeLocal) {
+  assert(isa(D) ||
+ isa(D) || isa(D) &&
+ "Must not be called with other decls");
+  llvm::MapVector Firsts;
+  CollectFirstDeclFromEachModule(D, IncludeLocal, Firsts);
+
+  for (const auto  : Firsts) {
+Record.AddDeclRef(F.second);
+ArrayRef Args;
+if (auto *CTSD = dyn_cast(D))
+  Args = CTSD->getTemplateArgs().asArray();
+else if (auto *VTSD = dyn_cast(D))
+  Args = VTSD->getTemplateArgs().asArray();
+else if (auto *FD = dyn_cast(D))
+  Args = FD->getTemplateSpecializationArgs()->asArray();
+assert(Args.size());
+Record.push_back(TemplateArgumentList::ComputeODRHash(Args));
+  }
+}
+
 /// Get the specialization decl from an entry in the specialization list.
 template 
 typename RedeclarableTemplateDecl::SpecEntryTraits::DeclType *
@@ -190,7 +225,8 @@
 decltype(T::PartialSpecializations) (T *Common) {
   return Common->PartialSpecializations;
 }
-ArrayRef getPartialSpecializations(FunctionTemplateDecl::Common *) {
+MutableArrayRef
+getPartialSpecializations(FunctionTemplateDecl::Common *) {
   return None;
 }
 
@@ -207,9 +243,11 @@
 assert(!Common->LazySpecializations);
   }
 
-  ArrayRef LazySpecializations;
+  using LazySpecializationInfo
+= RedeclarableTemplateDecl::LazySpecializationInfo;
+  ArrayRef LazySpecializations;
   if (auto *LS = Common->LazySpecializations)
-LazySpecializations = llvm::makeArrayRef(LS + 1, LS[0]);
+LazySpecializations = llvm::makeArrayRef(LS + 1, LS[0].DeclID);
 
   // Add a slot to the record for the number of specializations.
   unsigned I = Record.size();
@@ -225,12 +263,18 @@
 
   for (auto *D : Specs) {
 assert(D->isCanonicalDecl() && "non-canonical decl in set");
-AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
+AddFirstSpecializationDeclFromEachModule(D, /*IncludeLocal*/true);
+  }
+  for (auto  : LazySpecializations) {
+Record.push_back(IDHashPair.DeclID);
+Record.push_back(IDHashPair.ODRHash);
   }
-  Record.append(LazySpecializations.begin(), LazySpecializations.end());
 
-  // Update the size entry we added earlier.
-  Record[I] 

[PATCH] D41384: [analyzer] Suppress false positive warnings form security.insecureAPI.strcpy

2018-01-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

This patch makes a totally valid point :)




Comment at: lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp:513
 
+  int ArraySize = -1, StrLen = -1;
+  const auto *Target = CE->getArg(0)->IgnoreImpCasts(),

You might want to use a wider integer type because 64-bit arrays may have 2³¹ 
or more elements (not sure about string literals).


https://reviews.llvm.org/D41384



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


[PATCH] D41711: [docs] Mention support for Windows/ARM64 in the release notes

2018-01-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: rnk, compnerd, mgrang.
Herald added subscribers: kristof.beyls, aemerson.

Repository:
  rC Clang

https://reviews.llvm.org/D41711

Files:
  docs/ReleaseNotes.rst


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -168,8 +168,8 @@
 Windows Support
 ---
 
-Clang's support for building native Windows programs ...
-
+- Clang now has initial, preliminary support for targeting Windows on
+  ARM64.
 
 C Language Changes in Clang
 ---


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -168,8 +168,8 @@
 Windows Support
 ---
 
-Clang's support for building native Windows programs ...
-
+- Clang now has initial, preliminary support for targeting Windows on
+  ARM64.
 
 C Language Changes in Clang
 ---
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41716: clang-tidy: add IgnoreMacros option to readability-inconsistent-declaration-parameter-name

2018-01-03 Thread Miklos Vajna via Phabricator via cfe-commits
vmiklos created this revision.
vmiklos added reviewers: alexfh, piotrdz.

  And also enable it by default to be consistent with e.g. modernize-use-using.
  
  This helps e.g. when running this check on client code where the macro is
  provided by the system, so there is no easy way to modify it.


https://reviews.llvm.org/D41716

Files:
  clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
  clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
  docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
  test/clang-tidy/readability-inconsistent-declaration-parameter-name-macros.cpp
  test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp

Index: test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
===
--- test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
+++ test/clang-tidy/readability-inconsistent-declaration-parameter-name.cpp
@@ -178,11 +178,14 @@
 
 //
 
-#define DECLARE_FUNCTION_WITH_PARAM_NAME(function_name, param_name) \
-  void function_name(int param_name)
-
-// CHECK-MESSAGES: :[[@LINE+1]]:34: warning: function 'macroFunction' has 1 other declaration with different parameter names [readability-inconsistent-declaration-parameter-name]
-DECLARE_FUNCTION_WITH_PARAM_NAME(macroFunction, a);
-// CHECK-MESSAGES: :[[@LINE+2]]:34: note: the 1st inconsistent declaration seen here
-// CHECK-MESSAGES: :[[@LINE+1]]:34: note: differing parameters are named here: ('b'), in the other declaration: ('a')
-DECLARE_FUNCTION_WITH_PARAM_NAME(macroFunction, b);
+// This resulted in a warning by default.
+#define MACRO() \
+  void f(int x);
+
+struct S {
+  MACRO();
+};
+
+void S::f(int y)
+{
+}
Index: test/clang-tidy/readability-inconsistent-declaration-parameter-name-macros.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-inconsistent-declaration-parameter-name-macros.cpp
@@ -0,0 +1,25 @@
+// RUN: %check_clang_tidy %s readability-inconsistent-declaration-parameter-name %t -- \
+// RUN:   -config="{CheckOptions: [{key: readability-inconsistent-declaration-parameter-name.IgnoreMacros, value: 0}]}" \
+// RUN:   -- -std=c++11
+
+#define MACRO() \
+  void f(int x);
+
+struct S {
+  MACRO();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function 'S::f' has a definition with different parameter names
+};
+
+void S::f(int y) {
+}
+
+//
+
+#define DECLARE_FUNCTION_WITH_PARAM_NAME(function_name, param_name) \
+  void function_name(int param_name)
+
+// CHECK-MESSAGES: :[[@LINE+1]]:34: warning: function 'macroFunction' has 1 other declaration with different parameter names [readability-inconsistent-declaration-parameter-name]
+DECLARE_FUNCTION_WITH_PARAM_NAME(macroFunction, a);
+// CHECK-MESSAGES: :[[@LINE+2]]:34: note: the 1st inconsistent declaration seen here
+// CHECK-MESSAGES: :[[@LINE+1]]:34: note: differing parameters are named here: ('b'), in the other declaration: ('a')
+DECLARE_FUNCTION_WITH_PARAM_NAME(macroFunction, b);
Index: docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
===
--- docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
+++ docs/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.rst
@@ -42,3 +42,8 @@
 In the case of multiple redeclarations or function template specializations,
 a warning is issued for every redeclaration or specialization inconsistent with
 the definition or the first declaration seen in a translation unit.
+
+.. option:: IgnoreMacros
+
+   If this option is set to non-zero (default is `1`), the check will not warn
+   about names declared inside macros.
Index: clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
===
--- clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
+++ clang-tidy/readability/InconsistentDeclarationParameterNameCheck.h
@@ -27,15 +27,18 @@
 public:
   InconsistentDeclarationParameterNameCheck(StringRef Name,
 ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : ClangTidyCheck(Name, Context),
+IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", 1) != 0) {}
 
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
 
 private:
   void markRedeclarationsAsVisited(const FunctionDecl *FunctionDeclaration);
 
   llvm::DenseSet VisitedDeclarations;
+  const bool IgnoreMacros;
 };
 
 } // namespace readability
Index: 

[PATCH] D41717: [CGBuiltin] Handle unsigned mul overflow properly (PR35750)

2018-01-03 Thread Vedant Kumar via Phabricator via cfe-commits
vsk created this revision.
vsk added reviewers: efriedma, arphaman.

r320902 fixed the IRGen for some types of checked multiplications. It
did not handle unsigned overflow correctly in the case where the signed
operand is negative (PR35750).

Eli pointed out that on overflow, the result must be equal to the unique
value that is equivalent to the mathematically-correct result modulo two
raised to the k power, where k is the number of bits in the result type.

This patch fixes the specialized IRGen from r320902 accordingly.

Testing: Apart from check-clang, I modified the test harness from
r320902 to validate the results of all multiplications -- not just the
ones which don't overflow:

  https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081

llvm.org/PR35750, rdar://34963321


https://reviews.llvm.org/D41717

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtins-overflow.c


Index: test/CodeGen/builtins-overflow.c
===
--- test/CodeGen/builtins-overflow.c
+++ test/CodeGen/builtins-overflow.c
@@ -373,7 +373,9 @@
 // CHECK-NEXT:  [[NotNull:%.*]] = icmp ne i32 [[UnsignedResult]], 0
 // CHECK-NEXT:  [[Underflow:%.*]] = and i1 [[IsNeg]], [[NotNull]]
 // CHECK-NEXT:  [[OFlow:%.*]] = or i1 [[UnsignedOFlow]], [[Underflow]]
-// CHECK-NEXT:  store i32 [[UnsignedResult]], i32* %{{.*}}, align 4
+// CHECK-NEXT:  [[NegatedResult:%.*]] = sub i32 0, [[UnsignedResult]]
+// CHECK-NEXT:  [[Result:%.*]] = select i1 [[IsNeg]], i32 [[NegatedResult]], 
i32 [[UnsignedResult]]
+// CHECK-NEXT:  store i32 [[Result]], i32* %{{.*}}, align 4
 // CHECK:   br i1 [[OFlow]]
 
   unsigned result;
@@ -432,7 +434,9 @@
 // CHECK-NEXT:  [[OVERFLOW_PRE_TRUNC:%.*]] = or i1 {{.*}}, [[UNDERFLOW]]
 // CHECK-NEXT:  [[TRUNC_OVERFLOW:%.*]] = icmp ugt i64 [[UNSIGNED_RESULT]], 
4294967295
 // CHECK-NEXT:  [[OVERFLOW:%.*]] = or i1 [[OVERFLOW_PRE_TRUNC]], 
[[TRUNC_OVERFLOW]]
-// CHECK-NEXT:  trunc i64 [[UNSIGNED_RESULT]] to i32
+// CHECK-NEXT:  [[NEGATED:%.*]] = sub i64 0, [[UNSIGNED_RESULT]]
+// CHECK-NEXT:  [[RESULT:%.*]] = select i1 {{.*}}, i64 [[NEGATED]], i64 
[[UNSIGNED_RESULT]]
+// CHECK-NEXT:  trunc i64 [[RESULT]] to i32
 // CHECK-NEXT:  store
   unsigned result;
   if (__builtin_mul_overflow(y, x, ))
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -915,7 +915,11 @@
   Overflow = CGF.Builder.CreateOr(Overflow, TruncOverflow);
 }
 
-Result = CGF.Builder.CreateTrunc(UnsignedResult, ResTy);
+// Negate the product if it would be negative in infinite precision.
+Result = CGF.Builder.CreateSelect(
+IsNegative, CGF.Builder.CreateNeg(UnsignedResult), UnsignedResult);
+
+Result = CGF.Builder.CreateTrunc(Result, ResTy);
   }
   assert(Overflow && Result && "Missing overflow or result");
 


Index: test/CodeGen/builtins-overflow.c
===
--- test/CodeGen/builtins-overflow.c
+++ test/CodeGen/builtins-overflow.c
@@ -373,7 +373,9 @@
 // CHECK-NEXT:  [[NotNull:%.*]] = icmp ne i32 [[UnsignedResult]], 0
 // CHECK-NEXT:  [[Underflow:%.*]] = and i1 [[IsNeg]], [[NotNull]]
 // CHECK-NEXT:  [[OFlow:%.*]] = or i1 [[UnsignedOFlow]], [[Underflow]]
-// CHECK-NEXT:  store i32 [[UnsignedResult]], i32* %{{.*}}, align 4
+// CHECK-NEXT:  [[NegatedResult:%.*]] = sub i32 0, [[UnsignedResult]]
+// CHECK-NEXT:  [[Result:%.*]] = select i1 [[IsNeg]], i32 [[NegatedResult]], i32 [[UnsignedResult]]
+// CHECK-NEXT:  store i32 [[Result]], i32* %{{.*}}, align 4
 // CHECK:   br i1 [[OFlow]]
 
   unsigned result;
@@ -432,7 +434,9 @@
 // CHECK-NEXT:  [[OVERFLOW_PRE_TRUNC:%.*]] = or i1 {{.*}}, [[UNDERFLOW]]
 // CHECK-NEXT:  [[TRUNC_OVERFLOW:%.*]] = icmp ugt i64 [[UNSIGNED_RESULT]], 4294967295
 // CHECK-NEXT:  [[OVERFLOW:%.*]] = or i1 [[OVERFLOW_PRE_TRUNC]], [[TRUNC_OVERFLOW]]
-// CHECK-NEXT:  trunc i64 [[UNSIGNED_RESULT]] to i32
+// CHECK-NEXT:  [[NEGATED:%.*]] = sub i64 0, [[UNSIGNED_RESULT]]
+// CHECK-NEXT:  [[RESULT:%.*]] = select i1 {{.*}}, i64 [[NEGATED]], i64 [[UNSIGNED_RESULT]]
+// CHECK-NEXT:  trunc i64 [[RESULT]] to i32
 // CHECK-NEXT:  store
   unsigned result;
   if (__builtin_mul_overflow(y, x, ))
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -915,7 +915,11 @@
   Overflow = CGF.Builder.CreateOr(Overflow, TruncOverflow);
 }
 
-Result = CGF.Builder.CreateTrunc(UnsignedResult, ResTy);
+// Negate the product if it would be negative in infinite precision.
+Result = CGF.Builder.CreateSelect(
+IsNegative, CGF.Builder.CreateNeg(UnsignedResult), UnsignedResult);
+
+Result = CGF.Builder.CreateTrunc(Result, ResTy);
   }
   assert(Overflow && Result && "Missing overflow or result");
 
___
cfe-commits mailing list

[PATCH] D41538: [analyzer] Fix some checker's output plist not containing the checker name #2

2018-01-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I'm still not quite sure what's the whole point of having `BugType` without a 
checker. We can still easily write anything we want in the "category" and 
"name" fields anyways, so we can easily produce bugs that are indistinguishable 
to the user from different checkers, while being able to distinguish them when 
we, as developers, want to figure out what checker throws them, so what was the 
whole point this whole time? I might be missing something, but if you have 
time, maybe remove the whole `CheckName`-based constructor and just tie every 
`BugType` to the checker? The current approach is totally fine though :)




Comment at: include/clang/StaticAnalyzer/Core/BugReporter/BugType.h:51
   StringRef getCategory() const { return Category; }
-  StringRef getCheckName() const { return Check.getName(); }
+  StringRef getCheckName() const {
+// FIXME: This is a workaround to ensure that Check is initialized 

I suggest:

```
if (Checker)
  return Checker->getCheckname().getName();
return Check.getName();
```

Like, what's the point of storing the StringRef if we can retrieve it any time 
anyway?

I guess `Checker` does live long enough?



Comment at: lib/StaticAnalyzer/Checkers/ValistChecker.cpp:277
+  BT_leakedvalist.reset(new BugType(
+  CheckNames[ReportUninit ? CK_Uninitialized : CK_Unterminated],
+  "Leaked va_list", categories::MemoryError));

a.sidorin wrote:
> xazax.hun wrote:
> > a.sidorin wrote:
> > > If I understand correctly, if we report uninitialized and then 
> > > unterminated, the second report will have wrong CheckName because it is 
> > > never reset.
> > That is right. Unfortunately, If unterminated check is not turned on but 
> > uninitialized is, we can end up with empty check names. I replaced this 
> > workaround with a slightly more robust one.
> Maybe we should use different BugTypes for Uninitialized and Unterminated?
Yep, this rings my bells too. We shouldn't race on how do we initialize a 
`BugType` depending on what bug is encountered first in the translation unit.


https://reviews.llvm.org/D41538



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


r321770 - PR33503: When a qualified name in a redeclaration names a prior declaration in

2018-01-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jan  3 15:03:54 2018
New Revision: 321770

URL: http://llvm.org/viewvc/llvm-project?rev=321770=rev
Log:
PR33503: When a qualified name in a redeclaration names a prior declaration in
an inline namespace, update its semantic DeclContext to match.

We would previously get the semantic DeclContext wrong (pointing to the named
scope rather than the inline namespace within it), resulting in wrong lookup
results and linkage-related problems if the inline namespace was an anonymous
namespace.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/dcl.decl/dcl.meaning/p1-0x.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=321770=321769=321770=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jan  3 15:03:54 2018
@@ -2929,6 +2929,48 @@ static bool hasIdenticalPassObjectSizeAt
   return std::equal(A->param_begin(), A->param_end(), B->param_begin(), 
AttrEq);
 }
 
+/// If necessary, adjust the semantic declaration context for a qualified
+/// declaration to name the correct inline namespace within the qualifier.
+static void adjustDeclContextForDeclaratorDecl(DeclaratorDecl *NewD,
+   DeclaratorDecl *OldD) {
+  // The only case where we need to update the DeclContext is when
+  // redeclaration lookup for a qualified name finds a declaration
+  // in an inline namespace within the context named by the qualifier:
+  //
+  //   inline namespace N { int f(); }
+  //   int ::f(); // Sema DC needs adjusting from :: to N::.
+  //
+  // For unqualified declarations, the semantic context *can* change
+  // along the redeclaration chain (for local extern declarations,
+  // extern "C" declarations, and friend declarations in particular).
+  if (!NewD->getQualifier())
+return;
+
+  // NewD is probably already in the right context.
+  auto *NamedDC = NewD->getDeclContext()->getRedeclContext();
+  auto *SemaDC = OldD->getDeclContext()->getRedeclContext();
+  if (NamedDC->Equals(SemaDC))
+return;
+
+  assert((NamedDC->InEnclosingNamespaceSetOf(SemaDC) ||
+  NewD->isInvalidDecl() || OldD->isInvalidDecl()) &&
+ "unexpected context for redeclaration");
+
+  auto *LexDC = NewD->getLexicalDeclContext();
+  auto FixSemaDC = [=](NamedDecl *D) {
+if (!D)
+  return;
+D->setDeclContext(SemaDC);
+D->setLexicalDeclContext(LexDC);
+  };
+
+  FixSemaDC(NewD);
+  if (auto *FD = dyn_cast(NewD))
+FixSemaDC(FD->getDescribedFunctionTemplate());
+  else if (auto *VD = dyn_cast(NewD))
+FixSemaDC(VD->getDescribedVarTemplate());
+}
+
 /// MergeFunctionDecl - We just parsed a function 'New' from
 /// declarator D which has the same name and scope as a previous
 /// declaration 'Old'.  Figure out how to resolve this situation,
@@ -3953,6 +3995,7 @@ void Sema::MergeVarDecl(VarDecl *New, Lo
   New->setPreviousDecl(Old);
   if (NewTemplate)
 NewTemplate->setPreviousDecl(OldTemplate);
+  adjustDeclContextForDeclaratorDecl(New, Old);
 
   // Inherit access appropriately.
   New->setAccess(Old->getAccess());
@@ -9252,12 +9295,13 @@ bool Sema::CheckFunctionDeclaration(Scop
 
 if (FunctionTemplateDecl *OldTemplateDecl
   = dyn_cast(OldDecl)) {
-  NewFD->setPreviousDeclaration(OldTemplateDecl->getTemplatedDecl());
+  auto *OldFD = OldTemplateDecl->getTemplatedDecl();
+  NewFD->setPreviousDeclaration(OldFD);
+  adjustDeclContextForDeclaratorDecl(NewFD, OldFD);
   FunctionTemplateDecl *NewTemplateDecl
 = NewFD->getDescribedFunctionTemplate();
   assert(NewTemplateDecl && "Template/non-template mismatch");
-  if (CXXMethodDecl *Method
-= dyn_cast(NewTemplateDecl->getTemplatedDecl())) {
+  if (auto *Method = dyn_cast(NewFD)) {
 Method->setAccess(OldTemplateDecl->getAccess());
 NewTemplateDecl->setAccess(OldTemplateDecl->getAccess());
   }
@@ -9270,22 +9314,22 @@ bool Sema::CheckFunctionDeclaration(Scop
 assert(OldTemplateDecl->isMemberSpecialization());
 // Explicit specializations of a member template do not inherit deleted
 // status from the parent member template that they are specializing.
-if (OldTemplateDecl->getTemplatedDecl()->isDeleted()) {
-  FunctionDecl *const OldTemplatedDecl =
-  OldTemplateDecl->getTemplatedDecl();
+if (OldFD->isDeleted()) {
   // FIXME: This assert will not hold in the presence of modules.
-  assert(OldTemplatedDecl->getCanonicalDecl() == OldTemplatedDecl);
+  assert(OldFD->getCanonicalDecl() == OldFD);
   // FIXME: We need an update record for this AST mutation.
-  OldTemplatedDecl->setDeletedAsWritten(false);
+  OldFD->setDeletedAsWritten(false);
 }
   }
 
 } else {
   if 

[PATCH] D41717: [CGBuiltin] Handle unsigned mul overflow properly (PR35750)

2018-01-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321771: [CGBuiltin] Handle unsigned mul overflow properly 
(PR35750) (authored by vedantk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41717?vs=128567=128574#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41717

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


Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -915,7 +915,11 @@
   Overflow = CGF.Builder.CreateOr(Overflow, TruncOverflow);
 }
 
-Result = CGF.Builder.CreateTrunc(UnsignedResult, ResTy);
+// Negate the product if it would be negative in infinite precision.
+Result = CGF.Builder.CreateSelect(
+IsNegative, CGF.Builder.CreateNeg(UnsignedResult), UnsignedResult);
+
+Result = CGF.Builder.CreateTrunc(Result, ResTy);
   }
   assert(Overflow && Result && "Missing overflow or result");
 
Index: cfe/trunk/test/CodeGen/builtins-overflow.c
===
--- cfe/trunk/test/CodeGen/builtins-overflow.c
+++ cfe/trunk/test/CodeGen/builtins-overflow.c
@@ -373,7 +373,9 @@
 // CHECK-NEXT:  [[NotNull:%.*]] = icmp ne i32 [[UnsignedResult]], 0
 // CHECK-NEXT:  [[Underflow:%.*]] = and i1 [[IsNeg]], [[NotNull]]
 // CHECK-NEXT:  [[OFlow:%.*]] = or i1 [[UnsignedOFlow]], [[Underflow]]
-// CHECK-NEXT:  store i32 [[UnsignedResult]], i32* %{{.*}}, align 4
+// CHECK-NEXT:  [[NegatedResult:%.*]] = sub i32 0, [[UnsignedResult]]
+// CHECK-NEXT:  [[Result:%.*]] = select i1 [[IsNeg]], i32 [[NegatedResult]], 
i32 [[UnsignedResult]]
+// CHECK-NEXT:  store i32 [[Result]], i32* %{{.*}}, align 4
 // CHECK:   br i1 [[OFlow]]
 
   unsigned result;
@@ -432,7 +434,9 @@
 // CHECK-NEXT:  [[OVERFLOW_PRE_TRUNC:%.*]] = or i1 {{.*}}, [[UNDERFLOW]]
 // CHECK-NEXT:  [[TRUNC_OVERFLOW:%.*]] = icmp ugt i64 [[UNSIGNED_RESULT]], 
4294967295
 // CHECK-NEXT:  [[OVERFLOW:%.*]] = or i1 [[OVERFLOW_PRE_TRUNC]], 
[[TRUNC_OVERFLOW]]
-// CHECK-NEXT:  trunc i64 [[UNSIGNED_RESULT]] to i32
+// CHECK-NEXT:  [[NEGATED:%.*]] = sub i64 0, [[UNSIGNED_RESULT]]
+// CHECK-NEXT:  [[RESULT:%.*]] = select i1 {{.*}}, i64 [[NEGATED]], i64 
[[UNSIGNED_RESULT]]
+// CHECK-NEXT:  trunc i64 [[RESULT]] to i32
 // CHECK-NEXT:  store
   unsigned result;
   if (__builtin_mul_overflow(y, x, ))


Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -915,7 +915,11 @@
   Overflow = CGF.Builder.CreateOr(Overflow, TruncOverflow);
 }
 
-Result = CGF.Builder.CreateTrunc(UnsignedResult, ResTy);
+// Negate the product if it would be negative in infinite precision.
+Result = CGF.Builder.CreateSelect(
+IsNegative, CGF.Builder.CreateNeg(UnsignedResult), UnsignedResult);
+
+Result = CGF.Builder.CreateTrunc(Result, ResTy);
   }
   assert(Overflow && Result && "Missing overflow or result");
 
Index: cfe/trunk/test/CodeGen/builtins-overflow.c
===
--- cfe/trunk/test/CodeGen/builtins-overflow.c
+++ cfe/trunk/test/CodeGen/builtins-overflow.c
@@ -373,7 +373,9 @@
 // CHECK-NEXT:  [[NotNull:%.*]] = icmp ne i32 [[UnsignedResult]], 0
 // CHECK-NEXT:  [[Underflow:%.*]] = and i1 [[IsNeg]], [[NotNull]]
 // CHECK-NEXT:  [[OFlow:%.*]] = or i1 [[UnsignedOFlow]], [[Underflow]]
-// CHECK-NEXT:  store i32 [[UnsignedResult]], i32* %{{.*}}, align 4
+// CHECK-NEXT:  [[NegatedResult:%.*]] = sub i32 0, [[UnsignedResult]]
+// CHECK-NEXT:  [[Result:%.*]] = select i1 [[IsNeg]], i32 [[NegatedResult]], i32 [[UnsignedResult]]
+// CHECK-NEXT:  store i32 [[Result]], i32* %{{.*}}, align 4
 // CHECK:   br i1 [[OFlow]]
 
   unsigned result;
@@ -432,7 +434,9 @@
 // CHECK-NEXT:  [[OVERFLOW_PRE_TRUNC:%.*]] = or i1 {{.*}}, [[UNDERFLOW]]
 // CHECK-NEXT:  [[TRUNC_OVERFLOW:%.*]] = icmp ugt i64 [[UNSIGNED_RESULT]], 4294967295
 // CHECK-NEXT:  [[OVERFLOW:%.*]] = or i1 [[OVERFLOW_PRE_TRUNC]], [[TRUNC_OVERFLOW]]
-// CHECK-NEXT:  trunc i64 [[UNSIGNED_RESULT]] to i32
+// CHECK-NEXT:  [[NEGATED:%.*]] = sub i64 0, [[UNSIGNED_RESULT]]
+// CHECK-NEXT:  [[RESULT:%.*]] = select i1 {{.*}}, i64 [[NEGATED]], i64 [[UNSIGNED_RESULT]]
+// CHECK-NEXT:  trunc i64 [[RESULT]] to i32
 // CHECK-NEXT:  store
   unsigned result;
   if (__builtin_mul_overflow(y, x, ))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321771 - [CGBuiltin] Handle unsigned mul overflow properly (PR35750)

2018-01-03 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Wed Jan  3 15:11:32 2018
New Revision: 321771

URL: http://llvm.org/viewvc/llvm-project?rev=321771=rev
Log:
[CGBuiltin] Handle unsigned mul overflow properly (PR35750)

r320902 fixed the IRGen for some types of checked multiplications. It
did not handle unsigned overflow correctly in the case where the signed
operand is negative (PR35750).

Eli pointed out that on overflow, the result must be equal to the unique
value that is equivalent to the mathematically-correct result modulo two
raised to the k power, where k is the number of bits in the result type.

This patch fixes the specialized IRGen from r320902 accordingly.

Testing: Apart from check-clang, I modified the test harness from
r320902 to validate the results of all multiplications -- not just the
ones which don't overflow:

  https://gist.github.com/vedantk/3eb9c88f82e5c32f2e590555b4af5081

llvm.org/PR35750, rdar://34963321

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

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

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=321771=321770=321771=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jan  3 15:11:32 2018
@@ -915,7 +915,11 @@ EmitCheckedMixedSignMultiply(CodeGenFunc
   Overflow = CGF.Builder.CreateOr(Overflow, TruncOverflow);
 }
 
-Result = CGF.Builder.CreateTrunc(UnsignedResult, ResTy);
+// Negate the product if it would be negative in infinite precision.
+Result = CGF.Builder.CreateSelect(
+IsNegative, CGF.Builder.CreateNeg(UnsignedResult), UnsignedResult);
+
+Result = CGF.Builder.CreateTrunc(Result, ResTy);
   }
   assert(Overflow && Result && "Missing overflow or result");
 

Modified: cfe/trunk/test/CodeGen/builtins-overflow.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-overflow.c?rev=321771=321770=321771=diff
==
--- cfe/trunk/test/CodeGen/builtins-overflow.c (original)
+++ cfe/trunk/test/CodeGen/builtins-overflow.c Wed Jan  3 15:11:32 2018
@@ -373,7 +373,9 @@ int test_mixed_sign_mull_overflow_unsign
 // CHECK-NEXT:  [[NotNull:%.*]] = icmp ne i32 [[UnsignedResult]], 0
 // CHECK-NEXT:  [[Underflow:%.*]] = and i1 [[IsNeg]], [[NotNull]]
 // CHECK-NEXT:  [[OFlow:%.*]] = or i1 [[UnsignedOFlow]], [[Underflow]]
-// CHECK-NEXT:  store i32 [[UnsignedResult]], i32* %{{.*}}, align 4
+// CHECK-NEXT:  [[NegatedResult:%.*]] = sub i32 0, [[UnsignedResult]]
+// CHECK-NEXT:  [[Result:%.*]] = select i1 [[IsNeg]], i32 [[NegatedResult]], 
i32 [[UnsignedResult]]
+// CHECK-NEXT:  store i32 [[Result]], i32* %{{.*}}, align 4
 // CHECK:   br i1 [[OFlow]]
 
   unsigned result;
@@ -432,7 +434,9 @@ long long test_mixed_sign_mulll_overflow
 // CHECK-NEXT:  [[OVERFLOW_PRE_TRUNC:%.*]] = or i1 {{.*}}, [[UNDERFLOW]]
 // CHECK-NEXT:  [[TRUNC_OVERFLOW:%.*]] = icmp ugt i64 [[UNSIGNED_RESULT]], 
4294967295
 // CHECK-NEXT:  [[OVERFLOW:%.*]] = or i1 [[OVERFLOW_PRE_TRUNC]], 
[[TRUNC_OVERFLOW]]
-// CHECK-NEXT:  trunc i64 [[UNSIGNED_RESULT]] to i32
+// CHECK-NEXT:  [[NEGATED:%.*]] = sub i64 0, [[UNSIGNED_RESULT]]
+// CHECK-NEXT:  [[RESULT:%.*]] = select i1 {{.*}}, i64 [[NEGATED]], i64 
[[UNSIGNED_RESULT]]
+// CHECK-NEXT:  trunc i64 [[RESULT]] to i32
 // CHECK-NEXT:  store
   unsigned result;
   if (__builtin_mul_overflow(y, x, ))


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


Re: trivial_abi

2018-01-03 Thread John McCall via cfe-commits
> On Jan 3, 2018, at 5:53 PM, Richard Smith  wrote:
> On 3 January 2018 at 14:29, John McCall via cfe-commits 
> > wrote:
> 
>> On Jan 3, 2018, at 5:12 PM, Richard Smith > > wrote:
>> 
>> On 2 January 2018 at 20:55, John McCall via cfe-commits 
>> > wrote:
>>> On Jan 2, 2018, at 10:43 PM, Richard Smith >> > wrote:
>>> 
>>> On 2 January 2018 at 19:02, John McCall via cfe-commits 
>>> > wrote:
>>> 
 On Jan 2, 2018, at 9:15 PM, Akira Hatanaka > wrote:
 
 
 
> On Jan 2, 2018, at 4:56 PM, Richard Smith via cfe-commits 
> > wrote:
> 
> On 2 January 2018 at 15:33, John McCall via cfe-commits 
> > wrote:
> Hey, Richard et al.  Akira and I were talking about the right ABI rule 
> for deciding can-pass-in-registers-ness for structs in the presence of 
> trivial_abi, and I think I like Akira's approach but wanted to get your 
> input.
> 
> The current definition in Itanium is:
> 
>   non-trivial for the purposes of calls <>
>  <>
> A type is considered non-trivial for the purposes of calls if:
> 
> it has a non-trivial copy constructor, move constructor, or destructor, or
>  <>
> I'm assuming we're implicitly excluding deleted functions here. (I'd 
> prefer to make that explicit; this has been the source of a number of ABI 
> mismatches.)
> all of its copy and move constructors are deleted.
>  <>
> 
> I'd suggest modifying this to:
> 
>   A type is considered non-trivial for the purposes of calls if:
>   - if has a copy constructor, move constructor, or destructor 
> which is non-trivial for the purposes of calls, or
>   - all of its copy and move constructors are deleted and it does 
> not have the trivial_abi attribute.
> 
>   A copy/move constructor is considered trivial for the purposes of calls 
> if:
>   - it is user-provided and
>   - the class has the trivial_abi attribute and
>   - a defaulted definition of the constructor would be 
> trivial for the purposes of calls; or
> 
> We'd need to say what happens if the function in question cannot validly 
> be defaulted for any of the reasons in [dcl.fct.def.default]. Do we try 
> to infer whether it's a copy or move constructor, and use the rules for a 
> defaulted copy or move constructor? Or do we just say that's never 
> trivial for the purposes of calls? Or something else? Eg:
> 
> struct [[clang::trivial_abi]] A {
>   A(A && = make());
> };
> 
> Here, A::A(A&&) cannot validly be defaulted. Is A trivial for the purpose 
> of calls? Likewise:
> 
> struct [[clang::trivial_abi]] B {
>   B(...);
> };
> struct C {
>   volatile B b;
> };
> 
> Here, C's copy constructor calls B::B(...). Is C trivial for the purpose 
> of calls? (OK, Clang crashes on that example today. But still...)
> 
> I'd be uncomfortable making the rules in [dcl.fct.def.default] part of 
> the ABI; they seem to be changing relatively frequently. Perhaps we could 
> say "if the function is a copy constructor ([class.copy.ctor]/1), then 
> consider what an implicitly-declared defaulted copy constructor would do; 
> if it's a move constructor ([class.copy.ctor]/2), then consider what an 
> implicitly-declared defaulted move constructor would do; otherwise, it's 
> not trivial for the purpose of calls". That'd mean A is trivial for the 
> purpose of calls and C is not, which I think is probably the right answer.
> 
>   - it is not user-provided and
>   - the class has no virtual functions and no virtual 
> base classes, and
>   - the constructor used to copy/move each direct base 
> class subobject is trivial for the purposes of calls, and
>   - for each non-static data member that is of class type 
> (or array thereof), the constructor selected to copy/move that member is 
> trivial for the purposes of calls.
> 
>   A destructor is considered trivial for the purposes of calls if:
>   - it is not user-provided or the class has the trivial_abi 
> attribute, and
>   - the destructor is not virtual, and
>   - all of the direct base classes of its class have destructors 
> that are trivial for the purposes of calls, and

r321763 - Introduce some infrastructure for adding C attributes with [[]] syntax.

2018-01-03 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Jan  3 14:22:48 2018
New Revision: 321763

URL: http://llvm.org/viewvc/llvm-project?rev=321763=rev
Log:
Introduce some infrastructure for adding C attributes with [[]] syntax.

This patch adds support to the attribute tablegen for specifying a [[]] 
attribute is allowed in C mode. This patch also adds the annotate attribute to 
the list of double square bracket attributes we support in C mode.

Eventually, I anticipate that this logic will be reversed (you have to opt out 
of allowing an attribute in C rather than opting in), but I want to see how the 
design plays out as more attributes are considered.

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/test/Sema/annotate.c
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=321763=321762=321763=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed Jan  3 14:22:48 2018
@@ -231,9 +231,12 @@ class GCC : Spelling. This spelling
-// should be used for any Clang-specific attributes.
-class Clang : Spelling;
+// The Clang spelling implies GNU, CXX11<"clang", name>, and optionally,
+// C2x<"clang", name>. This spelling should be used for any Clang-specific
+// attributes.
+class Clang : Spelling {
+  bit AllowInC = allowInC;
+}
 
 class Accessor spellings> {
   string Name = name;
@@ -618,7 +621,7 @@ def AnalyzerNoReturn : InheritableAttr {
 }
 
 def Annotate : InheritableParamAttr {
-  let Spellings = [Clang<"annotate">];
+  let Spellings = [Clang<"annotate", 1>];
   let Args = [StringArgument<"Annotation">];
   // Ensure that the annotate attribute can be used with
   // '#pragma clang attribute' even though it has no subject list.

Modified: cfe/trunk/test/Sema/annotate.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/annotate.c?rev=321763=321762=321763=diff
==
--- cfe/trunk/test/Sema/annotate.c (original)
+++ cfe/trunk/test/Sema/annotate.c Wed Jan  3 14:22:48 2018
@@ -1,9 +1,13 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -fdouble-square-bracket-attributes -verify
 
 void __attribute__((annotate("foo"))) foo(float *a) {
   __attribute__((annotate("bar"))) int x;
+  [[clang::annotate("bar")]] int x2;
   __attribute__((annotate(1))) int y; // expected-error {{'annotate' attribute 
requires a string}}
+  [[clang::annotate(1)]] int y2; // expected-error {{'annotate' attribute 
requires a string}}
   __attribute__((annotate("bar", 1))) int z; // expected-error {{'annotate' 
attribute takes one argument}}
+  [[clang::annotate("bar", 1)]] int z2; // expected-error {{'annotate' 
attribute takes one argument}}
+
   int u = __builtin_annotation(z, (char*) 0); // expected-error {{second 
argument to __builtin_annotation must be a non-wide string constant}}
   int v = __builtin_annotation(z, (char*) L"bar"); // expected-error {{second 
argument to __builtin_annotation must be a non-wide string constant}}
   int w = __builtin_annotation(z, "foo");

Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=321763=321762=321763=diff
==
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Wed Jan  3 14:22:48 2018
@@ -87,6 +87,8 @@ GetFlattenedSpellings(const Record 
 } else if (Variety == "Clang") {
   Ret.emplace_back("GNU", Name, "", false);
   Ret.emplace_back("CXX11", Name, "clang", false);
+  if (Spelling->getValueAsBit("AllowInC"))
+Ret.emplace_back("C2x", Name, "clang", false);
 } else
   Ret.push_back(FlattenedSpelling(*Spelling));
   }


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


[PATCH] D41317: Infrastructure for adding C attributes

2018-01-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I commit in r321763. I changed the name of `IncludeC` to be `AllowInC` at John 
McCall's suggestion.


https://reviews.llvm.org/D41317



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


[PATCH] D41553: Support parsing double square-bracket attributes in ObjC

2018-01-03 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: include/clang/Basic/Attr.td:239
+  bit IncludeC = includeC;
+}
 

aaron.ballman wrote:
> rjmccall wrote:
> > I have no objection to allowing ObjC attributes to be spelled in 
> > [[clang::objc_whatever]] style.  We can debate giving them a more 
> > appropriate standard name in the objc namespace at a later time — or even 
> > the primary namespace, if we really want to flex our Somewhat Major 
> > Language muscles.
> > 
> > I feel like this IncludeC is not the best name for this tablegen property.  
> > Perhaps AllowInC?
> > 
> > Also, a random positional 1 argument is pretty obscure TableGen design.  Do 
> > we really expect to be making very many attributes that intentionally 
> > disallow C2x?  What would these be, just C++-specific attributes without C 
> > analogues?  It doesn't seem important to prohibit those at the parsing 
> > level rather than at the semantic level, since, after all, we are still 
> > allowing the GNU-style spelling, and these would still qualified with 
> > ``clang::``.
> > 
> > I would suggest standardizing in the opposite direction:  instead of 
> > forcing attributes to opt in to being allowed in C, we should make 
> > attributes that we really don't want to allow in the C2x [[clang::]] 
> > namespace be explicit about it.  If there are a lot of C++-specific 
> > attributes like that, we can make a ClangCXXOnly subclass.
> > I have no objection to allowing ObjC attributes to be spelled in 
> > [[clang::objc_whatever]] style. We can debate giving them a more 
> > appropriate standard name in the objc namespace at a later time — or even 
> > the primary namespace, if we really want to flex our Somewhat Major 
> > Language muscles.
> 
> Thanks -- are you okay with where the attributes are allowed in the syntax? I 
> tried to follow the position they're allowed in C and C++ as closely as I 
> could, but having confirmation would be nice.
> 
> As for putting the attributes in the primary namespace, that would be 
> reasonable for using the attributes in ObjC or ObjC++ but not so much for 
> using the same attributes in a pure C or C++ compilation.
> 
> > I feel like this IncludeC is not the best name for this tablegen property. 
> > Perhaps AllowInC?
> 
> I'm fine with that name. I'll change it in D41317 when I commit that.
> 
> > Also, a random positional 1 argument is pretty obscure TableGen design. Do 
> > we really expect to be making very many attributes that intentionally 
> > disallow C2x? What would these be, just C++-specific attributes without C 
> > analogues? 
> 
> I agree -- I was toying with using a named entity rather than a numeric 
> literal, but I wanted to see how the design shook out in practice once I had 
> a better feel for how many attributes are impacted. I'm glad you recommend 
> going the opposite direction as that was my ultimate goal. :-) Basically, my 
> initial approach is to disallow everything in C and then start enabling the 
> attributes that make sense. At some point, I believe we'll have more 
> attributes in both language modes than not, and then I plan to reverse the 
> meaning of the flag so that an attribute has to opt-out rather than opt-in. I 
> don't expect we'll have many attributes that are disallowed in C2x. I think 
> they'll fall into two categories: C++ attributes that don't make sense in C 
> and attributes that are governed by some other body.
> 
> > It doesn't seem important to prohibit those at the parsing level rather 
> > than at the semantic level, since, after all, we are still allowing the 
> > GNU-style spelling, and these would still qualified with `clang::`.
> 
> I think it's important for C targets when 
> `-fdouble-square-bracket-attributes` is not enabled, as the attributes cannot 
> syntactically appear in those positions.
> 
> > I would suggest standardizing in the opposite direction
> 
> I suspect I will ultimately get there. I chose this approach to be more 
> conservative about what we expose.
> Thanks -- are you okay with where the attributes are allowed in the syntax? I 
> tried to follow the position they're allowed in C and C++ as closely as I 
> could, but having confirmation would be nice.

I'll leave comments on the various places.  For the most part, no, I think 
these are the wrong places; where we allow attributes in ObjC is actually 
pretty carefully thought-out already, and it's better to follow the places 
where we parse GNU attributes than to try to imitate the C grammar.

> As for putting the attributes in the primary namespace, that would be 
> reasonable for using the attributes in ObjC or ObjC++ but not so much for 
> using the same attributes in a pure C or C++ compilation.

Yes, please ignore that.  I was just idly thinking about what we would do if we 
were adopting this feature as a more standard thing, i.e. leaving the 
implementation namespace.  I think we'd want to rename some of the attributes 
for 

[PATCH] D41708: [clang-tidy] Update fuchsia-overloaded-operator to check for valid loc

2018-01-03 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/fuchsia/OverloadedOperatorCheck.cpp:38
+  if (Loc.isValid())
+diag(Loc, "cannot overload %0") << D;
 }

This is not related to the fix, but the warning message is unclear, incorrect 
and confusing: one most certainly _can_ overload these functions, but shouldn't 
do this in fuchsia code due to certain reasons. Ideally, warning messages 
should make it clear to the reader what's wrong with the code, why, and how to 
fix it.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41708



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


[clang-tools-extra] r321762 - [clang-tidy] Update fuchsia-overloaded-operator to check for valid loc

2018-01-03 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Wed Jan  3 14:10:11 2018
New Revision: 321762

URL: http://llvm.org/viewvc/llvm-project?rev=321762=rev
Log:
[clang-tidy] Update fuchsia-overloaded-operator to check for valid loc

Updating fuchsia-overloaded-operator check to not issue warnings for
invalid locations.

Fixes PR35803.

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

Modified:
clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp

Modified: clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp?rev=321762=321761=321762=diff
==
--- clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/fuchsia/OverloadedOperatorCheck.cpp Wed 
Jan  3 14:10:11 2018
@@ -30,8 +30,12 @@ void OverloadedOperatorCheck::registerMa
 }
 
 void OverloadedOperatorCheck::check(const MatchFinder::MatchResult ) {
-  if (const auto *D = Result.Nodes.getNodeAs("decl"))
-diag(D->getLocStart(), "cannot overload %0") << D;
+  const auto *D = Result.Nodes.getNodeAs("decl");
+  assert(D && "No FunctionDecl captured!");
+  
+  SourceLocation Loc = D->getLocStart();
+  if (Loc.isValid())
+diag(Loc, "cannot overload %0") << D;
 }
 
 } // namespace fuchsia

Modified: 
clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp?rev=321762=321761=321762=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/fuchsia-overloaded-operator.cpp Wed 
Jan  3 14:10:11 2018
@@ -16,3 +16,6 @@ public:
 
 A operator-(const A , const A );
 // CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator-' 
[fuchsia-overloaded-operator]
+
+void operator delete(void*, void*) throw();
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: cannot overload 'operator delete' 
[fuchsia-overloaded-operator]


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


Re: trivial_abi

2018-01-03 Thread Richard Smith via cfe-commits
On 2 January 2018 at 20:55, John McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On Jan 2, 2018, at 10:43 PM, Richard Smith  wrote:
>
> On 2 January 2018 at 19:02, John McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> On Jan 2, 2018, at 9:15 PM, Akira Hatanaka  wrote:
>>
>>
>>
>> On Jan 2, 2018, at 4:56 PM, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> On 2 January 2018 at 15:33, John McCall via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Hey, Richard et al.  Akira and I were talking about the right ABI rule
>>> for deciding can-pass-in-registers-ness for structs in the presence of
>>> trivial_abi, and I think I like Akira's approach but wanted to get your
>>> input.
>>>
>>> The current definition in Itanium is:
>>>
>>>   *non-trivial for the purposes of calls*
>>>
>>> A type is considered non-trivial for the purposes of calls if:
>>>
>>>- it has a non-trivial copy constructor, move constructor, or
>>>destructor, or
>>>
>>> I'm assuming we're implicitly excluding deleted functions here. (I'd
>> prefer to make that explicit; this has been the source of a number of ABI
>> mismatches.)
>>
>>>
>>>- all of its copy and move constructors are deleted.
>>>
>>>
>>> I'd suggest modifying this to:
>>>
>>> A type is considered non-trivial for the purposes of calls if:
>>> - if has a copy constructor, move constructor, or destructor which is
>>> non-trivial for the purposes of calls, or
>>> - all of its copy and move constructors are deleted and it does not have
>>> the trivial_abi attribute.
>>>
>>> A copy/move constructor is considered trivial for the purposes of calls
>>> if:
>>> - it is user-provided and
>>> - the class has the trivial_abi attribute and
>>> - a defaulted definition of the constructor would be trivial for the
>>> purposes of calls; or
>>>
>>
>> We'd need to say what happens if the function in question cannot validly
>> be defaulted for any of the reasons in [dcl.fct.def.default]. Do we try to
>> infer whether it's a copy or move constructor, and use the rules for a
>> defaulted copy or move constructor? Or do we just say that's never trivial
>> for the purposes of calls? Or something else? Eg:
>>
>> struct [[clang::trivial_abi]] A {
>>   A(A && = make());
>> };
>>
>> Here, A::A(A&&) cannot validly be defaulted. Is A trivial for the purpose
>> of calls? Likewise:
>>
>> struct [[clang::trivial_abi]] B {
>>   B(...);
>> };
>> struct C {
>>   volatile B b;
>> };
>>
>> Here, C's copy constructor calls B::B(...). Is C trivial for the purpose
>> of calls? (OK, Clang crashes on that example today. But still...)
>>
>> I'd be uncomfortable making the rules in [dcl.fct.def.default] part of
>> the ABI; they seem to be changing relatively frequently. Perhaps we could
>> say "if the function is a copy constructor ([class.copy.ctor]/1), then
>> consider what an implicitly-declared defaulted copy constructor would do;
>> if it's a move constructor ([class.copy.ctor]/2), then consider what an
>> implicitly-declared defaulted move constructor would do; otherwise, it's
>> not trivial for the purpose of calls". That'd mean A is trivial for the
>> purpose of calls and C is not, which I think is probably the right answer.
>>
>> - it is not user-provided and
>>> - the class has no virtual functions and no virtual base classes, and
>>> - the constructor used to copy/move each direct base class subobject is
>>> trivial for the purposes of calls, and
>>> - for each non-static data member that is of class type (or array
>>> thereof), the constructor selected to copy/move that member is trivial for
>>> the purposes of calls.
>>>
>>> A destructor is considered trivial for the purposes of calls if:
>>> - it is not user-provided or the class has the trivial_abi attribute, and
>>> - the destructor is not virtual, and
>>> - all of the direct base classes of its class have destructors that are
>>> trivial for the purposes of calls, and
>>> - for all of the non-static data members of its class that are of class
>>> type (or array thereof), each such class is trivial for the purposes of
>>> calls.
>>>
>>> These definitions are intended to follow [class.copy.ctor]p11 and
>>> [class.dtor]p6 except for the special rules applicable to trivial_abi
>>> classes.
>>>
>>
>> If I could rephrase: a *tor is considered trivial for for the purposes of
>> calls if it is either defaulted or the class has the trivial_abi attribute,
>> and the defaulted definition would satisfy the language rule for being
>> trivial but with the word "trivial" replaced by "trivial for the purposes
>> of calls". So only effect of the trivial_abi attribute is to "undo" the
>> non-triviality implied by a user-provided *tor when computing triviality
>> for the purpose of calls.
>>
>> I think that's a reasonable rule, if we have a satisfactory notion of
>> "defaulted definition".
>>
>> I'm not sure about the "defaulted definition" rule 

[PATCH] D41717: [CGBuiltin] Handle unsigned mul overflow properly (PR35750)

2018-01-03 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D41717



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


Re: trivial_abi

2018-01-03 Thread Richard Smith via cfe-commits
On 3 January 2018 at 14:29, John McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> On Jan 3, 2018, at 5:12 PM, Richard Smith  wrote:
>
> On 2 January 2018 at 20:55, John McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On Jan 2, 2018, at 10:43 PM, Richard Smith  wrote:
>>
>> On 2 January 2018 at 19:02, John McCall via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> On Jan 2, 2018, at 9:15 PM, Akira Hatanaka  wrote:
>>>
>>>
>>>
>>> On Jan 2, 2018, at 4:56 PM, Richard Smith via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>> On 2 January 2018 at 15:33, John McCall via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Hey, Richard et al.  Akira and I were talking about the right ABI rule
 for deciding can-pass-in-registers-ness for structs in the presence of
 trivial_abi, and I think I like Akira's approach but wanted to get your
 input.

 The current definition in Itanium is:

   *non-trivial for the purposes of calls*

 A type is considered non-trivial for the purposes of calls if:

- it has a non-trivial copy constructor, move constructor, or
destructor, or

 I'm assuming we're implicitly excluding deleted functions here. (I'd
>>> prefer to make that explicit; this has been the source of a number of ABI
>>> mismatches.)
>>>

- all of its copy and move constructors are deleted.


 I'd suggest modifying this to:

 A type is considered non-trivial for the purposes of calls if:
 - if has a copy constructor, move constructor, or destructor which is
 non-trivial for the purposes of calls, or
 - all of its copy and move constructors are deleted and it does not
 have the trivial_abi attribute.

 A copy/move constructor is considered trivial for the purposes of calls
 if:
 - it is user-provided and
 - the class has the trivial_abi attribute and
 - a defaulted definition of the constructor would be trivial for the
 purposes of calls; or

>>>
>>> We'd need to say what happens if the function in question cannot validly
>>> be defaulted for any of the reasons in [dcl.fct.def.default]. Do we try to
>>> infer whether it's a copy or move constructor, and use the rules for a
>>> defaulted copy or move constructor? Or do we just say that's never trivial
>>> for the purposes of calls? Or something else? Eg:
>>>
>>> struct [[clang::trivial_abi]] A {
>>>   A(A && = make());
>>> };
>>>
>>> Here, A::A(A&&) cannot validly be defaulted. Is A trivial for the
>>> purpose of calls? Likewise:
>>>
>>> struct [[clang::trivial_abi]] B {
>>>   B(...);
>>> };
>>> struct C {
>>>   volatile B b;
>>> };
>>>
>>> Here, C's copy constructor calls B::B(...). Is C trivial for the purpose
>>> of calls? (OK, Clang crashes on that example today. But still...)
>>>
>>> I'd be uncomfortable making the rules in [dcl.fct.def.default] part of
>>> the ABI; they seem to be changing relatively frequently. Perhaps we could
>>> say "if the function is a copy constructor ([class.copy.ctor]/1), then
>>> consider what an implicitly-declared defaulted copy constructor would do;
>>> if it's a move constructor ([class.copy.ctor]/2), then consider what an
>>> implicitly-declared defaulted move constructor would do; otherwise, it's
>>> not trivial for the purpose of calls". That'd mean A is trivial for the
>>> purpose of calls and C is not, which I think is probably the right answer.
>>>
>>> - it is not user-provided and
 - the class has no virtual functions and no virtual base classes, and
 - the constructor used to copy/move each direct base class subobject is
 trivial for the purposes of calls, and
 - for each non-static data member that is of class type (or array
 thereof), the constructor selected to copy/move that member is trivial for
 the purposes of calls.

 A destructor is considered trivial for the purposes of calls if:
 - it is not user-provided or the class has the trivial_abi attribute,
 and
 - the destructor is not virtual, and
 - all of the direct base classes of its class have destructors that are
 trivial for the purposes of calls, and
 - for all of the non-static data members of its class that are of class
 type (or array thereof), each such class is trivial for the purposes of
 calls.

 These definitions are intended to follow [class.copy.ctor]p11 and
 [class.dtor]p6 except for the special rules applicable to trivial_abi
 classes.

>>>
>>> If I could rephrase: a *tor is considered trivial for for the purposes
>>> of calls if it is either defaulted or the class has the trivial_abi
>>> attribute, and the defaulted definition would satisfy the language rule for
>>> being trivial but with the word "trivial" replaced by "trivial for the
>>> purposes of calls". So only effect of the 

[PATCH] D41545: Replace cp -a in various Clang tests

2018-01-03 Thread Hubert Tong via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321778: Replace cp -a in various Clang tests (authored by 
hubert.reinterpretcast, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41545?vs=128584=128586#toc

Repository:
  rC Clang

https://reviews.llvm.org/D41545

Files:
  test/Modules/crash-vfs-path-emptydir-entries.m
  test/Modules/crash-vfs-path-symlink-component.m
  test/Modules/crash-vfs-path-symlink-topheader.m
  test/Modules/crash-vfs-umbrella-frameworks.m
  test/VFS/umbrella-framework-import-skipnonexist.m


Index: test/VFS/umbrella-framework-import-skipnonexist.m
===
--- test/VFS/umbrella-framework-import-skipnonexist.m
+++ test/VFS/umbrella-framework-import-skipnonexist.m
@@ -5,7 +5,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/vdir %t/outdir %t/cache
-// RUN: cp -a %S/Inputs/Bar.framework %t/outdir/
+// RUN: cp -R %S/Inputs/Bar.framework %t/outdir/
 //
 // RUN: sed -e "s:VDIR:%t/vdir:g" -e "s:OUT_DIR:%t/outdir:g" 
%S/Inputs/bar-headers.yaml > %t/vdir/bar-headers.yaml
 // RUN: rm -f %t/outdir/Bar.framework/Headers/B.h
Index: test/Modules/crash-vfs-path-symlink-component.m
===
--- test/Modules/crash-vfs-path-symlink-component.m
+++ test/Modules/crash-vfs-path-symlink-component.m
@@ -8,7 +8,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t %t/sysroot
-// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/usr %t/i/
 // RUN: ln -s include/tcl-private %t/i/usr/x
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
Index: test/Modules/crash-vfs-umbrella-frameworks.m
===
--- test/Modules/crash-vfs-umbrella-frameworks.m
+++ test/Modules/crash-vfs-umbrella-frameworks.m
@@ -5,7 +5,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t
-// RUN: cp -a %S/Inputs/crash-recovery/Frameworks %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/Frameworks %t/i/
 // RUN: mkdir -p %t/i/Frameworks/A.framework/Frameworks
 // RUN: ln -s ../../B.framework 
%t/i/Frameworks/A.framework/Frameworks/B.framework
 
Index: test/Modules/crash-vfs-path-symlink-topheader.m
===
--- test/Modules/crash-vfs-path-symlink-topheader.m
+++ test/Modules/crash-vfs-path-symlink-topheader.m
@@ -8,7 +8,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t %t/sysroot
-// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/usr %t/i/
 // RUN: rm -f %t/i/usr/include/pthread_impl.h
 // RUN: ln -s pthread/pthread_impl.h %t/i/usr/include/pthread_impl.h
 
Index: test/Modules/crash-vfs-path-emptydir-entries.m
===
--- test/Modules/crash-vfs-path-emptydir-entries.m
+++ test/Modules/crash-vfs-path-emptydir-entries.m
@@ -8,7 +8,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t %t/sysroot
-// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/usr %t/i/
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
 // RUN: %clang -fsyntax-only %s -I %/t/i -isysroot %/t/sysroot/ \


Index: test/VFS/umbrella-framework-import-skipnonexist.m
===
--- test/VFS/umbrella-framework-import-skipnonexist.m
+++ test/VFS/umbrella-framework-import-skipnonexist.m
@@ -5,7 +5,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/vdir %t/outdir %t/cache
-// RUN: cp -a %S/Inputs/Bar.framework %t/outdir/
+// RUN: cp -R %S/Inputs/Bar.framework %t/outdir/
 //
 // RUN: sed -e "s:VDIR:%t/vdir:g" -e "s:OUT_DIR:%t/outdir:g" %S/Inputs/bar-headers.yaml > %t/vdir/bar-headers.yaml
 // RUN: rm -f %t/outdir/Bar.framework/Headers/B.h
Index: test/Modules/crash-vfs-path-symlink-component.m
===
--- test/Modules/crash-vfs-path-symlink-component.m
+++ test/Modules/crash-vfs-path-symlink-component.m
@@ -8,7 +8,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t %t/sysroot
-// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/usr %t/i/
 // RUN: ln -s include/tcl-private %t/i/usr/x
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
Index: test/Modules/crash-vfs-umbrella-frameworks.m
===
--- test/Modules/crash-vfs-umbrella-frameworks.m
+++ test/Modules/crash-vfs-umbrella-frameworks.m
@@ -5,7 +5,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t
-// RUN: cp -a %S/Inputs/crash-recovery/Frameworks %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/Frameworks %t/i/
 // RUN: mkdir -p %t/i/Frameworks/A.framework/Frameworks
 // RUN: ln -s ../../B.framework %t/i/Frameworks/A.framework/Frameworks/B.framework
 
Index: 

r321778 - Replace cp -a in various Clang tests

2018-01-03 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Wed Jan  3 17:15:52 2018
New Revision: 321778

URL: http://llvm.org/viewvc/llvm-project?rev=321778=rev
Log:
Replace cp -a in various Clang tests

Summary:
cp -a is neither part of POSIX nor the LSB. The nearest equivalent under
POSIX is cp -RPp; however, cp -R is sufficient for the intended purpose.

test/Modules/crash-vfs-headermaps.m is not updated since it requires
system-darwin anyway.

Reviewers: bruno

Reviewed By: bruno

Subscribers: bruno, rcraik, cfe-commits

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

Modified:
cfe/trunk/test/Modules/crash-vfs-path-emptydir-entries.m
cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
cfe/trunk/test/Modules/crash-vfs-path-symlink-topheader.m
cfe/trunk/test/Modules/crash-vfs-umbrella-frameworks.m
cfe/trunk/test/VFS/umbrella-framework-import-skipnonexist.m

Modified: cfe/trunk/test/Modules/crash-vfs-path-emptydir-entries.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-emptydir-entries.m?rev=321778=321777=321778=diff
==
--- cfe/trunk/test/Modules/crash-vfs-path-emptydir-entries.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-path-emptydir-entries.m Wed Jan  3 
17:15:52 2018
@@ -8,7 +8,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t %t/sysroot
-// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/usr %t/i/
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
 // RUN: %clang -fsyntax-only %s -I %/t/i -isysroot %/t/sysroot/ \

Modified: cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m?rev=321778=321777=321778=diff
==
--- cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m Wed Jan  3 
17:15:52 2018
@@ -8,7 +8,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t %t/sysroot
-// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/usr %t/i/
 // RUN: ln -s include/tcl-private %t/i/usr/x
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \

Modified: cfe/trunk/test/Modules/crash-vfs-path-symlink-topheader.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-symlink-topheader.m?rev=321778=321777=321778=diff
==
--- cfe/trunk/test/Modules/crash-vfs-path-symlink-topheader.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-path-symlink-topheader.m Wed Jan  3 
17:15:52 2018
@@ -8,7 +8,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t %t/sysroot
-// RUN: cp -a %S/Inputs/crash-recovery/usr %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/usr %t/i/
 // RUN: rm -f %t/i/usr/include/pthread_impl.h
 // RUN: ln -s pthread/pthread_impl.h %t/i/usr/include/pthread_impl.h
 

Modified: cfe/trunk/test/Modules/crash-vfs-umbrella-frameworks.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-umbrella-frameworks.m?rev=321778=321777=321778=diff
==
--- cfe/trunk/test/Modules/crash-vfs-umbrella-frameworks.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-umbrella-frameworks.m Wed Jan  3 17:15:52 
2018
@@ -5,7 +5,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/i %t/m %t
-// RUN: cp -a %S/Inputs/crash-recovery/Frameworks %t/i/
+// RUN: cp -R %S/Inputs/crash-recovery/Frameworks %t/i/
 // RUN: mkdir -p %t/i/Frameworks/A.framework/Frameworks
 // RUN: ln -s ../../B.framework 
%t/i/Frameworks/A.framework/Frameworks/B.framework
 

Modified: cfe/trunk/test/VFS/umbrella-framework-import-skipnonexist.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/VFS/umbrella-framework-import-skipnonexist.m?rev=321778=321777=321778=diff
==
--- cfe/trunk/test/VFS/umbrella-framework-import-skipnonexist.m (original)
+++ cfe/trunk/test/VFS/umbrella-framework-import-skipnonexist.m Wed Jan  3 
17:15:52 2018
@@ -5,7 +5,7 @@
 
 // RUN: rm -rf %t
 // RUN: mkdir -p %t/vdir %t/outdir %t/cache
-// RUN: cp -a %S/Inputs/Bar.framework %t/outdir/
+// RUN: cp -R %S/Inputs/Bar.framework %t/outdir/
 //
 // RUN: sed -e "s:VDIR:%t/vdir:g" -e "s:OUT_DIR:%t/outdir:g" 
%S/Inputs/bar-headers.yaml > %t/vdir/bar-headers.yaml
 // RUN: rm -f %t/outdir/Bar.framework/Headers/B.h


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


r321779 - PR35045: Convert injected-class-name to its corresponding simple-template-id

2018-01-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jan  3 17:24:17 2018
New Revision: 321779

URL: http://llvm.org/viewvc/llvm-project?rev=321779=rev
Log:
PR35045: Convert injected-class-name to its corresponding simple-template-id
during template argument deduction.

We already did this when the injected-class-name was in P, but missed the case
where it was in A. This (probably) can't happen except in implicit deduction
guides.

Modified:
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp?rev=321779=321778=321779=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp Wed Jan  3 17:24:17 2018
@@ -502,6 +502,10 @@ DeduceTemplateArguments(Sema ,
 SmallVectorImpl ) {
   assert(Arg.isCanonical() && "Argument type must be canonical");
 
+  // Treat an injected-class-name as its underlying template-id.
+  if (auto *Injected = dyn_cast(Arg))
+Arg = Injected->getInjectedSpecializationType();
+
   // Check whether the template argument is a dependent template-id.
   if (const TemplateSpecializationType *SpecArg
 = dyn_cast(Arg)) {

Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=321779=321778=321779=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp 
(original)
+++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Wed Jan  
3 17:24:17 2018
@@ -309,6 +309,17 @@ namespace dependent {
   template int New(int);
 }
 
+namespace injected_class_name {
+  template struct A {
+A();
+template A(A);
+  };
+  A a;
+  A b = a;
+  using T = decltype(a);
+  using T = decltype(b);
+}
+
 #else
 
 // expected-no-diagnostics


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


r321781 - [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

2018-01-03 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jan  3 18:17:40 2018
New Revision: 321781

URL: http://llvm.org/viewvc/llvm-project?rev=321781=rev
Log:
[Modules] Allow modules specified by -fmodule-map-file to shadow implicitly 
found ones

When modules come from module map files explicitly specified by
-fmodule-map-file= arguments, allow those to override/shadow modules
with the same name that are found implicitly by header search. If such a
module is looked up by name (e.g. @import), we will always find the one
from -fmodule-map-file. If we try to use a shadowed module by including
one of its headers report an error.

This enables developers to force use of a specific copy of their module
to be used if there are multiple copies that would otherwise be visible,
for example if they develop modules that are installed in the default
search paths.

Patch originally by Ben Langmuir,
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20151116/143425.html

Based on cfe-dev discussion:
http://lists.llvm.org/pipermail/cfe-dev/2015-November/046164.html

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

rdar://problem/23612102

Added:
cfe/trunk/test/Modules/Inputs/shadow/
cfe/trunk/test/Modules/Inputs/shadow/A1/
cfe/trunk/test/Modules/Inputs/shadow/A1/A.h
cfe/trunk/test/Modules/Inputs/shadow/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadow/A2/
cfe/trunk/test/Modules/Inputs/shadow/A2/A.h
cfe/trunk/test/Modules/Inputs/shadow/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/Foo/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/Foo/module.modulemap
cfe/trunk/test/Modules/shadow.m
cfe/trunk/test/Modules/shadowed-submodule.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=321781=321780=321781=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Wed Jan  3 18:17:40 
2018
@@ -94,6 +94,9 @@ def remark_module_lock_failure : Remark<
   "could not acquire lock file for module '%0': %1">, InGroup;
 def remark_module_lock_timeout : Remark<
   "timed out waiting to acquire lock file for module '%0'">, 
InGroup;
+def err_module_shadowed : Error<"import of shadowed module '%0'">, 
DefaultFatal;
+def err_module_build_shadowed_submodule : Error<
+  "build a shadowed submodule '%0'">, DefaultFatal;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 
   DefaultFatal;
 def err_module_prebuilt : Error<

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=321781=321780=321781=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Wed Jan  3 18:17:40 2018
@@ -197,6 +197,9 @@ public:
   /// will be false to indicate that this (sub)module is not available.
   SmallVector Requirements;
 
+  /// \brief A module with the same name that shadows this module.
+  Module *ShadowingModule = nullptr;
+
   /// \brief Whether this module is missing a feature from \c Requirements.
   unsigned IsMissingRequirement : 1;
 
@@ -375,13 +378,20 @@ public:
   ///
   /// \param Target The target options used for the current translation unit.
   ///
-  /// \param Req If this module is unavailable, this parameter
-  /// will be set to one of the requirements that is not met for use of
-  /// this module.
+  /// \param Req If this module is unavailable because of a missing 
requirement,
+  /// this parameter will be set to one of the requirements 

[PATCH] D31269: [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

2018-01-03 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

> It might make more sense to have the module loaded from the AST file shadow 
> the module from the module map, especially for an explicit module build, now 
> that we have that functionality.)

+1, seems a much more consistent model.




Comment at: lib/Lex/ModuleMap.cpp:2574-2575
 
+  llvm::SaveAndRestore OldExplicit(CurrentModuleMapIsExplicitlyProvided);
+  CurrentModuleMapIsExplicitlyProvided |= IsExplicitlyProvided;
+

rsmith wrote:
> It would seem cleaner to make this a member of `ModuleMapParser` (and 
> explicitly pass down the flag when parsing an `extern module` declaration). 
> Is there a reason to use (essentially) global state for this?
I don't believe there's any reason for using a global state here (and Ben 
doesn't recall any specific reason either). I changed the patch to pass down 
the flag and it works fine.


https://reviews.llvm.org/D31269



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


Re: [PATCH] D41039: Add support for attribute "trivial_abi"

2018-01-03 Thread John McCall via cfe-commits
On Wed, Jan 3, 2018 at 2:07 PM, Akira Hatanaka  wrote:

> On Jan 3, 2018, at 10:25 AM, John McCall  wrote:
>
> On Wed, Jan 3, 2018 at 12:24 PM, Akira Hatanaka 
> wrote:
>
>> On Jan 2, 2018, at 9:42 AM, David Blaikie via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>
>>
>> On Tue, Dec 19, 2017 at 9:43 PM Akira Hatanaka 
>> wrote:
>>
>>> On Tue, Dec 12, 2017 at 12:12 PM, John McCall  wr
>>> ote:
>>>
 On Tue, Dec 12, 2017 at 1:45 PM, David Blaikie  w
 rote:

> On Mon, Dec 11, 2017 at 5:38 PM John McCall 
> wrote:
>
>> On Mon, Dec 11, 2017 at 6:19 PM, David Blaikie  w
>> rote:
>>
>>> On Mon, Dec 11, 2017 at 3:16 PM John McCall via Phabricator <
>>> revi...@reviews.llvm.org> wrote:
>>>
 rjmccall added a comment.

 In https://reviews.llvm.org/D41039#951648, @ahatanak wrote:

 > I had a discussion with Duncan today and he pointed out that
 perhaps we shouldn't allow users to annotate a struct with 
 "trivial_abi" if
 one of its subobjects is non-trivial and is not annotated with
 "trivial_abi" since that gives users too much power.
 >
 > Should we error out or drop "trivial_abi" from struct Outer when
 the following code is compiled?
 >
 >   struct Inner1 {
 > ~Inner1(); // non-trivial
 > int x;
 >   };
 >
 >   struct __attribute__((trivial_abi)) Outer {
 > ~Outer();
 > Inner1 x;
 >   };
 >
 >
 > The current patch doesn't error out or drop the attribute, but
 the patch would probably be much simpler if we didn't allow it.


 I think it makes sense to emit an error if there is provably a
 non-trivial-ABI component.  However, for class temploids I think that
 diagnostic should only fire on the definition, not on instantiations; 
 for
 example:

   template  struct __attribute__((trivial_abi)) holder {
  T value;
  ~holder() {}
   };
   holder hs; // this instantiation should be legal
 despite the fact that holder cannot be trivial-ABI.

 But we should still be able to emit the diagnostic in template
 definitions, e.g.:

   template  struct __attribute__((trivial_abi))
 named_holder {
  std::string name; // there are no instantiations of this
 template that could ever be trivial-ABI
  T value;
  ~named_holder() {}
   };

 The wording should be something akin to the standard template rule
 that a template is ill-formed if it has no valid instantiations, no
 diagnostic required.

 I would definitely like to open the conversation about the name of
 the attribute.  I don't think we've used "abi" in an existing attribute
 name; usually it's more descriptive.  And "trivial" is a weighty word 
 in
 the standard.  I'm not sure I have a great counter-proposal off the 
 top of
 my head, though.

>>>
>>> Agreed on both counts (would love a better name, don't have any
>>> stand-out candidates off the top of my head).
>>>
>>> I feel like a more descriptive term about the property of the object
>>> would make me happier - something like "address_independent_identity"
>>> (s/identity/value/?) though, yeah, that's not spectacular by any 
>>> stretch.
>>>
>>
>> Incidentally, your comments are not showing up on Phabricator for
>> some reason.
>>
>
> Yeah, Phab doesn't do a great job looking on the mailing list for
> interesting replies - I forget, maybe it only catches bottom post or top
> post but not infix replies or something...
>

 Well, fortunately the mailing list is also archived. :)


> The term "trivially movable" suggests itself, with two caveats:
>>   - What we're talking about is trivial *destructive* movability,
>> i.e. that the combination of moving the value to a new object and not
>> destroying the old object can be done trivially, which is not quite the
>> same as trivial movability in the normal C++ sense, which I guess could 
>> be
>> a property that someone theoretically might care about (if the type is
>> trivially destructed, but it isn't copyable for semantic reasons?).
>>   - Trivial destructive movability is a really common property, and
>> it's something that a compiler would really like to optimize based on 
>> even
>> in cases where trivial_abi can't be adopted for binary-compatibility
>> reasons.  Stealing the 

[PATCH] D40819: Implement Attribute Target MultiVersioning (Improved edition!)

2018-01-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Lots of comments, but no high-level design concerns. I think this is very close 
to being ready to go.




Comment at: include/clang/AST/Decl.h:2162-2168
+  /// Sets the multiversion state for this declaration and all of its
+  /// redeclarations.
+  void setIsMultiVersion(bool V = true) {
+IsMultiVersion = V;
+for (FunctionDecl *FD : redecls())
+  FD->IsMultiVersion = V;
+  }

Instead of looping over redeclarations here, how about only storing the flag on 
the canonical declaration (and only looking there in `isMultiVersion`)?



Comment at: include/clang/Basic/Attr.td:1809
   bool DuplicateArchitecture = false;
+  bool operator==(const ParsedTargetAttr ) {
+return DuplicateArchitecture == Other.DuplicateArchitecture &&

aaron.ballman wrote:
> This function should be marked `const`.
Nit: space before `{`.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9319-9320
+def err_target_required_in_redecl : Error<
+  "function declaration is missing 'target' attribute in a multiversioned "
+  "function">;
+def note_multiversioning_caused_here : Note<

Is it "multiversion function" or "multiversioned function"? You're using both 
in these diagnostics; please pick one and use it consistently. I prefer the 
"-ed" form, but I'm happy with whichever you'd prefer.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9322
+def note_multiversioning_caused_here : Note<
+  "function multiversion caused by this declaration">;
+def err_multiversion_after_used : Error<

"multiversioning" maybe? (Again, this is used inconsistently; there's a 
"function multiversioning" in err_multiversion_not_supported).



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9329-9331
+def note_ovl_candidate_nondefault_multiversion : Note<
+  "candidate ignored: non-default multiversion function cannot be called "
+  "directly">;

Maybe we should just suppress the "candidate" note entirely for these cases?



Comment at: lib/CodeGen/CodeGenModule.cpp:2144
+if (getContext().hasSameType(CurFD->getType(), FD->getType())) {
+  StringRef MangledName = getMangledName(CurFD);
+  llvm::Constant *Func = GetGlobalValue(MangledName);

erichkeane wrote:
> rsmith wrote:
> > You should skip functions you've already seen somewhere around here; we 
> > don't need to handle the same function multiple times.
> Will the lookup call give me duplicates?  I need to check each at least once 
> through this so that I can put them into "Options" so that I can emit them 
> during the resolver.  
> 
> Otherwise, I'm not terribly sure what you mean.
Yes, the lookup can in some cases find multiple declarations from the same 
redeclaration chain. (This happens particularly when the declarations are 
loaded from AST files.)



Comment at: lib/CodeGen/CodeGenModule.cpp:840-841
+
+  const auto *ND = cast(GD.getDecl());
+  UpdateMultiVersionNames(GD, ND);
+

I'm not especially enamoured with `getMangledName` mutating the IR. Can we 
perform this rename as part of emitting the multiversion dispatcher or ifunc, 
rather than here? (Or do we really not have anywhere else that this can live?)



Comment at: lib/CodeGen/CodeGenModule.cpp:2056-2057
   const auto *F = cast(GD.getDecl());
+  if (F->isMultiVersion())
+return true;
   if (CodeGenOpts.OptimizationLevel == 0 && !F->hasAttr())

Please add a comment explaining this check. (I'm guessing the issue is that we 
can't form a cross-translation-unit reference to the right function from an 
IFUNC, so we can't rely on an available_externally definition actually being 
usable? But it's not clear to me that this is the right resolution to that, 
especially in light of the dllexport case below where it would not be correct 
to emit the definition.)



Comment at: lib/CodeGen/CodeGenModule.cpp:2140-2143
+for (auto *CurDecl : FD->getDeclContext()->getRedeclContext()->lookup(
+ FD->getDeclName())) {
+  if (const auto *CurFD = dyn_cast(CurDecl))
+if (getContext().hasSameType(CurFD->getType(), FD->getType())) {

Consider moving the lookup, loop and type check here into an ASTContext or 
FunctionDecl utility to find or visit all the versions of a multiversioned 
function.



Comment at: lib/CodeGen/CodeGenModule.cpp:2142
+ FD->getDeclName())) {
+  if (const auto *CurFD = dyn_cast(CurDecl))
+if (getContext().hasSameType(CurFD->getType(), FD->getType())) {

`if` statements with nontrivial bodies should have their own braces.



Comment at: lib/Sema/SemaDecl.cpp:9526
+  S.Diag(NewFD->getLocation(), diag::err_multiversion_not_supported);
+  

[PATCH] D41629: [libcxx] Improve accuracy of complex asinh and acosh

2018-01-03 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added inline comments.



Comment at: 
test/std/numerics/complex.number/complex.transcendentals/acosh.pass.cpp:59
+{
+assert(r.real() == 0);
+assert(!std::signbit(r.real()));

Ideally, I would prefer some approximate comparison instead of `==` here, but 
`is_about` is not suitable for arguments that have zero or near-zero sum. 
That's why I used exact comparison (several other cases in this file do the 
same). This test passes on x86_64, so hopefully it will work the same way in 
any IEEE-compliant environment.


https://reviews.llvm.org/D41629



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


[PATCH] D41517: mmintrin.h documentation fixes and updates

2018-01-03 Thread Katya Romanova via Phabricator via cfe-commits
kromanova added inline comments.



Comment at: lib/Headers/mmintrin.h:1292
 ///
-/// This intrinsic corresponds to the  VXORPS / XORPS  instruction.
+/// This intrinsic corresponds to the  XOR  instruction.
 ///

craig.topper wrote:
> PXOR?
For which platform/compiler? 
 
I checked, for x86_64 Linux XORPS(no avx)/VXORPS (with -mavx) is generated.
For PS4 we generate XORL.

I guess, we need to write something more generic, implying that an appropriate 
platform-specific XOR instruction is generated. 



Comment at: lib/Headers/mmintrin.h:1384
 ///
-/// This intrinsic corresponds to the  VPSHUFD / PSHUFD  instruction.
+/// This intrinsic corresponds to the  PSHUFD  instruction.
 ///

craig.topper wrote:
> This is overly specific there is no guarantee we'd use those instructions. If 
> it was a constant we'd probably just use a load.
That's right. I think we should use the following wording to match other 
_mm_set* intrinsics documentation in this file.

/// This intrinsic is a utility function and does not correspond to a specific
///instruction.



https://reviews.llvm.org/D41517



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


[PATCH] D31269: [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

2018-01-03 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321781: [Modules] Allow modules specified by 
-fmodule-map-file to shadow implicitly… (authored by bruno, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D31269?vs=92738=128590#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31269

Files:
  cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
  cfe/trunk/include/clang/Basic/Module.h
  cfe/trunk/include/clang/Lex/HeaderSearch.h
  cfe/trunk/include/clang/Lex/ModuleMap.h
  cfe/trunk/lib/Basic/Module.cpp
  cfe/trunk/lib/Lex/HeaderSearch.cpp
  cfe/trunk/lib/Lex/ModuleMap.cpp
  cfe/trunk/lib/Lex/PPDirectives.cpp
  cfe/trunk/test/Modules/Inputs/shadow/A1/A.h
  cfe/trunk/test/Modules/Inputs/shadow/A1/module.modulemap
  cfe/trunk/test/Modules/Inputs/shadow/A2/A.h
  cfe/trunk/test/Modules/Inputs/shadow/A2/module.modulemap
  cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/Foo.h
  cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/module.modulemap
  cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A.h
  cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A2.h
  cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/Foo.h
  cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/module.modulemap
  cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A.h
  cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A2.h
  cfe/trunk/test/Modules/Inputs/shadowed-submodule/Foo/module.modulemap
  cfe/trunk/test/Modules/shadow.m
  cfe/trunk/test/Modules/shadowed-submodule.m

Index: cfe/trunk/include/clang/Lex/ModuleMap.h
===
--- cfe/trunk/include/clang/Lex/ModuleMap.h
+++ cfe/trunk/include/clang/Lex/ModuleMap.h
@@ -195,6 +195,17 @@
   /// header.
   llvm::DenseMap UmbrellaDirs;
 
+  /// \brief The set of modules provided explicitly (e.g. by -fmodule-map-file),
+  /// which are allowed to shadow other implicitly discovered modules.
+  llvm::DenseSet ExplicitlyProvidedModules;
+
+  bool mayShadowModuleBeingParsed(Module *ExistingModule,
+  bool IsExplicitlyProvided) {
+assert(!ExistingModule->Parent && "expected top-level module");
+return !IsExplicitlyProvided &&
+   ExplicitlyProvidedModules.count(ExistingModule);
+  }
+
   /// \brief The set of attributes that can be attached to a module.
   struct Attributes {
 /// \brief Whether this is a system module.
@@ -475,9 +486,9 @@
   ///
   /// \returns The found or newly-created module, along with a boolean value
   /// that will be true if the module is newly-created.
-  std::pair findOrCreateModule(StringRef Name, Module *Parent,
-   bool IsFramework,
-   bool IsExplicit);
+  std::pair
+  findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework,
+ bool IsExplicit, bool UsesExplicitModuleMapFile = false);
 
   /// \brief Create a 'global module' for a C++ Modules TS module interface
   /// unit.
@@ -502,6 +513,11 @@
   Module *inferFrameworkModule(const DirectoryEntry *FrameworkDir,
bool IsSystem, Module *Parent);
 
+  /// \brief Create a new top-level module that is shadowed by
+  /// \p ShadowingModule.
+  Module *createShadowedModule(StringRef Name, bool IsFramework,
+   Module *ShadowingModule);
+
   /// \brief Retrieve the module map file containing the definition of the given
   /// module.
   ///
@@ -587,6 +603,8 @@
   /// \brief Marks this header as being excluded from the given module.
   void excludeHeader(Module *Mod, Module::Header Header);
 
+  void setExplicitlyProvided(Module *Mod);
+
   /// \brief Parse the given module map file, and record any modules we 
   /// encounter.
   ///
@@ -606,10 +624,15 @@
   /// \param ExternModuleLoc The location of the "extern module" declaration
   ///that caused us to load this module map file, if any.
   ///
+  /// \param IsExplicitlyProvided Whether this module map file was provided
+  /// explicitly by the user (e.g. -fmodule-map-file), rather than found
+  /// implicitly.
+  ///
   /// \returns true if an error occurred, false otherwise.
   bool parseModuleMapFile(const FileEntry *File, bool IsSystem,
-  const DirectoryEntry *HomeDir, FileID ID = FileID(),
-  unsigned *Offset = nullptr,
+  const DirectoryEntry *HomeDir,
+  bool IsExplicitlyProvided = false,
+  FileID ID = FileID(), unsigned *Offset = nullptr,
   SourceLocation ExternModuleLoc = SourceLocation());
 
   /// \brief Dump the contents of the module map, for debugging purposes.
Index: cfe/trunk/include/clang/Lex/HeaderSearch.h
===
--- cfe/trunk/include/clang/Lex/HeaderSearch.h
+++ 

[PATCH] D40819: Implement Attribute Target MultiVersioning (Improved edition!)

2018-01-03 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

Couple of inline comments, otherwise I'm pretty happy. I'd wait for an ack by 
Richard for this though.

-eric




Comment at: lib/CodeGen/CGBuiltin.cpp:7673
 
-Value *CodeGenFunction::EmitX86CpuInit() {
+Value *CodeGenFunction::EmitX86CpuInit(CGBuilderTy ) {
   llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy,

Why do you need to pass in a Builder?



Comment at: lib/CodeGen/CodeGenFunction.cpp:2324
+  llvm::Triple::x86_64) &&
+ "Only implemented for x86 targets");
+

Can you get here via trying to compile code for another cpu?


https://reviews.llvm.org/D40819



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


Re: [PATCH] D41039: Add support for attribute "trivial_abi"

2018-01-03 Thread Akira Hatanaka via cfe-commits

> On Jan 3, 2018, at 6:39 PM, John McCall  wrote:
> 
> On Wed, Jan 3, 2018 at 2:07 PM, Akira Hatanaka  > wrote:
>> On Jan 3, 2018, at 10:25 AM, John McCall > > wrote:
>> 
>> On Wed, Jan 3, 2018 at 12:24 PM, Akira Hatanaka > > wrote:
>>> On Jan 2, 2018, at 9:42 AM, David Blaikie via cfe-commits 
>>> > wrote:
>>> 
>>> 
>>> 
>>> On Tue, Dec 19, 2017 at 9:43 PM Akira Hatanaka >> > wrote:
>>> On Tue, Dec 12, 2017 at 12:12 PM, John McCall >> > wrote:
>>> On Tue, Dec 12, 2017 at 1:45 PM, David Blaikie >> > wrote:
>>> On Mon, Dec 11, 2017 at 5:38 PM John McCall >> > wrote:
>>> On Mon, Dec 11, 2017 at 6:19 PM, David Blaikie >> > wrote:
>>> On Mon, Dec 11, 2017 at 3:16 PM John McCall via Phabricator 
>>> > wrote:
>>> rjmccall added a comment.
>>> 
>>> In https://reviews.llvm.org/D41039#951648 
>>> , @ahatanak wrote:
>>> 
>>> > I had a discussion with Duncan today and he pointed out that perhaps we 
>>> > shouldn't allow users to annotate a struct with "trivial_abi" if one of 
>>> > its subobjects is non-trivial and is not annotated with "trivial_abi" 
>>> > since that gives users too much power.
>>> >
>>> > Should we error out or drop "trivial_abi" from struct Outer when the 
>>> > following code is compiled?
>>> >
>>> >   struct Inner1 {
>>> > ~Inner1(); // non-trivial
>>> > int x;
>>> >   };
>>> >
>>> >   struct __attribute__((trivial_abi)) Outer {
>>> > ~Outer();
>>> > Inner1 x;
>>> >   };
>>> >
>>> >
>>> > The current patch doesn't error out or drop the attribute, but the patch 
>>> > would probably be much simpler if we didn't allow it.
>>> 
>>> 
>>> I think it makes sense to emit an error if there is provably a 
>>> non-trivial-ABI component.  However, for class temploids I think that 
>>> diagnostic should only fire on the definition, not on instantiations; for 
>>> example:
>>> 
>>>   template  struct __attribute__((trivial_abi)) holder {
>>>  T value;
>>>  ~holder() {}
>>>   };
>>>   holder hs; // this instantiation should be legal despite the 
>>> fact that holder cannot be trivial-ABI.
>>> 
>>> But we should still be able to emit the diagnostic in template definitions, 
>>> e.g.:
>>> 
>>>   template  struct __attribute__((trivial_abi)) named_holder {
>>>  std::string name; // there are no instantiations of this template that 
>>> could ever be trivial-ABI
>>>  T value;
>>>  ~named_holder() {}
>>>   };
>>> 
>>> The wording should be something akin to the standard template rule that a 
>>> template is ill-formed if it has no valid instantiations, no diagnostic 
>>> required.
>>> 
>>> I would definitely like to open the conversation about the name of the 
>>> attribute.  I don't think we've used "abi" in an existing attribute name; 
>>> usually it's more descriptive.  And "trivial" is a weighty word in the 
>>> standard.  I'm not sure I have a great counter-proposal off the top of my 
>>> head, though.
>>> 
>>> Agreed on both counts (would love a better name, don't have any stand-out 
>>> candidates off the top of my head).
>>> 
>>> I feel like a more descriptive term about the property of the object would 
>>> make me happier - something like "address_independent_identity" 
>>> (s/identity/value/?) though, yeah, that's not spectacular by any stretch.
>>> 
>>> Incidentally, your comments are not showing up on Phabricator for some 
>>> reason.
>>> 
>>> Yeah, Phab doesn't do a great job looking on the mailing list for 
>>> interesting replies - I forget, maybe it only catches bottom post or top 
>>> post but not infix replies or something... 
>>> 
>>> Well, fortunately the mailing list is also archived. :)
>>> 
>>> 
>>> The term "trivially movable" suggests itself, with two caveats:
>>>   - What we're talking about is trivial *destructive* movability, i.e. that 
>>> the combination of moving the value to a new object and not destroying the 
>>> old object can be done trivially, which is not quite the same as trivial 
>>> movability in the normal C++ sense, which I guess could be a property that 
>>> someone theoretically might care about (if the type is trivially 
>>> destructed, but it isn't copyable for semantic reasons?).
>>>   - Trivial destructive movability is a really common property, and it's 
>>> something that a compiler would really like to optimize based on even in 
>>> cases where trivial_abi can't be adopted for binary-compatibility reasons.  
>>> Stealing the term for the stronger property 

[PATCH] D38320: [clang] Fix serializers for `TypeTemplateParmDecl` + related types

2018-01-03 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande updated this revision to Diff 128593.
elsteveogrande added a comment.

Update: now works properly with modules as well.

This needed to handle the case where a `ParmDecl` is already inheriting, but 
it's innocuously inheriting from the same decl.  Now 
`inheritDefaultTemplateArgument` will return successfully and avoid the 
assertion error saying that `default argument already inherited`.

We'll now possibly step once or twice through the inheritance list, so when a 
`ParmDecl` is inheriting from another `ParmDecl`, which *itself* is inheriting 
from a third decl.  This is the case where `inheritDefaultTemplateArgument` is 
called with `From` being an inheriting (and not "owning") template parameter.

Modules make use of the `Chain` struct as well, and IIUC this can lead to one 
extra level of indirection, as it too has a `ParmDecl *` field.  So this now 
handles up to 2 indirections before validating that the inheritance is 
consistent.

Passes existing and new tests; also works with a mini project that uses 
modules, which was previously broken.


Repository:
  rC Clang

https://reviews.llvm.org/D38320

Files:
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/PCH/cxx-templates.cpp
  test/PCH/cxx-templates.h

Index: test/PCH/cxx-templates.h
===
--- test/PCH/cxx-templates.h
+++ test/PCH/cxx-templates.h
@@ -361,3 +361,38 @@
 namespace MemberSpecializationLocation {
   template struct A { static int n; };
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=34728
+namespace PR34728 {
+
+// case 1: defaulted `NonTypeTemplateParmDecl`, non-defaulted 2nd tpl param
+template 
+int func1(T const &);
+
+template 
+int func1(T const &) {
+  return foo;
+}
+
+// case 2: defaulted `TemplateTypeParmDecl`, non-defaulted 2nd tpl param
+template 
+A func2(B const &);
+
+template 
+A func2(B const &) {
+  return A(20.0f);
+}
+
+// case 3: defaulted `TemplateTemplateParmDecl`, non-defaulted 2nd tpl param
+template 
+struct Container { T const  };
+
+template  class C = Container, class D>
+C func3(D const &);
+
+template  class C, class D>
+C func3(D const ) {
+  return Container{d};
+}
+
+} // end namespace PR34728
Index: test/PCH/cxx-templates.cpp
===
--- test/PCH/cxx-templates.cpp
+++ test/PCH/cxx-templates.cpp
@@ -116,3 +116,19 @@
 #endif
   int k = A::n;
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=34728
+namespace PR34728 {
+int test() {
+  // Verify with several TemplateParmDecl kinds, using PCH (incl. modules).
+  int z1 = func1(/*ignored*/2.718);
+  int z2 = func2(/*ignored*/3.142);
+  int tmp3 = 30;
+  Container c = func3(tmp3);
+  int z3 = c.item;
+
+  // Return value is meaningless.  Just "use" all these values to avoid
+  // warning about unused vars / values.
+  return z1 + z2 + z3;
+}
+} // end namespace PR34728
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -1542,11 +1542,24 @@
 
   Record.push_back(D->wasDeclaredWithTypename());
 
-  bool OwnsDefaultArg = D->hasDefaultArgument() &&
-!D->defaultArgumentWasInherited();
-  Record.push_back(OwnsDefaultArg);
-  if (OwnsDefaultArg)
-Record.AddTypeSourceInfo(D->getDefaultArgumentInfo());
+  TypeSourceInfo *OwnedDefaultArg = nullptr;
+  Decl const *InheritsFromDecl = nullptr;
+  if (D->hasDefaultArgument()) {
+if (D->defaultArgumentWasInherited()) {
+  InheritsFromDecl = D->getDefaultArgStorage().getInheritedFrom();
+} else {
+  OwnedDefaultArg = D->getDefaultArgumentInfo();
+}
+  }
+
+  Record.push_back(OwnedDefaultArg != nullptr);
+  if (OwnedDefaultArg) {
+Record.AddTypeSourceInfo(OwnedDefaultArg);
+  }
+  Record.push_back(InheritsFromDecl != nullptr);
+  if (InheritsFromDecl) {
+Record.AddDeclRef(InheritsFromDecl);
+  }
 
   Code = serialization::DECL_TEMPLATE_TYPE_PARM;
 }
@@ -1573,11 +1586,26 @@
   } else {
 // Rest of NonTypeTemplateParmDecl.
 Record.push_back(D->isParameterPack());
-bool OwnsDefaultArg = D->hasDefaultArgument() &&
-  !D->defaultArgumentWasInherited();
-Record.push_back(OwnsDefaultArg);
-if (OwnsDefaultArg)
-  Record.AddStmt(D->getDefaultArgument());
+
+Expr *OwnedDefaultArg = nullptr;
+Decl const *InheritsFromDecl = nullptr;
+if (D->hasDefaultArgument()) {
+  if (D->defaultArgumentWasInherited()) {
+InheritsFromDecl = D->getDefaultArgStorage().getInheritedFrom();
+  } else {
+OwnedDefaultArg = D->getDefaultArgument();
+  }
+}
+
+Record.push_back(OwnedDefaultArg != nullptr);
+if (OwnedDefaultArg) {
+  Record.AddStmt(OwnedDefaultArg);
+}
+Record.push_back(InheritsFromDecl != nullptr);
+if (InheritsFromDecl) {
+  Record.AddDeclRef(InheritsFromDecl);
+}

r321786 - Revert "[Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones"

2018-01-03 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jan  3 23:31:24 2018
New Revision: 321786

URL: http://llvm.org/viewvc/llvm-project?rev=321786=rev
Log:
Revert "[Modules] Allow modules specified by -fmodule-map-file to shadow 
implicitly found ones"

This reverts r321781 until I fix the leaks pointed out by bots:

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/12146
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/3741

Removed:
cfe/trunk/test/Modules/Inputs/shadow/A1/A.h
cfe/trunk/test/Modules/Inputs/shadow/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadow/A2/A.h
cfe/trunk/test/Modules/Inputs/shadow/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/Foo/module.modulemap
cfe/trunk/test/Modules/shadow.m
cfe/trunk/test/Modules/shadowed-submodule.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=321786=321785=321786=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Wed Jan  3 23:31:24 
2018
@@ -94,9 +94,6 @@ def remark_module_lock_failure : Remark<
   "could not acquire lock file for module '%0': %1">, InGroup;
 def remark_module_lock_timeout : Remark<
   "timed out waiting to acquire lock file for module '%0'">, 
InGroup;
-def err_module_shadowed : Error<"import of shadowed module '%0'">, 
DefaultFatal;
-def err_module_build_shadowed_submodule : Error<
-  "build a shadowed submodule '%0'">, DefaultFatal;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 
   DefaultFatal;
 def err_module_prebuilt : Error<

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=321786=321785=321786=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Wed Jan  3 23:31:24 2018
@@ -197,9 +197,6 @@ public:
   /// will be false to indicate that this (sub)module is not available.
   SmallVector Requirements;
 
-  /// \brief A module with the same name that shadows this module.
-  Module *ShadowingModule = nullptr;
-
   /// \brief Whether this module is missing a feature from \c Requirements.
   unsigned IsMissingRequirement : 1;
 
@@ -378,20 +375,13 @@ public:
   ///
   /// \param Target The target options used for the current translation unit.
   ///
-  /// \param Req If this module is unavailable because of a missing 
requirement,
-  /// this parameter will be set to one of the requirements that is not met for
-  /// use of this module.
-  ///
-  /// \param MissingHeader If this module is unavailable because of a missing
-  /// header, this parameter will be set to one of the missing headers.
-  ///
-  /// \param ShadowingModule If this module is unavailable because it is
-  /// shadowed, this parameter will be set to the shadowing module.
+  /// \param Req If this module is unavailable, this parameter
+  /// will be set to one of the requirements that is not met for use of
+  /// this module.
   bool isAvailable(const LangOptions , 
const TargetInfo ,
Requirement ,
-   UnresolvedHeaderDirective ,
-   Module *) const;
+   UnresolvedHeaderDirective ) const;
 
   /// \brief Determine whether this module is a submodule.
   bool isSubModule() const { return Parent != nullptr; }

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=321786=321785=321786=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed Jan  3 23:31:24 2018
@@ -726,7 +726,6 @@ private:
   

[PATCH] D41716: clang-tidy: add IgnoreMacros option to readability-inconsistent-declaration-parameter-name

2018-01-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

> And also enable it by default to be consistent with e.g. modernize-use-using.

That changes the defaults though. I thought clang-tidy *tried* to produce the 
same results
on different clang-tidy versions with the same `.clang-tidy` config? Or is 
there no such guarantees?


https://reviews.llvm.org/D41716



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


[PATCH] D40819: Implement Attribute Target MultiVersioning (Improved edition!)

2018-01-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Hi all-- I'm intending to miss the branch for 6.0, but I'd love to get this in 
soon after.  Can anyone take another look?

Thanks,
Erich


https://reviews.llvm.org/D40819



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


Re: [PATCH] D41039: Add support for attribute "trivial_abi"

2018-01-03 Thread Akira Hatanaka via cfe-commits

> On Jan 2, 2018, at 9:42 AM, David Blaikie via cfe-commits 
>  wrote:
> 
> 
> 
> On Tue, Dec 19, 2017 at 9:43 PM Akira Hatanaka  > wrote:
> On Tue, Dec 12, 2017 at 12:12 PM, John McCall  > wrote:
> On Tue, Dec 12, 2017 at 1:45 PM, David Blaikie  > wrote:
> On Mon, Dec 11, 2017 at 5:38 PM John McCall  > wrote:
> On Mon, Dec 11, 2017 at 6:19 PM, David Blaikie  > wrote:
> On Mon, Dec 11, 2017 at 3:16 PM John McCall via Phabricator 
> > wrote:
> rjmccall added a comment.
> 
> In https://reviews.llvm.org/D41039#951648 
> , @ahatanak wrote:
> 
> > I had a discussion with Duncan today and he pointed out that perhaps we 
> > shouldn't allow users to annotate a struct with "trivial_abi" if one of its 
> > subobjects is non-trivial and is not annotated with "trivial_abi" since 
> > that gives users too much power.
> >
> > Should we error out or drop "trivial_abi" from struct Outer when the 
> > following code is compiled?
> >
> >   struct Inner1 {
> > ~Inner1(); // non-trivial
> > int x;
> >   };
> >
> >   struct __attribute__((trivial_abi)) Outer {
> > ~Outer();
> > Inner1 x;
> >   };
> >
> >
> > The current patch doesn't error out or drop the attribute, but the patch 
> > would probably be much simpler if we didn't allow it.
> 
> 
> I think it makes sense to emit an error if there is provably a 
> non-trivial-ABI component.  However, for class temploids I think that 
> diagnostic should only fire on the definition, not on instantiations; for 
> example:
> 
>   template  struct __attribute__((trivial_abi)) holder {
>  T value;
>  ~holder() {}
>   };
>   holder hs; // this instantiation should be legal despite the 
> fact that holder cannot be trivial-ABI.
> 
> But we should still be able to emit the diagnostic in template definitions, 
> e.g.:
> 
>   template  struct __attribute__((trivial_abi)) named_holder {
>  std::string name; // there are no instantiations of this template that 
> could ever be trivial-ABI
>  T value;
>  ~named_holder() {}
>   };
> 
> The wording should be something akin to the standard template rule that a 
> template is ill-formed if it has no valid instantiations, no diagnostic 
> required.
> 
> I would definitely like to open the conversation about the name of the 
> attribute.  I don't think we've used "abi" in an existing attribute name; 
> usually it's more descriptive.  And "trivial" is a weighty word in the 
> standard.  I'm not sure I have a great counter-proposal off the top of my 
> head, though.
> 
> Agreed on both counts (would love a better name, don't have any stand-out 
> candidates off the top of my head).
> 
> I feel like a more descriptive term about the property of the object would 
> make me happier - something like "address_independent_identity" 
> (s/identity/value/?) though, yeah, that's not spectacular by any stretch.
> 
> Incidentally, your comments are not showing up on Phabricator for some reason.
> 
> Yeah, Phab doesn't do a great job looking on the mailing list for interesting 
> replies - I forget, maybe it only catches bottom post or top post but not 
> infix replies or something... 
> 
> Well, fortunately the mailing list is also archived. :)
> 
> 
> The term "trivially movable" suggests itself, with two caveats:
>   - What we're talking about is trivial *destructive* movability, i.e. that 
> the combination of moving the value to a new object and not destroying the 
> old object can be done trivially, which is not quite the same as trivial 
> movability in the normal C++ sense, which I guess could be a property that 
> someone theoretically might care about (if the type is trivially destructed, 
> but it isn't copyable for semantic reasons?).
>   - Trivial destructive movability is a really common property, and it's 
> something that a compiler would really like to optimize based on even in 
> cases where trivial_abi can't be adopted for binary-compatibility reasons.  
> Stealing the term for the stronger property that the type is trivially 
> destructively movable *and its ABI should reflect that in a specific way* 
> would be unfortunate.
> 
> Fair point.
>  
> "trivially_movable" is a long attribute anyway, and 
> "trivially_destructively_movable" is even worse.
> 
> Maybe that second point is telling us that this isn't purely descriptive — 
> it's inherently talking about the ABI, not just the semantics of the type.  I 
> might be talking myself into accepting trivial_abi if we don't end up with a 
> better suggestion.
> 
> *nod* I think if you want to slice this that way (ensuring there's space to 
> support describing a similar property for use only 

[PATCH] D41575: [index] Return when DC is null in handleReference

2018-01-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

HighCommander4 narrowed it down 
https://github.com/jacobdufault/cquery/issues/219#issuecomment-354903152  to a 
much simpler reproduce:

  c++
  template 
  struct actor;
  
  template  class Actor = actor>
  struct terminal;

This may trigger null pointer dereference of `DC` (because it calls `cast`). If 
the default template argument is removed, the crash goes away.


Repository:
  rC Clang

https://reviews.llvm.org/D41575



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


[PATCH] D41102: Setup clang-doc frontend framework

2018-01-03 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In https://reviews.llvm.org/D41102#955200, @JDevlieghere wrote:

> I don't know what basis is used to differentiate between the two, but should 
> this be part of clang tools or clang-tools-extra?


AFAIK there's a general agreement that clang-tools-extra should be eventually 
merged into clang (see 
https://reviews.llvm.org/diffusion/L/browse/llvm/trunk/CMakeLists.txt;321745$127)
 so for new projects I think we should create them in clang directly rather 
than in clang-tools-extra only to be later moved to clang.


https://reviews.llvm.org/D41102



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


  1   2   >