Re: [PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-04-11 Thread Chih-hung Hsieh via cfe-commits
Should we have two versions of `__gcov_flush`?

One version is visible outside a .so file,
we use dlsym to find and call it to dump
profile data of .so files, like Android.

One version is hidden and must be called from another
wrapper function in a .so file. An application that
wants to flush .so file profile data will need to call
those wrapper functions.


On Wed, Apr 11, 2018 at 12:31 PM, Xinliang David Li 
wrote:

>
>
> On Wed, Apr 11, 2018 at 11:31 AM, Chih-Hung Hsieh via Phabricator via
> llvm-commits  wrote:
>
>> chh added a comment.
>>
>> Yes, calling `__gcov_flush` within .so files are different,
>> but it's a revert of https://reviews.llvm.org/D38124.
>> I think  https://bugs.llvm.org/show_bug.cgi?id=27224
>> can be fixed by hiding only llvm_gcda_* functions,
>> without any change to `__gcov_flush`.
>>
>>
> The coverage dumping behavior for shared libraries (not dlopened) was also
> wrong before D38124. D38124 fixed the crash as well as the dumping bug.
>
> David
>
>
>
>
>
>> (1) Before https://reviews.llvm.org/D38124:
>>
>> - Calling `__gcov_flush` within .so or main function dumps to main gcda
>> file.
>> - Android's dlsym() lookup/call of `__gcov_flush` dumps to .so file
>> specific gcda files.
>>
>> (2) After https://reviews.llvm.org/D38124:
>>
>> - Android's dlsym() cannot find/call `__gcov_flush`.
>> - Calling `__gcov_flush` from main works as in (1).
>> - Calling `__gcov_flush` from .so works differently; it will dump to .so
>> specific gcda file, not the main one.
>>
>> (3) With this change, we revert `__gcov_flush` behavior back to (1).
>>
>> Is there any application that needs to call `__gcov_flush` within .so
>> and expects the output to .so specific gcda file like in (2)?
>> I think the behavior of (1) is more desirable.
>> If a main program wants to dump to .so specific gcda file, like Android,
>> it can use dlsym() to look up .so specific `__gcov_flush`.
>>
>>
>> https://reviews.llvm.org/D45454
>>
>>
>>
>> ___
>> llvm-commits mailing list
>> llvm-comm...@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329854 - Driver: Add gcc search path for RHEL devtoolset-7

2018-04-11 Thread Tom Stellard via cfe-commits
Author: tstellar
Date: Wed Apr 11 15:29:35 2018
New Revision: 329854

URL: http://llvm.org/viewvc/llvm-project?rev=329854&view=rev
Log:
Driver:  Add gcc search path for RHEL devtoolset-7

Reviewers: bruno

Reviewed By: bruno

Subscribers: bruno, cfe-commits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=329854&r1=329853&r2=329854&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed Apr 11 15:29:35 2018
@@ -1785,6 +1785,7 @@ void Generic_GCC::GCCInstallationDetecto
   // Non-Solaris is much simpler - most systems just go with "/usr".
   if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) {
 // Yet, still look for RHEL devtoolsets.
+Prefixes.push_back("/opt/rh/devtoolset-7/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-6/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-4/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-3/root/usr");


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


[PATCH] D41938: [Analyzer] SValBuilder Comparison Rearrangement (with Restrictions and Analyzer Option)

2018-04-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

We've found a crash on our internal buildbot, would you like to have a look?:

**`$ cat repro.c`**

  int foo(int x, int y) {
short a = x - 1U;
return a - y;
  }

**`$ clang -cc1 -analyze -analyzer-checker=core repro.c`**

  Assertion failed: (APSIntType(LInt) == BV.getAPSIntType(SymTy) && "Integers 
are not of the same type as symbols!"), function doRearrangeUnchecked, file 
/Users/adergachev/llvm/tools/clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp,
 line 383.

`1U` can be replaced with `1L` or `1UL`.


Repository:
  rL LLVM

https://reviews.llvm.org/D41938



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


[PATCH] D44130: Driver: Add gcc search path for RHEL devtoolset-7

2018-04-11 Thread Tom Stellard via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329854: Driver:  Add gcc search path for RHEL devtoolset-7 
(authored by tstellar, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D44130

Files:
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp


Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -1785,6 +1785,7 @@
   // Non-Solaris is much simpler - most systems just go with "/usr".
   if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) {
 // Yet, still look for RHEL devtoolsets.
+Prefixes.push_back("/opt/rh/devtoolset-7/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-6/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-4/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-3/root/usr");


Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -1785,6 +1785,7 @@
   // Non-Solaris is much simpler - most systems just go with "/usr".
   if (SysRoot.empty() && TargetTriple.getOS() == llvm::Triple::Linux) {
 // Yet, still look for RHEL devtoolsets.
+Prefixes.push_back("/opt/rh/devtoolset-7/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-6/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-4/root/usr");
 Prefixes.push_back("/opt/rh/devtoolset-3/root/usr");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45015: [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.

2018-04-11 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Another approach is `__has_feature` but I don't think it is applicable in this 
case.

Is there a way right now to detect that aligned allocation is supported by 
clang, regardless of link time? Asking to make sure we are consistent.


Repository:
  rC Clang

https://reviews.llvm.org/D45015



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


[PATCH] D45015: [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.

2018-04-11 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

In https://reviews.llvm.org/D45015#1064922, @vsapsai wrote:

> Another approach is `__has_feature` but I don't think it is applicable in 
> this case.
>
> Is there a way right now to detect that aligned allocation is supported by 
> clang, regardless of link time? Asking to make sure we are consistent.


There is a C++ feature test macro, as specified by the standard, 
`__cpp_aligned_new`.  But I'm not sure how to be consistent with that.


Repository:
  rC Clang

https://reviews.llvm.org/D45015



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


[PATCH] D45544: [AAch64] Add the __ARM_FEATURE_DOTPROD macro definition

2018-04-11 Thread Junmo Park via Phabricator via cfe-commits
flyingforyou created this revision.
flyingforyou added a reviewer: SjoerdMeijer.
Herald added subscribers: kristof.beyls, javed.absar.

This matches what GCC does.
https://github.com/gcc-mirror/gcc/blob/master/gcc/config/aarch64/aarch64-c.c


https://reviews.llvm.org/D45544

Files:
  lib/Basic/Targets/AArch64.cpp
  lib/Basic/Targets/AArch64.h
  test/Preprocessor/aarch64-target-features.c


Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -89,6 +89,10 @@
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-SVE %s
 // CHECK-SVE: __ARM_FEATURE_SVE 1
 
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.2a+dotprod -x c -E
+// -dM %s -o - | FileCheck --check-prefix=CHECK-DOTPROD %s
+// CHECK-DOTPROD: __ARM_FEATURE_DOTPROD 1
+
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2a+fp16 -x c -E 
-dM %s -o - | FileCheck -match-full-lines 
--check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
Index: lib/Basic/Targets/AArch64.h
===
--- lib/Basic/Targets/AArch64.h
+++ lib/Basic/Targets/AArch64.h
@@ -33,6 +33,7 @@
   unsigned Crypto;
   unsigned Unaligned;
   unsigned HasFullFP16;
+  unsigned HasDotProd;
   llvm::AArch64::ArchKind ArchKind;
 
   static const Builtin::Info BuiltinInfo[];
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -193,6 +193,9 @@
   if (HasFullFP16)
Builder.defineMacro("__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", "1");
 
+  if (HasDotProd)
+Builder.defineMacro("__ARM_FEATURE_DOTPROD", "1");
+
   switch (ArchKind) {
   default:
 break;
@@ -248,6 +251,8 @@
   ArchKind = llvm::AArch64::ArchKind::ARMV8_2A;
 if (Feature == "+fullfp16")
   HasFullFP16 = 1;
+if (Feature == "+dotprod")
+  HasDotProd = 1;
   }
 
   setDataLayout();


Index: test/Preprocessor/aarch64-target-features.c
===
--- test/Preprocessor/aarch64-target-features.c
+++ test/Preprocessor/aarch64-target-features.c
@@ -89,6 +89,10 @@
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE %s
 // CHECK-SVE: __ARM_FEATURE_SVE 1
 
+// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.2a+dotprod -x c -E
+// -dM %s -o - | FileCheck --check-prefix=CHECK-DOTPROD %s
+// CHECK-DOTPROD: __ARM_FEATURE_DOTPROD 1
+
 // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2a+fp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1
 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1
Index: lib/Basic/Targets/AArch64.h
===
--- lib/Basic/Targets/AArch64.h
+++ lib/Basic/Targets/AArch64.h
@@ -33,6 +33,7 @@
   unsigned Crypto;
   unsigned Unaligned;
   unsigned HasFullFP16;
+  unsigned HasDotProd;
   llvm::AArch64::ArchKind ArchKind;
 
   static const Builtin::Info BuiltinInfo[];
Index: lib/Basic/Targets/AArch64.cpp
===
--- lib/Basic/Targets/AArch64.cpp
+++ lib/Basic/Targets/AArch64.cpp
@@ -193,6 +193,9 @@
   if (HasFullFP16)
Builder.defineMacro("__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", "1");
 
+  if (HasDotProd)
+Builder.defineMacro("__ARM_FEATURE_DOTPROD", "1");
+
   switch (ArchKind) {
   default:
 break;
@@ -248,6 +251,8 @@
   ArchKind = llvm::AArch64::ArchKind::ARMV8_2A;
 if (Feature == "+fullfp16")
   HasFullFP16 = 1;
+if (Feature == "+dotprod")
+  HasDotProd = 1;
   }
 
   setDataLayout();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329866 - Lex: make `clang::Preprocessor::macros` work on MSVC

2018-04-11 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Wed Apr 11 16:47:25 2018
New Revision: 329866

URL: http://llvm.org/viewvc/llvm-project?rev=329866&view=rev
Log:
Lex: make `clang::Preprocessor::macros` work on MSVC

The order of argument construction is reversed on MS ABI on Windows.
When `macros` was invoked, the `end` call is made prior to `begin`.  In
such a case, the DenseMap (`ModuleMap`) is populated after the `end`
iterator is constructed.  This reversal results in the invalidation of
the end iterator, resulting in a failure at runtime (assertion failure
in `DenseMap::operator!=` that "handles are not in sync!").  Ensure
that the end iterator is constructed after the begin iterator.  This
fixes the use of `macros(bool)`, which symptomized as an assertion
failure in the swift compiler in the clang importer.

Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=329866&r1=329865&r2=329866&view=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Apr 11 16:47:25 2018
@@ -1041,12 +1041,14 @@ public:
 
   macro_iterator macro_begin(bool IncludeExternalMacros = true) const;
   macro_iterator macro_end(bool IncludeExternalMacros = true) const;
-  llvm::iterator_range
 
+  llvm::iterator_range
   macros(bool IncludeExternalMacros = true) const {
-return llvm::make_range(macro_begin(IncludeExternalMacros),
-macro_end(IncludeExternalMacros));
+macro_iterator begin = macro_begin(IncludeExternalMacros);
+macro_iterator end = macro_end(IncludeExternalMacros);
+return llvm::make_range(begin, end);
   }
+
   /// \}
 
   /// \brief Return the name of the macro defined before \p Loc that has


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


[PATCH] D45529: [CMake] Set the default ABI version for Fuchsia in CMake as well

2018-04-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

ping?


Repository:
  rCXX libc++

https://reviews.llvm.org/D45529



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


r329869 - [ODRHash] Skip more types hashing TypedefType

2018-04-11 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Apr 11 19:26:49 2018
New Revision: 329869

URL: http://llvm.org/viewvc/llvm-project?rev=329869&view=rev
Log:
[ODRHash] Skip more types hashing TypedefType

To get the underlying type for TypedefType's, also skip ElaboratedType's.

Modified:
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=329869&r1=329868&r2=329869&view=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Wed Apr 11 19:26:49 2018
@@ -646,9 +646,19 @@ public:
 AddDecl(T->getDecl());
 QualType UnderlyingType = T->getDecl()->getUnderlyingType();
 VisitQualifiers(UnderlyingType.getQualifiers());
-while (const TypedefType *Underlying =
-   dyn_cast(UnderlyingType.getTypePtr())) {
-  UnderlyingType = Underlying->getDecl()->getUnderlyingType();
+while (true) {
+  if (const TypedefType *Underlying =
+  dyn_cast(UnderlyingType.getTypePtr())) {
+UnderlyingType = Underlying->getDecl()->getUnderlyingType();
+continue;
+  }
+  if (const ElaboratedType *Underlying =
+  dyn_cast(UnderlyingType.getTypePtr())) {
+UnderlyingType = Underlying->getNamedType();
+continue;
+  }
+
+  break;
 }
 AddType(UnderlyingType.getTypePtr());
 VisitType(T);

Modified: cfe/trunk/test/Modules/odr_hash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr_hash.cpp?rev=329869&r1=329868&r2=329869&view=diff
==
--- cfe/trunk/test/Modules/odr_hash.cpp (original)
+++ cfe/trunk/test/Modules/odr_hash.cpp Wed Apr 11 19:26:49 2018
@@ -2744,6 +2744,38 @@ struct S3 {
 #else
 S3 s3;
 #endif
+
+#if defined(FIRST)
+using A4 = int;
+using B4 = A4;
+struct S4 {
+  B4 x;
+};
+#elif defined(SECOND)
+using A4 = int;
+using B4 = ::MultipleTypedefs::A4;
+struct S4 {
+  B4 x;
+};
+#else
+S4 s4;
+#endif
+
+#if defined(FIRST)
+using A5 = int;
+using B5 = MultipleTypedefs::A5;
+struct S5 {
+  B5 x;
+};
+#elif defined(SECOND)
+using A5 = int;
+using B5 = ::MultipleTypedefs::A5;
+struct S5 {
+  B5 x;
+};
+#else
+S5 s5;
+#endif
 }  // MultipleTypedefs
 
 namespace DefaultArguments {


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


[PATCH] D45305: ObjCGNU: Fix empty v3 protocols being emitted two fields short

2018-04-11 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT added a comment.

Hi! Is there anything else holding up this patch? Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D45305



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-11 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D44882#1064196, @sammccall wrote:

> (BTW @hokein has https://reviews.llvm.org/D45513 to add row/col to the index, 
> which will allow all the file-reading stuff to be cleaned up, but no need to 
> wait on that since it's all working now).


Looking forward to it!




Comment at: clangd/ClangdLSPServer.cpp:101
+  // All clients should support those.
+  for (SymKindUnderlyingType I = SymbolKindMin;
+   I <= static_cast(SymbolKind::Array); ++I)

sammccall wrote:
> malaperle wrote:
> > I'd like to add some test to exercise the changes in ClangdLSPServer.cpp 
> > and Protocol.cpp but it's not straightforward to do nicely. Using a "lit" 
> > test, I cannot have a header and since symbols in the main file are not 
> > collected then it's not useful. If I make a gtest, I have to feed it the 
> > lsp server with stdin and check the stdout which is a bit messy, but doable.
> Yeah, we don't have a good way to test ClangdLSPServer :-( I would like to 
> fix that, but I don't know of any easy fixes.
> 
> This is kind of gross, but do standard library includes work from our lit 
> tests? You could `#include ` and then test using some symbols you know 
> are there...
> 
It doesn't seem to work unfortunately. I'm not sure why yet. Either way, I 
think I would add this test as a separate patch if we are to add a standard 
library include because I'm a bit nervous it will break and we will have to 
revert it :)



Comment at: clangd/ClangdLSPServer.cpp:103
+   I <= static_cast(SymbolKind::Array); ++I)
+SupportedSymbolKinds.set(I);
+

sammccall wrote:
> I'd like to be slightly less hostile than this to (broken) clients that fail 
> to call initialize.
> As the patch stands they'll get an empty SupportedSymbolKinds, and we'll 
> crash if they call documentSymbols.
> 
> Instead I'd suggest pulling out defaultSymbolKinds() and initializing to that 
> in the constructor, and then overriding with either `SpecifiedSymbolKinds` or 
> `SpecifiedSymbolKinds | defaultSymbolKinds()` here.
Good catch. I initialized SupportedSymbolKinds with defaultSymbolKinds() and 
let this loop add additional symbol kinds.



Comment at: clangd/ClangdServer.h:164
+  void workspaceSymbols(StringRef Query,
+const clangd::WorkspaceSymbolOptions &Opts,
+const DraftStore &DS,

sammccall wrote:
> I think it would probably be more consistent with other functions to just 
> take `int limit` here. I'm not sure CodeCompletion is an example we want to 
> emulate.
> 
> ClangdLSPServer might even just grab it from the code completion options, 
> since that's the behavior we actually want.
> 
> Up to you, though.
I think it makes sense. We can reintroduce an option struct when there is more 
than one thing in it.



Comment at: clangd/Protocol.cpp:209
+  default:
+llvm_unreachable("Unexpected symbol kind");
+  }

sammccall wrote:
> This doesn't actually seem unreachable (or won't stay that way), maybe log 
> and return `Null` or something like that? (Wow, there's really no catch-all 
> option for this mandatory enum...)
`Null` Is not in LSP 1.0 and 2.0 that's why I had put `Variable` at the 
beginning. Maybe `String` is better. Not sure what you think is best.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-11 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle updated this revision to Diff 142112.
malaperle marked 2 inline comments as done.
malaperle added a comment.

Address comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/FindSymbols.cpp
  clangd/FindSymbols.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/XRefs.cpp
  clangd/index/SymbolCollector.cpp
  clangd/tool/ClangdMain.cpp
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test
  unittests/clangd/CMakeLists.txt
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h

Index: unittests/clangd/SyncAPI.h
===
--- unittests/clangd/SyncAPI.h
+++ unittests/clangd/SyncAPI.h
@@ -41,6 +41,10 @@
 
 std::string runDumpAST(ClangdServer &Server, PathRef File);
 
+llvm::Expected>
+runWorkspaceSymbols(ClangdServer &Server, StringRef Query, int Limit,
+const DraftStore &DS);
+
 } // namespace clangd
 } // namespace clang
 
Index: unittests/clangd/SyncAPI.cpp
===
--- unittests/clangd/SyncAPI.cpp
+++ unittests/clangd/SyncAPI.cpp
@@ -110,5 +110,13 @@
   return std::move(*Result);
 }
 
+llvm::Expected>
+runWorkspaceSymbols(ClangdServer &Server, StringRef Query, int Limit,
+const DraftStore &DS) {
+  llvm::Optional>> Result;
+  Server.workspaceSymbols(Query, Limit, DS, capture(Result));
+  return std::move(*Result);
+}
+
 } // namespace clangd
 } // namespace clang
Index: unittests/clangd/FindSymbolsTests.cpp
===
--- /dev/null
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -0,0 +1,249 @@
+//===-- FindSymbolsTests.cpp -*- C++ -*===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+#include "Annotations.h"
+#include "ClangdServer.h"
+#include "DraftStore.h"
+#include "FindSymbols.h"
+#include "SyncAPI.h"
+#include "TestFS.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+
+namespace {
+
+using ::testing::AllOf;
+using ::testing::AnyOf;
+using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+using ::testing::UnorderedElementsAre;
+
+class IgnoreDiagnostics : public DiagnosticsConsumer {
+  void onDiagnosticsReady(PathRef File,
+  std::vector Diagnostics) override {}
+};
+
+// GMock helpers for matching SymbolInfos items.
+MATCHER_P(Named, Name, "") { return arg.name == Name; }
+MATCHER_P(InContainer, ContainerName, "") {
+  return arg.containerName == ContainerName;
+}
+MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
+
+ClangdServer::Options optsForTests() {
+  auto ServerOpts = ClangdServer::optsForTest();
+  ServerOpts.BuildDynamicSymbolIndex = true;
+  return ServerOpts;
+}
+
+class WorkspaceSymbolsTest : public ::testing::Test {
+public:
+  WorkspaceSymbolsTest()
+  : Server(CDB, FSProvider, DiagConsumer, optsForTests()) {}
+
+protected:
+  MockFSProvider FSProvider;
+  MockCompilationDatabase CDB;
+  IgnoreDiagnostics DiagConsumer;
+  ClangdServer Server;
+  int Limit;
+  DraftStore DS;
+
+  std::vector getSymbols(StringRef Query) {
+EXPECT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for preamble";
+auto SymbolInfos = runWorkspaceSymbols(Server, Query, Limit, DS);
+EXPECT_TRUE(bool(SymbolInfos)) << "workspaceSymbols returned an error";
+return *SymbolInfos;
+  }
+
+  void addFile(StringRef FileName, StringRef Contents) {
+auto Path = testPath(FileName);
+FSProvider.Files[Path] = Contents;
+Server.addDocument(Path, Contents);
+  }
+};
+
+} // namespace
+
+TEST_F(WorkspaceSymbolsTest, NoMacro) {
+  addFile("foo.cpp", R"cpp(
+  #define MACRO X
+  )cpp");
+
+  // Macros are not in the index.
+  EXPECT_THAT(getSymbols("macro"), IsEmpty());
+}
+
+TEST_F(WorkspaceSymbolsTest, NoLocals) {
+  addFile("foo.cpp", R"cpp(
+  void test(int FirstParam, int SecondParam) {
+struct LocalClass {};
+int local_var;
+  })cpp");
+  EXPECT_THAT(getSymbols("l"), IsEmpty());
+  EXPECT_THAT(getSymbols("p"), IsEmpty());
+}
+
+TEST_F(WorkspaceSymbolsTest, Globals) {
+  addFile("foo.h", R"cpp(
+  int global_var;
+
+  int global_func();
+
+  struct GlobalStruct {};)cpp");
+  addFile("foo.cpp", R"cpp(
+  #include "foo.h"
+  )cpp");
+  EXPECT_THAT(getSymbols("global"),
+  UnorderedElementsAre(AllOf(Named("GlobalStruct"), InContainer(""),

[PATCH] D45529: [CMake] Set the default ABI version for Fuchsia in CMake as well

2018-04-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

This LGTM given that Eric accepted your previous change. I'm happy to accept it 
in a day or two if he hasn't gotten the chance to take a look by then.




Comment at: libcxx/CMakeLists.txt:101
+if (FUCHSIA)
+  set(ABI_VERSION_DEFAULT 2)
+else()

I prefer `DEFAULT_ABI_VERSION` to `ABI_VERSION_DEFAULT`


Repository:
  rCXX libc++

https://reviews.llvm.org/D45529



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


[clang-tools-extra] r329873 - [clang-tidy] [modernize-use-auto] Get only a length of token, not the token itself

2018-04-11 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Wed Apr 11 22:41:24 2018
New Revision: 329873

URL: http://llvm.org/viewvc/llvm-project?rev=329873&view=rev
Log:
[clang-tidy] [modernize-use-auto] Get only a length of token, not the token 
itself


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

Modified: clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp?rev=329873&r1=329872&r2=329873&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseAutoCheck.cpp Wed Apr 11 
22:41:24 2018
@@ -11,6 +11,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Lex/Lexer.h"
 #include "clang/Tooling/FixIt.h"
 
 using namespace clang;
@@ -419,8 +420,8 @@ void UseAutoCheck::replaceExpr(
   SourceRange Range(Loc.getSourceRange());
 
   if (MinTypeNameLength != 0 &&
-  tooling::fixit::getText(Loc.getSourceRange(), FirstDecl->getASTContext())
-  .size() < MinTypeNameLength)
+  Lexer::MeasureTokenLength(Loc.getLocStart(), Context->getSourceManager(),
+getLangOpts()) < MinTypeNameLength)
 return;
 
   auto Diag = diag(Range.getBegin(), Message);


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


[clang-tools-extra] r329875 - [Documentation] Fix options order for Release Notes in modernize-use-auto.

2018-04-11 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Wed Apr 11 22:45:16 2018
New Revision: 329875

URL: http://llvm.org/viewvc/llvm-project?rev=329875&view=rev
Log:
[Documentation] Fix options order for Release Notes in modernize-use-auto.


Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst?rev=329875&r1=329874&r2=329875&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst Wed 
Apr 11 22:45:16 2018
@@ -177,24 +177,6 @@ Known Limitations
 Options
 ---
 
-.. option:: RemoveStars
-
-   If the option is set to non-zero (default is `0`), the check will remove
-   stars from the non-typedef pointer types when replacing type names with
-   ``auto``. Otherwise, the check will leave stars. For example:
-
-.. code-block:: c++
-
-  TypeName *my_first_pointer = new TypeName, *my_second_pointer = new TypeName;
-
-  // RemoveStars = 0
-
-  auto *my_first_pointer = new TypeName, *my_second_pointer = new TypeName;
-
-  // RemoveStars = 1
-
-  auto my_first_pointer = new TypeName, my_second_pointer = new TypeName;
-
 .. option:: MinTypeNameLength
 
If the option is set to non-zero (default `5`), the check will ignore type
@@ -214,3 +196,21 @@ Options
   int a = static_cast(foo());// ---> int  a = ...
   bool b = new bool;  // ---> bool b = ...
   unsigned c = static_cast(foo());  // ---> auto c = ...
+
+.. option:: RemoveStars
+
+   If the option is set to non-zero (default is `0`), the check will remove
+   stars from the non-typedef pointer types when replacing type names with
+   ``auto``. Otherwise, the check will leave stars. For example:
+
+.. code-block:: c++
+
+  TypeName *my_first_pointer = new TypeName, *my_second_pointer = new TypeName;
+
+  // RemoveStars = 0
+
+  auto *my_first_pointer = new TypeName, *my_second_pointer = new TypeName;
+
+  // RemoveStars = 1
+
+  auto my_first_pointer = new TypeName, my_second_pointer = new TypeName;


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


r329879 - [Sema][ObjC] Ensure that the return type of an ObjC method is a complete

2018-04-11 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Wed Apr 11 23:01:41 2018
New Revision: 329879

URL: http://llvm.org/viewvc/llvm-project?rev=329879&view=rev
Log:
[Sema][ObjC] Ensure that the return type of an ObjC method is a complete
type.

Copy the code in ActOnStartOfFunctionDef that checks a function's return
type to ActOnStartOfObjCMethodDef. This fixes an assertion failure in
IRGen caused by an uninstantiated return type.

rdar://problem/38691818

Added:
cfe/trunk/test/CodeGenObjCXX/instantiate-return.mm
Modified:
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/SemaObjCXX/instantiate-method-return.mm

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=329879&r1=329878&r2=329879&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Wed Apr 11 23:01:41 2018
@@ -341,6 +341,13 @@ void Sema::ActOnStartOfObjCMethodDef(Sco
   if (!MDecl)
 return;
 
+  QualType ResultType = MDecl->getReturnType();
+  if (!ResultType->isDependentType() && !ResultType->isVoidType() &&
+  !MDecl->isInvalidDecl() &&
+  RequireCompleteType(MDecl->getLocation(), ResultType,
+  diag::err_func_def_incomplete_result))
+MDecl->setInvalidDecl();
+
   // Allow all of Sema to see that we are entering a method definition.
   PushDeclContext(FnBodyScope, MDecl);
   PushFunctionScope();

Added: cfe/trunk/test/CodeGenObjCXX/instantiate-return.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/instantiate-return.mm?rev=329879&view=auto
==
--- cfe/trunk/test/CodeGenObjCXX/instantiate-return.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/instantiate-return.mm Wed Apr 11 23:01:41 2018
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -std=c++11 -o - %s 
| FileCheck %s
+
+template 
+struct TemplateClass {
+  int a = 0;
+};
+
+struct S0;
+
+@interface C1
+- (TemplateClass)m1;
+@end
+
+// This code used to assert in CodeGen because the return type 
TemplateClass
+// wasn't instantiated.
+
+// CHECK: define internal i32 @"\01-[C1 m1]"(
+
+@implementation C1
+- (TemplateClass)m1 {
+}
+@end

Modified: cfe/trunk/test/SemaObjCXX/instantiate-method-return.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/instantiate-method-return.mm?rev=329879&r1=329878&r2=329879&view=diff
==
--- cfe/trunk/test/SemaObjCXX/instantiate-method-return.mm (original)
+++ cfe/trunk/test/SemaObjCXX/instantiate-method-return.mm Wed Apr 11 23:01:41 
2018
@@ -1,14 +1,14 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
-// expected-no-diagnostics
 // PR7386
 
 @class NSObject;
 
-class A;
-template class V {};
+class A; // expected-note {{forward declaration of 'A'}}
+template class V { T x; }; // expected-error {{field has incomplete 
type 'A'}}
 
 @protocol Protocol
 - (V)protocolMethod;
+- (V)method2;
 @end
 
 
@@ -24,4 +24,6 @@ template class V {};
 - (V)protocolMethod {
   V va; return va;
 }
+- (V)method2 { // expected-note {{in instantiation of}}
+}
 @end


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


[PATCH] D28462: clang-format: Add new style option AlignConsecutiveMacros

2018-04-11 Thread Timothée Fivaz via Phabricator via cfe-commits
TimF added a comment.

In https://reviews.llvm.org/D28462#1064789, @enyquist wrote:

> As far as I know, there are no updates required from me for this pull 
> request-- I rebased on the main trunk recently, and will do it again tonight 
> to be sure. So it should be compiling/working just fine.
>  I believe it is just awaiting final approval from somebody.


I have done a checkout of both trunks yesterday, applied your patch and 
compiled everything. It is working flawlessly and now the defines are correctly 
aligned. I still hope they'll merge it because I prefer using an official 
release, but until then it will do the job. 
Thanks a lot for your work on this feature, it was the last point preventing us 
from using clang-format. (embedded development too, so we have lots of 
defines). And thanks to all the LLVM contributors by the way :-)


Repository:
  rL LLVM

https://reviews.llvm.org/D28462



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


[PATCH] D45403: Make [[maybe_unused]] work with static data members

2018-04-11 Thread S. B. Tam via Phabricator via cfe-commits
cpplearner added a comment.

I do not have commit access. Could someone commit the change for me?


https://reviews.llvm.org/D45403



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


r329882 - ObjCGNU: Fix empty v3 protocols being emitted two fields short

2018-04-11 Thread David Chisnall via cfe-commits
Author: theraven
Date: Wed Apr 11 23:46:15 2018
New Revision: 329882

URL: http://llvm.org/viewvc/llvm-project?rev=329882&view=rev
Log:
ObjCGNU: Fix empty v3 protocols being emitted two fields short

Summary:
Protocols that were being referenced but could not be fully realized were being 
emitted without `properties`/`optional_properties`. Since all v3 protocols must 
be 9 processor words wide, the lack of these fields is catastrophic for the 
runtime.

As an example, the runtime cannot know 
[here](https://github.com/gnustep/libobjc2/blob/master/protocol.c#L73) that 
`properties` and `optional_properties` are invalid.

Reviewers: rjmccall, theraven

Reviewed By: rjmccall, theraven

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGenObjC/gnu-empty-protocol-v3.m
Modified:
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=329882&r1=329881&r2=329882&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Wed Apr 11 23:46:15 2018
@@ -1748,11 +1748,13 @@ CGObjCGNU::GenerateEmptyProtocol(const s
   llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy));
 
   Elements.add(MakeConstantString(ProtocolName, ".objc_protocol_name"));
-  Elements.add(ProtocolList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
+  Elements.add(ProtocolList); /* .protocol_list */
+  Elements.add(MethodList);   /* .instance_methods */
+  Elements.add(MethodList);   /* .class_methods */
+  Elements.add(MethodList);   /* .optional_instance_methods */
+  Elements.add(MethodList);   /* .optional_class_methods */
+  Elements.add(NULLPtr);  /* .properties */
+  Elements.add(NULLPtr);  /* .optional_properties */
   return Elements.finishAndCreateGlobal(".objc_protocol",
 CGM.getPointerAlign());
 }

Added: cfe/trunk/test/CodeGenObjC/gnu-empty-protocol-v3.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/gnu-empty-protocol-v3.m?rev=329882&view=auto
==
--- cfe/trunk/test/CodeGenObjC/gnu-empty-protocol-v3.m (added)
+++ cfe/trunk/test/CodeGenObjC/gnu-empty-protocol-v3.m Wed Apr 11 23:46:15 2018
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fobjc-runtime=gnustep-1.9 
-emit-llvm -o - %s | FileCheck %s
+
+@protocol X;
+
+__attribute__((objc_root_class))
+@interface Z 
+@end
+
+@implementation Z
+@end
+
+// CHECK:  @.objc_protocol_list = internal global { i8*, i32, [0 x i8*] } 
zeroinitializer, align 4
+// CHECK:  @.objc_method_list = internal global { i32, [0 x { i8*, i8* }] 
} zeroinitializer, align 4
+// CHECK:  @.objc_protocol_name = private unnamed_addr constant [2 x i8] 
c"X\00", align 1
+// CHECK:  @.objc_protocol = internal global { i8*, i8*, { i8*, i32, [0 x 
i8*] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 
x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, i8*, i8* } {
+// CHECK-SAME: i8* inttoptr (i32 3 to i8*),
+// CHECK-SAME: i8* getelementptr inbounds ([2 x i8], [2 x i8]* 
@.objc_protocol_name, i32 0, i32 0),
+// CHECK-SAME: { i8*, i32, [0 x i8*] }* @.objc_protocol_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: i8* null,
+// CHECK-SAME: i8* null
+// CHECK-SAME: }, align 4


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


