[PATCH] D64123: Add clang-llvm-rename tool.

2019-07-09 Thread Rui Ueyama via Phabricator via cfe-commits
ruiu added a comment.

I wasn't aware that clang-tidy had a such feature. 
readability-identifier-naming rule doesn't seem to work for this purpose out of 
the box. That being said, in hindsight, maybe I should have written this as a 
patch to clang-tidy instead of a new tool (which should have saved my time!)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64123/new/

https://reviews.llvm.org/D64123



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


[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-07-09 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

Friendly ping.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943



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


[PATCH] D64375: [OpenMP][Docs] Provide implementation status details

2019-07-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Nice, thank you for working on this!

It would be also good to have a not OpenMP-5 specific, but an overview table - 
which OpenMP thingy was supported starting
with which Clang version, very much like https://clang.llvm.org/cxx_status.html 
/ https://libcxx.llvm.org/cxx1z_status.html,
i needed that a few times.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64375/new/

https://reviews.llvm.org/D64375



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


[PATCH] D64151: Enhance abseil-faster-strsplit-delimiter to handle other non-printable characters.

2019-07-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp:55
+
+  absl::StrSplit("ABC", R"(A)");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a 
string literal consisting of a single character; consider using the character 
overload [abseil-faster-strsplit-delimiter]

zhangxy988 wrote:
> lebedev.ri wrote:
> > Is there a negative test, `absl::StrSplit("ABC", R"(AA)");`?
> > Also what about wide chars? (the second assertion)
> I don't really know how to write a negative test like that.
> This check is only concerned with single character string literal and it 
> doesn't support wide char (since `StrSplit` doesn't).
What i'm asking is, those assertions are there just to say "look, i guarantee 
those invariants hold here",
or to say "oh no, we shouldn't have ever violated these invariants here"? The 
difference being, in former case,
there is some other error checking that prevents those assertions from 
triggering; in latter case there is not.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64151/new/

https://reviews.llvm.org/D64151



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


[PATCH] D64389: [NFC] [X86] Fix scan-build complaining

2019-07-09 Thread Pengfei Wang via Phabricator via cfe-commits
pengfei created this revision.
pengfei added reviewers: RKSimon, xiangzhangllvm, craig.topper.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Remove unused variable. This fixes bug:
https://bugs.llvm.org/show_bug.cgi?id=42526

Signed-off-by: pengfei 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64389

Files:
  clang/lib/CodeGen/CGBuiltin.cpp


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -11755,12 +11755,11 @@
 Value *Call = Builder.CreateCall(CGM.getIntrinsic(ID), {Ops[0], Ops[1]});
 Value *Result = Builder.CreateExtractValue(Call, 0);
 Result = EmitX86MaskedCompareResult(*this, Result, NumElts, nullptr);
-Value *Store = Builder.CreateDefaultAlignedStore(Result, Ops[2]);
+Builder.CreateDefaultAlignedStore(Result, Ops[2]);
 
 Result = Builder.CreateExtractValue(Call, 1);
 Result = EmitX86MaskedCompareResult(*this, Result, NumElts, nullptr);
-Store = Builder.CreateDefaultAlignedStore(Result, Ops[3]);
-return Store;
+return Builder.CreateDefaultAlignedStore(Result, Ops[3]);
   }
 
   case X86::BI__builtin_ia32_vpmultishiftqb128:


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -11755,12 +11755,11 @@
 Value *Call = Builder.CreateCall(CGM.getIntrinsic(ID), {Ops[0], Ops[1]});
 Value *Result = Builder.CreateExtractValue(Call, 0);
 Result = EmitX86MaskedCompareResult(*this, Result, NumElts, nullptr);
-Value *Store = Builder.CreateDefaultAlignedStore(Result, Ops[2]);
+Builder.CreateDefaultAlignedStore(Result, Ops[2]);
 
 Result = Builder.CreateExtractValue(Call, 1);
 Result = EmitX86MaskedCompareResult(*this, Result, NumElts, nullptr);
-Store = Builder.CreateDefaultAlignedStore(Result, Ops[3]);
-return Store;
+return Builder.CreateDefaultAlignedStore(Result, Ops[3]);
   }
 
   case X86::BI__builtin_ia32_vpmultishiftqb128:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64274: [analyzer] VirtualCallChecker overhaul.

2019-07-09 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D64274#1574118 , @NoQ wrote:

> Mmm, no, not really; it seems that if i introduce a checker dependency, i 
> also have to put the option onto the base checker, otherwise the checker name 
> wouldn't match when i do 
> `getCheckerBooleanOption(getChecker(), "PureOnly")`. 
> Which means that the option name will inevitably change. @Szelethus, do i 
> understand this correctly?


I don't think it would change, the only "problem" would be that the *checker 
object's* name would be `cplusplus.PureVirtualCall`. You can still however 
invoke `getChecker*Option` by passing the `optin.cplusplus.VirtualCall` name as 
the first argument, which you can retrieve through 
`CheckerManager::getCurrentCheckName` (?).

In D64274#1574086 , @NoQ wrote:

> Hmm, wait, i don't really break backwards compatibility. Fridays...




> Previously we have impure-checking when we enable the optin checker and 
> pureonly-checking when we disable the option.
> 
> I can easily bring back the option, only for the purposes of backwards 
> compatibility, so that it was turning off impure-checking.
> 
> In this case we'll still have impure-checking when we enable the optin 
> checker and pureonly-checking when we disable the option. The only difference 
> is that pureonly-checking is now going to be on by default.

I think we could just remove the option altogether. I'll take a second look on 
CodeCheckers side, but im reasonably sure we dont use it.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64274/new/

https://reviews.llvm.org/D64274



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


[PATCH] D64391: [CodeComplete] an option to suppress endings for header completion

2019-07-09 Thread Cai Rijun via Phabricator via cfe-commits
richard9404 created this revision.
richard9404 added reviewers: sammccall, ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous.
Herald added a project: clang.

Header completion in clang always apppends endings to the results, i.e. `/` for 
folders and `"` (or `>`) for files. But a language-neutral client (like many 
vim lsp plugins) does not know a subsequent completion is expected, while the 
auto-inserted `/` prevents the user from triggering one by manually typing a 
`/`. And `"`/`>` might collide with auto pair insertion in some clients.

  #include "f"
^ completion triggered here
 => folder/  <- client is not aware that another completion is expected
 => file.h"  <- '"' collides with the ending '"' inserted by the client

This commit adds an option to suppress the endings, and adds `/` as a 
completion trigger in clangd, which makes header completion more similar to 
object member completion. The downside is that clangd will not be able to 
distinguish folders from files when setting the completion item kinds.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64391

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/CodeCompleteOptions.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/included-files-endings.cpp

