[PATCH] D63139: [Diagnostics] Implement -Wswitch-unreachable

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D63139#1579231 , @rjmccall wrote:

> I agree that tools shouldn't be forced to deal with invalid AST that looks 
> like valid AST.  To me that means finding ways to preserve information that 
> (1) don't badly violate invariants and (2) are easily discoverable as invalid.


I think this makes sense.

> For `case`, which has external requirements (e.g. not being a duplicate 
> value) not entirely dissimilar to a declaration, I think that means having an 
> "invalid" flag; arbitrary tools already can't rely on the expression being 
> constant-evaluable because of templates, although granted many tools might 
> never look at template patterns.  For other things (e.g. a binary operator) 
> maybe that means using different classes (e.g. `InvalidBinaryOperator`) so 
> that tools looking at an apparently well-typed expression don't need to 
> consider totally invalid possibilities.

I'm not opposed to what you're saying, but I am a bit wary. IMO, we already 
have too many ways an AST node can be invalid that are easily checkable but 
totally different from node to node (sometimes child nodes are null, sometimes 
you check an isInvalid() predicate, sometimes you check that a type is null, 
sometimes we drop the node entirely, etc). I'd love to see a more uniform way 
to handle invalid information within an AST that retains as much source 
fidelity as we can get -- like ErrorDecl, ErrorStmt, ErrorExpr, and ErrorType 
AST nodes (perhaps these hold a partially-valid AST node of the usual kind as a 
child). This not only cuts down on difficulties with understanding the Clang 
codebase itself, but it definitely would help 3rd party tooling, pretty 
printing and AST dumping, AST matching, etc.

(Not that I expect that uniform way to appear as part of this patch, or even 
predicate the patch on it!)


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

https://reviews.llvm.org/D63139



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


[PATCH] D64504: Various minor tweaks to CLCompatOptions.td

2019-07-10 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/include/clang/Driver/CLCompatOptions.td:102
 def _SLASH_Gy_ : CLFlag<"Gy-">,
   HelpText<"Don't put each function in its own section (default)">,
   Alias;

ditto



Comment at: clang/include/clang/Driver/CLCompatOptions.td:107
 def _SLASH_Gw_ : CLFlag<"Gw-">,
-  HelpText<"Don't put each data item in its own section">,
+  HelpText<"Don't put each data item in its own section (default)">,
   Alias;

Standardize on uncontracted "Do not"?



Comment at: clang/include/clang/Driver/CLCompatOptions.td:250
 def _SLASH_Zi : CLFlag<"Zi">, Alias<_SLASH_Z7>,
-  HelpText<"Alias for /Z7. Does not produce PDBs.">;
+  HelpText<"Like /Z7">;
 def _SLASH_Zp : CLJoined<"Zp">,

I liked "Alias for /Z7". The note that it doesn't produce type server PDBs like 
/Zi would is interesting, but perhaps too much info for --help text.



Comment at: clang/include/clang/Driver/CLCompatOptions.td:294
 def _SLASH_GX : CLFlag<"GX">,
-  HelpText<"Enable exception handling">;
+  HelpText<"Deprecated (like /EHsc)">;
 def _SLASH_GX_ : CLFlag<"GX-">,

"Deprecated in favor of /EHsc"? or "(use /EHsc instead)"?


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

https://reviews.llvm.org/D64504



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


[PATCH] D64458: add -fthinlto-index= option to clang-cl

2019-07-10 Thread Bob Haarman via Phabricator via cfe-commits
inglorion added a comment.

> Do we really need to support clang-cl syntax here? Can't the user of 
> -fthinlto-index= use the regular clang driver?

We could, of course, require using the clang driver for this feature. But I 
would argue that clang-cl exists to make it easy for projects that use 
MSVC-style command lines to switch to Clang and get access to the benefits it 
provides, including features for which there is no equivalent MSVC flag. So I 
think this is reasonable to add.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64458



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


[PATCH] D64526: [NFC] Unforget a colon in a few CHECK: directives.

2019-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yeah, and i removed the one in `addrspace-operators.cl` because it has already 
been fixed in rC365666 .


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64526



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


[PATCH] D64526: [NFC] Unforget a colon in a few CHECK: directives.

2019-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 209060.
NoQ added reviewers: davidxl, aprantl, JDevlieghere.
NoQ set the repository for this revision to rL LLVM.
NoQ added a project: LLVM.
NoQ added a comment.
Herald added a subscriber: llvm-commits.

Add three more fixes - two with `CHECK-NEXT` and one with `CHECK-NOT`, in LLVM 
and compiler-rt.

One of the LLVM changes doesn't pass after the fix, so i added a FIXME instead.

I didn't immediately figure out how to compile compiler-rt so i didn't really 
have a look if the test passes; could use some help or i guess the buildbots 
will eventually tell me :)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64526

Files:
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/CodeGenCXX/noescape.cpp
  clang/test/CodeGenObjC/externally-retained.m
  compiler-rt/test/profile/instrprof-merge.c
  llvm/test/tools/dsymutil/X86/modules.m
  llvm/test/tools/dsymutil/X86/odr-fwd-declaration.cpp


Index: llvm/test/tools/dsymutil/X86/odr-fwd-declaration.cpp
===
--- llvm/test/tools/dsymutil/X86/odr-fwd-declaration.cpp
+++ llvm/test/tools/dsymutil/X86/odr-fwd-declaration.cpp
@@ -49,7 +49,7 @@
 // CHECK: AT_name{{.*}} "S"
 // CHECK-NOT: {{DW_TAG|NULL}}
 // CHECK: AT_declaration
-// CHECK-NOT AT_byte_size
+// CHECK-NOT: AT_byte_size
 
 #elif defined(FILE2)
 # 1 "Header.h" 1
Index: llvm/test/tools/dsymutil/X86/modules.m
===
--- llvm/test/tools/dsymutil/X86/modules.m
+++ llvm/test/tools/dsymutil/X86/modules.m
@@ -116,6 +116,7 @@
 // CHECK:   DW_AT_type {{.*}}{0x{{0*}}[[PTR:.*]]}
 //
 // CHECK: 0x{{0*}}[[PTR]]: DW_TAG_pointer_type
+// FIXME: The next line doesn't work.
 // CHECK-NEXT   DW_AT_type [DW_FORM_ref_addr] {0x{{0*}}[[INTERFACE]]
 extern int odr_violation;
 
Index: compiler-rt/test/profile/instrprof-merge.c
===
--- compiler-rt/test/profile/instrprof-merge.c
+++ compiler-rt/test/profile/instrprof-merge.c
@@ -89,8 +89,8 @@
 // Not profiled
 // CHECK-LABEL:  bar:
 // CHECK: Counters: 1
-// CHECK-NEXT Function count: 0
-// CHECK-NEXT Block counts: []
+// CHECK-NEXT:Function count: 0
+// CHECK-NEXT:Block counts: []
 
 // Not profiled
 // CHECK-LABEL:  main:
Index: clang/test/CodeGenObjC/externally-retained.m
===
--- clang/test/CodeGenObjC/externally-retained.m
+++ clang/test/CodeGenObjC/externally-retained.m
@@ -22,7 +22,7 @@
 void param(ObjTy *p) EXT_RET {
   // CHECK-LABEL: define void @param
   // CHECK-NOT: llvm.objc.
-  // CHECK ret
+  // CHECK: ret
 }
 
 void local() {
Index: clang/test/CodeGenCXX/noescape.cpp
===
--- clang/test/CodeGenCXX/noescape.cpp
+++ clang/test/CodeGenCXX/noescape.cpp
@@ -45,7 +45,7 @@
 }
 
 // CHECK-LABEL: define i8* @_Z5test1Pv(
-// CHECK : %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
+// CHECK: %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
 void *test1(void *p0) {
   return ::operator new(16, p0);
 }
Index: clang/test/Analysis/cfg-rich-constructors.cpp
===
--- clang/test/Analysis/cfg-rich-constructors.cpp
+++ clang/test/Analysis/cfg-rich-constructors.cpp
@@ -459,7 +459,7 @@
 // TODO: Should provide construction context for the constructor,
 // even if there is no specific trigger statement here.
 // CHECK: void simpleTemporary()
-// CHECK   1: C() (CXXConstructExpr, class C)
+// CHECK:  1: C() (CXXConstructExpr, class C)
 void simpleTemporary() {
   C();
 }


Index: llvm/test/tools/dsymutil/X86/odr-fwd-declaration.cpp
===
--- llvm/test/tools/dsymutil/X86/odr-fwd-declaration.cpp
+++ llvm/test/tools/dsymutil/X86/odr-fwd-declaration.cpp
@@ -49,7 +49,7 @@
 // CHECK: AT_name{{.*}} "S"
 // CHECK-NOT: {{DW_TAG|NULL}}
 // CHECK: AT_declaration
-// CHECK-NOT AT_byte_size
+// CHECK-NOT: AT_byte_size
 
 #elif defined(FILE2)
 # 1 "Header.h" 1
Index: llvm/test/tools/dsymutil/X86/modules.m
===
--- llvm/test/tools/dsymutil/X86/modules.m
+++ llvm/test/tools/dsymutil/X86/modules.m
@@ -116,6 +116,7 @@
 // CHECK:   DW_AT_type {{.*}}{0x{{0*}}[[PTR:.*]]}
 //
 // CHECK: 0x{{0*}}[[PTR]]: DW_TAG_pointer_type
+// FIXME: The next line doesn't work.
 // CHECK-NEXT   DW_AT_type [DW_FORM_ref_addr] {0x{{0*}}[[INTERFACE]]
 extern int odr_violation;
 
Index: compiler-rt/test/profile/instrprof-merge.c
===
--- compiler-rt/test/profile/instrprof-merge.c
+++ compiler-rt/test/profile/instrprof-merge.c
@@ -89,8 +89,8 @@
 // Not profiled
 // CHECK-LABEL:  bar:
 // CHECK: 

[PATCH] D64526: [NFC] Unforget a colon in a few CHECK: directives.

2019-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D64526#1579174 , @thakis wrote:

> (previously: D58061 )


Aha, that explains why most of these are new :)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64526



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


[PATCH] D64506: clang-cl: Remove -O0 option

2019-07-10 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Does `clang-cl -O0` without a `/` still work, though? It's used:

$ git grep O0 ../compiler-rt/test/asan/TestCases/Windows/
../compiler-rt/test/asan/TestCases/Windows/aligned_mallocs.cc:// RUN: 
%clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/allocators_sanity.cc:// RUN: 
%clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/beginthreadex.cc:// RUN: 
%clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/bitfield.cc:// RUN: %clang_cl_asan 
-O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/bitfield_uaf.cc:// RUN: 
%clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/calloc_left_oob.cc:// RUN: 
%clang_cl_asan -O0 %s -Fe%t
../compiler-rt/test/asan/TestCases/Windows/calloc_right_oob.cc:// RUN: 
%clang_cl_asan -O0 %s -Fe%t
...


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

https://reviews.llvm.org/D64506



___
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-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added a comment.

In D64356#1579154 , @NoQ wrote:

> Ugh, i forced a lot of boilerplate on you. Hope it was worth it >.<
>
> Thank you!~


No problems, thanks for the review!




Comment at: test/Analysis/cfg-openmp.cpp:3
+
+// CHECK:void xxx(int argc)
+// CHECK:[B1]

NoQ wrote:
> Those are quite readable because of very verbose pretty-prints but generally 
> i prefer to interleave code and `CHECK:` lines so that to easily see both on 
> one screen and know what corresponds to what.
Ok, I will do this.


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] D63139: [Diagnostics] Implement -Wswitch-unreachable

2019-07-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I agree that tools shouldn't be forced to deal with invalid AST that looks like 
valid AST.  To me that means finding ways to preserve information that (1) 
don't badly violate invariants and (2) are easily discoverable as invalid.  For 
`case`, which has external requirements (e.g. not being a duplicate value) not 
entirely dissimilar to a declaration, I think that means having an "invalid" 
flag; arbitrary tools already can't rely on the expression being 
constant-evaluable because of templates, although granted many tools might 
never look at template patterns.  For other things (e.g. a binary operator) 
maybe that means using different classes (e.g. `InvalidBinaryOperator`) so that 
tools looking at an apparently well-typed expression don't need to consider 
totally invalid possibilities.


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

https://reviews.llvm.org/D63139



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


[PATCH] D63663: [clang-doc] Add html links to references

2019-07-10 Thread Diego Astiazarán via Phabricator via cfe-commits
DiegoAstiazaran updated this revision to Diff 209053.
DiegoAstiazaran added a comment.

Use relative paths for references/links within files.
Don't fill namespaces of parentInfo in serialization and path is only generated 
when the parent is the global namespace.
Add new fields (Path in Reference and Path in Info) to YAML output and tests.


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

https://reviews.llvm.org/D63663

Files:
  clang-tools-extra/clang-doc/BitcodeReader.cpp
  clang-tools-extra/clang-doc/BitcodeWriter.cpp
  clang-tools-extra/clang-doc/BitcodeWriter.h
  clang-tools-extra/clang-doc/Generators.cpp
  clang-tools-extra/clang-doc/Generators.h
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/YAMLGenerator.cpp
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp

Index: clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp
@@ -25,6 +25,7 @@
 TEST(YAMLGeneratorTest, emitNamespaceYAML) {
   NamespaceInfo I;
   I.Name = "Namespace";
+  I.Path = "path/to/A";
   I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
 
   I.ChildNamespaces.emplace_back(EmptySID, "ChildNamespace",
@@ -45,6 +46,7 @@
   R"raw(---
 USR: ''
 Name:'Namespace'
+Path:'path/to/A'
 Namespace:   
   - Type:Namespace
 Name:'A'
@@ -69,15 +71,18 @@
 TEST(YAMLGeneratorTest, emitRecordYAML) {
   RecordInfo I;
   I.Name = "r";
+  I.Path = "path/to/r";
   I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
 
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
-  I.Members.emplace_back("int", "X", AccessSpecifier::AS_private);
+  I.Members.emplace_back("int", "path/to/int", "X",
+ AccessSpecifier::AS_private);
   I.TagType = TagTypeKind::TTK_Class;
-  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
-  I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
+  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record, "path/to/F");
+  I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record,
+"path/to/G");
 
   I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
   I.ChildFunctions.emplace_back();
@@ -95,6 +100,7 @@
   R"raw(---
 USR: ''
 Name:'r'
+Path:'path/to/r'
 Namespace:   
   - Type:Namespace
 Name:'A'
@@ -108,14 +114,17 @@
 Members: 
   - Type:
   Name:'int'
+  Path:'path/to/int'
 Name:'X'
 Access:  Private
 Parents: 
   - Type:Record
 Name:'F'
+Path:'path/to/F'
 VirtualParents:  
   - Type:Record
 Name:'G'
+Path:'path/to/G'
 ChildRecords:
   - Type:Record
 Name:'ChildStruct'
@@ -139,8 +148,9 @@
   I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
   I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
 
-  I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default);
-  I.Params.emplace_back("int", "P");
+  I.ReturnType =
+  TypeInfo(EmptySID, "void", InfoType::IT_default, "path/to/void");
+  I.Params.emplace_back("int", "path/to/int", "P");
   I.IsMethod = true;
   I.Parent = Reference(EmptySID, "Parent", InfoType::IT_record);
 
@@ -170,10 +180,12 @@
 Params:  
   - Type:
   Name:'int'
+  Path:'path/to/int'
 Name:'P'
 ReturnType:  
   Type:
 Name:'void'
+Path:'path/to/void'
 ...
 )raw";
   EXPECT_EQ(Expected, Actual.str());
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -57,7 +57,8 @@
   
 OneFunction
 
-   OneFunction()
+  OneFunction(
+  )
 
   
   Enums
@@ -73,14 +74,16 @@
 TEST(HTMLGeneratorTest, emitRecordHTML) {
   RecordInfo I;
   I.Name = "r";
+  I.Path = "X/Y/Z";
   I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
 
   I.DefLoc = Location(10, 

[PATCH] D64527: driver: Don't warn about assembler flags being unused when not assembling

2019-07-10 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D64527



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


[PATCH] D64526: [NFC] Unforget a colon in a few CHECK: directives.

2019-07-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(previously: D58061 )


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

https://reviews.llvm.org/D64526



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


[PATCH] D64525: [clang-scan-deps] Dependency directives source minimizer: single quotes are not digit separators after a valid character literal prefix

2019-07-10 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added inline comments.



Comment at: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp:270
+return false;
+  if (Prev == '8' && (Cur - 1 != Start) && *(Cur - 2) == 'u')
+return false;

arphaman wrote:
> Bigcheese wrote:
> > Are we sure at this point that it's always safe to jump back 2?
> It should be, because otherwise `Start` would've been equals to `Cur - 1` 
> which we check for right before the dereference.
Oh, obviously.  I missed that check.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64525



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


r365695 - My first test commit.

2019-07-10 Thread Saar Raz via cfe-commits
Author: saar.raz
Date: Wed Jul 10 13:01:44 2019
New Revision: 365695

URL: http://llvm.org/viewvc/llvm-project?rev=365695=rev
Log:
My first test commit.

Modified:
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp

Modified: 
cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp?rev=365695=365694=365695=diff
==
--- cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp 
(original)
+++ cfe/trunk/test/CXX/concepts-ts/dcl.dcl/dcl.spec/dcl.spec.concept/p1.cpp Wed 
Jul 10 13:01:44 2019
@@ -30,6 +30,7 @@ template
 concept bool D7() throw(int) { return true; } // expected-error {{function 
concept cannot have exception specification}}
 
 // Tag
+
 concept class CC1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
 concept struct CS1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}
 concept union CU1 {}; // expected-error {{'concept' can only appear on the 
definition of a function template or variable template}}


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


[PATCH] D64525: [clang-scan-deps] Dependency directives source minimizer: single quotes are not digit separators after a valid character literal prefix

2019-07-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman marked an inline comment as done.
arphaman added inline comments.



Comment at: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp:270
+return false;
+  if (Prev == '8' && (Cur - 1 != Start) && *(Cur - 2) == 'u')
+return false;

Bigcheese wrote:
> Are we sure at this point that it's always safe to jump back 2?
It should be, because otherwise `Start` would've been equals to `Cur - 1` which 
we check for right before the dereference.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64525



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


[PATCH] D64525: [clang-scan-deps] Dependency directives source minimizer: single quotes are not digit separators after a valid character literal prefix

2019-07-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman marked an inline comment as done.
arphaman added inline comments.



Comment at: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp:265-272
+  // Make sure that the L, u, U, u8 prefixes don't get marked as a
+  // separator though.
+  char Prev = *(Cur - 1);
+  if (Prev == 'L' || Prev == 'U' || Prev == 'u')
+return false;
+  if (Prev == '8' && (Cur - 1 != Start) && *(Cur - 2) == 'u')
+return false;

dexonsmith wrote:
> I wonder if this would be easier to identify walking forward from `Start` 
> rather than working backwards from `Cur`.
Yes, that's a possible option. We can scan scanning from start, until we reach 
non-whitespace right before Cur, and then identify the token. 

In such ambiguous cases it might be a good idea to raw lex the line using the 
Lexer from Start to End. Then we'll match the behavior of Lexer when there's an 
actual error as well. I'll see if I can setup a fallback like this in a 
follow-up patch.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64525



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


[PATCH] D64494: [analyzer]Add user docs rst

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

Np, please leave it in! :)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64494



___
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-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Ugh, i forced a lot of boilerplate on you. Hope it was worth it >.<

Thank you!~




Comment at: test/Analysis/cfg-openmp.cpp:3
+
+// CHECK:void xxx(int argc)
+// CHECK:[B1]

Those are quite readable because of very verbose pretty-prints but generally i 
prefer to interleave code and `CHECK:` lines so that to easily see both on one 
screen and know what corresponds to what.


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] D64526: [NFC] Unforget a colon in a few CHECK: directives.

2019-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 209046.
NoQ added a reviewer: Anastasia.
NoQ added a comment.

Found one more forgotten colon by grepping for `//CHECK ` instead of `// CHECK 
`.

Removed the FIXME for @ABataev so that not to cause merge conflicts when he 
fixes the test.

P.S. I didn't grep for custom FileCheck prefixes. Those may have more bugs.


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

https://reviews.llvm.org/D64526

Files:
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/CodeGenCXX/noescape.cpp
  clang/test/CodeGenObjC/externally-retained.m
  clang/test/CodeGenOpenCLCXX/addrspace-operators.cl


Index: clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
@@ -46,7 +46,7 @@
 //CHECK: %me = getelementptr inbounds %class.C, %class.C addrspace(4)* %this1, 
i32 0, i32 0
 //CHECK: store i32 [[E]], i32 addrspace(4)* %me
 
-//CHECK define linkonce_odr void @_ZNU3AS41C8OrAssignE1E(%class.C 
addrspace(4)* %this, i32 %e)
+//CHECK: define linkonce_odr void @_ZNU3AS41C8OrAssignE1E(%class.C 
addrspace(4)* %this, i32 %e)
 //CHECK: [[E:%[0-9]+]] = load i32, i32* %e.addr
 //CHECK: %mi = getelementptr inbounds %class.C, %class.C addrspace(4)* %this1, 
i32 0, i32 1
 //CHECK: [[MI:%[0-9]+]] = load i32, i32 addrspace(4)* %mi
Index: clang/test/CodeGenObjC/externally-retained.m
===
--- clang/test/CodeGenObjC/externally-retained.m
+++ clang/test/CodeGenObjC/externally-retained.m
@@ -22,7 +22,7 @@
 void param(ObjTy *p) EXT_RET {
   // CHECK-LABEL: define void @param
   // CHECK-NOT: llvm.objc.
-  // CHECK ret
+  // CHECK: ret
 }
 
 void local() {
Index: clang/test/CodeGenCXX/noescape.cpp
===
--- clang/test/CodeGenCXX/noescape.cpp
+++ clang/test/CodeGenCXX/noescape.cpp
@@ -45,7 +45,7 @@
 }
 
 // CHECK-LABEL: define i8* @_Z5test1Pv(
-// CHECK : %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
+// CHECK: %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
 void *test1(void *p0) {
   return ::operator new(16, p0);
 }
Index: clang/test/Analysis/cfg-rich-constructors.cpp
===
--- clang/test/Analysis/cfg-rich-constructors.cpp
+++ clang/test/Analysis/cfg-rich-constructors.cpp
@@ -459,7 +459,7 @@
 // TODO: Should provide construction context for the constructor,
 // even if there is no specific trigger statement here.
 // CHECK: void simpleTemporary()
-// CHECK   1: C() (CXXConstructExpr, class C)
+// CHECK:  1: C() (CXXConstructExpr, class C)
 void simpleTemporary() {
   C();
 }


Index: clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
@@ -46,7 +46,7 @@
 //CHECK: %me = getelementptr inbounds %class.C, %class.C addrspace(4)* %this1, i32 0, i32 0
 //CHECK: store i32 [[E]], i32 addrspace(4)* %me
 
-//CHECK define linkonce_odr void @_ZNU3AS41C8OrAssignE1E(%class.C addrspace(4)* %this, i32 %e)
+//CHECK: define linkonce_odr void @_ZNU3AS41C8OrAssignE1E(%class.C addrspace(4)* %this, i32 %e)
 //CHECK: [[E:%[0-9]+]] = load i32, i32* %e.addr
 //CHECK: %mi = getelementptr inbounds %class.C, %class.C addrspace(4)* %this1, i32 0, i32 1
 //CHECK: [[MI:%[0-9]+]] = load i32, i32 addrspace(4)* %mi
Index: clang/test/CodeGenObjC/externally-retained.m
===
--- clang/test/CodeGenObjC/externally-retained.m
+++ clang/test/CodeGenObjC/externally-retained.m
@@ -22,7 +22,7 @@
 void param(ObjTy *p) EXT_RET {
   // CHECK-LABEL: define void @param
   // CHECK-NOT: llvm.objc.
-  // CHECK ret
+  // CHECK: ret
 }
 
 void local() {
Index: clang/test/CodeGenCXX/noescape.cpp
===
--- clang/test/CodeGenCXX/noescape.cpp
+++ clang/test/CodeGenCXX/noescape.cpp
@@ -45,7 +45,7 @@
 }
 
 // CHECK-LABEL: define i8* @_Z5test1Pv(
-// CHECK : %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
+// CHECK: %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
 void *test1(void *p0) {
   return ::operator new(16, p0);
 }
Index: clang/test/Analysis/cfg-rich-constructors.cpp
===
--- clang/test/Analysis/cfg-rich-constructors.cpp
+++ clang/test/Analysis/cfg-rich-constructors.cpp
@@ -459,7 +459,7 @@
 // TODO: Should provide construction context for the constructor,
 // even if there is no specific trigger statement here.
 // CHECK: void simpleTemporary()
-// CHECK   1: C() (CXXConstructExpr, class C)
+// CHECK:  1: C() (CXXConstructExpr, class C)
 void 

[PATCH] D64526: [NFC] Unforget a colon in a few CHECK: directives.

2019-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: clang/test/OpenMP/sections_lastprivate_codegen.cpp:31
+
+// FIXME: This line doesn't work.
 // CHECK [[CAP_MAIN_TY:%.+]] = type { i{{[0-9]+}}*, [2 x i{{[0-9]+}}]*, [2 x 