[clang-tools-extra] r329881 - [clang-tidy] [modernize-use-auto] Fix test modernize-use-auto-new-remove-stars.cpp after improvement

2018-04-11 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Wed Apr 11 23:45:47 2018
New Revision: 329881

URL: http://llvm.org/viewvc/llvm-project?rev=329881&view=rev
Log:
[clang-tidy] [modernize-use-auto] Fix test 
modernize-use-auto-new-remove-stars.cpp  after improvement

'tooling::fixit::getText' considers a length of "int *" to be 5 instead of 3 
in a new algorithm in https://reviews.llvm.org/rCTE329873. It was the root of 
the test failure.


Modified:

clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new-remove-stars.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new-remove-stars.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new-remove-stars.cpp?rev=329881&r1=329880&r2=329881&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new-remove-stars.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new-remove-stars.cpp 
Wed Apr 11 23:45:47 2018
@@ -1,5 +1,5 @@
 // RUN: %check_clang_tidy %s modernize-use-auto %t -- \
-// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, 
value: '1'}]}" \
+// RUN:   -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, 
value: '1'}, {key: modernize-use-auto.MinTypeNameLength, value: '0'}]}" \
 // RUN:   -- -std=c++11
 
 class MyType {};


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


[PATCH] D45305: ObjCGNU: Fix empty v3 protocols being emitted two fields short

2018-04-11 Thread David Chisnall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329882: ObjCGNU: Fix empty v3 protocols being emitted two 
fields short (authored by theraven, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D45305

Files:
  lib/CodeGen/CGObjCGNU.cpp
  test/CodeGenObjC/gnu-empty-protocol-v3.m


Index: lib/CodeGen/CGObjCGNU.cpp
===
--- lib/CodeGen/CGObjCGNU.cpp
+++ lib/CodeGen/CGObjCGNU.cpp
@@ -1748,11 +1748,13 @@
   llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy));
 
   Elements.add(MakeConstantString(ProtocolName, ".objc_protocol_name"));
-  Elements.add(ProtocolList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
+  Elements.add(ProtocolList); /* .protocol_list */
+  Elements.add(MethodList);   /* .instance_methods */
+  Elements.add(MethodList);   /* .class_methods */
+  Elements.add(MethodList);   /* .optional_instance_methods */
+  Elements.add(MethodList);   /* .optional_class_methods */
+  Elements.add(NULLPtr);  /* .properties */
+  Elements.add(NULLPtr);  /* .optional_properties */
   return Elements.finishAndCreateGlobal(".objc_protocol",
 CGM.getPointerAlign());
 }
Index: test/CodeGenObjC/gnu-empty-protocol-v3.m
===
--- test/CodeGenObjC/gnu-empty-protocol-v3.m
+++ test/CodeGenObjC/gnu-empty-protocol-v3.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fobjc-runtime=gnustep-1.9 
-emit-llvm -o - %s | FileCheck %s
+
+@protocol X;
+
+__attribute__((objc_root_class))
+@interface Z 
+@end
+
+@implementation Z
+@end
+
+// CHECK:  @.objc_protocol_list = internal global { i8*, i32, [0 x i8*] } 
zeroinitializer, align 4
+// CHECK:  @.objc_method_list = internal global { i32, [0 x { i8*, i8* }] 
} zeroinitializer, align 4
+// CHECK:  @.objc_protocol_name = private unnamed_addr constant [2 x i8] 
c"X\00", align 1
+// CHECK:  @.objc_protocol = internal global { i8*, i8*, { i8*, i32, [0 x 
i8*] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 
x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, i8*, i8* } {
+// CHECK-SAME: i8* inttoptr (i32 3 to i8*),
+// CHECK-SAME: i8* getelementptr inbounds ([2 x i8], [2 x i8]* 
@.objc_protocol_name, i32 0, i32 0),
+// CHECK-SAME: { i8*, i32, [0 x i8*] }* @.objc_protocol_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: { i32, [0 x { i8*, i8* }] }* @.objc_method_list,
+// CHECK-SAME: i8* null,
+// CHECK-SAME: i8* null
+// CHECK-SAME: }, align 4


Index: lib/CodeGen/CGObjCGNU.cpp
===
--- lib/CodeGen/CGObjCGNU.cpp
+++ lib/CodeGen/CGObjCGNU.cpp
@@ -1748,11 +1748,13 @@
   llvm::ConstantInt::get(Int32Ty, ProtocolVersion), IdTy));
 
   Elements.add(MakeConstantString(ProtocolName, ".objc_protocol_name"));
-  Elements.add(ProtocolList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
-  Elements.add(MethodList);
+  Elements.add(ProtocolList); /* .protocol_list */
+  Elements.add(MethodList);   /* .instance_methods */
+  Elements.add(MethodList);   /* .class_methods */
+  Elements.add(MethodList);   /* .optional_instance_methods */
+  Elements.add(MethodList);   /* .optional_class_methods */
+  Elements.add(NULLPtr);  /* .properties */
+  Elements.add(NULLPtr);  /* .optional_properties */
   return Elements.finishAndCreateGlobal(".objc_protocol",
 CGM.getPointerAlign());
 }
Index: test/CodeGenObjC/gnu-empty-protocol-v3.m
===
--- test/CodeGenObjC/gnu-empty-protocol-v3.m
+++ test/CodeGenObjC/gnu-empty-protocol-v3.m
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fobjc-runtime=gnustep-1.9 -emit-llvm -o - %s | FileCheck %s
+
+@protocol X;
+
+__attribute__((objc_root_class))
+@interface Z 
+@end
+
+@implementation Z
+@end
+
+// CHECK:  @.objc_protocol_list = internal global { i8*, i32, [0 x i8*] } zeroinitializer, align 4
+// CHECK:  @.objc_method_list = internal global { i32, [0 x { i8*, i8* }] } zeroinitializer, align 4
+// CHECK:  @.objc_protocol_name = private unnamed_addr constant [2 x i8] c"X\00", align 1
+// CHECK:  @.objc_protocol = internal global { i8*, i8*, { i8*, i32, [0 x i8*] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, { i32, [0 x { i8*, i8* }] }*, i8*, i8* } {
+// CHECK-SAME: i8* inttoptr (i32 3 to i8*),
+// CHECK-SAME: i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.objc_protocol_name, i32 0, i32 0),
+// C

[PATCH] D43871: [modules] No longer include stdlib.h from mm_malloc.h.

2018-04-11 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: test/CXX/except/except.spec/libc-empty-except.cpp:27
+#else
+#include "mm_malloc.h"
+#include "stdlib.h"

Maybe we should reverse the includes here as we discussed offline.


https://reviews.llvm.org/D43871



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


[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference

2018-04-11 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 141955.
baloghadamsoftware added a comment.
Herald added a reviewer: george.karpenkov.

Rebased to the newly committed SValbuilder rearranger patch


https://reviews.llvm.org/D35110

Files:
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  test/Analysis/constraint_manager_negate_difference.c
  test/Analysis/ptr-arith.c

Index: test/Analysis/ptr-arith.c
===
--- test/Analysis/ptr-arith.c
+++ test/Analysis/ptr-arith.c
@@ -265,49 +265,26 @@
   clang_analyzer_eval((rhs - lhs) > 0); // expected-warning{{TRUE}}
 }
 