Index: clang/test/CodeCompletion/included-files-endings.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/included-files-endings.cpp
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t && mkdir %t && cp %s %t/main.cc && mkdir %t/foo && mkdir %t/sys
+// RUN: touch %t/foobar.h && touch %t/foo/bar.h && touch %t/sys/foosys.h
+
+// With endings.
+#include "foobar.h"
+// RUN: %clang -fsyntax-only -isystem %t/sys -Xclang -code-completion-at=%t/main.cc:5:13 %t/main.cc | FileCheck -check-prefix=CHECK-1 %s
+// CHECK-1: foo/
+// CHECK-1: foobar.h"
+
+// System headers with endings.
+#include 
+// RUN: %clang -fsyntax-only -isystem %t/sys -Xclang -code-completion-at=%t/main.cc:11:14 %t/main.cc | FileCheck -check-prefix=CHECK-2 %s
+// CHECK-2: sys.h>
+
+// Without endings.
+#include "foobar.h"
+// RUN: %clang -fsyntax-only -isystem %t/sys -Xclang -code-completion-at=%t/main.cc:16:13 -Xclang -no-code-completion-included-file-endings %t/main.cc | FileCheck -check-prefix=CHECK-3 %s
+// CHECK-3: foo
+// CHECK-3: foobar.h
+
+// System headers without endings.
+#include 
+// RUN: %clang -fsyntax-only -isystem %t/sys -Xclang -code-completion-at=%t/main.cc:22:14 -Xclang -no-code-completion-included-file-endings %t/main.cc | FileCheck -check-prefix=CHECK-4 %s
+// CHECK-4: sys.h
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -8655,7 +8655,8 @@
   auto AddCompletion = [&](StringRef Filename, bool IsDirectory) {
 SmallString<64> TypedChunk = Filename;
 // Directory completion is up to the slash, e.g. ' : '"');
+if (CodeCompleter->includedFileEndings())
+  TypedChunk.push_back(IsDirectory ? '/' : Angled ? '>' : '"');
 auto R = SeenResults.insert(TypedChunk);
 if (R.second) { // New completion
   const char *InternedTyped = Results.getAllocator().CopyString(TypedChunk);
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1809,6 +1809,8 @@
 = Args.hasArg(OPT_code_completion_brief_comments);
   Opts.CodeCompleteOpts.IncludeFixIts
 = Args.hasArg(OPT_code_completion_with_fixits);
+  Opts.CodeCompleteOpts.IncludedFileEndings
+= !Args.hasArg(OPT_no_code_completion_included_file_endings);
 
   Opts.OverrideRecordLayoutsFile
 = Args.getLastArgValue(OPT_foverride_record_layout_EQ);
Index: clang/include/clang/Sema/CodeCompleteOptions.h
===
--- clang/include/clang/Sema/CodeCompleteOptions.h
+++ clang/include/clang/Sema/CodeCompleteOptions.h
@@ -43,10 +43,14 @@
   /// on member access, etc.
   unsigned IncludeFixIts : 1;
 
+  /// Whether to include the '/', '"' and '>' endings when completing included
+  /// files.
+  unsigned IncludedFileEndings : 1;
+
   CodeCompleteOptions()
   : IncludeMacros(0), IncludeCodePatterns(0), IncludeGlobals(1),
-IncludeNamespaceLevelDecls(1), IncludeBriefComments(0),
-LoadExternal(1), IncludeFixIts(0) {}
+IncludeNames

r365445 - Add AlignConsecutiveMacros to the clang release notes

2019-07-09 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Tue Jul  9 01:45:55 2019
New Revision: 365445

URL: http://llvm.org/viewvc/llvm-project?rev=365445&view=rev
Log:
Add AlignConsecutiveMacros to the clang release notes

Modified:
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=365445&r1=365444&r2=365445&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Tue Jul  9 01:45:55 2019
@@ -188,6 +188,8 @@ clang-format
 - Add Microsoft coding style to encapsulate default C# formatting style
 - Added new option `PPDIS_BeforeHash` (in configuration: `BeforeHash`) to
   `IndentPPDirectives` which indents preprocessor directives before the hash.
+- Added new option `AlignConsecutiveMacros` to align the C/C++ preprocessor
+  macros of consecutive lines.
 
 libclang
 


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


[PATCH] D64391: [CodeComplete] an option to suppress endings for header completion

2019-07-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1088
+
+  if (Trigger == "/") { // trigger only on '#include.../'
+auto StartOfLine = Code->rfind('\n', *Offset);

i think instead of regex, it would be better to just perform a linear search to 
make sure line looks something like this(up to the Offset):
```{whitespaces}#{whitespaces}include{whitespaces}{",<}{not {",>}}```

IIRC, regex had a bad performance and we would like to trigger as quickly as 
possible. @sammccall might've more context about this one.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1090
+auto StartOfLine = Code->rfind('\n', *Offset);
+if (StartOfLine == llvm::StringRef::npos) {
+  StartOfLine = 0;

i suppose this if should only enclose the `StartOfLine = 0;` statement, not the 
rest?



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1092
+  StartOfLine = 0;
+  llvm::Regex IncPattern("^#[[:space:]]*include.*");
+  return IncPattern.match(

as i mentioned above, the line doesn't have to start with `#`, and we cannot 
expect arbitrary stuff after include, we must make sure current point is inside 
quotes(") or brackets(<)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64391/new/

https://reviews.llvm.org/D64391



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


[PATCH] D64278: Rename libclang_shared to libclang-cpp

2019-07-09 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@beanz works for you?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64278/new/

https://reviews.llvm.org/D64278



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


[PATCH] D64392: CodeGen: Use memset for bytewise values with any size

2019-07-09 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
vitalybuka added reviewers: eugenis, pcc, jfb.
Herald added subscribers: cfe-commits, dexonsmith, javed.absar.
Herald added a project: clang.

It was already done for zeros, now we support any bytes


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64392

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/test/CodeGen/arm-swiftcall.c
  clang/test/CodeGen/dump-struct-builtin.c
  clang/test/CodeGen/init-memset.c
  clang/test/CodeGen/windows-swiftcall.c
  clang/test/CodeGenCXX/auto-var-init.cpp
  clang/test/CodeGenCXX/references.cpp

Index: clang/test/CodeGenCXX/references.cpp
===
--- clang/test/CodeGenCXX/references.cpp
+++ clang/test/CodeGenCXX/references.cpp
@@ -281,7 +281,7 @@
   struct a { int a : 10, b : 10; };
   // CHECK-LABEL: define void @_ZN6PR95651fEv()
   void f() {
-// CHECK: call void @llvm.memcpy
+// CHECK: call void @llvm.memset
 a x = { 0, 0 };
 // CHECK: [[WITH_SEVENTEEN:%[.a-zA-Z0-9]+]] = or i32 [[WITHOUT_SEVENTEEN:%[.a-zA-Z0-9]+]], 17
 // CHECK: store i32 [[WITH_SEVENTEEN]], i32* [[XA:%[.a-zA-Z0-9]+]]
Index: clang/test/CodeGenCXX/auto-var-init.cpp
===
--- clang/test/CodeGenCXX/auto-var-init.cpp
+++ clang/test/CodeGenCXX/auto-var-init.cpp
@@ -34,193 +34,64 @@
 // PATTERN-NOT: undef
 // ZERO-NOT: undef
 
-// PATTERN-O0: @__const.test_empty_uninit.uninit = private unnamed_addr constant %struct.empty { i8 -86 }, align 1
-// PATTERN-O1-NOT: @__const.test_empty_uninit.uninit
 struct empty {};
-// PATTERN-O0: @__const.test_small_uninit.uninit = private unnamed_addr constant %struct.small { i8 -86 }, align 1
-// PATTERN-O0: @__const.test_small_custom.custom = private unnamed_addr constant %struct.small { i8 42 }, align 1
-// ZERO-O0: @__const.test_small_custom.custom = private unnamed_addr constant %struct.small { i8 42 }, align 1
-// PATTERN-O1-NOT: @__const.test_small_uninit.uninit
-// PATTERN-O1-NOT: @__const.test_small_custom.custom
-// ZERO-O1-NOT: @__const.test_small_custom.custom
 struct small { char c; };
-// PATTERN-O0: @__const.test_smallinit_uninit.uninit = private unnamed_addr constant %struct.smallinit { i8 -86 }, align 1
-// PATTERN-O0: @__const.test_smallinit_braces.braces = private unnamed_addr constant %struct.smallinit { i8 -86 }, align 1
-// PATTERN-O0: @__const.test_smallinit_custom.custom = private unnamed_addr constant %struct.smallinit { i8 -86 }, align 1
-// PATTERN-O1-NOT: @__const.test_smallinit_uninit.uninit
-// PATTERN-O1-NOT: @__const.test_smallinit_braces.braces
-// PATTERN-O1-NOT: @__const.test_smallinit_custom.custom
 struct smallinit { char c = 42; };
-// PATTERN-O0: @__const.test_smallpartinit_uninit.uninit = private unnamed_addr constant %struct.smallpartinit { i8 -86, i8 -86 }, align 1
-// PATTERN-O0: @__const.test_smallpartinit_braces.braces = private unnamed_addr constant %struct.smallpartinit { i8 -86, i8 -86 }, align 1
-// PATTERN-O0: @__const.test_smallpartinit_custom.custom = private unnamed_addr constant %struct.smallpartinit { i8 -86, i8 -86 }, align 1
-// PATTERN-O1-NOT: @__const.test_smallpartinit_uninit.uninit
-// PATTERN-O1-NOT: @__const.test_smallpartinit_braces.braces
-// PATTERN-O1-NOT: @__const.test_smallpartinit_custom.custom
 struct smallpartinit { char c = 42, d; };
-// PATTERN-O0: @__const.test_nullinit_uninit.uninit = private unnamed_addr constant %struct.nullinit { i8* inttoptr (i64 -6148914691236517206 to i8*) }, align 8
-// PATTERN-O0: @__const.test_nullinit_braces.braces = private unnamed_addr constant %struct.nullinit { i8* inttoptr (i64 -6148914691236517206 to i8*) }, align 8
-// PATTERN-O0: @__const.test_nullinit_custom.custom = private unnamed_addr constant %struct.nullinit { i8* inttoptr (i64 -6148914691236517206 to i8*) }, align 8
-// PATTERN-O1-NOT: @__const.test_nullinit_uninit.uninit
-// PATTERN-O1-NOT: @__const.test_nullinit_braces.braces
-// PATTERN-O1-NOT: @__const.test_nullinit_custom.custom
 struct nullinit { char* null = nullptr; };
-// PATTERN-O0: @__const.test_padded_uninit.uninit = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 -86, [3 x i8] c"\AA\AA\AA", i32 -1431655766 }, align 4
 // PATTERN-O0: @__const.test_padded_custom.custom = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 42, [3 x i8] zeroinitializer, i32 13371337 }, align 4
 // ZERO-O0: @__const.test_padded_custom.custom = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 42, [3 x i8] zeroinitializer, i32 13371337 }, align 4
-// PATTERN-O1-NOT: @__const.test_padded_uninit.uninit
-// PATTERN-O1-NOT: @__const.test_padded_custom.custom
-// ZERO-O1-NOT: @__const.test_padded_custom.custom
 struct padded { char c; int i; };
-// PATTERN-O0: @__const.test_paddednullinit_uninit.uninit = private unnamed_addr constant { i8, [3 x i8], i32 } { i8 -86, [3 x i8] c"\AA\AA\AA", i32 -1431655766 }, align 4
-// PATTERN-O0: @__const.test_paddednullinit_braces.brac

r365446 - Remove trailing whitespaces in the Language Extensions doc

2019-07-09 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Tue Jul  9 01:50:17 2019
New Revision: 365446

URL: http://llvm.org/viewvc/llvm-project?rev=365446&view=rev
Log:
Remove trailing whitespaces in the Language Extensions doc

Modified:
cfe/trunk/docs/LanguageExtensions.rst

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=365446&r1=365445&r2=365446&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Tue Jul  9 01:50:17 2019
@@ -330,11 +330,11 @@ Builtin Macros
 ``__BASE_FILE__``
   Defined to a string that contains the name of the main input file passed to
   Clang.
-  
+
 ``__FILE_NAME__``
   Clang-specific extension that functions similar to ``__FILE__`` but only
   renders the last path component (the filename) instead of an invocation
-  dependent full path to that file. 
+  dependent full path to that file.
 
 ``__COUNTER__``
   Defined to an integer value that starts at zero and is incremented each time
@@ -1372,7 +1372,7 @@ Objective-C retaining behavior attribute
 -
 
 In Objective-C, functions and methods are generally assumed to follow the
-`Cocoa Memory Management 
+`Cocoa Memory Management
 
`_
 conventions for ownership of object arguments and
 return values. However, there are exceptions, and so Clang provides attributes
@@ -1789,7 +1789,7 @@ the bitpattern of an integer value; for
 **Description**:
 
 The '``__builtin_rotateleft``' family of builtins is used to rotate
-the bits in the first argument by the amount in the second argument. 
+the bits in the first argument by the amount in the second argument.
 For example, ``0b1110`` rotated left by 11 becomes ``0b00110100``.
 The shift value is treated as an unsigned amount modulo the size of
 the arguments. Both arguments and the result have the bitwidth specified
@@ -1821,7 +1821,7 @@ by the name of the builtin.
 **Description**:
 
 The '``__builtin_rotateright``' family of builtins is used to rotate
-the bits in the first argument by the amount in the second argument. 
+the bits in the first argument by the amount in the second argument.
 For example, ``0b1110`` rotated right by 3 becomes ``0b1101``.
 The shift value is treated as an unsigned amount modulo the size of
 the arguments. Both arguments and the result have the bitwidth specified
@@ -2143,8 +2143,8 @@ Atomic Min/Max builtins with memory orde
 There are two atomic builtins with min/max in-memory comparison and swap.
 The syntax and semantics are similar to GCC-compatible __atomic_* builtins.
 
-* ``__atomic_fetch_min`` 
-* ``__atomic_fetch_max`` 
+* ``__atomic_fetch_min``
+* ``__atomic_fetch_max``
 
 The builtins work with signed and unsigned integers and require to specify 
memory ordering.
 The return value is the original value that was stored in memory before 
comparison.
@@ -2262,7 +2262,7 @@ C++ Coroutines support builtins
 
 
 .. warning::
-  This is a work in progress. Compatibility across Clang/LLVM releases is not 
+  This is a work in progress. Compatibility across Clang/LLVM releases is not
   guaranteed.
 
 Clang provides experimental builtins to support C++ Coroutines as defined by
@@ -2310,7 +2310,7 @@ Other coroutine builtins are either for
 development of the coroutine feature. See `Coroutines in LLVM
 `_ for
 more information on their semantics. Note that builtins matching the intrinsics
-that take token as the first parameter (llvm.coro.begin, llvm.coro.alloc, 
+that take token as the first parameter (llvm.coro.begin, llvm.coro.alloc,
 llvm.coro.free and llvm.coro.suspend) omit the token parameter and fill it to
 an appropriate value during the emission.
 
@@ -2485,8 +2485,8 @@ The effective values for mode are:
 - 2 - round to +infinity
 - 3 - round to -infinity
 
-Note that the mode argument will modulo 4, so if the int argument is greater 
-than 3, it will only use the least significant two bits of the mode. 
+Note that the mode argument will modulo 4, so if the int argument is greater
+than 3, it will only use the least significant two bits of the mode.
 Namely, ``__builtin_setrnd(102))`` is equal to ``__builtin_setrnd(2)``.
 
 PowerPC Language Extensions
@@ -2510,7 +2510,7 @@ The effective values for mode are:
 - 3 - round to -infinity
 
 Note that the mode argument will modulo 4, so if the integer argument is 
greater
-than 3, it will only use the least significant two bits of the mode. 
+than 3, it will only use the least significant two bits of the mode.
 Namely, ``__builtin_setrnd(102))`` is equal to ``__builtin_setrnd(2)``.
 
 PowerPC Language Extensions
@@ -2534,7 +2534,7 @@ The effective values for mode are:
 - 3

[PATCH] D64374: [analyzer] CastValueChecker: Model casts

2019-07-09 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:279
+  HelpText<"Model implementation of custom RTTIs">,
+  Documentation;
+

This checker only does modeling, but isn't hidden. Should we hide it?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64374/new/

https://reviews.llvm.org/D64374



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


[PATCH] D64294: [Driver] Consolidate shouldUseFramePointer() and shouldUseLeafFramePointer()

2019-07-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208615.
MaskRay edited the summary of this revision.
MaskRay added a comment.

Implement the GCC behavior:

  -fomit-frame-pointer wins over -mno-omit-leaf-frame-pointer
  -fno-omit-frame-pointer loses out to -momit-leaf-frame-pointer


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64294/new/

https://reviews.llvm.org/D64294

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cl-options.c
  test/Driver/clang_f_opts.c
  test/Driver/frame-pointer-elim.c
  test/Driver/xcore-opts.c

Index: test/Driver/xcore-opts.c
===
--- test/Driver/xcore-opts.c
+++ test/Driver/xcore-opts.c
@@ -4,8 +4,8 @@
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
 // CHECK: "-nostdsysteminc"
-// CHECK: "-momit-leaf-frame-pointer"
 // CHECK-NOT: "-mdisable-fp-elim"
+// CHECK-NOT: "-momit-leaf-frame-pointer"
 // CHECK: "-fno-signed-char"
 // CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
Index: test/Driver/frame-pointer-elim.c
===
--- test/Driver/frame-pointer-elim.c
+++ test/Driver/frame-pointer-elim.c
@@ -1,48 +1,72 @@
-// For these next two tests when optimized we should omit the leaf frame
-// pointer, for unoptimized we should have a leaf frame pointer.
-// RUN: %clang -### -target i386-pc-linux-gnu -S -O1 %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=LINUX-OPT %s
-// LINUX-OPT: "-momit-leaf-frame-pointer"
-
-// RUN: %clang -### -target i386-pc-linux-gnu -S %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=LINUX %s
-// LINUX-NOT: "-momit-leaf-frame-pointer"
+// KEEP-ALL: "-mdisable-fp-elim"
+// KEEP-ALL-NOT: "-momit-leaf-frame-pointer"
+
+// KEEP-NON-LEAF: "-mdisable-fp-elim"
+// KEEP-NON-LEAF: "-momit-leaf-frame-pointer"
+
+// KEEP-NONE-NOT: "-mdisable-fp-elim"
+// KEEP-NONE-NOT: "-momit-leaf-frame-pointer"
+
+// On Linux x86, omit frame pointer when optimization is enabled.
+// RUN: %clang -### -target i386-linux -S -fomit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+// RUN: %clang -### -target i386-linux -S -O1 %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+
+// -fno-omit-frame-pointer or -pg disables frame pointer omission.
+// RUN: %clang -### -target i386-linux -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+// RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+// RUN: %clang -### -target i386-linux -S -O1 -pg %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+
+// -momit-leaf-frame-pointer omits leaf frame pointer.
+// -fno-omit-frame-pointer loses out to -momit-leaf-frame-pointer.
+// RUN: %clang -### -target i386 -S -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+
+// Explicit or default -fomit-frame-pointer wins over -mno-omit-leaf-frame-pointer.
+// RUN: %clang -### -target i386 -S %s -fomit-frame-pointer -mno-omit-leaf-frame-pointer 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+// RUN: %clang -### -target i386-linux -S %s -O1 -mno-omit-leaf-frame-pointer 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+
+// -pg -fomit-frame-pointer => error.
+// RUN: %clang -### -S -fomit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-OMIT-FP-PG %s
+// RUN: %clang -### -S -fomit-frame-pointer -fno-omit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-MIX-NO-OMIT-FP-PG %s
+// CHECK-NO-MIX-OMIT-FP-PG: '-fomit-frame-pointer' not allowed with '-pg'
+// CHECK-MIX-NO-OMIT-FP-PG-NOT: '-fomit-frame-pointer' not allowed with '-pg'
 
 // CloudABI follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-cloudabi -S -O1 %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=CLOUDABI-OPT %s
-// CLOUDABI-OPT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
 
 // RUN: %clang -### -target x86_64-unknown-cloudabi -S %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=CLOUDABI %s
-// CLOUDABI-NOT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
 
 // NetBSD follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-netbsd -S -O1 %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=NETBSD-OPT %s
-// NETBSD-OPT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
 
 // RUN: %clang -### -target x86_64-unknown-netbsd -S %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=NETBSD %s
-// NETBSD-NOT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
 
 // Darwin disables omitting the leaf frame pointer even under optimization
 // unless the command lines are given.
 // RUN: %clang -

[PATCH] D64257: [clangd] Added highlighting for non-builtin types

2019-07-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

could you please also update the patch description? "non-builtin" types are not 
precise, this patch only highlights the class and enum types.




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:71
+
+TagDecl *D = TL.getTypePtr()->getAsTagDecl();
+if (!D)

nit: you could simplify the code like 

```
if (const auto* D = TL.getXXX)
  addToken(D->getLocation(), D);
return true;
```



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:81
   void addToken(SourceLocation Loc, const Decl *D) {
+if (isa(D)) {
+  addToken(Loc, HighlightingKind::Class);

nit: move this around `if (isa(D)) {` since they are related to 
`Class`, and we should have a comment describing the highlighting behavior of 
`class, constructor, and destructor`.



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:87
+  typedef abc::$Class[[A]] AAA;
+  enum class $Enum[[E]] {};
+  enum $Enum[[EE]] {};

could we split the enum case into a separate testcase? 

Thinking it further, we may want to highlight the enumerator as well.



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:101
+R"cpp(
+  struct $Class[[A]] {
+$Class[[A]]();

this test case can be merged into the above case (we could add 
constructor/destructor to class B there)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64257/new/

https://reviews.llvm.org/D64257



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


[PATCH] D64294: [Driver] Consolidate shouldUseFramePointer() and shouldUseLeafFramePointer()

2019-07-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208616.
MaskRay added a comment.

Simplify and add another test


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64294/new/

https://reviews.llvm.org/D64294

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cl-options.c
  test/Driver/clang_f_opts.c
  test/Driver/frame-pointer-elim.c
  test/Driver/xcore-opts.c

Index: test/Driver/xcore-opts.c
===
--- test/Driver/xcore-opts.c
+++ test/Driver/xcore-opts.c
@@ -4,8 +4,8 @@
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
 // CHECK: "-nostdsysteminc"
-// CHECK: "-momit-leaf-frame-pointer"
 // CHECK-NOT: "-mdisable-fp-elim"
+// CHECK-NOT: "-momit-leaf-frame-pointer"
 // CHECK: "-fno-signed-char"
 // CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
Index: test/Driver/frame-pointer-elim.c
===
--- test/Driver/frame-pointer-elim.c
+++ test/Driver/frame-pointer-elim.c
@@ -1,48 +1,74 @@
-// For these next two tests when optimized we should omit the leaf frame
-// pointer, for unoptimized we should have a leaf frame pointer.
-// RUN: %clang -### -target i386-pc-linux-gnu -S -O1 %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=LINUX-OPT %s
-// LINUX-OPT: "-momit-leaf-frame-pointer"
-
-// RUN: %clang -### -target i386-pc-linux-gnu -S %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=LINUX %s
-// LINUX-NOT: "-momit-leaf-frame-pointer"
+// KEEP-ALL: "-mdisable-fp-elim"
+// KEEP-ALL-NOT: "-momit-leaf-frame-pointer"
+
+// KEEP-NON-LEAF: "-mdisable-fp-elim"
+// KEEP-NON-LEAF: "-momit-leaf-frame-pointer"
+
+// KEEP-NONE-NOT: "-mdisable-fp-elim"
+// KEEP-NONE-NOT: "-momit-leaf-frame-pointer"
+
+// On Linux x86, omit frame pointer when optimization is enabled.
+// RUN: %clang -### -target i386-linux -S -fomit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+// RUN: %clang -### -target i386-linux -S -O1 %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+
+// -fno-omit-frame-pointer or -pg disables frame pointer omission.
+// RUN: %clang -### -target i386-linux -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+// RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+// RUN: %clang -### -target i386-linux -S -O1 -pg %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+
+// -momit-leaf-frame-pointer omits leaf frame pointer.
+// -fno-omit-frame-pointer loses out to -momit-leaf-frame-pointer.
+// RUN: %clang -### -target i386 -S -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target i386-linux -S -O1 -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+
+// Explicit or default -fomit-frame-pointer wins over -mno-omit-leaf-frame-pointer.
+// RUN: %clang -### -target i386 -S %s -fomit-frame-pointer -mno-omit-leaf-frame-pointer 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+// RUN: %clang -### -target i386-linux -S %s -O1 -mno-omit-leaf-frame-pointer 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+
+// -pg -fomit-frame-pointer => error.
+// RUN: %clang -### -S -fomit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-OMIT-FP-PG %s
+// RUN: %clang -### -S -fomit-frame-pointer -fno-omit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-MIX-NO-OMIT-FP-PG %s
+// CHECK-NO-MIX-OMIT-FP-PG: '-fomit-frame-pointer' not allowed with '-pg'
+// CHECK-MIX-NO-OMIT-FP-PG-NOT: '-fomit-frame-pointer' not allowed with '-pg'
 
 // CloudABI follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-cloudabi -S -O1 %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=CLOUDABI-OPT %s
-// CLOUDABI-OPT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
 
 // RUN: %clang -### -target x86_64-unknown-cloudabi -S %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=CLOUDABI %s
-// CLOUDABI-NOT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
 
 // NetBSD follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-netbsd -S -O1 %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=NETBSD-OPT %s
-// NETBSD-OPT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
 
 // RUN: %clang -### -target x86_64-unknown-netbsd -S %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=NETBSD %s
-// NETBSD-NOT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
 
 // Darwin disables omitting the leaf frame pointer even under optimization
 // unless the command lines are given.
 // RUN: %clang -### -target i386-apple-darwin -S %s 2

[PATCH] D64382: Use getMostFrequentByte to decide if should used memset+stores

2019-07-09 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 208617.
vitalybuka added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64382/new/

https://reviews.llvm.org/D64382

Files:
  clang/lib/CodeGen/CGDecl.cpp

Index: clang/lib/CodeGen/CGDecl.cpp
===
--- clang/lib/CodeGen/CGDecl.cpp
+++ clang/lib/CodeGen/CGDecl.cpp
@@ -860,118 +860,138 @@
   EmitStoreOfScalar(value, lvalue, /* isInitialization */ true);
 }
 
-/// Decide whether we can emit the non-zero parts of the specified initializer
-/// with equal or fewer than NumStores scalar stores.
-static bool canEmitInitWithFewStoresAfterBZero(llvm::Constant *Init,
-   unsigned &NumStores) {
-  // Zero and Undef never requires any extra stores.
-  if (isa(Init) ||
-  isa(Init) ||
-  isa(Init))
+/// Decide whether we can emit the non-pattern parts of the specified
+/// initializer with equal or fewer than NumStores scalar stores.
+static bool canEmitStoresForInitAfterMemset(CodeGenModule &CGM,
+llvm::Constant *Init,
+llvm::Value *Pattern,
+unsigned &NumStores) {
+  assert(Pattern);
+  llvm::Value *BWInit = isBytewiseValue(Init, CGM.getDataLayout());
+  if (BWInit && (BWInit == Pattern || isa(BWInit)))
 return true;
-  if (isa(Init) || isa(Init) ||
+  if (BWInit || isa(Init) || isa(Init) ||
   isa(Init) || isa(Init) ||
-  isa(Init))
-return Init->isNullValue() || NumStores--;
-
-  // See if we can emit each element.
-  if (isa(Init) || isa(Init)) {
-for (unsigned i = 0, e = Init->getNumOperands(); i != e; ++i) {
-  llvm::Constant *Elt = cast(Init->getOperand(i));
-  if (!canEmitInitWithFewStoresAfterBZero(Elt, NumStores))
-return false;
-}
-return true;
+  isa(Init) || isa(Init)) {
+// Single store or memset.
+return NumStores--;
   }
 
   if (llvm::ConstantDataSequential *CDS =
-dyn_cast(Init)) {
+  dyn_cast(Init)) {
 for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
   llvm::Constant *Elt = CDS->getElementAsConstant(i);
-  if (!canEmitInitWithFewStoresAfterBZero(Elt, NumStores))
+  if (!canEmitStoresForInitAfterMemset(CGM, Elt, Pattern, NumStores))
 return false;
 }
 return true;
   }
 
+  for (unsigned i = 0, e = Init->getNumOperands(); i != e; ++i) {
+llvm::Constant *Elt = cast(Init->getOperand(i));
+if (!canEmitStoresForInitAfterMemset(CGM, Elt, Pattern, NumStores))
+  return false;
+return true;
+  }
+
   // Anything else is hard and scary.
   return false;
 }
 
-/// For inits that canEmitInitWithFewStoresAfterBZero returned true for, emit
+/// For inits that canEmitStoresForInitAfterMemset returned true for, emit
 /// the scalar stores that would be required.
-static void emitStoresForInitAfterBZero(CodeGenModule &CGM,
-llvm::Constant *Init, Address Loc,
-bool isVolatile, CGBuilderTy &Builder) {
-  assert(!Init->isNullValue() && !isa(Init) &&
- "called emitStoresForInitAfterBZero for zero or undef value.");
-
+static void emitStoresForInitAfterMemset(CodeGenModule &CGM,
+ llvm::Constant *Init,
+ Address ParentLoc, int IdxInParent,
+ llvm::Value *Pattern, bool isVolatile,
+ CGBuilderTy &Builder) {
+  assert(Pattern);
+  llvm::Value *BWInit = isBytewiseValue(Init, CGM.getDataLayout());
+  if (BWInit && (BWInit == Pattern || isa(BWInit)))
+return;
+  Address Loc =
+  IdxInParent < 0
+  ? Builder.CreateElementBitCast(ParentLoc, Init->getType())
+  : Builder.CreateConstInBoundsGEP2_32(ParentLoc, 0, IdxInParent);
   if (isa(Init) || isa(Init) ||
   isa(Init) || isa(Init) ||
-  isa(Init)) {
+  isa(Init) || isa(Init)) {
 Builder.CreateStore(Init, Loc, isVolatile);
 return;
   }
 
+  if (BWInit) {
+auto *SizeVal = llvm::ConstantInt::get(
+CGM.IntPtrTy, CGM.getDataLayout().getTypeStoreSize(Init->getType()));
+Builder.CreateMemSet(Loc, BWInit, SizeVal, isVolatile);
+return;
+  }
+
   if (llvm::ConstantDataSequential *CDS =
   dyn_cast(Init)) {
 for (unsigned i = 0, e = CDS->getNumElements(); i != e; ++i) {
   llvm::Constant *Elt = CDS->getElementAsConstant(i);
-
-  // If necessary, get a pointer to the element and emit it.
-  if (!Elt->isNullValue() && !isa(Elt))
-emitStoresForInitAfterBZero(
-CGM, Elt, Builder.CreateConstInBoundsGEP2_32(Loc, 0, i), isVolatile,
-Builder);
+  emitStoresForInitAfterMemset(CGM, Elt, Loc, i, Pattern, isVolatile,
+   

[PATCH] D64257: [clangd] Added highlighting for non-builtin types

2019-07-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:87
+  typedef abc::$Class[[A]] AAA;
+  enum class $Enum[[E]] {};
+  enum $Enum[[EE]] {};

hokein wrote:
> could we split the enum case into a separate testcase? 
> 
> Thinking it further, we may want to highlight the enumerator as well.
(please don't add enum value highlighting in this patch, though)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64257/new/

https://reviews.llvm.org/D64257



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


[PATCH] D64062: Remove both -dumpversion and __VERSION__

2019-07-09 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 208619.
sylvestre.ledru added a comment.

Update of the release note.
thanks to @rnk for the suggestion


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64062/new/

https://reviews.llvm.org/D64062

Files:
  docs/ClangCommandLineReference.rst
  docs/LanguageExtensions.rst
  docs/ReleaseNotes.rst
  include/clang/Driver/Options.td
  lib/Basic/Version.cpp
  lib/Driver/Driver.cpp
  lib/Frontend/InitPreprocessor.cpp
  test/Driver/immediate-options.c
  test/Index/complete-exprs.c
  test/Preprocessor/init.c
  utils/builtin-defines.c

Index: utils/builtin-defines.c
===
--- utils/builtin-defines.c
+++ utils/builtin-defines.c
@@ -49,7 +49,6 @@
 #undef __INT8_TYPE__
 #undef __SSP__
 #undef __APPLE_CC__
-#undef __VERSION__
 #undef __clang__
 #undef __llvm__
 #undef __nocona
Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -101,7 +101,6 @@
 // COMMON:#define __ORDER_PDP_ENDIAN__ 3412
 // COMMON:#define __STDC_HOSTED__ 1
 // COMMON:#define __STDC__ 1
-// COMMON:#define __VERSION__ {{.*}}
 // COMMON:#define __clang__ 1
 // COMMON:#define __clang_major__ {{[0-9]+}}
 // COMMON:#define __clang_minor__ {{[0-9]+}}
@@ -8169,7 +8168,6 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__
-// SPARC:#define __VERSION__ "4.2.1 Compatible{{.*}}
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32
@@ -9041,7 +9039,6 @@
 // X86_64-CLOUDABI:#define __UINT_LEAST8_MAX__ 255
 // X86_64-CLOUDABI:#define __UINT_LEAST8_TYPE__ unsigned char
 // X86_64-CLOUDABI:#define __USER_LABEL_PREFIX__
-// X86_64-CLOUDABI:#define __VERSION__ "4.2.1 Compatible{{.*}}
 // X86_64-CLOUDABI:#define __WCHAR_MAX__ 2147483647
 // X86_64-CLOUDABI:#define __WCHAR_TYPE__ int
 // X86_64-CLOUDABI:#define __WCHAR_WIDTH__ 32
@@ -10043,7 +10040,6 @@
 // WEBASSEMBLY-NEXT:#define __UINT_LEAST8_MAX__ 255
 // WEBASSEMBLY-NEXT:#define __UINT_LEAST8_TYPE__ unsigned char
 // WEBASSEMBLY-NEXT:#define __USER_LABEL_PREFIX__
-// WEBASSEMBLY-NEXT:#define __VERSION__ "{{.*}}"
 // WEBASSEMBLY-NEXT:#define __WCHAR_MAX__ 2147483647
 // WEBASSEMBLY-NEXT:#define __WCHAR_TYPE__ int
 // WEBASSEMBLY-NOT:#define __WCHAR_UNSIGNED__
Index: test/Index/complete-exprs.c
===
--- test/Index/complete-exprs.c
+++ test/Index/complete-exprs.c
@@ -27,7 +27,6 @@
 // RUN: c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:7:10 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // CHECK-CC1: NotImplemented:{TypedText __PRETTY_FUNCTION__} (65)
-// CHECK-CC1: macro definition:{TypedText __VERSION__} (70)
 // CHECK-CC1: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (12) (unavailable)
 // CHECK-CC1-NOT: NotImplemented:{TypedText float} (65)
 // CHECK-CC1: ParmDecl:{ResultType int}{TypedText j} (8)
@@ -39,7 +38,6 @@
 // RUN: c-index-test -code-completion-at=%s:7:18 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: c-index-test -code-completion-at=%s:7:22 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s
 // RUN: c-index-test -code-completion-at=%s:7:2 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC2 %s
-// CHECK-CC2: macro definition:{TypedText __VERSION__} (70)
 // CHECK-CC2: FunctionDecl:{ResultType int}{TypedText f}{LeftParen (}{Placeholder int}{RightParen )} (50)
 // CHECK-CC2: NotImplemented:{TypedText float} (50)
 // CHECK-CC2: ParmDecl:{ResultType int}{TypedText j} (34)
Index: test/Driver/immediate-options.c
===
--- test/Driver/immediate-options.c
+++ test/Driver/immediate-options.c
@@ -6,9 +6,6 @@
 // RUN: %clang --help-hidden | FileCheck %s -check-prefix=HELP-HIDDEN
 // HELP-HIDDEN: driver-mode
 
-// RUN: %clang -dumpversion | FileCheck %s -check-prefix=DUMPVERSION
-// DUMPVERSION: {{[0-9]+\.[0-9.]+}}
-
 // RUN: %clang -print-search-dirs | FileCheck %s -check-prefix=PRINT-SEARCH-DIRS
 // PRINT-SEARCH-DIRS: programs: ={{.*}}
 // PRINT-SEARCH-DIRS: libraries: ={{.*}}
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -604,12 +604,6 @@
   // Support for #pragma redefine_extname (Sun compatibility)
   Builder.defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1");
 
-  // As sad as it is, enough software depends on the __VERSION__ for version
-  // c

[PATCH] D64382: Use getMostFrequentByte to decide if should used memset+stores

2019-07-09 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka marked 4 inline comments as done.
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:865
+/// initializer with equal or fewer than NumStores scalar stores.
+static bool canEmitStoresForInitAfterMemset(CodeGenModule &CGM,
+llvm::Constant *Init,

jfb wrote:
> You should update the return value to `Optional` where the non-`None` 
> return is the bytewise value.
Why?
We already know value which was used for memset, now we just counting 
additional store/memsets




Comment at: clang/lib/CodeGen/CGDecl.cpp:873
 return true;
-  if (isa(Init) || isa(Init) ||
+  if (BWInit || isa(Init) || isa(Init) ||
   isa(Init) || isa(Init) ||

jfb wrote:
> I'm not sure I understand what this bit does. If something isn't a bytewise 
> value then we now automatically assume it can be stored to with a single 
> store. That's not necessarily true. I think you need to drop `BWInit ||` from 
> here, and conditionalize this entire branch with `if (BWInit)` instead (so, 
> an `&&` on it all).
If value is bytewise, we will emit BWInit



Comment at: clang/lib/CodeGen/CGDecl.cpp:888
 return true;
   }
 

jfb wrote:
> The recursion now allows different values for `BWInit` on each sub-element.
yes



Comment at: clang/lib/CodeGen/CGDecl.cpp:895
+return true;
+  }
+

jfb wrote:
> What does this new loop do? It'll only ever go around the loop once.
it counts number of stores used by elements
similar look we had in canEmitInitWithFewStoresAfterBZero



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64382/new/

https://reviews.llvm.org/D64382



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


[PATCH] D64257: [clangd] Added highlighting for non-builtin types

2019-07-09 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 208621.
jvikstrom marked 5 inline comments as done.
jvikstrom added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64257/new/

https://reviews.llvm.org/D64257

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -34,11 +34,13 @@
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
-  {HighlightingKind::Function, "Function"}};
+  {HighlightingKind::Function, "Function"},
+  {HighlightingKind::Class, "Class"},
+  {HighlightingKind::Enum, "Enum"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
-std::vector Toks =
-makeHighlightingTokens(Test.ranges(KindString.second), KindString.first);
+std::vector Toks = makeHighlightingTokens(
+Test.ranges(KindString.second), KindString.first);
 ExpectedTokens.insert(ExpectedTokens.end(), Toks.begin(), Toks.end());
   }
 
@@ -49,14 +51,14 @@
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
 R"cpp(
-  struct AS {
+  struct $Class[[AS]] {
 double SomeMember;
   };
-  struct {
+  $Class[[struct]] {
   } $Variable[[S]];
-  void $Function[[foo]](int $Variable[[A]]) {
+  void $Function[[foo]](int $Variable[[A]], $Class[[AS]] $Variable[[As]]) {
 auto $Variable[[VeryLongVariableName]] = 12312;
-AS $Variable[[AA]];
+$Class[[AS]] $Variable[[AA]];
 auto $Variable[[L]] = $Variable[[AA]].SomeMember + $Variable[[A]];
 auto $Variable[[FN]] = [ $Variable[[AA]]](int $Variable[[A]]) -> void {};
 $Variable[[FN]](12312);
@@ -68,13 +70,43 @@
   void $Function[[foo]]() {
 auto $Variable[[Bou]] = $Function[[Gah]];
   }
+  struct $Class[[A]] {
+void $Function[[abc]]();
+  };
 )cpp",
 R"cpp(
-  struct A {
-A();
-~A();
-void $Function[[abc]]();
-void operator<<(int);
+  namespace abc {
+template
+struct $Class[[A]] {
+  T t;
+};
+  }
+  template
+  struct $Class[[C]] : abc::A {
+typename T::A* D;
+  };
+  abc::$Class[[A]] $Variable[[AA]];
+  typedef abc::$Class[[A]] AAA;
+  struct $Class[[B]] {
+$Class[[B]]();
+~$Class[[B]]();
+void operator<<($Class[[B]]);
+$Class[[AAA]] AA;
+  };
+  $Class[[B]]::$Class[[B]]() {}
+  $Class[[B]]::~$Class[[B]]() {}
+  void $Function[[f]] () {
+$Class[[B]] $Variable[[BB]] = $Class[[B]]();
+$Variable[[BB]].~$Class[[B]]();
+$Class[[B]]();
+  }
+)cpp",
+R"cpp(
+  enum class $Enum[[E]] {};
+  enum $Enum[[EE]] {};
+  struct $Class[[A]] {
+$Enum[[E]] EEE;
+$Enum[[EE]] ;
   };
 )cpp"};
   for (const auto &TestCase : TestCases) {
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -10,6 +10,12 @@
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
 # CHECK-NEXT:  ]
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.class.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.enum.cpp"
+# CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 ---
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -26,6 +26,8 @@
 enum class HighlightingKind {
   Variable = 0,
   Function,
+  Class,
+  Enum,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -35,7 +35,14 @@
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
-// FIXME: (De)Constructors/operator need to be highlighted some other way.
+// Constructors have a TypePtr TagDecl that is a Function, therefore we need
+// to get constructors as a NamedDecl instead.
+if (ND->getDeclName().getNameKind() =

[PATCH] D64257: [clangd] Added highlighting for non-builtin types

2019-07-09 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 208622.
jvikstrom added a comment.

Changed commit message.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64257/new/

https://reviews.llvm.org/D64257

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -34,11 +34,13 @@
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
-  {HighlightingKind::Function, "Function"}};
+  {HighlightingKind::Function, "Function"},
+  {HighlightingKind::Class, "Class"},
+  {HighlightingKind::Enum, "Enum"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
-std::vector Toks =
-makeHighlightingTokens(Test.ranges(KindString.second), KindString.first);
+std::vector Toks = makeHighlightingTokens(
+Test.ranges(KindString.second), KindString.first);
 ExpectedTokens.insert(ExpectedTokens.end(), Toks.begin(), Toks.end());
   }
 
@@ -49,14 +51,14 @@
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
 R"cpp(
-  struct AS {
+  struct $Class[[AS]] {
 double SomeMember;
   };
-  struct {
+  $Class[[struct]] {
   } $Variable[[S]];
-  void $Function[[foo]](int $Variable[[A]]) {
+  void $Function[[foo]](int $Variable[[A]], $Class[[AS]] $Variable[[As]]) {
 auto $Variable[[VeryLongVariableName]] = 12312;
-AS $Variable[[AA]];
+$Class[[AS]] $Variable[[AA]];
 auto $Variable[[L]] = $Variable[[AA]].SomeMember + $Variable[[A]];
 auto $Variable[[FN]] = [ $Variable[[AA]]](int $Variable[[A]]) -> void {};
 $Variable[[FN]](12312);
@@ -68,13 +70,43 @@
   void $Function[[foo]]() {
 auto $Variable[[Bou]] = $Function[[Gah]];
   }
+  struct $Class[[A]] {
+void $Function[[abc]]();
+  };
 )cpp",
 R"cpp(
-  struct A {
-A();
-~A();
-void $Function[[abc]]();
-void operator<<(int);
+  namespace abc {
+template
+struct $Class[[A]] {
+  T t;
+};
+  }
+  template
+  struct $Class[[C]] : abc::A {
+typename T::A* D;
+  };
+  abc::$Class[[A]] $Variable[[AA]];
+  typedef abc::$Class[[A]] AAA;
+  struct $Class[[B]] {
+$Class[[B]]();
+~$Class[[B]]();
+void operator<<($Class[[B]]);
+$Class[[AAA]] AA;
+  };
+  $Class[[B]]::$Class[[B]]() {}
+  $Class[[B]]::~$Class[[B]]() {}
+  void $Function[[f]] () {
+$Class[[B]] $Variable[[BB]] = $Class[[B]]();
+$Variable[[BB]].~$Class[[B]]();
+$Class[[B]]();
+  }
+)cpp",
+R"cpp(
+  enum class $Enum[[E]] {};
+  enum $Enum[[EE]] {};
+  struct $Class[[A]] {
+$Enum[[E]] EEE;
+$Enum[[EE]] ;
   };
 )cpp"};
   for (const auto &TestCase : TestCases) {
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -10,6 +10,12 @@
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
 # CHECK-NEXT:  ]
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.class.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.enum.cpp"
+# CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 ---
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -26,6 +26,8 @@
 enum class HighlightingKind {
   Variable = 0,
   Function,
+  Class,
+  Enum,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -35,7 +35,14 @@
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
-// FIXME: (De)Constructors/operator need to be highlighted some other way.
+// Constructors have a TypePtr TagDecl that is a Function, therefore we need
+// to get constructors as a NamedDecl instead.
+if (ND->getDeclName().getNameKind() ==
+DeclarationName::CXXConstruct

[PATCH] D64257: [clangd] Added highlighting for class and enum types

2019-07-09 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:81
   void addToken(SourceLocation Loc, const Decl *D) {
+if (isa(D)) {
+  addToken(Loc, HighlightingKind::Class);

hokein wrote:
> nit: move this around `if (isa(D)) {` since they are related to 
> `Class`, and we should have a comment describing the highlighting behavior of 
> `class, constructor, and destructor`.
I don't really know what you mean with this comment after the move RecordDecl 
around (or rather where to put the comment and what to put in it)
I wrote a comment but don't know if that's  really helpful


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64257/new/

https://reviews.llvm.org/D64257



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


[PATCH] D64243: [NFC][AArch64] Fix vector vqtb[lx][1-4]_s8 operand

2019-07-09 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64243/new/

https://reviews.llvm.org/D64243



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


[PATCH] D64382: Use getMostFrequentByte to decide if should used memset+stores

2019-07-09 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka marked an inline comment as done.
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:873
 return true;
-  if (isa(Init) || isa(Init) ||
+  if (BWInit || isa(Init) || isa(Init) ||
   isa(Init) || isa(Init) ||

vitalybuka wrote:
> jfb wrote:
> > I'm not sure I understand what this bit does. If something isn't a bytewise 
> > value then we now automatically assume it can be stored to with a single 
> > store. That's not necessarily true. I think you need to drop `BWInit ||` 
> > from here, and conditionalize this entire branch with `if (BWInit)` instead 
> > (so, an `&&` on it all).
> If value is bytewise, we will emit BWInit
>> If value is bytewise, we will emit BWInit
If value is bytewise, we will emit memset, which we can count as one store.
It's not always true that memset costs as a single store. However this is a 
heuristic, as the limit 6 itself.

Here I try to keep behavior close to original for zeroes.
In future patches I'd like to try to remove this function and use just 
"density" ((count memset bytes that match initializer)/(full size of 
initializer)). This will be simpler, should work good enough for exiting cases, 
and cover new cases with large initializers where 6 is not enough,


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64382/new/

https://reviews.llvm.org/D64382



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


r365454 - Retire VS2015 Support

2019-07-09 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Jul  9 03:12:37 2019
New Revision: 365454

URL: http://llvm.org/viewvc/llvm-project?rev=365454&view=rev
Log:
Retire VS2015 Support

As proposed here: 
https://lists.llvm.org/pipermail/llvm-dev/2019-June/133147.html

This patch raises the minimum supported version to build LLVM/Clang to Visual 
Studio 2017.

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

Modified:
cfe/trunk/www/get_started.html

Modified: cfe/trunk/www/get_started.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/get_started.html?rev=365454&r1=365453&r2=365454&view=diff
==
--- cfe/trunk/www/get_started.html (original)
+++ cfe/trunk/www/get_started.html Tue Jul  9 03:12:37 2019
@@ -110,7 +110,7 @@ Visual Studio:
 project files.  Get it from:
 https://cmake.org/download/";>
 https://cmake.org/download/
-Visual Studio 2015 or later
+Visual Studio 2017 or later
 Python.  It is used to run the clang test suite. Get it from:
 https://www.python.org/download/";>
 https://www.python.org/download/


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


[clang-tools-extra] r365453 - dummy variable extraction on a function scope

2019-07-09 Thread Shaurya Gupta via cfe-commits
Author: sureyeaah
Date: Tue Jul  9 03:12:26 2019
New Revision: 365453

URL: http://llvm.org/viewvc/llvm-project?rev=365453&view=rev
Log:
dummy variable extraction on a function scope

Summary:
- Added extraction to a dummy variable
- using auto for the dummy variable type for now
- Works on a function scope
- Adding braces to create a compound statement not supported yet
- added unit tests

Reviewers: sammccall, kadircet

Subscribers: mgorny, jkorous, arphaman, cfe-commits

Tags: #clang

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

Added:
clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp
Modified:
clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp

Modified: clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt?rev=365453&r1=365452&r2=365453&view=diff
==
--- clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt Tue Jul  9 
03:12:26 2019
@@ -17,6 +17,7 @@ add_clang_library(clangDaemonTweaks OBJE
   ExpandMacro.cpp
   RawStringLiteral.cpp
   SwapIfBranches.cpp
+  ExtractVariable.cpp
 
   LINK_LIBS
   clangAST

Added: clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp?rev=365453&view=auto
==
--- clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp (added)
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp Tue Jul  
9 03:12:26 2019
@@ -0,0 +1,243 @@
+//===--- ExtractVariable.cpp *- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "ClangdUnit.h"
+#include "Logger.h"
+#include "Protocol.h"
+#include "Selection.h"
+#include "SourceCode.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/OperationKinds.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Stmt.h"
+#include "clang/AST/StmtCXX.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+// information regarding the Expr that is being extracted
+class ExtractionContext {
+public:
+  ExtractionContext(const SelectionTree::Node *Node, const SourceManager &SM,
+const ASTContext &Ctx);
+  const clang::Expr *getExpr() const { return Expr; }
+  const SelectionTree::Node *getExprNode() const { return ExprNode; }
+  bool isExtractable() const { return Extractable; }
+  // Generate Replacement for replacing selected expression with given VarName
+  tooling::Replacement replaceWithVar(llvm::StringRef VarName) const;
+  // Generate Replacement for declaring the selected Expr as a new variable
+  tooling::Replacement insertDeclaration(llvm::StringRef VarName) const;
+
+private:
+  bool Extractable = false;
+  const clang::Expr *Expr;
+  const SelectionTree::Node *ExprNode;
+  // Stmt before which we will extract
+  const clang::Stmt *InsertionPoint = nullptr;
+  const SourceManager &SM;
+  const ASTContext &Ctx;
+  // Decls referenced in the Expr
+  std::vector ReferencedDecls;
+  // returns true if the Expr doesn't reference any variable declared in scope
+  bool exprIsValidOutside(const clang::Stmt *Scope) const;
+  // computes the Stmt before which we will extract out Expr
+  const clang::Stmt *computeInsertionPoint() const;
+};
+
+// Returns all the Decls referenced inside the given Expr
+static std::vector
+computeReferencedDecls(const clang::Expr *Expr) {
+  // RAV subclass to find all DeclRefs in a given Stmt
+  class FindDeclRefsVisitor
+  : public clang::RecursiveASTVisitor {
+  public:
+std::vector ReferencedDecls;
+bool VisitDeclRefExpr(DeclRefExpr *DeclRef) { // NOLINT
+  ReferencedDecls.push_back(DeclRef->getDecl());
+  return true;
+}
+  };
+  FindDeclRefsVisitor Visitor;
+  Visitor.TraverseStmt(const_cast(dyn_cast(Expr)));
+  return Visitor.ReferencedDecls;
+}
+
+// An expr is not extractable if it's null or an expression of type void
+// FIXME: Ignore assignment (a = 1) Expr since it is extracted as dummy 

[PATCH] D63773: [clangd] dummy variable extraction on a function scope

2019-07-09 Thread Shaurya Gupta via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
SureYeaah marked 8 inline comments as done.
Closed by commit rL365453: dummy variable extraction on a function scope 
(authored by SureYeaah, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63773?vs=208174&id=208626#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63773/new/

https://reviews.llvm.org/D63773

Files:
  clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
@@ -239,13 +239,13 @@
   checkNotAvailable(ID, "/*c^omment*/ int foo() return 2 ^ + 2; }");
 
   const char *Input = "int x = 2 ^+ 2;";
-  auto result = getMessage(ID, Input);
-  EXPECT_THAT(result, ::testing::HasSubstr("BinaryOperator"));
-  EXPECT_THAT(result, ::testing::HasSubstr("'+'"));
-  EXPECT_THAT(result, ::testing::HasSubstr("|-IntegerLiteral"));
-  EXPECT_THAT(result,
+  auto Result = getMessage(ID, Input);
+  EXPECT_THAT(Result, ::testing::HasSubstr("BinaryOperator"));
+  EXPECT_THAT(Result, ::testing::HasSubstr("'+'"));
+  EXPECT_THAT(Result, ::testing::HasSubstr("|-IntegerLiteral"));
+  EXPECT_THAT(Result,
   ::testing::HasSubstr(" 'int' 2\n`-IntegerLiteral"));
-  EXPECT_THAT(result, ::testing::HasSubstr(" 'int' 2"));
+  EXPECT_THAT(Result, ::testing::HasSubstr(" 'int' 2"));
 }
 
 TEST(TweakTest, ShowSelectionTree) {
@@ -277,6 +277,136 @@
   const char *Input = "struct ^X { int x; int y; }";
   EXPECT_THAT(getMessage(ID, Input), ::testing::HasSubstr("0 |   int x"));
 }
+TEST(TweakTest, ExtractVariable) {
+  llvm::StringLiteral ID = "ExtractVariable";
+  checkAvailable(ID, R"cpp(
+int xyz() {
+  // return statement
+  return ^1;
+}
+void f() {
+  int a = 5 + [[4 ^* ^xyz^()]];
+  // multivariable initialization
+  if(1)
+int x = ^1, y = ^a + 1, a = ^1, z = a + 1;
+  // if without else
+  if(^1) {}
+  // if with else
+  if(a < ^3)
+if(a == ^4)
+  a = ^5;
+else
+  a = ^6;
+  else if (a < ^4)
+a = ^4;
+  else
+a = ^5;
+  // for loop 
+  for(a = ^1; a > ^3^+^4; a++)
+a = ^2;
+  // while 
+  while(a < ^1)
+^a++;
+  // do while 
+  do
+a = ^1;
+  while(a < ^3);
+}
+  )cpp");
+  checkNotAvailable(ID, R"cpp(
+int xyz(int a = ^1) {
+  return 1;
+  class T {
+T(int a = ^1) {};
+int xyz = ^1;
+  };
+}
+// function default argument
+void f(int b = ^1) {
+  // void expressions
+  auto i = new int, j = new int;
+  de^lete i^, del^ete j;
+  // if
+  if(1)
+int x = 1, y = a + 1, a = 1, z = ^a + 1;
+  if(int a = 1)
+if(^a == 4)
+  a = ^a ^+ 1;
+  // for loop 
+  for(int a = 1, b = 2, c = 3; ^a > ^b ^+ ^c; ^a++)
+a = ^a ^+ 1;
+  // lambda 
+  auto lamb = [&^a, &^b](int r = ^1) {return 1;}
+}
+  )cpp");
+  // vector of pairs of input and output strings
+  const std::vector>
+  InputOutputs = {
+  // extraction from variable declaration/assignment
+  {R"cpp(void varDecl() {
+   int a = 5 * (4 + (3 [[- 1)]]);
+ })cpp",
+   R"cpp(void varDecl() {
+   auto dummy = (3 - 1); int a = 5 * (4 + dummy);
+ })cpp"},
+  // FIXME: extraction from switch case
+  /*{R"cpp(void f(int a) {
+   if(1)
+ while(a < 1)
+   switch (1) {
+   case 1:
+ a = [[1 + 2]];
+ break;
+   default:
+ break;
+   }
+ })cpp",
+   R"cpp(void f(int a) {
+   auto dummy = 1 + 2; if(1)
+ while(a < 1)
+   switch (1) {
+   case 1:
+ a = dummy;
+ break;
+   default:
+ break;
+   }
+ })cpp"},*/
+  // ensure InsertionPoint isn't inside a macro
+  {R"cpp(#define LOOP(x) {int a = x + 1;}
+ void f(int a) {
+   if(1)
+LOOP(5 + ^3)
+ })cpp",
+   R"cpp(#define LOOP(x) {int a = x + 1;}
+ void f(int a) {
+   auto dummy = 3; if(1)
+LOOP(5 +

[PATCH] D63773: [clangd] dummy variable extraction on a function scope

2019-07-09 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp:187
+  std::string ExtractedVarDecl = std::string("auto ") + VarName.str() + " = " +
+ ExtractionCode.str() + "; ";
+  return tooling::Replacement(SM, InsertionLoc, 0, ExtractedVarDecl);

sammccall wrote:
> nit: trailing space? should this be a newline?
Making it a newline makes writing tests harder.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63773/new/

https://reviews.llvm.org/D63773



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


[PATCH] D64375: [OpenMP][Docs] Provide implementation status details

2019-07-09 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a subscriber: protze.joachim.
Hahnfeld added inline comments.



Comment at: clang/docs/OpenMPSupport.rst:165
++--+--+--++
+| OMPD | OMPD interfaces   
   | mostly done  ||
++--+--+--++

This is not correct, at least it's not yet upstream.



Comment at: clang/docs/OpenMPSupport.rst:173
++--+--+--++
+| task extension   | task affinity 
   | done ||
++--+--+--++

This is wrong as well, at least not upstream (we have multiple versions in 
local repositories).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64375/new/

https://reviews.llvm.org/D64375



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


[clang-tools-extra] r365460 - Fixed assertion

2019-07-09 Thread Shaurya Gupta via cfe-commits
Author: sureyeaah
Date: Tue Jul  9 03:30:18 2019
New Revision: 365460

URL: http://llvm.org/viewvc/llvm-project?rev=365460&view=rev
Log:
Fixed assertion

Modified:
clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp

Modified: clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp?rev=365460&r1=365459&r2=365460&view=diff
==
--- clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp 
(original)
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/ExtractVariable.cpp Tue Jul  
9 03:30:18 2019
@@ -181,7 +181,7 @@ tooling::Replacement
 ExtractionContext::insertDeclaration(llvm::StringRef VarName) const {
   const llvm::Optional ExtractionRng =
   toHalfOpenFileRange(SM, Ctx.getLangOpts(), getExpr()->getSourceRange());
-  assert(ExractionRng && "ExtractionRng should not be null");
+  assert(ExtractionRng && "ExtractionRng should not be null");
   llvm::StringRef ExtractionCode = toSourceCode(SM, *ExtractionRng);
   const SourceLocation InsertionLoc =
   toHalfOpenFileRange(SM, Ctx.getLangOpts(),


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


[PATCH] D64257: [clangd] Added highlighting for class and enum types

2019-07-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:81
   void addToken(SourceLocation Loc, const Decl *D) {
+if (isa(D)) {
+  addToken(Loc, HighlightingKind::Class);

jvikstrom wrote:
> hokein wrote:
> > nit: move this around `if (isa(D)) {` since they are related to 
> > `Class`, and we should have a comment describing the highlighting behavior 
> > of `class, constructor, and destructor`.
> I don't really know what you mean with this comment after the move RecordDecl 
> around (or rather where to put the comment and what to put in it)
> I wrote a comment but don't know if that's  really helpful
> I don't really know what you mean with this comment after the move RecordDecl 
> around (or rather where to put the comment and what to put in it)

sorry for the confusion, I meant we group "class" cases together just as what 
your code does now (there are going to be many of kinds, it would be clear if 
we break them into group and sort them).

> I wrote a comment but don't know if that's really helpful

The comment should comment something **not obvious but important** in the code, 
so here we don't have a `if (isa(D)))` case to handle the 
destructor, but the code does highlight destructors  -- for destructors, we get 
a TagTypeLoc whose underlying decl is CXXRecordDecl in VisitTypeLoc), I think 
it deserves a comment here.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:38
   bool VisitNamedDecl(NamedDecl *ND) {
-// FIXME: (De)Constructors/operator need to be highlighted some other way.
+// Constructors have a TypePtr TagDecl that is a Function, therefore we 
need
+// to get constructors as a NamedDecl instead.

I don't understand this comment -- when visiting the constructor AST, we get a 
TagTypeLoc, and its underlying Decl is a `CXXConstructorDecl`



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:73
+
+if (!TL.getTypePtr())
+  return true;

From the comment of `getTypePtr()`:

> This function requires that the type not be NULL. If the type might be NULL, 
> use the (slightly less efficient) \c getTypePtrOrNull().`

I think we should use `getTypePtrOrNull` if you want to check the type ptr is 
null.

```
if (const auto* Type = TL.getTypePtrOrNull()) 
  if (if (const auto* D = Type.getTagDecl())
addToken(D->getLocation(), D);
```



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:57
   };
-  struct {
+  $Class[[struct]] {
   } $Variable[[S]];

just realize this case, this seems weird to me, we are highlighting a keyword 
`struct` as a class type.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64257/new/

https://reviews.llvm.org/D64257



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


[PATCH] D64151: Enhance abseil-faster-strsplit-delimiter to handle other non-printable characters.

2019-07-09 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr marked an inline comment as done.
gribozavr added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp:55
+
+  absl::StrSplit("ABC", R"(A)");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a 
string literal consisting of a single character; consider using the character 
overload [abseil-faster-strsplit-delimiter]

lebedev.ri wrote:
> zhangxy988 wrote:
> > lebedev.ri wrote:
> > > Is there a negative test, `absl::StrSplit("ABC", R"(AA)");`?
> > > Also what about wide chars? (the second assertion)
> > I don't really know how to write a negative test like that.
> > This check is only concerned with single character string literal and it 
> > doesn't support wide char (since `StrSplit` doesn't).
> What i'm asking is, those assertions are there just to say "look, i guarantee 
> those invariants hold here",
> or to say "oh no, we shouldn't have ever violated these invariants here"? The 
> difference being, in former case,
> there is some other error checking that prevents those assertions from 
> triggering; in latter case there is not.
There's a test below for multi-character string literals, 
`absl::StrSplit("ABC", "AB");`.

As far as wide characters go, code with wide characters won't pass semantic 
analysis because there's no StrSplit overload that accepts wide characters.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64151/new/

https://reviews.llvm.org/D64151



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


[clang-tools-extra] r365463 - Enhance abseil-faster-strsplit-delimiter to handle other non-printable characters.

2019-07-09 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Tue Jul  9 04:04:04 2019
New Revision: 365463

URL: http://llvm.org/viewvc/llvm-project?rev=365463&view=rev
Log:
Enhance abseil-faster-strsplit-delimiter to handle other non-printable 
characters.

Summary:
Currently it fails on cases like '\001'.

Note: Since `StringLiteral::outputString` dumps most nonprintable
characters in octal value, the exact string literal format isn't preserved,
e.g. `"\x01"` becomes `'\001'`.

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: lebedev.ri, Eugene.Zelenko, cfe-commits

Tags: #clang

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

Patch by Xiaoyi Zhang.

Modified:
clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp?rev=365463&r1=365462&r2=365463&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp 
Tue Jul  9 04:04:04 2019
@@ -9,6 +9,7 @@
 #include "FasterStrsplitDelimiterCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
 
 using namespace clang::ast_matchers;
 
@@ -20,23 +21,29 @@ namespace {
 
 AST_MATCHER(StringLiteral, lengthIsOne) { return Node.getLength() == 1; }
 
-llvm::Optional makeCharacterLiteral(const StringLiteral *Literal) 
{
-  std::string Result;
-  {
+llvm::Optional makeCharacterLiteral(const StringLiteral *Literal,
+ const ASTContext &Context) {
+  assert(Literal->getLength() == 1 &&
+ "Only single character string should be matched");
+  assert(Literal->getCharByteWidth() == 1 &&
+ "StrSplit doesn't support wide char");
+  std::string Result = clang::tooling::fixit::getText(*Literal, Context).str();
+  bool IsRawStringLiteral = StringRef(Result).startswith(R"(R")");
+  // Since raw string literal might contain unescaped non-printable characters,
+  // we normalize them using `StringLiteral::outputString`.
+  if (IsRawStringLiteral) {
+Result.clear();
 llvm::raw_string_ostream Stream(Result);
 Literal->outputString(Stream);
   }
-
   // Special case: If the string contains a single quote, we just need to 
return
   // a character of the single quote. This is a special case because we need to
   // escape it in the character literal.
   if (Result == R"("'")")
 return std::string(R"('\'')");
 
-  assert(Result.size() == 3 || (Result.size() == 4 && Result.substr(0, 2) == 
"\"\\"));
-
   // Now replace the " with '.
-  auto Pos = Result.find_first_of('"');
+  std::string::size_type Pos = Result.find_first_of('"');
   if (Pos == Result.npos)
 return llvm::None;
   Result[Pos] = '\'';
@@ -98,7 +105,8 @@ void FasterStrsplitDelimiterCheck::check
   if (Literal->getBeginLoc().isMacroID() || Literal->getEndLoc().isMacroID())
 return;
 
-  llvm::Optional Replacement = makeCharacterLiteral(Literal);
+  llvm::Optional Replacement =
+  makeCharacterLiteral(Literal, *Result.Context);
   if (!Replacement)
 return;
   SourceRange Range = Literal->getSourceRange();

Modified: 
clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp?rev=365463&r1=365462&r2=365463&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp 
Tue Jul  9 04:04:04 2019
@@ -44,6 +44,31 @@ void SplitDelimiters() {
   // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a 
string literal consisting of a single character; consider using the character 
overload [abseil-faster-strsplit-delimiter]
   // CHECK-FIXES: absl::StrSplit("ABC", 'A');
 
+  absl::StrSplit("ABC", "\x01");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a 
string literal consisting of a single character; consider using the character 
overload [abseil-faster-strsplit-delimiter]
+  // CHECK-FIXES: absl::StrSplit("ABC", '\x01');
+
+  absl::StrSplit("ABC", "\001");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a 
string literal consisting of a single character; consider using the character 
overload [abseil-faster-strsplit-delimiter]
+  // CHECK-FIXES: absl::StrSplit("ABC", '\001');
+
+  absl::StrSplit("ABC", R"(A)");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a 

[PATCH] D64151: Enhance abseil-faster-strsplit-delimiter to handle other non-printable characters.

2019-07-09 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365463: Enhance abseil-faster-strsplit-delimiter to handle 
other non-printable… (authored by gribozavr, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64151?vs=208500&id=208634#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64151/new/

https://reviews.llvm.org/D64151

Files:
  clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp


Index: 
clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
@@ -9,6 +9,7 @@
 #include "FasterStrsplitDelimiterCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
 
 using namespace clang::ast_matchers;
 
@@ -20,23 +21,29 @@
 
 AST_MATCHER(StringLiteral, lengthIsOne) { return Node.getLength() == 1; }
 
-llvm::Optional makeCharacterLiteral(const StringLiteral *Literal) 
{
-  std::string Result;
-  {
+llvm::Optional makeCharacterLiteral(const StringLiteral *Literal,
+ const ASTContext &Context) {
+  assert(Literal->getLength() == 1 &&
+ "Only single character string should be matched");
+  assert(Literal->getCharByteWidth() == 1 &&
+ "StrSplit doesn't support wide char");
+  std::string Result = clang::tooling::fixit::getText(*Literal, Context).str();
+  bool IsRawStringLiteral = StringRef(Result).startswith(R"(R")");
+  // Since raw string literal might contain unescaped non-printable characters,
+  // we normalize them using `StringLiteral::outputString`.
+  if (IsRawStringLiteral) {
+Result.clear();
 llvm::raw_string_ostream Stream(Result);
 Literal->outputString(Stream);
   }
-
   // Special case: If the string contains a single quote, we just need to 
return
   // a character of the single quote. This is a special case because we need to
   // escape it in the character literal.
   if (Result == R"("'")")
 return std::string(R"('\'')");
 
-  assert(Result.size() == 3 || (Result.size() == 4 && Result.substr(0, 2) == 
"\"\\"));
-
   // Now replace the " with '.
-  auto Pos = Result.find_first_of('"');
+  std::string::size_type Pos = Result.find_first_of('"');
   if (Pos == Result.npos)
 return llvm::None;
   Result[Pos] = '\'';
@@ -98,7 +105,8 @@
   if (Literal->getBeginLoc().isMacroID() || Literal->getEndLoc().isMacroID())
 return;
 
-  llvm::Optional Replacement = makeCharacterLiteral(Literal);
+  llvm::Optional Replacement =
+  makeCharacterLiteral(Literal, *Result.Context);
   if (!Replacement)
 return;
   SourceRange Range = Literal->getSourceRange();
Index: 
clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp
@@ -44,6 +44,31 @@
   // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a 
string literal consisting of a single character; consider using the character 
overload [abseil-faster-strsplit-delimiter]
   // CHECK-FIXES: absl::StrSplit("ABC", 'A');
 
+  absl::StrSplit("ABC", "\x01");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a 
string literal consisting of a single character; consider using the character 
overload [abseil-faster-strsplit-delimiter]
+  // CHECK-FIXES: absl::StrSplit("ABC", '\x01');
+
+  absl::StrSplit("ABC", "\001");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a 
string literal consisting of a single character; consider using the character 
overload [abseil-faster-strsplit-delimiter]
+  // CHECK-FIXES: absl::StrSplit("ABC", '\001');
+
+  absl::StrSplit("ABC", R"(A)");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a 
string literal consisting of a single character; consider using the character 
overload [abseil-faster-strsplit-delimiter]
+  // CHECK-FIXES: absl::StrSplit("ABC", 'A');
+
+  absl::StrSplit("ABC", R"(')");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a 
string literal consisting of a single character; consider using the character 
overload [abseil-faster-strsplit-delimiter]
+  // CHECK-FIXES: absl::StrSplit("ABC", '\'');
+
+  absl::StrSplit("ABC", R"(
+)");
+  // CHECK-MESSAGES: [[@LINE-2]]:25: warning: absl::StrSplit() called with a 
string literal consisting of a single character; consider using the character 
overload

r365464 - [ASTImporter] Added visibility context check for EnumDecl.

2019-07-09 Thread Balazs Keri via cfe-commits
Author: balazske
Date: Tue Jul  9 04:08:18 2019
New Revision: 365464

URL: http://llvm.org/viewvc/llvm-project?rev=365464&view=rev
Log:
[ASTImporter] Added visibility context check for EnumDecl.

Summary:
ASTImporter makes now difference between enums with same name in different 
translation
units if these are not visible outside.
("Scoped enums" are not handled yet.)

Reviewers: martong, a.sidorin, shafik, a_sidorin

Reviewed By: a_sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=365464&r1=365463&r2=365464&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Tue Jul  9 04:08:18 2019
@@ -2476,6 +2476,8 @@ ExpectedDecl ASTNodeImporter::VisitEnumD
   }
 
   if (auto *FoundEnum = dyn_cast(FoundDecl)) {
+if (!hasSameVisibilityContext(FoundEnum, D))
+  continue;
 if (IsStructuralMatch(D, FoundEnum))
   return Importer.MapImported(D, FoundEnum);
   }

Modified: cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp?rev=365464&r1=365463&r2=365464&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp Tue Jul  9 04:08:18 
2019
@@ -35,6 +35,10 @@ struct GetClassPattern {
   using DeclTy = CXXRecordDecl;
   BindableMatcher operator()() { return cxxRecordDecl(hasName("X")); }
 };
+struct GetEnumPattern {
+  using DeclTy = EnumDecl;
+  BindableMatcher operator()() { return enumDecl(hasName("E")); }
+};
 
 // Values for the value-parameterized test fixtures.
 // FunctionDecl:
@@ -48,6 +52,9 @@ const auto *AnonV = "namespace { extern
 // CXXRecordDecl:
 const auto *ExternC = "class X;";
 const auto *AnonC = "namespace { class X; }";
+// EnumDecl:
+const auto *ExternE = "enum E {};";
+const auto *AnonE = "namespace { enum E {}; }";
 
 // First value in tuple: Compile options.
 // Second value in tuple: Source code to be used in the test.
@@ -183,10 +190,53 @@ protected:
 else
   EXPECT_FALSE(ToD1->getPreviousDecl());
   }
+
+  void TypedTest_ImportAfterWithMerge() {
+TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX);
+TranslationUnitDecl *FromTu = getTuDecl(getCode1(), Lang_CXX, "input1.cc");
+
+auto *ToF0 = FirstDeclMatcher().match(ToTu, getPattern());
+auto *FromF1 = FirstDeclMatcher().match(FromTu, getPattern());
+
+auto *ToF1 = Import(FromF1, Lang_CXX);
+
+ASSERT_TRUE(ToF0);
+ASSERT_TRUE(ToF1);
+
+if (shouldBeLinked())
+  EXPECT_EQ(ToF0, ToF1);
+else
+  EXPECT_NE(ToF0, ToF1);
+
+// We expect no (ODR) warning during the import.
+EXPECT_EQ(0u, ToTu->getASTContext().getDiagnostics().getNumWarnings());
+  }
+
+  void TypedTest_ImportAfterImportWithMerge() {
+TranslationUnitDecl *FromTu0 = getTuDecl(getCode0(), Lang_CXX, 
"input0.cc");
+TranslationUnitDecl *FromTu1 = getTuDecl(getCode1(), Lang_CXX, 
"input1.cc");
+auto *FromF0 = FirstDeclMatcher().match(FromTu0, getPattern());
+auto *FromF1 = FirstDeclMatcher().match(FromTu1, getPattern());
+auto *ToF0 = Import(FromF0, Lang_CXX);
+auto *ToF1 = Import(FromF1, Lang_CXX);
+ASSERT_TRUE(ToF0);
+ASSERT_TRUE(ToF1);
+if (shouldBeLinked())
+  EXPECT_EQ(ToF0, ToF1);
+else
+  EXPECT_NE(ToF0, ToF1);
+
+// We expect no (ODR) warning during the import.
+EXPECT_EQ(0u, ToF0->getTranslationUnitDecl()
+  ->getASTContext()
+  .getDiagnostics()
+  .getNumWarnings());
+  }
 };
 using ImportFunctionsVisibility = ImportVisibility;
 using ImportVariablesVisibility = ImportVisibility;
 using ImportClassesVisibility = ImportVisibility;
+using ImportEnumsVisibility = ImportVisibility;
 
 // FunctionDecl.
 TEST_P(ImportFunctionsVisibility, ImportAfter) {
@@ -209,6 +259,13 @@ TEST_P(ImportClassesVisibility, ImportAf
 TEST_P(ImportClassesVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImport();
 }
+// EnumDecl.
+TEST_P(ImportEnumsVisibility, ImportAfter) {
+  TypedTest_ImportAfterWithMerge();
+}
+TEST_P(ImportEnumsVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImportWithMerge();
+}
 
 const bool ExpectLink = true;
 const bool ExpectNotLink = false;
@@ -247,6 +304,14 @@ INSTANTIATE_TEST_CASE_P(
   std::make_tuple(ExternC, AnonC, ExpectNotLink),
   std::make_tuple(AnonC, ExternC, ExpectNotLink),
  

[PATCH] D62484: [ASTImporter] Added visibility context check for EnumDecl.

2019-07-09 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365464: [ASTImporter] Added visibility context check for 
EnumDecl. (authored by balazske, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62484/new/

https://reviews.llvm.org/D62484

Files:
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp

Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -2476,6 +2476,8 @@
   }
 
   if (auto *FoundEnum = dyn_cast(FoundDecl)) {
+if (!hasSameVisibilityContext(FoundEnum, D))
+  continue;
 if (IsStructuralMatch(D, FoundEnum))
   return Importer.MapImported(D, FoundEnum);
   }
Index: cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -35,6 +35,10 @@
   using DeclTy = CXXRecordDecl;
   BindableMatcher operator()() { return cxxRecordDecl(hasName("X")); }
 };
+struct GetEnumPattern {
+  using DeclTy = EnumDecl;
+  BindableMatcher operator()() { return enumDecl(hasName("E")); }
+};
 
 // Values for the value-parameterized test fixtures.
 // FunctionDecl:
@@ -48,6 +52,9 @@
 // CXXRecordDecl:
 const auto *ExternC = "class X;";
 const auto *AnonC = "namespace { class X; }";
+// EnumDecl:
+const auto *ExternE = "enum E {};";
+const auto *AnonE = "namespace { enum E {}; }";
 
 // First value in tuple: Compile options.
 // Second value in tuple: Source code to be used in the test.
@@ -183,10 +190,53 @@
 else
   EXPECT_FALSE(ToD1->getPreviousDecl());
   }
+
+  void TypedTest_ImportAfterWithMerge() {
+TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX);
+TranslationUnitDecl *FromTu = getTuDecl(getCode1(), Lang_CXX, "input1.cc");
+
+auto *ToF0 = FirstDeclMatcher().match(ToTu, getPattern());
+auto *FromF1 = FirstDeclMatcher().match(FromTu, getPattern());
+
+auto *ToF1 = Import(FromF1, Lang_CXX);
+
+ASSERT_TRUE(ToF0);
+ASSERT_TRUE(ToF1);
+
+if (shouldBeLinked())
+  EXPECT_EQ(ToF0, ToF1);
+else
+  EXPECT_NE(ToF0, ToF1);
+
+// We expect no (ODR) warning during the import.
+EXPECT_EQ(0u, ToTu->getASTContext().getDiagnostics().getNumWarnings());
+  }
+
+  void TypedTest_ImportAfterImportWithMerge() {
+TranslationUnitDecl *FromTu0 = getTuDecl(getCode0(), Lang_CXX, "input0.cc");
+TranslationUnitDecl *FromTu1 = getTuDecl(getCode1(), Lang_CXX, "input1.cc");
+auto *FromF0 = FirstDeclMatcher().match(FromTu0, getPattern());
+auto *FromF1 = FirstDeclMatcher().match(FromTu1, getPattern());
+auto *ToF0 = Import(FromF0, Lang_CXX);
+auto *ToF1 = Import(FromF1, Lang_CXX);
+ASSERT_TRUE(ToF0);
+ASSERT_TRUE(ToF1);
+if (shouldBeLinked())
+  EXPECT_EQ(ToF0, ToF1);
+else
+  EXPECT_NE(ToF0, ToF1);
+
+// We expect no (ODR) warning during the import.
+EXPECT_EQ(0u, ToF0->getTranslationUnitDecl()
+  ->getASTContext()
+  .getDiagnostics()
+  .getNumWarnings());
+  }
 };
 using ImportFunctionsVisibility = ImportVisibility;
 using ImportVariablesVisibility = ImportVisibility;
 using ImportClassesVisibility = ImportVisibility;
+using ImportEnumsVisibility = ImportVisibility;
 
 // FunctionDecl.
 TEST_P(ImportFunctionsVisibility, ImportAfter) {
@@ -209,6 +259,13 @@
 TEST_P(ImportClassesVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImport();
 }
+// EnumDecl.
+TEST_P(ImportEnumsVisibility, ImportAfter) {
+  TypedTest_ImportAfterWithMerge();
+}
+TEST_P(ImportEnumsVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImportWithMerge();
+}
 
 const bool ExpectLink = true;
 const bool ExpectNotLink = false;
@@ -247,6 +304,14 @@
   std::make_tuple(ExternC, AnonC, ExpectNotLink),
   std::make_tuple(AnonC, ExternC, ExpectNotLink),
   std::make_tuple(AnonC, AnonC, ExpectNotLink))), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportEnumsVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(std::make_tuple(ExternE, ExternE, ExpectLink),
+  std::make_tuple(ExternE, AnonE, ExpectNotLink),
+  std::make_tuple(AnonE, ExternE, ExpectNotLink),
+  std::make_tuple(AnonE, AnonE, ExpectNotLink))), );
 
 } // end namespace ast_matchers
 } // end namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61637: [Syntax] Introduce syntax trees

2019-07-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

@ilya-biryukov We're seeing buildbot failures in SyntaxTests.exe : 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/50927
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/26822

Failing Tests (1):

  Clang-Unit :: Tooling/Syntax/./SyntaxTests.exe/SyntaxTreeTest.Basic


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61637/new/

https://reviews.llvm.org/D61637



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


r365465 - Revert rL365355 : [Syntax] Introduce syntax trees

2019-07-09 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Jul  9 04:26:35 2019
New Revision: 365465

URL: http://llvm.org/viewvc/llvm-project?rev=365465&view=rev
Log:
Revert rL365355 : [Syntax] Introduce syntax trees

Summary:
A tooling-focused alternative to the AST. This commit focuses on the
memory-management strategy and the structure of the AST.

More to follow later:
  - Operations to mutate the syntax trees and corresponding textual
replacements.
  - Mapping between clang AST nodes and syntax tree nodes.
  - More node types corresponding to the language constructs.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: llvm-commits, mgorny, cfe-commits

Tags: #clang, #llvm

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

Fixes buildbots which were crashing on SyntaxTests.exe

Removed:
cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h
cfe/trunk/include/clang/Tooling/Syntax/Nodes.h
cfe/trunk/include/clang/Tooling/Syntax/Tree.h
cfe/trunk/lib/Tooling/Syntax/BuildTree.cpp
cfe/trunk/lib/Tooling/Syntax/Nodes.cpp
cfe/trunk/lib/Tooling/Syntax/Tree.cpp
cfe/trunk/unittests/Tooling/Syntax/TreeTest.cpp
Modified:
cfe/trunk/lib/Tooling/Syntax/CMakeLists.txt
cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt

Removed: cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h?rev=365464&view=auto
==
--- cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h (original)
+++ cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h (removed)
@@ -1,24 +0,0 @@
-//===- BuildTree.h - build syntax trees ---*- C++ 
-*-=//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-// Functions to construct a syntax tree from an AST.
-//===--===//
-#ifndef LLVM_CLANG_TOOLING_SYNTAX_TREE_H
-#define LLVM_CLANG_TOOLING_SYNTAX_TREE_H
-
-#include "clang/AST/Decl.h"
-#include "clang/Tooling/Syntax/Nodes.h"
-
-namespace clang {
-namespace syntax {
-
-/// Build a syntax tree for the main file.
-syntax::TranslationUnit *buildSyntaxTree(Arena &A,
- const clang::TranslationUnitDecl &TU);
-} // namespace syntax
-} // namespace clang
-#endif

Removed: cfe/trunk/include/clang/Tooling/Syntax/Nodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Syntax/Nodes.h?rev=365464&view=auto
==
--- cfe/trunk/include/clang/Tooling/Syntax/Nodes.h (original)
+++ cfe/trunk/include/clang/Tooling/Syntax/Nodes.h (removed)
@@ -1,85 +0,0 @@
-//===- Nodes.h - syntax nodes for C/C++ grammar constructs *- C++ 
-*-=//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-// Syntax tree nodes for C, C++ and Objective-C grammar constructs.
-//===--===//
-#ifndef LLVM_CLANG_TOOLING_SYNTAX_NODES_H
-#define LLVM_CLANG_TOOLING_SYNTAX_NODES_H
-
-#include "clang/Basic/TokenKinds.h"
-#include "clang/Lex/Token.h"
-#include "clang/Tooling/Syntax/Tokens.h"
-#include "clang/Tooling/Syntax/Tree.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/raw_ostream.h"
-
-namespace clang {
-namespace syntax {
-
-/// A kind of a syntax node, used for implementing casts.
-enum class NodeKind : uint16_t {
-  Leaf,
-  TranslationUnit,
-  TopLevelDeclaration,
-  CompoundStatement
-};
-/// For debugging purposes.
-llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, NodeKind K);
-
-/// A root node for a translation unit. Parent is always null.
-class TranslationUnit final : public Tree {
-public:
-  TranslationUnit() : Tree(NodeKind::TranslationUnit) {}
-  static bool classof(const Node *N) {
-return N->kind() == NodeKind::TranslationUnit;
-  }
-};
-
-/// FIXME: this node is temporary and will be replaced with nodes for various
-///'declarations' and 'declarators' from the C/C++ grammar
-///
-/// Represents any top-level declaration. Only there to give the syntax tree a
-/// bit of structure until we implement syntax nodes for declarations and
-/// declarators.
-class TopLevelDeclaration final : public Tree {
-public:
-  TopLevelDeclaration() : Tree(NodeKind::TopLevelDeclaration) {}
-  static bool classof(const Node *N) {
-return N->kind() == NodeKind::TopLevelDeclaration;
-  }
-};
-
-//

[PATCH] D64151: Enhance abseil-faster-strsplit-delimiter to handle other non-printable characters.

2019-07-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri marked an inline comment as done.
lebedev.ri added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/abseil-faster-strsplit-delimiter.cpp:55
+
+  absl::StrSplit("ABC", R"(A)");
+  // CHECK-MESSAGES: [[@LINE-1]]:25: warning: absl::StrSplit() called with a 
string literal consisting of a single character; consider using the character 
overload [abseil-faster-strsplit-delimiter]

gribozavr wrote:
> lebedev.ri wrote:
> > zhangxy988 wrote:
> > > lebedev.ri wrote:
> > > > Is there a negative test, `absl::StrSplit("ABC", R"(AA)");`?
> > > > Also what about wide chars? (the second assertion)
> > > I don't really know how to write a negative test like that.
> > > This check is only concerned with single character string literal and it 
> > > doesn't support wide char (since `StrSplit` doesn't).
> > What i'm asking is, those assertions are there just to say "look, i 
> > guarantee those invariants hold here",
> > or to say "oh no, we shouldn't have ever violated these invariants here"? 
> > The difference being, in former case,
> > there is some other error checking that prevents those assertions from 
> > triggering; in latter case there is not.
> There's a test below for multi-character string literals, 
> `absl::StrSplit("ABC", "AB");`.
> 
> As far as wide characters go, code with wide characters won't pass semantic 
> analysis because there's no StrSplit overload that accepts wide characters.
Cool, i have no further comments here then, thanks.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64151/new/

https://reviews.llvm.org/D64151



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


[PATCH] D61637: [Syntax] Introduce syntax trees

2019-07-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D61637#1575542 , @RKSimon wrote:

> @ilya-biryukov We're seeing buildbot failures in SyntaxTests.exe : 
>  
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/50927
>  
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/26822
>
> Failing Tests (1):
>
>   Clang-Unit :: Tooling/Syntax/./SyntaxTests.exe/SyntaxTreeTest.Basic


Sorry about that. That's the same error we had with the previous patch. Will 
send a fix right away.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61637/new/

https://reviews.llvm.org/D61637



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


[PATCH] D61637: [Syntax] Introduce syntax trees

2019-07-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon reopened this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

@ilya-biryukov I'm sorry but I've reverted this at rL365465 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61637/new/

https://reviews.llvm.org/D61637



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


r365466 - Reland r365355: [Syntax] Introduce syntax trees

2019-07-09 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Jul  9 04:32:13 2019
New Revision: 365466

URL: http://llvm.org/viewvc/llvm-project?rev=365466&view=rev
Log:
Reland r365355: [Syntax] Introduce syntax trees

With a fix to a PS4 buildbot crash.

Added:
cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h
cfe/trunk/include/clang/Tooling/Syntax/Nodes.h
cfe/trunk/include/clang/Tooling/Syntax/Tree.h
cfe/trunk/lib/Tooling/Syntax/BuildTree.cpp
cfe/trunk/lib/Tooling/Syntax/Nodes.cpp
cfe/trunk/lib/Tooling/Syntax/Tree.cpp
cfe/trunk/unittests/Tooling/Syntax/TreeTest.cpp
Modified:
cfe/trunk/lib/Tooling/Syntax/CMakeLists.txt
cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt

Added: cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h?rev=365466&view=auto
==
--- cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h (added)
+++ cfe/trunk/include/clang/Tooling/Syntax/BuildTree.h Tue Jul  9 04:32:13 2019
@@ -0,0 +1,24 @@
+//===- BuildTree.h - build syntax trees ---*- C++ 
-*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+// Functions to construct a syntax tree from an AST.
+//===--===//
+#ifndef LLVM_CLANG_TOOLING_SYNTAX_TREE_H
+#define LLVM_CLANG_TOOLING_SYNTAX_TREE_H
+
+#include "clang/AST/Decl.h"
+#include "clang/Tooling/Syntax/Nodes.h"
+
+namespace clang {
+namespace syntax {
+
+/// Build a syntax tree for the main file.
+syntax::TranslationUnit *buildSyntaxTree(Arena &A,
+ const clang::TranslationUnitDecl &TU);
+} // namespace syntax
+} // namespace clang
+#endif

Added: cfe/trunk/include/clang/Tooling/Syntax/Nodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Syntax/Nodes.h?rev=365466&view=auto
==
--- cfe/trunk/include/clang/Tooling/Syntax/Nodes.h (added)
+++ cfe/trunk/include/clang/Tooling/Syntax/Nodes.h Tue Jul  9 04:32:13 2019
@@ -0,0 +1,85 @@
+//===- Nodes.h - syntax nodes for C/C++ grammar constructs *- C++ 
-*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+// Syntax tree nodes for C, C++ and Objective-C grammar constructs.
+//===--===//
+#ifndef LLVM_CLANG_TOOLING_SYNTAX_NODES_H
+#define LLVM_CLANG_TOOLING_SYNTAX_NODES_H
+
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Lex/Token.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Syntax/Tree.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+namespace syntax {
+
+/// A kind of a syntax node, used for implementing casts.
+enum class NodeKind : uint16_t {
+  Leaf,
+  TranslationUnit,
+  TopLevelDeclaration,
+  CompoundStatement
+};
+/// For debugging purposes.
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, NodeKind K);
+
+/// A root node for a translation unit. Parent is always null.
+class TranslationUnit final : public Tree {
+public:
+  TranslationUnit() : Tree(NodeKind::TranslationUnit) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::TranslationUnit;
+  }
+};
+
+/// FIXME: this node is temporary and will be replaced with nodes for various
+///'declarations' and 'declarators' from the C/C++ grammar
+///
+/// Represents any top-level declaration. Only there to give the syntax tree a
+/// bit of structure until we implement syntax nodes for declarations and
+/// declarators.
+class TopLevelDeclaration final : public Tree {
+public:
+  TopLevelDeclaration() : Tree(NodeKind::TopLevelDeclaration) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::TopLevelDeclaration;
+  }
+};
+
+/// An abstract node for C++ statements, e.g. 'while', 'if', etc.
+class Statement : public Tree {
+public:
+  Statement(NodeKind K) : Tree(K) {}
+  static bool classof(const Node *N) {
+return NodeKind::CompoundStatement <= N->kind() &&
+   N->kind() <= NodeKind::CompoundStatement;
+  }
+};
+
+/// { statement1; statement2; … }
+class CompoundStatement final : public Statement {
+public:
+  CompoundStatement() : Statement(NodeKind::CompoundStatement) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::C

[PATCH] D61637: [Syntax] Introduce syntax trees

2019-07-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Relanded in rL365466  with a fix to the 
crash.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61637/new/

https://reviews.llvm.org/D61637



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


[PATCH] D64391: [CodeComplete] an option to suppress endings for header completion

2019-07-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for digging through this!

Adding an option doesn't avoid a decision about what the behavior will be. >99% 
of users will use the default for something as fine-grained as this.
So we need to find a default that works well for most people. And if it's good 
enough to be the default, it's probably good enough to be the only behavior - 
supporting multiple has high costs and benefits few people.

As for behavior, it seems there's a few different changes/aspects worth looking 
at:

**Inserting trailing quotes after filenames**

The advantages:

- don't have to type the quote, or remember whether it's `>` or `"`
- makes the file/directory distinction in the completion list obvious

The disadvantages:

- looks funny in completion list

(I haven't included issues if the line already has more text and a closing 
quote here, as we have to consider this case carefully either way)

My take here is that inserting the trailing quote is somewhat useful and people 
quickly get used to it. What do you think?

**Inserting slashes after directories**

The current workflow (with the slash inserted) is:

1. start typing directory name
2. select completion item
3. hit enter or similar
4. start typing filename, or hit ctrl-space etc

The proposed workflow is:

1. start typing directory name
2. select completion
3. hit slash

This is certainly a better workflow, especially you don't know the first 
character of the next path segment (well, at least for US keyboard layout users 
where slash is easy to reach).
My main concerns are a) may not be available in all editors, b) users may not 
know about it and use it.

1. start typing directory name
2. select completion
3. hit enter or similar
4. hit slash

which is pretty clumsy. One option would be to check whether the client has 
`commitCharacter` support. If so, omit the slash, and send slash as a 
`commitCharacter`. Otherwise include the slash... This obviously solves the 
editor but not the user problem.

**Handling the rest of the line**

We may not be completing at the end of the line. This happens if the user 
completes in the middle of the file path, or the editor has inserted a matching 
quote, etc.

Now we need to decide how much of the line we're going to replace. Various API 
contracts mean this should be the same for every completion item in a given 
context. We can re-insert text that already exists in the replaced range (e.g. 
closing quotes), but the cursor will be placed on the right of it.

Let's look at `#include "a/b^c"` where c might be empty. (There are other 
cases, but I think this is the most important).
Our main options are:

1. replace b, c, and `"` with the completion (and quote)
2. replace b and c with the completion
3. replace b with the completion

Option 3 is dominated by option 2 I think - it tends to produce nonsense 
tokens. So only 1 and 2 are worth considering.

Advantages of replacing the closing quote:

- is consistent with inserting closing quotes elsewhere, which seems like 
useful behavior elsewhere
- puts us at the end of the line after the completion, ready to hit enter

Disadvantages of replacing the closing quote:

- less jarring when completing a directory, as it doesn't eat the closing quote

Are there others?
This one seems like a wash to me, and I'm comfortable with the current 
behavior. In particular I don't see the conflict between inserting quotes and 
editors auto-pairing quotes that you mention. Can you elaborate?

---

I don't want to jump to a conclusion, but I would at least figure that the most 
important part of this change/issue with current behavior is the workflow 
around completing a directory name. Is that right?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64391/new/

https://reviews.llvm.org/D64391



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


[PATCH] D64400: [OpenCL][PR42390] Deduce addr space for templ specialization

2019-07-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: rjmccall, mantognini.
Herald added subscribers: ebevhan, yaxunl.

Addr space of a template arg doesn't affect the `QualType` of template 
specialization. Therefore addr space of  a template specialization can be 
deduced during parsing of template definition directly.


https://reviews.llvm.org/D64400

Files:
  include/clang/AST/Type.h
  lib/Sema/SemaType.cpp
  test/SemaOpenCLCXX/address-space-deduction.cl


Index: test/SemaOpenCLCXX/address-space-deduction.cl
===
--- test/SemaOpenCLCXX/address-space-deduction.cl
+++ test/SemaOpenCLCXX/address-space-deduction.cl
@@ -38,3 +38,33 @@
   int foo[10];
   xxx(&foo[0]);
 }
+
+// Deducing addr spaces for template specialization is fine
+// addr space of template arg can't affecting the addr space
+// of specialization
+
+template 
+struct x1 {
+//CHECK: -CXXMethodDecl {{.*}} operator= '__generic x1 &(const __generic 
x1 &) __generic'
+  x1& operator=(const x1& xx) {
+y = xx.y;
+return *this;
+  }
+  int y;
+};
+
+template 
+struct x2 {
+//CHECK: -CXXMethodDecl {{.*}} foo 'void (__generic x1 *) __generic'
+  void foo(x1* xx) {
+m[0] = *xx;
+  }
+//CHECK: -FieldDecl {{.*}}  m 'x1 [2]'
+  x1 m[2];
+};
+
+void bar(__global x1* xx, __global x2* bar)
+{
+  bar->foo(xx);
+}
+
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7414,9 +7414,13 @@
   (T->isVoidType() && !IsPointee) ||
   // Do not deduce addr spaces for dependent types because they might end
   // up instantiating to a type with an explicit address space qualifier.
-  // Expect for pointer or reference types because the addr space in
-  // template argument can only belong to a pointee.
-  (T->isDependentType() && !T->isPointerType() && !T->isReferenceType()) ||
+  // Expect for:
+  // - pointer or reference types because the addr space in template
+  //   argument can only belong to a pointee.
+  // - template specialization as addr space in template argument doesn't
+  //   affect specialization.
+  (T->isDependentType() && (!T->isPointerType() && !T->isReferenceType() &&
+!T->isTemplateSpecializationType())) ||
   // Do not deduce addr space of decltype because it will be taken from
   // its argument.
   T->isDecltypeType() ||
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1981,6 +1981,7 @@
   bool isObjCBoxableRecordType() const;
   bool isInterfaceType() const;
   bool isStructureOrClassType() const;
+  bool isTemplateSpecializationType() const;
   bool isUnionType() const;
   bool isComplexIntegerType() const;// GCC _Complex integer type.
   bool isVectorType() const;// GCC vector type.
@@ -6507,6 +6508,10 @@
   return isa(this);
 }
 
+inline bool Type::isTemplateSpecializationType() const {
+  return isa(this);
+}
+
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
   inline bool Type::is##Id##Type() const { \
 return isSpecificBuiltinType(BuiltinType::Id); \


Index: test/SemaOpenCLCXX/address-space-deduction.cl
===
--- test/SemaOpenCLCXX/address-space-deduction.cl
+++ test/SemaOpenCLCXX/address-space-deduction.cl
@@ -38,3 +38,33 @@
   int foo[10];
   xxx(&foo[0]);
 }
+
+// Deducing addr spaces for template specialization is fine
+// addr space of template arg can't affecting the addr space
+// of specialization
+
+template 
+struct x1 {
+//CHECK: -CXXMethodDecl {{.*}} operator= '__generic x1 &(const __generic x1 &) __generic'
+  x1& operator=(const x1& xx) {
+y = xx.y;
+return *this;
+  }
+  int y;
+};
+
+template 
+struct x2 {
+//CHECK: -CXXMethodDecl {{.*}} foo 'void (__generic x1 *) __generic'
+  void foo(x1* xx) {
+m[0] = *xx;
+  }
+//CHECK: -FieldDecl {{.*}}  m 'x1 [2]'
+  x1 m[2];
+};
+
+void bar(__global x1* xx, __global x2* bar)
+{
+  bar->foo(xx);
+}
+
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7414,9 +7414,13 @@
   (T->isVoidType() && !IsPointee) ||
   // Do not deduce addr spaces for dependent types because they might end
   // up instantiating to a type with an explicit address space qualifier.
-  // Expect for pointer or reference types because the addr space in
-  // template argument can only belong to a pointee.
-  (T->isDependentType() && !T->isPointerType() && !T->isReferenceType()) ||
+  // Expect for:
+  // - pointer or reference types because the addr space in template
+  //   argument can only belong to a pointee.
+  // - template specialization as addr space in templa

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

2019-07-09 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

Sure, done in r365445 
thanks for your work!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D28462/new/

https://reviews.llvm.org/D28462



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


Dumping Clang AST to a file

2019-07-09 Thread Monalisa Rout via cfe-commits
Hello, Currently I am dumping the Clang AST to the console but I want to
write it to a file.

I have pasted the code snippet.

bool HandleTopLevelDecl(DeclGroupRef DR) override {
for (DeclGroupRef::iterator b = DR.begin(), e = DR.end(); b != e; ++b) {
(*b)->dump(llvm::errs(), false,clang::ADOF_JSON);
}
return true;
}

How this can be done ?? Any help is appreciated.

Regards,
Mona
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2019-07-09 Thread Nick Renieris via Phabricator via cfe-commits
VelocityRa added a comment.

In D28462#1575262 , @sylvestre.ledru 
wrote:

> @VelocityRa could you please add it to the release notes?
>  https://github.com/llvm-mirror/clang/blob/master/docs/ReleaseNotes.rst
>  I can commit the change if you need


Yeah could you do it? Thank you.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D28462/new/

https://reviews.llvm.org/D28462



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


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

2019-07-09 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@VelocityRa could you please add it to the release notes?
https://github.com/llvm-mirror/clang/blob/master/docs/ReleaseNotes.rst
I can commit the change if you need


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D28462/new/

https://reviews.llvm.org/D28462



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


Re: Dumping Clang AST to a file

2019-07-09 Thread Aaron Ballman via cfe-commits
On Tue, Jul 9, 2019 at 8:11 AM Monalisa Rout via cfe-commits
 wrote:
>
> Hello, Currently I am dumping the Clang AST to the console but I want to 
> write it to a file.
>
> I have pasted the code snippet.
>
> bool HandleTopLevelDecl(DeclGroupRef DR) override {
> for (DeclGroupRef::iterator b = DR.begin(), e = DR.end(); b != e; ++b) {
> (*b)->dump(llvm::errs(), false,clang::ADOF_JSON);
> }
> return true;
> }
>
> How this can be done ?? Any help is appreciated.

You are currently using llvm::errs() as the output stream for dumping.
To dump to a file, you would want to use a raw_fd_ostream object
(raw_ostream.h) instead.

HTH!

~Aaron

>
> Regards,
> Mona
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64389: [NFC] [X86] Fix scan-build complaining

2019-07-09 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM - cheers


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64389/new/

https://reviews.llvm.org/D64389



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


r365473 - [NFC] [X86] Fix scan-build complaining

2019-07-09 Thread Pengfei Wang via cfe-commits
Author: pengfei
Date: Tue Jul  9 05:41:12 2019
New Revision: 365473

URL: http://llvm.org/viewvc/llvm-project?rev=365473&view=rev
Log:
[NFC] [X86] Fix scan-build complaining

Summary:
Remove unused variable. This fixes bug:
https://bugs.llvm.org/show_bug.cgi?id=42526

Signed-off-by: pengfei 

Reviewers: RKSimon, xiangzhangllvm, craig.topper

Subscribers: cfe-commits

Tags: #clang

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

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

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=365473&r1=365472&r2=365473&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Jul  9 05:41:12 2019
@@ -11776,12 +11776,11 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 Value *Call = Builder.CreateCall(CGM.getIntrinsic(ID), {Ops[0], Ops[1]});
 Value *Result = Builder.CreateExtractValue(Call, 0);
 Result = EmitX86MaskedCompareResult(*this, Result, NumElts, nullptr);
-Value *Store = Builder.CreateDefaultAlignedStore(Result, Ops[2]);
+Builder.CreateDefaultAlignedStore(Result, Ops[2]);
 
 Result = Builder.CreateExtractValue(Call, 1);
 Result = EmitX86MaskedCompareResult(*this, Result, NumElts, nullptr);
-Store = Builder.CreateDefaultAlignedStore(Result, Ops[3]);
-return Store;
+return Builder.CreateDefaultAlignedStore(Result, Ops[3]);
   }
 
   case X86::BI__builtin_ia32_vpmultishiftqb128:


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


[PATCH] D64389: [NFC] [X86] Fix scan-build complaining

2019-07-09 Thread Pengfei Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365473: [NFC] [X86] Fix scan-build complaining (authored by 
pengfei, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64389?vs=208605&id=208653#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64389/new/

https://reviews.llvm.org/D64389

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp


Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -11776,12 +11776,11 @@
 Value *Call = Builder.CreateCall(CGM.getIntrinsic(ID), {Ops[0], Ops[1]});
 Value *Result = Builder.CreateExtractValue(Call, 0);
 Result = EmitX86MaskedCompareResult(*this, Result, NumElts, nullptr);
-Value *Store = Builder.CreateDefaultAlignedStore(Result, Ops[2]);
+Builder.CreateDefaultAlignedStore(Result, Ops[2]);
 
 Result = Builder.CreateExtractValue(Call, 1);
 Result = EmitX86MaskedCompareResult(*this, Result, NumElts, nullptr);
-Store = Builder.CreateDefaultAlignedStore(Result, Ops[3]);
-return Store;
+return Builder.CreateDefaultAlignedStore(Result, Ops[3]);
   }
 
   case X86::BI__builtin_ia32_vpmultishiftqb128:


Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -11776,12 +11776,11 @@
 Value *Call = Builder.CreateCall(CGM.getIntrinsic(ID), {Ops[0], Ops[1]});
 Value *Result = Builder.CreateExtractValue(Call, 0);
 Result = EmitX86MaskedCompareResult(*this, Result, NumElts, nullptr);
-Value *Store = Builder.CreateDefaultAlignedStore(Result, Ops[2]);
+Builder.CreateDefaultAlignedStore(Result, Ops[2]);
 
 Result = Builder.CreateExtractValue(Call, 1);
 Result = EmitX86MaskedCompareResult(*this, Result, NumElts, nullptr);
-Store = Builder.CreateDefaultAlignedStore(Result, Ops[3]);
-return Store;
+return Builder.CreateDefaultAlignedStore(Result, Ops[3]);
   }
 
   case X86::BI__builtin_ia32_vpmultishiftqb128:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-09 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:6549
+static bool
+pathInitializeLifetimePointer(llvm::ArrayRef Path) {
+  return Path.size() > 0 && llvm::all_of(Path, [=](IndirectLocalPathEntry E) {

Move closer to the point of usage?



Comment at: clang/lib/Sema/SemaInit.cpp:6549
+static bool
+pathInitializeLifetimePointer(llvm::ArrayRef Path) {
+  return Path.size() > 0 && llvm::all_of(Path, [=](IndirectLocalPathEntry E) {

gribozavr wrote:
> Move closer to the point of usage?
re: name, `pathOnlyContainsGslPointerInit` or `pathOnlyInitializesGslPointer`



Comment at: clang/lib/Sema/SemaInit.cpp:6564
+template
+static bool recordHasAttr(QualType Type) {
+  if (auto *RD = Type->getAsCXXRecordDecl())

"isRecordWithAttr" ?



Comment at: clang/lib/Sema/SemaInit.cpp:7072
+
+bool IsLifetimePtrInitWithTempOwner = false;
+if (!Path.empty() &&

Please adjust the name.



Comment at: clang/lib/Sema/SemaInit.cpp:7076
+auto Prefix = llvm::makeArrayRef(Path).drop_back();
+  if (pathInitializeLifetimePointer(Prefix))
+IsLifetimePtrInitWithTempOwner = true;

Is it important that the whole path only contains gsl::Pointer nodes?



Comment at: clang/lib/Sema/SemaInit.cpp:6510
 LifetimeBoundCall,
+LifetimePointerInit,
+LifetimeTempOwner

xazax.hun wrote:
> gribozavr wrote:
> > What is this name supposed to mean? Initialization of a "lifetime pointer"? 
> > What's a "lifetime pointer"?
> > 
> > If you were imitating "LifetimeBoundCall", it is a reference to the 
> > attribute: 
> > https://clang.llvm.org/docs/AttributeReference.html#lifetimebound .
> When we were working on the lifetime analysis we needed to distinguish raw 
> pointers from the user defined types that are categorized as pointers. We 
> adopted this notion of Lifetime Pointer which stands for the user defined 
> type that is annotated with gsl::Pointer.
> 
> In case this is confusing I could rename it `GslPointerInit` and 
> `GslTempOwner`. What do you think?
My suggestion is to refer to a type that was annotated with gsl::Pointer as a 
"gsl::Pointer type" in prose, or "GslPointer" where you need an identifier.

So I agree about `GslPointerInit`.

As for the second one, it seems like `GslOwnerTemporaryInit` would be more 
fitting -- WDYT? It is an initialization of a temporary that has a gsl::Owner 
type.



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:16
+
+struct [[gsl::Owner(int)]] T {
+  T();

xazax.hun wrote:
> gribozavr wrote:
> > Can `T` and `MyOwner` be the same type?
> > 
> > It is confusing to have two -- for example, `toOwner()` returning `T` 
> > instead of `MyOwner` is confusing.
> I agree that T might not be a great name. The reason why we have two types 
> because one can be converted to a Pointer using a conversion operator the 
> other can be converted using a one argument non-explicit constructor. These 
> two are generating different ASTs, thus I wanted to test both ways. 
Please explain this distinction in the comments in the test. If you didn't tell 
me just now, I would never know.

Maybe it is also a good idea to split the MyPointer type then, let each owner 
have its own pointer. Right now having one pointer with two owners is 
confusing, it suggests that owners are somehow related, but they aren't.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64256/new/

https://reviews.llvm.org/D64256



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


[PATCH] D64409: [libclang] Fix hang in release / assertion in debug when evaluating value-dependent types.

2019-07-09 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio created this revision.
emilio added reviewers: Anastasia, arphaman.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.
emilio edited the summary of this revision.

Expression evaluator doesn't work in value-dependent types, so ensure that the
precondition it asserts holds.

This fixes https://bugs.llvm.org/show_bug.cgi?id=42532.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64409

Files:
  clang/test/Index/evaluate-cursor.cpp
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3782,6 +3782,8 @@
 return nullptr;
 
   expr = expr->IgnoreParens();
+  if (expr->isValueDependent())
+return nullptr;
   if (!expr->EvaluateAsRValue(ER, ctx))
 return nullptr;
 
Index: clang/test/Index/evaluate-cursor.cpp
===
--- clang/test/Index/evaluate-cursor.cpp
+++ clang/test/Index/evaluate-cursor.cpp
@@ -21,6 +21,11 @@
 
 long long HUGE_NEG = -(1ll << 35);
 
+template  class e {
+  using f = d;
+  static const auto g = alignof(f);
+};
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -42,3 +47,9 @@
 // CHECK-LONG: unsigned, Value: 1152921504606846976
 // CHECK-LONG: unsigned, Value: 9223372036854775808
 // CHECK-LONG: Value: -34359738368
+
+// RUN: c-index-test -evaluate-cursor-at=%s:18:20 \
+// RUN:-evaluate-cursor-at=%s:20:20 \
+// RUN:-evaluate-cursor-at=%s:26:21 \
+// RUN:-std=c++11 %s | FileCheck -check-prefix=CHECK-DOES-NOT-CRASH %s
+// CHECK-DOES-NOT-CRASH: Not Evaluatable


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3782,6 +3782,8 @@
 return nullptr;
 
   expr = expr->IgnoreParens();
+  if (expr->isValueDependent())
+return nullptr;
   if (!expr->EvaluateAsRValue(ER, ctx))
 return nullptr;
 
Index: clang/test/Index/evaluate-cursor.cpp
===
--- clang/test/Index/evaluate-cursor.cpp
+++ clang/test/Index/evaluate-cursor.cpp
@@ -21,6 +21,11 @@
 
 long long HUGE_NEG = -(1ll << 35);
 
+template  class e {
+  using f = d;
+  static const auto g = alignof(f);
+};
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -42,3 +47,9 @@
 // CHECK-LONG: unsigned, Value: 1152921504606846976
 // CHECK-LONG: unsigned, Value: 9223372036854775808
 // CHECK-LONG: Value: -34359738368
+
+// RUN: c-index-test -evaluate-cursor-at=%s:18:20 \
+// RUN:-evaluate-cursor-at=%s:20:20 \
+// RUN:-evaluate-cursor-at=%s:26:21 \
+// RUN:-std=c++11 %s | FileCheck -check-prefix=CHECK-DOES-NOT-CRASH %s
+// CHECK-DOES-NOT-CRASH: Not Evaluatable
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64410: [WIP] Intrinsics side effects

2019-07-09 Thread Momchil Velikov via Phabricator via cfe-commits
chill created this revision.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls, 
javed.absar.
Herald added projects: clang, LLVM.

Change-Id: I49f5612ce6899004fa84b9a83c34dcd2d9af8224

Consistent types and naming for AArch64 target features (NFC)

Change-Id: I6bac2672de675a6e1c9c8867ed81bef879adc417

[AArch64] Add support for Transactional Memory Extension (TME)

TME is a future architecture technology, documented in

https://developer.arm.com/architectures/cpu-architecture/a-profile/exploration-tools
https://developer.arm.com/docs/ddi0601/a

This patch adds support for the TME instructions TSTART, TTEST, TCOMMIT, and
TCANCEL and the target feature/arch extension "tme".

It alaso implements TME builtin functions, defined in ACLE vX.Y spec.

Change-Id: If77e296a68d1e30d584808677b1ce96be1ac2420


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64410

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/aarch64-tme-errors.c
  clang/test/CodeGen/aarch64-tme-tcancel-arg.cpp
  clang/test/CodeGen/aarch64-tme-tcancel-const-error.c
  clang/test/CodeGen/aarch64-tme-tcancel-range-error.c
  clang/test/CodeGen/aarch64-tme.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/AArch64TargetParser.h
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/test/CodeGen/AArch64/tme.ll
  llvm/test/MC/AArch64/tme-error.s
  llvm/test/MC/AArch64/tme.s
  llvm/test/MC/Disassembler/AArch64/tme.txt
  llvm/unittests/Support/TargetParserTest.cpp
  llvm/utils/TableGen/CodeGenDAGPatterns.cpp
  llvm/utils/TableGen/IntrinsicEmitter.cpp

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -685,7 +685,7 @@
 }
 
 if (!intrinsic.canThrow ||
-intrinsic.ModRef != CodeGenIntrinsic::ReadWriteMem ||
+(intrinsic.ModRef != CodeGenIntrinsic::ReadWriteMem && !intrinsic.hasSideEffects) ||
 intrinsic.isNoReturn || intrinsic.isCold || intrinsic.isNoDuplicate ||
 intrinsic.isConvergent || intrinsic.isSpeculatable) {
   OS << "  const Attribute::AttrKind Atts[] = {";
@@ -727,6 +727,8 @@
 
   switch (intrinsic.ModRef) {
   case CodeGenIntrinsic::NoMem:
+if (intrinsic.hasSideEffects)
+  break;
 if (addComma)
   OS << ",";
 OS << "Attribute::ReadNone";
Index: llvm/utils/TableGen/CodeGenDAGPatterns.cpp
===
--- llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -2779,7 +2779,7 @@
 // chain.
 if (Int.IS.RetVTs.empty())
   Operator = getDAGPatterns().get_intrinsic_void_sdnode();
-else if (Int.ModRef != CodeGenIntrinsic::NoMem)
+else if (Int.ModRef != CodeGenIntrinsic::NoMem || Int.hasSideEffects)
   // Has side-effects, requires chain.
   Operator = getDAGPatterns().get_intrinsic_w_chain_sdnode();
 else // Otherwise, no chain.
Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -1118,6 +1118,7 @@
   {"rcpc", "norcpc", "+rcpc", "-rcpc" },
   {"rng", "norng", "+rand", "-rand"},
   {"memtag", "nomemtag", "+mte", "-mte"},
+  {"tme", "notme", "+tme", "-tme"},
   {"ssbs", "nossbs", "+ssbs", "-ssbs"},
   {"sb", "nosb", "+sb", "-sb"},
   {"predres", "nopredres", "+predres", "-predres"}
Index: llvm/test/MC/Disassembler/AArch64/tme.txt
===
--- /dev/null
+++ llvm/test/MC/Disassembler/AArch64/tme.txt
@@ -0,0 +1,19 @@
+# Tests for transaction memory extension instructions
+# RUN: llvm-mc -triple=aarch64 -mattr=+tme   -disassemble < %s  | FileCheck %s
+# RUN: not llvm-mc -triple=aarch64 -mattr=-tme   -disassemble < %s 2>&1 | FileCheck %s --check-prefix=NOTME
+
+[0x63,0x30,0x23,0xd5]
+[0x64,0x31,0x23,0xd5]
+[0x7f,0x30,0x03,0xd5]
+[0x80,0x46,0x62,0xd4]
+
+# CHECK: tstart x3
+# CHECK: ttest  x4
+# CHECK: tcommit
+# CHECK: tcancel #0x1234
+
+# NOTEME: mrs
+# NOTEME-NEXT: mrs
+ NOTEME-NEXT: msr
+# NOTME:  warning: invalid instruction encoding
+# NOTME-NEXT: [0x80,0x46,0x62,0xd4]
Index: llvm/test/MC/AArch64/tme.s
==

[PATCH] D64410: [WIP] Intrinsics side effects

2019-07-09 Thread Momchil Velikov via Phabricator via cfe-commits
chill abandoned this revision.
chill added a comment.

I fail at arcanist.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64410/new/

https://reviews.llvm.org/D64410



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


r365479 - [Syntax] Move roles into a separate enum

2019-07-09 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Jul  9 06:31:43 2019
New Revision: 365479

URL: http://llvm.org/viewvc/llvm-project?rev=365479&view=rev
Log:
[Syntax] Move roles into a separate enum

To align with reviewer's suggestions.

Modified:
cfe/trunk/include/clang/Tooling/Syntax/Nodes.h
cfe/trunk/include/clang/Tooling/Syntax/Tree.h
cfe/trunk/lib/Tooling/Syntax/BuildTree.cpp
cfe/trunk/lib/Tooling/Syntax/Nodes.cpp
cfe/trunk/lib/Tooling/Syntax/Tree.cpp
cfe/trunk/unittests/Tooling/Syntax/TreeTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Syntax/Nodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Syntax/Nodes.h?rev=365479&r1=365478&r2=365479&view=diff
==
--- cfe/trunk/include/clang/Tooling/Syntax/Nodes.h (original)
+++ cfe/trunk/include/clang/Tooling/Syntax/Nodes.h Tue Jul  9 06:31:43 2019
@@ -31,6 +31,18 @@ enum class NodeKind : uint16_t {
 /// For debugging purposes.
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, NodeKind K);
 
+/// A relation between a parent and child node. Used for implementing 
accessors.
+enum class NodeRole : uint8_t {
+  // A node without a parent.
+  Detached,
+  // Children of an unknown semantic nature, e.g. skipped tokens, comments.
+  Unknown,
+  // FIXME: should this be shared for all other nodes with braces, e.g. init
+  //lists?
+  CompoundStatement_lbrace,
+  CompoundStatement_rbrace
+};
+
 /// A root node for a translation unit. Parent is always null.
 class TranslationUnit final : public Tree {
 public:
@@ -73,11 +85,6 @@ public:
   }
   syntax::Leaf *lbrace();
   syntax::Leaf *rbrace();
-
-  struct Roles {
-static constexpr NodeRole lbrace = 1;
-static constexpr NodeRole rbrace = 2;
-  };
 };
 
 } // namespace syntax

Modified: cfe/trunk/include/clang/Tooling/Syntax/Tree.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Syntax/Tree.h?rev=365479&r1=365478&r2=365479&view=diff
==
--- cfe/trunk/include/clang/Tooling/Syntax/Tree.h (original)
+++ cfe/trunk/include/clang/Tooling/Syntax/Tree.h Tue Jul  9 06:31:43 2019
@@ -66,17 +66,7 @@ private:
 class Tree;
 class TreeBuilder;
 enum class NodeKind : uint16_t;
-
-/// Represents a relation of this node to its parent, e.g. 'lbrace inside a
-/// compound statement'.
-///
-/// Each node type defines a set of roles for its children.
-using NodeRole = uint8_t;
-
-/// Role for detached nodes, i.e. the ones that do not have parent nodes.
-constexpr NodeRole NodeRoleDetached = 0;
-/// Role for children of unknown semantic nature, e.g. skipped tokens, 
comments.
-constexpr NodeRole NodeRoleUnknown = 255;
+enum class NodeRole : uint8_t;
 
 /// A node in a syntax tree. Each node is either a Leaf (representing tokens) 
or
 /// a Tree (representing language constructrs).
@@ -84,12 +74,10 @@ class Node {
 public:
   /// Newly created nodes are detached from a tree, parent and sibling links 
are
   /// set when the node is added as a child to another one.
-  Node(NodeKind Kind)
-  : Parent(nullptr), NextSibling(nullptr),
-Kind(static_cast(Kind)), Role(NodeRoleDetached) {}
+  Node(NodeKind Kind);
 
   NodeKind kind() const { return static_cast(Kind); }
-  NodeRole role() const { return Role; }
+  NodeRole role() const { return static_cast(Role); }
 
   const Tree *parent() const { return Parent; }
   Tree *parent() { return Parent; }

Modified: cfe/trunk/lib/Tooling/Syntax/BuildTree.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Syntax/BuildTree.cpp?rev=365479&r1=365478&r2=365479&view=diff
==
--- cfe/trunk/lib/Tooling/Syntax/BuildTree.cpp (original)
+++ cfe/trunk/lib/Tooling/Syntax/BuildTree.cpp Tue Jul  9 06:31:43 2019
@@ -170,7 +170,7 @@ private:
 /// A with a role that should be assigned to it when adding to a parent.
 struct NodeAndRole {
   explicit NodeAndRole(syntax::Node *Node)
-  : Node(Node), Role(NodeRoleUnknown) {}
+  : Node(Node), Role(NodeRole::Unknown) {}
 
   syntax::Node *Node;
   NodeRole Role;
@@ -221,10 +221,12 @@ public:
   }
 
   bool WalkUpFromCompoundStmt(CompoundStmt *S) {
-using Roles = syntax::CompoundStatement::Roles;
+using NodeRole = syntax::NodeRole;
 
-Builder.markChildToken(S->getLBracLoc(), tok::l_brace, Roles::lbrace);
-Builder.markChildToken(S->getRBracLoc(), tok::r_brace, Roles::rbrace);
+Builder.markChildToken(S->getLBracLoc(), tok::l_brace,
+   NodeRole::CompoundStatement_lbrace);
+Builder.markChildToken(S->getRBracLoc(), tok::r_brace,
+   NodeRole::CompoundStatement_rbrace);
 
 Builder.foldNode(Builder.getRange(S),
  new (allocator()) syntax::CompoundStatement);

Modified: cfe/trunk/lib/Tooling/Syntax/Nodes.cpp
URL: 
http://llvm.o

r365480 - [ItaniumMangle] Refactor long double/__float128 mangling and fix the mangled code

2019-07-09 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Tue Jul  9 06:32:26 2019
New Revision: 365480

URL: http://llvm.org/viewvc/llvm-project?rev=365480&view=rev
Log:
[ItaniumMangle] Refactor long double/__float128 mangling and fix the mangled 
code

In gcc PowerPC, long double has 3 mangling schemes:

-mlong-double-64: `e`
-mlong-double-128 -mabi=ibmlongdouble: `g`
-mlong-double-128 -mabi=ieeelongdouble: `u9__ieee128` (gcc <= 8.1: 
`U10__float128`)

The current useFloat128ManglingForLongDouble() bisection is not suitable
when we support -mlong-double-128 in clang (D64277). Replace
useFloat128ManglingForLongDouble() with getLongDoubleMangling() and
getFloat128Mangling() to allow 3 mangling schemes.

I also deleted the `getTriple().isOSBinFormatELF()` check (the Darwin
support has gone: https://reviews.llvm.org/D50988).

For x86, change the mangled code of __float128 from `U10__float128` to `g`. 
`U10__float128` was wrongly copied from PowerPC.
The test will be added to `test/CodeGen/x86-long-double.cpp` in D64277.

Reviewed By: erichkeane

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

Modified:
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/Basic/Targets/PPC.h
cfe/trunk/lib/Basic/Targets/SystemZ.h
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/test/CodeGenCXX/float128-declarations.cpp

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=365480&r1=365479&r2=365480&view=diff
==
--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Tue Jul  9 06:32:26 2019
@@ -599,9 +599,11 @@ public:
 return *Float128Format;
   }
 
-  /// Return true if the 'long double' type should be mangled like
-  /// __float128.
-  virtual bool useFloat128ManglingForLongDouble() const { return false; }
+  /// Return the mangled code of long double.
+  virtual const char *getLongDoubleMangling() const { return "e"; }
+
+  /// Return the mangled code of __float128.
+  virtual const char *getFloat128Mangling() const { return "g"; }
 
   /// Return the value for the C99 FLT_EVAL_METHOD macro.
   virtual unsigned getFloatEvalMethod() const { return 0; }

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=365480&r1=365479&r2=365480&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Jul  9 06:32:26 2019
@@ -2608,30 +2608,19 @@ void CXXNameMangler::mangleType(const Bu
 Out << 'd';
 break;
   case BuiltinType::LongDouble: {
-bool UseFloat128Mangling =
-getASTContext().getTargetInfo().useFloat128ManglingForLongDouble();
-if (getASTContext().getLangOpts().OpenMP &&
-getASTContext().getLangOpts().OpenMPIsDevice) {
-  UseFloat128Mangling = getASTContext()
-.getAuxTargetInfo()
-->useFloat128ManglingForLongDouble();
-}
-Out << (UseFloat128Mangling ? 'g' : 'e');
+const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&
+   getASTContext().getLangOpts().OpenMPIsDevice
+   ? getASTContext().getAuxTargetInfo()
+   : &getASTContext().getTargetInfo();
+Out << TI->getLongDoubleMangling();
 break;
   }
   case BuiltinType::Float128: {
-bool UseFloat128Mangling =
-getASTContext().getTargetInfo().useFloat128ManglingForLongDouble();
-if (getASTContext().getLangOpts().OpenMP &&
-getASTContext().getLangOpts().OpenMPIsDevice) {
-  UseFloat128Mangling = getASTContext()
-.getAuxTargetInfo()
-->useFloat128ManglingForLongDouble();
-}
-if (UseFloat128Mangling)
-  Out << "U10__float128"; // Match the GCC mangling
-else
-  Out << 'g';
+const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&
+   getASTContext().getLangOpts().OpenMPIsDevice
+   ? getASTContext().getAuxTargetInfo()
+   : &getASTContext().getTargetInfo();
+Out << TI->getFloat128Mangling();
 break;
   }
   case BuiltinType::NullPtr:

Modified: cfe/trunk/lib/Basic/Targets/PPC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.h?rev=365480&r1=365479&r2=365480&view=diff
==
--- cfe/trunk/lib/Basic/Targets/PPC.h (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.h Tue Jul  9 06:32:26 2019
@@ -314,11 +314,14 @@ public:
 
   bool hasSjLjLowering() const override { return true; }
 
-  bool useFloat128ManglingForLongDouble() const o

[PATCH] D64276: [ItaniumMangle] Refactor long double/__float128 mangling and fix the mangled code

2019-07-09 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365480: [ItaniumMangle] Refactor long double/__float128 
mangling and fix the mangled… (authored by MaskRay, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64276/new/

https://reviews.llvm.org/D64276

Files:
  cfe/trunk/include/clang/Basic/TargetInfo.h
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/Basic/Targets/PPC.h
  cfe/trunk/lib/Basic/Targets/SystemZ.h
  cfe/trunk/lib/Basic/Targets/X86.h
  cfe/trunk/test/CodeGenCXX/float128-declarations.cpp

Index: cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
===
--- cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
+++ cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
@@ -84,15 +84,15 @@
 // CHECK-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global fp128 0xL40040800
 // CHECK-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x fp128]
 // CHECK-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x fp128] [fp128 0xL3FFF, fp128 0xL40008000, fp128 0xL4025176592E0]
-// CHECK-DAG: define internal fp128 @_ZN12_GLOBAL__N_16func1nERKU10__float128(fp128*
+// CHECK-DAG: define internal fp128 @_ZN12_GLOBAL__N_16func1nERKu9__ieee128(fp128*
 // CHECK-DAG: @f1f = global fp128 0xL
 // CHECK-DAG: @f2f = global fp128 0xL40040333
 // CHECK-DAG: @arr1f = global [10 x fp128]
 // CHECK-DAG: @arr2f = global [3 x fp128] [fp128 0xLBFFF, fp128 0xLC0008000, fp128 0xLC025176592E0]
-// CHECK-DAG: declare fp128 @_Z6func1fU10__float128(fp128)
-// CHECK-DAG: define linkonce_odr void @_ZN2C1C2EU10__float128(%class.C1* %this, fp128 %arg)
-// CHECK-DAG: define linkonce_odr fp128 @_ZN2C16func2cEU10__float128(fp128 %arg)
-// CHECK-DAG: define linkonce_odr fp128 @_Z6func1tIU10__float128ET_S0_(fp128 %arg)
+// CHECK-DAG: declare fp128 @_Z6func1fu9__ieee128(fp128)
+// CHECK-DAG: define linkonce_odr void @_ZN2C1C2Eu9__ieee128(%class.C1* %this, fp128 %arg)
+// CHECK-DAG: define linkonce_odr fp128 @_ZN2C16func2cEu9__ieee128(fp128 %arg)
+// CHECK-DAG: define linkonce_odr fp128 @_Z6func1tIu9__ieee128ET_S0_(fp128 %arg)
 // CHECK-DAG: @__const.main.s1 = private unnamed_addr constant %struct.S1 { fp128 0xL40060800 }
 // CHECK-DAG: store fp128 0xLF0AFD0EBFF292DCE42E0B38CDD83F26F, fp128* %f1l, align 16
 // CHECK-DAG: store fp128 0xL8000, fp128* %f2l, align 16
Index: cfe/trunk/lib/AST/ItaniumMangle.cpp
===
--- cfe/trunk/lib/AST/ItaniumMangle.cpp
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp
@@ -2608,30 +2608,19 @@
 Out << 'd';
 break;
   case BuiltinType::LongDouble: {
-bool UseFloat128Mangling =
-getASTContext().getTargetInfo().useFloat128ManglingForLongDouble();
-if (getASTContext().getLangOpts().OpenMP &&
-getASTContext().getLangOpts().OpenMPIsDevice) {
-  UseFloat128Mangling = getASTContext()
-.getAuxTargetInfo()
-->useFloat128ManglingForLongDouble();
-}
-Out << (UseFloat128Mangling ? 'g' : 'e');
+const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&
+   getASTContext().getLangOpts().OpenMPIsDevice
+   ? getASTContext().getAuxTargetInfo()
+   : &getASTContext().getTargetInfo();
+Out << TI->getLongDoubleMangling();
 break;
   }
   case BuiltinType::Float128: {
-bool UseFloat128Mangling =
-getASTContext().getTargetInfo().useFloat128ManglingForLongDouble();
-if (getASTContext().getLangOpts().OpenMP &&
-getASTContext().getLangOpts().OpenMPIsDevice) {
-  UseFloat128Mangling = getASTContext()
-.getAuxTargetInfo()
-->useFloat128ManglingForLongDouble();
-}
-if (UseFloat128Mangling)
-  Out << "U10__float128"; // Match the GCC mangling
-else
-  Out << 'g';
+const TargetInfo *TI = getASTContext().getLangOpts().OpenMP &&
+   getASTContext().getLangOpts().OpenMPIsDevice
+   ? getASTContext().getAuxTargetInfo()
+   : &getASTContext().getTargetInfo();
+Out << TI->getFloat128Mangling();
 break;
   }
   case BuiltinType::NullPtr:
Index: cfe/trunk/lib/Basic/Targets/X86.h
===
--- cfe/trunk/lib/Basic/Targets/X86.h
+++ cfe/trunk/lib/Basic/Targets/X86.h
@@ -848,7 +848,7 @@
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
   }
 
-  bool 

[PATCH] D61637: [Syntax] Introduce syntax trees

2019-07-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:43
+
+  struct Roles {
+static constexpr NodeRole eof = 1;

ilya-biryukov wrote:
> sammccall wrote:
> > we discussed offline - with 256 values, is it possible to come up with a 
> > single role enum that would cover all node types?
> > 
> > Advantage would be that certain logic could be generic (e.g. `Recovery` 
> > could be a role for leaves under any Tree, `LParen`/`RParen`/`MainKeyword` 
> > could apply to if, while, switch...)
> Will need to do some estimations to answer this properly, but my gut feeling 
> is that 256 could end up being too limiting in the long run (I would expect 
> each node to have at least one child, so without deduplication we can at 
> least as many roles as we have kinds).
> 
> Could imagine a two-level numbering scheme, though:
> - some generic roles like `lparen`, `rparen`, etc, take first `N` roles.
> - higher numbers are for node-specific roles (e.g. LHS or RHS of a 
> `BinaryExpr`).
> 
> But at that point, we probably don't have the benefits of a single enum.
> 
I think we misunderstood each other here... I think this is fairly important, 
and that we'd agreed on it in offline discussion. Didn't mean to leave it as an 
optional comment.

I'd be very surprised if 256 were too limiting. Indeed most nodes will have 
children, but most of them will not have unique roles. (And I would be 
surprised if we have 200 node types, but maybe not that surprised...).

If there's a more fundamental objection to merging these, I'd like to find some 
agreement before going further.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61637/new/

https://reviews.llvm.org/D61637



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


[PATCH] D64257: [clangd] Added highlighting for class and enum types

2019-07-09 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:38
   bool VisitNamedDecl(NamedDecl *ND) {
-// FIXME: (De)Constructors/operator need to be highlighted some other way.
+// Constructors have a TypePtr TagDecl that is a Function, therefore we 
need
+// to get constructors as a NamedDecl instead.

hokein wrote:
> I don't understand this comment -- when visiting the constructor AST, we get 
> a TagTypeLoc, and its underlying Decl is a `CXXConstructorDecl`
So the Constructor TypeLoc does not have a TagTypeDecl and is not a TagTypeLoc. 
When we get the TypePtr of the constructor it's a "FunctionProtoType" and there 
is no way to distinguish it from other functions. Therefore we need to get the 
constructor decls as NamedDecls..

The comment was written badly though. This version should be better now I hope.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64257/new/

https://reviews.llvm.org/D64257



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


[PATCH] D64257: [clangd] Added highlighting for class and enum types

2019-07-09 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 208670.
jvikstrom marked 4 inline comments as done.
jvikstrom added a comment.

No longer highlighting anonymous structs as types.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64257/new/

https://reviews.llvm.org/D64257

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -34,11 +34,13 @@
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
-  {HighlightingKind::Function, "Function"}};
+  {HighlightingKind::Function, "Function"},
+  {HighlightingKind::Class, "Class"},
+  {HighlightingKind::Enum, "Enum"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
-std::vector Toks =
-makeHighlightingTokens(Test.ranges(KindString.second), KindString.first);
+std::vector Toks = makeHighlightingTokens(
+Test.ranges(KindString.second), KindString.first);
 ExpectedTokens.insert(ExpectedTokens.end(), Toks.begin(), Toks.end());
   }
 
@@ -49,14 +51,14 @@
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
 R"cpp(
-  struct AS {
+  struct $Class[[AS]] {
 double SomeMember;
   };
   struct {
   } $Variable[[S]];
-  void $Function[[foo]](int $Variable[[A]]) {
+  void $Function[[foo]](int $Variable[[A]], $Class[[AS]] $Variable[[As]]) {
 auto $Variable[[VeryLongVariableName]] = 12312;
-AS $Variable[[AA]];
+$Class[[AS]] $Variable[[AA]];
 auto $Variable[[L]] = $Variable[[AA]].SomeMember + $Variable[[A]];
 auto $Variable[[FN]] = [ $Variable[[AA]]](int $Variable[[A]]) -> void {};
 $Variable[[FN]](12312);
@@ -68,13 +70,43 @@
   void $Function[[foo]]() {
 auto $Variable[[Bou]] = $Function[[Gah]];
   }
+  struct $Class[[A]] {
+void $Function[[abc]]();
+  };
 )cpp",
 R"cpp(
-  struct A {
-A();
-~A();
-void $Function[[abc]]();
-void operator<<(int);
+  namespace abc {
+template
+struct $Class[[A]] {
+  T t;
+};
+  }
+  template
+  struct $Class[[C]] : abc::A {
+typename T::A* D;
+  };
+  abc::$Class[[A]] $Variable[[AA]];
+  typedef abc::$Class[[A]] AAA;
+  struct $Class[[B]] {
+$Class[[B]]();
+~$Class[[B]]();
+void operator<<($Class[[B]]);
+$Class[[AAA]] AA;
+  };
+  $Class[[B]]::$Class[[B]]() {}
+  $Class[[B]]::~$Class[[B]]() {}
+  void $Function[[f]] () {
+$Class[[B]] $Variable[[BB]] = $Class[[B]]();
+$Variable[[BB]].~$Class[[B]]();
+$Class[[B]]();
+  }
+)cpp",
+R"cpp(
+  enum class $Enum[[E]] {};
+  enum $Enum[[EE]] {};
+  struct $Class[[A]] {
+$Enum[[E]] EEE;
+$Enum[[EE]] ;
   };
 )cpp"};
   for (const auto &TestCase : TestCases) {
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -10,6 +10,12 @@
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
 # CHECK-NEXT:  ]
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.class.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.enum.cpp"
+# CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 ---
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -26,6 +26,8 @@
 enum class HighlightingKind {
   Variable = 0,
   Function,
+  Class,
+  Enum,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -11,6 +11,8 @@
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 
 namespace clang {
@@ -35,7 +37,15 @@
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
-// FIXME: (

[PATCH] D64257: [clangd] Added highlighting for class and enum types

2019-07-09 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 208671.
jvikstrom added a comment.

Changed comment in addToken.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64257/new/

https://reviews.llvm.org/D64257

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -34,11 +34,13 @@
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
-  {HighlightingKind::Function, "Function"}};
+  {HighlightingKind::Function, "Function"},
+  {HighlightingKind::Class, "Class"},
+  {HighlightingKind::Enum, "Enum"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
-std::vector Toks =
-makeHighlightingTokens(Test.ranges(KindString.second), KindString.first);
+std::vector Toks = makeHighlightingTokens(
+Test.ranges(KindString.second), KindString.first);
 ExpectedTokens.insert(ExpectedTokens.end(), Toks.begin(), Toks.end());
   }
 
@@ -49,14 +51,14 @@
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
 R"cpp(
-  struct AS {
+  struct $Class[[AS]] {
 double SomeMember;
   };
   struct {
   } $Variable[[S]];
-  void $Function[[foo]](int $Variable[[A]]) {
+  void $Function[[foo]](int $Variable[[A]], $Class[[AS]] $Variable[[As]]) {
 auto $Variable[[VeryLongVariableName]] = 12312;
-AS $Variable[[AA]];
+$Class[[AS]] $Variable[[AA]];
 auto $Variable[[L]] = $Variable[[AA]].SomeMember + $Variable[[A]];
 auto $Variable[[FN]] = [ $Variable[[AA]]](int $Variable[[A]]) -> void {};
 $Variable[[FN]](12312);
@@ -68,13 +70,43 @@
   void $Function[[foo]]() {
 auto $Variable[[Bou]] = $Function[[Gah]];
   }
+  struct $Class[[A]] {
+void $Function[[abc]]();
+  };
 )cpp",
 R"cpp(
-  struct A {
-A();
-~A();
-void $Function[[abc]]();
-void operator<<(int);
+  namespace abc {
+template
+struct $Class[[A]] {
+  T t;
+};
+  }
+  template
+  struct $Class[[C]] : abc::A {
+typename T::A* D;
+  };
+  abc::$Class[[A]] $Variable[[AA]];
+  typedef abc::$Class[[A]] AAA;
+  struct $Class[[B]] {
+$Class[[B]]();
+~$Class[[B]]();
+void operator<<($Class[[B]]);
+$Class[[AAA]] AA;
+  };
+  $Class[[B]]::$Class[[B]]() {}
+  $Class[[B]]::~$Class[[B]]() {}
+  void $Function[[f]] () {
+$Class[[B]] $Variable[[BB]] = $Class[[B]]();
+$Variable[[BB]].~$Class[[B]]();
+$Class[[B]]();
+  }
+)cpp",
+R"cpp(
+  enum class $Enum[[E]] {};
+  enum $Enum[[EE]] {};
+  struct $Class[[A]] {
+$Enum[[E]] EEE;
+$Enum[[EE]] ;
   };
 )cpp"};
   for (const auto &TestCase : TestCases) {
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -10,6 +10,12 @@
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
 # CHECK-NEXT:  ]
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.class.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.enum.cpp"
+# CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 ---
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -26,6 +26,8 @@
 enum class HighlightingKind {
   Variable = 0,
   Function,
+  Class,
+  Enum,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -11,6 +11,8 @@
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 
 namespace clang {
@@ -35,7 +37,15 @@
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
-// FIXME: (De)Constructors/operator need to be highlighted some other way.
+ 

[PATCH] D63773: [clangd] dummy variable extraction on a function scope

2019-07-09 Thread Nico Weber via Phabricator via cfe-commits
thakis added inline comments.



Comment at: clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt:20
   SwapIfBranches.cpp
+  ExtractVariable.cpp
 

(nit: keep in alphabetical order)


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63773/new/

https://reviews.llvm.org/D63773



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


r365485 - [OPENMP]Fix the float point semantics handling on the device.

2019-07-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue Jul  9 07:09:53 2019
New Revision: 365485

URL: http://llvm.org/viewvc/llvm-project?rev=365485&view=rev
Log:
[OPENMP]Fix the float point semantics handling on the device.

The device should use the same float point representation as the host.
Previous patch fixed the handling of the sizes of the float point types,
but did not fixed the fp semantics. This patch makes target device to
use the host fp semantics. this is required for the correct data
transfer between host and device and correct codegen.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=365485&r1=365484&r2=365485&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jul  9 07:09:53 2019
@@ -1524,8 +1524,16 @@ const llvm::fltSemantics &ASTContext::ge
 return Target->getHalfFormat();
   case BuiltinType::Float:  return Target->getFloatFormat();
   case BuiltinType::Double: return Target->getDoubleFormat();
-  case BuiltinType::LongDouble: return Target->getLongDoubleFormat();
-  case BuiltinType::Float128:   return Target->getFloat128Format();
+  case BuiltinType::LongDouble:
+if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
+&Target->getLongDoubleFormat() != &AuxTarget->getLongDoubleFormat())
+  return AuxTarget->getLongDoubleFormat();
+return Target->getLongDoubleFormat();
+  case BuiltinType::Float128:
+if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
+&Target->getFloat128Format() != &AuxTarget->getFloat128Format())
+  return AuxTarget->getFloat128Format();
+return Target->getFloat128Format();
   }
 }
 

Modified: cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c?rev=365485&r1=365484&r2=365485&view=diff
==
--- cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c (original)
+++ cfe/trunk/test/OpenMP/nvptx_asm_delayed_diags.c Tue Jul  9 07:09:53 2019
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fopenmp -x c -triple i386-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only -Wuninitialized
-// RUN: %clang_cc1 -verify -DDIAGS -DIMMEDIATE -fopenmp -x c -triple 
nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only -Wuninitialized
-// RUN: %clang_cc1 -verify -DDIAGS -DDELAYED -fopenmp -x c -triple 
nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only -Wuninitialized
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx-unknown-unknown 
-aux-triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda %s 
-fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only 
-Wuninitialized
+// RUN: %clang_cc1 -verify -DDIAGS -DIMMEDIATE -fopenmp -x c -triple 
nvptx-unknown-unknown -aux-triple i386-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only -Wuninitialized
+// RUN: %clang_cc1 -verify -DDIAGS -DDELAYED -fopenmp -x c -triple 
nvptx-unknown-unknown -aux-triple i386-unknown-unknown 
-fopenmp-targets=nvptx-nvidia-cuda %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-x86-host.bc -fsyntax-only -Wuninitialized
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 

Modified: cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp?rev=365485&r1=365484&r2=365485&view=diff
==
--- cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_unsupported_type_codegen.cpp Tue Jul  9 
07:09:53 2019
@@ -1,11 +1,11 @@
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux 
-fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 
-aux-triple x86_64-unknown-linux -fopenmp-targets=nvptx64-nvidia-cuda 
-aux-triple x86_64-unknown-linux -emit-llvm %s -fopenmp-is-device 
-fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown 

[PATCH] D64375: [OpenMP][Docs] Provide implementation status details

2019-07-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/docs/OpenMPSupport.rst:161
++--+--+--++
+| memory mangagement   | memory allocators 
   | claimed  ||
++--+--+--++

Done



Comment at: clang/docs/OpenMPSupport.rst:163
++--+--+--++
+| memory mangagement   | allocate directive and allocate clause
   | claimed  | r355614,r335952|
++--+--+--++

Done



Comment at: clang/docs/OpenMPSupport.rst:175-177
+| task extension   | clause: depend on the taskwait construct  
   | claimed  ||
++--+--+--++
+| task extension   | depend objects and detachable tasks   
   | claimed  ||

I don't remember anything related to these items. Seems to me, they are 
unclaimed



Comment at: clang/docs/OpenMPSupport.rst:201
++--+--+--++
+| device extension | support full 'defaultmap' functionality   
   | claimed  ||
++--+--+--++

Seems to me it is unclaimed



Comment at: clang/docs/OpenMPSupport.rst:205
++--+--+--++
+| device extension | clause: device_type   
   | claimed  ||
++--+--+--++

Can't find this in the standard.



Comment at: clang/docs/OpenMPSupport.rst:207
++--+--+--++
+| device extension | clause: in_reduction  
   | claimed  ||
++--+--+--++

Done.



Comment at: clang/docs/OpenMPSupport.rst:213
++--+--+--++
+| device extension | nested target declare 
   | claimed  | D51378 |
++--+--+--++

Done



Comment at: clang/docs/OpenMPSupport.rst:215
++--+--+--++
+| device extension | implicitly map 'this' (this[:1])  
   | claimed  | D55982 |
++--+--+--++

Done



Comment at: clang/docs/OpenMPSupport.rst:233
++--+--+--++
+| device extension | mapping lambda expression 
   | claimed  | D51107 

[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: test/OpenMP/nvptx_unsupported_type_codegen.cpp:79
 }
-
-// CHECK: define weak void 
@__omp_offloading_{{.+}}foo{{.+}}_l75([[BIGTYPE:.+]]*

ABataev wrote:
> MaskRay wrote:
> > ABataev wrote:
> > > MaskRay wrote:
> > > > ABataev wrote:
> > > > > MaskRay wrote:
> > > > > > @ABataev The mangling scheme of __float128 is broken on x86 before 
> > > > > > this patch. For some reason the two lines no longer apply.. I 
> > > > > > assume you can fix this test properly :)
> > > > > You mean, these lines are not generated anymore? If so, it means that 
> > > > > you broke compatibility between the host and device codegen with this 
> > > > > patch. 
> > > > The two lines are not generated. Can you help fix the test? The 
> > > > mangling scheme of __float128 is incorrect without this patch. If the 
> > > > test relies on that, it should be fixed. I know little about 
> > > > openmp+nvidia to understand what's going on..
> > > Sure, will try to send additional changes next week, most probably on 
> > > Monday. Does this work for you?
> > Thanks!
> Hi, I have a fix for the problem revealed with your patch, will commit it 
> tomorrow. After this, I hope, the problem with the test will disappear.
I fixed the problem, try to update the patch, the test should pass with your 
changes.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277



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


[PATCH] D64409: [libclang] Fix hang in release / assertion in debug when evaluating value-dependent types.

2019-07-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64409/new/

https://reviews.llvm.org/D64409



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


[PATCH] D64418: [Docs][OpenCL] Documentation of C++ for OpenCL mode

2019-07-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: svenvh, mantognini, stuart, neil.hickey.
Herald added subscribers: ebevhan, yaxunl.

Added documentation of C++ for OpenCL mode into Clang User Manual and Language 
Extensions document.


https://reviews.llvm.org/D64418

Files:
  docs/LanguageExtensions.rst
  docs/UsersManual.rst

Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -2397,7 +2397,8 @@
 This will produce a generic test.bc file that can be used in vendor toolchains
 to perform machine code generation.
 
-Clang currently supports OpenCL C language standards up to v2.0.
+Clang currently supports OpenCL C language standards up to v2.0. Starting from Clang9
+C++ mode is available for OpenCL (see :ref:``).
 
 OpenCL Specific Options
 ---
@@ -2756,6 +2757,45 @@
   enqueue query functions from `section 6.13.17.5
   `_.
 
+.. _opencl_cpp:
+
+C++ for OpenCL
+--
+
+Starting from Clang9 kernel code can contain C++17 features: classes, templates,
+function overloading, type deduction, etc. Please note that this is not an
+implementation of `OpenCL C++
+`_ and
+there is no plan to support it in clang in any new releases in the near future.
+
+There are only a few restrictions on allowed C++ features, for detailed information
+please refer to documentation on Extensions (:doc:`LanguageExtensions`).
+
+Since C++ features are to be used on top of OpenCL C functionality all existing
+restrictions from OpenCL C v2.0 will inherently apply. All OpenCL C builtin types
+and function libraries are supported and can be used in the new mode.
+
+To enable the new mode pass the following command line option when compiling .cl
+file ``-cl-std=c++`` or ``-std=c++``.
+
+   .. code-block:: c++
+
+ template T add( T x, T y )
+ {
+   return x + y;
+ }
+
+ __kernel void test( __global float* a, __global float* b)
+ {
+   auto index = get_global_id(0);
+   a[index] = add(b[index], b[index+1]);
+ }
+
+
+   .. code-block:: console
+
+ clang -cl-std=c++ test.cl
+
 .. _target_features:
 
 Target-Specific Features and Limitations
Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1516,6 +1516,261 @@
 Query the presence of this new mangling with
 ``__has_feature(objc_protocol_qualifier_mangling)``.
 
+
+OpenCL Features
+===
+
+C++ for OpenCL
+--
+
+This functionality is built on top of OpenCL C v2.0 and C++17. Regular C++
+features can be used in OpenCL kernel code. All functionality from OpenCL C
+is inherited. This section describes minor differences to OpenCL C and any
+limitations related to C++ support as well as interactions between OpenCL and
+C++ features that are not documented elsewhere.
+
+Restrictions to C++17
+^
+
+The following features are not supported:
+- Virtual functions
+- ``dynamic_cast`` operator
+- Only placement ``new``/``delete`` operators
+- Standard C++ libraries. Currently there is no solution for alternative
+libraries provided. Future release will feature library support.
+
+
+Interplay of OpenCL and C++ features
+
+
+Address space behavior
+""
+
+Address spaces are part of the type qualifiers. Therefore many rules are just
+inherited from the qualifier behavior documented in OpenCL C v2.0 s6.5 and
+Embedded C extension ISO/IEC JTC1 SC22 WG14 N1021 s3.1. Note that since the
+address space behavior in C++ is not documented formally yet Clang extends
+existing concept from C and OpenCL. For example conversion rules are extended
+from qualification conversions but the compatibility is determined using sets
+and overlapping from Embedded C (ISO/IEC JTC1 SC22 WG14 N1021 s3.1.3). For OpenCL
+it means that implicit conversions are allowed from named to generic but not vice
+versa (OpenCL C v2.0 s6.5.5) except for constant address space. Most of the rules
+are built on top of this behavior.
+
+**Casts**
+
+C style cast will follow OpenCL C v2.0 rules (s6.5.5). All cast operators will
+permit implicit conversion to generic. However converting from named address
+spaces to generic can only be done using ``addrspace_cast``. Note that
+conversions between ``__constant`` and any other is still disallowed.
+
+.. _opencl_cpp_addrsp_deduction:
+**Deduction**
+
+Address spaces are not deduced for:
+- non-pointer/non-reference template parameters or any dependent types are except
+  for template specializations.
+- non-pointer/non-reference class members except for static data members that are
+  deduced to __global address space. 
+- non-pointer/non-reference alias declarations.
+- ``decltype

r365490 - [libclang] Fix hang in release / assertion in debug when evaluating value-dependent types.

2019-07-09 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Tue Jul  9 07:27:01 2019
New Revision: 365490

URL: http://llvm.org/viewvc/llvm-project?rev=365490&view=rev
Log:
[libclang] Fix hang in release / assertion in debug when evaluating 
value-dependent types.

Expression evaluator doesn't work in value-dependent types, so ensure that the
precondition it asserts holds.

This fixes https://bugs.llvm.org/show_bug.cgi?id=42532

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

Modified:
cfe/trunk/test/Index/evaluate-cursor.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/evaluate-cursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/evaluate-cursor.cpp?rev=365490&r1=365489&r2=365490&view=diff
==
--- cfe/trunk/test/Index/evaluate-cursor.cpp (original)
+++ cfe/trunk/test/Index/evaluate-cursor.cpp Tue Jul  9 07:27:01 2019
@@ -21,6 +21,11 @@ unsigned long long HUGE = 1ull << 63;
 
 long long HUGE_NEG = -(1ll << 35);
 
+template  class e {
+  using f = d;
+  static const auto g = alignof(f);
+};
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -42,3 +47,9 @@ long long HUGE_NEG = -(1ll << 35);
 // CHECK-LONG: unsigned, Value: 1152921504606846976
 // CHECK-LONG: unsigned, Value: 9223372036854775808
 // CHECK-LONG: Value: -34359738368
+
+// RUN: c-index-test -evaluate-cursor-at=%s:18:20 \
+// RUN:-evaluate-cursor-at=%s:20:20 \
+// RUN:-evaluate-cursor-at=%s:26:21 \
+// RUN:-std=c++11 %s | FileCheck -check-prefix=CHECK-DOES-NOT-CRASH %s
+// CHECK-DOES-NOT-CRASH: Not Evaluatable

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=365490&r1=365489&r2=365490&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue Jul  9 07:27:01 2019
@@ -3782,6 +3782,8 @@ static const ExprEvalResult* evaluateExp
 return nullptr;
 
   expr = expr->IgnoreParens();
+  if (expr->isValueDependent())
+return nullptr;
   if (!expr->EvaluateAsRValue(ER, ctx))
 return nullptr;
 


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


[PATCH] D64409: [libclang] Fix hang in release / assertion in debug when evaluating value-dependent types.

2019-07-09 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365490: [libclang] Fix hang in release / assertion in debug 
when evaluating value… (authored by emilio, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64409?vs=208658&id=208679#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64409/new/

https://reviews.llvm.org/D64409

Files:
  cfe/trunk/test/Index/evaluate-cursor.cpp
  cfe/trunk/tools/libclang/CIndex.cpp


Index: cfe/trunk/test/Index/evaluate-cursor.cpp
===
--- cfe/trunk/test/Index/evaluate-cursor.cpp
+++ cfe/trunk/test/Index/evaluate-cursor.cpp
@@ -21,6 +21,11 @@
 
 long long HUGE_NEG = -(1ll << 35);
 
+template  class e {
+  using f = d;
+  static const auto g = alignof(f);
+};
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -42,3 +47,9 @@
 // CHECK-LONG: unsigned, Value: 1152921504606846976
 // CHECK-LONG: unsigned, Value: 9223372036854775808
 // CHECK-LONG: Value: -34359738368
+
+// RUN: c-index-test -evaluate-cursor-at=%s:18:20 \
+// RUN:-evaluate-cursor-at=%s:20:20 \
+// RUN:-evaluate-cursor-at=%s:26:21 \
+// RUN:-std=c++11 %s | FileCheck -check-prefix=CHECK-DOES-NOT-CRASH %s
+// CHECK-DOES-NOT-CRASH: Not Evaluatable
Index: cfe/trunk/tools/libclang/CIndex.cpp
===
--- cfe/trunk/tools/libclang/CIndex.cpp
+++ cfe/trunk/tools/libclang/CIndex.cpp
@@ -3782,6 +3782,8 @@
 return nullptr;
 
   expr = expr->IgnoreParens();
+  if (expr->isValueDependent())
+return nullptr;
   if (!expr->EvaluateAsRValue(ER, ctx))
 return nullptr;
 


Index: cfe/trunk/test/Index/evaluate-cursor.cpp
===
--- cfe/trunk/test/Index/evaluate-cursor.cpp
+++ cfe/trunk/test/Index/evaluate-cursor.cpp
@@ -21,6 +21,11 @@
 
 long long HUGE_NEG = -(1ll << 35);
 
+template  class e {
+  using f = d;
+  static const auto g = alignof(f);
+};
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -42,3 +47,9 @@
 // CHECK-LONG: unsigned, Value: 1152921504606846976
 // CHECK-LONG: unsigned, Value: 9223372036854775808
 // CHECK-LONG: Value: -34359738368
+
+// RUN: c-index-test -evaluate-cursor-at=%s:18:20 \
+// RUN:-evaluate-cursor-at=%s:20:20 \
+// RUN:-evaluate-cursor-at=%s:26:21 \
+// RUN:-std=c++11 %s | FileCheck -check-prefix=CHECK-DOES-NOT-CRASH %s
+// CHECK-DOES-NOT-CRASH: Not Evaluatable
Index: cfe/trunk/tools/libclang/CIndex.cpp
===
--- cfe/trunk/tools/libclang/CIndex.cpp
+++ cfe/trunk/tools/libclang/CIndex.cpp
@@ -3782,6 +3782,8 @@
 return nullptr;
 
   expr = expr->IgnoreParens();
+  if (expr->isValueDependent())
+return nullptr;
   if (!expr->EvaluateAsRValue(ER, ctx))
 return nullptr;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64409: [libclang] Fix hang in release / assertion in debug when evaluating value-dependent types.

2019-07-09 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

Thanks for the review as always @Anastasia ^.^


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64409/new/

https://reviews.llvm.org/D64409



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


[PATCH] D64257: [clangd] Added highlighting for class and enum types

2019-07-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:38
   bool VisitNamedDecl(NamedDecl *ND) {
-// FIXME: (De)Constructors/operator need to be highlighted some other way.
+// Constructors have a TypePtr TagDecl that is a Function, therefore we 
need
+// to get constructors as a NamedDecl instead.

jvikstrom wrote:
> hokein wrote:
> > I don't understand this comment -- when visiting the constructor AST, we 
> > get a TagTypeLoc, and its underlying Decl is a `CXXConstructorDecl`
> So the Constructor TypeLoc does not have a TagTypeDecl and is not a 
> TagTypeLoc. When we get the TypePtr of the constructor it's a 
> "FunctionProtoType" and there is no way to distinguish it from other 
> functions. Therefore we need to get the constructor decls as NamedDecls..
> 
> The comment was written badly though. This version should be better now I 
> hope.
ah, I see, that make senses, thanks for the explanation.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:52
 
 if (ND->getDeclName().isEmpty())
   // Don't add symbols that don't have any length.

if you move this to `addToken` (and change function parameter type to 
`NamedDecl`), then you don't need the check on Line 79.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:73
+// elaborated types the actual type is highlighted as an inner TypeLoc.
+TL.getTypePtr()->dump();
+if (TL.getTypeLocClass() == TypeLoc::TypeLocClass::Elaborated)

nit: remove the debug dump.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:77
+
+if (TL.getTypePtr())
+  if (TagDecl *TD = TL.getTypePtr()->getAsTagDecl())

Again, you can save one cost of `TL.getTypePtr()`.

```
  if (const auto* TypePtr = TL.getTypePtr())
if (const auto* TD = TypePtr->getAsTagDecl())
```



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:87
   void addToken(SourceLocation Loc, const Decl *D) {
+// Destructors have a TypeLoc where the underlying TypePtr is a RecordDecl.
+if (isa(D)) {

how about?

```
We highlight class decls, constructor decls and destructor decls as `Class` 
type. The destructor decls are handled in `VisitTypeLoc` (we will visit a 
TypeLoc where the underlying Type is a CXXRecordDecl).
``` 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64257/new/

https://reviews.llvm.org/D64257



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


[PATCH] D64356: [OPENMP]Initial fix PR42392: Improve -Wuninitialized warnings for OpenMP programs.

2019-07-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked 3 inline comments as done.
ABataev added inline comments.



Comment at: lib/Analysis/CFG.cpp:4746-4750
+  D->for_each_used_expr([this, &B](Expr *E) {
+assert(E && "Expected expression.");
+if (CFGBlock *R = Visit(E))
+  B = R;
+  });

NoQ wrote:
> ABataev wrote:
> > NoQ wrote:
> > > Not sure, are these expressions actually evaluated in run-time when the 
> > > directive is hit? When i looked at a few AST dumps it seemed to me as if 
> > > these are just a few `DeclRefExpr`s that refer back to the captured 
> > > variables; they don't really do anything.
> > Some of them are real expressions, evaluated at the runtime. 
> > 
> > Some of them are the captured variables. But for some of those vars we need 
> > to create private copies, initialized with the values of the original 
> > variables. And we need to diagnose that the original captured variable is 
> > used without being initialized.
> > I'm going to extend this function to check all required expressions later. 
> > This is just an initial patch to setup the basic required functionality.
> Aha, ok, got it. So these are kinda like function arguments that are 
> evaluated before the call, outside the call.
> 
> My concern is that the CFG for these expressions need to appear only once: 
> either as part of the current CFG or as part of the CFG of the "outlined" 
> statement, but not in both. Otherwise any sort of inter-"procedure"-al 
> analysis over such CFG would mistakenly think that these statements are 
> evaluated twice.
> Aha, ok, got it. So these are kinda like function arguments that are 
> evaluated before the call, outside the call.

Well, a kind of.

> My concern is that the CFG for these expressions need to appear only once: 
> either as part of the current CFG or as part of the CFG of the "outlined" 
> statement, but not in both. Otherwise any sort of inter-"procedure"-al 
> analysis over such CFG would mistakenly think that these statements are 
> evaluated twice.

Agree, but currently they do not appear at all. Those expressions in most cases 
are not immdiate children of the OpenMP directive, they are children of OpenMP 
clauses, associated with the directives. And the function iterates through all 
the clauses to build the CFG for such expressions.



Comment at: lib/Analysis/CFG.cpp:4756-4757
+addLocalScopeAndDtors(S);
+  if (CFGBlock *R = addStmt(S))
+B = R;
+}

NoQ wrote:
> What you're saying here is "the statement is going to be executed at the 
> current moment of time, exactly once". Just curious, how accurate is this?
> 
> Generally it's perfectly fine drop some effects of the statement (eg., 
> atomicity). I'm not sure about things like `#pragma omp parallel` that may 
> evaluate the statement more than once, but it's not entirely inaccurate to 
> assume that the statement is executed once (on some systems it may as well be 
> true).
Do you suggest to exclude the bodies of the directives from the analysis?



Comment at: test/OpenMP/atomic_messages.c:5-9
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this 
warning}}
+#pragma omp atomic read
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used 
here}}
+}

NoQ wrote:
> Currently the CFG is as follows:
> ```lang=c++
> [B1]
>1: int x;
>2: argc
>3: x
>4: argc = x; // CapturedStmt
>5: #pragma omp atomic read 'argc = x;'
> ```
> I.e.,
> 1. Declare `x`;
> 2. Compute lvalue `argc`;
> 3. Compute lvalue `x`;
> 4. Draw the rest of the ~~owl~~ assignment operator. Ignore the whole 
> complexity with lvalue-to-rvalue casts that are expected to be there.
> 5. Suddenly realize that this whole thing was an OpenMP atomic read from the 
> start.
> 
> Step 4 actually looks pretty good to me, given that we treat `CapturedStmt` 
> as some sort of function call. I.e., we simply delegate the work of 
> evaluating the actual statement into an "outlined" function which has its 
> own, separate CFG that doesn't need to be squeezed into the current CFG. And 
> this other CFG is where we're going to have our implicit cast and stuff.
> 
> I don't understand the point of having a separate step 5. I just don't see 
> what extra work can be done here that wasn't already done on step 4. I'd 
> probably mildly prefer to have only one of those: either step 4 or (better 
> because it has more information) step 5. I don't mind having both though.
> 
> So i guess generally this CFG looks good to me. In particular, i can totally 
> work with it if i end up implementing OpenMP support in the Static Analyzer. 
> At the same time i'd probably be fine with a CFG that contains only steps 1 
> and 5. I need to see more examples :)
I'll investigate this and will add some CFG specific tests.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64356/new/

https://reviews

[PATCH] D64356: [OPENMP]Initial fix PR42392: Improve -Wuninitialized warnings for OpenMP programs.

2019-07-09 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added a comment.

In D64356#1574981 , @NoQ wrote:

> Ok, so i think i more or less understand where this is going and i like it! 
> My only concern about making sure that used-expressions don't appear in both 
> CFGs; and, even then, it's likely that i'm wrong.
>
> +@rsmith just in case he has any immediate thoughts on this.


What "both" CFGs do you mean?




Comment at: include/clang/AST/StmtOpenMP.h:292
+  /// reduction, linear and firstprivate clauses, etc.
+  void for_each_used_expr(llvm::function_ref Fn) const;
 };

NoQ wrote:
> This whole `X.for_each(λ)` idiom doesn't seem to be popular in LLVM; people 
> seem to prefer to write an iterator and then use the generic `for_each(X, λ)` 
> over it.
> 
> (i don't really care)
I can try to add the iterator instead.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64356/new/

https://reviews.llvm.org/D64356



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


[PATCH] D64383: build: use multiple `install` rather than building up a list

2019-07-09 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

I like that. Almost anything that helps us abolish global variables and lists 
(here `LIBCXX_INSTALL_TARGETS`) in the CMake scripts is a good thing.




Comment at: src/CMakeLists.txt:441
+  if (LIBCXX_INSTALL_STATIC_LIBRARY)
+install(TARGETS cxx_static
+  ARCHIVE DESTINATION 
${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx

Just to double-check, it's redundant to say `ARCHIVE` here because CMake knows 
it's a static archive -- correct?


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64383/new/

https://reviews.llvm.org/D64383



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


r365498 - Ignore trailing NullStmts in StmtExprs for GCC compatibility.

2019-07-09 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue Jul  9 08:02:07 2019
New Revision: 365498

URL: http://llvm.org/viewvc/llvm-project?rev=365498&view=rev
Log:
Ignore trailing NullStmts in StmtExprs for GCC compatibility.

Ignore trailing NullStmts in compound expressions when determining the result 
type and value. This is to match the GCC behavior which ignores semicolons at 
the end of compound expressions.

Patch by Dominic Ferreira.

Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/AST/ast-dump-stmt.c
cfe/trunk/test/CodeGen/exprs.c
cfe/trunk/test/Sema/statements.c
cfe/trunk/test/SemaCXX/statements.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=365498&r1=365497&r2=365498&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Tue Jul  9 08:02:07 2019
@@ -1349,11 +1349,6 @@ public:
 return !body_empty() ? body_begin()[size() - 1] : nullptr;
   }
 
-  void setLastStmt(Stmt *S) {
-assert(!body_empty() && "setLastStmt");
-body_begin()[size() - 1] = S;
-  }
-
   using const_body_iterator = Stmt *const *;
   using body_const_range = llvm::iterator_range;
 
@@ -1396,6 +1391,26 @@ public:
 return const_reverse_body_iterator(body_begin());
   }
 
+  // Get the Stmt that StmtExpr would consider to be the result of this
+  // compound statement. This is used by StmtExpr to properly emulate the GCC
+  // compound expression extension, which ignores trailing NullStmts when
+  // getting the result of the expression.
+  // i.e. ({ 5;;; })
+  //   ^^ ignored
+  // If we don't find something that isn't a NullStmt, just return the last
+  // Stmt.
+  Stmt *getStmtExprResult() {
+for (auto *B : llvm::reverse(body())) {
+  if (!isa(B))
+return B;
+}
+return body_back();
+  }
+
+  const Stmt *getStmtExprResult() const {
+return const_cast(this)->getStmtExprResult();
+  }
+
   SourceLocation getBeginLoc() const { return CompoundStmtBits.LBraceLoc; }
   SourceLocation getEndLoc() const { return RBraceLoc; }
 

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=365498&r1=365497&r2=365498&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Jul  9 08:02:07 2019
@@ -381,44 +381,48 @@ CodeGenFunction::EmitCompoundStmtWithout
   bool GetLast,
   AggValueSlot AggSlot) {
 
-  for (CompoundStmt::const_body_iterator I = S.body_begin(),
-   E = S.body_end()-GetLast; I != E; ++I)
-EmitStmt(*I);
+  const Stmt *ExprResult = S.getStmtExprResult();
+  assert((!GetLast || (GetLast && ExprResult)) &&
+ "If GetLast is true then the CompoundStmt must have a 
StmtExprResult");
 
   Address RetAlloca = Address::invalid();
-  if (GetLast) {
-// We have to special case labels here.  They are statements, but when put
-// at the end of a statement expression, they yield the value of their
-// subexpression.  Handle this by walking through all labels we encounter,
-// emitting them before we evaluate the subexpr.
-// Similar issues arise for attributed statements.
-const Stmt *LastStmt = S.body_back();
-while (!isa(LastStmt)) {
-  if (const auto *LS = dyn_cast(LastStmt)) {
-EmitLabel(LS->getDecl());
-LastStmt = LS->getSubStmt();
-  } else if (const auto *AS = dyn_cast(LastStmt)) {
-// FIXME: Update this if we ever have attributes that affect the
-// semantics of an expression.
-LastStmt = AS->getSubStmt();
-  } else {
-llvm_unreachable("unknown value statement");
+
+  for (auto *CurStmt : S.body()) {
+if (GetLast && ExprResult == CurStmt) {
+  // We have to special case labels here.  They are statements, but when 
put
+  // at the end of a statement expression, they yield the value of their
+  // subexpression.  Handle this by walking through all labels we 
encounter,
+  // emitting them before we evaluate the subexpr.
+  // Similar issues arise for attributed statements.
+  while (!isa(ExprResult)) {
+if (const auto *LS = dyn_cast(ExprResult)) {
+  EmitLabel(LS->getDecl());
+  ExprResult = LS->getSubStmt();
+} else if (const auto *AS = dyn_cast(ExprResult)) {
+  // FIXME: Update this if we ever have attributes that affect the
+  // semantics of an expression.
+  ExprResult = AS->getSubStmt();
+} else {
+  llvm_unreachable("unknown value statement");
+

[PATCH] D57086: Ignore trailing NullStmts in StmtExprs for GCC compatibility

2019-07-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

I've commit on your behalf in r365498. Thank you for the patch!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57086/new/

https://reviews.llvm.org/D57086



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


[PATCH] D63835: [Syntax] Add nodes for most common statements

2019-07-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

Submitting a few comments to start up the discussions.

The actual changes will follow.




Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:99
 /// An abstract node for C++ statements, e.g. 'while', 'if', etc.
 class Statement : public Tree {
 public:

sammccall wrote:
> Do you want to expose the statement-ending-semicolon here?
> 
> (Not all statements have it, but common enough you may want it in the base 
> class instead of all children)
Yes, only "leaf" (i.e. the ones not having any statement children) have it.
I was thinking about:
  - having a separate class for non-composite statements and providing an 
accessor there,
  - providing an accessor in each of the leaf statements (would mean some 
duplication, but, arguably, better discoverability).

But, from an offline conversation, we seem to disagree that inheritance is a 
proper way to model this.
Would it be ok to do this in a follow-up? I'll add a FIXME for now.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:160
+  syntax::Leaf *caseKeyword();
+  syntax::Statement *body();
+

sammccall wrote:
> syntactically, is it useful to model the body as a single statement? It's not 
> a CompoundStmt as it has no braces. Seems like a sequence...
> 
> Or is the idea that the first following statement is the body (might be 
> nothing), and subsequent ones aren't part of the body? Why is this more 
> useful than making the body a sibling?
This models the structure of the C++ grammar (and clang AST).
Getting from a switch statements to all its `case` and `default` labels seems 
useful, but should be addressed by a separate API that traverses the 
corresponding syntax tree nodes.

Marking as done, from an offline conversation we seem to agree here.
Feel free to reopen if needed.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:176
+  syntax::Leaf *defaultKeyword();
+  syntax::Statement *body();
+

sammccall wrote:
> might be handy to unify this with CaseStatement somehow (a base class, or 
> make it literally a CaseStatement with a null body and a bool isDefaultCase() 
> that looks at the keyword token)
> 
> Mostly thinking about code that's going to iterate over case statements.
I would model with with a base class, but let's agree whether that's the right 
way to approach this.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:193
+  syntax::Statement *thenStatement();
+  syntax::Leaf *elseKeyword();
+  syntax::Statement *elseStatement();

sammccall wrote:
> I think throughout it's important to mark which of these are:
>  - nullable in correct code
>  - nullable in code generated by recovery
I would suggest to only mark the nodes that are nullable in the correct code. 
For recovery, I would assume the following rule (please tell me if I'm wrong):

On a construct whose parsing involved recovery:
- if the node has an introducing token (`if`, `try`, etc.), the corresponding 
child cannot be null.
- any other child can be null.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63835/new/

https://reviews.llvm.org/D63835



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


[PATCH] D64383: build: use multiple `install` rather than building up a list

2019-07-09 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd marked an inline comment as done.
compnerd added a comment.

@ldionne - that was exactly the motivation for this change - it always takes me 
a couple of reads to figure out what we are trying to do here.




Comment at: src/CMakeLists.txt:441
+  if (LIBCXX_INSTALL_STATIC_LIBRARY)
+install(TARGETS cxx_static
+  ARCHIVE DESTINATION 
${LIBCXX_INSTALL_PREFIX}${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx

ldionne wrote:
> Just to double-check, it's redundant to say `ARCHIVE` here because CMake 
> knows it's a static archive -- correct?
No, the `ARCHIVE DESTINATION` here indicates to CMake where to install the 
target *if* it is an archive.  This is the location used if the target is a 
static library or if the target is Windows and the target is a shared library 
in which case this is the path where the import library is installed.


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64383/new/

https://reviews.llvm.org/D64383



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


r365499 - [OpenCL][Sema] Fix builtin rewriting

2019-07-09 Thread Marco Antognini via cfe-commits
Author: mantognini
Date: Tue Jul  9 08:04:23 2019
New Revision: 365499

URL: http://llvm.org/viewvc/llvm-project?rev=365499&view=rev
Log:
[OpenCL][Sema] Fix builtin rewriting

This patch ensures built-in functions are rewritten using the proper
parent declaration.

Existing tests are modified to run in C++ mode to ensure the
functionality works also with C++ for OpenCL while not increasing the
testing runtime.

Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGenOpenCL/builtins.cl
cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=365499&r1=365498&r2=365499&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Tue Jul  9 08:04:23 2019
@@ -1478,6 +1478,7 @@ BUILTIN(__builtin_coro_begin, "v*v*", "n
 BUILTIN(__builtin_coro_end, "bv*Ib", "n")
 BUILTIN(__builtin_coro_suspend, "cIb", "n")
 BUILTIN(__builtin_coro_param, "bv*v*", "n")
+
 // OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
 // We need the generic prototype, since the packet type could be anything.
 LANGBUILTIN(read_pipe, "i.", "tn", OCLC20_LANG)
@@ -1513,6 +1514,8 @@ LANGBUILTIN(get_kernel_max_sub_group_siz
 LANGBUILTIN(get_kernel_sub_group_count_for_ndrange, "Ui.", "tn", OCLC20_LANG)
 
 // OpenCL v2.0 s6.13.9 - Address space qualifier functions.
+// FIXME: Pointer parameters of OpenCL builtins should have their address space
+// requirement defined.
 LANGBUILTIN(to_global, "v*v*", "tn", OCLC20_LANG)
 LANGBUILTIN(to_local, "v*v*", "tn", OCLC20_LANG)
 LANGBUILTIN(to_private, "v*v*", "tn", OCLC20_LANG)

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=365499&r1=365498&r2=365499&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jul  9 08:04:23 2019
@@ -5360,7 +5360,7 @@ static bool checkArgsForPlaceholders(Sem
 ///  FunctionDecl is returned.
 /// TODO: Handle pointer return types.
 static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext 
&Context,
-const FunctionDecl *FDecl,
+FunctionDecl *FDecl,
 MultiExprArg ArgExprs) {
 
   QualType DeclType = FDecl->getType();
@@ -5408,7 +5408,7 @@ static FunctionDecl *rewriteBuiltinFunct
   FunctionProtoType::ExtProtoInfo EPI;
   QualType OverloadTy = Context.getFunctionType(FT->getReturnType(),
 OverloadParams, EPI);
-  DeclContext *Parent = Context.getTranslationUnitDecl();
+  DeclContext *Parent = FDecl->getParent();
   FunctionDecl *OverloadDecl = FunctionDecl::Create(Context, Parent,
 FDecl->getLocation(),
 FDecl->getLocation(),

Modified: cfe/trunk/test/CodeGenOpenCL/builtins.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins.cl?rev=365499&r1=365498&r2=365499&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins.cl Tue Jul  9 08:04:23 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -finclude-default-header -cl-std=CL2.0 -O0 -emit-llvm -o 
- -triple "spir-unknown-unknown" | FileCheck %s
+// RUN: %clang_cc1 %s -finclude-default-header -cl-std=c++ -fblocks -O0 
-emit-llvm -o - -triple "spir-unknown-unknown" | FileCheck %s
 
 void testBranchingOnEnqueueKernel(queue_t default_queue, unsigned flags, 
ndrange_t ndrange) {
 // Ensure `enqueue_kernel` can be branched upon.

Modified: cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl?rev=365499&r1=365498&r2=365499&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl Tue Jul  9 08:04:23 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=CL2.0 -o - 
%s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=c++ -o - 
%s | FileCheck %s
 
 // CHECK-DAG: %opencl.pipe_ro_t = type opaque
 // CHECK-DAG: %opencl.pipe_wo_t = type opaque

Modified: cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl?rev=365499&r1=365498&r2=365499&view=d

r365500 - [OpenCL][Sema] Improve address space support for blocks

2019-07-09 Thread Marco Antognini via cfe-commits
Author: mantognini
Date: Tue Jul  9 08:04:27 2019
New Revision: 365500

URL: http://llvm.org/viewvc/llvm-project?rev=365500&view=rev
Log:
[OpenCL][Sema] Improve address space support for blocks

Summary:
This patch ensures that the following code is compiled identically with
-cl-std=CL2.0 and -fblocks -cl-std=c++.

kernel void test(void) {
  void (^const block_A)(void) = ^{
return;
  };
}

A new test is not added because cl20-device-side-enqueue.cl will cover
this once blocks are further improved for C++ for OpenCL.

The changes to Sema::PerformImplicitConversion are based on
the parts of Sema::CheckAssignmentConstraints on block pointer
conversions.

Reviewers: rjmccall, Anastasia

Subscribers: yaxunl, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Sema/SemaExprCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=365500&r1=365499&r2=365500&view=diff
==
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jul  9 08:04:27 2019
@@ -4216,7 +4216,20 @@ Sema::PerformImplicitConversion(Expr *Fr
 break;
 
   case ICK_Block_Pointer_Conversion: {
-From = ImpCastExprToType(From, ToType.getUnqualifiedType(), CK_BitCast,
+QualType LHSType = Context.getCanonicalType(ToType).getUnqualifiedType();
+QualType RHSType = Context.getCanonicalType(FromType).getUnqualifiedType();
+
+// Assumptions based on Sema::IsBlockPointerConversion.
+assert(isa(LHSType) && "BlockPointerType expected");
+assert(isa(RHSType) && "BlockPointerType expected");
+
+LangAS AddrSpaceL =
+LHSType->getAs()->getPointeeType().getAddressSpace();
+LangAS AddrSpaceR =
+RHSType->getAs()->getPointeeType().getAddressSpace();
+CastKind Kind =
+AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
+From = ImpCastExprToType(From, ToType.getUnqualifiedType(), Kind,
  VK_RValue, /*BasePath=*/nullptr, CCK).get();
 break;
   }


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


[PATCH] D64083: [OpenCL][Sema] Improve address space support for blocks

2019-07-09 Thread Marco Antognini via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365500: [OpenCL][Sema] Improve address space support for 
blocks (authored by mantognini, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64083?vs=207573&id=208683#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64083/new/

https://reviews.llvm.org/D64083

Files:
  cfe/trunk/lib/Sema/SemaExprCXX.cpp


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -4216,7 +4216,20 @@
 break;
 
   case ICK_Block_Pointer_Conversion: {
-From = ImpCastExprToType(From, ToType.getUnqualifiedType(), CK_BitCast,
+QualType LHSType = Context.getCanonicalType(ToType).getUnqualifiedType();
+QualType RHSType = Context.getCanonicalType(FromType).getUnqualifiedType();
+
+// Assumptions based on Sema::IsBlockPointerConversion.
+assert(isa(LHSType) && "BlockPointerType expected");
+assert(isa(RHSType) && "BlockPointerType expected");
+
+LangAS AddrSpaceL =
+LHSType->getAs()->getPointeeType().getAddressSpace();
+LangAS AddrSpaceR =
+RHSType->getAs()->getPointeeType().getAddressSpace();
+CastKind Kind =
+AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
+From = ImpCastExprToType(From, ToType.getUnqualifiedType(), Kind,
  VK_RValue, /*BasePath=*/nullptr, CCK).get();
 break;
   }


Index: cfe/trunk/lib/Sema/SemaExprCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaExprCXX.cpp
+++ cfe/trunk/lib/Sema/SemaExprCXX.cpp
@@ -4216,7 +4216,20 @@
 break;
 
   case ICK_Block_Pointer_Conversion: {
-From = ImpCastExprToType(From, ToType.getUnqualifiedType(), CK_BitCast,
+QualType LHSType = Context.getCanonicalType(ToType).getUnqualifiedType();
+QualType RHSType = Context.getCanonicalType(FromType).getUnqualifiedType();
+
+// Assumptions based on Sema::IsBlockPointerConversion.
+assert(isa(LHSType) && "BlockPointerType expected");
+assert(isa(RHSType) && "BlockPointerType expected");
+
+LangAS AddrSpaceL =
+LHSType->getAs()->getPointeeType().getAddressSpace();
+LangAS AddrSpaceR =
+RHSType->getAs()->getPointeeType().getAddressSpace();
+CastKind Kind =
+AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
+From = ImpCastExprToType(From, ToType.getUnqualifiedType(), Kind,
  VK_RValue, /*BasePath=*/nullptr, CCK).get();
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64247: [clangd] Filter out non-governed files from broadcast

2019-07-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 208686.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64247/new/

https://reviews.llvm.org/D64247

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -12,6 +12,8 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
 #include "ClangdServer.h"
+#include "GlobalCompilationDatabase.h"
+#include "Path.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -48,7 +50,9 @@
   StringRef RelPathPrefix = StringRef());
 
   llvm::Optional
-  getCompileCommand(PathRef File, ProjectInfo * = nullptr) const override;
+  getCompileCommand(PathRef File) const override;
+
+  llvm::Optional getProjectInfo(PathRef File) const override;
 
   std::vector ExtraClangFlags;
 
Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -6,7 +6,11 @@
 //
 //===--===//
 #include "TestFS.h"
+#include "GlobalCompilationDatabase.h"
+#include "Path.h"
 #include "URI.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Path.h"
@@ -36,9 +40,13 @@
   // -ffreestanding avoids implicit stdc-predef.h.
 }
 
+llvm::Optional
+MockCompilationDatabase::getProjectInfo(PathRef File) const {
+  return ProjectInfo{Directory};
+};
+
 llvm::Optional
-MockCompilationDatabase::getCompileCommand(PathRef File,
-   ProjectInfo *Project) const {
+MockCompilationDatabase::getCompileCommand(PathRef File) const {
   if (ExtraClangFlags.empty())
 return None;
 
@@ -57,8 +65,6 @@
 CommandLine.push_back(RelativeFilePath.str());
   }
 
-  if (Project)
-Project->SourceRoot = Directory;
   return {tooling::CompileCommand(Directory != llvm::StringRef()
   ? Directory
   : llvm::sys::path::parent_path(File),
Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -8,10 +8,21 @@
 
 #include "GlobalCompilationDatabase.h"
 
+#include "Path.h"
 #include "TestFS.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -20,8 +31,10 @@
 using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::EndsWith;
+using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::StartsWith;
+using ::testing::UnorderedElementsAre;
 
 TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
   DirectoryBasedGlobalCompilationDatabase DB(None);
@@ -50,13 +63,9 @@
   class BaseCDB : public GlobalCompilationDatabase {
   public:
 llvm::Optional
-getCompileCommand(llvm::StringRef File,
-  ProjectInfo *Project) const override {
-  if (File == testPath("foo.cc")) {
-if (Project)
-  Project->SourceRoot = testRoot();
+getCompileCommand(llvm::StringRef File) const override {
+  if (File == testPath("foo.cc"))
 return cmd(File, "-DA=1");
-  }
   return None;
 }
 
@@ -64,6 +73,10 @@
 getFallbackCommand(llvm::StringRef File) const override {
   return cmd(File, "-DA=2");
 }
+
+llvm::Optional getProjectInfo(PathRef File) const override {
+  return ProjectInfo{testRoot()};
+}
   };
 
 protected:
@@ -153,6 +166,109 @@
 Not(Contains("random-plugin";
 }
 
+TEST(GlobalCompilationDat

[PATCH] D64247: [clangd] Filter out non-governed files from broadcast

2019-07-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/index/Background.cpp:653
+auto PI = CDB.getProjectInfo(File);
+assert(PI && "Found CDB but no ProjectInfo!");
+

sammccall wrote:
> This looks like a bad assertion: it should be OK to provide compile commands 
> but not project info.
> 
> (Otherwise getProjectInfo should be pure virtual, but I'm concerned about the 
> raciness if we're going to insist they're consistent but not provide any way 
> of synchronizing)
> 
> I'd suggest we should just not index such files (for now). Later we can start 
> passing "" to the index storage factory to get the fallback storage (I think 
> today we pass "", but the factory doesn't handle it - oops!)
actually we have a nullstorage for that, which just logs a messsage and doesn't 
persist the shard.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64247/new/

https://reviews.llvm.org/D64247



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


[PATCH] D64247: [clangd] Filter out non-governed files from broadcast

2019-07-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 208697.
kadircet added a comment.

- Rearrange changes to get a better diff


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64247/new/

https://reviews.llvm.org/D64247

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -12,6 +12,8 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
 #include "ClangdServer.h"
+#include "GlobalCompilationDatabase.h"
+#include "Path.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -48,7 +50,9 @@
   StringRef RelPathPrefix = StringRef());
 
   llvm::Optional
-  getCompileCommand(PathRef File, ProjectInfo * = nullptr) const override;
+  getCompileCommand(PathRef File) const override;
+
+  llvm::Optional getProjectInfo(PathRef File) const override;
 
   std::vector ExtraClangFlags;
 
Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -6,7 +6,11 @@
 //
 //===--===//
 #include "TestFS.h"
+#include "GlobalCompilationDatabase.h"
+#include "Path.h"
 #include "URI.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Path.h"
@@ -36,9 +40,13 @@
   // -ffreestanding avoids implicit stdc-predef.h.
 }
 
+llvm::Optional
+MockCompilationDatabase::getProjectInfo(PathRef File) const {
+  return ProjectInfo{Directory};
+};
+
 llvm::Optional
-MockCompilationDatabase::getCompileCommand(PathRef File,
-   ProjectInfo *Project) const {
+MockCompilationDatabase::getCompileCommand(PathRef File) const {
   if (ExtraClangFlags.empty())
 return None;
 
@@ -57,8 +65,6 @@
 CommandLine.push_back(RelativeFilePath.str());
   }
 
-  if (Project)
-Project->SourceRoot = Directory;
   return {tooling::CompileCommand(Directory != llvm::StringRef()
   ? Directory
   : llvm::sys::path::parent_path(File),
Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -8,10 +8,21 @@
 
 #include "GlobalCompilationDatabase.h"
 
+#include "Path.h"
 #include "TestFS.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -20,8 +31,10 @@
 using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::EndsWith;
+using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::StartsWith;
+using ::testing::UnorderedElementsAre;
 
 TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
   DirectoryBasedGlobalCompilationDatabase DB(None);
@@ -50,13 +63,9 @@
   class BaseCDB : public GlobalCompilationDatabase {
   public:
 llvm::Optional
-getCompileCommand(llvm::StringRef File,
-  ProjectInfo *Project) const override {
-  if (File == testPath("foo.cc")) {
-if (Project)
-  Project->SourceRoot = testRoot();
+getCompileCommand(llvm::StringRef File) const override {
+  if (File == testPath("foo.cc"))
 return cmd(File, "-DA=1");
-  }
   return None;
 }
 
@@ -64,6 +73,10 @@
 getFallbackCommand(llvm::StringRef File) const override {
   return cmd(File, "-DA=2");
 }
+
+llvm::Optional getProjectInfo(PathRef File) const override {
+  return ProjectInfo{testRoot()};
+}
   };
 
 protected:
@@ -153,6 +166,109 @@
 Not(Contains("random-plugin";
 }
 
+TEST(GlobalCompilationDatabaseTest, DiscoveryW

[libunwind] r365505 - [libunwind] Fix Unwind-EHABI.cpp:getByte on big-endian targets

2019-07-09 Thread Mikhail Maltsev via cfe-commits
Author: miyuki
Date: Tue Jul  9 08:29:06 2019
New Revision: 365505

URL: http://llvm.org/viewvc/llvm-project?rev=365505&view=rev
Log:
[libunwind] Fix Unwind-EHABI.cpp:getByte on big-endian targets

Summary:
The function getByte is dependent on endianness and the current
behavior is incorrect on big-endian targets.

This patch fixes the issue.

Reviewers: phosek, ostannard, dmgreen, christof, chill

Reviewed By: ostannard, chill

Subscribers: chill, christof, libcxx-commits

Tags: #libc

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

Modified:
libunwind/trunk/src/Unwind-EHABI.cpp

Modified: libunwind/trunk/src/Unwind-EHABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-EHABI.cpp?rev=365505&r1=365504&r2=365505&view=diff
==
--- libunwind/trunk/src/Unwind-EHABI.cpp (original)
+++ libunwind/trunk/src/Unwind-EHABI.cpp Tue Jul  9 08:29:06 2019
@@ -31,7 +31,11 @@ namespace {
 // signinficant byte.
 uint8_t getByte(const uint32_t* data, size_t offset) {
   const uint8_t* byteData = reinterpret_cast(data);
+#ifdef __LITTLE_ENDIAN__
   return byteData[(offset & ~(size_t)0x03) + (3 - (offset & (size_t)0x03))];
+#else
+  return byteData[offset];
+#endif
 }
 
 const char* getNextWord(const char* data, uint32_t* out) {


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


[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 208704.
MaskRay added a comment.

Rebase

The openmp issue was fixed by r365485


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64277/new/

https://reviews.llvm.org/D64277

Files:
  include/clang/Driver/Options.td
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/X86.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ppc64-long-double.cpp
  test/CodeGen/x86-long-double.cpp
  test/Driver/mlong-double-128.c

Index: test/Driver/mlong-double-128.c
===
--- /dev/null
+++ test/Driver/mlong-double-128.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target powerpc-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64-pc-freebsd12 -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64le-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target i686-linux-gnu -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+
+// CHECK: "-mlong-double-128"
+
+// RUN: %clang -target aarch64 -c -### %s -mlong-double-128 2>&1 | FileCheck --check-prefix=ERR %s
+
+// ERR: error: unsupported option '-mlong-double-128' for target 'aarch64'
Index: test/CodeGen/x86-long-double.cpp
===
--- test/CodeGen/x86-long-double.cpp
+++ test/CodeGen/x86-long-double.cpp
@@ -16,6 +16,15 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-64 | \
 // RUN:   FileCheck --check-prefixes=FP64,FP64-X64 %s
 
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+
 // Check -malign-double increases the alignment from 4 to 8 on x86-32.
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-64 \
 // RUN:   -malign-double | FileCheck --check-prefixes=FP64,FP64-X64 %s
@@ -37,7 +46,11 @@
 // FP64-X64: @x = global double {{.*}}, align 8
 // FP64-X64: @size = global i32 8
 
+// FP128: @x = global fp128 {{.*}}, align 16
+// FP128: @size = global i32 16
+
 long double foo(long double d) { return d; }
 
 // FP64: double @_Z3fooe(double %d)
 // FP80: x86_fp80 @_Z3fooe(x86_fp80 %d)
+// FP128: fp128 @_Z3foog(fp128 %d)
Index: test/CodeGen/ppc64-long-double.cpp
===
--- test/CodeGen/ppc64-long-double.cpp
+++ test/CodeGen/ppc64-long-double.cpp
@@ -2,8 +2,11 @@
 // RUN:   FileCheck --check-prefix=FP64 %s
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s -mlong-double-64 | \
 // RUN:   FileCheck --check-prefix=FP64 %s
+
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
+// RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \
+// RUN:   FileCheck --check-prefix=IBM128 %s
 
 long double x = 0;
 int size = sizeof(x);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2742,7 +2742,9 @@
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
-  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
+  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
+? 128
+: Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.ROPI = Args.hasArg(OPT_fropi);
   Opts.RWPI = Args.hasArg(OPT_frwpi);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4001,11 +4001,14 @@
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs);
 
-  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64)) {
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64,
+   options::OPT_mlong_double_128)) {
 if (TC.getArch() == llvm::Triple::x86 ||
 TC.getArch() == llvm::Triple::x86_64 ||
 TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) {
-  CmdArgs.push_back("-mlong-double-64");
+  CmdArgs.p

[PATCH] D62855: [clangd] Implementation of auto type expansion.

2019-07-09 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel updated this revision to Diff 208705.
kuhnel marked 22 inline comments as done.
kuhnel added a comment.

Allrighty then, next update:

- moved 2 helper funtions to `AST.cpp`
- added `ASTTests.cpp`
- added more tests
- removed a lot of redundant code
- implemented corner case for not replacing function pointers
- removed unwanted header file


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62855/new/

https://reviews.llvm.org/D62855

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/Selection.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/test/code-action-request.test
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -2108,6 +2108,28 @@
   }
 }
 
+TEST(GetDeductedType, KwAutoExpansion) {
+  struct Test {
+StringRef AnnotatedCode;
+const char *DeductedType;
+  } Tests[] = {
+  {"^auto i = 0;", "int"},
+  {"^auto f(){ return 1;};", "int"}
+  };
+  for (Test T : Tests) {
+Annotations File(T.AnnotatedCode);
+auto AST = TestTU::withCode(File.code()).build();
+ASSERT_TRUE(AST.getDiagnostics().empty()) << AST.getDiagnostics().begin()->Message;
+SourceManagerForFile SM("foo.cpp", File.code());
+
+for (Position Pos : File.points()) {
+  auto Location = sourceLocationInMainFile(SM.get(), Pos);
+  auto DeducedType = getDeducedType(AST, *Location);
+  EXPECT_EQ(DeducedType->getAsString(), T.DeductedType);
+}
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -11,6 +11,7 @@
 #include "TestTU.h"
 #include "refactor/Tweak.h"
 #include "clang/AST/Expr.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/StringRef.h"
@@ -19,6 +20,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+//#include "refactor/tweaks/ExpandAutoType.cpp"
 
 using llvm::Failed;
 using llvm::Succeeded;
@@ -126,6 +128,19 @@
   EXPECT_EQ(Output, std::string(*Result)) << Input;
 }
 
+/// Check if apply returns an error and that the @ErrorMessage is contained
+/// in that error
+void checkApplyContainsError(llvm::StringRef ID, llvm::StringRef Input,
+ const std::string& ErrorMessage) {
+  auto Result = apply(ID, Input);
+  EXPECT_FALSE(Result) << "expected error message:\n   " << ErrorMessage <<
+   "\non input:" << Input;
+  EXPECT_NE(std::string::npos,
+llvm::toString(Result.takeError()).find(ErrorMessage))
+<< "Wrong error message:\n  " << llvm::toString(Result.takeError())
+<< "\nexpected:\n  " << ErrorMessage;
+}
+
 TEST(TweakTest, SwapIfBranches) {
   llvm::StringLiteral ID = "SwapIfBranches";
 
@@ -509,6 +524,132 @@
   )cpp");
 }
 
+TEST(TweakTest, ExpandAutoType) {
+  llvm::StringLiteral ID = "ExpandAutoType";
+
+  checkAvailable(ID, R"cpp(
+^a^u^t^o^ i = 0;
+  )cpp");
+
+  checkNotAvailable(ID, R"cpp(
+auto ^i^ ^=^ ^0^;^
+  )cpp");
+
+  llvm::StringLiteral Input = R"cpp(
+[[auto]] i = 0;
+  )cpp";
+  llvm::StringLiteral Output = R"cpp(
+int i = 0;
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // check primitive type
+  Input = R"cpp(
+au^to i = 0;
+  )cpp";
+  Output = R"cpp(
+int i = 0;
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // check classes and namespaces
+  Input = R"cpp(
+namespace testns {
+  class TestClass {
+class SubClass {};
+  };
+}
+^auto C = testns::TestClass::SubClass();
+  )cpp";
+  Output = R"cpp(
+namespace testns {
+  class TestClass {
+class SubClass {};
+  };
+}
+testns::TestClass::SubClass C = testns::TestClass::SubClass();
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // check that namespaces are shortened
+  Input = R"cpp(
+namespace testns {
+class TestClass {
+};
+void func() { ^auto C = TestClass(); }
+}
+  )cpp";
+  Output = R"cpp(
+namespace testns {
+class TestClass {
+};
+void func() { TestClass C = TestClass(); }
+}
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // unknown types 

[PATCH] D62855: [clangd] Implementation of auto type expansion.

2019-07-09 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel added inline comments.



Comment at: clang-tools-extra/clangd/AST.cpp:172
 
+namespace {
+/// Computes the deduced type at a given location by visiting the relevant

sammccall wrote:
> It looks like this has been moved from somewhere (at least code looks 
> familiar) but isn't deleted anywhere. (The code in XRefs is touched but 
> doesn't seem to use this). Is there a reason we can't reuse one copy?
> 
> 
Ah interesting. It got messed up during rebase and someone implemented a 
similar function in XRefs.cpp in the mean time. So I'll just move over to their 
implementation. And remove the changes to AST...



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp:32
+  CachedLocation = findAutoType(Node);
+  return CachedLocation != llvm::None;
+}

sammccall wrote:
> && `!CachedLocation->getTypePtr()->getDeducedType()->isNull()`?
> 
> to avoid triggering in e.g. dependent code like
> ```
> template  void f() {
> auto X = T::foo();
> }
> ```
I added the new testcase and if fails with and without the added condition.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp:39
+  llvm::Optional DeductedType =
+  getDeducedType(Inputs.AST, CachedLocation->getBeginLoc());
+

sammccall wrote:
> is this ever not just `CachedLocation->getTypePtr()->getDeducedType()`?
There is some difference, because quite a few tests fail, wenn I use your call. 
--> Staying with current implementation



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp:47
+  // if it's a lambda expression, return an error message
+  if (isa(*DeductedType) and
+  dyn_cast(*DeductedType)->getDecl()->isLambda()) {

sammccall wrote:
> again, this is actually a cheap test (if we don't need to use the deduced 
> type visitor), we can lift it into prepare
Then I would have to move the call to `getDeducedType(...)` also to 
`prepare`



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp:53
+
+  SourceRange OriginalRange(CachedLocation->getBeginLoc(),
+CachedLocation->getEndLoc());

sammccall wrote:
> nit: this is just CachedLocation->getSourceRange()
correct.



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp:68
+const llvm::Optional
+ExpandAutoType::findAutoType(const SelectionTree::Node* StartNode) {
+  auto Node = StartNode;

sammccall wrote:
> I'm confused about this - how can the user select the child of an AutoTypeLoc 
> rather than the AutoTypeLoc itself? i.e. do we need the loop?
At first I understood that we would have to walk the AST, but it seems we don't 
have to...



Comment at: clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp:76
+std::string
+ExpandAutoType::shortenNamespace(const llvm::StringRef &OriginalName,
+ const llvm::StringRef &CurrentNamespace) {

sammccall wrote:
> sammccall wrote:
> > This is nice. We might want to move it to SourceCode.h, somewhere near 
> > SplitQualifiedName. Then we'd generally unit test all the cases in 
> > SourceCodeTests, and we only have to smoke test the shortening here.
> > 
> > One limitation is that it only handles shortening the qualifier on the name 
> > itself, but not other parts of a printed type. e.g. `namespace ns { struct 
> > S(); auto* x = new std::vector(); }` will expand to 
> > `std::vector`, not `std::vector`. To fully solve this we may want 
> > to modify PrintingPolicy at some point, though we could probably get a long 
> > way by searching for chunks of text inside printed types that look like 
> > qualified names.
> > 
> > I think it might more clearly communicate the limitations if this function 
> > operated on the scope part only, e.g. `printScope("clang::clangd::", 
> > "clang::") --> "clangd::"`.
> > 
> > In the general case, `CurrentNamespace` should be a vector, because there 
> > can be others (introduced by using-declarations). Fine to leave this as a 
> > fixme if it's hard to do here, though.
> StringRefs are passed by value. They're just shorthand for a char* + length.
1) added documentation on that.

2) In general it would be nicer to do these operations on a some model and not 
on bare strings. We could probably recursively search for more namespaces 
inside angle brackets <>...



Comment at: clang-tools-extra/clangd/unittests/TweakTests.cpp:221
 
+TEST(TweakTest, ExpandAutoType) {
+  llvm::StringLiteral ID = "ExpandAutoType";

sammccall wrote:
> can you add testcases for:
>  - unknown types in a template `template  void x() { auto y = 
> T::z(); }`
>  - broken code `auto x = doesnt_exist();`
>  - lambda `auto x = []{};`
>  - inline/anon namespace: `inline namespace x { namespace { struct S; } } 
> auto y = S();` should insert

[PATCH] D62855: [clangd] Implementation of auto type expansion.

2019-07-09 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel updated this revision to Diff 208706.
kuhnel added a comment.

fixed typo on "Deducted"


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62855/new/

https://reviews.llvm.org/D62855

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/Selection.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/test/code-action-request.test
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -2108,6 +2108,28 @@
   }
 }
 
+TEST(GetDeducedType, KwAutoExpansion) {
+  struct Test {
+StringRef AnnotatedCode;
+const char *DeducedType;
+  } Tests[] = {
+  {"^auto i = 0;", "int"},
+  {"^auto f(){ return 1;};", "int"}
+  };
+  for (Test T : Tests) {
+Annotations File(T.AnnotatedCode);
+auto AST = TestTU::withCode(File.code()).build();
+ASSERT_TRUE(AST.getDiagnostics().empty()) << AST.getDiagnostics().begin()->Message;
+SourceManagerForFile SM("foo.cpp", File.code());
+
+for (Position Pos : File.points()) {
+  auto Location = sourceLocationInMainFile(SM.get(), Pos);
+  auto DeducedType = getDeducedType(AST, *Location);
+  EXPECT_EQ(DeducedType->getAsString(), T.DeducedType);
+}
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -11,6 +11,7 @@
 #include "TestTU.h"
 #include "refactor/Tweak.h"
 #include "clang/AST/Expr.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/StringRef.h"
@@ -19,6 +20,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+//#include "refactor/tweaks/ExpandAutoType.cpp"
 
 using llvm::Failed;
 using llvm::Succeeded;
@@ -126,6 +128,19 @@
   EXPECT_EQ(Output, std::string(*Result)) << Input;
 }
 
+/// Check if apply returns an error and that the @ErrorMessage is contained
+/// in that error
+void checkApplyContainsError(llvm::StringRef ID, llvm::StringRef Input,
+ const std::string& ErrorMessage) {
+  auto Result = apply(ID, Input);
+  EXPECT_FALSE(Result) << "expected error message:\n   " << ErrorMessage <<
+   "\non input:" << Input;
+  EXPECT_NE(std::string::npos,
+llvm::toString(Result.takeError()).find(ErrorMessage))
+<< "Wrong error message:\n  " << llvm::toString(Result.takeError())
+<< "\nexpected:\n  " << ErrorMessage;
+}
+
 TEST(TweakTest, SwapIfBranches) {
   llvm::StringLiteral ID = "SwapIfBranches";
 
@@ -509,6 +524,132 @@
   )cpp");
 }
 
+TEST(TweakTest, ExpandAutoType) {
+  llvm::StringLiteral ID = "ExpandAutoType";
+
+  checkAvailable(ID, R"cpp(
+^a^u^t^o^ i = 0;
+  )cpp");
+
+  checkNotAvailable(ID, R"cpp(
+auto ^i^ ^=^ ^0^;^
+  )cpp");
+
+  llvm::StringLiteral Input = R"cpp(
+[[auto]] i = 0;
+  )cpp";
+  llvm::StringLiteral Output = R"cpp(
+int i = 0;
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // check primitive type
+  Input = R"cpp(
+au^to i = 0;
+  )cpp";
+  Output = R"cpp(
+int i = 0;
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // check classes and namespaces
+  Input = R"cpp(
+namespace testns {
+  class TestClass {
+class SubClass {};
+  };
+}
+^auto C = testns::TestClass::SubClass();
+  )cpp";
+  Output = R"cpp(
+namespace testns {
+  class TestClass {
+class SubClass {};
+  };
+}
+testns::TestClass::SubClass C = testns::TestClass::SubClass();
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // check that namespaces are shortened
+  Input = R"cpp(
+namespace testns {
+class TestClass {
+};
+void func() { ^auto C = TestClass(); }
+}
+  )cpp";
+  Output = R"cpp(
+namespace testns {
+class TestClass {
+};
+void func() { TestClass C = TestClass(); }
+}
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // unknown types in a template should not be replaced
+  Input = R"cpp(
+template  void x() {
+^auto y =  T::z();
+}
+  )cpp";
+  checkApplyContainsError(ID, Input, "Could not deduce type for 'auto' type");
+
+  // undefined functions should not be replac

[PATCH] D61467: [Rewrite] Extend to further accept CharSourceRange

2019-07-09 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added inline comments.



Comment at: cfe/trunk/unittests/Rewrite/CMakeLists.txt:12
   clangRewrite
+  clangTooling
   )

jdenny wrote:
> thakis wrote:
> > This makes RewriteTests depend on clangTooling, and in follow-ups on 
> > clangFrontend and clangSerialization. Rewrite used to depend on basically 
> > only clangBasic and clangLex, and now it depends on almost all of clang. 
> > Maybe there's a less heavy-weight way to test this?
> > 
> > Also, when do you expect to land code that uses this? Checking in code 
> > that's unused upstream over a long period of time seems suboptimal. I 
> > delete code that shows up unused on http://llvm-cs.pcc.me.uk/ every now and 
> > then for example. (Ignore this part if you expect to check in clients of 
> > the overload soon.)
> > This makes RewriteTests depend on clangTooling, and in follow-ups on 
> > clangFrontend and clangSerialization. Rewrite used to depend on basically 
> > only clangBasic and clangLex, and now it depends on almost all of clang. 
> > Maybe there's a less heavy-weight way to test this?
> 
> Sure, I can look for another way to test this.  I didn't realize this would 
> be a real problem.  But
> 
> > Also, when do you expect to land code that uses this?
> 
> Not soon.  I offered this patch thinking that obvious Rewrite extensions like 
> this one could prove useful to the larger community even if there are no 
> upstream users now.  I'm also fine to revert and keep my Rewrite extensions 
> private for now.  Is that the best approach?
>   This makes RewriteTests depend on clangTooling, and in follow-ups on 
> clangFrontend and clangSerialization. Rewrite used to depend on basically 
> only clangBasic and clangLex, and now it depends on almost all of clang. 
> Maybe there's a less heavy-weight way to test this?

I'm thinking of adding more Rewrite unit tests in the future.  Does anyone have 
advice on this issue?  That is, is there any easy way to build ASTs in unit 
tests without such dependencies?  On the other hand, these dependencies are 
common throughout `clang/unittests` subdirectories, so I'm not sure why 
RewriteTests needs to avoid them.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61467/new/

https://reviews.llvm.org/D61467



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


[PATCH] D64423: [OpenMP] Simplify getFloatTypeSemantics

2019-07-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added a reviewer: ABataev.
Herald added subscribers: cfe-commits, jdoerfert, guansong.
Herald added a project: clang.

Repository:
  rC Clang

https://reviews.llvm.org/D64423

Files:
  lib/AST/ASTContext.cpp


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1525,13 +1525,11 @@
   case BuiltinType::Float:  return Target->getFloatFormat();
   case BuiltinType::Double: return Target->getDoubleFormat();
   case BuiltinType::LongDouble:
-if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
-&Target->getLongDoubleFormat() != &AuxTarget->getLongDoubleFormat())
+if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice)
   return AuxTarget->getLongDoubleFormat();
 return Target->getLongDoubleFormat();
   case BuiltinType::Float128:
-if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
-&Target->getFloat128Format() != &AuxTarget->getFloat128Format())
+if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice)
   return AuxTarget->getFloat128Format();
 return Target->getFloat128Format();
   }


Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1525,13 +1525,11 @@
   case BuiltinType::Float:  return Target->getFloatFormat();
   case BuiltinType::Double: return Target->getDoubleFormat();
   case BuiltinType::LongDouble:
-if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
-&Target->getLongDoubleFormat() != &AuxTarget->getLongDoubleFormat())
+if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice)
   return AuxTarget->getLongDoubleFormat();
 return Target->getLongDoubleFormat();
   case BuiltinType::Float128:
-if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice &&
-&Target->getFloat128Format() != &AuxTarget->getFloat128Format())
+if (getLangOpts().OpenMP && getLangOpts().OpenMPIsDevice)
   return AuxTarget->getFloat128Format();
 return Target->getFloat128Format();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r365509 - Revert Revert Devirtualize destructor of final class.

2019-07-09 Thread Hiroshi Yamauchi via cfe-commits
Author: yamauchi
Date: Tue Jul  9 08:57:29 2019
New Revision: 365509

URL: http://llvm.org/viewvc/llvm-project?rev=365509&view=rev
Log:
Revert Revert Devirtualize destructor of final class.

Revert r364359 and recommit r364100.

r364100 was reverted as r364359 due to an internal test failure, but it was a
false alarm.



Added:
cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=365509&r1=365508&r2=365509&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Tue Jul  9 08:57:29 2019
@@ -1865,9 +1865,33 @@ static void EmitObjectDelete(CodeGenFunc
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
-Dtor);
-return;
+bool UseVirtualCall = true;
+const Expr *Base = DE->getArgument();
+if (auto *DevirtualizedDtor =
+dyn_cast_or_null(
+Dtor->getDevirtualizedMethod(
+Base, CGF.CGM.getLangOpts().AppleKext))) {
+  UseVirtualCall = false;
+  const CXXRecordDecl *DevirtualizedClass =
+  DevirtualizedDtor->getParent();
+  if (declaresSameEntity(getCXXRecord(Base), DevirtualizedClass)) {
+// Devirtualized to the class of the base type (the type of the
+// whole expression).
+Dtor = DevirtualizedDtor;
+  } else {
+// Devirtualized to some other type. Would need to cast the this
+// pointer to that type but we don't have support for that yet, so
+// do a virtual call. FIXME: handle the case where it is
+// devirtualized to the derived type (the type of the inner
+// expression) as in EmitCXXMemberOrOperatorMemberCallExpr.
+UseVirtualCall = true;
+  }
+}
+if (UseVirtualCall) {
+  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, 
ElementType,
+  Dtor);
+  return;
+}
   }
 }
   }

Added: cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp?rev=365509&view=auto
==
--- cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp Tue Jul  9 08:57:29 
2019
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - 
| FileCheck %s
+
+namespace Test1 {
+  struct A { virtual ~A() {} };
+  struct B final : A {};
+  struct C : A { virtual ~C() final {} };
+  struct D { virtual ~D() final = 0; };
+  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
+  void foo(B *b) {
+// CHECK: call void @_ZN5Test11BD1Ev
+delete b;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
+  void foo2(C *c) {
+// CHECK: call void @_ZN5Test11CD1Ev
+delete c;
+  }
+  // CHECK-LABEL: define void @_ZN5Test14evilEPNS_1DE
+  void evil(D *p) {
+// CHECK-NOT: call void @_ZN5Test11DD1Ev
+delete p;
+  }
+}


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


[PATCH] D64257: [clangd] Added highlighting for class and enum types

2019-07-09 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 208708.
jvikstrom marked 4 inline comments as done.
jvikstrom added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64257/new/

https://reviews.llvm.org/D64257

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -34,11 +34,13 @@
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
-  {HighlightingKind::Function, "Function"}};
+  {HighlightingKind::Function, "Function"},
+  {HighlightingKind::Class, "Class"},
+  {HighlightingKind::Enum, "Enum"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
-std::vector Toks =
-makeHighlightingTokens(Test.ranges(KindString.second), KindString.first);
+std::vector Toks = makeHighlightingTokens(
+Test.ranges(KindString.second), KindString.first);
 ExpectedTokens.insert(ExpectedTokens.end(), Toks.begin(), Toks.end());
   }
 
@@ -49,14 +51,14 @@
 TEST(SemanticHighlighting, GetsCorrectTokens) {
   const char *TestCases[] = {
 R"cpp(
-  struct AS {
+  struct $Class[[AS]] {
 double SomeMember;
   };
   struct {
   } $Variable[[S]];
-  void $Function[[foo]](int $Variable[[A]]) {
+  void $Function[[foo]](int $Variable[[A]], $Class[[AS]] $Variable[[As]]) {
 auto $Variable[[VeryLongVariableName]] = 12312;
-AS $Variable[[AA]];
+$Class[[AS]] $Variable[[AA]];
 auto $Variable[[L]] = $Variable[[AA]].SomeMember + $Variable[[A]];
 auto $Variable[[FN]] = [ $Variable[[AA]]](int $Variable[[A]]) -> void {};
 $Variable[[FN]](12312);
@@ -68,13 +70,43 @@
   void $Function[[foo]]() {
 auto $Variable[[Bou]] = $Function[[Gah]];
   }
+  struct $Class[[A]] {
+void $Function[[abc]]();
+  };
 )cpp",
 R"cpp(
-  struct A {
-A();
-~A();
-void $Function[[abc]]();
-void operator<<(int);
+  namespace abc {
+template
+struct $Class[[A]] {
+  T t;
+};
+  }
+  template
+  struct $Class[[C]] : abc::A {
+typename T::A* D;
+  };
+  abc::$Class[[A]] $Variable[[AA]];
+  typedef abc::$Class[[A]] AAA;
+  struct $Class[[B]] {
+$Class[[B]]();
+~$Class[[B]]();
+void operator<<($Class[[B]]);
+$Class[[AAA]] AA;
+  };
+  $Class[[B]]::$Class[[B]]() {}
+  $Class[[B]]::~$Class[[B]]() {}
+  void $Function[[f]] () {
+$Class[[B]] $Variable[[BB]] = $Class[[B]]();
+$Variable[[BB]].~$Class[[B]]();
+$Class[[B]]();
+  }
+)cpp",
+R"cpp(
+  enum class $Enum[[E]] {};
+  enum $Enum[[EE]] {};
+  struct $Class[[A]] {
+$Enum[[E]] EEE;
+$Enum[[EE]] ;
   };
 )cpp"};
   for (const auto &TestCase : TestCases) {
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -10,6 +10,12 @@
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
 # CHECK-NEXT:  ]
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.class.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.enum.cpp"
+# CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 ---
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -26,6 +26,8 @@
 enum class HighlightingKind {
   Variable = 0,
   Function,
+  Class,
+  Enum,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -11,6 +11,8 @@
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 
 namespace clang {
@@ -35,13 +37,18 @@
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
-// FIXME: (De)Constructors/operator need 

[PATCH] D62829: [clang-tidy] Check for dynamically initialized statics in headers.

2019-07-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp:39
+return;
+  Finder->addMatcher(varDecl(hasGlobalStorage()).bind("var"), this);
+}

czhang wrote:
> aaron.ballman wrote:
> > Do you want to restrict this matcher to only variable declarations that 
> > have initializers, or are you also intending for this check to cover cases 
> > like:
> > ```
> > // At file scope.
> > struct S { S(); } s;
> > ```
> I think only variables with static storage are relevant to the stated goal of 
> the checker.
Variables declared at file scope have static storage duration by default.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp:55
+  SourceLocation Loc = Var->getLocation();
+  if (!Loc.isValid() || !utils::isPresumedLocInHeaderFile(Loc, 
*Result.SourceManager,
+  
HeaderFileExtensions))

czhang wrote:
> aaron.ballman wrote:
> > We have an AST matcher for this (`isExpansionInSystemHeader()`).
> Isn't this for system headers only, not just included 'user' headers?
Ahh, good point! Still, this should be trivial to make a local AST matcher for.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62829/new/

https://reviews.llvm.org/D62829



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


[PATCH] D63857: [clang-doc] Add a structured HTML generator

2019-07-09 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett accepted this revision.
juliehockett added a comment.
This revision is now accepted and ready to land.

LGTM, unless Jake has further comments.




Comment at: clang-tools-extra/clang-doc/HTMLGenerator.cpp:503
+  }
+  // std::move(Nodes.begin(), Nodes.end(), 
std::back_inserter(MainContentNode));
+

Remove this


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63857/new/

https://reviews.llvm.org/D63857



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


[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-09 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked 6 inline comments as done.
xazax.hun added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:7076
+auto Prefix = llvm::makeArrayRef(Path).drop_back();
+  if (pathInitializeLifetimePointer(Prefix))
+IsLifetimePtrInitWithTempOwner = true;

gribozavr wrote:
> Is it important that the whole path only contains gsl::Pointer nodes?
We are trying to figure out what do we initialize a `gsl::Pointer` annotated 
class. The reason why we have multiple `GslPointerInit`s in the path is that we 
usually can see a lot of intermediate temporary objects. Looking at the AST of 
the examples I have so far the other kind of paths does not seem to be 
relevant. I can imagine refining this condition later after examining a false 
negative but I think starting with the most conservative approach should be 
reasonable for warnings. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64256/new/

https://reviews.llvm.org/D64256



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


  1   2   3   >