[[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, i{{[0-9]+}}* }

ABataev wrote:
> I'll fix this test.
Yay!


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

https://reviews.llvm.org/D64526



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


[PATCH] D64525: [clang-scan-deps] Dependency directives source minimizer: single quotes are not digit separators after a valid character literal prefix

2019-07-10 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added inline comments.



Comment at: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp:270
+return false;
+  if (Prev == '8' && (Cur - 1 != Start) && *(Cur - 2) == 'u')
+return false;

Are we sure at this point that it's always safe to jump back 2?


Repository:
  rC Clang

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

https://reviews.llvm.org/D64525



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


r365691 - [OPENMP]Remove not used check line from the test, NFC.

2019-07-10 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Jul 10 12:30:25 2019
New Revision: 365691

URL: http://llvm.org/viewvc/llvm-project?rev=365691=rev
Log:
[OPENMP]Remove not used check line from the test, NFC.

Modified:
cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp

Modified: cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp?rev=365691=365690=365691=diff
==
--- cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/sections_lastprivate_codegen.cpp Wed Jul 10 12:30:25 
2019
@@ -27,7 +27,6 @@ struct S {
 volatile int g = 1212;
 
 // CHECK: [[S_FLOAT_TY:%.+]] = type { float }
-// CHECK [[CAP_MAIN_TY:%.+]] = type { i{{[0-9]+}}*, [2 x i{{[0-9]+}}]*, [2 x 
[[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, i{{[0-9]+}}* }
 // CHECK: [[S_INT_TY:%.+]] = type { i32 }
 // CHECK-DAG: [[SECTIONS_BARRIER_LOC:@.+]] = private unnamed_addr global 
%{{.+}} { i32 0, i32 194, i32 0, i32 0, i8*
 // CHECK-DAG: [[X:@.+]] = global double 0.0


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


[PATCH] D64494: [analyzer]Add user docs rst

2019-07-10 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> In any case, LGTM, if this really is a beginning of porting the already 
> existing documentation to sphinx.

This is really the beginning of porting the existing docs to sphinx which is 
supposedly going to be done by @dkrupp. And I am planning to add new user 
manual documentation about CTU.

> I guess any time we modify analyzer stuff, we may invite the main analyzer 
> developers to the patch review as well.

Yes, I agree. I was under the impression that there is already a consensus 
between the analyzer devs about the sphinx movement. If there is not, please 
indicate and I'll revert.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64494



___
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-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 209042.
ABataev added a comment.

Improved code.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64356

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/StmtOpenMP.h
  lib/AST/OpenMPClause.cpp
  lib/Analysis/CFG.cpp
  lib/Analysis/UninitializedValues.cpp
  test/Analysis/cfg-openmp.cpp
  test/OpenMP/atomic_messages.c
  test/OpenMP/critical_messages.cpp
  test/OpenMP/distribute_parallel_for_messages.cpp
  test/OpenMP/distribute_parallel_for_simd_misc_messages.c
  test/OpenMP/distribute_simd_misc_messages.c
  test/OpenMP/for_misc_messages.c
  test/OpenMP/for_simd_misc_messages.c
  test/OpenMP/master_messages.cpp
  test/OpenMP/ordered_messages.cpp
  test/OpenMP/parallel_for_messages.cpp
  test/OpenMP/parallel_for_simd_messages.cpp
  test/OpenMP/parallel_messages.cpp
  test/OpenMP/parallel_sections_messages.cpp
  test/OpenMP/sections_misc_messages.c
  test/OpenMP/simd_misc_messages.c
  test/OpenMP/single_misc_messages.c
  test/OpenMP/target_depend_messages.cpp
  test/OpenMP/target_parallel_for_messages.cpp
  test/OpenMP/target_parallel_for_simd_messages.cpp
  test/OpenMP/target_parallel_messages.cpp
  test/OpenMP/target_simd_messages.cpp
  test/OpenMP/target_teams_distribute_messages.cpp
  test/OpenMP/target_teams_distribute_parallel_for_messages.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_messages.cpp
  test/OpenMP/target_teams_distribute_simd_messages.cpp
  test/OpenMP/target_teams_messages.cpp
  test/OpenMP/target_update_messages.cpp
  test/OpenMP/task_messages.cpp
  test/OpenMP/taskgroup_messages.cpp
  test/OpenMP/taskloop_misc_messages.c
  test/OpenMP/taskloop_simd_misc_messages.c
  test/OpenMP/teams_distribute_parallel_for_messages.cpp
  test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
  test/OpenMP/teams_distribute_simd_messages.cpp
  test/OpenMP/teams_messages.cpp

Index: test/OpenMP/teams_messages.cpp
===
--- test/OpenMP/teams_messages.cpp
+++ test/OpenMP/teams_messages.cpp
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -o - %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target
+#pragma omp teams
+  argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
Index: test/OpenMP/teams_distribute_simd_messages.cpp
===
--- test/OpenMP/teams_distribute_simd_messages.cpp
+++ test/OpenMP/teams_distribute_simd_messages.cpp
@@ -2,6 +2,14 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute simd
+  for (int i = 0; i < 10; ++i)
+argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
Index: test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
===
--- test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
+++ test/OpenMP/teams_distribute_parallel_for_simd_messages.cpp
@@ -2,6 +2,14 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute parallel for simd
+  for (int i = 0; i < 10; ++i)
+argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
Index: test/OpenMP/teams_distribute_parallel_for_messages.cpp
===
--- test/OpenMP/teams_distribute_parallel_for_messages.cpp
+++ test/OpenMP/teams_distribute_parallel_for_messages.cpp
@@ -2,6 +2,14 @@
 
 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp target
+#pragma omp teams distribute parallel for
+  for (int i = 0; i < 10; ++i)
+argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 void foo() {
 }
 
Index: test/OpenMP/taskloop_simd_misc_messages.c
===
--- test/OpenMP/taskloop_simd_misc_messages.c
+++ test/OpenMP/taskloop_simd_misc_messages.c
@@ -2,6 +2,13 @@
 
 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -triple x86_64-unknown-unknown -verify %s -Wuninitialized
 
+void xxx(int argc) {
+  int x; // expected-note {{initialize the variable 'x' to silence this warning}}
+#pragma omp taskloop simd
+  for (int i = 0; i < 10; ++i)
+argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
+}
+
 // 

[PATCH] D64527: driver: Don't warn about assembler flags being unused when not assembling

2019-07-10 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.
Herald added subscribers: kristof.beyls, javed.absar.

clang currently warns when passing flags for the assembler (e.g.
-Wa,-mbig-obj) to an invocation that doesn't run the assembler (e.g.
-E).

At first sight, that makes sense -- the flag really is unused. But many
other flags don't have an effect if no assembler runs (e.g.
-fno-integrated-as, -ffunction-sections, and many others), and those
currently don't warn. So this seems more like a side effect of how
CollectArgsForIntegratedAssembler() is implemented than like an
intentional feature.

Since it's a bit inconvenient when debugging builds and adding -E,
always call CollectArgsForIntegratedAssembler() to make sure assembler
args always get claimed. Currently, this affects only these flags:
-mincremental-linker-compatible, -mimplicit-it= (on ARM), -Wa, -Xassembler

It does have the side effect that assembler options now need to be valid
even if -E is passed. Previously, `-Wa,-mbig-obj` would error for
non-coff output only if the assembler ran, now it always errors. This
too makes assembler flags more consistent with all the other flags and
seems like a progression.

Fixes PR42066.


https://reviews.llvm.org/D64527

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/as-options.s


Index: clang/test/Driver/as-options.s
===
--- clang/test/Driver/as-options.s
+++ clang/test/Driver/as-options.s
@@ -35,3 +35,14 @@
 // RUN:   | FileCheck %s
 
 // CHECK: "-I" "foo_dir"
+
+// Test that assembler options don't cause warnings when there's no assembler
+// stage.
+
+// RUN: %clang -mincremental-linker-compatible -E -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN --allow-empty %s
+// RUN: %clang -mimplicit-it=always -target armv7-linux-gnueabihf -E %s \
+// RUN:   | FileCheck --check-prefix=WARN --allow-empty %s
+// RUN: %clang -Wa,-mbig-obj -target i386-pc-windows -E %s \
+// RUN:   | FileCheck --check-prefix=WARN --allow-empty %s
+// WARN-NOT: unused
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3545,6 +3545,18 @@
   // Select the appropriate action.
   RewriteKind rewriteKind = RK_None;
 
+  // If CollectArgsForIntegratedAssembler() isn't called below, call it here
+  // with a dummy args list to mark assembler flags as used even when not
+  // running an assembler. Otherwise, clang would emit "argument unused"
+  // warnings for assembler flags when e.g. adding "-E" to flags while 
debugging
+  // something. That'd be somewhat inconvenient, and it's also inconsistent 
with
+  // most other flags -- we don't warn on -ffunction-sections not being used
+  // in -E mode either for example, even though it's not really used either.
+  if (!isa(JA)) {
+ArgStringList DummyArgs;
+CollectArgsForIntegratedAssembler(C, Args, DummyArgs, D);
+  }
+
   if (isa(JA)) {
 assert(JA.getType() == types::TY_Plist && "Invalid output type.");
 CmdArgs.push_back("-analyze");


Index: clang/test/Driver/as-options.s
===
--- clang/test/Driver/as-options.s
+++ clang/test/Driver/as-options.s
@@ -35,3 +35,14 @@
 // RUN:   | FileCheck %s
 
 // CHECK: "-I" "foo_dir"
+
+// Test that assembler options don't cause warnings when there's no assembler
+// stage.
+
+// RUN: %clang -mincremental-linker-compatible -E -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN --allow-empty %s
+// RUN: %clang -mimplicit-it=always -target armv7-linux-gnueabihf -E %s \
+// RUN:   | FileCheck --check-prefix=WARN --allow-empty %s
+// RUN: %clang -Wa,-mbig-obj -target i386-pc-windows -E %s \
+// RUN:   | FileCheck --check-prefix=WARN --allow-empty %s
+// WARN-NOT: unused
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3545,6 +3545,18 @@
   // Select the appropriate action.
   RewriteKind rewriteKind = RK_None;
 
+  // If CollectArgsForIntegratedAssembler() isn't called below, call it here
+  // with a dummy args list to mark assembler flags as used even when not
+  // running an assembler. Otherwise, clang would emit "argument unused"
+  // warnings for assembler flags when e.g. adding "-E" to flags while debugging
+  // something. That'd be somewhat inconvenient, and it's also inconsistent with
+  // most other flags -- we don't warn on -ffunction-sections not being used
+  // in -E mode either for example, even though it's not really used either.
+  if (!isa(JA)) {
+ArgStringList DummyArgs;
+CollectArgsForIntegratedAssembler(C, Args, DummyArgs, D);
+  }
+
   if (isa(JA)) {
 assert(JA.getType() == types::TY_Plist && "Invalid output type.");
 

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

2019-07-10 Thread Julie Hockett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365687: [clang-doc] Add a structured HTML generator 
(authored by juliehockett, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63857?vs=208792=209040#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63857

Files:
  clang-tools-extra/trunk/clang-doc/CMakeLists.txt
  clang-tools-extra/trunk/clang-doc/Generators.cpp
  clang-tools-extra/trunk/clang-doc/Generators.h
  clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/trunk/clang-doc/MDGenerator.cpp
  clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt
  clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp

Index: clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt
===
--- clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt
+++ clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt
@@ -12,6 +12,7 @@
 add_extra_unittest(ClangDocTests
   BitcodeTest.cpp
   ClangDocTest.cpp
+  HTMLGeneratorTest.cpp
   MDGeneratorTest.cpp
   MergeTest.cpp
   SerializeTest.cpp
Index: clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
===
--- clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -0,0 +1,276 @@
+//===-- clang-doc/HTMLGeneratorTest.cpp ---===//
+//
+// 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 "ClangDocTest.h"
+#include "Generators.h"
+#include "Representation.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace doc {
+
+std::unique_ptr getHTMLGenerator() {
+  auto G = doc::findGeneratorByName("html");
+  if (!G)
+return nullptr;
+  return std::move(G.get());
+}
+
+TEST(HTMLGeneratorTest, emitNamespaceHTML) {
+  NamespaceInfo I;
+  I.Name = "Namespace";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.ChildNamespaces.emplace_back(EmptySID, "ChildNamespace",
+ InfoType::IT_namespace);
+  I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
+  I.ChildFunctions.emplace_back();
+  I.ChildFunctions.back().Name = "OneFunction";
+  I.ChildEnums.emplace_back();
+  I.ChildEnums.back().Name = "OneEnum";
+
+  auto G = getHTMLGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(, Actual);
+  assert(!Err);
+  std::string Expected = R"raw(
+
+namespace Namespace
+
+  namespace Namespace
+  Namespaces
+  
+ChildNamespace
+  
+  Records
+  
+ChildStruct
+  
+  Functions
+  
+OneFunction
+
+   OneFunction()
+
+  
+  Enums
+  
+enum OneEnum
+  
+
+)raw";
+
+  EXPECT_EQ(Expected, Actual.str());
+}
+
+TEST(HTMLGeneratorTest, emitRecordHTML) {
+  RecordInfo I;
+  I.Name = "r";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
+  I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
+
+  I.Members.emplace_back("int", "X", AccessSpecifier::AS_private);
+  I.TagType = TagTypeKind::TTK_Class;
+  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
+  I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
+
+  I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
+  I.ChildFunctions.emplace_back();
+  I.ChildFunctions.back().Name = "OneFunction";
+  I.ChildEnums.emplace_back();
+  I.ChildEnums.back().Name = "OneEnum";
+
+  auto G = getHTMLGenerator();
+  assert(G);
+  std::string Buffer;
+  llvm::raw_string_ostream Actual(Buffer);
+  auto Err = G->generateDocForInfo(, Actual);
+  assert(!Err);
+  std::string Expected = R"raw(
+
+class r
+
+  class r
+  
+Defined at line 10 of test.cpp
+  
+  
+Inherits from F, G
+  
+  Members
+  
+private int X
+  
+  Records
+  
+ChildStruct
+  
+  Functions
+  
+OneFunction
+
+   OneFunction()
+
+  
+  Enums
+  
+enum OneEnum
+  
+
+)raw";
+
+  EXPECT_EQ(Expected, Actual.str());
+}
+
+TEST(HTMLGeneratorTest, emitFunctionHTML) {
+  FunctionInfo I;
+  I.Name = "f";
+  I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
+
+  I.DefLoc = Location(10, llvm::SmallString<16>{"test.cpp"});
+  I.Loc.emplace_back(12, llvm::SmallString<16>{"test.cpp"});
+
+  I.ReturnType = TypeInfo(EmptySID, "void", InfoType::IT_default);
+  

[clang-tools-extra] r365687 - [clang-doc] Add a structured HTML generator

2019-07-10 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Wed Jul 10 12:03:25 2019
New Revision: 365687

URL: http://llvm.org/viewvc/llvm-project?rev=365687=rev
Log:
[clang-doc] Add a structured HTML generator

Implements an HTML generator.
Nodes are used to represent each part of the HTML file. There are TagNodes that
represent every HTML tag (p, h1, div, ...) and they have children nodes, which
can be TagNodes or TextNodes (these nodes only have text).
Proper indentation is rendered within the files generated by tool.
No styling (CSS) is included.

Committed on behalf of Diego Astiazarán (diegoaa...@gmail.com)

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

Added:
clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
clang-tools-extra/trunk/unittests/clang-doc/HTMLGeneratorTest.cpp
Modified:
clang-tools-extra/trunk/clang-doc/CMakeLists.txt
clang-tools-extra/trunk/clang-doc/Generators.cpp
clang-tools-extra/trunk/clang-doc/Generators.h
clang-tools-extra/trunk/clang-doc/MDGenerator.cpp
clang-tools-extra/trunk/clang-doc/tool/ClangDocMain.cpp
clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-doc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/CMakeLists.txt?rev=365687=365686=365687=diff
==
--- clang-tools-extra/trunk/clang-doc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-doc/CMakeLists.txt Wed Jul 10 12:03:25 2019
@@ -8,6 +8,7 @@ add_clang_library(clangDoc
   BitcodeWriter.cpp
   ClangDoc.cpp
   Generators.cpp
+  HTMLGenerator.cpp
   Mapper.cpp
   MDGenerator.cpp
   Representation.cpp

Modified: clang-tools-extra/trunk/clang-doc/Generators.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Generators.cpp?rev=365687=365686=365687=diff
==
--- clang-tools-extra/trunk/clang-doc/Generators.cpp (original)
+++ clang-tools-extra/trunk/clang-doc/Generators.cpp Wed Jul 10 12:03:25 2019
@@ -25,14 +25,62 @@ findGeneratorByName(llvm::StringRef Form
  llvm::inconvertibleErrorCode());
 }
 
+// Enum conversion
+
+std::string getAccess(AccessSpecifier AS) {
+  switch (AS) {
+  case AccessSpecifier::AS_public:
+return "public";
+  case AccessSpecifier::AS_protected:
+return "protected";
+  case AccessSpecifier::AS_private:
+return "private";
+  case AccessSpecifier::AS_none:
+return {};
+  }
+  llvm_unreachable("Unknown AccessSpecifier");
+}
+
+std::string getTagType(TagTypeKind AS) {
+  switch (AS) {
+  case TagTypeKind::TTK_Class:
+return "class";
+  case TagTypeKind::TTK_Union:
+return "union";
+  case TagTypeKind::TTK_Interface:
+return "interface";
+  case TagTypeKind::TTK_Struct:
+return "struct";
+  case TagTypeKind::TTK_Enum:
+return "enum";
+  }
+  llvm_unreachable("Unknown TagTypeKind");
+}
+
+// Generates a comma-separated list of Refs
+// Used to display the parents of a record
+std::string genReferenceList(const llvm::SmallVectorImpl ) {
+  std::string Buffer;
+  llvm::raw_string_ostream Stream(Buffer);
+  for (const auto  : Refs) {
+if ( != Refs.begin())
+  Stream << ", ";
+Stream << R.Name;
+  }
+  return Stream.str();
+}
+
 // This anchor is used to force the linker to link in the generated object file
 // and thus register the generators.
 extern volatile int YAMLGeneratorAnchorSource;
 extern volatile int MDGeneratorAnchorSource;
+extern volatile int HTMLGeneratorAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED YAMLGeneratorAnchorDest =
 YAMLGeneratorAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED MDGeneratorAnchorDest =
 MDGeneratorAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED HTMLGeneratorAnchorDest =
+HTMLGeneratorAnchorSource;
 
 } // namespace doc
 } // namespace clang

Modified: clang-tools-extra/trunk/clang-doc/Generators.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/Generators.h?rev=365687=365686=365687=diff
==
--- clang-tools-extra/trunk/clang-doc/Generators.h (original)
+++ clang-tools-extra/trunk/clang-doc/Generators.h Wed Jul 10 12:03:25 2019
@@ -34,6 +34,12 @@ typedef llvm::Registry Genera
 llvm::Expected>
 findGeneratorByName(llvm::StringRef Format);
 
+std::string getAccess(AccessSpecifier AS);
+
+std::string getTagType(TagTypeKind AS);
+
+std::string genReferenceList(const llvm::SmallVectorImpl );
+
 } // namespace doc
 } // namespace clang
 

Added: clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp?rev=365687=auto
==
--- clang-tools-extra/trunk/clang-doc/HTMLGenerator.cpp (added)
+++ 

[PATCH] D64526: [NFC] Unforget a colon in a few CHECK: directives.

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



Comment at: clang/test/OpenMP/sections_lastprivate_codegen.cpp:31
+
+// FIXME: This line doesn't work.
 // CHECK [[CAP_MAIN_TY:%.+]] = type { i{{[0-9]+}}*, [2 x i{{[0-9]+}}]*, [2 x 
[[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, i{{[0-9]+}}* }

I'll fix this test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64526



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


[PATCH] D64525: [clang-scan-deps] Dependency directives source minimizer: single quotes are not digit separators after a valid character literal prefix

2019-07-10 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM, but I have a suggestion inline for another approach.




Comment at: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp:265-272
+  // Make sure that the L, u, U, u8 prefixes don't get marked as a
+  // separator though.
+  char Prev = *(Cur - 1);
+  if (Prev == 'L' || Prev == 'U' || Prev == 'u')
+return false;
+  if (Prev == '8' && (Cur - 1 != Start) && *(Cur - 2) == 'u')
+return false;

I wonder if this would be easier to identify walking forward from `Start` 
rather than working backwards from `Cur`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64525



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


[PATCH] D64526: [NFC] Unforget a colon in a few CHECK: directives.

2019-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: kkwli0, ABataev, ahatanak, erik.pilkington.
Herald added subscribers: cfe-commits, Charusso, jdoerfert, dexonsmith.
Herald added a project: clang.

I noticed that people occasionally forget that unlike `CHECK:`, directives 
`CHECK` and `CHECK :` are not reacted upon by FileCheck. Tests still pass, but 
they don't actually test anything.

So i grepped real quick and found these four missing colons, one of which (the 
one in `Analysis/cfg-rich-constructors.cpp`) is mine. All four are in clang; 
there aren't any missing colons in other projects in the monorepo.

I'm not entirely sure about the change 
`OpenMP/sections_lastprivate_codegen.cpp`: it seems that replacing `CHECK:` 
with `CHECK` is a common way of making FIXME tests, but there's no indication 
anywhere that this is a known issue. The test was added in D11619 
.


Repository:
  rC Clang

https://reviews.llvm.org/D64526

Files:
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/CodeGenCXX/noescape.cpp
  clang/test/CodeGenObjC/externally-retained.m
  clang/test/OpenMP/sections_lastprivate_codegen.cpp


Index: clang/test/OpenMP/sections_lastprivate_codegen.cpp
===
--- clang/test/OpenMP/sections_lastprivate_codegen.cpp
+++ clang/test/OpenMP/sections_lastprivate_codegen.cpp
@@ -27,7 +27,10 @@
 volatile int g = 1212;
 
 // CHECK: [[S_FLOAT_TY:%.+]] = type { float }
+
+// FIXME: This line doesn't work.
 // CHECK [[CAP_MAIN_TY:%.+]] = type { i{{[0-9]+}}*, [2 x i{{[0-9]+}}]*, [2 x 
[[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, i{{[0-9]+}}* }
+
 // CHECK: [[S_INT_TY:%.+]] = type { i32 }
 // CHECK-DAG: [[SECTIONS_BARRIER_LOC:@.+]] = private unnamed_addr global 
%{{.+}} { i32 0, i32 194, i32 0, i32 0, i8*
 // CHECK-DAG: [[X:@.+]] = global double 0.0
Index: clang/test/CodeGenObjC/externally-retained.m
===
--- clang/test/CodeGenObjC/externally-retained.m
+++ clang/test/CodeGenObjC/externally-retained.m
@@ -22,7 +22,7 @@
 void param(ObjTy *p) EXT_RET {
   // CHECK-LABEL: define void @param
   // CHECK-NOT: llvm.objc.
-  // CHECK ret
+  // CHECK: ret
 }
 
 void local() {
Index: clang/test/CodeGenCXX/noescape.cpp
===
--- clang/test/CodeGenCXX/noescape.cpp
+++ clang/test/CodeGenCXX/noescape.cpp
@@ -45,7 +45,7 @@
 }
 
 // CHECK-LABEL: define i8* @_Z5test1Pv(
-// CHECK : %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
+// CHECK: %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
 void *test1(void *p0) {
   return ::operator new(16, p0);
 }
Index: clang/test/Analysis/cfg-rich-constructors.cpp
===
--- clang/test/Analysis/cfg-rich-constructors.cpp
+++ clang/test/Analysis/cfg-rich-constructors.cpp
@@ -459,7 +459,7 @@
 // TODO: Should provide construction context for the constructor,
 // even if there is no specific trigger statement here.
 // CHECK: void simpleTemporary()
-// CHECK   1: C() (CXXConstructExpr, class C)
+// CHECK:  1: C() (CXXConstructExpr, class C)
 void simpleTemporary() {
   C();
 }


Index: clang/test/OpenMP/sections_lastprivate_codegen.cpp
===
--- clang/test/OpenMP/sections_lastprivate_codegen.cpp
+++ clang/test/OpenMP/sections_lastprivate_codegen.cpp
@@ -27,7 +27,10 @@
 volatile int g = 1212;
 
 // CHECK: [[S_FLOAT_TY:%.+]] = type { float }
+
+// FIXME: This line doesn't work.
 // CHECK [[CAP_MAIN_TY:%.+]] = type { i{{[0-9]+}}*, [2 x i{{[0-9]+}}]*, [2 x [[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, i{{[0-9]+}}* }
+
 // CHECK: [[S_INT_TY:%.+]] = type { i32 }
 // CHECK-DAG: [[SECTIONS_BARRIER_LOC:@.+]] = private unnamed_addr global %{{.+}} { i32 0, i32 194, i32 0, i32 0, i8*
 // CHECK-DAG: [[X:@.+]] = global double 0.0
Index: clang/test/CodeGenObjC/externally-retained.m
===
--- clang/test/CodeGenObjC/externally-retained.m
+++ clang/test/CodeGenObjC/externally-retained.m
@@ -22,7 +22,7 @@
 void param(ObjTy *p) EXT_RET {
   // CHECK-LABEL: define void @param
   // CHECK-NOT: llvm.objc.
-  // CHECK ret
+  // CHECK: ret
 }
 
 void local() {
Index: clang/test/CodeGenCXX/noescape.cpp
===
--- clang/test/CodeGenCXX/noescape.cpp
+++ clang/test/CodeGenCXX/noescape.cpp
@@ -45,7 +45,7 @@
 }
 
 // CHECK-LABEL: define i8* @_Z5test1Pv(
-// CHECK : %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
+// CHECK: %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
 void *test1(void *p0) {
   return ::operator new(16, p0);
 }
Index: clang/test/Analysis/cfg-rich-constructors.cpp
===
--- clang/test/Analysis/cfg-rich-constructors.cpp
+++ 

[PATCH] D62584: [OpenCL][PR42033] Deducing addr space with template parameter types

2019-07-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: lib/Sema/TreeTransform.h:5363
+if (ResultType.getAddressSpace() != LangAS::Default &&
+(ResultType.getAddressSpace() != LangAS::opencl_private)) {
   SemaRef.Diag(TL.getReturnLoc().getBeginLoc(),

rjmccall wrote:
> Anastasia wrote:
> > Anastasia wrote:
> > > rjmccall wrote:
> > > > Anastasia wrote:
> > > > > I am trying to be a bit more helpful here although I am not sure if 
> > > > > we should instead require explicit template parameter and fail the 
> > > > > template deduction instead.
> > > > > 
> > > > > Basically, do we want the following code to always require specifying 
> > > > > template argument explicitly:
> > > > > 
> > > > > 
> > > > > ```
> > > > > template 
> > > > > T xxx(T *in) {
> > > > >   T *i = in;
> > > > >   return *i;
> > > > > }
> > > > > 
> > > > > __kernel void test() {
> > > > >   int foo[10];
> > > > >   xxx([0]); // if we deduce type from foo, it ends up being 
> > > > > qualified by __private that we currently diagnose. However private is 
> > > > > default (implicit) address space for return type so technically there 
> > > > > is no danger in just allowing xxx([0])
> > > > > }
> > > > > ```
> > > > Implicitly ignoring all address-space qualifiers on the return type 
> > > > seems like the right thing to do; I don't think it needs to be limited 
> > > > to `__private`.  That's probably also the right thing to do for locals, 
> > > > but I'm less certain about it.
> > > Just to clarify by "Implicitly ignoring" you mean ignoring if the templ 
> > > parameters were deduced?
> > > 
> > > Although I am a bit concerned about allowing other than `__private` 
> > > address spaces in return types as we reject them in return types of 
> > > functions generally. Would it not be somehow inconsistent?
> > Ok, I have removed the diagnostic completely. At least we don't seem to 
> > generate any incorrect IR.
> They should be diagnosed somehow when written explicitly on a return type, 
> but if you just do that on the parser path you don't have to worry about it 
> during template instantiation.  They should probably otherwise be ignored no 
> matter where they came from — if someone typedefs `private_int_t` to 
> `__private int`, you should just treat that as `int` in a return type.  
> Stripping the qualifier from the type is probably the right thing to do so 
> that it doesn't further impact semantic analysis.
> 
> I definitely don't think you want a model where the qualifier actually means 
> that the return is somehow done via an object in that address space.
> They should be diagnosed somehow when written explicitly on a return type, 
> but if you just do that on the parser path you don't have to worry about it 
> during template instantiation.

Ok, this seems to be working currently. The following won't compile:

```
template 
struct S {
  __global T f1(); // error: return value cannot be qualified with address 
space
};

```

> They should probably otherwise be ignored no matter where they came from — if 
> someone typedefs private_int_t to __private int, you should just treat that 
> as int in a return type.

We produce diagnostic for this case currently. I can update this in a separate 
patch if you think it's more helpful behavior. Although I feel a bit worried 
about it. However it would align with what we are doing with templates here... 
so perhaps it's logical change... 

> Stripping the qualifier from the type is probably the right thing to do so 
> that it doesn't further impact semantic analysis.

I guess you mean stripping quals for the case of typedef or others where we 
will accept the code and ignore quals on the return type? I have tried to do 
this just for the template case but there are some assertions firing because we 
are expecting the original return type to be the same before and after template 
instantiation. So it feels like I would have to do it for everything together. 
Maybe it should rather go into separate review?


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

https://reviews.llvm.org/D62584



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


[PATCH] D64525: [clang-scan-deps] Dependency directives source minimizer: single quotes are not digit separators after a valid character literal prefix

2019-07-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added a reviewer: Bigcheese.
Herald added subscribers: tschuett, dexonsmith, jkorous.
Herald added a project: clang.

The single quote character can act as a c++ digit separator. However, the 
minimizer shouldn't treat it as such when it's actually following a valid 
character literal prefix, like `L`, `U`, `u`, or `u8`.


Repository:
  rC Clang

https://reviews.llvm.org/D64525

Files:
  clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp


Index: clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
===
--- clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
+++ clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
@@ -507,4 +507,41 @@
   EXPECT_STREQ("#include \n#include \n", Out.data());
 }
 
+TEST(MinimizeSourceToDependencyDirectivesTest, CharacterLiteralPrefixL) {
+  SmallVector Out;
+
+  StringRef Source = R"(L'P'
+#if DEBUG
+// '
+#endif
+#include 
+)";
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+  EXPECT_STREQ("#include \n", Out.data());
+}
+
+TEST(MinimizeSourceToDependencyDirectivesTest, CharacterLiteralPrefixU) {
+  SmallVector Out;
+
+  StringRef Source = R"(int x = U'P';
+#include 
+// '
+)";
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+  EXPECT_STREQ("#include \n", Out.data());
+}
+
+TEST(MinimizeSourceToDependencyDirectivesTest, CharacterLiteralPrefixu) {
+  SmallVector Out;
+
+  StringRef Source = R"(int x = u'b';
+int y = u8'a';
+int z = 128'78;
+#include 
+// '
+)";
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+  EXPECT_STREQ("#include \n", Out.data());
+}
+
 } // end anonymous namespace
Index: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -262,7 +262,14 @@
   if (Start == Cur)
 return false;
   // The previous character must be a valid PP number character.
-  if (!isPreprocessingNumberBody(*(Cur - 1)))
+  // Make sure that the L, u, U, u8 prefixes don't get marked as a
+  // separator though.
+  char Prev = *(Cur - 1);
+  if (Prev == 'L' || Prev == 'U' || Prev == 'u')
+return false;
+  if (Prev == '8' && (Cur - 1 != Start) && *(Cur - 2) == 'u')
+return false;
+  if (!isPreprocessingNumberBody(Prev))
 return false;
   // The next character should be a valid identifier body character.
   return (Cur + 1) < End && isIdentifierBody(*(Cur + 1));


Index: clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
===
--- clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
+++ clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
@@ -507,4 +507,41 @@
   EXPECT_STREQ("#include \n#include \n", Out.data());
 }
 