-//---
-// False positives
-//---
-
 void zero_implies_reversed_equal(int *lhs, int *rhs) {
   clang_analyzer_eval((rhs - lhs) == 0); // expected-warning{{UNKNOWN}}
   if ((rhs - lhs) == 0) {
-#ifdef ANALYZER_CM_Z3
 clang_analyzer_eval(rhs != lhs); // expected-warning{{FALSE}}
 clang_analyzer_eval(rhs == lhs); // expected-warning{{TRUE}}
-#else
-clang_analyzer_eval(rhs != lhs); // expected-warning{{UNKNOWN}}
-clang_analyzer_eval(rhs == lhs); // expected-warning{{UNKNOWN}}
-#endif
 return;
   }
   clang_analyzer_eval((rhs - lhs) == 0); // expected-warning{{FALSE}}
-#ifdef ANALYZER_CM_Z3
   clang_analyzer_eval(rhs == lhs); // expected-warning{{FALSE}}
   clang_analyzer_eval(rhs != lhs); // expected-warning{{TRUE}}
-#else
-  clang_analyzer_eval(rhs == lhs); // expected-warning{{UNKNOWN}}
-  clang_analyzer_eval(rhs != lhs); // expected-warning{{UNKNOWN}}
-#endif
 }
 
 void canonical_equal(int *lhs, int *rhs) {
   clang_analyzer_eval(lhs == rhs); // expected-warning{{UNKNOWN}}
   if (lhs == rhs) {
-#ifdef ANALYZER_CM_Z3
 clang_analyzer_eval(rhs == lhs); // expected-warning{{TRUE}}
-#else
-clang_analyzer_eval(rhs == lhs); // expected-warning{{UNKNOWN}}
-#endif
 return;
   }
   clang_analyzer_eval(lhs == rhs); // expected-warning{{FALSE}}
-
-#ifdef ANALYZER_CM_Z3
   clang_analyzer_eval(rhs == lhs); // expected-warning{{FALSE}}
-#else
-  clang_analyzer_eval(rhs == lhs); // expected-warning{{UNKNOWN}}
-#endif
 }
 
 void compare_element_region_and_base(int *p) {
Index: test/Analysis/constraint_manager_negate_difference.c
===
--- /dev/null
+++ test/Analysis/constraint_manager_negate_difference.c
@@ -0,0 +1,66 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection,core.builtin -analyzer-config aggressive-relational-comparison-simplification=true -verify %s
+
+void clang_analyzer_eval(int);
+
+void exit(int);
+
+#define UINT_MAX (~0U)
+#define INT_MAX (UINT_MAX & (UINT_MAX >> 1))
+
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+unsigned int __line, __const char *__function)
+ __attribute__ ((__noreturn__));
+#define assert(expr) \
+  ((expr)  ? (void)(0)  : __assert_fail (#expr, __FILE__, __LINE__, __func__))
+
+void assert_in_range(int x) {
+  assert(x <= ((int)INT_MAX / 4));
+  assert(x >= -(((int)INT_MAX) / 4));
+}
+
+void assert_in_range_2(int m, int n) {
+  assert_in_range(m);
+  assert_in_range(n);
+}
+
+void equal(int m, int n) {
+  assert_in_range_2(m, n);
+  if (m != n)
+return;
+  clang_analyzer_eval(n == m); // expected-warning{{TRUE}}
+}
+
+void non_equal(int m, int n) {
+  assert_in_range_2(m, n);
+  if (m == n)
+return;
+  clang_analyzer_eval(n != m); // expected-warning{{TRUE}}
+}
+
+void less_or_equal(int m, int n) {
+  assert_in_range_2(m, n);
+  if (m < n)
+return;
+  clang_analyzer_eval(n <= m); // expected-warning{{TRUE}}
+}
+
+void less(int m, int n) {
+  assert_in_range_2(m, n);
+  if (m <= n)
+return;
+  clang_analyzer_eval(n < m); // expected-warning{{TRUE}}
+}
+
+void greater_or_equal(int m, int n) {
+  assert_in_range_2(m, n);
+  if (m > n)
+return;
+  clang_analyzer_eval(n >= m); // expected-warning{{TRUE}}
+}
+
+void greater(int m, int n) {
+  assert_in_range_2(m, n);
+  if (m >= n)
+return;
+  clang_analyzer_eval(n > m); // expected-warning{{TRUE}}
+}
Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -256,6 +256,29 @@
 return newRanges;
   }
 
+  // Turn all [A, B] ranges to [-B, -A]. Turn minimal signed value to maximal
+  // signed value and vice versa.
+  RangeSet Negate(BasicValueFactory &BV, Factory &F) const {
+PrimRangeSet newRanges = F.getEmptySet();
+
+for (iterator i = begin(), e = end(); i != e; ++i) {
+  const llvm::APSInt &from = i->From(), &to = i->To();
+  const llvm::APSInt &newFrom = (to.isMinSignedValue() ?
+ BV.getMaxValue(to) :
+ (to.isMaxSignedValue() ?
+  BV.getMinValue(to) :
+   

[PATCH] D45442: Parse .h files as objective-c++ if we don't have a compile command.

2018-04-11 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/GlobalCompilationDatabase.cpp:24
+  // Parsing as Objective C++ is friendly to more cases.
+  if (llvm::sys::path::extension(File) == ".h")
+Argv.push_back("-xobjective-c++-header");

sammccall wrote:
> ilya-biryukov wrote:
> > Maybe use `.equals_lower(".h")` instead? Just in case.
> .H is (unambiguously) c++, and will be treated as such by clang.
Wasn't aware of that convention, thanks.
In that case, LG


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45442



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


r329784 - [Tooling] Optimize memory usage in InMemoryToolResults.

2018-04-11 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Apr 11 01:13:07 2018
New Revision: 329784

URL: http://llvm.org/viewvc/llvm-project?rev=329784&view=rev
Log:
[Tooling] Optimize memory usage in InMemoryToolResults.

Avoid storing duplicated "std::string"s.

clangd's global-symbol-builder takes 20+GB memory running across LLVM
repository. With this patch, the used memory is ~10GB (running on 48
threads, most of meory are AST-related).

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/include/clang/Tooling/Execution.h
cfe/trunk/lib/Tooling/AllTUsExecution.cpp
cfe/trunk/lib/Tooling/Execution.cpp

Modified: cfe/trunk/include/clang/Tooling/Execution.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Execution.h?rev=329784&r1=329783&r2=329784&view=diff
==
--- cfe/trunk/include/clang/Tooling/Execution.h (original)
+++ cfe/trunk/include/clang/Tooling/Execution.h Wed Apr 11 01:13:07 2018
@@ -32,6 +32,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Registry.h"
+#include "llvm/Support/StringSaver.h"
 
 namespace clang {
 namespace tooling {
@@ -45,20 +46,30 @@ class ToolResults {
 public:
   virtual ~ToolResults() = default;
   virtual void addResult(StringRef Key, StringRef Value) = 0;
-  virtual std::vector> AllKVResults() = 0;
+  virtual std::vector>
+  AllKVResults() = 0;
   virtual void forEachResult(
   llvm::function_ref Callback) = 0;
 };
 
+/// \brief Stores the key-value results in memory. It maintains the lifetime of
+/// the result. Clang tools using this class are expected to generate a small
+/// set of different results, or a large set of duplicated results.
 class InMemoryToolResults : public ToolResults {
 public:
+  InMemoryToolResults() : StringsPool(Arena) {}
   void addResult(StringRef Key, StringRef Value) override;
-  std::vector> AllKVResults() override;
+  std::vector>
+  AllKVResults() override;
   void forEachResult(llvm::function_ref
  Callback) override;
 
 private:
-  std::vector> KVResults;
+  llvm::BumpPtrAllocator Arena;
+  llvm::StringSaver StringsPool;
+  llvm::DenseSet Strings;
+
+  std::vector> KVResults;
 };
 
 /// \brief The context of an execution, including the information about

Modified: cfe/trunk/lib/Tooling/AllTUsExecution.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/AllTUsExecution.cpp?rev=329784&r1=329783&r2=329784&view=diff
==
--- cfe/trunk/lib/Tooling/AllTUsExecution.cpp (original)
+++ cfe/trunk/lib/Tooling/AllTUsExecution.cpp Wed Apr 11 01:13:07 2018
@@ -36,7 +36,8 @@ public:
 Results.addResult(Key, Value);
   }
 
-  std::vector> AllKVResults() override {
+  std::vector>
+  AllKVResults() override {
 return Results.AllKVResults();
   }
 

Modified: cfe/trunk/lib/Tooling/Execution.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Execution.cpp?rev=329784&r1=329783&r2=329784&view=diff
==
--- cfe/trunk/lib/Tooling/Execution.cpp (original)
+++ cfe/trunk/lib/Tooling/Execution.cpp Wed Apr 11 01:13:07 2018
@@ -21,10 +21,19 @@ static llvm::cl::opt
  llvm::cl::init("standalone"));
 
 void InMemoryToolResults::addResult(StringRef Key, StringRef Value) {
-  KVResults.push_back({Key.str(), Value.str()});
+  auto Intern = [&](StringRef &V) {
+auto R = Strings.insert(V);
+if (R.second) { // A new entry, create a new string copy.
+  *R.first = StringsPool.save(V);
+}
+V = *R.first;
+  };
+  Intern(Key);
+  Intern(Value);
+  KVResults.push_back({Key, Value});
 }
 
-std::vector>
+std::vector>
 InMemoryToolResults::AllKVResults() {
   return KVResults;
 }


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


[PATCH] D45479: [Tooling] Optimize memory usage in InMemoryToolResults.

2018-04-11 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329784: [Tooling] Optimize memory usage in 
InMemoryToolResults. (authored by hokein, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45479?vs=141842&id=141956#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45479

Files:
  include/clang/Tooling/Execution.h
  lib/Tooling/AllTUsExecution.cpp
  lib/Tooling/Execution.cpp


Index: lib/Tooling/Execution.cpp
===
--- lib/Tooling/Execution.cpp
+++ lib/Tooling/Execution.cpp
@@ -21,10 +21,19 @@
  llvm::cl::init("standalone"));
 
 void InMemoryToolResults::addResult(StringRef Key, StringRef Value) {
-  KVResults.push_back({Key.str(), Value.str()});
+  auto Intern = [&](StringRef &V) {
+auto R = Strings.insert(V);
+if (R.second) { // A new entry, create a new string copy.
+  *R.first = StringsPool.save(V);
+}
+V = *R.first;
+  };
+  Intern(Key);
+  Intern(Value);
+  KVResults.push_back({Key, Value});
 }
 
-std::vector>
+std::vector>
 InMemoryToolResults::AllKVResults() {
   return KVResults;
 }
Index: lib/Tooling/AllTUsExecution.cpp
===
--- lib/Tooling/AllTUsExecution.cpp
+++ lib/Tooling/AllTUsExecution.cpp
@@ -36,7 +36,8 @@
 Results.addResult(Key, Value);
   }
 
-  std::vector> AllKVResults() override {
+  std::vector>
+  AllKVResults() override {
 return Results.AllKVResults();
   }
 
Index: include/clang/Tooling/Execution.h
===
--- include/clang/Tooling/Execution.h
+++ include/clang/Tooling/Execution.h
@@ -32,6 +32,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Registry.h"
+#include "llvm/Support/StringSaver.h"
 
 namespace clang {
 namespace tooling {
@@ -45,20 +46,30 @@
 public:
   virtual ~ToolResults() = default;
   virtual void addResult(StringRef Key, StringRef Value) = 0;
-  virtual std::vector> AllKVResults() = 0;
+  virtual std::vector>
+  AllKVResults() = 0;
   virtual void forEachResult(
   llvm::function_ref Callback) = 0;
 };
 
+/// \brief Stores the key-value results in memory. It maintains the lifetime of
+/// the result. Clang tools using this class are expected to generate a small
+/// set of different results, or a large set of duplicated results.
 class InMemoryToolResults : public ToolResults {
 public:
+  InMemoryToolResults() : StringsPool(Arena) {}
   void addResult(StringRef Key, StringRef Value) override;
-  std::vector> AllKVResults() override;
+  std::vector>
+  AllKVResults() override;
   void forEachResult(llvm::function_ref
  Callback) override;
 
 private:
-  std::vector> KVResults;
+  llvm::BumpPtrAllocator Arena;
+  llvm::StringSaver StringsPool;
+  llvm::DenseSet Strings;
+
+  std::vector> KVResults;
 };
 
 /// \brief The context of an execution, including the information about


Index: lib/Tooling/Execution.cpp
===
--- lib/Tooling/Execution.cpp
+++ lib/Tooling/Execution.cpp
@@ -21,10 +21,19 @@
  llvm::cl::init("standalone"));
 
 void InMemoryToolResults::addResult(StringRef Key, StringRef Value) {
-  KVResults.push_back({Key.str(), Value.str()});
+  auto Intern = [&](StringRef &V) {
+auto R = Strings.insert(V);
+if (R.second) { // A new entry, create a new string copy.
+  *R.first = StringsPool.save(V);
+}
+V = *R.first;
+  };
+  Intern(Key);
+  Intern(Value);
+  KVResults.push_back({Key, Value});
 }
 
-std::vector>
+std::vector>
 InMemoryToolResults::AllKVResults() {
   return KVResults;
 }
Index: lib/Tooling/AllTUsExecution.cpp
===
--- lib/Tooling/AllTUsExecution.cpp
+++ lib/Tooling/AllTUsExecution.cpp
@@ -36,7 +36,8 @@
 Results.addResult(Key, Value);
   }
 
-  std::vector> AllKVResults() override {
+  std::vector>
+  AllKVResults() override {
 return Results.AllKVResults();
   }
 
Index: include/clang/Tooling/Execution.h
===
--- include/clang/Tooling/Execution.h
+++ include/clang/Tooling/Execution.h
@@ -32,6 +32,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Registry.h"
+#include "llvm/Support/StringSaver.h"
 
 namespace clang {
 namespace tooling {
@@ -45,20 +46,30 @@
 public:
   virtual ~ToolResults() = default;
   virtual void addResult(StringRef Key, StringRef Value) = 0;
-  virtual std::vector> AllKVResults() = 0;
+  virtual std::vector>
+  AllKVResults() = 0;
   virtual void forEachResult(
   llvm::function_ref Callback) = 0;
 };
 
+/// \brief Stores the key-value results in memory. It maintains the lifetime of
+/// the result. Clang tools using this class are expected to generate a small
+/// set of differe

[PATCH] D45442: Parse .h files as objective-c++ if we don't have a compile command.

2018-04-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 141957.
sammccall added a comment.
Herald added a subscriber: mgorny.

Add test, shave required yaks


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45442

Files:
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  unittests/clangd/CMakeLists.txt
  unittests/clangd/GlobalCompilationDatabaseTests.cpp
  unittests/clangd/TestFS.cpp

Index: unittests/clangd/TestFS.cpp
===
--- unittests/clangd/TestFS.cpp
+++ unittests/clangd/TestFS.cpp
@@ -55,8 +55,10 @@
 std::string testPath(PathRef File) {
   assert(sys::path::is_relative(File) && "FileName should be relative");
 
+  SmallString<32> NativeFile = File;
+  sys::path::native(NativeFile);
   SmallString<32> Path;
-  sys::path::append(Path, testRoot(), File);
+  sys::path::append(Path, testRoot(), NativeFile);
   return Path.str();
 }
 
Index: unittests/clangd/GlobalCompilationDatabaseTests.cpp
===
--- /dev/null
+++ unittests/clangd/GlobalCompilationDatabaseTests.cpp
@@ -0,0 +1,37 @@
+//===-- GlobalCompilationDatabaseTests.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "GlobalCompilationDatabase.h"
+
+#include "TestFS.h"
+#include "llvm/ADT/StringExtras.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+using ::testing::ElementsAre;
+
+TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
+  DirectoryBasedGlobalCompilationDatabase DB(llvm::None);
+  auto Cmd = DB.getFallbackCommand(testPath("foo/bar.cc"));
+  EXPECT_EQ(Cmd.Directory, testPath("foo"));
+  EXPECT_THAT(Cmd.CommandLine, ElementsAre("clang", testPath("foo/bar.cc")));
+  EXPECT_EQ(Cmd.Output, "");
+
+  // .h files have unknown language, so they are parsed liberally as obj-c++.
+  Cmd = DB.getFallbackCommand(testPath("foo/bar.h"));
+  EXPECT_THAT(Cmd.CommandLine, ElementsAre("clang", "-xobjective-c++-header",
+   testPath("foo/bar.h")));
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: unittests/clangd/CMakeLists.txt
===
--- unittests/clangd/CMakeLists.txt
+++ unittests/clangd/CMakeLists.txt
@@ -18,6 +18,7 @@
   DraftStoreTests.cpp
   FileIndexTests.cpp
   FuzzyMatchTests.cpp
+  GlobalCompilationDatabaseTests.cpp
   HeadersTests.cpp
   IndexTests.cpp
   JSONExprTests.cpp
Index: clangd/GlobalCompilationDatabase.h
===
--- clangd/GlobalCompilationDatabase.h
+++ clangd/GlobalCompilationDatabase.h
@@ -52,6 +52,7 @@
 public:
   DirectoryBasedGlobalCompilationDatabase(
   llvm::Optional CompileCommandsDir);
+  ~DirectoryBasedGlobalCompilationDatabase() override;
 
   /// Scans File's parents looking for compilation databases.
   /// Any extra flags will be added.
Index: clangd/GlobalCompilationDatabase.cpp
===
--- clangd/GlobalCompilationDatabase.cpp
+++ clangd/GlobalCompilationDatabase.cpp
@@ -18,17 +18,26 @@
 
 tooling::CompileCommand
 GlobalCompilationDatabase::getFallbackCommand(PathRef File) const {
+  std::vector Argv = {"clang"};
+  // Clang treats .h files as C by default, resulting in unhelpful diagnostics.
+  // Parsing as Objective C++ is friendly to more cases.
+  if (llvm::sys::path::extension(File) == ".h")
+Argv.push_back("-xobjective-c++-header");
+  Argv.push_back(File);
   return tooling::CompileCommand(llvm::sys::path::parent_path(File),
  llvm::sys::path::filename(File),
- {"clang", File.str()},
+ std::move(Argv),
  /*Output=*/"");
 }
 
 DirectoryBasedGlobalCompilationDatabase::
 DirectoryBasedGlobalCompilationDatabase(
 llvm::Optional CompileCommandsDir)
 : CompileCommandsDir(std::move(CompileCommandsDir)) {}
 
+DirectoryBasedGlobalCompilationDatabase::
+~DirectoryBasedGlobalCompilationDatabase() = default;
+
 llvm::Optional
 DirectoryBasedGlobalCompilationDatabase::getCompileCommand(PathRef File) const {
   if (auto CDB = getCDBForFile(File)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45442: Parse .h files as objective-c++ if we don't have a compile command.

2018-04-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Added a unit test, and cleaned up a couple of things to make it pass:

- GlobalCompilationDatabase.h wasn't self-contained due to incomplete types
- testPath() isn't very usable with subdirectories on windows




Comment at: clangd/GlobalCompilationDatabase.cpp:24
+  // Parsing as Objective C++ is friendly to more cases.
+  if (llvm::sys::path::extension(File) == ".h")
+Argv.push_back("-xobjective-c++-header");

ilya-biryukov wrote:
> sammccall wrote:
> > ilya-biryukov wrote:
> > > Maybe use `.equals_lower(".h")` instead? Just in case.
> > .H is (unambiguously) c++, and will be treated as such by clang.
> Wasn't aware of that convention, thanks.
> In that case, LG
Yeah .C/.H is rare these days I think. (But present in Driver/Types.cpp)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45442



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


[PATCH] D44970: [XRay][clang] Add flag to choose instrumentation bundles

2018-04-11 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris updated this revision to Diff 141958.
dberris marked an inline comment as done.
dberris added a comment.
Herald added a subscriber: mgorny.

- Rebase
- Address comments to use a bitmask/bitset for instrumentation bundle


https://reviews.llvm.org/D44970

Files:
  clang/include/clang/Basic/XRayInstr.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/XRayArgs.h
  clang/include/clang/Frontend/CodeGenOptions.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/XRayInstr.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/XRayArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/xray-instrumentation-bundles.cpp

Index: clang/test/CodeGen/xray-instrumentation-bundles.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-instrumentation-bundles.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fxray-instrument -fxray-instrumentation-bundle=none -x c++ \
+// RUN: -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,NOFUNCTION,NOCUSTOM %s
+// RUN: %clang_cc1 -fxray-instrument \
+// RUN: -fxray-instrumentation-bundle=function -x c++ \
+// RUN: -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,FUNCTION,NOCUSTOM %s
+// RUN: %clang_cc1 -fxray-instrument \
+// RUN: -fxray-instrumentation-bundle=custom -x c++ \
+// RUN: -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s \
+// RUN: | FileCheck --check-prefixes CHECK,NOFUNCTION,CUSTOM %s
+
+// CHECK: define void @_Z16alwaysInstrumentv() #[[ALWAYSATTR:[0-9]+]] {
+[[clang::xray_always_instrument]] void alwaysInstrument() {
+  static constexpr char kPhase[] = "always";
+  __xray_customevent(kPhase, 6);
+  // CUSTOM: call void @llvm.xray.customevent(i8*{{.*}}, i32 6)
+  // NOCUSTOM-NOT: call void @llvm.xray.customevent(i8*{{.*}}, i32 6)
+}
+
+// FUNCTION: attributes #[[ALWAYSATTR]] = {{.*}} "function-instrument"="xray-always" {{.*}}
+// NOFUNCTION-NOT: attributes #[[ALWAYSATTR]] = {{.*}} "function-instrument"="xray-always" {{.*}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -26,6 +26,7 @@
 #include "clang/Basic/VersionTuple.h"
 #include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Basic/Visibility.h"
+#include "clang/Basic/XRayInstr.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -75,9 +76,9 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Regex.h"
+#include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetOptions.h"
-#include "llvm/Support/ScopedPrinter.h"
 #include 
 #include 
 #include 
@@ -446,6 +447,25 @@
   }
 }
 
+static void parseXRayInstrumentationBundle(StringRef FlagName, StringRef Bundle,
+   ArgList &Args, DiagnosticsEngine &D,
+   XRayInstrSet &S) {
+  llvm::SmallVector BundleParts;
+  llvm::SplitString(Bundle, BundleParts, ",");
+  for (const auto B : BundleParts) {
+auto Mask = parseXRayInstrValue(B);
+if (Mask == 0)
+  if (B != "none")
+D.Report(diag::err_drv_invalid_value) << FlagName << Bundle;
+  else
+S.Mask = Mask;
+else if (Mask == XRayInstrKind::All)
+  S.Mask = Mask;
+else
+  S.set(Mask, true);
+  }
+}
+
 // Set the profile kind for fprofile-instrument.
 static void setPGOInstrumentor(CodeGenOptions &Opts, ArgList &Args,
DiagnosticsEngine &Diags) {
@@ -821,11 +841,23 @@
   Args.hasArg(OPT_finstrument_functions_after_inlining);
   Opts.InstrumentFunctionEntryBare =
   Args.hasArg(OPT_finstrument_function_entry_bare);
-  Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
+
+  Opts.XRayInstrumentFunctions =
+  Args.hasArg(OPT_fxray_instrument);
   Opts.XRayAlwaysEmitCustomEvents =
   Args.hasArg(OPT_fxray_always_emit_customevents);
   Opts.XRayInstructionThreshold =
   getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
+
+  auto XRayInstrBundles =
+  Args.getAllArgValues(OPT_fxray_instrumentation_bundle);
+  if (XRayInstrBundles.empty())
+Opts.XRayInstrumentationBundle.Mask = XRayInstrKind::All;
+  else
+for (const auto &A : XRayInstrBundles)
+  parseXRayInstrumentationBundle("-fxray-instrumentation-bundle=", A, Args,
+ Diags, Opts.XRayInstrumentationBundle);
+
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.CallFEntry = Args.hasArg(OPT_mfentry);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);

[PATCH] D45512: [Tooling] Correct the "-std" compile command option.

2018-04-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a subscriber: klimek.

"-std c++11" is not valid in compiler, we have to use "-std=c++11".

Test in vscode with this patch, code completion for header works as expected.


Repository:
  rC Clang

https://reviews.llvm.org/D45512

Files:
  lib/Tooling/InterpolatingCompilationDatabase.cpp
  unittests/Tooling/CompilationDatabaseTest.cpp


Index: unittests/Tooling/CompilationDatabaseTest.cpp
===
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -711,9 +711,9 @@
 
   // .h is ambiguous, so we add explicit language flags
   EXPECT_EQ(getCommand("foo.h"),
-"clang -D dir/foo.cpp -x c++-header -std c++17");
+"clang -D dir/foo.cpp -x c++-header -std=c++17");
   // and don't add -x if the inferred language is correct.
-  EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std c++17");
+  EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std=c++17");
   // respect -x if it's already there.
   EXPECT_EQ(getCommand("baz.h"), "clang -D dir/baz.cee -x c-header");
   // prefer a worse match with the right language
Index: lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -191,9 +191,9 @@
 // --std flag may only be transferred if the language is the same.
 // We may consider "translating" these, e.g. c++11 -> c11.
 if (Std != LangStandard::lang_unspecified && foldType(TargetType) == Type) 
{
-  Result.CommandLine.push_back("-std");
   Result.CommandLine.push_back(
-  LangStandard::getLangStandardForKind(Std).getName());
+  "-std=" +
+  std::string(LangStandard::getLangStandardForKind(Std).getName()));
 }
 Result.CommandLine.push_back(Filename);
 return Result;


Index: unittests/Tooling/CompilationDatabaseTest.cpp
===
--- unittests/Tooling/CompilationDatabaseTest.cpp
+++ unittests/Tooling/CompilationDatabaseTest.cpp
@@ -711,9 +711,9 @@
 
   // .h is ambiguous, so we add explicit language flags
   EXPECT_EQ(getCommand("foo.h"),
-"clang -D dir/foo.cpp -x c++-header -std c++17");
+"clang -D dir/foo.cpp -x c++-header -std=c++17");
   // and don't add -x if the inferred language is correct.
-  EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std c++17");
+  EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std=c++17");
   // respect -x if it's already there.
   EXPECT_EQ(getCommand("baz.h"), "clang -D dir/baz.cee -x c-header");
   // prefer a worse match with the right language
Index: lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -191,9 +191,9 @@
 // --std flag may only be transferred if the language is the same.
 // We may consider "translating" these, e.g. c++11 -> c11.
 if (Std != LangStandard::lang_unspecified && foldType(TargetType) == Type) {
-  Result.CommandLine.push_back("-std");
   Result.CommandLine.push_back(
-  LangStandard::getLangStandardForKind(Std).getName());
+  "-std=" +
+  std::string(LangStandard::getLangStandardForKind(Std).getName()));
 }
 Result.CommandLine.push_back(Filename);
 return Result;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45406: Document -std= values for different languages

2018-04-11 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

Ping


Repository:
  rC Clang

https://reviews.llvm.org/D45406



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


[PATCH] D45512: [Tooling] Correct the "-std" compile command option.

2018-04-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D45512



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


[PATCH] D45513: [clangd] Add line and column number to the index symbol.

2018-04-11 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: MaskRay, ioeric, jkorous-apple, ilya-biryukov, klimek.

LSP is using Line & column as symbol position, clangd needs to transfer file
offset to Line & column when sending results back to LSP client, which is a high
cost, especially for finding workspace symbol -- we have to read the file
content from disk (if it isn't loaded in memory).

Saving these information in the index will make the clangd life eaiser.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45513

Files:
  clangd/index/Index.h
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolYAML.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -59,6 +59,21 @@
   return arg.Definition.StartOffset == Offsets.first &&
  arg.Definition.EndOffset == Offsets.second;
 }
+MATCHER_P(DeclRangePos, Pos, "") {
+  return std::tie(arg.CanonicalDeclaration.StartPos.Line,
+  arg.CanonicalDeclaration.StartPos.Character,
+  arg.CanonicalDeclaration.EndPos.Line,
+  arg.CanonicalDeclaration.EndPos.Character) ==
+ std::tie(Pos.start.line, Pos.start.character, Pos.end.line,
+  Pos.end.character);
+}
+MATCHER_P(DefRangePos, Pos, "") {
+  return std::tie(arg.Definition.StartPos.Line,
+  arg.Definition.StartPos.Character, arg.Definition.EndPos.Line,
+  arg.Definition.EndPos.Character) ==
+ std::tie(Pos.start.line, Pos.start.character, Pos.end.line,
+  Pos.end.character);
+}
 MATCHER_P(Refs, R, "") { return int(arg.References) == R; }
 
 namespace clang {
@@ -209,7 +224,8 @@
   )");
   runSymbolCollector(Header.code(), /*Main=*/"");
   EXPECT_THAT(Symbols, UnorderedElementsAreArray({AllOf(
-   QName("Tmpl"), DeclRange(Header.offsetRange()))}));
+   QName("Tmpl"), DeclRange(Header.offsetRange()),
+   DeclRangePos(Header.range()))}));
 }
 
 TEST_F(SymbolCollectorTest, Locations) {
@@ -234,13 +250,24 @@
   EXPECT_THAT(
   Symbols,
   UnorderedElementsAre(
-  AllOf(QName("X"), DeclRange(Header.offsetRange("xdecl")),
-DefRange(Main.offsetRange("xdef"))),
-  AllOf(QName("Cls"), DeclRange(Header.offsetRange("clsdecl")),
-DefRange(Main.offsetRange("clsdef"))),
-  AllOf(QName("print"), DeclRange(Header.offsetRange("printdecl")),
-DefRange(Main.offsetRange("printdef"))),
-  AllOf(QName("Z"), DeclRange(Header.offsetRange("zdecl");
+  AllOf(QName("X"),
+DeclRange(Header.offsetRange("xdecl")),
+DeclRangePos(Header.range("xdecl")),
+DefRange(Main.offsetRange("xdef")),
+DefRangePos(Main.range("xdef"))),
+  AllOf(QName("Cls"),
+DeclRange(Header.offsetRange("clsdecl")),
+DeclRangePos(Header.range("clsdecl")),
+DefRange(Main.offsetRange("clsdef")),
+DefRangePos(Main.range("clsdef"))),
+  AllOf(QName("print"),
+DeclRange(Header.offsetRange("printdecl")),
+DeclRangePos(Header.range("printdecl")),
+DefRange(Main.offsetRange("printdef")),
+DefRangePos(Main.range("printdef"))),
+  AllOf(QName("Z"),
+DeclRange(Header.offsetRange("zdecl")),
+DeclRangePos(Header.range("zdecl");
 }
 
 TEST_F(SymbolCollectorTest, References) {
@@ -365,9 +392,13 @@
   EXPECT_THAT(
   Symbols,
   UnorderedElementsAre(
-  AllOf(QName("abc_Test"), DeclRange(Header.offsetRange("expansion")),
+  AllOf(QName("abc_Test"),
+DeclRange(Header.offsetRange("expansion")),
+DeclRangePos(Header.range("expansion")),
 DeclURI(TestHeaderURI)),
-  AllOf(QName("Test"), DeclRange(Header.offsetRange("spelling")),
+  AllOf(QName("Test"),
+DeclRange(Header.offsetRange("spelling")),
+DeclRangePos(Header.range("spelling")),
 DeclURI(TestHeaderURI;
 }
 
@@ -382,7 +413,9 @@
  /*ExtraArgs=*/{"-DNAME=name"});
   EXPECT_THAT(Symbols,
   UnorderedElementsAre(AllOf(
-  QName("name"), DeclRange(Header.offsetRange("expansion")),
+  QName("name"),
+  DeclRange(Header.offsetRange("expansion")),
+  DeclRangePos(Header.range("expansion")),
   DeclURI(TestHeaderURI;
 }
 
@@ -514,6 +547,12 @@
   StartOffset: 0
   EndOffset:   1
   FileURI:file:///path/foo.h
+  StartPos:
+line: 0
+character: 0
+  EndPos:
+line: 0
+c

r329786 - [Tooling] Correct the "-std" compile command option.

2018-04-11 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Apr 11 02:18:18 2018
New Revision: 329786

URL: http://llvm.org/viewvc/llvm-project?rev=329786&view=rev
Log:
[Tooling] Correct the "-std" compile command option.

Summary:
"-std c++11" is not valid in compiler, we have to use "-std=c++11".

Test in vscode with this patch, code completion for header works as expected.

Reviewers: sammccall

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp

Modified: cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp?rev=329786&r1=329785&r2=329786&view=diff
==
--- cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp Wed Apr 11 
02:18:18 2018
@@ -191,9 +191,9 @@ struct TransferableCommand {
 // --std flag may only be transferred if the language is the same.
 // We may consider "translating" these, e.g. c++11 -> c11.
 if (Std != LangStandard::lang_unspecified && foldType(TargetType) == Type) 
{
-  Result.CommandLine.push_back("-std");
   Result.CommandLine.push_back(
-  LangStandard::getLangStandardForKind(Std).getName());
+  "-std=" +
+  std::string(LangStandard::getLangStandardForKind(Std).getName()));
 }
 Result.CommandLine.push_back(Filename);
 return Result;

Modified: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp?rev=329786&r1=329785&r2=329786&view=diff
==
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp Wed Apr 11 02:18:18 
2018
@@ -711,9 +711,9 @@ TEST_F(InterpolateTest, Language) {
 
   // .h is ambiguous, so we add explicit language flags
   EXPECT_EQ(getCommand("foo.h"),
-"clang -D dir/foo.cpp -x c++-header -std c++17");
+"clang -D dir/foo.cpp -x c++-header -std=c++17");
   // and don't add -x if the inferred language is correct.
-  EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std c++17");
+  EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std=c++17");
   // respect -x if it's already there.
   EXPECT_EQ(getCommand("baz.h"), "clang -D dir/baz.cee -x c-header");
   // prefer a worse match with the right language


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


[PATCH] D45512: [Tooling] Correct the "-std" compile command option.

2018-04-11 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329786: [Tooling] Correct the "-std" compile 
command option. (authored by hokein, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D45512

Files:
  cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
  cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp


Index: cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -191,9 +191,9 @@
 // --std flag may only be transferred if the language is the same.
 // We may consider "translating" these, e.g. c++11 -> c11.
 if (Std != LangStandard::lang_unspecified && foldType(TargetType) == Type) 
{
-  Result.CommandLine.push_back("-std");
   Result.CommandLine.push_back(
-  LangStandard::getLangStandardForKind(Std).getName());
+  "-std=" +
+  std::string(LangStandard::getLangStandardForKind(Std).getName()));
 }
 Result.CommandLine.push_back(Filename);
 return Result;
Index: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -711,9 +711,9 @@
 
   // .h is ambiguous, so we add explicit language flags
   EXPECT_EQ(getCommand("foo.h"),
-"clang -D dir/foo.cpp -x c++-header -std c++17");
+"clang -D dir/foo.cpp -x c++-header -std=c++17");
   // and don't add -x if the inferred language is correct.
-  EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std c++17");
+  EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std=c++17");
   // respect -x if it's already there.
   EXPECT_EQ(getCommand("baz.h"), "clang -D dir/baz.cee -x c-header");
   // prefer a worse match with the right language


Index: cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ cfe/trunk/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -191,9 +191,9 @@
 // --std flag may only be transferred if the language is the same.
 // We may consider "translating" these, e.g. c++11 -> c11.
 if (Std != LangStandard::lang_unspecified && foldType(TargetType) == Type) {
-  Result.CommandLine.push_back("-std");
   Result.CommandLine.push_back(
-  LangStandard::getLangStandardForKind(Std).getName());
+  "-std=" +
+  std::string(LangStandard::getLangStandardForKind(Std).getName()));
 }
 Result.CommandLine.push_back(Filename);
 return Result;
Index: cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
+++ cfe/trunk/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -711,9 +711,9 @@
 
   // .h is ambiguous, so we add explicit language flags
   EXPECT_EQ(getCommand("foo.h"),
-"clang -D dir/foo.cpp -x c++-header -std c++17");
+"clang -D dir/foo.cpp -x c++-header -std=c++17");
   // and don't add -x if the inferred language is correct.
-  EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std c++17");
+  EXPECT_EQ(getCommand("foo.hpp"), "clang -D dir/foo.cpp -std=c++17");
   // respect -x if it's already there.
   EXPECT_EQ(getCommand("baz.h"), "clang -D dir/baz.cee -x c-header");
   // prefer a worse match with the right language
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44203: [clang-format] Improve Incomplete detection for (text) protos

2018-04-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: lib/Format/TokenAnnotator.cpp:773
 case tok::r_brace:
-  // Lines can start with '}'.
-  if (Tok->Previous)
+  // Lines can start with '}' except in text protos.
+  if (Tok->Previous || Style.Language == FormatStyle::LK_TextProto)

krasimir wrote:
> sammccall wrote:
> > In what sense of "line" is this true?
> This is the UnwrappedLine concept of clang-format: roughly a maximal sequence 
> of tokens that we could have put on the same line if there was no column 
> limit.
I still don't understand why it's true for say C or JS then.
(kinda relevant here because I would like to understand why proto is an 
exception)



Comment at: unittests/Format/FormatTestProto.cpp:21
 class FormatTestProto : public ::testing::Test {
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+

DoNotCheck is never used, consider removing it



Comment at: unittests/Format/FormatTestProto.cpp:21
 class FormatTestProto : public ::testing::Test {
+  enum StatusCheck { SC_ExpectComplete, SC_ExpectIncomplete, SC_DoNotCheck };
+

sammccall wrote:
> DoNotCheck is never used, consider removing it
(nit: is the SC_ prefix really needed in tests?)


Repository:
  rC Clang

https://reviews.llvm.org/D44203



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


[PATCH] D43871: [modules] No longer include stdlib.h from mm_malloc.h.

2018-04-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaExceptionSpec.cpp:312
+OldProto->getReturnType(), OldProto->getParamTypes(),
+OldProto->getExtProtoInfo().withExceptionSpec(EST_DynamicNone)));
+return false;

Updating the old function's type here can potentially violate our AST 
invariants, especially in C++17 where it will change the canonical type of the 
function. You would need to at least notify AST mutation listeners, and iterate 
over all previous declarations rather than only updating one of them. (You're 
also throwing away things like calling conventions here.)

`Sema::UpdateExceptionSpec` handles these details for you.


https://reviews.llvm.org/D43871



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


[PATCH] D45478: [clangd] Merge symbols in global-sym-builder on the go

2018-04-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Is this patch still relevant after haojian's string deduplication?




Comment at: clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp:53
 
+/// Combines occurrences of the same symbols across translation units.
+class SymbolMerger {

Seems reasonably likely we would actually have contention here? merging 
per-thread (combiner) and then globally at the end (reducer) might be the way 
to go (might be significantly faster). But not sure how big the impact is.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45478



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


[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident

2018-04-11 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

ping


https://reviews.llvm.org/D45255



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


[PATCH] D43764: [clang-apply-replacements] Convert tooling::Replacements to tooling::AtomicChange for conflict resolving of changes, code cleanup, and code formatting.

2018-04-11 Thread Jeremy Demeule via Phabricator via cfe-commits
jdemeule updated this revision to Diff 141969.
jdemeule marked 3 inline comments as done.
jdemeule added a comment.

Sort replacements before converting them to AtomicChange.


https://reviews.llvm.org/D43764

Files:
  
clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-apply-replacements/tool/CMakeLists.txt
  clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  test/clang-apply-replacements/Inputs/basic/file2.yaml
  test/clang-apply-replacements/Inputs/conflict/expected.txt
  test/clang-apply-replacements/Inputs/identical/file1.yaml
  test/clang-apply-replacements/Inputs/identical/identical.cpp
  test/clang-apply-replacements/Inputs/order-dependent/expected.txt
  test/clang-apply-replacements/Inputs/order-dependent/file1.yaml
  test/clang-apply-replacements/Inputs/order-dependent/file2.yaml
  test/clang-apply-replacements/Inputs/order-dependent/order-dependent.cpp
  test/clang-apply-replacements/identical.cpp
  test/clang-apply-replacements/order-dependent.cpp
  unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
  unittests/clang-apply-replacements/CMakeLists.txt
  unittests/clang-apply-replacements/ReformattingTest.cpp

Index: unittests/clang-apply-replacements/ReformattingTest.cpp
===
--- unittests/clang-apply-replacements/ReformattingTest.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-//===- clang-apply-replacements/ReformattingTest.cpp --===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "clang-apply-replacements/Tooling/ApplyReplacements.h"
-#include "common/VirtualFileHelper.h"
-#include "clang/Format/Format.h"
-#include "clang/Tooling/Refactoring.h"
-#include "gtest/gtest.h"
-
-using namespace clang;
-using namespace clang::tooling;
-using namespace clang::replace;
-
-typedef std::vector ReplacementsVec;
-
-static Replacement makeReplacement(unsigned Offset, unsigned Length,
-   unsigned ReplacementLength,
-   llvm::StringRef FilePath = "") {
-  return Replacement(FilePath, Offset, Length,
- std::string(ReplacementLength, '~'));
-}
-
-// generate a set of replacements containing one element
-static ReplacementsVec makeReplacements(unsigned Offset, unsigned Length,
-unsigned ReplacementLength,
-llvm::StringRef FilePath = "~") {
-  ReplacementsVec Replaces;
-  Replaces.push_back(
-  makeReplacement(Offset, Length, ReplacementLength, FilePath));
-  return Replaces;
-}
-
-// Put these functions in the clang::tooling namespace so arg-dependent name
-// lookup finds these functions for the EXPECT_EQ macros below.
-namespace clang {
-namespace tooling {
-
-std::ostream &operator<<(std::ostream &os, const Range &R) {
-  return os << "Range(" << R.getOffset() << ", " << R.getLength() << ")";
-}
-
-} // namespace tooling
-} // namespace clang
-
-// Ensure zero-length ranges are produced. Even lines where things are deleted
-// need reformatting.
-TEST(CalculateChangedRangesTest, producesZeroLengthRange) {
-  RangeVector Changes = calculateChangedRanges(makeReplacements(0, 4, 0));
-  EXPECT_EQ(Range(0, 0), Changes.front());
-}
-
-// Basic test to ensure replacements turn into ranges properly.
-TEST(CalculateChangedRangesTest, calculatesRanges) {
-  ReplacementsVec R;
-  R.push_back(makeReplacement(2, 0, 3));
-  R.push_back(makeReplacement(5, 2, 4));
-  RangeVector Changes = calculateChangedRanges(R);
-
-  Range ExpectedRanges[] = { Range(2, 3), Range(8, 4) };
-  EXPECT_TRUE(std::equal(Changes.begin(), Changes.end(), ExpectedRanges));
-}
Index: unittests/clang-apply-replacements/CMakeLists.txt
===
--- unittests/clang-apply-replacements/CMakeLists.txt
+++ unittests/clang-apply-replacements/CMakeLists.txt
@@ -9,12 +9,12 @@
 
 add_extra_unittest(ClangApplyReplacementsTests
   ApplyReplacementsTest.cpp
-  ReformattingTest.cpp
   )
 
 target_link_libraries(ClangApplyReplacementsTests
   PRIVATE
   clangApplyReplacements
   clangBasic
   clangToolingCore
+  clangToolingRefactor
   )
Index: unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
===
--- unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
+++ unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
@@ -9,6 +9,7 @@
 //===--===//
 
 #include "clang-apply-replacements/Tooling/ApplyReplacements.h"
+#include "clang/Format/Format.h"
 #include "gtest/gtest.h"
 

[PATCH] D45414: [clang-tidy] add missing assignment operations in hicpp-signed-bitwise

2018-04-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 141970.
JonasToth added a comment.

- remove shifting exception for standarized bitmask types


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45414

Files:
  clang-tidy/hicpp/SignedBitwiseCheck.cpp
  docs/ReleaseNotes.rst
  test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
  test/clang-tidy/hicpp-signed-bitwise.cpp

Index: test/clang-tidy/hicpp-signed-bitwise.cpp
===
--- test/clang-tidy/hicpp-signed-bitwise.cpp
+++ test/clang-tidy/hicpp-signed-bitwise.cpp
@@ -41,9 +41,12 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
   UResult = SValue & -1;
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
+  UResult&= 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
 
   UResult = UValue & 1u; // Ok
   UResult = UValue & UValue; // Ok
+  UResult&= 2u;  // Ok
 
   unsigned char UByte1 = 0u;
   unsigned char UByte2 = 16u;
@@ -68,18 +71,30 @@
   UByte1 = UByte1 | UByte2; // Ok
   UByte1 = UByte1 | SByte2;
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1|= SByte2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1|= UByte2; // Ok
 
   UByte1 = UByte1 ^ UByte2; // Ok
   UByte1 = UByte1 ^ SByte2;
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1^= SByte2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1^= UByte2; // Ok
 
   UByte1 = UByte1 >> UByte2; // Ok
   UByte1 = UByte1 >> SByte2;
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1>>= SByte2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1>>= UByte2; // Ok
 
   UByte1 = UByte1 << UByte2; // Ok
   UByte1 = UByte1 << SByte2;
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1<<= SByte2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
+  UByte1<<= UByte2; // Ok
 
   int SignedInt1 = 1 << 12;
   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use of a signed integer operand with a binary bitwise operator
@@ -195,10 +210,16 @@
   int s3;
   s3 = IntOne | IntTwo; // Signed
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
+  s3|= IntTwo; // Signed
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
   s3 = IntOne & IntTwo; // Signed
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
+  s3&= IntTwo; // Signed
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
   s3 = IntOne ^ IntTwo; // Signed
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
+  s3^= IntTwo; // Signed
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
   s3 = s1 | s2; // Signed
   // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
   s3 = s1 & s2; // Signed
Index: test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
===
--- test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
+++ test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
@@ -8,51 +8,57 @@
   std::locale::category C = std::locale::category::ctype;
 
   SResult = std::locale::category::none | std::locale::category::collate;
+  SResult|= std::locale::category::collate;
   SResult = std::locale::category::ctype & std::locale::category::monetary;
+  SResult&= std::locale::category::monetary;
   SResult = std::locale::category::numeric ^ std::locale::category::time;
+  SResult^= std::locale::category::time;
   SResult = std::locale::category::messages | std::locale::category::all;
 
   SResult = std::locale::category::all & C;
+  SResult&= std::locale::category::all;
   SResult = std::locale::category::all | C;
+  SResult|= std::locale::category::all;
   SResult = std::locale::category::all ^ C;
+  SResult^= std::locale::category::all;
 
   // std::ctype_base::mask
   std::ctype_base::mask M = std::ctype_base::mask::punct;
 
   SResult = std::ctype_base::mask::space | std::ctype_base::mask::print;
   SResult = std::ctype_base::mask::cntrl & std::ctype_base::mask::upper;
   SResult = std::ctype_base::mask::lower ^ std:

[PATCH] D45513: [clangd] Add line and column number to the index symbol.

2018-04-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/index/Index.h:27
 struct SymbolLocation {
+  struct Position {
+// Line position in a document (zero-based).

There are 4 of these per symbol, if we can keep line + character to 32 bits we 
save 16 bytes per symbol.

That looks like it might still be ~10% of non-string size. WDYT?
(12 bits for column and 20 bits for line seems like a reasonable guess)



Comment at: clangd/index/Index.h:28
+  struct Position {
+// Line position in a document (zero-based).
+int Line = 0;

These comments seem pretty obvious, I think
`int Line=0, Character=0 // zero-based` is enough, but up to you.

I would like a comment explaining why we're storing these redundant 
representations though.
e.g. `// Storing Line/Character allows us to build LSP responses without 
reading the file content.`





Comment at: clangd/index/Index.h:32
+// Character offset on a line in a document (zero-based).
+int Character = 0;
+  };

Column?

LSP calls this "character" but this is nonstandard and I find it very confusing 
with offset. 



Comment at: clangd/index/Index.h:39
   // using half-open range, [StartOffset, EndOffset).
+  // FIXME(hokein): remove these fields in favor of Position.
   unsigned StartOffset = 0;

I don't think we should remove them, we'll just have the same problem in 
reverse.
Could position have have line/col/offset, and have Position Start, End?



Comment at: clangd/index/SymbolCollector.cpp:206
+  Result.EndPos.Line = Result.StartPos.Line;
+  Result.EndPos.Character = Result.StartPos.Character + TokenLength;
+

I don't think this works, tokens can be split across lines.

I believe you want to compute NameLoc.locWithOffset(TokenLength) and then 
decompose that into line/col.
(getLocForEndOfToken, confusingly, is different)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45513



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


[PATCH] D45414: [clang-tidy] add missing assignment operations in hicpp-signed-bitwise

2018-04-11 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth closed this revision.
JonasToth added a comment.

Commit in https://reviews.llvm.org/rCTE329789


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45414



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


[PATCH] D45406: Document -std= values for different languages

2018-04-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Looks good to me, thank you


Repository:
  rC Clang

https://reviews.llvm.org/D45406



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


[PATCH] D43578: -ftime-report switch support in Clang

2018-04-11 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

In https://reviews.llvm.org/D43578#1062950, @thakis wrote:

> @davezarzycki remarks in https://reviews.llvm.org/D45485 that this breaks the 
> shared build. The proposed fix there is to make several of clang's modules 
> depend on LLVM's IR library ("Core"). This seems weird to me for two reasons, 
> one architectural, one form a build point of view:
>
> 1. The modules growing the dep don't really depend on IR, they just need that 
> one bool that happens to be defined there. That bool is called 
> `TimePassesIsEnabled` which is a reasonable bool to live in IR, but this 
> patch starts using that bool for meanings other than "should we time 
> passes?". It instead uses the same bool to decide if clang should print a 
> bunch of timing info. We probably should have a separate bool in clang and 
> key this off that and make -ftime-report set both.
> 2. From a build PoV, depending on Core means explicitly depending on TableGen 
> processing the Attributes.td and Intrinsics.td files in include/llvm/IR, 
> which needlessly (explicitly) serializes the build.


In fact the current trunk already depends on TimePassesIsEnabled (w/o this 
patch applied):

//$ find clang -name \*.cpp | xargs grep TimePassesIsEnabled
clang/lib/CodeGen/CodeGenAction.cpp:  llvm::TimePassesIsEnabled = 
TimePasses;
clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled) {
clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled) {
clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
clang/lib/CodeGen/CodeGenAction.cpp:if (llvm::TimePassesIsEnabled) {
clang/lib/CodeGen/CodeGenAction.cpp:if (llvm::TimePassesIsEnabled) {
clang/lib/CodeGen/BackendUtil.cpp:  TimeRegion Region(llvm::TimePassesIsEnabled 
? &CodeGenerationTime : nullptr);
clang/lib/CodeGen/BackendUtil.cpp:  TimeRegion Region(llvm::TimePassesIsEnabled 
? &CodeGenerationTime : nullptr);
//
But I agree that such dependence is not OK. I'll create a separate bool instead 
of TimePassesIsEnabled but the question is should I remove the above usage of 
TimePassesIsEnabled as well? Or maybe it should be a separate pre-patch? Or it 
could be left as it is?


Repository:
  rL LLVM

https://reviews.llvm.org/D43578



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


[PATCH] D38845: [ASTImporter] Support importing UnresolvedMemberExpr, DependentNameType, DependentScopeDeclRefExpr

2018-04-11 Thread Peter Szecsi via Phabricator via cfe-commits
szepet marked an inline comment as done.
szepet added a comment.

Hello Aleksei,

Thanks for carrying the ASTImporter improvements (in general)! I will rebase it 
and upload for sure, but probably just next week. (After EuroLLVM.)


https://reviews.llvm.org/D38845



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


[PATCH] D33537: [clang-tidy] Exception Escape Checker

2018-04-11 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Thank you for your thorough review, I will do the fixes next week, after the 
Euro LLVM.


https://reviews.llvm.org/D33537



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


[PATCH] D45476: [C++2a] Implement operator<=> CodeGen and ExprConstant

2018-04-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/ComparisonCategories.h:68
+  /// \brief A map containing the comparison category values built from the
+  /// standard library. The key is a value of ComparisonCategoryValue.
+  llvm::DenseMap Objects;

What is ComparisonCategoryValue? Do you mean ComparisonCategoryResult?



Comment at: include/clang/AST/ComparisonCategories.h:77-78
+  ///   comparison category. For example 'std::strong_equality::equal'
+  const DeclRefExpr *getResultValue(ComparisonCategoryResult ValueKind) const {
+const DeclRefExpr *DR = getResultValueUnsafe(ValueKind);
+assert(DR &&

This should deal in `DeclRefExpr*`s, not `NamedDecl*`s. We don't have an 
expression naming the comparison result value, and we shouldn't pretend we do.



Comment at: include/clang/AST/ComparisonCategories.h:175-177
+  /// \brief returns true if the comparison category data has already been
+  /// built, and false otherwise.
+  bool hasData() const { return HasData; }

I don't think this should be exposed. (I think we should only be building the 
CCK that we need when we request them, rather than building all five, and if we 
do that, then this function is meaningless.)



Comment at: include/clang/AST/ComparisonCategories.h:180
+public:
+  // implementation details which should only be used by the function creating
+  // and setting the data.

Comments should start with a capital letter.



Comment at: include/clang/AST/Expr.h:3097-3106
+  bool isRelationalOp() const {
+return isRelationalOp(getOpcode()) ||
+   (getOpcode() == BO_Cmp && IsCmpOrdered);
+  }
 
   static bool isEqualityOp(Opcode Opc) { return Opc == BO_EQ || Opc == BO_NE; }
+  bool isEqualityOp() const {

These seem wrong to me. Relational operators are `<`, `<=`, `>`, and `>=`. 
`<=>` is not a relational operator even if it's an ordered comparison. 
Likewise, `<=>` is not an equality operator even if we don't have an ordered 
comparison.

If you undo this, you can also drop the `IsCmpOrdered` member entirely.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9377-9378
+def err_implied_comparison_category_type_not_found : Error<
+  "%0 type was not found; include  before defining "
+  "or using 'operator<=>'">;
+def err_spaceship_argument_narrowing : Error<

This doesn't sound quite right. You can define your own `operator<=>` without 
including `` so long as you don't try to default it or use one of the 
standard comparison category kinds. Also, instead of saying "before doing X or 
Y", say which one the user actually did.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9384-9385
+def err_spaceship_comparison_of_void_ptr : Error<
+  "three-way comparison with void pointer %select{operand type|operand types}0 
"
+  "(%1 and %2)">;
+def err_spaceship_comparison_of_invalid_comp_type : Error<

Why are you diagnosing this case as an error?



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9386-9387
+  "(%1 and %2)">;
+def err_spaceship_comparison_of_invalid_comp_type : Error<
+  "three-way comparison of operands has composite type %0 (%1 and %2)">;
+def err_std_compare_type_missing_member : Error<

It's unclear to me what this diagnostic is supposed to mean. What actionable 
feedback is this supposed to be giving a user?



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9389
+def err_std_compare_type_missing_member : Error<
+  "%0 missing a member named '%1'">;
+def err_std_compare_type_invalid_member : Error<

"%0 *is* missing [...]"?



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9391
+def err_std_compare_type_invalid_member : Error<
+  "member '%1' of %0 is ill-formed">;
+def note_spaceship_operand_not_cce : Note<

What do you mean by "ill-formed" here?

I think what you really mean is "we don't understand how to deal with this 
definition of that member", so maybe we should just fold this and the prior 
diagnostic into something like "sorry, this standard library implementation of 
std::whatever is not supported"?



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9393
+def note_spaceship_operand_not_cce : Note<
+  "argument is not a constant expression">;
 } // end of sema component.

Is this really useful? I would think almost all the cases where you'd hit the 
"cannot be narrowed" error, this diagnostic and the explanation of why the 
operand is not constant would be meaningless noise, because it was never meant 
to be constant, and the problem is simply that you are trying to three-way 
compare integers of mixed signedness.



Comment at: lib/AST/ExprConstant.cpp:6238-6263
+bool VisitBinC

[PATCH] D43817: [x86] wbnoinvd intrinsic

2018-04-11 Thread Gabor Buella via Phabricator via cfe-commits
GBuella added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:188
 setFeatureEnabledImpl(Features, "mpx", true);
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);

craig.topper wrote:
> Not related to this patch, but does IcelakeServer have SGX? The adding 
> icelake-server patch and removing sgx from skylakeserver intersected here.
As far as I know both icelake-client & icelake-server has it.
https://software.intel.com/sites/default/files/managed/c5/15/architecture-instruction-set-extensions-programming-reference.pdf
says:
"ENCLV - Ice Lake Server and later ; Future Tremont and later"
enclv is an SGX leaf.


https://reviews.llvm.org/D43817



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


Re: r329784 - [Tooling] Optimize memory usage in InMemoryToolResults.

2018-04-11 Thread Alexander Kornienko via cfe-commits
On Wed, Apr 11, 2018 at 10:16 AM Haojian Wu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: hokein
> Date: Wed Apr 11 01:13:07 2018
> New Revision: 329784
> ...
>
> ==
> --- cfe/trunk/include/clang/Tooling/Execution.h (original)
> +++ cfe/trunk/include/clang/Tooling/Execution.h Wed Apr 11 01:13:07 2018
>
> @@ -45,20 +46,30 @@ class ToolResults {
>  public:
>virtual ~ToolResults() = default;
>virtual void addResult(StringRef Key, StringRef Value) = 0;
> -  virtual std::vector> AllKVResults()
> = 0;
> +  virtual std::vector>
> +  AllKVResults() = 0;
>

I would add a comment re: lifetime of the strings pointed by the return
value.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45363: [OpenCL] Added -std/-cl-std=CL2.2/CLC++

2018-04-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 141975.
Anastasia edited the summary of this revision.
Anastasia added a comment.

Changed to `-cl-std=c++` since it's explicitly defined in spec. We could reuse 
`OpenCLVersion` in `LangOpts` but I think it might be cleaner to add separate 
`OpenCLCPlusPlusVersion`.


https://reviews.llvm.org/D45363

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/autocomplete.c
  test/Driver/opencl.cl
  test/Driver/unknown-std.cl
  test/Frontend/opencl.cl
  test/Frontend/stdlang.c
  test/Preprocessor/predefined-macros.c

Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -159,6 +159,8 @@
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL20
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=c++ \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CLCPP10
 // CHECK-CL10: #define CL_VERSION_1_0 100
 // CHECK-CL10: #define CL_VERSION_1_1 110
 // CHECK-CL10: #define CL_VERSION_1_2 120
@@ -184,6 +186,10 @@
 // CHECK-CL20: #define __OPENCL_C_VERSION__ 200
 // CHECK-CL20-NOT: #define __FAST_RELAXED_MATH__ 1
 // CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP10: #define __CL_CPP_VERSION_1_0__ 100
+// CHECK-CLCPP10: #define __OPENCL_CPP_VERSION__ 100
+// CHECK-CLCPP10-NOT: #define __FAST_RELAXED_MATH__ 1
+// CHECK-CLCPP10-NOT: #define __ENDIAN_LITTLE__ 1
 
 // RUN: %clang_cc1 %s -E -dM -o - -x cl \
 // RUN:   | FileCheck %s --check-prefix=MSCOPE
Index: test/Frontend/stdlang.c
===
--- test/Frontend/stdlang.c
+++ test/Frontend/stdlang.c
@@ -4,6 +4,7 @@
 // RUN: %clang_cc1 -x cl -cl-std=cl1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl1.2 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=cl2.0 -DOPENCL %s
+// RUN: %clang_cc1 -x cl -cl-std=c++ -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.1 -DOPENCL %s
 // RUN: %clang_cc1 -x cl -cl-std=CL1.2 -DOPENCL %s
Index: test/Frontend/opencl.cl
===
--- test/Frontend/opencl.cl
+++ test/Frontend/opencl.cl
@@ -1,24 +1,33 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0
-// RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS
-// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS
-// RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=c++ -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -fblocks -DBLOCKS -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.1 -fblocks -DBLOCKS -DSYNTAX
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL1.2 -fblocks -DBLOCKS -DSYNTAX
+// RUN: %clang_cc1 %s -triple amdgcn--amdhsa -x c -std=c99 -verify -fsyntax-only -DSYNTAX
 // RUN: %clang_cc1 -cl-std=CL1.1 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION11 %s
 // RUN: %clang_cc1 -cl-std=CL1.2 -cl-strict-aliasing -fblocks %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION12 %s
 // RUN: %clang_cc1 -cl-std=CL2.0 -cl-strict-aliasing %s 2>&1 | FileCheck --check-prefix=CHECK-INVALID-OPENCL-VERSION20 %s
 
+#ifdef SYNTAX
+class test{
+int member;
+};
+#ifndef __OPENCL_CPP_VERSION__
+//expected-error@-4{{unknown type name 'class'}}
+//expected-error@-5{{expected ';' after top level declarator}}
+#endif
+#endif
+
 void f(void (^g)(void)) {
-#ifdef __OPENCL_C_VERSION__
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0 && !defined(BLOCKS)
-  // expected-error@-3{{blocks support disabled - compile with -fblocks or for OpenCL 2.0 or above}}
-#else
-  // expected-no-diagnostics
+#if defined(__OPENCL_C_VERSION__) || defined(__OPENCL_CPP_VERSION__)
+#if !defined(BLOCKS) && (defined(__OPENCL_CPP_VERSION__)  || __OPENCL_C_VERSION__ != CL_VERSION_2_0)
+  // expected-error@-3{{blocks support disabled - compile with -fblocks or for OpenCL 2.0}}
 #endif
 #else
-  // expected-error@-8{{blocks support disabled - compile with -fb

[PATCH] D45363: [OpenCL] Added -std/-cl-std=CL2.2/CLC++

2018-04-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: lib/Frontend/InitPreprocessor.cpp:434
+llvm_unreachable("Unsupported OpenCL C++ version");
+  Builder.defineMacro("__CL_CPP_VERSION_1_0__", "100");
+} else {

There is no such macro in the spec it seems, but I am adding it because it's 
probably useful. Also endian and fast math macros (bfrom below) are not in the 
spec it seems. Not sure it was on purpose.


https://reviews.llvm.org/D45363



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


[PATCH] D43578: -ftime-report switch support in Clang

2018-04-11 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

We also see an assertion failure prior to the revert. At r329738:

  $ cat test.cpp
  template  struct A {
template  using rebind_alloc = _Other;
  };
  template  struct _Wrap_alloc {
template 
using rebind_alloc = typename A<_Alloc>::template rebind_alloc<_Other>;
template  using rebind = _Wrap_alloc;
  };
  _Wrap_alloc::rebind w;
  
  $ clang++ -c test.cpp
  
  $ clang++ -c test.cpp -ftime-report
  clang-7: llvm/lib/Support/Timer.cpp:133: void llvm::Timer::startTimer(): 
Assertion `!Running && "Cannot start a running timer"' failed.


Repository:
  rL LLVM

https://reviews.llvm.org/D43578



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


[PATCH] D45482: [clangd] Match AST and Index label for template Symbols

2018-04-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice, I'd been wondering about that...




Comment at: clangd/index/SymbolCollector.cpp:36
+  return *T;
+return ND;
+  }

uber-nit: these three return statements are a bit confusing to me. Maybe omit 
them and if/elseif, so the default case falls through to the bottom.



Comment at: clangd/index/SymbolCollector.cpp:331
+  // We call getTemplateOrThis, since this is what clang's code completion gets
+  // from the lookup in an actual run.
+  CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);

"an actual run" confused me here. Maybe "We use the primary template, as clang 
does during code completion"?



Comment at: unittests/clangd/FileIndexTests.cpp:218
+  EXPECT_EQ(Sym.CompletionLabel, "vector");
+  EXPECT_EQ(Sym.CompletionSnippetInsertText, "vector<${1:class Ty}>");
+  SeenVector = true;

If snippets are off, we'll get "vector", not "vector<>", right?

(Probably no need to test this explicitly, but I just want to be sure)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45482



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


[PATCH] D44921: [PowerPC] Option for secure plt mode

2018-04-11 Thread Strahinja Petrovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329795: [PowerPC] Option for secure plt mode (authored by 
spetrovic, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44921?vs=140060&id=141976#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44921

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
  cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h
  cfe/trunk/test/Driver/ppc-features.cpp


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1957,6 +1957,7 @@
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
 def mvsx : Flag<["-"], "mvsx">, Group;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group;
+def msecure_plt : Flag<["-"], "msecure-plt">, Group;
 def mpower8_vector : Flag<["-"], "mpower8-vector">,
 Group;
 def mno_power8_vector : Flag<["-"], "mno-power8-vector">,
Index: cfe/trunk/test/Driver/ppc-features.cpp
===
--- cfe/trunk/test/Driver/ppc-features.cpp
+++ cfe/trunk/test/Driver/ppc-features.cpp
@@ -22,6 +22,10 @@
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -msoft-float -mhard-float 
-### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SOFTHARD %s
 // CHECK-SOFTHARD-NOT: "-target-feature" "-hard-float"
 
+// check -msecure-plt option for ppc32
+// RUN: %clang -target powerpc-unknown-linux-gnu -msecure-plt %s  -### -o %t.o 
2>&1 | FileCheck --check-prefix=CHECK-SECUREPLT %s
+// CHECK-SECUREPLT: "-target-feature" "+secure-plt"
+
 // check -mfloat-abi=x option
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -mfloat-abi=x -### -o %t.o 
2>&1 | FileCheck --check-prefix=CHECK-ERRMSG %s
 // CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'
Index: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -106,6 +106,16 @@
   ppc::FloatABI FloatABI = ppc::getPPCFloatABI(D, Args);
   if (FloatABI == ppc::FloatABI::Soft)
 Features.push_back("-hard-float");
+
+  ppc::ReadGOTPtrMode ReadGOT = ppc::getPPCReadGOTPtrMode(D, Args);
+  if (ReadGOT == ppc::ReadGOTPtrMode::SecurePlt)
+Features.push_back("+secure-plt");
+}
+
+ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver &D, const ArgList 
&Args) {
+  if (Args.getLastArg(options::OPT_msecure_plt))
+return ppc::ReadGOTPtrMode::SecurePlt;
+  return ppc::ReadGOTPtrMode::Bss;
 }
 
 ppc::FloatABI ppc::getPPCFloatABI(const Driver &D, const ArgList &Args) {
Index: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h
@@ -29,10 +29,17 @@
   Hard,
 };
 
+enum class ReadGOTPtrMode {
+  Bss,
+  SecurePlt,
+};
+
 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 
 std::string getPPCTargetCPU(const llvm::opt::ArgList &Args);
 const char *getPPCAsmModeForCPU(StringRef Name);
+ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver &D,
+   const llvm::opt::ArgList &Args);
 
 void getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -1957,6 +1957,7 @@
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
 def mvsx : Flag<["-"], "mvsx">, Group;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group;
+def msecure_plt : Flag<["-"], "msecure-plt">, Group;
 def mpower8_vector : Flag<["-"], "mpower8-vector">,
 Group;
 def mno_power8_vector : Flag<["-"], "mno-power8-vector">,
Index: cfe/trunk/test/Driver/ppc-features.cpp
===
--- cfe/trunk/test/Driver/ppc-features.cpp
+++ cfe/trunk/test/Driver/ppc-features.cpp
@@ -22,6 +22,10 @@
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -msoft-float -mhard-float -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SOFTHARD %s
 // CHECK-SOFTHARD-NOT: "-target-feature" "-hard-float"
 
+// check -msecure-plt option for ppc32
+// RUN: %clang -target powerpc-unknown-linux-gnu -msecure-plt %s  -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SECUREPLT %s
+// CHECK-SECUREPLT: "-target-feature" "+secure-plt"
+
 // check -mfloat-abi=x option
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -mfloat-abi=x -### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-ERRMSG %s
 // CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'
Index: cfe/trunk/lib/Driver/T

r329795 - [PowerPC] Option for secure plt mode

2018-04-11 Thread Strahinja Petrovic via cfe-commits
Author: spetrovic
Date: Wed Apr 11 05:24:44 2018
New Revision: 329795

URL: http://llvm.org/viewvc/llvm-project?rev=329795&view=rev
Log:
[PowerPC] Option for secure plt mode

This patch enables option for secure plt mode in
clang (-msecure-plt).

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h
cfe/trunk/test/Driver/ppc-features.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=329795&r1=329794&r2=329795&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Apr 11 05:24:44 2018
@@ -1957,6 +1957,7 @@ def maltivec : Flag<["-"], "maltivec">,
 def mno_altivec : Flag<["-"], "mno-altivec">, Group;
 def mvsx : Flag<["-"], "mvsx">, Group;
 def mno_vsx : Flag<["-"], "mno-vsx">, Group;
+def msecure_plt : Flag<["-"], "msecure-plt">, Group;
 def mpower8_vector : Flag<["-"], "mpower8-vector">,
 Group;
 def mno_power8_vector : Flag<["-"], "mno-power8-vector">,

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp?rev=329795&r1=329794&r2=329795&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp Wed Apr 11 05:24:44 2018
@@ -106,6 +106,16 @@ void ppc::getPPCTargetFeatures(const Dri
   ppc::FloatABI FloatABI = ppc::getPPCFloatABI(D, Args);
   if (FloatABI == ppc::FloatABI::Soft)
 Features.push_back("-hard-float");
+
+  ppc::ReadGOTPtrMode ReadGOT = ppc::getPPCReadGOTPtrMode(D, Args);
+  if (ReadGOT == ppc::ReadGOTPtrMode::SecurePlt)
+Features.push_back("+secure-plt");
+}
+
+ppc::ReadGOTPtrMode ppc::getPPCReadGOTPtrMode(const Driver &D, const ArgList 
&Args) {
+  if (Args.getLastArg(options::OPT_msecure_plt))
+return ppc::ReadGOTPtrMode::SecurePlt;
+  return ppc::ReadGOTPtrMode::Bss;
 }
 
 ppc::FloatABI ppc::getPPCFloatABI(const Driver &D, const ArgList &Args) {

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h?rev=329795&r1=329794&r2=329795&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.h Wed Apr 11 05:24:44 2018
@@ -29,10 +29,17 @@ enum class FloatABI {
   Hard,
 };
 
+enum class ReadGOTPtrMode {
+  Bss,
+  SecurePlt,
+};
+
 FloatABI getPPCFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 
 std::string getPPCTargetCPU(const llvm::opt::ArgList &Args);
 const char *getPPCAsmModeForCPU(StringRef Name);
+ReadGOTPtrMode getPPCReadGOTPtrMode(const Driver &D,
+   const llvm::opt::ArgList &Args);
 
 void getPPCTargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,

Modified: cfe/trunk/test/Driver/ppc-features.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ppc-features.cpp?rev=329795&r1=329794&r2=329795&view=diff
==
--- cfe/trunk/test/Driver/ppc-features.cpp (original)
+++ cfe/trunk/test/Driver/ppc-features.cpp Wed Apr 11 05:24:44 2018
@@ -22,6 +22,10 @@
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -msoft-float -mhard-float 
-### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-SOFTHARD %s
 // CHECK-SOFTHARD-NOT: "-target-feature" "-hard-float"
 
+// check -msecure-plt option for ppc32
+// RUN: %clang -target powerpc-unknown-linux-gnu -msecure-plt %s  -### -o %t.o 
2>&1 | FileCheck --check-prefix=CHECK-SECUREPLT %s
+// CHECK-SECUREPLT: "-target-feature" "+secure-plt"
+
 // check -mfloat-abi=x option
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -mfloat-abi=x -### -o %t.o 
2>&1 | FileCheck --check-prefix=CHECK-ERRMSG %s
 // CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'


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


[clang-tools-extra] r329790 - [clang-tidy] fix buildbots from hicpp-signed-bitwise

2018-04-11 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Wed Apr 11 03:22:25 2018
New Revision: 329790

URL: http://llvm.org/viewvc/llvm-project?rev=329790&view=rev
Log:
[clang-tidy] fix buildbots from hicpp-signed-bitwise

The applied patch to diagnose assignment operators introduced
breakage on some architectures. This patch tries to rectify that.


Modified:

clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp?rev=329790&r1=329789&r2=329790&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp 
Wed Apr 11 03:22:25 2018
@@ -93,11 +93,16 @@ void still_forbidden() {
   // Staying within the allowed standard types is ok for bitwise assignment
   // operations.
   std::ctype_base::mask var = std::ctype_base::mask::print;
-  var<<= std::ctype_base::mask::upper;
-  var>>= std::ctype_base::mask::upper;
-  var &= std::ctype_base::mask::upper;
-  var |= std::ctype_base::mask::upper;
-  var ^= std::ctype_base::mask::upper;
+  SResult<<= std::ctype_base::mask::upper;
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand 
with a binary bitwise operator
+  SResult>>= std::ctype_base::mask::upper;
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand 
with a binary bitwise operator
+  SResult &= std::ctype_base::mask::upper;
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand 
with a binary bitwise operator
+  SResult |= std::ctype_base::mask::upper;
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand 
with a binary bitwise operator
+  SResult ^= std::ctype_base::mask::upper;
+  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand 
with a binary bitwise operator
 
   UResult = std::locale::category::collate << 1u;
   UResult = std::locale::category::ctype << 1;


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


[clang-tools-extra] r329789 - [clang-tidy] add missing assignment operations in hicpp-signed-bitwise

2018-04-11 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Wed Apr 11 02:53:08 2018
New Revision: 329789

URL: http://llvm.org/viewvc/llvm-project?rev=329789&view=rev
Log:
[clang-tidy] add missing assignment operations in hicpp-signed-bitwise

This patch resolves the bug https://bugs.llvm.org/show_bug.cgi?id=36963.

- implement missing assignment operators for hicpp-signed-bitwise
- mention fix in release notes

Reviewers:
aaron.ballman, hokein, alexfh

Differential: https://reviews.llvm.org/D45414


Modified:
clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst

clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise.cpp

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp?rev=329789&r1=329788&r2=329789&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/SignedBitwiseCheck.cpp Wed Apr 11 
02:53:08 2018
@@ -36,7 +36,8 @@ void SignedBitwiseCheck::registerMatcher
   Finder->addMatcher(
   binaryOperator(
   allOf(anyOf(hasOperatorName("^"), hasOperatorName("|"),
-  hasOperatorName("&")),
+  hasOperatorName("&"), hasOperatorName("^="),
+  hasOperatorName("|="), hasOperatorName("&=")),
 
 unless(allOf(hasLHS(IsStdBitmask), hasRHS(IsStdBitmask))),
 
@@ -48,10 +49,11 @@ void SignedBitwiseCheck::registerMatcher
   // Shifting and complement is not allowed for any signed integer type because
   // the sign bit may corrupt the result.
   Finder->addMatcher(
-  binaryOperator(allOf(anyOf(hasOperatorName("<<"), hasOperatorName(">>")),
-   hasEitherOperand(SignedIntegerOperand),
-   hasLHS(hasType(isInteger())),
-   hasRHS(hasType(isInteger()
+  binaryOperator(
+  allOf(anyOf(hasOperatorName("<<"), hasOperatorName(">>"),
+  hasOperatorName("<<="), hasOperatorName(">>=")),
+hasEitherOperand(SignedIntegerOperand),
+hasLHS(hasType(isInteger())), hasRHS(hasType(isInteger()
   .bind("binary-sign-interference"),
   this);
 
@@ -84,10 +86,8 @@ void SignedBitwiseCheck::check(const Mat
 else
   llvm_unreachable("unexpected matcher result");
   }
-
-  diag(Location,
-   "use of a signed integer operand with a %select{binary|unary}0 bitwise "
-   "operator")
+  diag(Location, "use of a signed integer operand with a "
+ "%select{binary|unary}0 bitwise operator")
   << IsUnary << SignedOperand->getSourceRange();
 }
 

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=329789&r1=329788&r2=329789&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Wed Apr 11 02:53:08 2018
@@ -156,6 +156,9 @@ Improvements to clang-tidy
   `
   added.
 
+- Adding the missing bitwise assignment operations to 
+  :doc:`hicpp-signed-bitwise `.
+
 - The 'misc-forwarding-reference-overload' check was renamed to 
:doc:`bugprone-forwarding-reference-overload
   `
 

Modified: 
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp?rev=329789&r1=329788&r2=329789&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp 
Wed Apr 11 02:53:08 2018
@@ -8,13 +8,19 @@ void pure_bitmask_types() {
   std::locale::category C = std::locale::category::ctype;
 
   SResult = std::locale::category::none | std::locale::category::collate;
+  SResult|= std::locale::category::collate;
   SResult = std::locale::category::ctype & std::locale::category::monetary;
+  SResult&= std::locale::category::monetary;
   SResult = std::locale::category::numeric ^ std::locale::category::time;
+  SResult^= std::locale::category::time;
   SResult = std::locale::category::messages | std::locale::category::all;
 
   SResult = std::locale::category::all & C;
+  SResult&= std::locale::category::all;
   SResult = std::locale::category::all | C;
+  SResult|= std::locale::category::all;
   SResult = std::locale::category::all ^ C;
+  SResult^= std::locale::category::all;
 
   // std::ctype_base::mask
   std::ctype_base::mas

[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-04-11 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin updated this revision to Diff 141979.
aheejin added a comment.

- Change personality function name to a unique one


Repository:
  rC Clang

https://reviews.llvm.org/D44931

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGCleanup.h
  lib/CodeGen/CGException.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/wasm-eh.cpp

Index: test/CodeGenCXX/wasm-eh.cpp
===
--- /dev/null
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -0,0 +1,392 @@
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+
+void may_throw();
+void dont_throw() noexcept;
+
+struct Cleanup {
+  ~Cleanup() { dont_throw(); }
+};
+
+// Multiple catch clauses w/o catch-all
+void test0() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (double) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: define void @_Z5test0v() {{.*}} personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*)
+
+// CHECK:   %[[INT_ALLOCA:.*]] = alloca i32
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label %[[NORMAL_BB:.*]] unwind label %[[CATCHDISPATCH_BB:.*]]
+
+// CHECK: [[CATCHDISPATCH_BB]]:
+// CHECK-NEXT:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* bitcast (i8** @_ZTId to i8*)]
+// CHECK-NEXT:   %[[EXN:.*]] = call i8* @llvm.wasm.get.exception()
+// CHECK-NEXT:   store i8* %[[EXN]], i8** %exn.slot
+// CHECK-NEXT:   %[[SELECTOR:.*]] = call i32 @llvm.wasm.get.ehselector()
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_INT_BB:.*]], label %[[CATCH_FALLTHROUGH_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK-NEXT:   %[[EXN:.*]] = load i8*, i8** %exn.slot
+// CHECK-NEXT:   %[[ADDR:.*]] = call i8* @__cxa_begin_catch(i8* %[[EXN]]) {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   %[[ADDR_CAST:.*]] = bitcast i8* %[[ADDR]] to i32*
+// CHECK-NEXT:   %[[INT_VAL:.*]] = load i32, i32* %[[ADDR_CAST]]
+// CHECK-NEXT:   store i32 %[[INT_VAL]], i32* %[[INT_ALLOCA]]
+// CHECK-NEXT:   call void @_Z10dont_throwv() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   call void @__cxa_end_catch() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB0:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB0]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB:.*]]
+
+// CHECK: [[CATCH_FALLTHROUGH_BB]]
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTId to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_FLOAT_BB:.*]], label %[[RETHROW_BB:.*]]
+
+// CHECK: [[CATCH_FLOAT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB1:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB1]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB]]
+
+// CHECK: [[RETHROW_BB]]:
+// CHECK-NEXT:   call void @__cxa_rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   unreachable
+
+
+// Single catch-all
+void test1() {
+  try {
+may_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CATCH-LABEL: @_Z5test1v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* null]
+// CHECK:   br label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Multiple catch clauses w/ catch-all
+void test2() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: @_Z5test2v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* null]
+// CHECK:   br i1 %{{.*}}, label %[[CATCH_INT_BB:.*]], label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Cleanup
+void test3() {
+  Cleanup c;
+  may_throw();
+}
+
+// CHECK-LABEL: @_Z5test3v()
+
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label {{.*}} unwind label %[[EHCL

[PATCH] D45515: [NEON] Support vrndns_f32 intrinsic

2018-04-11 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added reviewers: t.p.northover, rengolin, SjoerdMeijer.
kosarev added a project: clang.
Herald added a subscriber: javed.absar.

https://reviews.llvm.org/D45515

Files:
  include/clang/Basic/arm_neon.td
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/arm-neon-directed-rounding.c


Index: test/CodeGen/arm-neon-directed-rounding.c
===
--- test/CodeGen/arm-neon-directed-rounding.c
+++ test/CodeGen/arm-neon-directed-rounding.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 
-ffreestanding -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | 
FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 \
+// RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \
+// RUN: opt -S -mem2reg | FileCheck %s
 
 #include 
 
@@ -85,3 +87,10 @@
 float32x4_t test_vrndq_f32(float32x4_t a) {
   return vrndq_f32(a);
 }
+
+// CHECK-LABEL: define float @test_vrndns_f32(float %a) #0 {
+// CHECK:   [[VRNDN_I:%.*]] = call float @llvm.arm.neon.vrintn.f32(float %a) #2
+// CHECK:   ret float [[VRNDN_I]]
+float32_t test_vrndns_f32(float32_t a) {
+  return vrndns_f32(a);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -5485,6 +5485,12 @@
   case NEON::BI__builtin_neon_vgetq_lane_f32:
 return Builder.CreateExtractElement(Ops[0], Ops[1], "vget_lane");
 
+  case NEON::BI__builtin_neon_vrndns_f32: {
+Value *Arg = EmitScalarExpr(E->getArg(0));
+llvm::Type *Tys[] = {Arg->getType()};
+Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vrintn, Tys);
+return Builder.CreateCall(F, {Arg}, "vrndn"); }
+
   case NEON::BI__builtin_neon_vset_lane_i8:
   case NEON::BI__builtin_neon_vset_lane_i16:
   case NEON::BI__builtin_neon_vset_lane_i32:
Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -1116,6 +1116,12 @@
 }
 
 

+// Scalar Floating-point Round to Integral
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_DIRECTED_ROUNDING)" 
in {
+def SCALAR_FRINTN_S32 : SInst<"vrndn", "ss", "Sf">;
+}
+
+
 // Scalar Reduce Pairwise Addition (Scalar and Floating Point)
 def SCALAR_ADDP  : SInst<"vpadd", "sd", "SfSHlSHdSHUl">;
 


Index: test/CodeGen/arm-neon-directed-rounding.c
===
--- test/CodeGen/arm-neon-directed-rounding.c
+++ test/CodeGen/arm-neon-directed-rounding.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8-linux-gnueabihf -target-cpu cortex-a57 \
+// RUN: -ffreestanding -disable-O0-optnone -emit-llvm %s -o - | \
+// RUN: opt -S -mem2reg | FileCheck %s
 
 #include 
 
@@ -85,3 +87,10 @@
 float32x4_t test_vrndq_f32(float32x4_t a) {
   return vrndq_f32(a);
 }
+
+// CHECK-LABEL: define float @test_vrndns_f32(float %a) #0 {
+// CHECK:   [[VRNDN_I:%.*]] = call float @llvm.arm.neon.vrintn.f32(float %a) #2
+// CHECK:   ret float [[VRNDN_I]]
+float32_t test_vrndns_f32(float32_t a) {
+  return vrndns_f32(a);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -5485,6 +5485,12 @@
   case NEON::BI__builtin_neon_vgetq_lane_f32:
 return Builder.CreateExtractElement(Ops[0], Ops[1], "vget_lane");
 
+  case NEON::BI__builtin_neon_vrndns_f32: {
+Value *Arg = EmitScalarExpr(E->getArg(0));
+llvm::Type *Tys[] = {Arg->getType()};
+Function *F = CGM.getIntrinsic(Intrinsic::arm_neon_vrintn, Tys);
+return Builder.CreateCall(F, {Arg}, "vrndn"); }
+
   case NEON::BI__builtin_neon_vset_lane_i8:
   case NEON::BI__builtin_neon_vset_lane_i16:
   case NEON::BI__builtin_neon_vset_lane_i32:
Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -1116,6 +1116,12 @@
 }
 
 
+// Scalar Floating-point Round to Integral
+let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_DIRECTED_ROUNDING)" in {
+def SCALAR_FRINTN_S32 : SInst<"vrndn", "ss", "Sf">;
+}
+
+
 // Scalar Reduce Pairwise Addition (Scalar and Floating Point)
 def SCALAR_ADDP  : SInst<"vpadd", "sd", "SfSHlSHdSHUl">;
 
_

Re: [PATCH] D43578: -ftime-report switch support in Clang

2018-04-11 Thread Nico Weber via cfe-commits
On Wed, Apr 11, 2018 at 6:18 AM, Andrew V. Tischenko via Phabricator via
cfe-commits  wrote:

> avt77 added a comment.
>
> In https://reviews.llvm.org/D43578#1062950, @thakis wrote:
>
> > @davezarzycki remarks in https://reviews.llvm.org/D45485 that this
> breaks the shared build. The proposed fix there is to make several of
> clang's modules depend on LLVM's IR library ("Core"). This seems weird to
> me for two reasons, one architectural, one form a build point of view:
> >
> > 1. The modules growing the dep don't really depend on IR, they just need
> that one bool that happens to be defined there. That bool is called
> `TimePassesIsEnabled` which is a reasonable bool to live in IR, but this
> patch starts using that bool for meanings other than "should we time
> passes?". It instead uses the same bool to decide if clang should print a
> bunch of timing info. We probably should have a separate bool in clang and
> key this off that and make -ftime-report set both.
> > 2. From a build PoV, depending on Core means explicitly depending on
> TableGen processing the Attributes.td and Intrinsics.td files in
> include/llvm/IR, which needlessly (explicitly) serializes the build.
>
>
> In fact the current trunk already depends on TimePassesIsEnabled (w/o this
> patch applied):
>
> //$ find clang -name \*.cpp | xargs grep TimePassesIsEnabled
> clang/lib/CodeGen/CodeGenAction.cpp:  llvm::TimePassesIsEnabled =
> TimePasses;
> clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
> clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
> clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled) {
> clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled) {
> clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
> clang/lib/CodeGen/CodeGenAction.cpp:  if (llvm::TimePassesIsEnabled)
> clang/lib/CodeGen/CodeGenAction.cpp:if
> (llvm::TimePassesIsEnabled) {
> clang/lib/CodeGen/CodeGenAction.cpp:if
> (llvm::TimePassesIsEnabled) {
> clang/lib/CodeGen/BackendUtil.cpp:  TimeRegion 
> Region(llvm::TimePassesIsEnabled
> ? &CodeGenerationTime : nullptr);
> clang/lib/CodeGen/BackendUtil.cpp:  TimeRegion 
> Region(llvm::TimePassesIsEnabled
> ? &CodeGenerationTime : nullptr);
>

Note that these are all in CodeGen, which needs to depend on LLVM's IR
library anyway for code generation. It's still possible that CodeGen is
misusing TimePassesIsEnabled for a meaning which isn't "should we time
passes", in which case I agree we should change that, but at least it
doesn't add an unnecessary dependency there.


> //
> But I agree that such dependence is not OK. I'll create a separate bool
> instead of TimePassesIsEnabled but the question is should I remove the
> above usage of TimePassesIsEnabled as well? Or maybe it should be a
> separate pre-patch? Or it could be left as it is?
>

It could be a separate patch after your main change made it in.


>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D43578
>
>
>
> ___
> 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] D45363: [OpenCL] Added -std/-cl-std=CL2.2/CLC++

2018-04-11 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D45363



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


[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-04-11 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin updated this revision to Diff 141983.
aheejin added a comment.

- Rebase


Repository:
  rC Clang

https://reviews.llvm.org/D44931

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGCleanup.h
  lib/CodeGen/CGException.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenCXX/wasm-eh.cpp

Index: test/CodeGenCXX/wasm-eh.cpp
===
--- /dev/null
+++ test/CodeGenCXX/wasm-eh.cpp
@@ -0,0 +1,392 @@
+// RUN: %clang_cc1 %s -triple wasm32-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+// RUN: %clang_cc1 %s -triple wasm64-unknown-unknown -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
+
+void may_throw();
+void dont_throw() noexcept;
+
+struct Cleanup {
+  ~Cleanup() { dont_throw(); }
+};
+
+// Multiple catch clauses w/o catch-all
+void test0() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (double) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: define void @_Z5test0v() {{.*}} personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*)
+
+// CHECK:   %[[INT_ALLOCA:.*]] = alloca i32
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label %[[NORMAL_BB:.*]] unwind label %[[CATCHDISPATCH_BB:.*]]
+
+// CHECK: [[CATCHDISPATCH_BB]]:
+// CHECK-NEXT:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* bitcast (i8** @_ZTId to i8*)]
+// CHECK-NEXT:   %[[EXN:.*]] = call i8* @llvm.wasm.get.exception()
+// CHECK-NEXT:   store i8* %[[EXN]], i8** %exn.slot
+// CHECK-NEXT:   %[[SELECTOR:.*]] = call i32 @llvm.wasm.get.ehselector()
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTIi to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_INT_BB:.*]], label %[[CATCH_FALLTHROUGH_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK-NEXT:   %[[EXN:.*]] = load i8*, i8** %exn.slot
+// CHECK-NEXT:   %[[ADDR:.*]] = call i8* @__cxa_begin_catch(i8* %[[EXN]]) {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   %[[ADDR_CAST:.*]] = bitcast i8* %[[ADDR]] to i32*
+// CHECK-NEXT:   %[[INT_VAL:.*]] = load i32, i32* %[[ADDR_CAST]]
+// CHECK-NEXT:   store i32 %[[INT_VAL]], i32* %[[INT_ALLOCA]]
+// CHECK-NEXT:   call void @_Z10dont_throwv() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   call void @__cxa_end_catch() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB0:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB0]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB:.*]]
+
+// CHECK: [[CATCH_FALLTHROUGH_BB]]
+// CHECK-NEXT:   %[[TYPEID:.*]] = call i32 @llvm.eh.typeid.for(i8* bitcast (i8** @_ZTId to i8*)) #2
+// CHECK-NEXT:   %[[MATCHES:.*]] = icmp eq i32 %[[SELECTOR]], %[[TYPEID]]
+// CHECK-NEXT:   br i1 %[[MATCHES]], label %[[CATCH_FLOAT_BB:.*]], label %[[RETHROW_BB:.*]]
+
+// CHECK: [[CATCH_FLOAT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label %[[CATCHRET_DEST_BB1:.*]]
+
+// CHECK: [[CATCHRET_DEST_BB1]]:
+// CHECK-NEXT:   br label %[[TRY_CONT_BB]]
+
+// CHECK: [[RETHROW_BB]]:
+// CHECK-NEXT:   call void @__cxa_rethrow() {{.*}} [ "funclet"(token %[[CATCHPAD]]) ]
+// CHECK-NEXT:   unreachable
+
+
+// Single catch-all
+void test1() {
+  try {
+may_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CATCH-LABEL: @_Z5test1v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* null]
+// CHECK:   br label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Multiple catch clauses w/ catch-all
+void test2() {
+  try {
+may_throw();
+  } catch (int) {
+dont_throw();
+  } catch (...) {
+dont_throw();
+  }
+}
+
+// CHECK-LABEL: @_Z5test2v()
+
+// CHECK:   %[[CATCHSWITCH:.*]] = catchswitch within none [label %[[CATCHSTART_BB:.*]]] unwind to caller
+
+// CHECK: [[CATCHSTART_BB]]:
+// CHECK-NEXT:   %[[CATCHPAD:.*]] = catchpad within %[[CATCHSWITCH]] [i8* bitcast (i8** @_ZTIi to i8*), i8* null]
+// CHECK:   br i1 %{{.*}}, label %[[CATCH_INT_BB:.*]], label %[[CATCH_ALL_BB:.*]]
+
+// CHECK: [[CATCH_INT_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+// CHECK: [[CATCH_ALL_BB]]:
+// CHECK:   catchret from %[[CATCHPAD]] to label
+
+
+// Cleanup
+void test3() {
+  Cleanup c;
+  may_throw();
+}
+
+// CHECK-LABEL: @_Z5test3v()
+
+// CHECK:   invoke void @_Z9may_throwv()
+// CHECK-NEXT:   to label {{.*}} unwind label %[[EHCLEANUP_BB:.*]]
+
+// CHECK: [[EHCLEANUP_BB]

[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Sorry about the delay Marc-André - I got stuck on "how to test ClangdLSPServer" 
and then distracted!
But this looks great.




Comment at: clangd/ClangdLSPServer.cpp:101
+  // All clients should support those.
+  for (SymKindUnderlyingType I = SymbolKindMin;
+   I <= static_cast(SymbolKind::Array); ++I)

malaperle wrote:
> I'd like to add some test to exercise the changes in ClangdLSPServer.cpp and 
> Protocol.cpp but it's not straightforward to do nicely. Using a "lit" test, I 
> cannot have a header and since symbols in the main file are not collected 
> then it's not useful. If I make a gtest, I have to feed it the lsp server 
> with stdin and check the stdout which is a bit messy, but doable.
Yeah, we don't have a good way to test ClangdLSPServer :-( I would like to fix 
that, but I don't know of any easy fixes.

This is kind of gross, but do standard library includes work from our lit 
tests? You could `#include ` and then test using some symbols you know are 
there...




Comment at: clangd/ClangdLSPServer.cpp:103
+   I <= static_cast(SymbolKind::Array); ++I)
+SupportedSymbolKinds.set(I);
+

I'd like to be slightly less hostile than this to (broken) clients that fail to 
call initialize.
As the patch stands they'll get an empty SupportedSymbolKinds, and we'll crash 
if they call documentSymbols.

Instead I'd suggest pulling out defaultSymbolKinds() and initializing to that 
in the constructor, and then overriding with either `SpecifiedSymbolKinds` or 
`SpecifiedSymbolKinds | defaultSymbolKinds()` here.



Comment at: clangd/ClangdServer.h:164
+  void workspaceSymbols(StringRef Query,
+const clangd::WorkspaceSymbolOptions &Opts,
+const DraftStore &DS,

I think it would probably be more consistent with other functions to just take 
`int limit` here. I'm not sure CodeCompletion is an example we want to emulate.

ClangdLSPServer might even just grab it from the code completion options, since 
that's the behavior we actually want.

Up to you, though.



Comment at: clangd/ClangdServer.h:165
+const clangd::WorkspaceSymbolOptions &Opts,
+const DraftStore &DS,
+Callback> CB);

maybe a short FIXME here too e.g. "remove param when the index has line/col"



Comment at: clangd/FindSymbols.cpp:42
+
+  if (!supportedSymbolKinds) {
+// Provide some sensible default when all fails.

malaperle wrote:
> sammccall wrote:
> > This code shouldn't need to handle this case. The LSP specifies the default 
> > set of supported types if it's not provided, so ClangdLSPServer should 
> > enure we always have a valid set
> My thought is that if we start dealing with one of those:
> ```
>   Object = 19,
>   Key = 20,
>   Null = 21,
>   Event = 24,
>   Operator = 25,
>   TypeParameter = 26
> ```
> and it's an older client that only supports up to "Array = 18", then we can 
> provide a fallback, otherwise the client my not handle the unknown kind 
> gracefully. But we can add this later if necessary I guess.
Ah yes I agree, fallbacks are good. I just meant that ClangdLSPServer should 
ensure that we actually have the bitset populated with the right values. I 
think it looks good now.



Comment at: clangd/Protocol.cpp:209
+  default:
+llvm_unreachable("Unexpected symbol kind");
+  }

This doesn't actually seem unreachable (or won't stay that way), maybe log and 
return `Null` or something like that? (Wow, there's really no catch-all option 
for this mandatory enum...)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D44882: [clangd] Implementation of workspace/symbol request

2018-04-11 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(BTW @hokein has https://reviews.llvm.org/D45513 to add row/col to the index, 
which will allow all the file-reading stuff to be cleaned up, but no need to 
wait on that since it's all working now).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44882



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


[PATCH] D45045: [DebugInfo] Generate debug information for labels.

2018-04-11 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 141989.
HsiangKai added a comment.

Update the test case for inlined functions. The inlined label will attach to 
DISubprogram(..., labels: !n)


Repository:
  rC Clang

https://reviews.llvm.org/D45045

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  lib/CodeGen/CGStmt.cpp
  test/CodeGen/debug-label-inline.c
  test/CodeGen/debug-label.c

Index: test/CodeGen/debug-label.c
===
--- /dev/null
+++ test/CodeGen/debug-label.c
@@ -0,0 +1,16 @@
+// This test will test the correstness of generating DILabel and
+// llvm.dbg.label for labels.
+//
+// RUN: %clang_cc1 -emit-llvm %s -o - -emit-llvm -debug-info-kind=limited | FileCheck %s
+
+int f1(int a, int b) {
+  int sum;
+
+top:
+  // CHECK: call void @llvm.dbg.label(metadata [[LABEL_METADATA:!.*]]), !dbg [[LABEL_LOCATION:!.*]]
+  sum = a + b;
+  return sum;
+}
+
+// CHECK: [[LABEL_METADATA]] = !DILabel({{.*}}, name: "top", {{.*}}, line: 9)
+// CHECK: [[LABEL_LOCATION]] = !DILocation(line: 9,
Index: test/CodeGen/debug-label-inline.c
===
--- /dev/null
+++ test/CodeGen/debug-label-inline.c
@@ -0,0 +1,28 @@
+// This test will test the correctness of generating DILabel and
+// llvm.dbg.label when the label is in inlined functions.
+//
+// RUN: %clang_cc1 -O2 %s -o - -emit-llvm -debug-info-kind=limited | FileCheck %s
+inline int f1(int a, int b) {
+  int sum;
+
+top:
+  sum = a + b;
+  return sum;
+}
+
+extern int ga, gb;
+
+int f2(void) {
+  int result;
+
+  result = f1(ga, gb);
+  // CHECK: call void @llvm.dbg.label(metadata [[LABEL_METADATA:!.*]]), !dbg [[LABEL_LOCATION:!.*]]
+
+  return result;
+}
+
+// CHECK: distinct !DISubprogram(name: "f1", {{.*}}, labels: [[LABELS:!.*]])
+// CHECK: [[LABELS]] = !{[[LABEL_METADATA]]}
+// CHECK: [[LABEL_METADATA]] = !DILabel({{.*}}, name: "top", {{.*}}, line: 8)
+// CHECK: [[INLINEDAT:!.*]] = distinct !DILocation(line: 18,
+// CHECK: [[LABEL_LOCATION]] = !DILocation(line: 8, {{.*}}, inlinedAt: [[INLINEDAT]])
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -531,6 +531,18 @@
   }
 
   EmitBlock(Dest.getBlock());
+
+  // Emit debug info for the label only if it's reachable.
+  if (HaveInsertPoint()) {
+if (CGDebugInfo *DI = getDebugInfo()) {
+  if (CGM.getCodeGenOpts().getDebugInfo() >=
+  codegenoptions::LimitedDebugInfo) {
+DI->setLocation(D->getLocation());
+DI->EmitLabel(D, Builder);
+  }
+}
+  }
+
   incrementProfileCounter(D->getStmt());
 }
 
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -395,6 +395,9 @@
llvm::Value *AI,
CGBuilderTy &Builder);
 
+  /// Emit call to \c llvm.dbg.label for an label.
+  void EmitLabel(const LabelDecl *D, CGBuilderTy &Builder);
+
   /// Emit call to \c llvm.dbg.declare for an imported variable
   /// declaration in a block.
   void EmitDeclareOfBlockDeclRefVariable(const VarDecl *variable,
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -3640,6 +3640,33 @@
   return EmitDeclare(VD, Storage, llvm::None, Builder);
 }
 
+void CGDebugInfo::EmitLabel(const LabelDecl *D,
+CGBuilderTy &Builder) {
+  assert(DebugKind >= codegenoptions::LimitedDebugInfo);
+  assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
+
+  if (D->hasAttr())
+return;
+
+  auto *Scope = cast(LexicalBlockStack.back());
+  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
+
+  // Get location information.
+  unsigned Line = getLineNumber(D->getLocation());
+  unsigned Column = getColumnNumber(D->getLocation());
+
+  StringRef Name = D->getName();
+
+  // Create the descriptor for the label.
+  auto *L = DBuilder.createLabel(Scope, Name, Unit, Line,
+ CGM.getLangOpts().Optimize);
+
+  // Insert an llvm.dbg.label into the current block.
+  DBuilder.insertLabel(L,
+   llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
+   Builder.GetInsertBlock());
+}
+
 llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
   llvm::DIType *Ty) {
   llvm::DIType *CachedTy = getTypeOrNull(QualTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45405: [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length to be replaced with 'auto'

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

In https://reviews.llvm.org/D45405#1063890, @zinovy.nis wrote:

> Roman, I see you've fixed them. Thanks a lot!
>  I did not face with these errors on MSVS'201 so  had no chance to fix early.


No stress, but as Roman said, please watch the bots after committing a patch: 
http://lab.llvm.org:8011/console.

> ср, 11 апр. 2018 г. в 0:02, Roman Lebedev via Phabricator <
>  revi...@reviews.llvm.org>:
> 
>> lebedev.ri added a comment.
>> 
>> This change had two different problems.
>>  Please watch the bots?




Repository:
  rL LLVM

https://reviews.llvm.org/D45405



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


[PATCH] D45491: [analyzer] Do not invalidate the `this` pointer.

2018-04-11 Thread Henry Wong via Phabricator via cfe-commits
MTC added a comment.

In https://reviews.llvm.org/D45491#1063364, @george.karpenkov wrote:

> @MTC what happens for
>
>   this.j = 0;
>   for (int i=0; i<100; i++)
>  this.j++;
>
>
> ?


@george.karpenkov  `this`'s value will remain unchanged, `j` will be 
invalidated.

   1   void clang_analyzer_printState();
   2   struct A {
   3   int j;
   4   void foo() {
   5   this->j = 0;
   6   clang_analyzer_printState();
   7   for (int i = 0; i < 100; ++i)
   8   this->j++;
   9   clang_analyzer_printState();
  10 }
  11   };
  12
  13   void func() {
  14   A a;
  15   a.foo();
  16   }

For the above code, given the command `clang -cc1 -analyze 
-analyzer-checker=core,debug.ExprInspection -analyzer-config widen-loops=true 
test.cpp`. The output about `Store` is as follows.

  Store (direct and default bindings), 0x7fb7d008c068 :
   (a,0,direct) : 0 S32b
  
   (this,0,direct) : &a
  
  
  Store (direct and default bindings), 0x7fb7d080a618 :
   (a,0,default) : conj_$1{int}
  
   (this,0,direct) : &a


Repository:
  rC Clang

https://reviews.llvm.org/D45491



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


[PATCH] D45392: [clang-tidy] add new check to find out objc ivars which do not have prefix '_'

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

Thank you, that's much better!

I'd also appreciate, if you could document the options this check supports in 
its .rst document (separately from this patch).

A few more comments inline.




Comment at: test/clang-tidy/readability-identifier-naming-objc.m:1-3
+// Remove UNSUPPORTED for powerpc64le when the problem introduced by
+// r288563 is resolved.
+// UNSUPPORTED: powerpc64le

I'd try committing the patch without disabling the test for powerpc64le and see 
whether the relevant buildbot complains. Looking at the description of r288563, 
I don't see anything that could be relevant to this test.



Comment at: test/clang-tidy/readability-identifier-naming-objc.m:7
+// RUN: {key: readability-identifier-naming.ObjcIvarPrefix, value: '_'}, \
+// RUN:   ]}' -- -fno-delayed-template-parsing \
+// RUN:   -I%S/Inputs/readability-identifier-naming \

I suspect the -fno-delayed-template-parsing is not needed, since no templates 
are used in this test.



Comment at: test/clang-tidy/readability-identifier-naming-objc.m:8-9
+// RUN:   ]}' -- -fno-delayed-template-parsing \
+// RUN:   -I%S/Inputs/readability-identifier-naming \
+// RUN:   -isystem %S/Inputs/readability-identifier-naming/system
+

It looks like these flags are not needed, since there are no #include 
directives in this test.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45392



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


[PATCH] D45515: [NEON] Support vrndns_f32 intrinsic

2018-04-11 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Looks good to me.


https://reviews.llvm.org/D45515



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


r329804 - [Sema] Fix built-in decrement operator overload resolution

2018-04-11 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Wed Apr 11 06:36:29 2018
New Revision: 329804

URL: http://llvm.org/viewvc/llvm-project?rev=329804&view=rev
Log:
[Sema] Fix built-in decrement operator overload resolution

C++ [over.built] p4:

"For every pair (T, VQ), where T is an arithmetic type other than bool, and VQ 
is either volatile or empty, there exist candidate operator functions of the 
form

  VQ T&  operator--(VQ T&);
  T  operator--(VQ T&, int);
"
The bool type is in position LastPromotedIntegralType in 
BuiltinOperatorOverloadBuilder::getArithmeticType::ArithmeticTypes, but 
addPlusPlusMinusMinusArithmeticOverloads() was expecting it at position 0.

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

rdar://problem/34255516

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=329804&r1=329803&r2=329804&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Apr 11 06:36:29 2018
@@ -7796,10 +7796,12 @@ public:
 if (!HasArithmeticOrEnumeralCandidateType)
   return;
 
-for (unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
- Arith < NumArithmeticTypes; ++Arith) {
+for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
+  const auto TypeOfT = ArithmeticTypes[Arith];
+  if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy)
+continue;
   addPlusPlusMinusMinusStyleOverloads(
-ArithmeticTypes[Arith],
+TypeOfT,
 VisibleTypeConversionsQuals.hasVolatile(),
 VisibleTypeConversionsQuals.hasRestrict());
 }

Modified: cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp?rev=329804&r1=329803&r2=329804&view=diff
==
--- cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp (original)
+++ cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp Wed Apr 11 06:36:29 
2018
@@ -62,6 +62,10 @@ void f(Short s, Long l, Enum1 e1, Enum2
   // FIXME: should pass (void)static_cast(islong(e1 % e2));
 }
 
+struct BoolRef {
+  operator bool&();
+};
+
 struct ShortRef { // expected-note{{candidate function (the implicit copy 
assignment operator) not viable}}
 #if __cplusplus >= 201103L // C++11 or later
 // expected-note@-2 {{candidate function (the implicit move assignment 
operator) not viable}}
@@ -73,6 +77,10 @@ struct LongRef {
   operator volatile long&();
 };
 
+struct FloatRef {
+  operator float&();
+};
+
 struct XpmfRef { // expected-note{{candidate function (the implicit copy 
assignment operator) not viable}}
 #if __cplusplus >= 201103L // C++11 or later
 // expected-note@-2 {{candidate function (the implicit move assignment 
operator) not viable}}
@@ -84,13 +92,19 @@ struct E2Ref {
   operator E2&();
 };
 
-void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef pmf_ref) {
+void g(BoolRef br, ShortRef sr, LongRef lr, FloatRef fr, E2Ref e2_ref, XpmfRef 
pmf_ref) {
   // C++ [over.built]p3
   short s1 = sr++;
 
-  // C++ [over.built]p3
+  // C++ [over.built]p4
   long l1 = lr--;
 
+  // C++ [over.built]p4
+  float f1 = fr--;
+
+  // C++ [over.built]p4
+  bool b2 = br--; // expected-error{{cannot decrement value of type 'BoolRef'}}
+
   // C++ [over.built]p18
   short& sr1 = (sr *= lr);
   volatile long& lr1 = (lr *= sr);


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


[PATCH] D44988: [Sema] Fix decrement availability for built-in types

2018-04-11 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329804: [Sema] Fix built-in decrement operator overload 
resolution (authored by jkorous, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44988?vs=141865&id=141995#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44988

Files:
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp


Index: cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
===
--- cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
+++ cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
@@ -62,6 +62,10 @@
   // FIXME: should pass (void)static_cast(islong(e1 % e2));
 }
 
+struct BoolRef {
+  operator bool&();
+};
+
 struct ShortRef { // expected-note{{candidate function (the implicit copy 
assignment operator) not viable}}
 #if __cplusplus >= 201103L // C++11 or later
 // expected-note@-2 {{candidate function (the implicit move assignment 
operator) not viable}}
@@ -73,6 +77,10 @@
   operator volatile long&();
 };
 
+struct FloatRef {
+  operator float&();
+};
+
 struct XpmfRef { // expected-note{{candidate function (the implicit copy 
assignment operator) not viable}}
 #if __cplusplus >= 201103L // C++11 or later
 // expected-note@-2 {{candidate function (the implicit move assignment 
operator) not viable}}
@@ -84,13 +92,19 @@
   operator E2&();
 };
 
-void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef pmf_ref) {
+void g(BoolRef br, ShortRef sr, LongRef lr, FloatRef fr, E2Ref e2_ref, XpmfRef 
pmf_ref) {
   // C++ [over.built]p3
   short s1 = sr++;
 
-  // C++ [over.built]p3
+  // C++ [over.built]p4
   long l1 = lr--;
 
+  // C++ [over.built]p4
+  float f1 = fr--;
+
+  // C++ [over.built]p4
+  bool b2 = br--; // expected-error{{cannot decrement value of type 'BoolRef'}}
+
   // C++ [over.built]p18
   short& sr1 = (sr *= lr);
   volatile long& lr1 = (lr *= sr);
Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -7796,10 +7796,12 @@
 if (!HasArithmeticOrEnumeralCandidateType)
   return;
 
-for (unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
- Arith < NumArithmeticTypes; ++Arith) {
+for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
+  const auto TypeOfT = ArithmeticTypes[Arith];
+  if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy)
+continue;
   addPlusPlusMinusMinusStyleOverloads(
-ArithmeticTypes[Arith],
+TypeOfT,
 VisibleTypeConversionsQuals.hasVolatile(),
 VisibleTypeConversionsQuals.hasRestrict());
 }


Index: cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
===
--- cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
+++ cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
@@ -62,6 +62,10 @@
   // FIXME: should pass (void)static_cast(islong(e1 % e2));
 }
 