+TEST(MinimizeSourceToDependencyDirectivesTest, CharacterLiteralPrefixL) {
+  SmallVector Out;
+
+  StringRef Source = R"(L'P'
+#if DEBUG
+// '
+#endif
+#include 
+)";
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+  EXPECT_STREQ("#include \n", Out.data());
+}
+
+TEST(MinimizeSourceToDependencyDirectivesTest, CharacterLiteralPrefixU) {
+  SmallVector Out;
+
+  StringRef Source = R"(int x = U'P';
+#include 
+// '
+)";
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+  EXPECT_STREQ("#include \n", Out.data());
+}
+
+TEST(MinimizeSourceToDependencyDirectivesTest, CharacterLiteralPrefixu) {
+  SmallVector Out;
+
+  StringRef Source = R"(int x = u'b';
+int y = u8'a';
+int z = 128'78;
+#include 
+// '
+)";
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
+  EXPECT_STREQ("#include \n", Out.data());
+}
+
 } // end anonymous namespace
Index: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
===
--- clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
+++ clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
@@ -262,7 +262,14 @@
   if (Start == Cur)
 return false;
   // The previous character must be a valid PP number character.
-  if (!isPreprocessingNumberBody(*(Cur - 1)))
+  // Make sure that the L, u, U, u8 prefixes don't get marked as a
+  // separator though.
+  char Prev = *(Cur - 1);
+  if (Prev == 'L' || Prev == 'U' || Prev == 'u')
+return false;
+  if (Prev == '8' && (Cur - 1 != Start) && *(Cur - 2) == 'u')
+return false;
+  if (!isPreprocessingNumberBody(Prev))
 return false;
   // The next character should be a valid identifier body character.
   return (Cur + 1) < End && isIdentifierBody(*(Cur + 1));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64381: Update libc++ include path detection to use VFS on Linux

2019-07-10 Thread Julie Hockett via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365682: Update libc++ include path detection to use VFS on 
Linux (authored by juliehockett, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64381?vs=208546=209036#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64381

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


Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp
@@ -865,12 +865,13 @@
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
 }
 