+struct BoolRef {
+  operator bool&();
+};
+
 struct ShortRef { // expected-note{{candidate function (the implicit copy assignment operator) not viable}}
 #if __cplusplus >= 201103L // C++11 or later
 // expected-note@-2 {{candidate function (the implicit move assignment operator) not viable}}
@@ -73,6 +77,10 @@
   operator volatile long&();
 };
 
+struct FloatRef {
+  operator float&();
+};
+
 struct XpmfRef { // expected-note{{candidate function (the implicit copy assignment operator) not viable}}
 #if __cplusplus >= 201103L // C++11 or later
 // expected-note@-2 {{candidate function (the implicit move assignment operator) not viable}}
@@ -84,13 +92,19 @@
   operator E2&();
 };
 
-void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef pmf_ref) {
+void g(BoolRef br, ShortRef sr, LongRef lr, FloatRef fr, E2Ref e2_ref, XpmfRef pmf_ref) {
   // C++ [over.built]p3
   short s1 = sr++;
 
-  // C++ [over.built]p3
+  // C++ [over.built]p4
   long l1 = lr--;
 
+  // C++ [over.built]p4
+  float f1 = fr--;
+
+  // C++ [over.built]p4
+  bool b2 = br--; // expected-error{{cannot decrement value of type 'BoolRef'}}
+
   // C++ [over.built]p18
   short& sr1 = (sr *= lr);
   volatile long& lr1 = (lr *= sr);
Index: cfe/trunk/lib/Sema/SemaOverload.cpp
===
--- cfe/trunk/lib/Sema/SemaOverload.cpp
+++ cfe/trunk/lib/Sema/SemaOverload.cpp
@@ -7796,10 +7796,12 @@
 if (!HasArithmeticOrEnumeralCandidateType)
   return;
 
-for (unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
- Arith < NumArithmeticTypes; ++Arith) {
+for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
+  const auto TypeOfT = ArithmeticTypes[Arith];
+  if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy)
+continue;
   addPlusPlusMinusMinusSty

[PATCH] D45491: [analyzer] Do not invalidate the `this` pointer.

2018-04-11 Thread Henry Wong via Phabricator via cfe-commits
MTC marked 2 inline comments as done.
MTC added inline comments.



Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1024-1027
+  // 'this' pointer is not an lvalue, we should not invalidate it.
+  if (CXXThisRegion::classof(baseR))
+return;
+

NoQ wrote:
> I don't think this run-time check belongs here. The fix should be isolated in 
> loop widening because everything else is already known to work correctly. The 
> invalidation worker is not to be blamed for other entities throwing incorrect 
> stuff into it.
Make sense, will do.



Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:2057-2060
+  assert((!CXXThisRegion::classof(R) ||
+  CXXThisRegion::classof(R) && !B.lookup(R)) &&
+ "'this' pointer is not an l-value and is not assignable");
+

NoQ wrote:
> This assertion is great to have.
> 
> Please use `!isa(R)` instead of `CXXThisRegion::classof(R)`. 
> The left argument of `&&` is always true, so you can omit it.
Excellent advice, thank you! Will do.


Repository:
  rC Clang

https://reviews.llvm.org/D45491



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


[PATCH] D44602: [clang-tidy] readability-function-size: add VariableThreshold param.

2018-04-11 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 141997.
lebedev.ri added a reviewer: alexfh.
lebedev.ri added a comment.

After a quick IRC chat with @aaron.ballman, it was discovered that there has 
been a big misunderstanding:

  we don't need to ignore/exempt *all* the variables declared in macros, we 
just need to ignore *all* GNU Statement Expressions.

Yay!

I think this is ready now, please review.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44602

Files:
  clang-tidy/readability/FunctionSizeCheck.cpp
  clang-tidy/readability/FunctionSizeCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-function-size.rst
  test/clang-tidy/readability-function-size-variables-c++17.cpp
  test/clang-tidy/readability-function-size.cpp

Index: test/clang-tidy/readability-function-size.cpp
===
--- test/clang-tidy/readability-function-size.cpp
+++ test/clang-tidy/readability-function-size.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-function-size %t -- -config='{CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}, {key: readability-function-size.ParameterThreshold, value: 5}, {key: readability-function-size.NestingThreshold, value: 2}]}' -- -std=c++11
+// RUN: %check_clang_tidy %s readability-function-size %t -- -config='{CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}, {key: readability-function-size.ParameterThreshold, value: 5}, {key: readability-function-size.NestingThreshold, value: 2}, {key: readability-function-size.VariableThreshold, value: 1}]}' -- -std=c++11
 
 // Bad formatting is intentional, don't run clang-format over the whole file!
 
@@ -64,7 +64,7 @@
 
 void baz0() { // 1
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds recommended size/complexity
-  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 27 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 28 lines including whitespace and comments (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 9 statements (threshold 0)
   int a;
   { // 2
@@ -87,14 +87,15 @@
 }
   }
   macro()
-// CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
-// CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
+  // CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+  // CHECK-MESSAGES: :[[@LINE-27]]:6: note: 9 variables (threshold 1)
 }
 
 // check that nested if's are not reported. this was broken initially
 void nesting_if() { // 1
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'nesting_if' exceeds recommended size/complexity
-  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 18 statements (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 6 branches (threshold 0)
   if (true) { // 2
@@ -114,12 +115,13 @@
   } else if (true) { // 2
  int j;
   }
+  // CHECK-MESSAGES: :[[@LINE-22]]:6: note: 6 variables (threshold 1)
 }
 
 // however this should warn
 void bad_if_nesting() { // 1
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_if_nesting' exceeds recommended size/complexity
-// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
 // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 12 statements (threshold 0)
 // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 4 branches (threshold 0)
   if (true) {// 2
@@ -139,4 +141,161 @@
   }
 }
   }
+  // CHECK-MESSAGES: :[[@LINE-22]]:6: note: 4 variables (threshold 1)
 }
+
+void variables_0() {
+  int i;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_0' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
+void variables_1(int i) {
+  int j;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_1' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
+void variables_2(int i, int j) {
+  ;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_2' exceeds reco

[PATCH] D45405: [clang-tidy] [modernize-use-auto] Add a threshold for minimal type name length to be replaced with 'auto'

2018-04-11 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

The build was broken by someone else's commit then. From my side there was
a warning only I fixed immediately.

ср, 11 апр. 2018 г. в 16:26, Alexander Kornienko via Phabricator <
revi...@reviews.llvm.org>:

> alexfh added a comment.
> 
> In https://reviews.llvm.org/D45405#1063890, @zinovy.nis wrote:
> 
>> Roman, I see you've fixed them. Thanks a lot!
>  >  I did not face with these errors on MSVS'201 so  had no chance to fix
>  early.
> 
> No stress, but as Roman said, please watch the bots after committing a
>  patch: http://lab.llvm.org:8011/console.
> 
>> ср, 11 апр. 2018 г. в 0:02, Roman Lebedev via Phabricator <
>  >  revi...@reviews.llvm.org>:
>  >
>  >> lebedev.ri added a comment.
>  >>
>  >> This change had two different problems.
>  >>  Please watch the bots?
> 
> Repository:
> 
>   rL LLVM
> 
> https://reviews.llvm.org/D45405


Repository:
  rL LLVM

https://reviews.llvm.org/D45405



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


[PATCH] D44602: [clang-tidy] readability-function-size: add VariableThreshold param.

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

Aside from some minor nits, LGTM!




Comment at: clang-tidy/readability/FunctionSizeCheck.cpp:28
+// Do not count decomposition declarations (C++17's structured bindings).
+// Do not count variables declared in macros.
+if (StructNesting == 0 &&

Comment is now stale.



Comment at: clang-tidy/readability/FunctionSizeCheck.cpp:31
+!(isa(VD) || isa(VD)))
+  Info.Variables++;
+return true;

Do you mind switching these to preincrement (and predecrement, below) since the 
value is not subsequently used?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44602



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


[PATCH] D45517: [analyzer] WIP: False positive refutation with Z3

2018-04-11 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs created this revision.
rnkovacs added reviewers: george.karpenkov, NoQ, dcoughlin.
Herald added subscribers: a.sidorin, szepet, baloghadamsoftware, whisperity, 
fhahn.

This is a prototype of a bug reporter visitor that invalidates bug reports by 
re-checking constraints of certain states on the bug path using the Z3 
constraint manager backend. The functionality is available under the 
`postprocess-reports` analyzer config flag.

Results of analysis runs on a few open-source projects with this option turned 
on can be explored here .

This work is preliminary and any comments are appreciated. A few remarks:

- In order to work with constraints generated by the range-based constraint 
manager outside its own file, much of the `Range`, `RangeTrait` and `RangeSet` 
classes have been moved to the corresponding header file.

- The visitor currently checks states appearing as block edges in the exploded 
graph. The first idea was to filter states based on the shape of the exploded 
graph, by checking the number of successors of the parent node, but 
surprisingly, both `succ_size()` and `pred_size()` seemed to return 1 for each 
node in the graph (except for the root), even if there clearly were branchings 
in the code (and on the `.dot` picture). To my understanding, the exploded 
graph is fully constructed at the stage where visitors are run, so I must be 
missing something.

- 1-bit APSInts obtained from ranged constraints crashed when 
`isSignedIntegerOrEnumerationType()` was called on them inside 
`Z3ConstraintManager`'s methods. This issue is currently sidestepped, but they 
might be converted to a valid built-in type at some point.


Repository:
  rC Clang

https://reviews.llvm.org/D45517

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.h
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp

Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#include "RangedConstraintManager.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -915,6 +916,8 @@
   void print(ProgramStateRef St, raw_ostream &Out, const char *nl,
  const char *sep) override;
 
+  bool checkRangedStateConstraints(ProgramStateRef State) override;
+
   //===--===//
   // Implementation for interface from SimpleConstraintManager.
   //===--===//
@@ -1235,6 +1238,47 @@
   return State->set(CZ);
 }
 
+bool Z3ConstraintManager::checkRangedStateConstraints(ProgramStateRef State) {
+  Solver.reset();
+  ConstraintRangeTy CR = State->get();
+
+  for (ConstraintRangeTy::iterator I = CR.begin(), E = CR.end(); I != E; ++I) {
+SymbolRef Sym = I.getKey();
+
+for (const auto &Range : I.getData()) {
+  const llvm::APSInt &From = Range.From();
+  const llvm::APSInt &To = Range.To();
+
+  assert((getAPSIntType(From) == getAPSIntType(To)) &&
+ "Range values have different types!");
+  QualType RangeTy = getAPSIntType(From);
+  // Skip ranges whose endpoints cannot be converted to APSInts with
+  // a valid APSIntType.
+  if (RangeTy.isNull())
+continue;
+
+  QualType SymTy;
+  Z3Expr Exp = getZ3Expr(Sym, &SymTy);
+  bool isSignedTy = SymTy->isSignedIntegerOrEnumerationType();
+
+  Z3Expr FromExp = Z3Expr::fromAPSInt(From);
+  Z3Expr ToExp = Z3Expr::fromAPSInt(To);
+
+  if (From == To) {
+Z3Expr Eq = getZ3BinExpr(Exp, SymTy, BO_EQ, FromExp, RangeTy, nullptr);
+Solver.addConstraint(Eq);
+  } else {
+Z3Expr LHS = getZ3BinExpr(Exp, SymTy, BO_GE, FromExp, RangeTy, nullptr);
+Z3Expr RHS = getZ3BinExpr(Exp, SymTy, BO_LE, ToExp, RangeTy, nullptr);
+Solver.addConstraint(Z3Expr::fromBinOp(LHS, BO_LAnd, RHS, isSignedTy));
+  }
+}
+  }
+  // If Z3 timeouts, Z3_L_UNDEF is returned, and we assume that the state
+  // is feasible.
+  return Solver.check() != Z3_L_FALSE;
+}
+
 //===--===//
 // Internal implementation.
 

[PATCH] D44602: [clang-tidy] readability-function-size: add VariableThreshold param.

2018-04-11 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 142003.
lebedev.ri marked 2 inline comments as done.
lebedev.ri added a comment.

- Drop stale comment
- Switch to pre{in,de}crement


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44602

Files:
  clang-tidy/readability/FunctionSizeCheck.cpp
  clang-tidy/readability/FunctionSizeCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-function-size.rst
  test/clang-tidy/readability-function-size-variables-c++17.cpp
  test/clang-tidy/readability-function-size.cpp

Index: test/clang-tidy/readability-function-size.cpp
===
--- test/clang-tidy/readability-function-size.cpp
+++ test/clang-tidy/readability-function-size.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-function-size %t -- -config='{CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}, {key: readability-function-size.ParameterThreshold, value: 5}, {key: readability-function-size.NestingThreshold, value: 2}]}' -- -std=c++11
+// RUN: %check_clang_tidy %s readability-function-size %t -- -config='{CheckOptions: [{key: readability-function-size.LineThreshold, value: 0}, {key: readability-function-size.StatementThreshold, value: 0}, {key: readability-function-size.BranchThreshold, value: 0}, {key: readability-function-size.ParameterThreshold, value: 5}, {key: readability-function-size.NestingThreshold, value: 2}, {key: readability-function-size.VariableThreshold, value: 1}]}' -- -std=c++11
 
 // Bad formatting is intentional, don't run clang-format over the whole file!
 
@@ -64,7 +64,7 @@
 
 void baz0() { // 1
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'baz0' exceeds recommended size/complexity
-  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 27 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 28 lines including whitespace and comments (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 9 statements (threshold 0)
   int a;
   { // 2
@@ -87,14 +87,15 @@
 }
   }
   macro()
-// CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
-// CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: note: nesting level 3 starts here (threshold 2)
+  // CHECK-MESSAGES: :[[@LINE-28]]:25: note: expanded from macro 'macro'
+  // CHECK-MESSAGES: :[[@LINE-27]]:6: note: 9 variables (threshold 1)
 }
 
 // check that nested if's are not reported. this was broken initially
 void nesting_if() { // 1
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'nesting_if' exceeds recommended size/complexity
-  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 18 statements (threshold 0)
   // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 6 branches (threshold 0)
   if (true) { // 2
@@ -114,12 +115,13 @@
   } else if (true) { // 2
  int j;
   }
+  // CHECK-MESSAGES: :[[@LINE-22]]:6: note: 6 variables (threshold 1)
 }
 
 // however this should warn
 void bad_if_nesting() { // 1
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: function 'bad_if_nesting' exceeds recommended size/complexity
-// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 22 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-2]]:6: note: 23 lines including whitespace and comments (threshold 0)
 // CHECK-MESSAGES: :[[@LINE-3]]:6: note: 12 statements (threshold 0)
 // CHECK-MESSAGES: :[[@LINE-4]]:6: note: 4 branches (threshold 0)
   if (true) {// 2
@@ -139,4 +141,161 @@
   }
 }
   }
+  // CHECK-MESSAGES: :[[@LINE-22]]:6: note: 4 variables (threshold 1)
 }
+
+void variables_0() {
+  int i;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_0' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
+void variables_1(int i) {
+  int j;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_1' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0)
+void variables_2(int i, int j) {
+  ;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:6: warning: function 'variables_2' exceeds recommended size/complexity thresholds [readability-function-size]
+// CHECK-MESSAGES: :[[@LINE-4]]:6: note: 2 lines including whitespace and comments (threshold 0)
+// CHECK-MESSAGES: :[[@LINE-5]]:6: note: 1 statements (threshold 0

Re: r329804 - [Sema] Fix built-in decrement operator overload resolution

2018-04-11 Thread Richard Smith via cfe-commits
While you're here... ++ should not be available for bool in C++17 onwards.
:)

On Wed, 11 Apr 2018, 14:39 Jan Korous via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> Author: jkorous
> Date: Wed Apr 11 06:36:29 2018
> New Revision: 329804
>
> URL: http://llvm.org/viewvc/llvm-project?rev=329804&view=rev
> Log:
> [Sema] Fix built-in decrement operator overload resolution
>
> C++ [over.built] p4:
>
> "For every pair (T, VQ), where T is an arithmetic type other than bool,
> and VQ is either volatile or empty, there exist candidate operator
> functions of the form
>
>   VQ T&  operator--(VQ T&);
>   T  operator--(VQ T&, int);
> "
> The bool type is in position LastPromotedIntegralType in
> BuiltinOperatorOverloadBuilder::getArithmeticType::ArithmeticTypes, but
> addPlusPlusMinusMinusArithmeticOverloads() was expecting it at position 0.
>
> Differential Revision: https://reviews.llvm.org/D44988
>
> rdar://problem/34255516
>
> Modified:
> cfe/trunk/lib/Sema/SemaOverload.cpp
> cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=329804&r1=329803&r2=329804&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Apr 11 06:36:29 2018
> @@ -7796,10 +7796,12 @@ public:
>  if (!HasArithmeticOrEnumeralCandidateType)
>return;
>
> -for (unsigned Arith = (Op == OO_PlusPlus? 0 : 1);
> - Arith < NumArithmeticTypes; ++Arith) {
> +for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) {
> +  const auto TypeOfT = ArithmeticTypes[Arith];
> +  if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy)
> +continue;
>addPlusPlusMinusMinusStyleOverloads(
> -ArithmeticTypes[Arith],
> +TypeOfT,
>  VisibleTypeConversionsQuals.hasVolatile(),
>  VisibleTypeConversionsQuals.hasRestrict());
>  }
>
> Modified: cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp?rev=329804&r1=329803&r2=329804&view=diff
>
> ==
> --- cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp (original)
> +++ cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp Wed Apr 11
> 06:36:29 2018
> @@ -62,6 +62,10 @@ void f(Short s, Long l, Enum1 e1, Enum2
>// FIXME: should pass (void)static_cast(islong(e1 % e2));
>  }
>
> +struct BoolRef {
> +  operator bool&();
> +};
> +
>  struct ShortRef { // expected-note{{candidate function (the implicit copy
> assignment operator) not viable}}
>  #if __cplusplus >= 201103L // C++11 or later
>  // expected-note@-2 {{candidate function (the implicit move assignment
> operator) not viable}}
> @@ -73,6 +77,10 @@ struct LongRef {
>operator volatile long&();
>  };
>
> +struct FloatRef {
> +  operator float&();
> +};
> +
>  struct XpmfRef { // expected-note{{candidate function (the implicit copy
> assignment operator) not viable}}
>  #if __cplusplus >= 201103L // C++11 or later
>  // expected-note@-2 {{candidate function (the implicit move assignment
> operator) not viable}}
> @@ -84,13 +92,19 @@ struct E2Ref {
>operator E2&();
>  };
>
> -void g(ShortRef sr, LongRef lr, E2Ref e2_ref, XpmfRef pmf_ref) {
> +void g(BoolRef br, ShortRef sr, LongRef lr, FloatRef fr, E2Ref e2_ref,
> XpmfRef pmf_ref) {
>// C++ [over.built]p3
>short s1 = sr++;
>
> -  // C++ [over.built]p3
> +  // C++ [over.built]p4
>long l1 = lr--;
>
> +  // C++ [over.built]p4
> +  float f1 = fr--;
> +
> +  // C++ [over.built]p4
> +  bool b2 = br--; // expected-error{{cannot decrement value of type
> 'BoolRef'}}
> +
>// C++ [over.built]p18
>short& sr1 = (sr *= lr);
>volatile long& lr1 = (lr *= sr);
>
>
> ___
> 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


r329810 - [Driver] Don't forward -m[no-]unaligned-access options to GCC when assembling/linking

2018-04-11 Thread Chad Rosier via cfe-commits
Author: mcrosier
Date: Wed Apr 11 07:20:37 2018
New Revision: 329810

URL: http://llvm.org/viewvc/llvm-project?rev=329810&view=rev
Log:
[Driver] Don't forward -m[no-]unaligned-access options to GCC when 
assembling/linking

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/gcc_forward.c

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=329810&r1=329809&r2=329810&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed Apr 11 07:20:37 2018
@@ -85,6 +85,13 @@ void tools::gcc::Common::ConstructJob(Co
   A->getOption().matches(options::OPT_W_Group))
 continue;
 
+  // Don't forward -mno-unaligned-access since GCC doesn't understand
+  // it and because it doesn't affect the assembly or link steps.
+  if ((isa(JA) || isa(JA)) &&
+  (A->getOption().matches(options::OPT_munaligned_access) ||
+   A->getOption().matches(options::OPT_mno_unaligned_access)))
+continue;
+
   A->render(Args, CmdArgs);
 }
   }

Modified: cfe/trunk/test/Driver/gcc_forward.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gcc_forward.c?rev=329810&r1=329809&r2=329810&view=diff
==
--- cfe/trunk/test/Driver/gcc_forward.c (original)
+++ cfe/trunk/test/Driver/gcc_forward.c Wed Apr 11 07:20:37 2018
@@ -34,3 +34,9 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 // CHECK-ASM: as
 // CHECK-ASM-NOT: "-g"