-static std::string DetectLibcxxIncludePath(StringRef base) {
+static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem ,
+   StringRef base) {
   std::error_code EC;
   int MaxVersion = 0;
   std::string MaxVersionString = "";
-  for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE;
-   LI = LI.increment(EC)) {
+  for (llvm::vfs::directory_iterator LI = vfs.dir_begin(base, EC), LE;
+   !EC && LI != LE; LI = LI.increment(EC)) {
 StringRef VersionText = llvm::sys::path::filename(LI->path());
 int Version;
 if (VersionText[0] == 'v' &&
@@ -888,12 +889,12 @@
   llvm::opt::ArgStringList ) const {
   const std::string& SysRoot = computeSysRoot();
   const std::string LibCXXIncludePathCandidates[] = {
-  DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
+  DetectLibcxxIncludePath(getVFS(), getDriver().Dir + "/../include/c++"),
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
-  DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"),
-  DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") };
+  DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/local/include/c++"),
+  DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/include/c++") };
   for (const auto  : LibCXXIncludePathCandidates) {
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
   continue;


Index: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp
@@ -865,12 +865,13 @@
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
 }
 
-static std::string DetectLibcxxIncludePath(StringRef base) {
+static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem ,
+   StringRef base) {
   std::error_code EC;
   int MaxVersion = 0;
   std::string MaxVersionString = "";
-  for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE;
-   LI = LI.increment(EC)) {
+  for (llvm::vfs::directory_iterator LI = vfs.dir_begin(base, EC), LE;
+   !EC && LI != LE; LI = LI.increment(EC)) {
 StringRef VersionText = llvm::sys::path::filename(LI->path());
 int Version;
 if (VersionText[0] == 'v' &&
@@ -888,12 +889,12 @@
   llvm::opt::ArgStringList ) const {
   const std::string& SysRoot = computeSysRoot();
   const std::string LibCXXIncludePathCandidates[] = {
-  DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
+  DetectLibcxxIncludePath(getVFS(), getDriver().Dir + "/../include/c++"),
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
-  DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"),
-  DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") };
+  DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/local/include/c++"),
+  DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/include/c++") };
   for (const auto  : LibCXXIncludePathCandidates) {
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r365682 - Update libc++ include path detection to use VFS on Linux

2019-07-10 Thread Julie Hockett via cfe-commits
Author: juliehockett
Date: Wed Jul 10 11:41:35 2019
New Revision: 365682

URL: http://llvm.org/viewvc/llvm-project?rev=365682=rev
Log:
Update libc++ include path detection to use VFS on Linux

The DetectLibcxxIncludePath function had been using
llvm::sys::fs::directory_iterator, and this updates it to use
llvm::vfs::directory_iterator.

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

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

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=365682=365681=365682=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Wed Jul 10 11:41:35 2019
@@ -865,12 +865,13 @@ void Linux::AddClangSystemIncludeArgs(co
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
 }
 
-static std::string DetectLibcxxIncludePath(StringRef base) {
+static std::string DetectLibcxxIncludePath(llvm::vfs::FileSystem ,
+   StringRef base) {
   std::error_code EC;
   int MaxVersion = 0;
   std::string MaxVersionString = "";
-  for (llvm::sys::fs::directory_iterator LI(base, EC), LE; !EC && LI != LE;
-   LI = LI.increment(EC)) {
+  for (llvm::vfs::directory_iterator LI = vfs.dir_begin(base, EC), LE;
+   !EC && LI != LE; LI = LI.increment(EC)) {
 StringRef VersionText = llvm::sys::path::filename(LI->path());
 int Version;
 if (VersionText[0] == 'v' &&
@@ -888,12 +889,12 @@ void Linux::addLibCxxIncludePaths(const
   llvm::opt::ArgStringList ) const {
   const std::string& SysRoot = computeSysRoot();
   const std::string LibCXXIncludePathCandidates[] = {
-  DetectLibcxxIncludePath(getDriver().Dir + "/../include/c++"),
+  DetectLibcxxIncludePath(getVFS(), getDriver().Dir + "/../include/c++"),
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
-  DetectLibcxxIncludePath(SysRoot + "/usr/local/include/c++"),
-  DetectLibcxxIncludePath(SysRoot + "/usr/include/c++") };
+  DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/local/include/c++"),
+  DetectLibcxxIncludePath(getVFS(), SysRoot + "/usr/include/c++") };
   for (const auto  : LibCXXIncludePathCandidates) {
 if (IncludePath.empty() || !getVFS().exists(IncludePath))
   continue;


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


[clang-tools-extra] r365678 - Revert "[clangd] Filter out non-governed files from broadcast"

2019-07-10 Thread Matthew Voss via cfe-commits
Author: ormris
Date: Wed Jul 10 11:16:35 2019
New Revision: 365678

URL: http://llvm.org/viewvc/llvm-project?rev=365678=rev
Log:
Revert "[clangd] Filter out non-governed files from broadcast"

This reverts commit d5214dfa7b5650745eaeb102857c9e90adb16137.

It's causing failures, both in our local CI and the PS4 Windows bot.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/26872/steps/test/logs/stdio

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

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=365678=365677=365678=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Jul 10 
11:16:35 2019
@@ -8,18 +8,12 @@
 
 #include "GlobalCompilationDatabase.h"
 #include "Logger.h"
-#include "Path.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CompilationDatabase.h"
-#include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
-#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include 
-#include 
-#include 
 
 namespace clang {
 namespace clangd {
@@ -49,16 +43,6 @@ std::string getStandardResourceDir() {
   return CompilerInvocation::GetResourcesPath("clangd", (void *));
 }
 
-// Runs the given action on all parent directories of filename, starting from
-// deepest directory and going up to root. Stops whenever action succeeds.
-void actOnAllParentDirectories(PathRef FileName,
-   llvm::function_ref Action) {
-  for (auto Path = llvm::sys::path::parent_path(FileName);
-   !Path.empty() && !Action(Path);
-   Path = llvm::sys::path::parent_path(Path))
-;
-}
-
 } // namespace
 
 static std::string getFallbackClangPath() {
@@ -97,138 +81,60 @@ DirectoryBasedGlobalCompilationDatabase:
 ~DirectoryBasedGlobalCompilationDatabase() = default;
 
 llvm::Optional
-DirectoryBasedGlobalCompilationDatabase::getCompileCommand(PathRef File) const 
{
-  CDBLookupRequest Req;
-  Req.FileName = File;
-  Req.ShouldBroadcast = true;
-
-  auto Res = lookupCDB(Req);
-  if (!Res) {
+DirectoryBasedGlobalCompilationDatabase::getCompileCommand(
+PathRef File, ProjectInfo *Project) const {
+  if (auto CDB = getCDBForFile(File, Project)) {
+auto Candidates = CDB->getCompileCommands(File);
+if (!Candidates.empty()) {
+  return std::move(Candidates.front());
+}
+  } else {
 log("Failed to find compilation database for {0}", File);
-return llvm::None;
   }
-
-  auto Candidates = Res->CDB->getCompileCommands(File);
-  if (!Candidates.empty())
-return std::move(Candidates.front());
-
   return None;
 }
 
-std::pair
+std::pair
 DirectoryBasedGlobalCompilationDatabase::getCDBInDirLocked(PathRef Dir) const {
   // FIXME(ibiryukov): Invalidate cached compilation databases on changes
   auto CachedIt = CompilationDatabases.find(Dir);
   if (CachedIt != CompilationDatabases.end())
-return {CachedIt->second.CDB.get(), CachedIt->second.SentBroadcast};
+return {CachedIt->second.get(), true};
   std::string Error = "";
-
-  CachedCDB Entry;
-  Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
-  auto Result = Entry.CDB.get();
-  CompilationDatabases[Dir] = std::move(Entry);
-
+  auto CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
+  auto Result = CDB.get();
+  CompilationDatabases.insert(std::make_pair(Dir, std::move(CDB)));
   return {Result, false};
 }
 
-llvm::Optional
-DirectoryBasedGlobalCompilationDatabase::lookupCDB(
-CDBLookupRequest Request) const {
-  assert(llvm::sys::path::is_absolute(Request.FileName) &&
+tooling::CompilationDatabase *
+DirectoryBasedGlobalCompilationDatabase::getCDBForFile(
+PathRef File, ProjectInfo *Project) const {
+  namespace path = llvm::sys::path;
+  assert((path::is_absolute(File, path::Style::posix) ||
+  path::is_absolute(File, path::Style::windows)) &&
  "path must be absolute");
 
-  CDBLookupResult Result;
-  bool SentBroadcast = false;
-
-  {
-std::lock_guard Lock(Mutex);
-if (CompileCommandsDir) {
-  std::tie(Result.CDB, SentBroadcast) =
-  getCDBInDirLocked(*CompileCommandsDir);
-  Result.PI.SourceRoot = *CompileCommandsDir;
-} 

[PATCH] D64492: [clangd] Added highlightings for namespace specifiers.

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



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:73
 // This check is for not getting two entries when there are anonymous
 // structs. It also makes us not highlight namespace qualifiers. For
 // elaborated types the actual type is highlighted as an inner TypeLoc.

jvikstrom wrote:
> hokein wrote:
> > this comment is stale with this patch, now we are highlighting namespace, 
> > it seems more natural to do it here, we can get a NestedNameSpecifierLoc 
> > from an `ElaboratedTypeLoc ` (so that we don't need the 
> > `TraverseNestedNameSpecifierLoc`).
> Doing it in VisitTypeLoc means that we fail on this testcase:
> 
> ```
>   namespace $Namespace[[aa]] {
> namespace $Namespace[[bb]] {
>   struct $Class[[A]] {};
> }
>   }
>   $Namespace[[aa]]::$Namespace[[bb]]::$Class[[A]] $Variable[[a]];
> ```
> 
> It can't detect the `bb` namespace qualifier in `aa::bb::A a;`.
> 
> Maybe there is some way of solving this without 
> `TraverseNestedNameSpecifierLoc` that I am not aware of?
> Also don't know how I'd get a `NestedNameSpecifierLoc` from an 
> `ElaboratedTypeLoc`.
TraverseNestedNameSpecifierLoc is the right way to deal with 
namespaces-as-prefixes, I think it's best to follow that consistently.

(For namespaces not-as-prefixes, you've got namespacealiasdecl, namespacedecl, 
using-directives... I think that's everything)



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:87
+  bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNSLoc) {
+if (NestedNameSpecifier *NNS = NNSLoc.getNestedNameSpecifier())
+  if (NNS->getKind() == NestedNameSpecifier::Namespace ||

if you're just doing something and then calling base, can you make this Visit 
instead of Traverse?



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:131
+  // The target namespace can not be found in any other way.
+  addToken(NAD->getTargetNameLoc(), HighlightingKind::Namespace);
+  return;

this doesn't fit with the contract of this addToken() function, which should 
only highlight the provided token.

Instead, can you call this from VisitNamespaceAliasDecl?



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:86
   template
-  struct $Class[[C]] : abc::A {
+  struct $Class[[C]] : $Namespace[[abc]]::A {
 typename T::A* D;

can you add a case where we spell with leading colons e.g. `::abc::A`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64492



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


[PATCH] D64494: [analyzer]Add user docs rst

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

I guess any time we modify analyzer stuff, we may invite the main analyzer 
developers to the patch review as well.

In any case, LGTM, if this really is a beginning of porting the already 
existing documentation to sphinx.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64494



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


[PATCH] D62413: [OpenCL][PR41727] Prevent ICE on global dtors

2019-07-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGDeclCXX.cpp:132
+  Argument = CGM.getTargetCodeGenInfo().performAddrSpaceCast(
+  CGM, Addr.getPointer(), SrcAS, LangAS::opencl_global, DestTy);
 

rjmccall wrote:
> Anastasia wrote:
> > rjmccall wrote:
> > > Anastasia wrote:
> > > > rjmccall wrote:
> > > > > Should this code be conditional to OpenCL?  And why does 
> > > > > `_cxa_atexit` take a `__global` pointer instead of, say, a 
> > > > > `__generic` one?
> > > > The only objects that are destructible globally in OpenCL are 
> > > > `__global` and `__constant`. However `__constant` isn't convertible to 
> > > > `__generic`. Therefore, I am adding `__global` directly to avoid extra 
> > > > conversion. I am not yet sure how to handle `__constant`though and how 
> > > > much destructing objects in read-only memory segments would make sense 
> > > > anyway. I think I will address this separately.
> > > The pointer argument to `__cxa_atexit` is just an arbitrary bit of 
> > > context and doesn't have to actually be the address of a global.  It's 
> > > *convenient* to use the address of a global sometimes; e.g. you can use 
> > > the global as the pointer and its destructor as the function, and then 
> > > `__cxa_atexit` will just call the destructor for you without any 
> > > additional code.  But as far as the runtime is concerned, the pointer 
> > > could be `malloc`'ed or something; we've never had a need to do that in 
> > > the ABI, but it's good future-proofing to allow it.
> > > 
> > > So there are three ways to get a global destructor to destroy a variable 
> > > in `__constant`:
> > > - You can pass the pointer bitcast'ed as long as `sizeof(__constant 
> > > void*) <= sizeof(__cxa_atexit_context_pointer)`.
> > > - You can ignore the argument and just materialize the address separately 
> > > within the destructor function.
> > > - You can allocate memory for a context and then store the pointer in 
> > > that.
> > > 
> > > Obviously you should go with the one of the first two, but you should 
> > > make sure your ABI doesn't preclude doing the latter in case it's useful 
> > > for some future language feature.  In other words, it doesn't really 
> > > matter whether this argument is notionally in `__global` as long as 
> > > that's wide enough to pass a more-or-less arbitrary pointer through.
> > Ok, I see. I guess option 1 would be fine since we can't setup pointer 
> > width per address space in clang currently. However, spec doesn't provide 
> > any clarifications in this regard.
> > 
> > So I guess using either `__global` or `__generic` for the pointer parameter 
> > would be fine... Or perhaps even leave it without any address space (i.e. 
> > _`_private`) and just addrspacecast from either `__global` or `__constant`. 
> > Do you have any preferences?
> > 
> > As for `malloc` I am not sure that will work for OpenCL since we don't 
> > allow mem allocation on the device. Unless you mean the memory is allocated 
> > on a host... then I am not sure how it should work.
> > Ok, I see. I guess option 1 would be fine since we can't setup pointer 
> > width per address space in clang currently.
> 
> Really?  What's missing there?  It looks to me like `getPointerSize` does 
> take an address space.
> 
> > So I guess using either __global or __generic for the pointer parameter 
> > would be fine... Or perhaps even leave it without any address space (i.e. 
> > _`_private`) and just addrspacecast from either __global or __constant. Do 
> > you have any preferences?
> 
> `__private` is likely to be a smaller address space, right?  I would 
> recommend using the fattest pointer that you want to actually support at 
> runtime — you shouldn't go all the way to `__generic` if the target relies on 
> eliminating that statically.  If you want a target hook for the address space 
> of the notional `__cxa_atexit_context_pointer` typedef, I think that would be 
> reasonable.
> 
> > As for malloc I am not sure that will work for OpenCL since we don't allow 
> > mem allocation on the device. Unless you mean the memory is allocated on a 
> > host... then I am not sure how it should work.
> 
> Well, maybe not actually heap-allocated.  I just think you should design the 
> ABI so that it's reasonably future-proof against taking any specific sort of 
> reasonable pointer.
This cast only works if the address space is a subspace of the `__cxa_atexit` 
address space, right?  Should we be checking that and emitting a diagnostic if 
that's not true?  I think an IRGen-level diagnostic is fine here.


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

https://reviews.llvm.org/D62413



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


[PATCH] D63192: [Diagnostics] Implement -Wswitch-default

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D63192#1578867 , @xbolva00 wrote:

> I see. I should really check clang-tidy codebase :)


I have a hunch that this will be equally as trivially implementable in 
clang-tidy -- if you go that route, feel free to add me as a reviewer!


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

https://reviews.llvm.org/D63192



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


[PATCH] D62105: [CommandLine] Remove OptionCategory and SubCommand caches from the Option class.

2019-07-10 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365675: Recommit [CommandLine] Remove OptionCategory 
and SubCommand caches from the… (authored by dhinton, committed by ).
Herald added a subscriber: ilya-biryukov.

Changed prior to commit:
  https://reviews.llvm.org/D62105?vs=208736=209021#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62105

Files:
  cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
  clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
  clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp
  llvm/trunk/include/llvm/Support/CommandLine.h
  llvm/trunk/lib/Support/CommandLine.cpp
  llvm/trunk/unittests/Support/CommandLineTest.cpp

Index: llvm/trunk/lib/Support/CommandLine.cpp
===
--- llvm/trunk/lib/Support/CommandLine.cpp
+++ llvm/trunk/lib/Support/CommandLine.cpp
@@ -142,7 +142,7 @@
   // This collects Options added with the cl::DefaultOption flag. Since they can
   // be overridden, they are not added to the appropriate SubCommands until
   // ParseCommandLineOptions actually runs.
-  SmallVector DefaultOptions;
+  SmallVector, 4> DefaultOptions;
 
   // This collects the different option categories that have been registered.
   SmallPtrSet RegisteredOptionCategories;
@@ -151,6 +151,7 @@
   SmallPtrSet RegisteredSubCommands;
 
   CommandLineParser() : ActiveSubCommand(nullptr) {
+RegisteredOptionCategories.insert(&*GeneralCategory);
 registerSubCommand(&*TopLevelSubCommand);
 registerSubCommand(&*AllSubCommands);
   }
@@ -182,15 +183,16 @@
   }
 
   void addLiteralOption(Option , StringRef Name) {
-if (Opt.Subs.empty())
-  addLiteralOption(Opt, &*TopLevelSubCommand, Name);
-else {
-  for (auto SC : Opt.Subs)
-addLiteralOption(Opt, SC, Name);
-}
+for(SubCommand *SC: Opt.getSubCommands())
+  addLiteralOption(Opt, SC, Name);
   }
 
-  void addOption(Option *O, SubCommand *SC) {
+  void addOption(Option *O, SubCommand *SC, bool ProcessDefaultOptions = false) {
+if (!ProcessDefaultOptions && O->isDefaultOption()) {
+  DefaultOptions.push_back(std::make_pair(O, SC));
+  return;
+}
+
 bool HadErrors = false;
 if (O->hasArgStr()) {
   // If it's a DefaultOption, check to make sure it isn't already there.
@@ -232,22 +234,14 @@
   for (const auto  : RegisteredSubCommands) {
 if (SC == Sub)
   continue;
-addOption(O, Sub);
+addOption(O, Sub, ProcessDefaultOptions);
   }
 }
   }
 
-  void addOption(Option *O, bool ProcessDefaultOption = false) {
-if (!ProcessDefaultOption && O->isDefaultOption()) {
-  DefaultOptions.push_back(O);
-  return;
-}
-
-if (O->Subs.empty()) {
-  addOption(O, &*TopLevelSubCommand);
-} else {
-  for (auto SC : O->Subs)
-addOption(O, SC);
+  void addDefaultOptions() {
+for (std::pair  : DefaultOptions) {
+  addOption(DO.first, DO.second, true);
 }
   }
 
@@ -285,17 +279,8 @@
   }
 
   void removeOption(Option *O) {
-if (O->Subs.empty())
-  removeOption(O, &*TopLevelSubCommand);
-else {
-  if (O->isInAllSubCommands()) {
-for (auto SC : RegisteredSubCommands)
-  removeOption(O, SC);
-  } else {
-for (auto SC : O->Subs)
-  removeOption(O, SC);
-  }
-}
+for (auto SC : RegisteredSubCommands)
+  removeOption(O, SC);
   }
 
   bool hasOptions(const SubCommand ) const {
@@ -324,17 +309,8 @@
   }
 
   void updateArgStr(Option *O, StringRef NewName) {
-if (O->Subs.empty())
-  updateArgStr(O, NewName, &*TopLevelSubCommand);
-else {
-  if (O->isInAllSubCommands()) {
-for (auto SC : RegisteredSubCommands)
-  updateArgStr(O, NewName, SC);
-  } else {
-for (auto SC : O->Subs)
-  updateArgStr(O, NewName, SC);
-  }
-}
+for (auto SC : RegisteredSubCommands)
+  updateArgStr(O, NewName, SC);
   }
 
   void printOptionValues();
@@ -389,6 +365,7 @@
 
 MoreHelp.clear();
 RegisteredOptionCategories.clear();
+RegisteredOptionCategories.insert(&*GeneralCategory);
 
 ResetAllOptionOccurrences();
 RegisteredSubCommands.clear();
@@ -427,13 +404,38 @@
   GlobalParser->MoreHelp.push_back(Help);
 }
 
-void Option::addArgument() {
-  GlobalParser->addOption(this);
+void Option::addArgument(SubCommand ) {
+  GlobalParser->addOption(this, );
   FullyInitialized = true;
 }
 
 void Option::removeArgument() { GlobalParser->removeOption(this); }
 
+SmallPtrSet Option::getCategories() const {
+  SmallPtrSet Cats;
+  for (OptionCategory *C: GlobalParser->RegisteredOptionCategories) {
+if (C->MemberOptions.find(this) != C->MemberOptions.end())
+  Cats.insert(C);
+  }
+  if (Cats.empty())
+Cats.insert(&*GeneralCategory);
+  return Cats;
+}
+
+SmallPtrSet Option::getSubCommands() const {
+  // This can 

[clang-tools-extra] r365675 - Recommit "[CommandLine] Remove OptionCategory and SubCommand caches from the Option class."

2019-07-10 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Wed Jul 10 10:57:05 2019
New Revision: 365675

URL: http://llvm.org/viewvc/llvm-project?rev=365675=rev
Log:
Recommit "[CommandLine] Remove OptionCategory and SubCommand caches from the 
Option class."

Previously reverted in 364141 due to buildbot breakage, and fixed here
by making GeneralCategory global a ManagedStatic.

Summary:
This change processes `OptionCategory`s and `SubCommand`s as they
are seen instead of caching them in the Option class and processing
them later.  Doing so simplifies the work needed to be done by the Global
parser and significantly reduces the size of the Option class to a mere 64
bytes.

Removing  the `OptionCategory` cache saved 24 bytes, and removing
the `SubCommand` cache saved an additional 48 bytes, for a total of a
72 byte reduction.

Reviewed By: serge-sans-paille

Tags: #llvm, #clang

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

Modified:
clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp

Modified: clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp?rev=365675=365674=365675=diff
==
--- clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/dex/dexp/Dexp.cpp Wed Jul 10 10:57:05 
2019
@@ -77,7 +77,7 @@ class Command {
   // By resetting the parser options, we lost the standard -help flag.
   llvm::cl::opt> Help{
   "help", llvm::cl::desc("Display available options"),
-  llvm::cl::ValueDisallowed, llvm::cl::cat(llvm::cl::GeneralCategory)};
+  llvm::cl::ValueDisallowed};
   virtual void run() = 0;
 
 protected:

Modified: clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp?rev=365675=365674=365675=diff
==
--- clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/indexer/IndexerMain.cpp Wed Jul 10 10:57:05 
2019
@@ -110,7 +110,7 @@ int main(int argc, const char **argv) {
   )";
 
   auto Executor = clang::tooling::createExecutorFromCommandLineArgs(
-  argc, argv, llvm::cl::GeneralCategory, Overview);
+  argc, argv, *llvm::cl::GeneralCategory, Overview);
 
   if (!Executor) {
 llvm::errs() << llvm::toString(Executor.takeError()) << "\n";


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


r365675 - Recommit "[CommandLine] Remove OptionCategory and SubCommand caches from the Option class."

2019-07-10 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Wed Jul 10 10:57:05 2019
New Revision: 365675

URL: http://llvm.org/viewvc/llvm-project?rev=365675=rev
Log:
Recommit "[CommandLine] Remove OptionCategory and SubCommand caches from the 
Option class."

Previously reverted in 364141 due to buildbot breakage, and fixed here
by making GeneralCategory global a ManagedStatic.

Summary:
This change processes `OptionCategory`s and `SubCommand`s as they
are seen instead of caching them in the Option class and processing
them later.  Doing so simplifies the work needed to be done by the Global
parser and significantly reduces the size of the Option class to a mere 64
bytes.

Removing  the `OptionCategory` cache saved 24 bytes, and removing
the `SubCommand` cache saved an additional 48 bytes, for a total of a
72 byte reduction.

Reviewed By: serge-sans-paille

Tags: #llvm, #clang

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

Modified:
cfe/trunk/tools/clang-refactor/ClangRefactor.cpp

Modified: cfe/trunk/tools/clang-refactor/ClangRefactor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-refactor/ClangRefactor.cpp?rev=365675=365674=365675=diff
==
--- cfe/trunk/tools/clang-refactor/ClangRefactor.cpp (original)
+++ cfe/trunk/tools/clang-refactor/ClangRefactor.cpp Wed Jul 10 10:57:05 2019
@@ -38,11 +38,9 @@ namespace opts {
 static cl::OptionCategory CommonRefactorOptions("Refactoring options");
 
 static cl::opt Verbose("v", cl::desc("Use verbose output"),
- cl::cat(cl::GeneralCategory),
  cl::sub(*cl::AllSubCommands));
 
 static cl::opt Inplace("i", cl::desc("Inplace edit s"),
- cl::cat(cl::GeneralCategory),
  cl::sub(*cl::AllSubCommands));
 
 } // end namespace opts
@@ -611,7 +609,7 @@ int main(int argc, const char **argv) {
   ClangRefactorTool RefactorTool;
 
   CommonOptionsParser Options(
-  argc, argv, cl::GeneralCategory, cl::ZeroOrMore,
+  argc, argv, *cl::GeneralCategory, cl::ZeroOrMore,
   "Clang-based refactoring tool for C, C++ and Objective-C");
 
   if (auto Err = RefactorTool.Init()) {


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


[PATCH] D64128: [CodeGen] Generate llvm.ptrmask instead of inttoptr(and(ptrtoint, C)) if possible.

2019-07-10 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D64128#1576391 , @rjmccall wrote:

> I wouldn't favor adding something really obscure that was only useful for 
> clang, but I think builtins to set and clear mask bits while promising to 
> preserve object-reference identity would be more generally useful for 
> libraries.  For example, there might be somewhere in libc++ that could take 
> advantage of this.


Yep, I think for this to be generally useful we would also need an intrinsic to 
set bits as well. I'll commit the LLVM patches and improvements to 
ValueTracking in the next few days for ptrmask and will put up a patch for 
builtins once I know more about how libcxx could use them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64128



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


[PATCH] D64518: [LibTooling] Relax Transformer to allow rewriting macro expansions

2019-07-10 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: ilya-biryukov.
Herald added a project: clang.

Currently, Transformer rejects any changes to source locations inside macro
expansions. This change relaxes that constraint to allow rewrites when the
entirety of the expansion is replaced, since that can be mapped to replacing the
entirety of the expansion range in the file source.  This change makes
Transformer consistent with the handling of edit ranges in `clang::edit::Commit`
(which is used, for example, for applying `FixItHint`s from diagnostics).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64518

Files:
  clang/lib/Tooling/Refactoring/Transformer.cpp
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -137,7 +137,7 @@
   TransformerTest() { appendToHeader(KHeaderContents); }
 };
 
-// Given string s, change strlen($s.c_str()) to $s.size().
+// Given string s, change strlen($s.c_str()) to REPLACED.
 static RewriteRule ruleStrlenSize() {
   StringRef StringExpr = "strexpr";
   auto StringType = namedDecl(hasAnyName("::basic_string", "::string"));
@@ -163,17 +163,6 @@
   testRule(ruleStrlenSize(), Input, Input);
 }
 
-// Tests that expressions in macro arguments are rewritten (when applicable).
-TEST_F(TransformerTest, StrlenSizeMacro) {
-  std::string Input = R"cc(
-#define ID(e) e
-int f(string s) { return ID(strlen(s.c_str())); })cc";
-  std::string Expected = R"cc(
-#define ID(e) e
-int f(string s) { return ID(REPLACED); })cc";
-  testRule(ruleStrlenSize(), Input, Expected);
-}
-
 // Tests replacing an expression.
 TEST_F(TransformerTest, Flag) {
   StringRef Flag = "flag";
@@ -619,23 +608,114 @@
   EXPECT_EQ(ErrorCount, 0);
 }
 
-TEST_F(TransformerTest, NoTransformationInMacro) {
+// Transformation of macro source text when the change encompasses the entirety
+// of the expanded text.
+TEST_F(TransformerTest, SimpleMacro) {
+  std::string Input = R"cc(
+#define ZERO 0
+int f(string s) { return ZERO; }
+  )cc";
+  std::string Expected = R"cc(
+#define ZERO 0
+int f(string s) { return 0; }
+  )cc";
+
+  StringRef zero = "zero";
+  RewriteRule R = makeRule(integerLiteral(equals(0)).bind(zero),
+   change(node(zero), text("0")));
+  testRule(R, Input, Expected);
+}
+
+// Transformation of macro source text when the change encompasses the entirety
+// of the expanded text, for the case of function-style macros.
+TEST_F(TransformerTest, FunctionMacro) {
   std::string Input = R"cc(
 #define MACRO(str) strlen((str).c_str())
-int f(string s) { return MACRO(s); })cc";
-  testRule(ruleStrlenSize(), Input, Input);
+int f(string s) { return MACRO(s); }
+  )cc";
+  std::string Expected = R"cc(
+#define MACRO(str) strlen((str).c_str())
+int f(string s) { return REPLACED; }
+  )cc";
+
+  testRule(ruleStrlenSize(), Input, Expected);
+}
+
+// Tests that expressions in macro arguments can be rewritten.
+TEST_F(TransformerTest, MacroArg) {
+  std::string Input = R"cc(
+#define PLUS(e) e + 1
+int f(string s) { return PLUS(strlen(s.c_str())); }
+  )cc";
+  std::string Expected = R"cc(
+#define PLUS(e) e + 1
+int f(string s) { return PLUS(REPLACED); }
+  )cc";
+
+  testRule(ruleStrlenSize(), Input, Expected);
 }
 
-// This test handles the corner case where a macro called within another macro
-// expands to matching code, but the matched code is an argument to the nested
-// macro.  A simple check of isMacroArgExpansion() vs. isMacroBodyExpansion()
-// will get this wrong, and transform the code. This test verifies that no such
-// transformation occurs.
-TEST_F(TransformerTest, NoTransformationInNestedMacro) {
+// Tests that expressions in macro arguments can be rewritten, even when the
+// macro call occurs inside another macro's definition.
+TEST_F(TransformerTest, MacroArgInMacroDef) {
   std::string Input = R"cc(
 #define NESTED(e) e
 #define MACRO(str) NESTED(strlen((str).c_str()))
-int f(string s) { return MACRO(s); })cc";
+int f(string s) { return MACRO(s); }
+  )cc";
+  std::string Expected = R"cc(
+#define NESTED(e) e
+#define MACRO(str) NESTED(strlen((str).c_str()))
+int f(string s) { return REPLACED; }
+  )cc";
+
+  testRule(ruleStrlenSize(), Input, Expected);
+}
+
+// Tests the corner case of the identity macro, specifically that it is
+// discarded in the rewrite rather than preserved (like PLUS is preserved in the
+// previous test).  This behavior is of dubious value (and marked with a FIXME
+// in the code), but we test it to verify (and demonstrate) how this case is
+// handled.
+TEST_F(TransformerTest, IdentityMacro) {
+  std::string Input = R"cc(
+#define ID(e) e
+int f(string s) { return ID(strlen(s.c_str())); }
+  )cc";
+  std::string Expected = R"cc(
+#define ID(e) e
+int f(string s) 

[PATCH] D63192: [Diagnostics] Implement -Wswitch-default

2019-07-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 planned changes to this revision.
xbolva00 added a comment.

I see. I should really check clang-tidy codebase :)


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

https://reviews.llvm.org/D63192



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


[PATCH] D62413: [OpenCL][PR41727] Prevent ICE on global dtors

2019-07-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: lib/CodeGen/TargetInfo.h:274
+return LangAS::Default;
+  }
+

rjmccall wrote:
> This target hook should just return the address space of the `__cxa_atexit` 
> argument, not to claim anything specific about the relation between that 
> address space and others.  That is a global and permanent property of the 
> target ABI.  We should *advise* targets to use an address space that other 
> major address spaces can be bitcast to, but ultimately that's just advisory.
> 
> This would be a good thing to include in a PR to the Itanium C++ ABI, but it 
> would be reasonable to bundle all the address-space-related changes you need 
> in one PR.
> This would be a good thing to include in a PR to the Itanium C++ ABI, but it 
> would be reasonable to bundle all the address-space-related changes you need 
> in one PR.

I can try to do it but I would need some explanation of the process. :)




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

https://reviews.llvm.org/D62413



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


[PATCH] D62413: [OpenCL][PR41727] Prevent ICE on global dtors

2019-07-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 209012.
Anastasia added a comment.

Changed API for target hook.


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

https://reviews.llvm.org/D62413

Files:
  lib/CodeGen/CGDeclCXX.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/CodeGen/TargetInfo.h
  test/CodeGenOpenCLCXX/atexit.cl

Index: test/CodeGenOpenCLCXX/atexit.cl
===
--- /dev/null
+++ test/CodeGenOpenCLCXX/atexit.cl
@@ -0,0 +1,11 @@
+//RUN: %clang_cc1 %s -triple spir -cl-std=c++ -emit-llvm -O0 -o - | FileCheck %s
+
+struct S {
+  ~S(){};
+};
+S s;
+
+//CHECK-LABEL: define internal void @__cxx_global_var_init()
+//CHECK: call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.S addrspace(4)*)* @_ZNU3AS41SD1Ev to void (i8*)*), i8* addrspacecast (i8 addrspace(1)* getelementptr inbounds (%struct.S, %struct.S addrspace(1)* @s, i32 0, i32 0) to i8*), i8 addrspace(1)* @__dso_handle)
+
+//CHECK: declare i32 @__cxa_atexit(void (i8*)*, i8*, i8 addrspace(1)*)
Index: lib/CodeGen/TargetInfo.h
===
--- lib/CodeGen/TargetInfo.h
+++ lib/CodeGen/TargetInfo.h
@@ -267,6 +267,11 @@
LangAS SrcAddr, LangAS DestAddr,
llvm::Type *DestTy) const;
 
+  /// Get address space of pointer parameter for __cxa_atexit.
+  virtual LangAS getAddrSpaceOfCxaAtexitPtrParam() const {
+return LangAS::Default;
+  }
+
   /// Get the syncscope used in LLVM IR.
   virtual llvm::SyncScope::ID getLLVMSyncScopeID(const LangOptions ,
  SyncScope Scope,
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2284,8 +2284,19 @@
   llvm::Type *dtorTy =
 llvm::FunctionType::get(CGF.VoidTy, CGF.Int8PtrTy, false)->getPointerTo();
 
+  // Preserve address space of addr.
+  auto AddrAS = addr ? addr->getType()->getPointerAddressSpace() : 0;
+  auto AddrInt8PtrTy =
+  AddrAS ? CGF.Int8Ty->getPointerTo(AddrAS) : CGF.Int8PtrTy;
+
+  // Create a variable that binds the atexit to this shared object.
+  llvm::Constant *handle =
+  CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+  auto *GV = cast(handle->stripPointerCasts());
+  GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
+
   // extern "C" int __cxa_atexit(void (*f)(void *), void *p, void *d);
-  llvm::Type *paramTys[] = { dtorTy, CGF.Int8PtrTy, CGF.Int8PtrTy };
+  llvm::Type *paramTys[] = {dtorTy, AddrInt8PtrTy, handle->getType()};
   llvm::FunctionType *atexitTy =
 llvm::FunctionType::get(CGF.IntTy, paramTys, false);
 
@@ -2294,12 +2305,6 @@
   if (llvm::Function *fn = dyn_cast(atexit.getCallee()))
 fn->setDoesNotThrow();
 
-  // Create a variable that binds the atexit to this shared object.
-  llvm::Constant *handle =
-  CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
-  auto *GV = cast(handle->stripPointerCasts());
-  GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
-
   if (!addr)
 // addr is null when we are trying to register a dtor annotated with
 // __attribute__((destructor)) in a constructor function. Using null here is
@@ -2309,7 +2314,7 @@
 
   llvm::Value *args[] = {llvm::ConstantExpr::getBitCast(
  cast(dtor.getCallee()), dtorTy),
- llvm::ConstantExpr::getBitCast(addr, CGF.Int8PtrTy),
+ llvm::ConstantExpr::getBitCast(addr, AddrInt8PtrTy),
  handle};
   CGF.EmitNounwindRuntimeCall(atexit, args);
 }
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3577,8 +3577,12 @@
 llvm::Constant *
 CodeGenModule::CreateRuntimeVariable(llvm::Type *Ty,
  StringRef Name) {
-  auto *Ret =
-  GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr);
+  auto PtrTy =
+  getContext().getLangOpts().OpenCL
+  ? llvm::PointerType::get(
+Ty, getContext().getTargetAddressSpace(LangAS::opencl_global))
+  : llvm::PointerType::getUnqual(Ty);
+  auto *Ret = GetOrCreateLLVMGlobal(Name, PtrTy, nullptr);
   setDSOLocal(cast(Ret->stripPointerCasts()));
   return Ret;
 }
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -14,6 +14,7 @@
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
 #include "CGOpenMPRuntime.h"
+#include "TargetInfo.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Intrinsics.h"
@@ -118,9 +119,21 @@
 CXXDestructorDecl *Dtor = 

[PATCH] D63192: [Diagnostics] Implement -Wswitch-default

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm wary of adding this as an on-by-default warning, despite its presence in 
MSVC (and despite submitting a similar patch years ago to implement the same 
functionality). Machine-generated code runs into this one frequently (we've 
been bitten by it numerous times with our tablegen code, especially in the 
backends), but it does not seem likely to occur in hand-written code very often.

While it's pretty easy to implement this in the frontend, I sort of feel like 
this is a better candidate for clang-tidy's `readability` module.


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

https://reviews.llvm.org/D63192



___
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-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaType.cpp:7421
+  // - template specialization as addr space in template argument doesn't
+  //   affect specialization.
+  (T->isDependentType() && (!T->isPointerType() && !T->isReferenceType() &&

Anastasia wrote:
> rjmccall wrote:
> > I don't understand what you're saying here.  Why does inference depend on 
> > whether the type is a template specialization?  And what does this have to 
> > do with template arguments?  Also, address spaces in template arguments are 
> > definitely part of the template argument and affect which specialization 
> > you're naming.
> What I am trying to say here is that an address space of a template argument 
> isn't used as an address space of a template specialization and therefore we 
> can deduce the address space of a template specialization since it's not 
> going to be provided during the template instantiation.
> 
> Let's say we have specialization `MyClass`. The address space of `T` has 
> nothing to do with the address space of `MyClass`. They are different. 
> Therefore if the address space of `MyClass` is not provided explicitly it 
> is ok to deduce it.
> 
> Does it make sense?
Of course the address space of `T` has nothing to do with the address space of 
`MyClass`, but that's true of literally every type, and you don't need to 
add special cases checking for specific type spellings.

Why don't you just never infer address spaces on dependent types and then infer 
them as necessary during instantiation?  Why is it important to infer address 
spaces on any dependent type in the template pattern?


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

https://reviews.llvm.org/D64400



___
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-10 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:585
+  (A && A->getOption().matches(options::OPT_fno_omit_frame_pointer)) ||
+  (!(A && A->getOption().matches(options::OPT_fomit_frame_pointer)) &&
+   (Args.hasArg(options::OPT_pg) ||

MaskRay wrote:
> ychen wrote:
> > It looks better if  `frame_pointer` is represented using tri-state. 
> > Something like this?
> > 
> > It would be great to have comments for conditions that are not obvious such 
> > as the overriding rules.
> > 
> > ```
> >   // There are three states for frame_pointer.
> >   enum class FpFlag {true, false, none};
> >   FpFlag FPF = FpFlag::none;
> >   if (Arg *A = Args.getLastArg(options::OPT_fomit_frame_pointer,
> >options::OPT_fno_omit_frame_pointer))
> > FPF = A->getOption().matches(options::OPT_fno_omit_frame_pointer)) ?
> >  FpFlag::true : FpFlag::false;
> > 
> >   if (!mustUseNonLeaf && FPF == FpFlag::false)
> > return FramePointerKind::None;
> > 
> >   if (mustUseNonLeaf || FPF == FpFlag::true || Args.hasArg(options::OPT_pg) 
> > ||
> >   useFramePointerForTargetByDefault(Args, Triple)) {
> > if (Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
> >  options::OPT_mno_omit_leaf_frame_pointer,
> >  Triple.isPS4CPU()))
> >   return FramePointerKind::NonLeaf;
> > return FramePointerKind::All;
> >   }
> >   return FramePointerKind::None;
> > ```
> I actually think the current version is clearer.. The local `enum class 
> FpFlag {true, false, none};` doesn't improve readability in my opinion.
> 
> 
> I can define separate variables for:
> 
> * A && A->getOption().matches(options::OPT_fno_omit_frame_pointer)
> * A && A->getOption().matches(options::OPT_fomit_frame_pointer)
> 
> If reviewers think that makes the code easier to read.
I think local enum may be optional.

Say 
  - `Fp  = A && A->getOption().matches(options::OPT_fno_omit_frame_pointer)`
  - `NoFp = A && A->getOption().matches(options::OPT_fomit_frame_pointer)`

The `!(A && A->getOption().matches(options::OPT_fomit_frame_pointer))` in the 
current revision could be `!A`. The implicit logic is `NoFp`  could only be 
overriden by `mustUseNonLeaf`.

This block helps to make the implicit logic explicit and simplify the rest of 
the code.

```
if (!mustUseNonLeaf && NoFp)
  return FramePointerKind::None;
}
```




Repository:
  rC Clang

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

https://reviews.llvm.org/D64294



___
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-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: cfe/trunk/lib/Sema/SemaExprCXX.cpp:4229
+LangAS AddrSpaceR =
+RHSType->getAs()->getPointeeType().getAddressSpace();
+CastKind Kind =

Anastasia wrote:
> rjmccall wrote:
> > All of this can be much simpler:
> > 
> > ```
> > LangAS AddrSpaceL = 
> > ToType->castAs()->getPointeeType().getAddressSpace();
> > LangAS AddrSpaceR = 
> > FromType->castAs()->getPointeeType().getAddressSpace();
> > ```
> > 
> > Is there something actually checking the validity of this address-space 
> > cast somewhere?
> > Is there something actually checking the validity of this address-space 
> > cast somewhere?
> 
> The address spaces for blocks are currently added by clang implicitly. It 
> doesn't seem possible to write kernel code qualifying blocks with address 
> spaces. Although I have to say the error is not given properly because the 
> parser gets confused at least for the examples I have tried. The OpenCL spec 
> doesn't detail much regarding this use case. Potentially this is the area for 
> improvement.
> 
> So for now we can add an assert to check the cast validity if you think it 
> makes sense and maybe a FIXME in the  code to explain that address spaces 
> aren't working with blocks
> The address spaces for blocks are currently added by clang implicitly. It 
> doesn't seem possible to write kernel code qualifying blocks with address 
> spaces.

There's no way that just fell out from the existing implementation; it was a 
change someone must have made for OpenCL.  Unless you care about blocks 
existing in multiple address spaces — which, given that you depend on 
eliminating them, I'm pretty sure you don't — the compiler just shouldn't do 
that if it's causing you problems.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64083



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


r365666 - [clang] Preserve names of addrspacecast'ed values.

2019-07-10 Thread Vyacheslav Zakharin via cfe-commits
Author: vzakhari
Date: Wed Jul 10 10:10:05 2019
New Revision: 365666

URL: http://llvm.org/viewvc/llvm-project?rev=365666=rev
Log:
[clang] Preserve names of addrspacecast'ed values.

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

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-of-this.cl
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-references.cl
cfe/trunk/test/CodeGenOpenCLCXX/template-address-spaces.cl

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=365666=365665=365666=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jul 10 10:10:05 2019
@@ -449,7 +449,9 @@ llvm::Value *TargetCodeGenInfo::performA
   // space, an address space conversion may end up as a bitcast.
   if (auto *C = dyn_cast(Src))
 return performAddrSpaceCast(CGF.CGM, C, SrcAddr, DestAddr, DestTy);
-  return CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Src, DestTy);
+  // Try to preserve the source's name to make IR more readable.
+  return CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+  Src, DestTy, Src->hasName() ? Src->getName() + ".ascast" : "");
 }
 
 llvm::Constant *

Modified: cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu?rev=365666=365665=365666=diff
==
--- cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu Wed Jul 10 10:10:05 2019
@@ -2,15 +2,15 @@
 #include "Inputs/cuda.h"
 
 // CHECK-LABEL: @_Z16use_dispatch_ptrPi(
-// CHECK: %2 = call i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
-// CHECK: %3 = addrspacecast i8 addrspace(4)* %2 to i8 addrspace(4)**
+// CHECK: %[[PTR:.*]] = call i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
+// CHECK: %{{.*}} = addrspacecast i8 addrspace(4)* %[[PTR]] to i8 
addrspace(4)**
 __global__ void use_dispatch_ptr(int* out) {
   const int* dispatch_ptr = (const int*)__builtin_amdgcn_dispatch_ptr();
   *out = *dispatch_ptr;
 }
 
 // CHECK-LABEL: @_Z12test_ds_fmaxf(
-// CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* 
@_ZZ12test_ds_fmaxfE6shared, float %2, i32 0, i32 0, i1 false)
+// CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* 
@_ZZ12test_ds_fmaxfE6shared, float %{{[^,]*}}, i32 0, i32 0, i1 false)
 __global__
 void test_ds_fmax(float src) {
   __shared__ float shared;

Modified: cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl?rev=365666=365665=365666=diff
==
--- cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl Wed Jul 10 
10:10:05 2019
@@ -13,7 +13,7 @@ void test(global int *arg_glob, generic
   // CHECK-NOFAKE-NOT: addrspacecast
 
   arg_gen = _priv; // implicit cast with obtaining adr, private -> generic
-  // CHECK: %{{[0-9]+}} = addrspacecast i32* %var_priv to i32 addrspace(4)*
+  // CHECK: %{{[._a-z0-9]+}} = addrspacecast i32* %{{[._a-z0-9]+}} to i32 
addrspace(4)*
   // CHECK-NOFAKE-NOT: addrspacecast
 
   arg_glob = (global int *)arg_gen; // explicit cast

Modified: cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl?rev=365666=365665=365666=diff
==
--- cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl (original)
+++ cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl Wed Jul 10 
10:10:05 2019
@@ -29,7 +29,7 @@ int foo(int par, int PTR par_p){
   int loc;
   //COMMON: %loc_p = alloca i32 addrspace(4)*
   //COMMON: %loc_p_const = alloca i32*
-  //COMMON: [[GAS:%[0-9]+]] = addrspacecast i32* %loc to i32 addrspace(4)*
+  //COMMON: [[GAS:%[._a-z0-9]*]] = addrspacecast i32* %loc to i32 addrspace(4)*
   //COMMON: store i32 addrspace(4)* [[GAS]], i32 addrspace(4)** %loc_p
   int PTR loc_p = ADR(loc);
   //COMMON: store i32* %loc, i32** %loc_p_const

Modified: cfe/trunk/test/CodeGenOpenCLCXX/addrspace-of-this.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/addrspace-of-this.cl?rev=365666=365665=365666=diff
==
--- cfe/trunk/test/CodeGenOpenCLCXX/addrspace-of-this.cl (original)
+++ 

r365668 - [X86] Add guards to some of the x86 intrinsic tests to skip 64-bit mode only intrinsics when compiled for 32-bit mode.

2019-07-10 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Jul 10 10:11:23 2019
New Revision: 365668

URL: http://llvm.org/viewvc/llvm-project?rev=365668=rev
Log:
[X86] Add guards to some of the x86 intrinsic tests to skip 64-bit mode only 
intrinsics when compiled for 32-bit mode.

All the command lines are for 64-bit mode, but sometimes I compile
the tests in 32-bit mode to see what assembly we get and we need
to skip these to do that.

Modified:
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/bmi-builtins.c
cfe/trunk/test/CodeGen/bmi2-builtins.c
cfe/trunk/test/CodeGen/popcnt-builtins.c
cfe/trunk/test/CodeGen/rdrand-builtins.c
cfe/trunk/test/CodeGen/sse-builtins.c
cfe/trunk/test/CodeGen/sse2-builtins.c
cfe/trunk/test/CodeGen/sse41-builtins.c
cfe/trunk/test/CodeGen/sse42-builtins.c
cfe/trunk/test/CodeGen/tbm-builtins.c

Modified: cfe/trunk/test/CodeGen/avx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-builtins.c?rev=365668=365667=365668=diff
==
--- cfe/trunk/test/CodeGen/avx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-builtins.c Wed Jul 10 10:11:23 2019
@@ -1079,11 +1079,13 @@ int test_mm256_extract_epi32(__m256i A)
   return _mm256_extract_epi32(A, 7);
 }
 
+#if __x86_64__
 long long test_mm256_extract_epi64(__m256i A) {
   // CHECK-LABEL: test_mm256_extract_epi64
   // CHECK: extractelement <4 x i64> %{{.*}}, {{i32|i64}} 3
   return _mm256_extract_epi64(A, 3);
 }
+#endif
 
 __m128d test_mm256_extractf128_pd(__m256d A) {
   // CHECK-LABEL: test_mm256_extractf128_pd
@@ -1157,11 +1159,13 @@ __m256i test_mm256_insert_epi32(__m256i
   return _mm256_insert_epi32(x, b, 5);
 }
 
+#if __x86_64__
 __m256i test_mm256_insert_epi64(__m256i x, long long b) {
   // CHECK-LABEL: test_mm256_insert_epi64
   // CHECK: insertelement <4 x i64> %{{.*}}, i64 %{{.*}}, {{i32|i64}} 2
   return _mm256_insert_epi64(x, b, 2);
 }
+#endif
 
 __m256d test_mm256_insertf128_pd(__m256d A, __m128d B) {
   // CHECK-LABEL: test_mm256_insertf128_pd

Modified: cfe/trunk/test/CodeGen/bmi-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/bmi-builtins.c?rev=365668=365667=365668=diff
==
--- cfe/trunk/test/CodeGen/bmi-builtins.c (original)
+++ cfe/trunk/test/CodeGen/bmi-builtins.c Wed Jul 10 10:11:23 2019
@@ -65,6 +65,7 @@ int test_mm_tzcnt_32(unsigned int __X) {
   return _mm_tzcnt_32(__X);
 }
 
+#ifdef __x86_64__
 unsigned long long test__andn_u64(unsigned long __X, unsigned long __Y) {
   // CHECK-LABEL: test__andn_u64
   // CHECK: xor i64 %{{.*}}, -1
@@ -110,6 +111,7 @@ long long test_mm_tzcnt_64(unsigned long
   // CHECK: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
   return _mm_tzcnt_64(__X);
 }
+#endif
 
 // Intel intrinsics
 
@@ -164,6 +166,7 @@ unsigned int test_tzcnt_u32(unsigned int
   return _tzcnt_u32(__X);
 }
 
+#ifdef __x86_64__
 unsigned long long test_andn_u64(unsigned long __X, unsigned long __Y) {
   // CHECK-LABEL: test_andn_u64
   // CHECK: xor i64 %{{.*}}, -1
@@ -209,3 +212,4 @@ unsigned long long test_tzcnt_u64(unsign
   // CHECK: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
   return _tzcnt_u64(__X);
 }
+#endif

Modified: cfe/trunk/test/CodeGen/bmi2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/bmi2-builtins.c?rev=365668=365667=365668=diff
==
--- cfe/trunk/test/CodeGen/bmi2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/bmi2-builtins.c Wed Jul 10 10:11:23 2019
@@ -28,6 +28,7 @@ unsigned int test_mulx_u32(unsigned int
   return _mulx_u32(__X, __Y, __P);
 }
 
+#ifdef __x86_64__
 unsigned long long test_bzhi_u64(unsigned long long __X, unsigned long long 
__Y) {
   // CHECK: @llvm.x86.bmi.bzhi.64
   return _bzhi_u64(__X, __Y);
@@ -49,3 +50,4 @@ unsigned long long test_mulx_u64(unsigne
   // CHECK: mul i128
   return _mulx_u64(__X, __Y, __P);
 }
+#endif

Modified: cfe/trunk/test/CodeGen/popcnt-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/popcnt-builtins.c?rev=365668=365667=365668=diff
==
--- cfe/trunk/test/CodeGen/popcnt-builtins.c (original)
+++ cfe/trunk/test/CodeGen/popcnt-builtins.c Wed Jul 10 10:11:23 2019
@@ -21,6 +21,7 @@ int test__popcntd(unsigned int __X) {
   return __popcntd(__X);
 }
 
+#ifdef __x86_64__
 #ifdef __POPCNT__
 long long test_mm_popcnt_u64(unsigned long long __X) {
   //CHECK-POPCNT: call i64 @llvm.ctpop.i64
@@ -37,3 +38,4 @@ long long test__popcntq(unsigned long lo
   //CHECK: call i64 @llvm.ctpop.i64
   return __popcntq(__X);
 }
+#endif

Modified: cfe/trunk/test/CodeGen/rdrand-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/rdrand-builtins.c?rev=365668=365667=365668=diff

[PATCH] D63846: [clang] Preserve names of addrspacecast'ed values.

2019-07-10 Thread Vyacheslav Zakharin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365666: [clang] Preserve names of addrspacecasted 
values. (authored by vzakhari, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63846?vs=208564=209006#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63846

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
  cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
  cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl
  cfe/trunk/test/CodeGenOpenCLCXX/addrspace-of-this.cl
  cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
  cfe/trunk/test/CodeGenOpenCLCXX/addrspace-references.cl
  cfe/trunk/test/CodeGenOpenCLCXX/template-address-spaces.cl

Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -449,7 +449,9 @@
   // space, an address space conversion may end up as a bitcast.
   if (auto *C = dyn_cast(Src))
 return performAddrSpaceCast(CGF.CGM, C, SrcAddr, DestAddr, DestTy);
-  return CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Src, DestTy);
+  // Try to preserve the source's name to make IR more readable.
+  return CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+  Src, DestTy, Src->hasName() ? Src->getName() + ".ascast" : "");
 }
 
 llvm::Constant *
Index: cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
===
--- cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
+++ cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
@@ -13,7 +13,7 @@
   // CHECK-NOFAKE-NOT: addrspacecast
 
   arg_gen = _priv; // implicit cast with obtaining adr, private -> generic
-  // CHECK: %{{[0-9]+}} = addrspacecast i32* %var_priv to i32 addrspace(4)*
+  // CHECK: %{{[._a-z0-9]+}} = addrspacecast i32* %{{[._a-z0-9]+}} to i32 addrspace(4)*
   // CHECK-NOFAKE-NOT: addrspacecast
 
   arg_glob = (global int *)arg_gen; // explicit cast
Index: cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
===
--- cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
+++ cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
@@ -2,15 +2,15 @@
 #include "Inputs/cuda.h"
 
 // CHECK-LABEL: @_Z16use_dispatch_ptrPi(
-// CHECK: %2 = call i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
-// CHECK: %3 = addrspacecast i8 addrspace(4)* %2 to i8 addrspace(4)**
+// CHECK: %[[PTR:.*]] = call i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
+// CHECK: %{{.*}} = addrspacecast i8 addrspace(4)* %[[PTR]] to i8 addrspace(4)**
 __global__ void use_dispatch_ptr(int* out) {
   const int* dispatch_ptr = (const int*)__builtin_amdgcn_dispatch_ptr();
   *out = *dispatch_ptr;
 }
 
 // CHECK-LABEL: @_Z12test_ds_fmaxf(
-// CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* @_ZZ12test_ds_fmaxfE6shared, float %2, i32 0, i32 0, i1 false)
+// CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* @_ZZ12test_ds_fmaxfE6shared, float %{{[^,]*}}, i32 0, i32 0, i1 false)
 __global__
 void test_ds_fmax(float src) {
   __shared__ float shared;
Index: cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
===
--- cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
+++ cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
@@ -19,11 +19,11 @@
 //CHECK-LABEL: define spir_func void @_Z3barv()
 void bar() {
   C c;
-  //CHECK: addrspacecast %class.C* %c to %class.C addrspace(4)*
-  //CHECK: call void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* %{{[0-9]+}}, i32 0)
+  //CHECK: [[A1:%[.a-z0-9]+]] = addrspacecast %class.C* [[C:%[a-z0-9]+]] to %class.C addrspace(4)*
+  //CHECK: call void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* [[A1]], i32 0)
   c.Assign(a);
-  //CHECK: addrspacecast %class.C* %c to %class.C addrspace(4)*
-  //CHECK: call void @_ZNU3AS41C8OrAssignE1E(%class.C addrspace(4)* %{{[0-9]+}}, i32 0)
+  //CHECK: [[A2:%[.a-z0-9]+]] = addrspacecast %class.C* [[C]] to %class.C addrspace(4)*
+  //CHECK: call void @_ZNU3AS41C8OrAssignE1E(%class.C addrspace(4)* [[A2]], i32 0)
   c.OrAssign(a);
 
   E e;
@@ -35,19 +35,33 @@
   globI |= b;
   //CHECK: store i32 %add, i32 addrspace(1)* @globI
   globI += a;
-  //CHECK: store volatile i32 %and, i32 addrspace(1)* @globVI
+  //CHECK: [[GVIV1:%[0-9]+]] = load volatile i32, i32 addrspace(1)* @globVI
+  //CHECK: [[AND:%[a-z0-9]+]] = and i32 [[GVIV1]], 1
+  //CHECK: store volatile i32 [[AND]], i32 addrspace(1)* @globVI
   globVI &= b;
-  //CHECK: store volatile i32 %sub, i32 addrspace(1)* @globVI
+  //CHECK: [[GVIV2:%[0-9]+]] = load volatile i32, i32 addrspace(1)* @globVI
+  //CHECK: [[SUB:%[a-z0-9]+]] = sub nsw i32 [[GVIV2]], 0
+  //CHECK: 

r365669 - [X86] Change the IR sequence for _mm_storeh_pi and _mm_storel_pi to perform the store as a <2 x float> instead of i64.

2019-07-10 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Jul 10 10:11:29 2019
New Revision: 365669

URL: http://llvm.org/viewvc/llvm-project?rev=365669=rev
Log:
[X86] Change the IR sequence for _mm_storeh_pi and _mm_storel_pi to perform the 
store as a <2 x float> instead of i64.

This is similar to what we do for loadl_pi and loadh_pi.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/xmmintrin.h
cfe/trunk/test/CodeGen/builtins-x86.c
cfe/trunk/test/CodeGen/sse-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=365669=365668=365669=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Jul 10 10:11:29 2019
@@ -306,8 +306,6 @@ TARGET_BUILTIN(__builtin_ia32_stmxcsr, "
 TARGET_HEADER_BUILTIN(_mm_getcsr, "Ui", "nh", "xmmintrin.h", ALL_LANGUAGES, 
"sse")
 TARGET_BUILTIN(__builtin_ia32_cvtss2si, "iV4f", "ncV:128:", "sse")
 TARGET_BUILTIN(__builtin_ia32_cvttss2si, "iV4f", "ncV:128:", "sse")
-TARGET_BUILTIN(__builtin_ia32_storehps, "vV2i*V4f", "nV:128:", "sse")
-TARGET_BUILTIN(__builtin_ia32_storelps, "vV2i*V4f", "nV:128:", "sse")
 TARGET_BUILTIN(__builtin_ia32_movmskps, "iV4f", "nV:128:", "sse")
 TARGET_BUILTIN(__builtin_ia32_sfence, "v", "n", "sse")
 TARGET_HEADER_BUILTIN(_mm_sfence, "v", "nh", "xmmintrin.h", ALL_LANGUAGES, 
"sse")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=365669=365668=365669=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jul 10 10:11:29 2019
@@ -10651,22 +10651,6 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 return Builder.CreateCall(Intr, Ops);
   }
 
-  case X86::BI__builtin_ia32_storehps:
-  case X86::BI__builtin_ia32_storelps: {
-llvm::Type *PtrTy = llvm::PointerType::getUnqual(Int64Ty);
-llvm::Type *VecTy = llvm::VectorType::get(Int64Ty, 2);
-
-// cast val v2i64
-Ops[1] = Builder.CreateBitCast(Ops[1], VecTy, "cast");
-
-// extract (0, 1)
-unsigned Index = BuiltinID == X86::BI__builtin_ia32_storelps ? 0 : 1;
-Ops[1] = Builder.CreateExtractElement(Ops[1], Index, "extract");
-
-// cast pointer to i64 & store
-Ops[0] = Builder.CreateBitCast(Ops[0], PtrTy);
-return Builder.CreateDefaultAlignedStore(Ops[1], Ops[0]);
-  }
   case X86::BI__builtin_ia32_vextractf128_pd256:
   case X86::BI__builtin_ia32_vextractf128_ps256:
   case X86::BI__builtin_ia32_vextractf128_si256:

Modified: cfe/trunk/lib/Headers/xmmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xmmintrin.h?rev=365669=365668=365669=diff
==
--- cfe/trunk/lib/Headers/xmmintrin.h (original)
+++ cfe/trunk/lib/Headers/xmmintrin.h Wed Jul 10 10:11:29 2019
@@ -1919,7 +1919,11 @@ _mm_setzero_ps(void)
 static __inline__ void __DEFAULT_FN_ATTRS
 _mm_storeh_pi(__m64 *__p, __m128 __a)
 {
-  __builtin_ia32_storehps((__v2si *)__p, (__v4sf)__a);
+  typedef float __mm_storeh_pi_v2f32 __attribute__((__vector_size__(8)));
+  struct __mm_storeh_pi_struct {
+__mm_storeh_pi_v2f32 __u;
+  } __attribute__((__packed__, __may_alias__));
+  ((struct __mm_storeh_pi_struct*)__p)->__u = __builtin_shufflevector(__a, 
__a, 2, 3);
 }
 
 /// Stores the lower 64 bits of a 128-bit vector of [4 x float] to a
@@ -1936,7 +1940,11 @@ _mm_storeh_pi(__m64 *__p, __m128 __a)
 static __inline__ void __DEFAULT_FN_ATTRS
 _mm_storel_pi(__m64 *__p, __m128 __a)
 {
-  __builtin_ia32_storelps((__v2si *)__p, (__v4sf)__a);
+  typedef float __mm_storeh_pi_v2f32 __attribute__((__vector_size__(8)));
+  struct __mm_storeh_pi_struct {
+__mm_storeh_pi_v2f32 __u;
+  } __attribute__((__packed__, __may_alias__));
+  ((struct __mm_storeh_pi_struct*)__p)->__u = __builtin_shufflevector(__a, 
__a, 0, 1);
 }
 
 /// Stores the lower 32 bits of a 128-bit vector of [4 x float] to a

Modified: cfe/trunk/test/CodeGen/builtins-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-x86.c?rev=365669=365668=365669=diff
==
--- cfe/trunk/test/CodeGen/builtins-x86.c (original)
+++ cfe/trunk/test/CodeGen/builtins-x86.c Wed Jul 10 10:11:29 2019
@@ -341,8 +341,6 @@ void f0() {
 #endif
   tmp_V2i = __builtin_ia32_cvttps2pi(tmp_V4f);
   (void) __builtin_ia32_maskmovq(tmp_V8c, tmp_V8c, tmp_cp);
-  (void) __builtin_ia32_storehps(tmp_V2ip, tmp_V4f);
-  (void) __builtin_ia32_storelps(tmp_V2ip, tmp_V4f);
   tmp_i = __builtin_ia32_movmskps(tmp_V4f);
   tmp_i = __builtin_ia32_pmovmskb(tmp_V8c);
   (void) __builtin_ia32_movntq(tmp_V1LLip, tmp_V1LLi);

Modified: 

[PATCH] D64274: [analyzer] VirtualCallChecker overhaul.

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

Please know that I'm currently out of town, so it'll be a while before I can 
formally accept. Its on top of my list when I get home though! :^)


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] D64492: [clangd] Added highlightings for namespace specifiers.

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



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:73
 // This check is for not getting two entries when there are anonymous
 // structs. It also makes us not highlight namespace qualifiers. For
 // elaborated types the actual type is highlighted as an inner TypeLoc.

hokein wrote:
> this comment is stale with this patch, now we are highlighting namespace, it 
> seems more natural to do it here, we can get a NestedNameSpecifierLoc from an 
> `ElaboratedTypeLoc ` (so that we don't need the 
> `TraverseNestedNameSpecifierLoc`).
Doing it in VisitTypeLoc means that we fail on this testcase:

```
  namespace $Namespace[[aa]] {
namespace $Namespace[[bb]] {
  struct $Class[[A]] {};
}
  }
  $Namespace[[aa]]::$Namespace[[bb]]::$Class[[A]] $Variable[[a]];
```

It can't detect the `bb` namespace qualifier in `aa::bb::A a;`.

Maybe there is some way of solving this without 
`TraverseNestedNameSpecifierLoc` that I am not aware of?
Also don't know how I'd get a `NestedNameSpecifierLoc` from an 
`ElaboratedTypeLoc`.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:247
+  case HighlightingKind::Namespace:
+return "entity.name.type.namespace.cpp";
   case HighlightingKind::NumKinds:

hokein wrote:
> I think here should be `entity.name.namespace.cpp`, vscode uses this TX scope 
> for namespace.
Really? Because I see `entity.name.type.namespace.cpp` when I inspect the TM 
scopes for namespaces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64492



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


[PATCH] D64492: [clangd] Added highlightings for namespace specifiers.

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

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64492

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
@@ -36,7 +36,8 @@
   {HighlightingKind::Variable, "Variable"},
   {HighlightingKind::Function, "Function"},
   {HighlightingKind::Class, "Class"},
-  {HighlightingKind::Enum, "Enum"}};
+  {HighlightingKind::Enum, "Enum"},
+  {HighlightingKind::Namespace, "Namespace"}};
   std::vector ExpectedTokens;
   for (const auto  : KindToString) {
 std::vector Toks = makeHighlightingTokens(
@@ -75,18 +76,18 @@
   };
 )cpp",
 R"cpp(
-  namespace abc {
+  namespace $Namespace[[abc]] {
 template
 struct $Class[[A]] {
   T t;
 };
   }
   template
-  struct $Class[[C]] : abc::A {
+  struct $Class[[C]] : $Namespace[[abc]]::A {
 typename T::A* D;
   };
-  abc::$Class[[A]] $Variable[[AA]];
-  typedef abc::$Class[[A]] AAA;
+  $Namespace[[abc]]::$Class[[A]] $Variable[[AA]];
+  typedef $Namespace[[abc]]::$Class[[A]] AAA;
   struct $Class[[B]] {
 $Class[[B]]();
 ~$Class[[B]]();
@@ -108,6 +109,27 @@
 $Enum[[E]] EEE;
 $Enum[[EE]] ;
   };
+)cpp",
+R"cpp(
+  namespace $Namespace[[abc]] {
+namespace {}
+namespace $Namespace[[bcd]] {
+  struct $Class[[A]] {};
+  namespace $Namespace[[cde]] {
+struct $Class[[A]] {
+  enum class $Enum[[B]] {
+Hi,
+  };
+};
+  }
+}
+  }
+  using namespace $Namespace[[abc]]::$Namespace[[bcd]];
+  namespace $Namespace[[vwz]] =
+$Namespace[[abc]]::$Namespace[[bcd]]::$Namespace[[cde]];
+  $Namespace[[abc]]::$Namespace[[bcd]]::$Class[[A]] $Variable[[AA]];
+  $Namespace[[vwz]]::$Class[[A]]::$Enum[[B]] $Variable[[AAA]] =
+$Namespace[[vwz]]::$Class[[A]]::$Enum[[B]]::Hi;
 )cpp"};
   for (const auto  : TestCases) {
 checkHighlightings(TestCase);
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
@@ -9,12 +9,15 @@
 # CHECK-NEXT:  ],
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
-# CHECK-NEXT:  ]
+# 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:"entity.name.type.namespace.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
@@ -28,6 +28,7 @@
   Function,
   Class,
   Enum,
+  Namespace,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -11,8 +11,6 @@
 #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 {
@@ -37,6 +35,14 @@
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
+// UsingDirectiveDecl's namespaces do not show up anywhere else in the
+// Visit/Traverse mehods. But they should also be highlighted as a
+// namespace.
+if (const auto *UD = dyn_cast(ND)) {
+  addToken(UD->getIdentLocation(), HighlightingKind::Namespace);
+  return true;
+}
+
 // Constructors' TypeLoc has a TypePtr that is a FunctionProtoType. It has
 // no tag decl and therefore constructors must be gotten as NamedDecls
 // instead.
@@ -65,17 +71,28 @@
 
   bool VisitTypeLoc(TypeLoc ) {
 // This check is for not getting two entries when there are anonymous
-// structs. It also makes us not 

[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D64454#1578704 , @Szelethus wrote:

> Just thinking aloud!
>
> We were tinkering with the idea of a checker creator script similar to what 
> clang-tidy has, that could help on this potentially.
>
> Is generating the rst code with Tblgen a feasable approach? At first glance, 
> it sounds like a nightmare to implement, and I wonder whether the maintainers 
> of sphinx buildbots would need to adjust to that.


clang-tidy doesn't currently rely on tablegen for producing docs like we do for 
attributes or command line arguments in Clang itself, but I don't think we need 
that for an initial offering anyway. I'd be happy with a simple python script 
that we execute as-needed (like we do for AST matchers, for instance) to 
generate docs that are committed. I figured that python script could execute a 
tablegen command to offload some of that work. Eventually, we might get to a 
point where that script can then be run on a server like we do elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454



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


[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

2019-07-10 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry added a comment.

In D64454#1578352 , @aaron.ballman 
wrote:

> I'm worried that this will continue to drift out of sync with the static 
> analyzer checks unless we find some way to automate it. I wonder if we could 
> write a script to generate these .rst files and somehow fit it into the 
> workflow for adding new static analyzer checks to re-run the script to 
> produce new files (or modified files) as needed? @NoQ and @Szelethus may have 
> ideas.


I wrote a script to generate these. I can clean it up a bit more and add it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454



___
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-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

This is ready for another round




Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:25
 /// A kind of a syntax node, used for implementing casts.
 enum class NodeKind : uint16_t {
   Leaf,

sammccall wrote:
> there are going to be many of these. I'd suggest either sorting them all, or 
> breaking them into blocks (e.g. statements vs declarations vs leaf/tu/etc) 
> and sorting those blocks.
I've added two blocks now - statements and expressions.
Did not sort, though, I find the semantic grouping (loop statements close to 
each other) more useful, but hard to keep consistent.


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] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

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

Just thinking aloud!

We were tinkering with the idea of a checker creator script similar to what 
clang-tidy has, that could help on this potentially.

Is generating the rst code with Tblgen a feasable approach? At first glance, it 
sounds like a nightmare to implement, and I wonder whether the maintainers of 
sphinx buildbots would need to adjust to that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454



___
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-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 208995.
ilya-biryukov added a comment.

- Mark groups of kinds for statements and expressions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63835

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -136,19 +136,326 @@
 | |-(
 | |-)
 | `-CompoundStatement
-|   |-2: {
-|   `-3: }
+|   |-{
+|   `-}
 |-TopLevelDeclaration
 | |-void
 | |-foo
 | |-(
 | |-)
 | `-CompoundStatement
-|   |-2: {
-|   `-3: }
+|   |-{
+|   `-}
 `-
 )txt"},
-  };
+  // if.
+  {
+  R"cpp(
+int main() {
+  if (true) {}
+  if (true) {} else if (false) {}
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-int
+| |-main
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-IfStatement
+|   | |-if
+|   | |-(
+|   | |-UnknownExpression
+|   | | `-true
+|   | |-)
+|   | `-CompoundStatement
+|   |   |-{
+|   |   `-}
+|   |-IfStatement
+|   | |-if
+|   | |-(
+|   | |-UnknownExpression
+|   | | `-true
+|   | |-)
+|   | |-CompoundStatement
+|   | | |-{
+|   | | `-}
+|   | |-else
+|   | `-IfStatement
+|   |   |-if
+|   |   |-(
+|   |   |-UnknownExpression
+|   |   | `-false
+|   |   |-)
+|   |   `-CompoundStatement
+|   | |-{
+|   | `-}
+|   `-}
+`-
+)txt"},
+  // for.
+  {R"cpp(
+void test() {
+  for (;;)  {}
+}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-ForStatement
+|   | |-for
+|   | |-(
+|   | |-;
+|   | |-;
+|   | |-)
+|   | `-CompoundStatement
+|   |   |-{
+|   |   `-}
+|   `-}
+`-
+)txt"},
+  // declaration statement.
+  {"void test() { int a = 10; }",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-DeclarationStatement
+|   | |-int
+|   | |-a
+|   | |-=
+|   | |-10
+|   | `-;
+|   `-}
+`-
+)txt"},
+  {"void test() { ; }", R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-EmptyStatement
+|   | `-;
+|   `-}
+`-
+)txt"},
+  // switch, case and default.
+  {R"cpp(
+void test() {
+  switch (true) {
+case 0:
+default:;
+  }
+}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-SwitchStatement
+|   | |-switch
+|   | |-(
+|   | |-UnknownExpression
+|   | | `-true
+|   | |-)
+|   | `-CompoundStatement
+|   |   |-{
+|   |   |-CaseStatement
+|   |   | |-case
+|   |   | |-UnknownExpression
+|   |   | | `-0
+|   |   | |-:
+|   |   | `-DefaultStatement
+|   |   |   |-default
+|   |   |   |-:
+|   |   |   `-EmptyStatement
+|   |   | `-;
+|   |   `-}
+|   `-}
+`-
+)txt"},
+  // while.
+  {R"cpp(
+void test() {
+  while (true) { continue; break; }
+}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-WhileStatement
+|   | |-while
+|   | |-(
+|   | |-UnknownExpression
+|   | | `-true
+|   | |-)
+|   | `-CompoundStatement
+|   |   |-{
+|   |   |-ContinueStatement
+|   |   | |-continue
+|   |   | `-;
+|   |   |-BreakStatement
+|   |   | |-break
+|   |   | `-;
+|   |   `-}
+|   `-}
+`-
+)txt"},
+  // return.
+  {R"cpp(
+int test() { return 1; }
+  )cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-int
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-ReturnStatement
+|   | |-return
+|   | |-UnknownExpression
+|   | | `-1
+|   | `-;
+|   `-}
+`-
+   )txt"},
+  // Range-based for.
+  {R"cpp(
+void test() {
+  int a[3];
+  for (int x : a) ;
+}
+  )cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-DeclarationStatement
+|   | |-int
+|   | |-a
+|   | |-[
+|   | |-3
+|   | |-]
+|   | `-;
+|   |-RangeBasedForStatement
+|   | |-for
+|   | |-(
+|   | |-int
+|   | |-x
+|   | |-:
+|   | |-UnknownExpression
+|   | | `-a
+|   | |-)
+|   | `-EmptyStatement
+|   |   `-;
+|   `-}
+`-
+   )txt"},
+  // Unhandled statements should end up as 'unknown statement'.
+  // This example uses a 'label statement', which does not yet have a syntax
+  // counterpart.
+  {"void main() { foo: return 100; }", R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-main
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-UnknownStatement
+|   | |-foo
+|   | |-:
+|   | 

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

2019-07-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked 2 inline comments as done and 2 inline comments as done.
Anastasia added inline comments.



Comment at: include/clang/AST/Type.h:6512
+inline bool Type::isTemplateSpecializationType() const {
+  return isa(this);
+}

rjmccall wrote:
> This is a sugar type.  What are you trying to do?
I just need a helper function to identify this type in the addr space deduction 
logic below. Do you think we shouldn't expose it as interface? 

In fact I am now adding `isInjectedClassNameType` for the same reason to cover 
another similar test case.



Comment at: lib/Sema/SemaType.cpp:7421
+  // - template specialization as addr space in template argument doesn't
+  //   affect specialization.
+  (T->isDependentType() && (!T->isPointerType() && !T->isReferenceType() &&

rjmccall wrote:
> I don't understand what you're saying here.  Why does inference depend on 
> whether the type is a template specialization?  And what does this have to do 
> with template arguments?  Also, address spaces in template arguments are 
> definitely part of the template argument and affect which specialization 
> you're naming.
What I am trying to say here is that an address space of a template argument 
isn't used as an address space of a template specialization and therefore we 
can deduce the address space of a template specialization since it's not going 
to be provided during the template instantiation.

Let's say we have specialization `MyClass`. The address space of `T` has 
nothing to do with the address space of `MyClass`. They are different. 
Therefore if the address space of `MyClass` is not provided explicitly it is 
ok to deduce it.

Does it make sense?



Comment at: lib/Sema/SemaType.cpp:7421
+  // - template specialization as addr space in template argument doesn't
+  //   affect specialization.
+  (T->isDependentType() &&

If you think it's reasonable the same would apply to `InjectedClassNameType`.


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

https://reviews.llvm.org/D64400



___
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-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 208993.
Anastasia marked 2 inline comments as done.
Anastasia added a comment.

- Added handling of similar test case with `InjectedClassNameType`


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

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,41 @@
   int foo[10];
   xxx([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);
+}
+
+template 
+class x3 : public T {
+public:
+  //CHECK: -CXXConstructorDecl {{.*}} x3 'void (const __generic x3 &) 
__generic'
+  x3(const x3 );
+};
+//CHECK: -CXXConstructorDecl {{.*}} 'void (const __generic x3 &) __generic'
+template 
+x3::x3(const x3 ) {}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7414,9 +7414,14 @@
   (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()) ||
+  // Except 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() && !T->isInjectedClassNameType())) 
||
   // 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,8 @@
   bool isObjCBoxableRecordType() const;
   bool isInterfaceType() const;
   bool isStructureOrClassType() const;
+  bool isTemplateSpecializationType() const;
+  bool isInjectedClassNameType() const;
   bool isUnionType() const;
   bool isComplexIntegerType() const;// GCC _Complex integer type.
   bool isVectorType() const;// GCC vector type.
@@ -6507,6 +6509,14 @@
   return isa(this);
 }
 
+inline bool Type::isTemplateSpecializationType() const {
+  return isa(this);
+}
+
+inline bool Type::isInjectedClassNameType() 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,41 @@
   int foo[10];
   xxx([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);
+}
+
+template 
+class x3 : public T {
+public:
+  //CHECK: -CXXConstructorDecl {{.*}} x3 'void (const __generic x3 &) __generic'
+  x3(const x3 );
+};
+//CHECK: -CXXConstructorDecl {{.*}} 'void (const __generic x3 &) __generic'
+template 
+x3::x3(const x3 ) {}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7414,9 +7414,14 @@
   (T->isVoidType() && !IsPointee) ||
   // 

[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

2019-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D64454#1578352 , @aaron.ballman 
wrote:

> I'm worried that this will continue to drift out of sync with the static 
> analyzer checks unless we find some way to automate it. I wonder if we could 
> write a script to generate these .rst files and somehow fit it into the 
> workflow for adding new static analyzer checks to re-run the script to 
> produce new files (or modified files) as needed? @NoQ and @Szelethus may have 
> ideas.


I totally agree. The list of checkers changes fairly often.

The checkers are listed in a machine-readable tablegen file, 
`include/clang/StaticAnalyzer/Checkers/Checkers.td`.

Note that some of the checkers in the list don't emit any warnings (which is 
fine in the Static Analyzer as checkers can interact with each other and the 
only purpose of these checkers is to make other checkers be more correct). 
There's a related set of checkers that are "hidden" (marked as Hidden in 
`Checkers.td`) - those checkers that we don't support enabling/disabling 
manually, so you should probably not list them either. I think currently all or 
most of the non-warning checkers are also hidden.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454



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


[PATCH] D64495: [AArch64] Implement __jcvt intrinsic from Armv8.3-A

2019-07-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Looks like a good change to me, some nits inlined.

It shouldn't be difficult to request an account and commit it yourself, which 
might be useful if you maybe intend to submit more patches. 
But I can of course easily commit this on your behalf, just let me know. If you 
want me to commit this, it is easiest if you do upload a new diff with the nits 
fixed.




Comment at: clang/test/CodeGen/arm_acle.c:5
 // RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +neon -target-feature +crc -target-feature +crypto -O2 
-fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-NEWPM 
-check-prefix=AArch64-NEWPM
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.3a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3 -check-prefix=CHECK-LABEL
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.4a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3 -check-prefix=CHECK-LABEL

Some nits that you can fix before committing; no need for another review I 
think.

You can remove: 

  -check-prefix=CHECK-LABEL

in all these 3 lines below.



Comment at: clang/test/CodeGen/arm_acle.c:830
+
+// CHECK-LABEL: @test_jcvt(
+// AArch64-v8_3: call i32 @llvm.aarch64.fjcvtzs

and change 

  // CHECK-LABEL: @test_jcvt(

into 

   // AArch64-v8_3-LABEL: @test_jcvt(


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

https://reviews.llvm.org/D64495



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


[PATCH] D63192: [Diagnostics] Implement -Wswitch-default

2019-07-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 208984.

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

https://reviews.llvm.org/D63192

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaStmt.cpp
  test/Sema/switch-availability.c
  test/SemaCXX/switch_default.cpp
  test/SemaCXX/uninitialized.cpp

Index: test/SemaCXX/uninitialized.cpp
===
--- test/SemaCXX/uninitialized.cpp
+++ test/SemaCXX/uninitialized.cpp
@@ -1444,8 +1444,8 @@
   if (int n = 0; (n == k || k > 5)) {}
 
   if (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} expected-note {{initialize}}
-
+  // expected-warning@+1 {{switch has no default and case labels}}
   switch (int n = 0; (n == k || k > 5)) {} // expected-warning {{boolean}}
-
+  // expected-warning@+1 {{switch has no default and case labels}}
   switch (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} expected-note {{initialize}} expected-warning {{boolean}}
 }
Index: test/SemaCXX/switch_default.cpp
===
--- test/SemaCXX/switch_default.cpp
+++ test/SemaCXX/switch_default.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wswitch-default %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wswitch-default %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wall %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wall %s
+
+void test(int x) {
+  switch (x) {
+  default: // expected-warning {{switch contains only default label}}
+break;
+  }
+
+  switch (x) {
+  default: // expected-warning {{switch contains only default label}}
+x++;
+  }
+
+  switch (x) {
+  default:; // expected-warning {{switch contains only default label}}
+  }
+
+  switch (x)
+  default: // expected-warning {{switch contains only default label}}
+break;
+
+  switch (x) {
+  default:
+return;
+  case 1:
+break;
+  }
+
+  switch (x) {
+  case 1:
+break;
+  default:
+return;
+  }
+}
Index: test/Sema/switch-availability.c
===
--- test/Sema/switch-availability.c
+++ test/Sema/switch-availability.c
@@ -5,7 +5,7 @@
 };
 
 void testSwitchOne(enum SwitchOne so) {
-  switch (so) {} // no warning
+  switch (so) {} // expected-warning {{switch has no default and case labels}}
 }
 
 enum SwitchTwo {
@@ -15,6 +15,7 @@
 };
 
 void testSwitchTwo(enum SwitchTwo st) {
+  // expected-warning@+1 {{switch has no default and case labels}}
   switch (st) {} // expected-warning{{enumeration values 'Vim' and 'Emacs' not handled in switch}}
 }
 
@@ -23,5 +24,6 @@
 };
 
 void testSwitchThree(enum SwitchThree st) {
+  // expected-warning@+1 {{switch has no default and case labels}}
   switch (st) {} // expected-warning{{enumeration value 'New' not handled in switch}}
 }
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -865,8 +865,13 @@
 
   bool CaseListIsErroneous = false;
 
-  for (SwitchCase *SC = SS->getSwitchCaseList(); SC && !HasDependentValue;
-   SC = SC->getNextSwitchCase()) {
+  SwitchCase *SC = SS->getSwitchCaseList();
+  if (!SC)
+Diag(SS->getBeginLoc(), diag::warn_no_cases_in_switch);
+  else if (isa(SC) && !SC->getNextSwitchCase())
+Diag(SC->getBeginLoc(), diag::warn_default_only_in_switch);
+
+  for (; SC && !HasDependentValue; SC = SC->getNextSwitchCase()) {
 
 if (DefaultStmt *DS = dyn_cast(SC)) {
   if (TheDefaultStmt) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8201,6 +8201,10 @@
 def warn_break_binds_to_switch : Warning<
   "'break' is bound to loop, GCC binds it to switch">,
   InGroup;
+def warn_no_cases_in_switch : Warning<
+  "switch has no default and case labels">, InGroup, DefaultIgnore;
+def warn_default_only_in_switch : Warning<
+  "switch contains only default label">, InGroup, DefaultIgnore;
 def err_default_not_in_switch : Error<
   "'default' statement not in switch statement">;
 def err_case_not_in_switch : Error<"'case' statement not in switch statement">;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -458,7 +458,6 @@
 def : DiagGroup<"sign-promo">;
 def SignCompare : DiagGroup<"sign-compare">;
 def : DiagGroup<"stack-protector">;
-def : DiagGroup<"switch-default">;
 def : DiagGroup<"synth">;
 def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">;
 def SizeofArrayDecay : DiagGroup<"sizeof-array-decay">;
@@ -537,6 +536,7 @@
 def ObjCCStringFormat : DiagGroup<"cstring-format-directive">;
 def CoveredSwitchDefault : 

[PATCH] D64506: clang-cl: Remove -O0 option

2019-07-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I did check that we now warn, like you had requested:

  $ out/gn/bin/clang-cl test.cc /O0 /c
  clang: warning: argument unused during compilation: '/O0' 
[-Wunused-command-line-argument]

Adding a test for that felt weird though, so I didn't.


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

https://reviews.llvm.org/D64506



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


[PATCH] D64506: clang-cl: Remove -O0 option

2019-07-10 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.

cl.exe doesn't understand it; there's /Od instead. See also the review
thread for r229575.


https://reviews.llvm.org/D64506

Files:
  clang/include/clang/Driver/CLCompatOptions.td


Index: clang/include/clang/Driver/CLCompatOptions.td
===
--- clang/include/clang/Driver/CLCompatOptions.td
+++ clang/include/clang/Driver/CLCompatOptions.td
@@ -118,8 +118,6 @@
 def _SLASH_O : CLJoined<"O">,
   HelpText<"Set multiple /O flags at once; e.g. '/O2y-' for '/O2 /Oy-'">,
   MetaVarName<"">;
-// FIXME: Not sure why we have -O0 here; MSVC doesn't support that.
-def : CLFlag<"O0">, Alias, HelpText<"Disable optimization">;
 def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>,
   HelpText<"Optimize for size  (same as /Og /Os /Oy /Ob2 /GF /Gy)">;
 def : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>,


Index: clang/include/clang/Driver/CLCompatOptions.td
===
--- clang/include/clang/Driver/CLCompatOptions.td
+++ clang/include/clang/Driver/CLCompatOptions.td
@@ -118,8 +118,6 @@
 def _SLASH_O : CLJoined<"O">,
   HelpText<"Set multiple /O flags at once; e.g. '/O2y-' for '/O2 /Oy-'">,
   MetaVarName<"">;
-// FIXME: Not sure why we have -O0 here; MSVC doesn't support that.
-def : CLFlag<"O0">, Alias, HelpText<"Disable optimization">;
 def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>,
   HelpText<"Optimize for size  (same as /Og /Os /Oy /Ob2 /GF /Gy)">;
 def : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64495: [AArch64] Implement __jcvt intrinsic from Armv8.3-A

2019-07-10 Thread Kyrill Tkachov via Phabricator via cfe-commits
ktkachov updated this revision to Diff 208980.
ktkachov added a comment.

Add more CHECK-LABEL tests, test v8.4a and v8.5a features. Fix formatting in 
pattern.


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

https://reviews.llvm.org/D64495

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/arm_acle.c
  clang/test/CodeGen/builtins-arm64.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/fjcvtzs.ll

Index: llvm/test/CodeGen/AArch64/fjcvtzs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/fjcvtzs.ll
@@ -0,0 +1,10 @@
+; RUN: llc -mtriple=arm64-eabi -mattr=+jsconv -o - %s | FileCheck %s
+
+define i32 @test_jcvt(double %v) {
+; CHECK-LABEL: test_jcvt:
+; CHECK: fjcvtzs w0, d0
+  %val = call i32 @llvm.aarch64.fjcvtzs(double %v)
+  ret i32 %val
+}
+
+declare i32 @llvm.aarch64.fjcvtzs(double)
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -717,7 +717,9 @@
 // v8.3a floating point conversion for javascript
 let Predicates = [HasJS, HasFPARMv8] in
 def FJCVTZS  : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
-  "fjcvtzs", []> {
+  "fjcvtzs",
+  [(set GPR32:$Rd,
+ (int_aarch64_fjcvtzs FPR64:$Rn))]> {
   let Inst{31} = 0;
 } // HasJS, HasFPARMv8
 
Index: llvm/include/llvm/IR/IntrinsicsAArch64.td
===
--- llvm/include/llvm/IR/IntrinsicsAArch64.td
+++ llvm/include/llvm/IR/IntrinsicsAArch64.td
@@ -31,6 +31,8 @@
 def int_aarch64_udiv : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>,
 LLVMMatchType<0>], [IntrNoMem]>;
 
+def int_aarch64_fjcvtzs : Intrinsic<[llvm_i32_ty], [llvm_double_ty], [IntrNoMem]>;
+
 //===--===//
 // HINT
 
Index: clang/test/CodeGen/builtins-arm64.c
===
--- clang/test/CodeGen/builtins-arm64.c
+++ clang/test/CodeGen/builtins-arm64.c
@@ -58,6 +58,12 @@
 // CHECK: call {{.*}} @llvm.prefetch(i8* null, i32 0, i32 3, i32 0)
 }
 
+int32_t jcvt(double v) {
+  //CHECK-LABEL: @jcvt(
+  //CHECK: call i32 @llvm.aarch64.fjcvtzs
+  return __builtin_arm_jcvt(v);
+}
+
 __typeof__(__builtin_arm_rsr("1:2:3:4:5")) rsr(void);
 
 uint32_t rsr() {
Index: clang/test/CodeGen/arm_acle.c
===
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -2,6 +2,9 @@
 // RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 -O2  -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch32 -check-prefix=ARM-NEWPM -check-prefix=AArch32-NEWPM
 // RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +neon -target-feature +crc -target-feature +crypto -O2 -fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-LEGACY -check-prefix=AArch64-LEGACY
 // RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +neon -target-feature +crc -target-feature +crypto -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-NEWPM -check-prefix=AArch64-NEWPM
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +v8.3a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=AArch64-v8_3 -check-prefix=CHECK-LABEL
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +v8.4a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=AArch64-v8_3 -check-prefix=CHECK-LABEL
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +v8.5a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=AArch64-v8_3 -check-prefix=CHECK-LABEL
 
 #include 
 
@@ -823,3 +826,11 @@
 
 // AArch64: ![[M0]] = !{!"1:2:3:4:5"}
 // AArch64: ![[M1]] = !{!"sysreg"}
+
+// CHECK-LABEL: @test_jcvt(
+// AArch64-v8_3: call i32 @llvm.aarch64.fjcvtzs
+#ifdef __ARM_64BIT_STATE
+int32_t test_jcvt(double v) {
+  return __jcvt(v);
+}
+#endif
Index: clang/lib/Headers/arm_acle.h
===
--- 

[PATCH] D64504: Various minor tweaks to CLCompatOptions.td

2019-07-10 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.

- Add back indentation I accidentally removed in r364901
- Wrap two lines to 80 cols
- Slightly tighten up help text for several flags
- Consistently use "Do not" instead of "Don't"
- Make every option description start with a verb
- Use "Set" instead of "Specify"
- Mark default values of options more consistently
- Remove text about "/Zi" not producing PDBs since it's confusing for people 
not intimately familiar with the implementation of the normal PDB pipeline. /Zi 
lets the linker produce PDBs, which is what most users want.
- Consistently use "file" over "filename" in meta var names, consistently use 
"file name" over "filename" in text
- Make all output setting options have consistent language

Hopefully makes help output a bit easier to read.
Also makes help for most flags in the "CL COMPAT FLAGS" section fit in an 80 
column terminal.


https://reviews.llvm.org/D64504

Files:
  clang/include/clang/Driver/CLCompatOptions.td

Index: clang/include/clang/Driver/CLCompatOptions.td
===
--- clang/include/clang/Driver/CLCompatOptions.td
+++ clang/include/clang/Driver/CLCompatOptions.td
@@ -52,21 +52,21 @@
 // already in the right group.)
 
 def _SLASH_Brepro : CLFlag<"Brepro">,
-  HelpText<"Emit an object file which can be reproduced over time">,
+  HelpText<"Do not write current time into COFF output (breaks link.exe /incremental)">,
   Alias;
 def _SLASH_Brepro_ : CLFlag<"Brepro-">,
-  HelpText<"Emit an object file which cannot be reproduced over time">,
+  HelpText<"Write current time into COFF output (default)">,
   Alias;
 def _SLASH_C : CLFlag<"C">,
-  HelpText<"Don't discard comments when preprocessing">, Alias;
+  HelpText<"Do not discard comments when preprocessing">, Alias;
 def _SLASH_c : CLFlag<"c">, HelpText<"Compile only">, Alias;
 def _SLASH_d1PP : CLFlag<"d1PP">,
   HelpText<"Retain macro definitions in /E mode">, Alias;
 def _SLASH_d1reportAllClassLayout : CLFlag<"d1reportAllClassLayout">,
   HelpText<"Dump record layout information">,
-Alias, AliasArgs<["-fdump-record-layouts"]>;
+  Alias, AliasArgs<["-fdump-record-layouts"]>;
 def _SLASH_diagnostics_caret : CLFlag<"diagnostics:caret">,
-  HelpText<"Enable caret and column diagnostics (on by default)">;
+  HelpText<"Enable caret and column diagnostics (default)">;
 def _SLASH_diagnostics_column : CLFlag<"diagnostics:column">,
   HelpText<"Disable caret diagnostics but keep column info">;
 def _SLASH_diagnostics_classic : CLFlag<"diagnostics:classic">,
@@ -83,12 +83,14 @@
 def _SLASH_fp_strict : CLFlag<"fp:strict">, HelpText<"">, Alias;
 def _SLASH_GA : CLFlag<"GA">, Alias, AliasArgs<["local-exec"]>,
   HelpText<"Assume thread-local variables are defined in the executable">;
-def _SLASH_GR : CLFlag<"GR">, HelpText<"Enable emission of RTTI data">;
-def _SLASH_GR_ : CLFlag<"GR-">, HelpText<"Disable emission of RTTI data">;
-def _SLASH_GF : CLIgnoredFlag<"GF">, HelpText<"Enable string pooling (default)">;
+def _SLASH_GR : CLFlag<"GR">, HelpText<"Emit RTTI data (default)">;
+def _SLASH_GR_ : CLFlag<"GR-">, HelpText<"Do not emit RTTI data">;
+def _SLASH_GF : CLIgnoredFlag<"GF">,
+  HelpText<"Enable string pooling (default)">;
 def _SLASH_GF_ : CLFlag<"GF-">, HelpText<"Disable string pooling">,
   Alias;
-def _SLASH_GS : CLFlag<"GS">, HelpText<"Enable buffer security check (default)">;
+def _SLASH_GS : CLFlag<"GS">,
+  HelpText<"Enable buffer security check (default)">;
 def _SLASH_GS_ : CLFlag<"GS-">, HelpText<"Disable buffer security check">;
 def : CLFlag<"Gs">, HelpText<"Use stack probes (default)">,
   Alias, AliasArgs<["4096"]>;
@@ -102,7 +104,7 @@
 def _SLASH_Gw : CLFlag<"Gw">, HelpText<"Put each data item in its own section">,
   Alias;
 def _SLASH_Gw_ : CLFlag<"Gw-">,
-  HelpText<"Don't put each data item in its own section">,
+  HelpText<"Don't put each data item in its own section (default)">,
   Alias;
 def _SLASH_help : CLFlag<"help">, Alias,
   HelpText<"Display available options">;
@@ -121,13 +123,13 @@
 // FIXME: Not sure why we have -O0 here; MSVC doesn't support that.
 def : CLFlag<"O0">, Alias, HelpText<"Disable optimization">;
 def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>,
-  HelpText<"Optimize for size  (same as /Og /Os /Oy /Ob2 /GF /Gy)">;
+  HelpText<"Optimize for size  (like /Og /Os /Oy /Ob2 /GF /Gy)">;
 def : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>,
-  HelpText<"Optimize for speed (same as /Og /Oi /Ot /Oy /Ob2 /GF /Gy)">;
+  HelpText<"Optimize for speed (like /Og /Oi /Ot /Oy /Ob2 /GF /Gy)">;
 def : CLFlag<"Ob0">, Alias<_SLASH_O>, AliasArgs<["b0"]>,
   HelpText<"Disable function inlining">;
 def : CLFlag<"Ob1">, Alias<_SLASH_O>, AliasArgs<["b1"]>,
-  HelpText<"Only inline functions which are (explicitly or implicitly) marked inline">;
+  HelpText<"Only inline functions explicitly or implicitly marked inline">;
 def : CLFlag<"Ob2">, Alias<_SLASH_O>, AliasArgs<["b2"]>,
   

[PATCH] D63192: [Diagnostics] Implement -Wswitch-default

2019-07-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D63192#1539605 , @xbolva00 wrote:

> I will work on this after we land https://reviews.llvm.org/D63139.


^ not yet landed, but please @aaron.ballman  take a look, this patch is ready 
for review.


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

https://reviews.llvm.org/D63192



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


[PATCH] D63192: [Diagnostics] Implement -Wswitch-default

2019-07-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 208974.
xbolva00 added a comment.

Rebased, improved.


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

https://reviews.llvm.org/D63192

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaStmt.cpp
  test/SemaCXX/switch_default.cpp
  test/SemaCXX/uninitialized.cpp

Index: test/SemaCXX/uninitialized.cpp
===
--- test/SemaCXX/uninitialized.cpp
+++ test/SemaCXX/uninitialized.cpp
@@ -1444,8 +1444,8 @@
   if (int n = 0; (n == k || k > 5)) {}
 
   if (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} expected-note {{initialize}}
-
+  // expected-warning@+1 {{switch has no default and case labels}}
   switch (int n = 0; (n == k || k > 5)) {} // expected-warning {{boolean}}
-
+  // expected-warning@+1 {{switch has no default and case labels}}
   switch (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} expected-note {{initialize}} expected-warning {{boolean}}
 }
Index: test/SemaCXX/switch_default.cpp
===
--- test/SemaCXX/switch_default.cpp
+++ test/SemaCXX/switch_default.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wswitch-default %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wswitch-default %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wall %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wall %s
+
+void test(int x) {
+  switch (x) {
+  default: // expected-warning {{switch contains only default label}}
+break;
+  }
+
+  switch (x) {
+  default: // expected-warning {{switch contains only default label}}
+x++;
+  }
+
+  switch (x) {
+  default:; // expected-warning {{switch contains only default label}}
+  }
+
+  switch (x)
+  default: // expected-warning {{switch contains only default label}}
+break;
+
+  switch (x) {
+  default:
+return;
+  case 1:
+break;
+  }
+
+  switch (x) {
+  case 1:
+break;
+  default:
+return;
+  }
+
+  switch (x) { // expected-warning {{switch has no default and case labels}}
+  }
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -865,8 +865,13 @@
 
   bool CaseListIsErroneous = false;
 
-  for (SwitchCase *SC = SS->getSwitchCaseList(); SC && !HasDependentValue;
-   SC = SC->getNextSwitchCase()) {
+  SwitchCase *SC = SS->getSwitchCaseList();
+  if (!SC)
+Diag(SS->getBeginLoc(), diag::warn_no_cases_in_switch);
+  else if (isa(SC) && !SC->getNextSwitchCase())
+Diag(SC->getBeginLoc(), diag::warn_default_only_in_switch);
+
+  for (; SC && !HasDependentValue; SC = SC->getNextSwitchCase()) {
 
 if (DefaultStmt *DS = dyn_cast(SC)) {
   if (TheDefaultStmt) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8201,6 +8201,10 @@
 def warn_break_binds_to_switch : Warning<
   "'break' is bound to loop, GCC binds it to switch">,
   InGroup;
+def warn_no_cases_in_switch : Warning<
+  "switch has no default and case labels">, InGroup, DefaultIgnore;
+def warn_default_only_in_switch : Warning<
+  "switch contains only default label">, InGroup, DefaultIgnore;
 def err_default_not_in_switch : Error<
   "'default' statement not in switch statement">;
 def err_case_not_in_switch : Error<"'case' statement not in switch statement">;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -458,7 +458,6 @@
 def : DiagGroup<"sign-promo">;
 def SignCompare : DiagGroup<"sign-compare">;
 def : DiagGroup<"stack-protector">;
-def : DiagGroup<"switch-default">;
 def : DiagGroup<"synth">;
 def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">;
 def SizeofArrayDecay : DiagGroup<"sizeof-array-decay">;
@@ -537,6 +536,7 @@
 def ObjCCStringFormat : DiagGroup<"cstring-format-directive">;
 def CoveredSwitchDefault : DiagGroup<"covered-switch-default">;
 def SwitchBool : DiagGroup<"switch-bool">;
+def SwitchDefault  : DiagGroup<"switch-default">;
 def SwitchEnum : DiagGroup<"switch-enum">;
 def Switch : DiagGroup<"switch">;
 def EnumCompareSwitch : DiagGroup<"enum-compare-switch">;
@@ -842,7 +842,7 @@
 // Note that putting warnings in -Wall will not disable them by default. If a
 // warning should be active _only_ when -Wall is passed in, mark it as
 // DefaultIgnore in addition to putting it here.
-def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>;
+def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool, SwitchDefault]>;
 
 // Warnings that should be in clang-cl /w4.
 def : DiagGroup<"CL4", [All, Extra]>;

[PATCH] D63932: [GlobalDCE] Dead Virtual Function Elimination

2019-07-10 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Hi Oliver, thanks for working on this. This is something that I've always 
wanted to do with the type metadata but never had time to work on. I'll try to 
take a more in depth look later this week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63932



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


r365643 - [AMDGPU] Increased the number of implicit argument bytes for both OpenCL and HIP (CLANG).

2019-07-10 Thread Christudasan Devadasan via cfe-commits
Author: cdevadas
Date: Wed Jul 10 08:10:08 2019
New Revision: 365643

URL: http://llvm.org/viewvc/llvm-project?rev=365643=rev
Log:
[AMDGPU] Increased the number of implicit argument bytes for both OpenCL and 
HIP (CLANG).

To enable a new implicit kernel argument,
increased the number of argument bytes from 48 to 56.

Reviewed By: yaxunl

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

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=365643=365642=365643=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jul 10 08:10:08 2019
@@ -7910,7 +7910,7 @@ void AMDGPUTargetCodeGenInfo::setTargetA
   if (((M.getLangOpts().OpenCL && FD->hasAttr()) ||
   (M.getLangOpts().HIP && FD->hasAttr())) &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
-F->addFnAttr("amdgpu-implicitarg-num-bytes", "48");
+F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {

Modified: cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu?rev=365643=365642=365643=diff
==
--- cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu Wed Jul 10 
08:10:08 2019
@@ -5,4 +5,4 @@
 __global__ void hip_kernel_temp() {
 }
 
-// CHECK: attributes {{.*}} = {{.*}} "amdgpu-implicitarg-num-bytes"="48"
+// CHECK: attributes {{.*}} = {{.*}} "amdgpu-implicitarg-num-bytes"="56"

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl?rev=365643=365642=365643=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl Wed Jul 10 08:10:08 2019
@@ -158,30 +158,30 @@ void a_function() {
 // CHECK-NOT: "amdgpu-num-sgpr"="0"
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="64,64" 
"amdgpu-implicitarg-num-bytes"="48" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="16,128" 
"amdgpu-implicitarg-num-bytes"="48" 
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64" 
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="56" 
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="64,64" 
"amdgpu-implicitarg-num-bytes"="56" 
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="16,128" 
"amdgpu-implicitarg-num-bytes"="56" 
+// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-waves-per-eu"="2"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-waves-per-eu"="2,4"
+// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-sgpr"="32" 
+// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-vgpr"="64" 
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4]] = { 

[PATCH] D63756: [AMDGPU] Increased the number of implicit argument bytes for both OpenCL and HIP (CLANG).

2019-07-10 Thread Christudasan Devadasan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365643: [AMDGPU] Increased the number of implicit argument 
bytes for both OpenCL and… (authored by cdevadas, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63756?vs=206377=208969#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63756

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
  cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl


Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl
@@ -158,30 +158,30 @@
 // CHECK-NOT: "amdgpu-num-sgpr"="0"
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="64,64" 
"amdgpu-implicitarg-num-bytes"="48" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="16,128" 
"amdgpu-implicitarg-num-bytes"="48" 
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64" 
-
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_SGPR_32]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_VGPR_64]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64" 
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="48" 
"amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="48" 
"amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="48" 
"amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="48" 
"amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32_NUM_VGPR_64]] = { convergent noinline 
nounwind optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
"amdgpu-num-vgpr"="64" 
-
-// CHECK-DAG: attributes 
[[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
"amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes 
[[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64" 
"amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes 
[[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
"amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes 
[[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64" 
"amdgpu-waves-per-eu"="2,4"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone 

[PATCH] D64495: [AArch64] Implement __jcvt intrinsic from Armv8.3-A

2019-07-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.td:720
 def FJCVTZS  : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
-  "fjcvtzs", []> {
+  "fjcvtzs", [(set GPR32:$Rd, 
(int_aarch64_fjcvtzs FPR64:$Rn))]> {
   let Inst{31} = 0;

and a last nit: this needs some reformatting (exceeding the max column width)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64495



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


[PATCH] D64492: [clangd] Added highlightings for namespace specifiers.

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



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:41
+// namespace.
+if (const auto UD = dyn_cast(ND)) {
+  addToken(UD->getIdentLocation(), HighlightingKind::Namespace);

nit: const auto *



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:42
+if (const auto UD = dyn_cast(ND)) {
+  addToken(UD->getIdentLocation(), HighlightingKind::Namespace);
+}

nit: you miss a `return`



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:73
 // This check is for not getting two entries when there are anonymous
 // structs. It also makes us not highlight namespace qualifiers. For
 // elaborated types the actual type is highlighted as an inner TypeLoc.

this comment is stale with this patch, now we are highlighting namespace, it 
seems more natural to do it here, we can get a NestedNameSpecifierLoc from an 
`ElaboratedTypeLoc ` (so that we don't need the 
`TraverseNestedNameSpecifierLoc`).



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:247
+  case HighlightingKind::Namespace:
+return "entity.name.type.namespace.cpp";
   case HighlightingKind::NumKinds:

I think here should be `entity.name.namespace.cpp`, vscode uses this TX scope 
for namespace.



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:114
+R"cpp(
+  namespace $Namespace[[abc]] {
+namespace $Namespace[[bcd]] {

could you add a testcase for anonymous namespace?

`namespace {}`



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:119
+struct $Class[[A]] {
+  static enum class $Enum[[B]] {
+Hi,

nit: the `static` is not needed for a type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64492



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


[PATCH] D64495: [AArch64] Implement __jcvt intrinsic from Armv8.3-A

2019-07-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:237
+break;
+  case llvm::AArch64::ArchKind::ARMV8_4A:
+getTargetDefinesARMV84A(Opts, Builder);

SjoerdMeijer wrote:
> It is a good change, but I think you should either add tests for these cases, 
> or remove this (temporarily) because it is not adding much at the moment.
Ah, sorry: "-march=armv8.4-a also enables this"
probably good to add some tests for v8.4 and v8.5 too then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64495



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


[PATCH] D64494: [analyzer]Add user docs rst

2019-07-10 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365639: [analyzer]Add user docs rst (authored by martong, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64494?vs=208958=208966#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64494

Files:
  cfe/trunk/docs/ClangStaticAnalyzer.rst
  cfe/trunk/docs/analyzer/user-docs.rst


Index: cfe/trunk/docs/analyzer/user-docs.rst
===
--- cfe/trunk/docs/analyzer/user-docs.rst
+++ cfe/trunk/docs/analyzer/user-docs.rst
@@ -0,0 +1,4 @@
+User Docs
+=
+
+Contents:
Index: cfe/trunk/docs/ClangStaticAnalyzer.rst
===
--- cfe/trunk/docs/ClangStaticAnalyzer.rst
+++ cfe/trunk/docs/ClangStaticAnalyzer.rst
@@ -5,15 +5,16 @@
 The Clang Static Analyzer is a source code analysis tool that finds bugs in C, 
C++, and Objective-C programs.
 It implements *path-sensitive*, *inter-procedural analysis* based on *symbolic 
execution* technique.
 
-This is the Static Analyzer documentation page. 
+This is the Static Analyzer documentation page.
 
 See the `Official Tool Page `_.
 
 .. toctree::
:caption: Table of Contents
:numbered:
-   :maxdepth: 2  
- 
+   :maxdepth: 2
+
analyzer/checkers
+   analyzer/user-docs
analyzer/developer-docs
 


Index: cfe/trunk/docs/analyzer/user-docs.rst
===
--- cfe/trunk/docs/analyzer/user-docs.rst
+++ cfe/trunk/docs/analyzer/user-docs.rst
@@ -0,0 +1,4 @@
+User Docs
+=
+
+Contents:
Index: cfe/trunk/docs/ClangStaticAnalyzer.rst
===
--- cfe/trunk/docs/ClangStaticAnalyzer.rst
+++ cfe/trunk/docs/ClangStaticAnalyzer.rst
@@ -5,15 +5,16 @@
 The Clang Static Analyzer is a source code analysis tool that finds bugs in C, C++, and Objective-C programs.
 It implements *path-sensitive*, *inter-procedural analysis* based on *symbolic execution* technique.
 
-This is the Static Analyzer documentation page. 
+This is the Static Analyzer documentation page.
 
 See the `Official Tool Page `_.
 
 .. toctree::
:caption: Table of Contents
:numbered:
-   :maxdepth: 2  
- 
+   :maxdepth: 2
+
analyzer/checkers
+   analyzer/user-docs
analyzer/developer-docs
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r365639 - [analyzer]Add user docs rst

2019-07-10 Thread Gabor Marton via cfe-commits
Author: martong
Date: Wed Jul 10 07:49:53 2019
New Revision: 365639

URL: http://llvm.org/viewvc/llvm-project?rev=365639=rev
Log:
[analyzer]Add user docs rst

Summary:
Add user documentation page. This is an empty page atm, later patches will add
the specific user documentatoins.

Reviewers: dkrupp

Subscribers: whisperity, xazax.hun, baloghadamsoftware, szepet, rnkovacs, 
a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, gamesh411, Charusso, 
cfe-commits

Tags: #clang

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

Added:
cfe/trunk/docs/analyzer/user-docs.rst
Modified:
cfe/trunk/docs/ClangStaticAnalyzer.rst

Modified: cfe/trunk/docs/ClangStaticAnalyzer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangStaticAnalyzer.rst?rev=365639=365638=365639=diff
==
--- cfe/trunk/docs/ClangStaticAnalyzer.rst (original)
+++ cfe/trunk/docs/ClangStaticAnalyzer.rst Wed Jul 10 07:49:53 2019
@@ -5,15 +5,16 @@ Clang Static Analyzer
 The Clang Static Analyzer is a source code analysis tool that finds bugs in C, 
C++, and Objective-C programs.
 It implements *path-sensitive*, *inter-procedural analysis* based on *symbolic 
execution* technique.
 
-This is the Static Analyzer documentation page. 
+This is the Static Analyzer documentation page.
 
 See the `Official Tool Page `_.
 
 .. toctree::
:caption: Table of Contents
:numbered:
-   :maxdepth: 2  
- 
+   :maxdepth: 2
+
analyzer/checkers
+   analyzer/user-docs
analyzer/developer-docs
 

Added: cfe/trunk/docs/analyzer/user-docs.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/user-docs.rst?rev=365639=auto
==
--- cfe/trunk/docs/analyzer/user-docs.rst (added)
+++ cfe/trunk/docs/analyzer/user-docs.rst Wed Jul 10 07:49:53 2019
@@ -0,0 +1,4 @@
+User Docs
+=
+
+Contents:


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


r365638 - Remove two unused member variables.

2019-07-10 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Jul 10 07:49:36 2019
New Revision: 365638

URL: http://llvm.org/viewvc/llvm-project?rev=365638=rev
Log:
Remove two unused member variables.

They were added over 10 years ago in r66575 and have never been used as
far as I can tell.

(r67087 added similar fields to Compilation, and those are used.)

Modified:
cfe/trunk/include/clang/Driver/Driver.h

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=365638=365637=365638=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Wed Jul 10 07:49:36 2019
@@ -235,9 +235,6 @@ private:
   /// Certain options suppress the 'no input files' warning.
   unsigned SuppressMissingInputWarning : 1;
 
-  std::list TempFiles;
-  std::list ResultFiles;
-
   /// Cache of all the ToolChains in use by the driver.
   ///
   /// This maps from the string representation of a triple to a ToolChain


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


[PATCH] D64494: [analyzer]Add user docs rst

2019-07-10 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D64494#1578373 , @dkrupp wrote:

> I guess this is a placeholder for the subpages of "User Manual" @ 
> https://clang-analyzer.llvm.org, which will be ported in follow-up patches.


Yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64494



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


[PATCH] D64495: [AArch64] Implement __jcvt intrinsic from Armv8.3-A

2019-07-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:237
+break;
+  case llvm::AArch64::ArchKind::ARMV8_4A:
+getTargetDefinesARMV84A(Opts, Builder);

It is a good change, but I think you should either add tests for these cases, 
or remove this (temporarily) because it is not adding much at the moment.



Comment at: clang/test/CodeGen/arm_acle.c:829
+
+// AArch64-v8_3: call i32 @llvm.aarch64.fjcvtzs
+#ifdef __ARM_64BIT_STATE

Same comment, better is to do a CHECK-LABEL first



Comment at: clang/test/CodeGen/builtins-arm64.c:61
 
+int32_t jcvt(double v) {
+  //CHECK: call i32 @llvm.aarch64.fjcvtzs

Although this file doesn't seem to do this, better is check the function name 
first, e.g.:

  // CHECK-LABEL: @jcvt(

followed by what you want to check:
  
  //CHECK: call i32 @llvm.aarch64.fjcvtzs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64495



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


[PATCH] D63139: [Diagnostics] Implement -Wswitch-unreachable

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D63139#1561891 , @rjmccall wrote:

> Are the `CaseStmt`s being dropped in C++ because the expression overflows?  I 
> agree that that's bad AST behavior; we should strive to generate AST whenever 
> we can, even if it's not valid.


We do strive to generate an AST whenever we can (like recovering as though 
fix-its were applied, or keeping declarations and marking them as invalid), but 
I don't think we want to generate *invalid* AST nodes. I believe that way leads 
to more cascading, insensible errors and worse behavior for tooling than 
dropping the invalid AST node does (depending on the scenario). I have a hazy 
recollection that we wanted to consider adding AST nodes to represent erroneous 
constructs that attempt to hold onto as much valid state as we can capture to 
help with these situations, but I'm not certain that idea went anywhere.

It would be nice if we could suppress the unreachable warning in this case, but 
I'm not certain it's strictly required for this patch to proceed, either. 
@rsmith, do you have opinions?


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

https://reviews.llvm.org/D63139



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


[PATCH] D64482: [Driver] Define _FILE_OFFSET_BITS=64 on Solaris

2019-07-10 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D64482#1578245 , @MaskRay wrote:

> > There's one caveat: gcc defines _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE 
> > for C++ only, while clang has long been doing it for all languages
>
> Can you explain more about the hack 
> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0f97ccfdccc033f543ccbcb220697e62e84bf01f


No hack at all ;-)  See the patch submission 
https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01320.html for details.  Apart 
from that,
this is the direction libstdc++/g++ mean to take in general.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64482



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


[PATCH] D64494: [analyzer]Add user docs rst

2019-07-10 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp accepted this revision.
dkrupp added a comment.
This revision is now accepted and ready to land.

I guess this is a placeholder for the subpages of "User Manual" @ 
https://clang-analyzer.llvm.org, which will be ported in follow-up patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64494



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


[PATCH] D64495: [AArch64] Implement __jcvt intrinsic from Armv8.3-A

2019-07-10 Thread Kyrill Tkachov via Phabricator via cfe-commits
ktkachov created this revision.
ktkachov added reviewers: t.p.northover, SjoerdMeijer, pbarrio, momchil.velikov.
ktkachov added projects: LLVM, clang.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls, 
javed.absar.

The __jcvt intrinsic defined in ACLE [1] is available when __ARM_FEATURE_JCVT 
is defined.

  

This change introduces the AArch64 intrinsic, wires it up to the instruction 
and a new clang builtin function.
The __ARM_FEATURE_JCVT macro is now defined when an Armv8.3-A or higher target 
is used.
I've implemented the target detection logic in Clang so that this feature is 
enabled for architectures from armv8.3-a onwards (so -march=armv8.4-a also 
enables this, for example).

make check-all didn't show any new failures.

[1] https://developer.arm.com/docs/101028/latest/data-processing-intrinsics

N.B. This is my first patch to LLVM. Apologies if some code looks weird. If 
this is okay can somebody please apply it for me?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64495

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/arm_acle.c
  clang/test/CodeGen/builtins-arm64.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/fjcvtzs.ll

Index: llvm/test/CodeGen/AArch64/fjcvtzs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/fjcvtzs.ll
@@ -0,0 +1,10 @@
+; RUN: llc -mtriple=arm64-eabi -mattr=+jsconv -o - %s | FileCheck %s
+
+define i32 @test_jcvt(double %v) {
+; CHECK-LABEL: test_jcvt:
+; CHECK: fjcvtzs w0, d0
+  %val = call i32 @llvm.aarch64.fjcvtzs(double %v)
+  ret i32 %val
+}
+
+declare i32 @llvm.aarch64.fjcvtzs(double)
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -717,7 +717,7 @@
 // v8.3a floating point conversion for javascript
 let Predicates = [HasJS, HasFPARMv8] in
 def FJCVTZS  : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
-  "fjcvtzs", []> {
+  "fjcvtzs", [(set GPR32:$Rd, (int_aarch64_fjcvtzs FPR64:$Rn))]> {
   let Inst{31} = 0;
 } // HasJS, HasFPARMv8
 
Index: llvm/include/llvm/IR/IntrinsicsAArch64.td
===
--- llvm/include/llvm/IR/IntrinsicsAArch64.td
+++ llvm/include/llvm/IR/IntrinsicsAArch64.td
@@ -31,6 +31,8 @@
 def int_aarch64_udiv : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>,
 LLVMMatchType<0>], [IntrNoMem]>;
 
+def int_aarch64_fjcvtzs : Intrinsic<[llvm_i32_ty], [llvm_double_ty], [IntrNoMem]>;
+
 //===--===//
 // HINT
 
Index: clang/test/CodeGen/builtins-arm64.c
===
--- clang/test/CodeGen/builtins-arm64.c
+++ clang/test/CodeGen/builtins-arm64.c
@@ -58,6 +58,11 @@
 // CHECK: call {{.*}} @llvm.prefetch(i8* null, i32 0, i32 3, i32 0)
 }
 
+int32_t jcvt(double v) {
+  //CHECK: call i32 @llvm.aarch64.fjcvtzs
+  return __builtin_arm_jcvt(v);
+}
+
 __typeof__(__builtin_arm_rsr("1:2:3:4:5")) rsr(void);
 
 uint32_t rsr() {
Index: clang/test/CodeGen/arm_acle.c
===
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 -O2  -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch32 -check-prefix=ARM-NEWPM -check-prefix=AArch32-NEWPM
 // RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +neon -target-feature +crc -target-feature +crypto -O2 -fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-LEGACY -check-prefix=AArch64-LEGACY
 // RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +neon -target-feature +crc -target-feature +crypto -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-NEWPM -check-prefix=AArch64-NEWPM
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +v8.3a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s --check-prefix=AArch64-v8_3
 
 #include 
 
@@ -823,3 +824,11 @@
 
 // AArch64: ![[M0]] = !{!"1:2:3:4:5"}
 // AArch64: ![[M1]] = !{!"sysreg"}
+
+
+// AArch64-v8_3: call i32 @llvm.aarch64.fjcvtzs
+#ifdef __ARM_64BIT_STATE
+int32_t 

[PATCH] D64494: [analyzer]Add user docs rst

2019-07-10 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added a reviewer: dkrupp.
Herald added subscribers: cfe-commits, Charusso, gamesh411, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun, whisperity.
Herald added a project: clang.

Add user documentation page. This is an empty page atm, later patches will add
the specific user documentatoins.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64494

Files:
  clang/docs/ClangStaticAnalyzer.rst
  clang/docs/analyzer/user-docs.rst


Index: clang/docs/analyzer/user-docs.rst
===
--- /dev/null
+++ clang/docs/analyzer/user-docs.rst
@@ -0,0 +1,4 @@
+User Docs
+=
+
+Contents:
Index: clang/docs/ClangStaticAnalyzer.rst
===
--- clang/docs/ClangStaticAnalyzer.rst
+++ clang/docs/ClangStaticAnalyzer.rst
@@ -5,15 +5,16 @@
 The Clang Static Analyzer is a source code analysis tool that finds bugs in C, 
C++, and Objective-C programs.
 It implements *path-sensitive*, *inter-procedural analysis* based on *symbolic 
execution* technique.
 
-This is the Static Analyzer documentation page. 
+This is the Static Analyzer documentation page.
 
 See the `Official Tool Page `_.
 
 .. toctree::
:caption: Table of Contents
:numbered:
-   :maxdepth: 2  
- 
+   :maxdepth: 2
+
analyzer/checkers
+   analyzer/user-docs
analyzer/developer-docs
 


Index: clang/docs/analyzer/user-docs.rst
===
--- /dev/null
+++ clang/docs/analyzer/user-docs.rst
@@ -0,0 +1,4 @@
+User Docs
+=
+
+Contents:
Index: clang/docs/ClangStaticAnalyzer.rst
===
--- clang/docs/ClangStaticAnalyzer.rst
+++ clang/docs/ClangStaticAnalyzer.rst
@@ -5,15 +5,16 @@
 The Clang Static Analyzer is a source code analysis tool that finds bugs in C, C++, and Objective-C programs.
 It implements *path-sensitive*, *inter-procedural analysis* based on *symbolic execution* technique.
 
-This is the Static Analyzer documentation page. 
+This is the Static Analyzer documentation page.
 
 See the `Official Tool Page `_.
 
 .. toctree::
:caption: Table of Contents
:numbered:
-   :maxdepth: 2  
- 
+   :maxdepth: 2
+
analyzer/checkers
+   analyzer/user-docs
analyzer/developer-docs
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: NoQ, Szelethus.
aaron.ballman added a subscriber: NoQ.
aaron.ballman added a comment.

I'm worried that this will continue to drift out of sync with the static 
analyzer checks unless we find some way to automate it. I wonder if we could 
write a script to generate these .rst files and somehow fit it into the 
workflow for adding new static analyzer checks to re-run the script to produce 
new files (or modified files) as needed? @NoQ and @Szelethus may have ideas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454



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


[PATCH] D64380: Add 'require_designated_init' and 'required' attribute to clang

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



Comment at: clang/include/clang/Basic/Attr.td:1947
 
+def RequireDesignatedInit : InheritableAttr {
+  let Spellings = [CXX11<"clang", "require_designated_init">];

This should be `RequiresDesignator`.



Comment at: clang/include/clang/Basic/Attr.td:1948
+def RequireDesignatedInit : InheritableAttr {
+  let Spellings = [CXX11<"clang", "require_designated_init">];
+  let Subjects = SubjectList<[Type]>;

I'd prefer this be named `requires_designator`.



Comment at: clang/include/clang/Basic/Attr.td:1949
+  let Spellings = [CXX11<"clang", "require_designated_init">];
+  let Subjects = SubjectList<[Type]>;
+  let Documentation = [RequireDesignatedInitDocs];

I'm a bit confused by this subject -- it's a declaration attribute that 
appertains to types? Why is this not `RecordDecl` instead?



Comment at: clang/include/clang/Basic/Attr.td:1953
+
+def Required : InheritableAttr {
+  let Spellings = [CXX11<"clang", "designated_init_required">];

This should be `RequiresInit`



Comment at: clang/include/clang/Basic/Attr.td:1954
+def Required : InheritableAttr {
+  let Spellings = [CXX11<"clang", "designated_init_required">];
+  let Subjects = SubjectList<[Field]>;

This should also use the `Clang` spelling. Also, I'd prefer this be named 
`requires_init`.

As it stands, these two attribute names are *way* too similar.



Comment at: clang/include/clang/Basic/Attr.td:1948
+def RequireDesignatedInit : InheritableAttr {
+  let Spellings = [GNU<"require_designated_init">];
+  let Subjects = SubjectList<[Type]>;

compnerd wrote:
> This seems like an extension?  I think that we want to explicitly mark this 
> as an extension, as this is not available in GCC AFAIK.
This should use the `Clang` attribute spelling rather than `CXX11`.



Comment at: clang/include/clang/Basic/AttrDocs.td:1448
 
+def RequireDesignatedInitDocs : Documentation {
+  let Category = DocCatType;

The behavior should be documented as to what happens when you apply these 
attributes to unions.



Comment at: clang/include/clang/Basic/AttrDocs.td:1451
+  let Content = [{
+This attribute can be applied to a struct definition to require that anytime a
+variable of that struct's type is declared, the declaration uses designated

anytime -> any time



Comment at: clang/include/clang/Basic/AttrDocs.td:1452
+This attribute can be applied to a struct definition to require that anytime a
+variable of that struct's type is declared, the declaration uses designated
+initializer syntax ([dcl.init.aggr]p3.1).

struct's -> structure's



Comment at: clang/include/clang/Basic/AttrDocs.td:1484
+This attribute can be applied to a field definition within a struct or a class
+to require that anytime a variable of the struct/class's type is declared, that
+field must be initialized using designated initializer syntax 
([dcl.init.aggr]p3.1).

anytime -> any time
struct/class -> struct



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3533-3541
+def err_require_designated_init_failed : Error<
+  "variable declaration does not use designated initializer syntax">;
+def note_declared_required_designated_init_here : Note<
+  "required by 'require_designated_init' attribute here">;
+
+def err_required_failed : Error<
+  "initializer for variable %0 must explicitly initialize field %1">;

I'm a little uncomfortable with these being errors rather than warnings. I 
think of these attributes as being preferences rather than requirements; the 
code isn't *wrong* if it fails to use the designated initializer (it's 
conforming to C or C++, does not have UB, etc) and other implementations are 
free to ignore those attributes and the end result will be identical to what's 
produced by Clang.

What do you think about turning these into warnings? Users can always use 
`-Werror` to strengthen their own requirements.



Comment at: clang/lib/Sema/SemaDecl.cpp:11214
 
+  if (auto *TD = VDecl->getType().getTypePtr()->getAsTagDecl()) {
+// If the type of the declaration is a struct/class and that type has the

Any reason this shouldn't be `const auto *`? (Propagated elsewhere.)



Comment at: clang/lib/Sema/SemaDecl.cpp:11220-11221
+  if (auto *ILE = dyn_cast(Init)) {
+for (unsigned i = 0; i < ILE->getNumInits(); i++) {
+  Expr *init = ILE->getInit(i);
+  if (auto *DIE = dyn_cast(init))

You can use a range-based for loop over `inits()`, I believe. Also, the 
variable should be named `Init` to meet the coding style.



Comment at: clang/lib/Sema/SemaDecl.cpp:11228
+  << 

[PATCH] D64493: [Driver] Don't pass --dynamic-linker to ld on Solaris

2019-07-10 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added reviewers: fedor.sergeev, rsmith, theraven.
Herald added subscribers: jrtc27, jyknight.
Herald added a project: clang.

I noticed that clang currenly passes `--dynamic-linker` to `ld`.  This has been 
the case
since Solaris 11 support was added initially back in 2012 by David Chisnall 
(r150580).
I couldn't find any patch submission, let alone a justification, for this, and 
it seems
completely useless: `--dynamic-linker` is a gld compatibility form of the 
option, the
native option being `-I`.  First of all, however, the dynamic linker passed is 
simply the
default, so there's no reason at all to specify it in the first place.

This patch removes passing the option and adjusts the affected testcase 
accordingly.

Tested on `x86_64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.  Ok for trunk?


Repository:
  rC Clang

https://reviews.llvm.org/D64493

Files:
  lib/Driver/ToolChains/Solaris.cpp
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/ld.so.1
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/sparcv9/ld.so.1
  test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/ld.so.1
  test/Driver/Inputs/solaris_x86_tree/usr/lib/ld.so.1
  test/Driver/solaris-ld.c


Index: test/Driver/solaris-ld.c
===
--- test/Driver/solaris-ld.c
+++ test/Driver/solaris-ld.c
@@ -11,7 +11,6 @@
 // CHECK-LD-SPARC32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" 
"sparc-sun-solaris2.11"
 // CHECK-LD-SPARC32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD-SPARC32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LD-SPARC32-SAME: "--dynamic-linker" 
"[[SYSROOT]]/usr/lib{{/|}}ld.so.1"
 // CHECK-LD-SPARC32-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crt1.o"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD-SPARC32-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtbegin.o"
@@ -35,7 +34,6 @@
 // CHECK-LD-SPARC64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" 
"sparcv9-sun-solaris2.11"
 // CHECK-LD-SPARC64-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD-SPARC64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LD-SPARC64-SAME: "--dynamic-linker" 
"[[SYSROOT]]/usr/lib/sparcv9{{/|}}ld.so.1"
 // CHECK-LD-SPARC64-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crt1.o"
 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/lib/sparcv9{{/|}}crti.o"
 // CHECK-LD-SPARC64-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crtbegin.o"
@@ -59,7 +57,6 @@
 // CHECK-LD-X32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "i386-pc-solaris2.11"
 // CHECK-LD-X32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD-X32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LD-X32-SAME: "--dynamic-linker" "[[SYSROOT]]/usr/lib{{/|}}ld.so.1"
 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crt1.o"
 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD-X32-SAME: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|}}crtbegin.o"
@@ -83,7 +80,6 @@
 // CHECK-LD-X64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" 
"x86_64-pc-solaris2.11"
 // CHECK-LD-X64-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD-X64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LD-X64-SAME: "--dynamic-linker" 
"[[SYSROOT]]/usr/lib/amd64{{/|}}ld.so.1"
 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|}}crt1.o"
 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|}}crti.o"
 // CHECK-LD-X64-SAME: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|}}crtbegin.o"
Index: lib/Driver/ToolChains/Solaris.cpp
===
--- lib/Driver/ToolChains/Solaris.cpp
+++ lib/Driver/ToolChains/Solaris.cpp
@@ -65,10 +65,6 @@
 CmdArgs.push_back("-Bdynamic");
 if (Args.hasArg(options::OPT_shared)) {
   CmdArgs.push_back("-shared");
-} else {
-  CmdArgs.push_back("--dynamic-linker");
-  CmdArgs.push_back(
-  Args.MakeArgString(getToolChain().GetFilePath("ld.so.1")));
 }
 
 // libpthread has been folded into libc since Solaris 10, no need to do


Index: test/Driver/solaris-ld.c
===
--- test/Driver/solaris-ld.c
+++ test/Driver/solaris-ld.c
@@ -11,7 +11,6 @@
 // CHECK-LD-SPARC32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "sparc-sun-solaris2.11"
 // CHECK-LD-SPARC32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD-SPARC32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LD-SPARC32-SAME: "--dynamic-linker" "[[SYSROOT]]/usr/lib{{/|}}ld.so.1"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crt1.o"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtbegin.o"
@@ -35,7 +34,6 @@
 // CHECK-LD-SPARC64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "sparcv9-sun-solaris2.11"
 // 

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

2019-07-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365634: [clangd] Filter out non-governed files from 
broadcast (authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64247?vs=208890=208957#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64247

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

Index: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
===
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
@@ -40,9 +40,13 @@
   virtual ~GlobalCompilationDatabase() = default;
 
   /// If there are any known-good commands for building this file, returns one.
-  /// If the ProjectInfo pointer is set, it will also be populated.
   virtual llvm::Optional
-  getCompileCommand(PathRef File, ProjectInfo * = nullptr) const = 0;
+  getCompileCommand(PathRef File) const = 0;
+
+  /// Finds the closest project to \p File.
+  virtual llvm::Optional getProjectInfo(PathRef File) const {
+return llvm::None;
+  }
 
   /// Makes a guess at how to build a file.
   /// The default implementation just runs clang on the file.
@@ -71,20 +75,40 @@
 
   /// Scans File's parents looking for compilation databases.
   /// Any extra flags will be added.
+  /// Might trigger OnCommandChanged, if CDB wasn't broadcasted yet.
   llvm::Optional
-  getCompileCommand(PathRef File, ProjectInfo * = nullptr) const override;
+  getCompileCommand(PathRef File) const override;
+
+  /// Returns the path to first directory containing a compilation database in
+  /// \p File's parents.
+  llvm::Optional getProjectInfo(PathRef File) const override;
 
 private:
-  tooling::CompilationDatabase *getCDBForFile(PathRef File,
-  ProjectInfo *) const;
-  std::pair
+  std::pair
   getCDBInDirLocked(PathRef File) const;
 
+  struct CDBLookupRequest {
+PathRef FileName;
+// Whether this lookup should trigger discovery of the CDB found.
+bool ShouldBroadcast = false;
+  };
+  struct CDBLookupResult {
+tooling::CompilationDatabase *CDB = nullptr;
+ProjectInfo PI;
+  };
+  llvm::Optional lookupCDB(CDBLookupRequest Request) const;
+
+  // Performs broadcast on governed files.
+  void broadcastCDB(CDBLookupResult Res) const;
+
   mutable std::mutex Mutex;
   /// Caches compilation databases loaded from directories(keys are
   /// directories).
-  mutable llvm::StringMap>
-  CompilationDatabases;
+  struct CachedCDB {
+std::unique_ptr CDB = nullptr;
+bool SentBroadcast = false;
+  };
+  mutable llvm::StringMap CompilationDatabases;
 
   /// Used for command argument pointing to folder where compile_commands.json
   /// is located.
@@ -109,8 +133,9 @@
  llvm::Optional ResourceDir = llvm::None);
 
   llvm::Optional
-  getCompileCommand(PathRef File, ProjectInfo * = nullptr) const override;
+  getCompileCommand(PathRef File) const override;
   tooling::CompileCommand getFallbackCommand(PathRef File) const override;
+  llvm::Optional getProjectInfo(PathRef File) const override;
 
   /// Sets or clears the compilation command for a particular file.
   void
Index: clang-tools-extra/trunk/clangd/unittests/TestFS.h
===
--- clang-tools-extra/trunk/clangd/unittests/TestFS.h
+++ clang-tools-extra/trunk/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/trunk/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/trunk/clangd/unittests/ClangdTests.cpp
+++ 

[clang-tools-extra] r365634 - [clangd] Filter out non-governed files from broadcast

2019-07-10 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Wed Jul 10 07:11:46 2019
New Revision: 365634

URL: http://llvm.org/viewvc/llvm-project?rev=365634=rev
Log:
[clangd] Filter out non-governed files from broadcast

Summary:
This also turns off implicit discovery of additional compilation
databases.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=365634=365633=365634=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Jul 10 
07:11:46 2019
@@ -8,12 +8,18 @@
 
 #include "GlobalCompilationDatabase.h"
 #include "Logger.h"
+#include "Path.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include 
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -43,6 +49,16 @@ std::string getStandardResourceDir() {
   return CompilerInvocation::GetResourcesPath("clangd", (void *));
 }
 
+// Runs the given action on all parent directories of filename, starting from
+// deepest directory and going up to root. Stops whenever action succeeds.
+void actOnAllParentDirectories(PathRef FileName,
+   llvm::function_ref Action) {
+  for (auto Path = llvm::sys::path::parent_path(FileName);
+   !Path.empty() && !Action(Path);
+   Path = llvm::sys::path::parent_path(Path))
+;
+}
+
 } // namespace
 
 static std::string getFallbackClangPath() {
@@ -81,60 +97,138 @@ DirectoryBasedGlobalCompilationDatabase:
 ~DirectoryBasedGlobalCompilationDatabase() = default;
 
 llvm::Optional
-DirectoryBasedGlobalCompilationDatabase::getCompileCommand(
-PathRef File, ProjectInfo *Project) const {
-  if (auto CDB = getCDBForFile(File, Project)) {
-auto Candidates = CDB->getCompileCommands(File);
-if (!Candidates.empty()) {
-  return std::move(Candidates.front());
-}
-  } else {
+DirectoryBasedGlobalCompilationDatabase::getCompileCommand(PathRef File) const 
{
+  CDBLookupRequest Req;
+  Req.FileName = File;
+  Req.ShouldBroadcast = true;
+
+  auto Res = lookupCDB(Req);
+  if (!Res) {
 log("Failed to find compilation database for {0}", File);
+return llvm::None;
   }
+
+  auto Candidates = Res->CDB->getCompileCommands(File);
+  if (!Candidates.empty())
+return std::move(Candidates.front());
+
   return None;
 }
 
-std::pair
+std::pair
 DirectoryBasedGlobalCompilationDatabase::getCDBInDirLocked(PathRef Dir) const {
   // FIXME(ibiryukov): Invalidate cached compilation databases on changes
   auto CachedIt = CompilationDatabases.find(Dir);
   if (CachedIt != CompilationDatabases.end())
-return {CachedIt->second.get(), true};
+return {CachedIt->second.CDB.get(), CachedIt->second.SentBroadcast};
   std::string Error = "";
-  auto CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
-  auto Result = CDB.get();
-  CompilationDatabases.insert(std::make_pair(Dir, std::move(CDB)));
+
+  CachedCDB Entry;
+  Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
+  auto Result = Entry.CDB.get();
+  CompilationDatabases[Dir] = std::move(Entry);
+
   return {Result, false};
 }
 
-tooling::CompilationDatabase *
-DirectoryBasedGlobalCompilationDatabase::getCDBForFile(
-PathRef File, ProjectInfo *Project) const {
-  namespace path = llvm::sys::path;
-  assert((path::is_absolute(File, path::Style::posix) ||
-  path::is_absolute(File, path::Style::windows)) &&
+llvm::Optional
+DirectoryBasedGlobalCompilationDatabase::lookupCDB(
+CDBLookupRequest Request) const {
+  assert(llvm::sys::path::is_absolute(Request.FileName) &&
  "path must be absolute");
 
-  tooling::CompilationDatabase *CDB = nullptr;
-  bool Cached = false;
-  std::lock_guard Lock(Mutex);
+  CDBLookupResult Result;
+  bool SentBroadcast = false;
+
+  {
+std::lock_guard Lock(Mutex);
+if (CompileCommandsDir) {
+  std::tie(Result.CDB, SentBroadcast) =
+  

[PATCH] D64492: [clangd] Added highlightings for namespace specifiers.

2019-07-10 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom created this revision.
jvikstrom added reviewers: hokein, sammccall, ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Added highlightings for namespace specifiers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64492

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
@@ -36,7 +36,8 @@
   {HighlightingKind::Variable, "Variable"},
   {HighlightingKind::Function, "Function"},
   {HighlightingKind::Class, "Class"},
-  {HighlightingKind::Enum, "Enum"}};
+  {HighlightingKind::Enum, "Enum"},
+  {HighlightingKind::Namespace, "Namespace"}};
   std::vector ExpectedTokens;
   for (const auto  : KindToString) {
 std::vector Toks = makeHighlightingTokens(
@@ -75,18 +76,18 @@
   };
 )cpp",
 R"cpp(
-  namespace abc {
+  namespace $Namespace[[abc]] {
 template
 struct $Class[[A]] {
   T t;
 };
   }
   template
-  struct $Class[[C]] : abc::A {
+  struct $Class[[C]] : $Namespace[[abc]]::A {
 typename T::A* D;
   };
-  abc::$Class[[A]] $Variable[[AA]];
-  typedef abc::$Class[[A]] AAA;
+  $Namespace[[abc]]::$Class[[A]] $Variable[[AA]];
+  typedef $Namespace[[abc]]::$Class[[A]] AAA;
   struct $Class[[B]] {
 $Class[[B]]();
 ~$Class[[B]]();
@@ -108,6 +109,26 @@
 $Enum[[E]] EEE;
 $Enum[[EE]] ;
   };
+)cpp",
+R"cpp(
+  namespace $Namespace[[abc]] {
+namespace $Namespace[[bcd]] {
+  struct $Class[[A]] {};
+  namespace $Namespace[[cde]] {
+struct $Class[[A]] {
+  static enum class $Enum[[B]] {
+Hi,
+  };
+};
+  }
+}
+  }
+  using namespace $Namespace[[abc]]::$Namespace[[bcd]];
+  namespace $Namespace[[vwz]] =
+$Namespace[[abc]]::$Namespace[[bcd]]::$Namespace[[cde]];
+  $Namespace[[abc]]::$Namespace[[bcd]]::$Class[[A]] $Variable[[AA]];
+  $Namespace[[vwz]]::$Class[[A]]::$Enum[[B]] $Variable[[AAA]] =
+$Namespace[[vwz]]::$Class[[A]]::$Enum[[B]]::Hi;
 )cpp"};
   for (const auto  : TestCases) {
 checkHighlightings(TestCase);
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
@@ -9,12 +9,15 @@
 # CHECK-NEXT:  ],
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
-# CHECK-NEXT:  ]
+# 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:"entity.name.type.namespace.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
@@ -28,6 +28,7 @@
   Function,
   Class,
   Enum,
+  Namespace,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -11,8 +11,6 @@
 #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 {
@@ -37,6 +35,13 @@
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
+// UsingDirectiveDecl's namespaces do not show up anywhere else in the
+// Visit/Traverse mehods. But they should also be highlighted as a
+// namespace.
+if (const auto UD = dyn_cast(ND)) {
+  addToken(UD->getIdentLocation(), HighlightingKind::Namespace);
+}
+
 // Constructors' TypeLoc has a TypePtr that is a FunctionProtoType. It has
 // no tag decl and therefore constructors must be gotten as NamedDecls
 // instead.
@@ -76,6 +81,16 @@
 return true;
   }
 
+  bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNSLoc) {
+if (NestedNameSpecifier *NNS = 

[PATCH] D64491: [Driver] Enable __cxa_atexit on Solaris

2019-07-10 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added reviewers: fedor.sergeev, rsmith.
Herald added subscribers: dexonsmith, mehdi_amini, jyknight.
Herald added a project: clang.

Starting with Solaris 11.4 (which is now the required minimal version), Solaris 
does
support `__cxa_atexit`.  This patch reflects that.

One might consider removing the affected tests altogether instead of inverting 
them,
as is done on other targets.

Besides, this lets two ASan tests PASS:

  AddressSanitizer-i386-sunos :: TestCases/init-order-atexit.cc
  AddressSanitizer-i386-sunos-dynamic :: TestCases/init-order-atexit.cc

Tested on `x86_64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.  Ok for trunk?


Repository:
  rC Clang

https://reviews.llvm.org/D64491

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cxa-atexit.cpp
  test/Driver/solaris-opts.c


Index: test/Driver/solaris-opts.c
===
--- test/Driver/solaris-opts.c
+++ test/Driver/solaris-opts.c
@@ -1,4 +1,4 @@
 // RUN: %clang %s --target=sparc-sun-solaris2.11 -### -o %t.o 2>&1 | FileCheck 
%s
 
-// CHECK: "-fno-use-cxa-atexit"
+// CHECK-NOT: "-fno-use-cxa-atexit"
 
Index: test/Driver/cxa-atexit.cpp
===
--- test/Driver/cxa-atexit.cpp
+++ test/Driver/cxa-atexit.cpp
@@ -19,7 +19,7 @@
 // RUN: %clang -### -target sparc-sun-solaris -c %s -o /dev/null 2>&1 | 
FileCheck %s -check-prefix CHECK-SOLARIS
 
 // CHECK-WINDOWS: "-fno-use-cxa-atexit"
-// CHECK-SOLARIS: "-fno-use-cxa-atexit"
+// CHECK-SOLARIS-NOT: "-fno-use-cxa-atexit"
 // CHECK-HEXAGON-NOT: "-fno-use-cxa-atexit"
 // CHECK-XCORE: "-fno-use-cxa-atexit"
 // CHECK-MTI: "-fno-use-cxa-atexit"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4750,7 +4750,6 @@
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSWindows() &&
-  RawTriple.getOS() != llvm::Triple::Solaris &&
   TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||


Index: test/Driver/solaris-opts.c
===
--- test/Driver/solaris-opts.c
+++ test/Driver/solaris-opts.c
@@ -1,4 +1,4 @@
 // RUN: %clang %s --target=sparc-sun-solaris2.11 -### -o %t.o 2>&1 | FileCheck %s
 
-// CHECK: "-fno-use-cxa-atexit"
+// CHECK-NOT: "-fno-use-cxa-atexit"
 
Index: test/Driver/cxa-atexit.cpp
===
--- test/Driver/cxa-atexit.cpp
+++ test/Driver/cxa-atexit.cpp
@@ -19,7 +19,7 @@
 // RUN: %clang -### -target sparc-sun-solaris -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-SOLARIS
 
 // CHECK-WINDOWS: "-fno-use-cxa-atexit"
-// CHECK-SOLARIS: "-fno-use-cxa-atexit"
+// CHECK-SOLARIS-NOT: "-fno-use-cxa-atexit"
 // CHECK-HEXAGON-NOT: "-fno-use-cxa-atexit"
 // CHECK-XCORE: "-fno-use-cxa-atexit"
 // CHECK-MTI: "-fno-use-cxa-atexit"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4750,7 +4750,6 @@
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSWindows() &&
-  RawTriple.getOS() != llvm::Triple::Solaris &&
   TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64489: [clangd][QueryDriver] Use language from underlying database if possible

2019-07-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64489

Files:
  clang-tools-extra/clangd/QueryDriverDatabase.cpp


Index: clang-tools-extra/clangd/QueryDriverDatabase.cpp
===
--- clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -83,11 +83,11 @@
 }
 
 std::vector extractSystemIncludes(PathRef Driver,
-   llvm::StringRef Ext,
+   llvm::StringRef Lang,
llvm::Regex ) {
   trace::Span Tracer("Extract system includes");
   SPAN_ATTACH(Tracer, "driver", Driver);
-  SPAN_ATTACH(Tracer, "ext", Ext);
+  SPAN_ATTACH(Tracer, "lang", Lang);
 
   if (!QueryDriverRegex.match(Driver)) {
 vlog("System include extraction: not whitelisted driver {0}", Driver);
@@ -117,14 +117,8 @@
   llvm::Optional Redirects[] = {
   {""}, {""}, llvm::StringRef(StdErrPath)};
 
-  auto Type = driver::types::lookupTypeForExtension(Ext);
-  if (Type == driver::types::TY_INVALID) {
-elog("System include extraction: invalid file type for {0}", Ext);
-return {};
-  }
   // Should we also preserve flags like "-sysroot", "-nostdinc" ?
-  const llvm::StringRef Args[] = {
-  Driver, "-E", "-x", driver::types::getTypeName(Type), "-", "-v"};
+  const llvm::StringRef Args[] = {Driver, "-E", "-x", Lang, "-", "-v"};
 
   if (int RC = llvm::sys::ExecuteAndWait(Driver, Args, /*Env=*/llvm::None,
  Redirects)) {
@@ -220,10 +214,27 @@
 if (!Cmd || Cmd->CommandLine.empty())
   return Cmd;
 
+llvm::StringRef Lang;
+for (size_t I = 0, E = Cmd->CommandLine.size(); I < E; ++I) {
+  llvm::StringRef Arg = Cmd->CommandLine[I];
+  if (Arg == "-x" && I + 1 < E)
+Lang = Cmd->CommandLine[I + 1];
+  else if (Arg.startswith("-x"))
+Lang = Arg.drop_front(2).trim();
+}
+if (Lang.empty()) {
+  llvm::StringRef Ext = llvm::sys::path::extension(File).trim('.');
+  auto Type = driver::types::lookupTypeForExtension(Ext);
+  if (Type == driver::types::TY_INVALID) {
+elog("System include extraction: invalid file type for {0}", Ext);
+return {};
+  }
+  Lang = driver::types::getTypeName(Type);
+}
+
 llvm::SmallString<128> Driver(Cmd->CommandLine.front());
 llvm::sys::fs::make_absolute(Cmd->Directory, Driver);
-llvm::StringRef Ext = llvm::sys::path::extension(File).trim('.');
-auto Key = std::make_pair(Driver.str(), Ext);
+auto Key = std::make_pair(Driver.str(), Lang);
 
 std::vector SystemIncludes;
 {


Index: clang-tools-extra/clangd/QueryDriverDatabase.cpp
===
--- clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -83,11 +83,11 @@
 }
 
 std::vector extractSystemIncludes(PathRef Driver,
-   llvm::StringRef Ext,
+   llvm::StringRef Lang,
llvm::Regex ) {
   trace::Span Tracer("Extract system includes");
   SPAN_ATTACH(Tracer, "driver", Driver);
-  SPAN_ATTACH(Tracer, "ext", Ext);
+  SPAN_ATTACH(Tracer, "lang", Lang);
 
   if (!QueryDriverRegex.match(Driver)) {
 vlog("System include extraction: not whitelisted driver {0}", Driver);
@@ -117,14 +117,8 @@
   llvm::Optional Redirects[] = {
   {""}, {""}, llvm::StringRef(StdErrPath)};
 
-  auto Type = driver::types::lookupTypeForExtension(Ext);
-  if (Type == driver::types::TY_INVALID) {
-elog("System include extraction: invalid file type for {0}", Ext);
-return {};
-  }
   // Should we also preserve flags like "-sysroot", "-nostdinc" ?
-  const llvm::StringRef Args[] = {
-  Driver, "-E", "-x", driver::types::getTypeName(Type), "-", "-v"};
+  const llvm::StringRef Args[] = {Driver, "-E", "-x", Lang, "-", "-v"};
 
   if (int RC = llvm::sys::ExecuteAndWait(Driver, Args, /*Env=*/llvm::None,
  Redirects)) {
@@ -220,10 +214,27 @@
 if (!Cmd || Cmd->CommandLine.empty())
   return Cmd;
 
+llvm::StringRef Lang;
+for (size_t I = 0, E = Cmd->CommandLine.size(); I < E; ++I) {
+  llvm::StringRef Arg = Cmd->CommandLine[I];
+  if (Arg == "-x" && I + 1 < E)
+Lang = Cmd->CommandLine[I + 1];
+  else if (Arg.startswith("-x"))
+Lang = Arg.drop_front(2).trim();
+}
+if (Lang.empty()) {
+  llvm::StringRef Ext = llvm::sys::path::extension(File).trim('.');
+  auto Type = driver::types::lookupTypeForExtension(Ext);
+  if (Type == driver::types::TY_INVALID) {
+

[PATCH] D64482: [Driver] Define _FILE_OFFSET_BITS=64 on Solaris

2019-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> There's one caveat: gcc defines _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE for 
> C++ only, while clang has long been doing it for all languages

Can you explain more about the hack 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0f97ccfdccc033f543ccbcb220697e62e84bf01f


Repository:
  rC Clang

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

https://reviews.llvm.org/D64482



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


[PATCH] D64488: [Driver] Support -fsanitize=function on Solaris/x86

2019-07-10 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added a reviewer: kcc.
ro added a project: Sanitizers.
Herald added a subscriber: fedor.sergeev.
Herald added a project: clang.

`UBSan-Standalone-x86_64 :: TestCases/TypeCheck/Function/function.cpp` currently
FAILs on Solaris/x86_64:

  clang-9: error: unsupported option '-fsanitize=function' for target 
'x86_64-pc-solaris2.11'

AFAICS, there's nothing more to do then enable that sanitizer in the driver 
(for x86 only),
which is what this patch does, together with updating another testcase.

Tested on `x86_64-pc-solaris2.11`.  Ok for trunk?


Repository:
  rC Clang

https://reviews.llvm.org/D64488

Files:
  lib/Driver/ToolChains/Solaris.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -717,6 +717,9 @@
 // RUN: %clang -target x86_64--netbsd -fsanitize=scudo %s -### 2>&1 | 
FileCheck %s -check-prefix=SCUDO-NETBSD
 // SCUDO-NETBSD: "-fsanitize=scudo"
 
+// RUN: %clang -target x86_64--solaris -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-SOLARIS
+// RUN: %clang -target x86_64--solaris -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-SOLARIS
+// FUNCTION-SOLARIS: "-fsanitize=function"
 
 
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function 
-fsanitize=undefined %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-FSAN-UBSAN-PS4
Index: lib/Driver/ToolChains/Solaris.cpp
===
--- lib/Driver/ToolChains/Solaris.cpp
+++ lib/Driver/ToolChains/Solaris.cpp
@@ -181,6 +181,7 @@
 
 SanitizerMask Solaris::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
+  const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
   const bool IsSparc = getTriple().getArch() == llvm::Triple::sparc;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   // FIXME: Omit X86_64 and SPARCv9 until 64-bit support is figured out.
@@ -189,6 +190,8 @@
 Res |= SanitizerKind::PointerCompare;
 Res |= SanitizerKind::PointerSubtract;
   }
+  if (IsX86 || IsX86_64)
+Res |= SanitizerKind::Function;
   Res |= SanitizerKind::Vptr;
   return Res;
 }


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -717,6 +717,9 @@
 // RUN: %clang -target x86_64--netbsd -fsanitize=scudo %s -### 2>&1 | FileCheck %s -check-prefix=SCUDO-NETBSD
 // SCUDO-NETBSD: "-fsanitize=scudo"
 
+// RUN: %clang -target x86_64--solaris -fsanitize=function %s -### 2>&1 | FileCheck %s -check-prefix=FUNCTION-SOLARIS
+// RUN: %clang -target x86_64--solaris -fsanitize=function %s -### 2>&1 | FileCheck %s -check-prefix=FUNCTION-SOLARIS
+// FUNCTION-SOLARIS: "-fsanitize=function"
 
 
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-FSAN-UBSAN-PS4
Index: lib/Driver/ToolChains/Solaris.cpp
===
--- lib/Driver/ToolChains/Solaris.cpp
+++ lib/Driver/ToolChains/Solaris.cpp
@@ -181,6 +181,7 @@
 
 SanitizerMask Solaris::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
+  const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
   const bool IsSparc = getTriple().getArch() == llvm::Triple::sparc;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   // FIXME: Omit X86_64 and SPARCv9 until 64-bit support is figured out.
@@ -189,6 +190,8 @@
 Res |= SanitizerKind::PointerCompare;
 Res |= SanitizerKind::PointerSubtract;
   }
+  if (IsX86 || IsX86_64)
+Res |= SanitizerKind::Function;
   Res |= SanitizerKind::Vptr;
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


<    1   2   3   >