+
+// Check that we're not forwarding -mno-unaligned-access.
+// RUN: %clang -target aarch64-none-elf -mno-unaligned-access %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM %s
+// CHECK-ARM: gcc{{[^"]*}}"
+// CHECK-ARM-NOT: -mno-unaligned-access


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


[PATCH] D45092: [Driver] Don't forward -m[no-]unaligned-access options to GCC when assembling/linking

2018-04-11 Thread Chad Rosier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329810: [Driver] Don't forward -m[no-]unaligned-access 
options to GCC when… (authored by mcrosier, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D45092

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/gcc_forward.c


Index: test/Driver/gcc_forward.c
===
--- test/Driver/gcc_forward.c
+++ test/Driver/gcc_forward.c
@@ -34,3 +34,9 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 // CHECK-ASM: as
 // CHECK-ASM-NOT: "-g"
+
+// Check that we're not forwarding -mno-unaligned-access.
+// RUN: %clang -target aarch64-none-elf -mno-unaligned-access %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM %s
+// CHECK-ARM: gcc{{[^"]*}}"
+// CHECK-ARM-NOT: -mno-unaligned-access
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -85,6 +85,13 @@
   A->getOption().matches(options::OPT_W_Group))
 continue;
 
+  // Don't forward -mno-unaligned-access since GCC doesn't understand
+  // it and because it doesn't affect the assembly or link steps.
+  if ((isa(JA) || isa(JA)) &&
+  (A->getOption().matches(options::OPT_munaligned_access) ||
+   A->getOption().matches(options::OPT_mno_unaligned_access)))
+continue;
+
   A->render(Args, CmdArgs);
 }
   }


Index: test/Driver/gcc_forward.c
===
--- test/Driver/gcc_forward.c
+++ test/Driver/gcc_forward.c
@@ -34,3 +34,9 @@
 // RUN:   | FileCheck --check-prefix=CHECK-ASM %s
 // CHECK-ASM: as
 // CHECK-ASM-NOT: "-g"
+
+// Check that we're not forwarding -mno-unaligned-access.
+// RUN: %clang -target aarch64-none-elf -mno-unaligned-access %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM %s
+// CHECK-ARM: gcc{{[^"]*}}"
+// CHECK-ARM-NOT: -mno-unaligned-access
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -85,6 +85,13 @@
   A->getOption().matches(options::OPT_W_Group))
 continue;
 
+  // Don't forward -mno-unaligned-access since GCC doesn't understand
+  // it and because it doesn't affect the assembly or link steps.
+  if ((isa(JA) || isa(JA)) &&
+  (A->getOption().matches(options::OPT_munaligned_access) ||
+   A->getOption().matches(options::OPT_mno_unaligned_access)))
+continue;
+
   A->render(Args, CmdArgs);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43578: -ftime-report switch support in Clang

2018-04-11 Thread Andrew V. Tischenko via Phabricator via cfe-commits
avt77 added a comment.

In https://reviews.llvm.org/D43578#1064113, @russell.gallop wrote:

> We also see an assertion failure prior to the revert. At r329738:


Yes, you're right - thaks again for this test case.


Repository:
  rL LLVM

https://reviews.llvm.org/D43578



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


[PATCH] D43764: [clang-apply-replacements] Convert tooling::Replacements to tooling::AtomicChange for conflict resolving of changes, code cleanup, and code formatting.

2018-04-11 Thread Malcolm Parsons via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329813: [clang-apply-replacements] Convert 
tooling::Replacements to tooling… (authored by malcolm.parsons, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D43764?vs=141969&id=142006#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D43764

Files:
  
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  
clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt
  
clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file2.yaml
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/expected.txt
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/file1.yaml
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/identical.cpp
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/expected.txt
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/file1.yaml
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/file2.yaml
  
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/order-dependent.cpp
  clang-tools-extra/trunk/test/clang-apply-replacements/identical.cpp
  clang-tools-extra/trunk/test/clang-apply-replacements/order-dependent.cpp
  
clang-tools-extra/trunk/unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
  clang-tools-extra/trunk/unittests/clang-apply-replacements/CMakeLists.txt
  
clang-tools-extra/trunk/unittests/clang-apply-replacements/ReformattingTest.cpp

Index: clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
===
--- clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
+++ clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
@@ -18,6 +18,7 @@
 
 #include "clang/Tooling/Core/Diagnostic.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -29,15 +30,8 @@
 class DiagnosticsEngine;
 class Rewriter;
 
-namespace format {
-struct FormatStyle;
-} // end namespace format
-
 namespace replace {
 
-/// \brief Collection of source ranges.
-typedef std::vector RangeVector;
-
 /// \brief Collection of TranslationUnitReplacements.
 typedef std::vector TUReplacements;
 
@@ -47,10 +41,10 @@
 /// \brief Collection of TranslationUniDiagnostics.
 typedef std::vector TUDiagnostics;
 
-/// \brief Map mapping file name to Replacements targeting that file.
+/// \brief Map mapping file name to a set of AtomicChange targeting that file.
 typedef llvm::DenseMap>
-FileToReplacementsMap;
+   std::vector>
+FileToChangesMap;
 
 /// \brief Recursively descends through a directory structure rooted at \p
 /// Directory and attempts to deserialize *.yaml files as
@@ -77,65 +71,39 @@
 const llvm::StringRef Directory, TUDiagnostics &TUs,
 TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics);
 
-/// \brief Deduplicate, check for conflicts, and apply all Replacements stored
-/// in \c TUs. If conflicts occur, no Replacements are applied.
+/// \brief Deduplicate, check for conflicts, and extract all Replacements stored
+/// in \c TUs. Conflicting replacements are skipped.
 ///
-/// \post For all (key,value) in GroupedReplacements, value[i].getOffset() <=
+/// \post For all (key,value) in FileChanges, value[i].getOffset() <=
 /// value[i+1].getOffset().
 ///
 /// \param[in] TUs Collection of TranslationUnitReplacements or
-/// TranslationUnitDiagnostics to merge,
-/// deduplicate, and test for conflicts.
-/// \param[out] GroupedReplacements Container grouping all Replacements by the
-/// file they target.
+/// TranslationUnitDiagnostics to merge, deduplicate, and test for conflicts.
+/// \param[out] FileChanges Container grouping all changes by the
+/// file they target. Only non conflicting replacements are kept into
+/// FileChanges.
 /// \param[in] SM SourceManager required for conflict reporting.
 ///
 /// \returns \parblock
-///  \li true If all changes were applied successfully.
+///  \li true If all changes were converted successfully.
 ///  \li false If there were conflicts.
-bool mergeAndDeduplicate(const TUReplacements &TUs,
- FileToReplacementsMap &GroupedReplacements,
- clang::SourceManager &SM);
-
-bool mergeAndDeduplicate(const TUDiagnostics &TUs,
-  

[clang-tools-extra] r329813 - [clang-apply-replacements] Convert tooling::Replacements to tooling::AtomicChange for conflict resolving of changes, code cleanup, and code formatting.

2018-04-11 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Wed Apr 11 07:39:17 2018
New Revision: 329813

URL: http://llvm.org/viewvc/llvm-project?rev=329813&view=rev
Log:
[clang-apply-replacements] Convert tooling::Replacements to 
tooling::AtomicChange for conflict resolving of changes, code cleanup, and code 
formatting.

Summary:
By converting Replacements by AtomicChange, clang-apply-replacements is able 
like clang-tidy to automatically cleanup and format changes.
This should permits to close this ticket: 
https://bugs.llvm.org/show_bug.cgi?id=35051 and attempt to follow hints from 
https://reviews.llvm.org/D43500 comments.

Reviewers: klimek, ioeric

Reviewed By: ioeric

Subscribers: malcolm.parsons, mgorny, cfe-commits

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

Patch by Jeremy Demeule.

Added:
clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/file1.yaml

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/identical/identical.cpp

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/expected.txt

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/file1.yaml

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/file2.yaml

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/order-dependent/order-dependent.cpp
clang-tools-extra/trunk/test/clang-apply-replacements/identical.cpp
clang-tools-extra/trunk/test/clang-apply-replacements/order-dependent.cpp
Removed:

clang-tools-extra/trunk/unittests/clang-apply-replacements/ReformattingTest.cpp
Modified:

clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h

clang-tools-extra/trunk/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
clang-tools-extra/trunk/clang-apply-replacements/tool/CMakeLists.txt

clang-tools-extra/trunk/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/basic/file2.yaml

clang-tools-extra/trunk/test/clang-apply-replacements/Inputs/conflict/expected.txt

clang-tools-extra/trunk/unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
clang-tools-extra/trunk/unittests/clang-apply-replacements/CMakeLists.txt

Modified: 
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h?rev=329813&r1=329812&r2=329813&view=diff
==
--- 
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
 (original)
+++ 
clang-tools-extra/trunk/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
 Wed Apr 11 07:39:17 2018
@@ -18,6 +18,7 @@
 
 #include "clang/Tooling/Core/Diagnostic.h"
 #include "clang/Tooling/Refactoring.h"
+#include "clang/Tooling/Refactoring/AtomicChange.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include 
@@ -29,15 +30,8 @@ namespace clang {
 class DiagnosticsEngine;
 class Rewriter;
 
-namespace format {
-struct FormatStyle;
-} // end namespace format
-
 namespace replace {
 
-/// \brief Collection of source ranges.
-typedef std::vector RangeVector;
-
 /// \brief Collection of TranslationUnitReplacements.
 typedef std::vector 
TUReplacements;
 
@@ -47,10 +41,10 @@ typedef std::vector TURepla
 /// \brief Collection of TranslationUniDiagnostics.
 typedef std::vector TUDiagnostics;
 
-/// \brief Map mapping file name to Replacements targeting that file.
+/// \brief Map mapping file name to a set of AtomicChange targeting that file.
 typedef llvm::DenseMap>
-FileToReplacementsMap;
+   std::vector>
+FileToChangesMap;
 
 /// \brief Recursively descends through a directory structure rooted at \p
 /// Directory and attempts to deserialize *.yaml files as
@@ -77,65 +71,39 @@ std::error_code collectReplacementsFromD
 const llvm::StringRef Directory, TUDiagnostics &TUs,
 TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics);
 
-/// \brief Deduplicate, check for conflicts, and apply all Replacements stored
-/// in \c TUs. If conflicts occur, no Replacements are applied.
+/// \brief Deduplicate, check for conflicts, and extract all Replacements 
stored
+/// in \c TUs. Conflicting replacements are skipped.
 ///
-/// \post For all (key,value) in GroupedReplacements, value[i].getOffset() <=
+/// \post For all (key,value) in FileChanges, value[i].getOffset() <=
 /// value[i+1].getOffset().
 ///
 /// \param[in] TUs Collection of TranslationUnitReplacements or
-/// Tran

r329814 - [NEON] Support vfma_n and vfms_n intrinsics

2018-04-11 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Wed Apr 11 07:43:11 2018
New Revision: 329814

URL: http://llvm.org/viewvc/llvm-project?rev=329814&view=rev
Log:
[NEON] Support vfma_n and vfms_n intrinsics

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

Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/test/CodeGen/aarch64-neon-2velem.c

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=329814&r1=329813&r2=329814&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Wed Apr 11 07:43:11 2018
@@ -621,8 +621,8 @@ def FMLS : SOpInst<"vfms", "", "dQd"
 // MUL, MLA, MLS, FMA, FMS definitions with scalar argument
 def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>;
 
-def FMLA_N : SOpInst<"vfma_n", "ddds", "fQfQd", OP_FMLA_N>;
-def FMLS_N : SOpInst<"vfms_n", "ddds", "fQfQd", OP_FMLS_N>;
+def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>;
+def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>;
 
 def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>;
 def MLS_N : SOpInst<"vmls_n", "ddds", "Qd", OP_MLS_N>;

Modified: cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-2velem.c?rev=329814&r1=329813&r2=329814&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-2velem.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-2velem.c Wed Apr 11 07:43:11 2018
@@ -3083,6 +3083,17 @@ float32x2_t test_vfma_n_f32(float32x2_t
   return vfma_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfma_n_f64(
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, 
i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> %b, 
<1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfma_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfma_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmaq_n_f32(
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
 // CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], 
float %n, i32 1
@@ -3110,6 +3121,18 @@ float32x2_t test_vfms_n_f32(float32x2_t
   return vfms_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfms_n_f64(
+// CHECK:   [[SUB_I:%.*]] = fsub <1 x double> , %b
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, 
i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> [[SUB_I]] to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> 
[[SUB_I]], <1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfms_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfms_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmsq_n_f32(
 // CHECK:   [[SUB_I:%.*]] = fsub <4 x float> , %b
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0


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


[PATCH] D45483: [NEON] Support vfma_n and vfms_n intrinsics

2018-04-11 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC329814: [NEON] Support vfma_n and vfms_n intrinsics 
(authored by kosarev, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D45483

Files:
  include/clang/Basic/arm_neon.td
  test/CodeGen/aarch64-neon-2velem.c


Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -621,8 +621,8 @@
 // MUL, MLA, MLS, FMA, FMS definitions with scalar argument
 def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>;
 
-def FMLA_N : SOpInst<"vfma_n", "ddds", "fQfQd", OP_FMLA_N>;
-def FMLS_N : SOpInst<"vfms_n", "ddds", "fQfQd", OP_FMLS_N>;
+def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>;
+def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>;
 
 def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>;
 def MLS_N : SOpInst<"vmls_n", "ddds", "Qd", OP_MLS_N>;
Index: test/CodeGen/aarch64-neon-2velem.c
===
--- test/CodeGen/aarch64-neon-2velem.c
+++ test/CodeGen/aarch64-neon-2velem.c
@@ -3083,6 +3083,17 @@
   return vfma_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfma_n_f64(
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, 
i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> %b, 
<1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfma_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfma_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmaq_n_f32(
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
 // CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], 
float %n, i32 1
@@ -3110,6 +3121,18 @@
   return vfms_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfms_n_f64(
+// CHECK:   [[SUB_I:%.*]] = fsub <1 x double> , %b
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, 
i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> [[SUB_I]] to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> 
[[SUB_I]], <1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfms_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfms_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmsq_n_f32(
 // CHECK:   [[SUB_I:%.*]] = fsub <4 x float> , %b
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0


Index: include/clang/Basic/arm_neon.td
===
--- include/clang/Basic/arm_neon.td
+++ include/clang/Basic/arm_neon.td
@@ -621,8 +621,8 @@
 // MUL, MLA, MLS, FMA, FMS definitions with scalar argument
 def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>;
 
-def FMLA_N : SOpInst<"vfma_n", "ddds", "fQfQd", OP_FMLA_N>;
-def FMLS_N : SOpInst<"vfms_n", "ddds", "fQfQd", OP_FMLS_N>;
+def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>;
+def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>;
 
 def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>;
 def MLS_N : SOpInst<"vmls_n", "ddds", "Qd", OP_MLS_N>;
Index: test/CodeGen/aarch64-neon-2velem.c
===
--- test/CodeGen/aarch64-neon-2velem.c
+++ test/CodeGen/aarch64-neon-2velem.c
@@ -3083,6 +3083,17 @@
   return vfma_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfma_n_f64(
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> %b, <1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfma_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfma_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmaq_n_f32(
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
 // CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], float %n, i32 1
@@ -3110,6 +3121,18 @@
   return vfms_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfms_n_f64(
+// CHECK:   [[SUB_I:%.*]] = fsub <1 x double> , %b
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.

[PATCH] D45483: [NEON] Support vfma_n and vfms_n intrinsics

2018-04-11 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329814: [NEON] Support vfma_n and vfms_n intrinsics 
(authored by kosarev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45483?vs=141828&id=142008#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45483

Files:
  cfe/trunk/include/clang/Basic/arm_neon.td
  cfe/trunk/test/CodeGen/aarch64-neon-2velem.c


Index: cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
===
--- cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
+++ cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
@@ -3083,6 +3083,17 @@
   return vfma_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfma_n_f64(
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, 
i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> %b, 
<1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfma_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfma_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmaq_n_f32(
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
 // CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], 
float %n, i32 1
@@ -3110,6 +3121,18 @@
   return vfms_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfms_n_f64(
+// CHECK:   [[SUB_I:%.*]] = fsub <1 x double> , %b
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, 
i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> [[SUB_I]] to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> 
[[SUB_I]], <1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfms_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfms_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmsq_n_f32(
 // CHECK:   [[SUB_I:%.*]] = fsub <4 x float> , %b
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -621,8 +621,8 @@
 // MUL, MLA, MLS, FMA, FMS definitions with scalar argument
 def VMUL_N_A64 : IOpInst<"vmul_n", "dds", "Qd", OP_MUL_N>;
 
-def FMLA_N : SOpInst<"vfma_n", "ddds", "fQfQd", OP_FMLA_N>;
-def FMLS_N : SOpInst<"vfms_n", "ddds", "fQfQd", OP_FMLS_N>;
+def FMLA_N : SOpInst<"vfma_n", "ddds", "fdQfQd", OP_FMLA_N>;
+def FMLS_N : SOpInst<"vfms_n", "ddds", "fdQfQd", OP_FMLS_N>;
 
 def MLA_N : SOpInst<"vmla_n", "ddds", "Qd", OP_MLA_N>;
 def MLS_N : SOpInst<"vmls_n", "ddds", "Qd", OP_MLS_N>;


Index: cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
===
--- cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
+++ cfe/trunk/test/CodeGen/aarch64-neon-2velem.c
@@ -3083,6 +3083,17 @@
   return vfma_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfma_n_f64(
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> %b to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> %b, <1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfma_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfma_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmaq_n_f32(
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4 x float> undef, float %n, i32 0
 // CHECK:   [[VECINIT1_I:%.*]] = insertelement <4 x float> [[VECINIT_I]], float %n, i32 1
@@ -3110,6 +3121,18 @@
   return vfms_n_f32(a, b, n);
 }
 
+// CHECK-LABEL: @test_vfms_n_f64(
+// CHECK:   [[SUB_I:%.*]] = fsub <1 x double> , %b
+// CHECK:   [[VECINIT_I:%.*]] = insertelement <1 x double> undef, double %n, i32 0
+// CHECK:   [[TMP0:%.*]] = bitcast <1 x double> %a to <8 x i8>
+// CHECK:   [[TMP1:%.*]] = bitcast <1 x double> [[SUB_I]] to <8 x i8>
+// CHECK:   [[TMP2:%.*]] = bitcast <1 x double> [[VECINIT_I]] to <8 x i8>
+// CHECK:   [[TMP3:%.*]] = call <1 x double> @llvm.fma.v1f64(<1 x double> [[SUB_I]], <1 x double> [[VECINIT_I]], <1 x double> %a)
+// CHECK:   ret <1 x double> [[TMP3]]
+float64x1_t test_vfms_n_f64(float64x1_t a, float64x1_t b, float64_t n) {
+  return vfms_n_f64(a, b, n);
+}
+
 // CHECK-LABEL: @test_vfmsq_n_f32(
 // CHE

r329816 - Fix bugs around handling C++11 attributes.

2018-04-11 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Wed Apr 11 07:51:54 2018
New Revision: 329816

URL: http://llvm.org/viewvc/llvm-project?rev=329816&view=rev
Log:
Fix bugs around handling C++11 attributes.

Previously, we would format:
  int a() { ... }
  [[unused]] int b() { ... }
as...
  int a() {} [[unused] int b() {}
Now we correctly format each on its own line.

Similarly, we would detect:
  [[unused]] int b() { return 42; }
As a lambda and leave it on a single line, even if that was disallowed
by the format style.

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

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=329816&r1=329815&r2=329816&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed Apr 11 07:51:54 2018
@@ -449,12 +449,19 @@ void UnwrappedLineParser::calculateBrace
   (Style.isCpp() && NextTok->is(tok::l_paren)) ||
   NextTok->isOneOf(tok::comma, tok::period, tok::colon,
tok::r_paren, tok::r_square, tok::l_brace,
-   tok::l_square, tok::ellipsis) ||
+   tok::ellipsis) ||
   (NextTok->is(tok::identifier) &&
!PrevTok->isOneOf(tok::semi, tok::r_brace, tok::l_brace)) ||
   (NextTok->is(tok::semi) &&
(!ExpectClassBody || LBraceStack.size() != 1)) ||
   (NextTok->isBinaryOperator() && !NextIsObjCMethod);
+  if (NextTok->is(tok::l_square)) {
+// We can have an array subscript after a braced init
+// list, but C++11 attributes are expected after blocks.
+NextTok = Tokens->getNextToken();
+++ReadTokens;
+ProbablyBracedList = NextTok->isNot(tok::l_square);
+  }
 }
 if (ProbablyBracedList) {
   Tok->BlockKind = BK_BracedInit;
@@ -1406,13 +1413,16 @@ bool UnwrappedLineParser::tryToParseLamb
   const FormatToken *Previous = FormatTok->Previous;
   if (Previous &&
   (Previous->isOneOf(tok::identifier, tok::kw_operator, tok::kw_new,
- tok::kw_delete) ||
+ tok::kw_delete, tok::l_square) ||
FormatTok->isCppStructuredBinding(Style) || Previous->closesScope() ||
Previous->isSimpleTypeSpecifier())) {
 nextToken();
 return false;
   }
   nextToken();
+  if (FormatTok->is(tok::l_square)) {
+return false;
+  }
   parseSquare(/*LambdaIntroducer=*/true);
   return true;
 }

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=329816&r1=329815&r2=329816&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Apr 11 07:51:54 2018
@@ -6078,6 +6078,21 @@ TEST_F(FormatTest, UnderstandsSquareAttr
   verifyFormat("void f() [[deprecated(\"so sorry\")]];");
   verifyFormat("aa\n"
"[[unused]] aaa(int i);");
+
+  // Make sure we do not mistake attributes for array subscripts.
+  verifyFormat("int a() {}\n"
+   "[[unused]] int b() {}\n");
+
+  // On the other hand, we still need to correctly find array subscripts.
+  verifyFormat("int a = std::vector{1, 2, 3}[0];");
+
+  // Make sure we do not parse attributes as lambda introducers.
+  FormatStyle MultiLineFunctions = getLLVMStyle();
+  MultiLineFunctions.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+  verifyFormat("[[unused]] int b() {\n"
+   "  return 42;\n"
+   "}\n",
+   MultiLineFunctions);
 }
 
 TEST_F(FormatTest, UnderstandsEllipsis) {


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


[PATCH] D45521: [clang-format] Improve ObjC guessing heuristic by supporting all @keywords

2018-04-11 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: djasper, jolesiak.
Herald added subscribers: cfe-commits, klimek.

This diff improves the Objective-C guessing heuristic by
replacing the hard-coded list of a subset of Objective-C @keywords
with a general check which supports all @keywords.

I also added a few more Foundation keywords which were missing from
the heuristic.

Test Plan: Unit tests updated. Ran tests with:

  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D45521

Files:
  lib/Format/Format.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12101,6 +12101,12 @@
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.mm", ""));
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", ""));
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "@interface 
Foo\n@end\n"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define TRY(x, y) @try { x; } @finally { y; }"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#define AVAIL(x) @available(x, *))"));
+  EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "@class Foo;"));
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo", ""));
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo", "@interface 
Foo\n@end\n"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1465,6 +1465,7 @@
 "NSAffineTransform",
 "NSArray",
 "NSAttributedString",
+"NSBlockOperation",
 "NSBundle",
 "NSCache",
 "NSCalendar",
@@ -1480,6 +1481,7 @@
 "NSIndexPath",
 "NSIndexSet",
 "NSInteger",
+"NSInvocationOperation",
 "NSLocale",
 "NSMapTable",
 "NSMutableArray",
@@ -1494,9 +1496,13 @@
 "NSNumber",
 "NSNumberFormatter",
 "NSObject",
+"NSOperation",
+"NSOperationQueue",
+"NSOperationQueuePriority",
 "NSOrderedSet",
 "NSPoint",
 "NSPointerArray",
+"NSQualityOfService",
 "NSRange",
 "NSRect",
 "NSRegularExpression",
@@ -1518,10 +1524,7 @@
   for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&
- (FormatTok->isObjCAtKeyword(tok::objc_interface) ||
-  FormatTok->isObjCAtKeyword(tok::objc_implementation) ||
-  FormatTok->isObjCAtKeyword(tok::objc_protocol) ||
-  FormatTok->isObjCAtKeyword(tok::objc_end) ||
+ (FormatTok->Tok.getObjCKeywordID() != tok::objc_not_keyword ||
   FormatTok->isOneOf(tok::numeric_constant, tok::l_square,
  tok::l_brace))) ||
 (FormatTok->Tok.isAnyIdentifier() &&


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -12101,6 +12101,12 @@
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.mm", ""));
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo.h", ""));
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "@interface Foo\n@end\n"));
+  EXPECT_EQ(
+  FormatStyle::LK_ObjC,
+  guessLanguage("foo.h", "#define TRY(x, y) @try { x; } @finally { y; }"));
+  EXPECT_EQ(FormatStyle::LK_ObjC,
+guessLanguage("foo.h", "#define AVAIL(x) @available(x, *))"));
+  EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo.h", "@class Foo;"));
   EXPECT_EQ(FormatStyle::LK_Cpp, guessLanguage("foo", ""));
   EXPECT_EQ(FormatStyle::LK_ObjC, guessLanguage("foo", "@interface Foo\n@end\n"));
   EXPECT_EQ(FormatStyle::LK_ObjC,
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -1465,6 +1465,7 @@
 "NSAffineTransform",
 "NSArray",
 "NSAttributedString",
+"NSBlockOperation",
 "NSBundle",
 "NSCache",
 "NSCalendar",
@@ -1480,6 +1481,7 @@
 "NSIndexPath",
 "NSIndexSet",
 "NSInteger",
+"NSInvocationOperation",
 "NSLocale",
 "NSMapTable",
 "NSMutableArray",
@@ -1494,9 +1496,13 @@
 "NSNumber",
 "NSNumberFormatter",
 "NSObject",
+"NSOperation",
+"NSOperationQueue",
+"NSOperationQueuePriority",
 "NSOrderedSet",
 "NSPoint",
 "NSPointerArray",
+"NSQualityOfService",
 "NSRange",
 "NSRect",
 "NSRegularExpression",
@@ -1518,10 +1524,7 @@

[PATCH] D45523: [CodeGen] Handle __func__ inside __finally

2018-04-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: compnerd, majnemer, rnk.

When we enter a __finally block, the CGF's CurCodeDecl will be null
(because CodeGenFunction::StartFunction is given an empty GlobalDecl for
a __finally block), and so the dyn_cast here will result in an assertion
failure. Change it to dyn_cast_or_null to handle this case.


Repository:
  rC Clang

https://reviews.llvm.org/D45523

Files:
  lib/CodeGen/CGExpr.cpp
  test/CodeGen/exceptions-seh-finally.c


Index: test/CodeGen/exceptions-seh-finally.c
===
--- test/CodeGen/exceptions-seh-finally.c
+++ test/CodeGen/exceptions-seh-finally.c
@@ -268,6 +268,18 @@
 // CHECK-LABEL: define internal void 
@"?fin$1@0@finally_within_finally@@"({{[^)]*}})
 // CHECK-SAME: [[finally_attrs]]
 
+void cleanup_with_func(const char *);
+void finally_with_func() {
+  __try {
+might_crash();
+  } __finally {
+cleanup_with_func(__func__);
+  }
+}
+
+// CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
+// CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], 
[18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i32 0, i32 0))
+
 // Look for the absence of noinline. Enum attributes come first, so check that
 // a string attribute is the first to verify that no enum attributes are
 // present.
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -2611,7 +2611,7 @@
   StringRef NameItems[] = {
   PredefinedExpr::getIdentTypeName(E->getIdentType()), FnName};
   std::string GVName = llvm::join(NameItems, NameItems + 2, ".");
-  if (auto *BD = dyn_cast(CurCodeDecl)) {
+  if (auto *BD = dyn_cast_or_null(CurCodeDecl)) {
 std::string Name = SL->getString();
 if (!Name.empty()) {
   unsigned Discriminator =


Index: test/CodeGen/exceptions-seh-finally.c
===
--- test/CodeGen/exceptions-seh-finally.c
+++ test/CodeGen/exceptions-seh-finally.c
@@ -268,6 +268,18 @@
 // CHECK-LABEL: define internal void @"?fin$1@0@finally_within_finally@@"({{[^)]*}})
 // CHECK-SAME: [[finally_attrs]]
 
+void cleanup_with_func(const char *);
+void finally_with_func() {
+  __try {
+might_crash();
+  } __finally {
+cleanup_with_func(__func__);
+  }
+}
+
+// CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
+// CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i32 0, i32 0))
+
 // Look for the absence of noinline. Enum attributes come first, so check that
 // a string attribute is the first to verify that no enum attributes are
 // present.
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -2611,7 +2611,7 @@
   StringRef NameItems[] = {
   PredefinedExpr::getIdentTypeName(E->getIdentType()), FnName};
   std::string GVName = llvm::join(NameItems, NameItems + 2, ".");
-  if (auto *BD = dyn_cast(CurCodeDecl)) {
+  if (auto *BD = dyn_cast_or_null(CurCodeDecl)) {
 std::string Name = SL->getString();
 if (!Name.empty()) {
   unsigned Discriminator =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45523: [CodeGen] Handle __func__ inside __finally

2018-04-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added inline comments.



Comment at: test/CodeGen/exceptions-seh-finally.c:281
+// CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
+// CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], 
[18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i32 0, i32 0))
+

How stable is the mangling here? I included the complete `call` instruction 
because I wanted to ensure that the value of `__func__` inside a `__finally` 
block reflects the parent function, not the outlined funclet, and both the `[18 
x i8]` and the mangled string name are pretty good proxies for that. I can 
generalize it more if it'll make the test more reliable though.


Repository:
  rC Clang

https://reviews.llvm.org/D45523



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


[PATCH] D45491: [analyzer] Do not invalidate the `this` pointer.

2018-04-11 Thread Henry Wong via Phabricator via cfe-commits
MTC updated this revision to Diff 142026.
MTC marked 2 inline comments as done.
MTC added a comment.

- Move the `CXXThisRegion`'s check to `LoopWidening.cpp`
- Use `isa(R)` instead of `CXXThisRegion::classof(R)`.


Repository:
  rC Clang

https://reviews.llvm.org/D45491

Files:
  lib/StaticAnalyzer/Core/LoopWidening.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/this-pointer.cpp

Index: test/Analysis/this-pointer.cpp
===
--- /dev/null
+++ test/Analysis/this-pointer.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -analyzer-config widen-loops=true -analyzer-disable-retry-exhausted -verify %s
+
+void clang_analyzer_eval(bool);
+void clang_analyzer_dump(int);
+
+// 'this' pointer is not an lvalue, we should not invalidate it.
+namespace this_pointer_after_loop_widen {
+class A {
+public:
+  A() {
+int count = 10;
+do {
+} while (count--);
+  }
+};
+
+void goo(A a);
+void test_temporary_object() {
+  goo(A()); // no-crash
+}
+
+struct B {
+  int mem;
+  B() : mem(0) {
+for (int i = 0; i < 10; ++i) {
+}
+mem = 0;
+  }
+};
+
+void test_ctor() {
+  B b;
+  clang_analyzer_eval(b.mem == 0); // expected-warning{{TRUE}}
+}
+
+struct C {
+  int mem;
+  C() : mem(0) {}
+  void set() {
+for (int i = 0; i < 10; ++i) {
+}
+mem = 10;
+  }
+};
+
+void test_method() {
+  C c;
+  clang_analyzer_eval(c.mem == 0); // expected-warning{{TRUE}}
+  c.set();
+  clang_analyzer_eval(c.mem == 10); // expected-warning{{TRUE}}
+}
+
+struct D {
+  int mem;
+  D() : mem(0) {}
+  void set() {
+for (int i = 0; i < 10; ++i) {
+}
+mem = 10;
+  }
+};
+
+void test_new() {
+  D *d = new D;
+  clang_analyzer_eval(d->mem == 0); // expected-warning{{TRUE}}
+  d->set();
+  clang_analyzer_eval(d->mem == 10); // expected-warning{{TRUE}}
+}
+
+struct E {
+  int mem;
+  E() : mem(0) {}
+  void set() {
+for (int i = 0; i < 10; ++i) {
+}
+setAux();
+  }
+  void setAux() {
+this->mem = 10;
+  }
+};
+
+void test_chained_method_call() {
+  E e;
+  e.set();
+  clang_analyzer_eval(e.mem == 10); // expected-warning{{TRUE}}
+}
+} // namespace this_pointer_after_loop_widen
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2050,6 +2050,9 @@
 R = GetElementZeroRegion(SR, T);
   }
 
+  assert((!isa(R) || !B.lookup(R)) &&
+ "'this' pointer is not an l-value and is not assignable");
+
   // Clear out bindings that may overlap with this binding.
   RegionBindingsRef NewB = removeSubRegionBindings(B, cast(R));
   return NewB.addBinding(BindingKey::Make(R, BindingKey::Direct), V);
Index: lib/StaticAnalyzer/Core/LoopWidening.cpp
===
--- lib/StaticAnalyzer/Core/LoopWidening.cpp
+++ lib/StaticAnalyzer/Core/LoopWidening.cpp
@@ -59,6 +59,18 @@
 ITraits.setTrait(Region,
  RegionAndSymbolInvalidationTraits::TK_EntireMemSpace);
   }
+
+  // 'this' pointer is not an lvalue, we should not invalidate it. If the loop
+  // is located in a method, constructor or destructor, the value of 'this'
+  // pointer shoule remain unchanged.
+  if (const CXXMethodDecl *CXXMD = dyn_cast(STC->getDecl())) {
+const CXXThisRegion *ThisR = MRMgr.getCXXThisRegion(
+CXXMD->getThisType(STC->getAnalysisDeclContext()->getASTContext()),
+STC);
+ITraits.setTrait(ThisR,
+ RegionAndSymbolInvalidationTraits::TK_PreserveContents);
+  }
+
   return PrevState->invalidateRegions(Regions, getLoopCondition(LoopStmt),
   BlockCount, LCtx, true, nullptr, nullptr,
   &ITraits);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45454: Make __gcov_flush visible outside a shared library

2018-04-11 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

The behavior will change if the shared libraries are not 'dlopen'ed but loaded 
at program startup time.


https://reviews.llvm.org/D45454



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


[PATCH] D45255: [CodeGen] Add an option to suppress output of llvm.ident

2018-04-11 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

What's your use-case for this?




Comment at: test/CodeGen/no-ident-version.c:4
+// CHECK-NOT: llvm.ident
+// CHECK-NOT: producer:
+int main(void) {}

You'll also want to check for something positive, otherwise this test will 
succeed even if clang is symlinked to /bin/true :-)


https://reviews.llvm.org/D45255



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


[PATCH] D45523: [CodeGen] Handle __func__ inside __finally

2018-04-11 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, thanks!




Comment at: test/CodeGen/exceptions-seh-finally.c:281
+// CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
+// CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], 
[18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i32 0, i32 0))
+

smeenai wrote:
> How stable is the mangling here? I included the complete `call` instruction 
> because I wanted to ensure that the value of `__func__` inside a `__finally` 
> block reflects the parent function, not the outlined funclet, and both the 
> `[18 x i8]` and the mangled string name are pretty good proxies for that. I 
> can generalize it more if it'll make the test more reliable though.
It's pretty stable.


Repository:
  rC Clang

https://reviews.llvm.org/D45523



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


[PATCH] D45526: [clang-format] Prefer breaking after ObjC category close paren

2018-04-11 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: djasper, jolesiak.
Herald added subscribers: cfe-commits, klimek.

Previously, `clang-format` would break Objective-C
category extensions after the opening parenthesis to avoid
breaking the protocol list:

  % echo "@interface c (ccc)  { }" | \
clang-format -assume-filename=foo.h -style="{BasedOnStyle: llvm, \
ColumnLimit: 40}"
  @interface c (
  ccc)  {
  }

This looks fairly odd, as we could have kept the category extension
on the previous line.

Category extensions are a single item, so they are generally very
short compared to protocol lists. We should prefer breaking after the
opening `<` of the protocol list over breaking after the opening `(`
of the category extension.

With this diff, we now prefer breaking after the category extension's
closing paren:

  % echo "@interface c (ccc)  { }" | \
./bin/clang-format -assume-filename=foo.h -style="{BasedOnStyle: llvm, \
ColumnLimit: 40}"
  @interface c (ccc) <
  c> {
  }

Test Plan: New test added. Confirmed test failed before diff and

  passed after diff by running:
  % make -j16 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D45526

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -334,6 +334,9 @@
"c, c,\n"
"c, c> {\n"
"}");
+  verifyFormat("@interface c (ccc) <\n"
+   "c> {\n"
+   "}");
   Style.ObjCBinPackProtocolList = FormatStyle::BPS_Never;
   verifyFormat("@interface d () <\n"
"d,\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2272,6 +2272,12 @@
   if (Left.is(tok::colon) && Left.is(TT_ObjCMethodExpr))
 return Line.MightBeFunctionDecl ? 50 : 500;
 
+  // In Objective-C type declarations, prefer breaking after the category's
+  // close paren instead of after the open paren.
+  if (Line.Type == LT_ObjCDecl && Left.is(tok::l_paren) && Left.Previous &&
+  Left.Previous->isOneOf(tok::identifier, tok::greater))
+return 500;
+
   if (Left.is(tok::l_paren) && InFunctionDecl &&
   Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign)
 return 100;


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -334,6 +334,9 @@
"c, c,\n"
"c, c> {\n"
"}");
+  verifyFormat("@interface c (ccc) <\n"
+   "c> {\n"
+   "}");
   Style.ObjCBinPackProtocolList = FormatStyle::BPS_Never;
   verifyFormat("@interface d () <\n"
"d,\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2272,6 +2272,12 @@
   if (Left.is(tok::colon) && Left.is(TT_ObjCMethodExpr))
 return Line.MightBeFunctionDecl ? 50 : 500;
 
+  // In Objective-C type declarations, prefer breaking after the category's
+  // close paren instead of after the open paren.
+  if (Line.Type == LT_ObjCDecl && Left.is(tok::l_paren) && Left.Previous &&
+  Left.Previous->isOneOf(tok::identifier, tok::greater))
+return 500;
+
   if (Left.is(tok::l_paren) && InFunctionDecl &&
   Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign)
 return 100;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r329827 - Document -std= values for different languages

2018-04-11 Thread Dimitry Andric via cfe-commits
Author: dim
Date: Wed Apr 11 10:21:52 2018
New Revision: 329827

URL: http://llvm.org/viewvc/llvm-project?rev=329827&view=rev
Log:
Document -std= values for different languages

Summary:
After a remark on a FreeBSD mailing list that the clang man page did
not have any list of possible values for the `-std=` flag, I have now
attempted to exhaustively list those, for each available language.

I also documented the default standard for each language, if there was
more than one choice.

Reviewers: rsmith, dexonsmith, sylvestre.ledru, mgorny

Reviewed By: rsmith

Subscribers: fhahn, emaste, cfe-commits, krytarowski

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

Modified:
cfe/trunk/docs/CommandGuide/clang.rst

Modified: cfe/trunk/docs/CommandGuide/clang.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/CommandGuide/clang.rst?rev=329827&r1=329826&r2=329827&view=diff
==
--- cfe/trunk/docs/CommandGuide/clang.rst (original)
+++ cfe/trunk/docs/CommandGuide/clang.rst Wed Apr 11 10:21:52 2018
@@ -98,10 +98,129 @@ Language Selection and Mode Options
 
  Treat subsequent input files as having type language.
 
-.. option:: -std=
+.. option:: -std=
 
  Specify the language standard to compile for.
 
+ Supported values for the C language are:
+
+  | ``c89``
+  | ``c90``
+  | ``iso9899:1990``
+
+   ISO C 1990
+
+  | ``iso9899:199409``
+
+   ISO C 1990 with amendment 1
+
+  | ``gnu89``
+  | ``gnu90``
+
+   ISO C 1990 with GNU extensions
+
+  | ``c99``
+  | ``iso9899:1999``
+
+   ISO C 1999
+
+  | ``gnu99``
+
+   ISO C 1999 with GNU extensions
+
+  | ``c11``
+  | ``iso9899:2011``
+
+   ISO C 2011
+
+  | ``gnu11``
+
+   ISO C 2011 with GNU extensions
+
+  | ``c17``
+  | ``iso9899:2017``
+
+   ISO C 2017
+
+  | ``gnu17``
+
+   ISO C 2017 with GNU extensions
+
+ The default C language standard is ``gnu11``, except on PS4, where it is
+ ``gnu99``.
+
+ Supported values for the C++ language are:
+
+  | ``c++98``
+  | ``c++03``
+
+   ISO C++ 1998 with amendments
+
+  | ``gnu++98``
+  | ``gnu++03``
+
+   ISO C++ 1998 with amendments and GNU extensions
+
+  | ``c++11``
+
+   ISO C++ 2011 with amendments
+
+  | ``gnu++11``
+
+ISO C++ 2011 with amendments and GNU extensions
+
+  | ``c++14``
+
+   ISO C++ 2014 with amendments
+
+  | ``gnu++14``
+
+   ISO C++ 2014 with amendments and GNU extensions
+
+  | ``c++17``
+
+   ISO C++ 2017 with amendments
+
+  | ``gnu++17``
+
+   ISO C++ 2017 with amendments and GNU extensions
+
+  | ``c++2a``
+
+   Working draft for ISO C++ 2020
+
+  | ``gnu++2a``
+
+   Working draft for ISO C++ 2020 with GNU extensions
+
+ The default C++ language standard is ``gnu++14``.
+
+ Supported values for the OpenCL language are:
+
+  | ``cl1.0``
+
+   OpenCL 1.0
+
+  | ``cl1.1``
+
+   OpenCL 1.1
+
+  | ``cl1.2``
+
+   OpenCL 1.2
+
+  | ``cl2.0``
+
+   OpenCL 2.0
+
+ The default OpenCL language standard is ``cl1.0``.
+
+ Supported values for the CUDA language are:
+
+  | ``cuda``
+
+   NVIDIA CUDA(tm)
+
 .. option:: -stdlib=
 
  Specify the C++ standard library to use; supported options are libstdc++ and


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


[PATCH] D45529: [CMake] Set the default ABI version for Fuchsia in CMake as well

2018-04-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: EricWF, beanz.
Herald added subscribers: cfe-commits, christof, mgorny.

This is neeeded since the CMake value is used for the SOVERSION.


Repository:
  rCXX libc++

https://reviews.llvm.org/D45529

Files:
  libcxx/CMakeLists.txt


Index: libcxx/CMakeLists.txt
===
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -97,7 +97,12 @@
 cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
 "Install libc++experimental.a" ON
 "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
-set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
+if (FUCHSIA)
+  set(ABI_VERSION_DEFAULT 2)
+else()
+  set(ABI_VERSION_DEFAULT 1)
+endif()
+set(LIBCXX_ABI_VERSION ${ABI_VERSION_DEFAULT} CACHE STRING "ABI version of 
libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
 option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the 
Itanium ABI.")
 option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the 
Microsoft ABI.")
@@ -619,7 +624,7 @@
 endif()
 
 # Configuration file flags 
=
-if (NOT LIBCXX_ABI_VERSION EQUAL "1")
+if (NOT LIBCXX_ABI_VERSION EQUAL ABI_VERSION_DEFAULT)
   config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
 endif()
 config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE)


Index: libcxx/CMakeLists.txt
===
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -97,7 +97,12 @@
 cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY
 "Install libc++experimental.a" ON
 "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF)
-set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
+if (FUCHSIA)
+  set(ABI_VERSION_DEFAULT 2)
+else()
+  set(ABI_VERSION_DEFAULT 1)
+endif()
+set(LIBCXX_ABI_VERSION ${ABI_VERSION_DEFAULT} CACHE STRING "ABI version of libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
 option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.")
 option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.")
@@ -619,7 +624,7 @@
 endif()
 
 # Configuration file flags =
-if (NOT LIBCXX_ABI_VERSION EQUAL "1")
+if (NOT LIBCXX_ABI_VERSION EQUAL ABI_VERSION_DEFAULT)
   config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION)
 endif()
 config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45406: Document -std= values for different languages

2018-04-11 Thread Dimitry Andric via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL329827: Document -std= values for different languages 
(authored by dim, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D45406?vs=141529&id=142042#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D45406

Files:
  cfe/trunk/docs/CommandGuide/clang.rst

Index: cfe/trunk/docs/CommandGuide/clang.rst
===
--- cfe/trunk/docs/CommandGuide/clang.rst
+++ cfe/trunk/docs/CommandGuide/clang.rst
@@ -98,10 +98,129 @@
 
  Treat subsequent input files as having type language.
 
-.. option:: -std=
+.. option:: -std=
 
  Specify the language standard to compile for.
 
+ Supported values for the C language are:
+
+  | ``c89``
+  | ``c90``
+  | ``iso9899:1990``
+
+   ISO C 1990
+
+  | ``iso9899:199409``
+
+   ISO C 1990 with amendment 1
+
+  | ``gnu89``
+  | ``gnu90``
+
+   ISO C 1990 with GNU extensions
+
+  | ``c99``
+  | ``iso9899:1999``
+
+   ISO C 1999
+
+  | ``gnu99``
+
+   ISO C 1999 with GNU extensions
+
+  | ``c11``
+  | ``iso9899:2011``
+
+   ISO C 2011
+
+  | ``gnu11``
+
+   ISO C 2011 with GNU extensions
+
+  | ``c17``
+  | ``iso9899:2017``
+
+   ISO C 2017
+
+  | ``gnu17``
+
+   ISO C 2017 with GNU extensions
+
+ The default C language standard is ``gnu11``, except on PS4, where it is
+ ``gnu99``.
+
+ Supported values for the C++ language are:
+
+  | ``c++98``
+  | ``c++03``
+
+   ISO C++ 1998 with amendments
+
+  | ``gnu++98``
+  | ``gnu++03``
+
+   ISO C++ 1998 with amendments and GNU extensions
+
+  | ``c++11``
+
+   ISO C++ 2011 with amendments
+
+  | ``gnu++11``
+
+ISO C++ 2011 with amendments and GNU extensions
+
+  | ``c++14``
+
+   ISO C++ 2014 with amendments
+
+  | ``gnu++14``
+
+   ISO C++ 2014 with amendments and GNU extensions
+
+  | ``c++17``
+
+   ISO C++ 2017 with amendments
+
+  | ``gnu++17``
+
+   ISO C++ 2017 with amendments and GNU extensions
+
+  | ``c++2a``
+
+   Working draft for ISO C++ 2020
+
+  | ``gnu++2a``
+
+   Working draft for ISO C++ 2020 with GNU extensions
+
+ The default C++ language standard is ``gnu++14``.
+
+ Supported values for the OpenCL language are:
+
+  | ``cl1.0``
+
+   OpenCL 1.0
+
+  | ``cl1.1``
+
+   OpenCL 1.1
+
+  | ``cl1.2``
+
+   OpenCL 1.2
+
+  | ``cl2.0``
+
+   OpenCL 2.0
+
+ The default OpenCL language standard is ``cl1.0``.
+
+ Supported values for the CUDA language are:
+
+  | ``cuda``
+
+   NVIDIA CUDA(tm)
+
 .. option:: -stdlib=
 
  Specify the C++ standard library to use; supported options are libstdc++ and
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >