[PATCH] D40381: Parse concept definition

2017-12-21 Thread changyu via Phabricator via cfe-commits
changyu marked 6 inline comments as done.
changyu added inline comments.



Comment at: lib/Sema/SemaTemplate.cpp:7735
+  ActOnDocumentableDecl(NewDecl);
+  CurContext->addDecl(NewDecl);
+  return NewDecl;

faisalv wrote:
> Why not use 'PushOnScopeChains' onto the enclosing scope?
> Something along these lines:
>assert(S->isTemplateParamScope() && S->getParent() && 
> !S->getParent()->isTemplateParamScope() && "...");
>PushOnScopeChains(NewDecl, S->getParent(),/*AddToContext*/true);
The condition
```
S->isTemplateParamScope()
```
fails in this case
```
template concept D1 = true; // expected-error {{expected template 
parameter}}
```

`ParseTemplateDeclarationOrSpecialization` calls `ParseTemplateParameters` 
which eventually calls `ParseNonTypeTemplateParameter`. 
`ParseNonTypeTemplateParameter` prints the diag and fails but does not cause 
`ParseTemplateParameters` to fail (I'm not sure why).  
`ParseTemplateDeclarationOrSpecialization` proceeds to parse the concept 
definition, and we get this

```
/home/changyu/test.cpp:1:10: error: expected template parameter
template concept D1 = true; // expected-error {{expected template 
parameter}}
 ^
clang: /home/changyu/git/llvm/tools/clang/lib/Sema/SemaTemplate.cpp:7747: 
clang::Decl* clang::Sema::ActOnConceptDefinition(clang::Scope*, 
clang::MultiTemplateParamsArg, clang::IdentifierInfo*, clang::SourceLocation, 
clang::Expr*): Assertion `S->isTemplateParamScope() && "Not in template param 
scope?"' failed.
```

What should we do?


https://reviews.llvm.org/D40381



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


[PATCH] D40478: Added control flow architecture protection Flag

2017-12-21 Thread Oren Ben Simhon via Phabricator via cfe-commits
oren_ben_simhon added a comment.

ping


Repository:
  rL LLVM

https://reviews.llvm.org/D40478



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


r321250 - [CodeGen] Fix access sizes in new-format TBAA tags

2017-12-21 Thread Ivan A. Kosarev via cfe-commits
Author: kosarev
Date: Thu Dec 21 00:14:16 2017
New Revision: 321250

URL: http://llvm.org/viewvc/llvm-project?rev=321250&view=rev
Log:
[CodeGen] Fix access sizes in new-format TBAA tags

The new format requires to specify both the type of the access
and its size. This patch fixes setting access sizes for TBAA tags
that denote accesses to structure members. This fix affects all
future TBAA metadata tests for the new format, so I guess we
don't need any special tests for this fix.

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

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

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=321250&r1=321249&r2=321250&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Dec 21 00:14:16 2017
@@ -3801,8 +3801,10 @@ LValue CodeGenFunction::EmitLValueForFie
   FieldTBAAInfo.Offset +=
   Layout.getFieldOffset(field->getFieldIndex()) / CharWidth;
 
-// Update the final access type.
+// Update the final access type and size.
 FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType);
+FieldTBAAInfo.Size =
+getContext().getTypeSizeInChars(FieldType).getQuantity();
   }
 
   Address addr = base.getAddress();


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


[PATCH] D41452: [CodeGen] Fix access sizes in new-format TBAA tags

2017-12-21 Thread Ivan Kosarev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321250: [CodeGen] Fix access sizes in new-format TBAA tags 
(authored by kosarev, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41452?vs=127724&id=127834#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41452

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


Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -3801,8 +3801,10 @@
   FieldTBAAInfo.Offset +=
   Layout.getFieldOffset(field->getFieldIndex()) / CharWidth;
 
-// Update the final access type.
+// Update the final access type and size.
 FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType);
+FieldTBAAInfo.Size =
+getContext().getTypeSizeInChars(FieldType).getQuantity();
   }
 
   Address addr = base.getAddress();


Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -3801,8 +3801,10 @@
   FieldTBAAInfo.Offset +=
   Layout.getFieldOffset(field->getFieldIndex()) / CharWidth;
 
-// Update the final access type.
+// Update the final access type and size.
 FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType);
+FieldTBAAInfo.Size =
+getContext().getTypeSizeInChars(FieldType).getQuantity();
   }
 
   Address addr = base.getAddress();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41363: [clang-tidy] Adding Fuchsia checker for overloaded operators

2017-12-21 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added inline comments.



Comment at: docs/clang-tidy/checks/fuchsia-overloaded-operator.rst:17
+
+See the features disallowed in Fuchsia at 
https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md

juliehockett wrote:
> JonasToth wrote:
> > Could you make the link clickable? 
> Doesn't rST parse standalone links this into hyperlinks without additional 
> markup?
I am not sure but probably. It's ok then.


https://reviews.llvm.org/D41363



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


[PATCH] D41394: [CodeGen] Support generation of TBAA info in the new format

2017-12-21 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev updated this revision to Diff 127838.
kosarev added a comment.

Updated as suggested.


https://reviews.llvm.org/D41394

Files:
  lib/CodeGen/CodeGenTBAA.cpp
  test/CodeGen/tbaa.cpp

Index: test/CodeGen/tbaa.cpp
===
--- test/CodeGen/tbaa.cpp
+++ test/CodeGen/tbaa.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -no-struct-path-tbaa -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefix=PATH
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefixes=PATH,OLD-PATH
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -new-struct-path-tbaa -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefixes=PATH,NEW-PATH
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O0 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-TBAA
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -relaxed-aliasing -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -check-prefix=NO-TBAA
 // Test TBAA metadata generated by front-end.
@@ -248,29 +249,57 @@
 // CHECK: [[TYPE_i16]] = !{!"short", [[TYPE_char]],
 // CHECK: [[TAG_char]] = !{[[TYPE_char]], [[TYPE_char]], i64 0}
 
-// PATH: [[TYPE_CHAR:!.*]] = !{!"omnipotent char", !
-// PATH: [[TAG_i32]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
-// PATH: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]
-// PATH: [[TAG_A_f32]] = !{[[TYPE_A:!.*]], [[TYPE_INT]], i64 4}
-// PATH: [[TYPE_A]] = !{!"_ZTS7StructA", [[TYPE_SHORT:!.*]], i64 0, [[TYPE_INT]], i64 4, [[TYPE_SHORT]], i64 8, [[TYPE_INT]], i64 12}
-// PATH: [[TYPE_SHORT:!.*]] = !{!"short", [[TYPE_CHAR]]
-// PATH: [[TAG_A_f16]] = !{[[TYPE_A]], [[TYPE_SHORT]], i64 0}
-// PATH: [[TAG_B_a_f32]] = !{[[TYPE_B:!.*]], [[TYPE_INT]], i64 8}
-// PATH: [[TYPE_B]] = !{!"_ZTS7StructB", [[TYPE_SHORT]], i64 0, [[TYPE_A]], i64 4, [[TYPE_INT]], i64 20}
-// PATH: [[TAG_B_a_f16]] = !{[[TYPE_B]], [[TYPE_SHORT]], i64 4}
-// PATH: [[TAG_B_f32]] = !{[[TYPE_B]], [[TYPE_INT]], i64 20}
-// PATH: [[TAG_B_a_f32_2]] = !{[[TYPE_B]], [[TYPE_INT]], i64 16}
-// PATH: [[TAG_S_f32]] = !{[[TYPE_S:!.*]], [[TYPE_INT]], i64 4}
-// PATH: [[TYPE_S]] = !{!"_ZTS7StructS", [[TYPE_SHORT]], i64 0, [[TYPE_INT]], i64 4}
-// PATH: [[TAG_S_f16]] = !{[[TYPE_S]], [[TYPE_SHORT]], i64 0}
-// PATH: [[TAG_S2_f32]] = !{[[TYPE_S2:!.*]], [[TYPE_INT]], i64 4}
-// PATH: [[TYPE_S2]] = !{!"_ZTS8StructS2", [[TYPE_SHORT]], i64 0, [[TYPE_INT]], i64 4}
-// PATH: [[TAG_S2_f16]] = !{[[TYPE_S2]], [[TYPE_SHORT]], i64 0}
-// PATH: [[TAG_C_b_a_f32]] = !{[[TYPE_C:!.*]], [[TYPE_INT]], i64 12}
-// PATH: [[TYPE_C]] = !{!"_ZTS7StructC", [[TYPE_SHORT]], i64 0, [[TYPE_B]], i64 4, [[TYPE_INT]], i64 28}
-// PATH: [[TAG_D_b_a_f32]] = !{[[TYPE_D:!.*]], [[TYPE_INT]], i64 12}
-// PATH: [[TYPE_D]] = !{!"_ZTS7StructD", [[TYPE_SHORT]], i64 0, [[TYPE_B]], i64 4, [[TYPE_INT]], i64 28, [[TYPE_CHAR]], i64 32}
-// PATH: [[TAG_five_b]] = !{[[TYPE_five:!.*]], [[TYPE_CHAR]], i64 1}
-// PATH: [[TYPE_five]] = !{!"_ZTS4five", [[TYPE_CHAR]], i64 0, [[TYPE_INT]], i64 1, [[TYPE_CHAR]], i64 1, [[TYPE_CHAR]], i64 2}
-// PATH: [[TAG_six_b]] = !{[[TYPE_six:!.*]], [[TYPE_CHAR]], i64 4}
-// PATH: [[TYPE_six]] = !{!"_ZTS3six", [[TYPE_CHAR]], i64 0, [[TYPE_INT]], i64 4, [[TYPE_CHAR]], i64 4, [[TYPE_CHAR]], i64 5}
+// OLD-PATH: [[TYPE_CHAR:!.*]] = !{!"omnipotent char", !
+// OLD-PATH: [[TAG_i32]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
+// OLD-PATH: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]
+// OLD-PATH: [[TAG_A_f32]] = !{[[TYPE_A:!.*]], [[TYPE_INT]], i64 4}
+// OLD-PATH: [[TYPE_A]] = !{!"_ZTS7StructA", [[TYPE_SHORT:!.*]], i64 0, [[TYPE_INT]], i64 4, [[TYPE_SHORT]], i64 8, [[TYPE_INT]], i64 12}
+// OLD-PATH: [[TYPE_SHORT:!.*]] = !{!"short", [[TYPE_CHAR]]
+// OLD-PATH: [[TAG_A_f16]] = !{[[TYPE_A]], [[TYPE_SHORT]], i64 0}
+// OLD-PATH: [[TAG_B_a_f32]] = !{[[TYPE_B:!.*]], [[TYPE_INT]], i64 8}
+// OLD-PATH: [[TYPE_B]] = !{!"_ZTS7StructB", [[TYPE_SHORT]], i64 0, [[TYPE_A]], i64 4, [[TYPE_INT]], i64 20}
+// OLD-PATH: [[TAG_B_a_f16]] = !{[[TYPE_B]], [[TYPE_SHORT]], i64 4}
+// OLD-PATH: [[TAG_B_f32]] = !{[[TYPE_B]], [[TYPE_INT]], i64 20}
+// OLD-PATH: [[TAG_B_a_f32_2]] = !{[[TYPE_B]], [[TYPE_INT]], i64 16}
+// OLD-PATH: [[TAG_S_f32]] = !{[[TYPE_S:!.*]], [[TYPE_INT]], i64 4}
+// OLD-PATH: [[TYPE_S]] = !{!"_ZTS7StructS", [[TYPE_SHORT]], i64 0, [[TYPE_INT]], i64 4}
+// OLD-PATH: [[TAG_S_f16]] = !{[[TYPE_S]], [[TYPE_SHORT]], i64 0}
+// OLD-PATH: [[TAG_S2_f32]] = !{[[TYPE_S2:!.*]], [[TYPE_INT]], i64 4}
+// OLD-PATH: [[TYPE_S2]] = !{!"_ZTS8StructS2", [[TYPE_SHORT]], i64 0, [[TYPE_INT]], i64 4}
+// OLD-PATH: [[TAG_S2_f16]] = !{[[TYPE_S2]], [[TYPE_SHORT]], i64 0}
+// OLD-PATH: [[TAG_C_b_a_f32]] = !{[[TYPE_C:!.*]], [[TYPE_INT]], i64 12}
+// OLD-PATH: [[TYPE_C]] = !{!"_ZTS7StructC", [[TYPE_SHORT]], i64 0, [[TYPE_B]], i64 4, [[TYPE_INT]], i64 28}
+// OLD-PATH: [[TAG_D_b_a_f

[PATCH] D41391: [clangd] Use the clang-tools-extra as the official repo for `vscode-clangd` extension.

2017-12-21 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321252: [clangd] Use the clang-tools-extra as the official 
repo for `vscode-clangd`… (authored by hokein, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D41391

Files:
  clang-tools-extra/trunk/clangd/clients/clangd-vscode/LICENSE
  clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.md
  clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.txt
  clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json

Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/LICENSE
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/LICENSE
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 The LLVM Developers
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.md
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.md
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.md
@@ -0,0 +1,51 @@
+# vscode-clangd
+
+Provides C/C++ language IDE features for VS Code using [clangd](https://clang.llvm.org/extra/clangd.html).
+
+## Usage
+
+`vscode-clangd` provides the features designated by the [Language Server
+Protocol](https://github.com/Microsoft/language-server-protocol), such as
+code completion, code formatting and goto definition.
+
+**Note**: `clangd` is under heavy development, not all LSP features are
+implemented. See [Current Status](https://clang.llvm.org/extra/clangd.html#current-status)
+for details.
+
+To use `vscode-clangd` extension in VS Code, you need to install `vscode-clangd`
+from VS Code extension marketplace.
+
+`vscode-clangd` will attempt to find the `clangd` binary on your `PATH`.
+Alternatively, the `clangd` executable can be specified in your VS Code
+`settings.json` file:
+
+```json
+{
+"clangd.path": "/absolute/path/to/clangd"
+}
+```
+
+To obtain `clangd` binary, please see the [installing Clangd](https://clang.llvm.org/extra/clangd.html#installing-clangd).
+
+## Development
+
+A guide of developing `vscode-clangd` extension.
+
+### Requirements
+
+* VS Code
+* node.js and npm
+
+### Steps
+
+1. Make sure you disable the installed `vscode-clangd` extension in VS Code.
+2. Make sure you have clangd in /usr/bin/clangd or edit src/extension.ts to
+point to the binary.
+3. In order to start a development instance of VS code extended with this, run:
+
+```bash
+   $ cd /path/to/clang-tools-extra/clangd/clients/clangd-vscode/
+   $ npm install
+   $ code .
+   # When VS Code starts, press .
+```
Index: clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json
@@ -1,17 +1,25 @@
 {
-"name": "clangd-vscode",
-"displayName": "clangd-vscode",
+"name": "vscode-clangd",
+"displayName": "vscode-clangd",
 "description": "Clang Language Server",
-"version": "0.0.1",
-"publisher": "Unpublished",
+"version": "0.0.2",
+"publisher": "llvm-vs-code-extensions",
+"homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {
 "vscode": "^1.15.0"
 },
 "categories": [
 "Languages",
 "Linters",
 "Snippets"
 ],
+"keywords": [
+"C",
+"C++",
+"LSP",
+"Clangd",
+"LLVM"
+],
 "activationEvents": [
 "onLanguage:cpp",
 "onLanguage:c"
@@ -34,6 +42,10 @@
 "@types/node": "^6.0.40",
 "@types/mocha": "^2.2.32"
 },
+"repository": {
+  "type": "svn",
+  "url": "http://llvm.org/svn/llvm-project/clang-tools-extra/trunk/clang

[clang-tools-extra] r321252 - [clangd] Use the clang-tools-extra as the official repo for `vscode-clangd` extension.

2017-12-21 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Dec 21 00:45:18 2017
New Revision: 321252

URL: http://llvm.org/viewvc/llvm-project?rev=321252&view=rev
Log:
[clangd] Use the clang-tools-extra as the official repo for `vscode-clangd` 
extension.

Summary:
Previously, we use a separate GitHub repository 
(https://github.com/llvm-vs-code-extensions/vscode-clangd)
for publishing `vscode-clangd` extension to marketplace.

To reduce the maintain burden, we will use the vscode extension in the
clang-tools-extra, and deprecate the one on GitHub.

Test in 
https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.clangd-vscode-test

Reviewers: sammccall, krasimir

Reviewed By: sammccall

Subscribers: klimek, ilya-biryukov, cfe-commits

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

Added:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/LICENSE
clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.md
Removed:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.txt
Modified:
clang-tools-extra/trunk/clangd/clients/clangd-vscode/package.json

Added: clang-tools-extra/trunk/clangd/clients/clangd-vscode/LICENSE
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/LICENSE?rev=321252&view=auto
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/LICENSE (added)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/LICENSE Thu Dec 21 
00:45:18 2017
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 The LLVM Developers
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

Added: clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.md
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.md?rev=321252&view=auto
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.md (added)
+++ clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.md Thu Dec 21 
00:45:18 2017
@@ -0,0 +1,51 @@
+# vscode-clangd
+
+Provides C/C++ language IDE features for VS Code using 
[clangd](https://clang.llvm.org/extra/clangd.html).
+
+## Usage
+
+`vscode-clangd` provides the features designated by the [Language Server
+Protocol](https://github.com/Microsoft/language-server-protocol), such as
+code completion, code formatting and goto definition.
+
+**Note**: `clangd` is under heavy development, not all LSP features are
+implemented. See [Current 
Status](https://clang.llvm.org/extra/clangd.html#current-status)
+for details.
+
+To use `vscode-clangd` extension in VS Code, you need to install 
`vscode-clangd`
+from VS Code extension marketplace.
+
+`vscode-clangd` will attempt to find the `clangd` binary on your `PATH`.
+Alternatively, the `clangd` executable can be specified in your VS Code
+`settings.json` file:
+
+```json
+{
+"clangd.path": "/absolute/path/to/clangd"
+}
+```
+
+To obtain `clangd` binary, please see the [installing 
Clangd](https://clang.llvm.org/extra/clangd.html#installing-clangd).
+
+## Development
+
+A guide of developing `vscode-clangd` extension.
+
+### Requirements
+
+* VS Code
+* node.js and npm
+
+### Steps
+
+1. Make sure you disable the installed `vscode-clangd` extension in VS Code.
+2. Make sure you have clangd in /usr/bin/clangd or edit src/extension.ts to
+point to the binary.
+3. In order to start a development instance of VS code extended with this, run:
+
+```bash
+   $ cd /path/to/clang-tools-extra/clangd/clients/clangd-vscode/
+   $ npm install
+   $ code .
+   # When VS Code starts, press .
+```

Removed: clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/clients/clangd-vscode/README.txt?rev=321251&view=auto
==
--- clang-tools-extra/trunk/clangd/clients/clangd-vsc

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

2017-12-21 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

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




Comment at: docs/OpenMPSupport.rst:17
+
+Clang fully supports OpenMP 3.1 + some elements of OpenMP 4.5. Clang supports 
offloading to X86_64, AArch64, PPC64[LE] and Cuda devices.
+The status of major OpenMP 4.5 features support in Clang.

We should probably say that current trunk is not able to compile for Cuda 
devices yet.


Repository:
  rC Clang

https://reviews.llvm.org/D39457



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


[PATCH] D41456: [clang-tidy] readability-else-after-return: also diagnose noreturn function calls.

2017-12-21 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added a comment.

This check could also handle else after goto.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41456



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


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

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



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

ioeric wrote:
> sammccall wrote:
> > I think you probably want a raw pointer rather than optional:
> >  - reduce the size of the struct when it's absent
> >  - make it inheritance-friendly so we can hang index-specific info off it
> > (raw pointer rather than unique_ptr because it's owned by a slab not by 
> > malloc, but unique_ptr is ok for now)
> > 
> This is not easy for now with `unique_ptr` because of this line :( 
> https://github.com/llvm-mirror/clang-tools-extra/blob/3565d1a1a692fc9f5c21e634b470535da2bb4d25/clangd/index/SymbolYAML.cpp#L141).
>  
> 
> This shouldn't be an issue when we have the optimized symbol slab, where we 
> store raw pointers. And we would probably want to serialize the whole slab 
> instead of the individual symbols anyway.
> 
> > reduce the size of the struct when it's absent
> `llvm::Optional` doesn't take much more space, so the size should be fine.
> 
> > make it inheritance-friendly so we can hang index-specific info off it
> Could you elaborate on `index-specific info`? It's unclear to me how this 
> would be used.
> This is not easy for now with unique_ptr because of this line
Oh no, somehow i missed this during review.
We shouldn't be relying on symbols being copyable. I'll try to work out how to 
fix this and delete the copy constructor.

> This shouldn't be an issue when we have the optimized symbol slab, where we 
> store raw pointers.
Sure. That's not a big monolithic/mysterous thing though, storing the details 
in the slab can be done in this patch... If you think it'll be easier once 
strings are arena-based, then maybe we should delay this patch until that's 
done, rather than make that work bigger.

> And we would probably want to serialize the whole slab instead of the 
> individual symbols anyway.
This i'm less sure about, but I don't think it matters.

> llvm::Optional doesn't take much more space, so the size should be fine.
Optional takes the same size as the details itself (plus one bool). This is 
fairly small for now, but I think a major point of Details is to expand it in 
the future?

> Could you elaborate on index-specific info? It's unclear to me how this would 
> be used.
Yeah, this is something we talked about in the meeting with Marc-Andre but it's 
not really obvious - what's the point of allowing Details to be extended if 
clangd has to consume it?

It sounded like he might have use cases for using index infrastructure outside 
clangd. We might also have google-internal index features we want (matching 
generated code to proto fields?). I'm not really sure how compelling this 
argument is.



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

can you add a comment to the class indicating that it needs to be used for one 
TU and then thrown away? This seems unfortunate but is probably simpler than 
the alternative. It also seems to be a new restriction with this patch.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41345



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


[PATCH] D41242: [Solaris] Silence -pthread warning on Solaris

2017-12-21 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

ping


Repository:
  rC Clang

https://reviews.llvm.org/D41242



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


[PATCH] D41241: [Solaris] Only define _REENTRANT if -pthread

2017-12-21 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

ping


Repository:
  rC Clang

https://reviews.llvm.org/D41241



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


[PATCH] D41454: [clangd] Add ClangdUnit diagnostics tests using annotated code.

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 127843.
sammccall added a comment.

Tighten preprocessor test


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41454

Files:
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/diagnostics-preamble.test
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ClangdUnitTests.cpp

Index: unittests/clangd/ClangdUnitTests.cpp
===
--- /dev/null
+++ unittests/clangd/ClangdUnitTests.cpp
@@ -0,0 +1,130 @@
+//===-- ClangdUnitTests.cpp - ClangdUnit tests --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ClangdUnit.h"
+#include "Annotations.h"
+#include "TestFS.h"
+#include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Frontend/PCHContainerOperations.h"
+#include "clang/Frontend/Utils.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+using namespace llvm;
+void PrintTo(const DiagWithFixIts &D, std::ostream *O) {
+  llvm::raw_os_ostream OS(*O);
+  OS << D.Diag;
+  if (!D.FixIts.empty()) {
+OS << " {";
+const char *Sep = "";
+for (const auto &F : D.FixIts) {
+  OS << Sep << F;
+  Sep = ", ";
+}
+OS << "}";
+  }
+}
+
+namespace {
+using testing::ElementsAre;
+
+// FIXME: this is duplicated with FileIndexTests. Share it.
+ParsedAST build(StringRef Code, std::vector Flags = {}) {
+  std::vector Cmd = {"clang", "main.cpp"};
+  Cmd.insert(Cmd.begin() + 1, Flags.begin(), Flags.end());
+  auto CI = createInvocationFromCommandLine(Cmd);
+  auto Buf = MemoryBuffer::getMemBuffer(Code);
+  auto AST = ParsedAST::Build(
+  Context::empty(), std::move(CI), nullptr, std::move(Buf),
+  std::make_shared(), vfs::getRealFileSystem());
+  assert(AST.hasValue());
+  return std::move(*AST);
+}
+
+MATCHER_P2(Diag, Range, Message,
+   "Diagnostic at " + llvm::to_string(Range) + " = [" + Message + "]") {
+  return arg.Diag.range == Range && arg.Diag.message == Message &&
+ arg.FixIts.empty();
+}
+
+MATCHER_P3(Fix, Range, Replacement, Message,
+   "Fix " + llvm::to_string(Range) + " => " +
+   testing::PrintToString(Replacement) + " = [" + Message + "]") {
+  return arg.Diag.range == Range && arg.Diag.message == Message &&
+ arg.FixIts.size() == 1 && arg.FixIts[0].range == Range &&
+ arg.FixIts[0].newText == Replacement;
+}
+
+TEST(DiagnosticsTest, DiagnosticRanges) {
+  // Check we report correct ranges, including various edge-cases.
+  Annotations Test(R"cpp(
+void $decl[[foo]]();
+int main() {
+  $typo[[go\
+o]]();
+  foo()$semicolon[[]]
+  $unk[[unknown]]();
+}
+  )cpp");
+  llvm::errs() << Test.code();
+  EXPECT_THAT(
+  build(Test.code()).getDiagnostics(),
+  ElementsAre(
+  // This range spans lines.
+  Fix(Test.range("typo"), "foo",
+  "use of undeclared identifier 'goo'; did you mean 'foo'?"),
+  // This is a pretty normal range.
+  Diag(Test.range("decl"), "'foo' declared here"),
+  // This range is zero-width, and at the end of a line.
+  Fix(Test.range("semicolon"), ";",
+  "expected ';' after expression"),
+  // This range isn't provided by clang, we expand to the token.
+  Diag(Test.range("unk"),
+   "use of undeclared identifier 'unknown'")));
+}
+
+TEST(DiagnosticsTest, FlagsMatter) {
+  Annotations Test("[[void]] main() {}");
+  EXPECT_THAT(
+  build(Test.code()).getDiagnostics(),
+  ElementsAre(Fix(Test.range(), "int", "'main' must return 'int'")));
+  // Same code built as C gets different diagnostics.
+  EXPECT_THAT(
+  build(Test.code(), {"-x", "c"}).getDiagnostics(),
+  ElementsAre(
+  // FIXME: ideally this would be one diagnostic with a named FixIt.
+  Diag(Test.range(), "return type of 'main' is not 'int'"),
+  Fix(Test.range(), "int", "change return type to 'int'")));
+}
+
+TEST(DiagnosticsTest, Preprocessor) {
+  // This looks like a preamble, but there's an #else in the middle!
+  // Check that:
+  //  - the #else doesn't generate diagnostics (we had this bug)
+  //  - we get diagnostics from the taken branch
+  //  - we get no diagnostics from the not taken branch
+  Annotations Test(R"cpp(
+#ifndef FOO
+#define FOO
+  int a = [[b]];
+#else
+  int x = y;
+#endif
+)cpp");
+  EXPECT_THAT(
+  build(Test.code()).getDiagnostics(),
+  ElementsAre(Diag(Test.range(), "use of undeclared identifier 'b'")));
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: unittests/clangd/CMakeLi

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

2017-12-21 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

I added two more reviewers as we would like to get that in trunk before 6.0 
branches.


https://reviews.llvm.org/D38124



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


[PATCH] D41483: [clangd] Index symbols share storage within a slab.

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, ilya-biryukov, klimek.

Symbols are not self-contained - it's only safe to hand them out if you
guarantee the lifetime of the underlying data.

Before this lands, I'm going to measure the before/after memory usage of the
LLVM index loaded into memory in a single slab.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41483

Files:
  clangd/index/Index.cpp
  clangd/index/Index.h
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/IndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -33,7 +33,7 @@
 // GMock helpers for matching Symbol.
 MATCHER_P(QName, Name, "") {
   return (arg.second.Scope + (arg.second.Scope.empty() ? "" : "::") +
-  arg.second.Name) == Name;
+  arg.second.Name).str() == Name;
 }
 
 namespace clang {
Index: unittests/clangd/IndexTests.cpp
===
--- unittests/clangd/IndexTests.cpp
+++ unittests/clangd/IndexTests.cpp
@@ -75,7 +75,8 @@
   std::vector Matches;
   auto Ctx = Context::empty();
   I.fuzzyFind(Ctx, Req, [&](const Symbol &Sym) {
-Matches.push_back(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name);
+Matches.push_back(
+(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name).str());
   });
   return Matches;
 }
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -93,7 +93,8 @@
   std::vector Matches;
   auto Ctx = Context::empty();
   I.fuzzyFind(Ctx, Req, [&](const Symbol &Sym) {
-Matches.push_back(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name);
+Matches.push_back(
+(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name).str());
   });
   return Matches;
 }
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -15,15 +15,16 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringSet.h"
 #include 
 #include 
 
 namespace clang {
 namespace clangd {
 
 struct SymbolLocation {
   // The absolute path of the source file where a symbol occurs.
-  std::string FilePath;
+  llvm::StringRef FilePath;
   // The 0-based offset to the first character of the symbol from the beginning
   // of the source file.
   unsigned StartOffset;
@@ -71,16 +72,19 @@
 
 // The class presents a C++ symbol, e.g. class, function.
 //
-// FIXME: instead of having own copy fields for each symbol, we can share
-// storage from SymbolSlab.
+// WARNING: Symbols do now own much of their underlying data - typically strings
+// are owned by a SymbolSlab. They should be treated as non-owning references.
+// Copies are shallow.
+// When adding new unowned data fields to Symbol, remember to update
+// SymbolSlab::insert to copy them to the slab's storage.
 struct Symbol {
   // The ID of the symbol.
   SymbolID ID;
   // The unqualified name of the symbol, e.g. "bar" (for "n1::n2::bar").
-  std::string Name;
+  llvm::StringRef Name;
   // The scope (e.g. namespace) of the symbol, e.g. "n1::n2" (for
   // "n1::n2::bar").
-  std::string Scope;
+  llvm::StringRef Scope;
   // The symbol information, like symbol kind.
   index::SymbolInfo SymInfo;
   // The location of the canonical declaration of the symbol.
@@ -117,11 +121,17 @@
   // operation is irreversible.
   void freeze();
 
-  void insert(Symbol S);
+  void insert(const Symbol& S);
 
 private:
+  void intern(llvm::StringRef &S) {
+S = S.empty() ? llvm::StringRef() : Strings.insert(S).first->getKey();
+  }
+
   bool Frozen = false;
 
+  // Intern table for strings. Not StringPool as we don't refcount, just insert.
+  llvm::StringSet Strings;
   llvm::DenseMap Symbols;
 };
 
Index: clangd/index/Index.cpp
===
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -38,9 +38,13 @@
 
 void SymbolSlab::freeze() { Frozen = true; }
 
-void SymbolSlab::insert(Symbol S) {
+void SymbolSlab::insert(const Symbol &S) {
   assert(!Frozen && "Can't insert a symbol after the slab has been frozen!");
-  Symbols[S.ID] = std::move(S);
+  auto &Sym = Symbols[S.ID] = S;
+
+  intern(Sym.Name);
+  intern(Sym.Scope);
+  intern(Sym.CanonicalDeclaration.FilePath);
 }
 
 } // namespace clangd
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41483: [clangd] Index symbols share storage within a slab.

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 127849.
sammccall added a comment.

Don't intern unless the symbol was actually inserted.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41483

Files:
  clangd/index/Index.cpp
  clangd/index/Index.h
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/IndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -33,7 +33,7 @@
 // GMock helpers for matching Symbol.
 MATCHER_P(QName, Name, "") {
   return (arg.second.Scope + (arg.second.Scope.empty() ? "" : "::") +
-  arg.second.Name) == Name;
+  arg.second.Name).str() == Name;
 }
 
 namespace clang {
Index: unittests/clangd/IndexTests.cpp
===
--- unittests/clangd/IndexTests.cpp
+++ unittests/clangd/IndexTests.cpp
@@ -75,7 +75,8 @@
   std::vector Matches;
   auto Ctx = Context::empty();
   I.fuzzyFind(Ctx, Req, [&](const Symbol &Sym) {
-Matches.push_back(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name);
+Matches.push_back(
+(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name).str());
   });
   return Matches;
 }
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -93,7 +93,8 @@
   std::vector Matches;
   auto Ctx = Context::empty();
   I.fuzzyFind(Ctx, Req, [&](const Symbol &Sym) {
-Matches.push_back(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name);
+Matches.push_back(
+(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name).str());
   });
   return Matches;
 }
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -15,15 +15,16 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringSet.h"
 #include 
 #include 
 
 namespace clang {
 namespace clangd {
 
 struct SymbolLocation {
   // The absolute path of the source file where a symbol occurs.
-  std::string FilePath;
+  llvm::StringRef FilePath;
   // The 0-based offset to the first character of the symbol from the beginning
   // of the source file.
   unsigned StartOffset;
@@ -71,16 +72,19 @@
 
 // The class presents a C++ symbol, e.g. class, function.
 //
-// FIXME: instead of having own copy fields for each symbol, we can share
-// storage from SymbolSlab.
+// WARNING: Symbols do now own much of their underlying data - typically strings
+// are owned by a SymbolSlab. They should be treated as non-owning references.
+// Copies are shallow.
+// When adding new unowned data fields to Symbol, remember to update
+// SymbolSlab::insert to copy them to the slab's storage.
 struct Symbol {
   // The ID of the symbol.
   SymbolID ID;
   // The unqualified name of the symbol, e.g. "bar" (for "n1::n2::bar").
-  std::string Name;
+  llvm::StringRef Name;
   // The scope (e.g. namespace) of the symbol, e.g. "n1::n2" (for
   // "n1::n2::bar").
-  std::string Scope;
+  llvm::StringRef Scope;
   // The symbol information, like symbol kind.
   index::SymbolInfo SymInfo;
   // The location of the canonical declaration of the symbol.
@@ -117,11 +121,19 @@
   // operation is irreversible.
   void freeze();
 
-  void insert(Symbol S);
+  // Adds the symbol to this slab.
+  // This is a deep copy: underlying strings will be owned by the slab.
+  void insert(const Symbol& S);
 
 private:
+  void intern(llvm::StringRef &S) {
+S = S.empty() ? llvm::StringRef() : Strings.insert(S).first->getKey();
+  }
+
   bool Frozen = false;
 
+  // Intern table for strings. Not StringPool as we don't refcount, just insert.
+  llvm::StringSet Strings;
   llvm::DenseMap Symbols;
 };
 
Index: clangd/index/Index.cpp
===
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -38,9 +38,17 @@
 
 void SymbolSlab::freeze() { Frozen = true; }
 
-void SymbolSlab::insert(Symbol S) {
+void SymbolSlab::insert(const Symbol &S) {
   assert(!Frozen && "Can't insert a symbol after the slab has been frozen!");
-  Symbols[S.ID] = std::move(S);
+  auto ItInserted = Symbols.try_emplace(S.ID, S);
+  if (!ItInserted.second)
+return;
+  auto &Sym = ItInserted.first->second;
+
+  // We inserted a new symbol, so copy the underlying data.
+  intern(Sym.Name);
+  intern(Sym.Scope);
+  intern(Sym.CanonicalDeclaration.FilePath);
 }
 
 } // namespace clangd
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41485: [OpenMP][libomptarget] Add data sharing support in libomptarget

2017-12-21 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: carlo.bertolli, ABataev, Hahnfeld, grokos, caomhin, 
hfinkel.

This patch extends the libomptarget functionality in patch 
https://reviews.llvm.org/D14254 with support for the data sharing scheme for 
supporting implicitly shared variables. The runtime therefore maintains a list 
of references to shared variables.


Repository:
  rL LLVM

https://reviews.llvm.org/D41485

Files:
  libomptarget/deviceRTLs/nvptx/src/interface.h
  libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu
  libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h
  libomptarget/deviceRTLs/nvptx/src/option.h
  libomptarget/deviceRTLs/nvptx/src/parallel.cu

Index: libomptarget/deviceRTLs/nvptx/src/parallel.cu
===
--- libomptarget/deviceRTLs/nvptx/src/parallel.cu
+++ libomptarget/deviceRTLs/nvptx/src/parallel.cu
@@ -210,10 +210,16 @@
 //}
 //
 // This routine is always called by the team master..
-EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn, int16_t IsOMPRuntimeInitialized) {
+EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn, int16_t IsOMPRuntimeInitialized,
+   void ***SharedArgs, int32_t nArgs) {
   PRINT0(LD_IO, "call to __kmpc_kernel_prepare_parallel\n");
   omptarget_nvptx_workFn = WorkFn;
 
+  if (nArgs > 0) {
+omptarget_nvptx_sharedArgs.EnsureSize(nArgs);
+*SharedArgs = omptarget_nvptx_sharedArgs.GetArgs();
+  }
+
   if (!IsOMPRuntimeInitialized) return;
 
   // This routine is only called by the team master.  The team master is
@@ -310,11 +316,13 @@
 // returns True if this thread is active, else False.
 //
 // Only the worker threads call this routine.
-EXTERN bool __kmpc_kernel_parallel(void **WorkFn, int16_t IsOMPRuntimeInitialized) {
+EXTERN bool __kmpc_kernel_parallel(void **WorkFn, int16_t IsOMPRuntimeInitialized,
+   void ***SharedArgs) {
   PRINT0(LD_IO | LD_PAR, "call to __kmpc_kernel_parallel\n");
 
   // Work function and arguments for L1 parallel region.
   *WorkFn   = omptarget_nvptx_workFn;
+  *SharedArgs = omptarget_nvptx_sharedArgs.GetArgs();
 
   if (!IsOMPRuntimeInitialized) return true;
 
Index: libomptarget/deviceRTLs/nvptx/src/option.h
===
--- libomptarget/deviceRTLs/nvptx/src/option.h
+++ libomptarget/deviceRTLs/nvptx/src/option.h
@@ -46,6 +46,10 @@
 // to synchronize with each other.
 #define L1_BARRIER (1)
 
+// Maximum number of preallocated arguments to an outlined parallel/simd function.
+// Anything more requires dynamic memory allocation.
+#define MAX_SHARED_ARGS 20
+
 // Maximum number of omp state objects per SM allocated statically in global memory.
 #if __CUDA_ARCH__ >= 600
 #define OMP_STATE_COUNT 32
Index: libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h
===
--- libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h
+++ libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h
@@ -60,6 +60,46 @@
 #define __ACTIVEMASK() __ballot(1)
 #endif
 
+// arguments needed for L0 parallelism only.
+class omptarget_nvptx_SharedArgs {
+public:
+  // All these methods must be called by the master thread only.
+  INLINE void Init() {
+args  = buffer;
+nArgs = MAX_SHARED_ARGS;
+  }
+  INLINE void DeInit() {
+// Free any memory allocated for outlined parallel function with a large
+// number of arguments.
+if (nArgs > MAX_SHARED_ARGS) {
+  SafeFree(args, (char *)"new extended args");
+  Init();
+}
+  }
+  INLINE void EnsureSize(int size) {
+if (size > nArgs) {
+  if (nArgs > MAX_SHARED_ARGS) {
+SafeFree(args, (char *)"new extended args");
+  }
+  args = (void **) SafeMalloc(size * sizeof(void *),
+  (char *)"new extended args");
+  nArgs = size;
+}
+  }
+  // Called by all threads.
+  INLINE void **GetArgs() { return args; };
+private:
+  // buffer of pre-allocated arguments.
+  void *buffer[MAX_SHARED_ARGS];
+  // pointer to arguments buffer.
+  // starts off as a pointer to 'buffer' but can be dynamically allocated.
+  void **args;
+  // starts off as MAX_SHARED_ARGS but can increase in size.
+  uint32_t nArgs;
+};
+
+extern __device__ __shared__ omptarget_nvptx_SharedArgs omptarget_nvptx_sharedArgs;
+
 // Data sharing related quantities, need to match what is used in the compiler.
 enum DATA_SHARING_SIZES {
   // The maximum number of workers in a kernel.
Index: libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu
===
--- libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu
+++ libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu
@@ -32,6 +32,7 @@
 //
 extern volatile __device__ __shared__ omptarget_nvptx_WorkFn   omptarget_nvptx_workFn;
 extern __device__ __shared__ uint32_t execution_param;
+__device__ __shared__ 

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

2017-12-21 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, carlo.bertolli, hfinkel, Hahnfeld, caomhin.
Herald added a subscriber: jholewinski.

This patch adds a missing argument to the runtime interface. Tests are adjusted 
accordingly.


Repository:
  rL LLVM

https://reviews.llvm.org/D41486

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  test/OpenMP/nvptx_data_sharing.cpp
  test/OpenMP/nvptx_target_teams_codegen.cpp


Index: test/OpenMP/nvptx_target_teams_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_codegen.cpp
@@ -60,7 +60,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** 
[[OMP_WORK_FN]], i8*** %shared_args)
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** 
[[OMP_WORK_FN]], {{.*}} i8*** %shared_args)
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -148,7 +148,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** 
[[OMP_WORK_FN]], i8*** %shared_args)
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** 
[[OMP_WORK_FN]], {{.*}} i8*** %shared_args)
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
Index: test/OpenMP/nvptx_data_sharing.cpp
===
--- test/OpenMP/nvptx_data_sharing.cpp
+++ test/OpenMP/nvptx_data_sharing.cpp
@@ -24,15 +24,15 @@
 
 // CK1: define internal void @__omp_offloading_{{.*}}test_ds{{.*}}worker() 
[[ATTR1:#.*]] {
 // CK1: [[SHAREDARGS:%.+]] = alloca i8**
-// CK1: call i1 @__kmpc_kernel_parallel(i8** %work_fn, i8*** [[SHAREDARGS]])
+// CK1: call i1 @__kmpc_kernel_parallel(i8** %work_fn, {{.*}} i8*** 
[[SHAREDARGS]])
 // CK1: [[SHARGSTMP:%.+]] = load i8**, i8*** [[SHAREDARGS]]
 // CK1: call void @__omp_outlined___wrapper{{.*}}({{.*}}, i8** [[SHARGSTMP]])
 
 /// = In the kernel function = ///
 
 // CK1: {{.*}}define void @__omp_offloading{{.*}}test_ds{{.*}}() [[ATTR2:#.*]] 
{
 // CK1: [[SHAREDARGS1:%.+]] = alloca i8**
-// CK1: call void @__kmpc_kernel_prepare_parallel({{.*}}, i8*** 
[[SHAREDARGS1]], i32 1)
+// CK1: call void @__kmpc_kernel_prepare_parallel({{.*}}, {{.*}} i8*** 
[[SHAREDARGS1]], i32 1)
 // CK1: [[SHARGSTMP1:%.+]] = load i8**, i8*** [[SHAREDARGS1]]
 // CK1: [[SHARGSTMP2:%.+]] = getelementptr inbounds i8*, i8** [[SHARGSTMP1]]
 // CK1: [[SHAREDVAR:%.+]] = bitcast i32* {{.*}} to i8*
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -521,7 +521,8 @@
   // Set up shared arguments
   Address SharedArgs =
   CGF.CreateDefaultAlignTempAlloca(CGF.Int8PtrPtrTy, "shared_args");
-  llvm::Value *Args[] = {WorkFn.getPointer(), SharedArgs.getPointer()};
+  llvm::Value *Args[] = {WorkFn.getPointer(), Bld.getInt16(1),
+ SharedArgs.getPointer()};
   llvm::Value *Ret = CGF.EmitRuntimeCall(
   createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_parallel), Args);
   Bld.CreateStore(Bld.CreateZExt(Ret, CGF.Int8Ty), ExecStatus);
@@ -638,16 +639,16 @@
   case OMPRTL_NVPTX__kmpc_kernel_prepare_parallel: {
 /// Build void __kmpc_kernel_prepare_parallel(
 /// void *outlined_function, void ***args, kmp_int32 nArgs);
-llvm::Type *TypeParams[] = {CGM.Int8PtrTy,
+llvm::Type *TypeParams[] = {CGM.Int8PtrTy, CGM.Int16Ty,
 CGM.Int8PtrPtrTy->getPointerTo(0), CGM.Int32Ty};
 llvm::FunctionType *FnTy =
 llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_kernel_prepare_parallel");
 break;
   }
   case OMPRTL_NVPTX__kmpc_kernel_parallel: {
 /// Build bool __kmpc_kernel_parallel(void **outlined_function, void 
***args);
-llvm::Type *TypeParams[] = {CGM.Int8PtrPtrTy,
+llvm::Type *TypeParams[] = {CGM.Int8PtrPtrTy, CGM.Int16Ty,
 CGM.Int8PtrPtrTy->getPointerTo(0)};
 llvm::Type *RetTy = CGM.getTypes().ConvertType(CGM.getContext().BoolTy);
 llvm::FunctionType *FnTy =
@@ -949,7 +950,7 @@
   CGF.CreateDefaultAlignTempAlloca(CGF.VoidPtrPtrTy,
   "shared_args");
   llvm::Value *SharedArgsPtr = SharedArgs.getPointer();
-  llvm::Value *Args[] = {ID, SharedArgsPtr,
+  llvm::Value *Args[] = {ID, Bld.getInt16(1), SharedArgsPtr,
  Bld.getInt32(CapturedVars.size())};
 
   CGF.EmitRuntimeCall(
@@ -970,7 +971,7 @@
 Idx++;
   }
 } else {
-  llvm::Value *Args[] = {ID,
+  llvm::Value *

[PATCH] D41485: [OpenMP][libomptarget] Add data sharing support in libomptarget

2017-12-21 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: libomptarget/deviceRTLs/nvptx/src/interface.h:1290-1291
 EXTERN void __kmpc_spmd_kernel_deinit();
-EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn, int16_t 
IsOMPRuntimeInitialized);
-EXTERN bool __kmpc_kernel_parallel(void **WorkFn, int16_t 
IsOMPRuntimeInitialized);
+EXTERN void __kmpc_kernel_prepare_parallel(void *WorkFn, int16_t 
IsOMPRuntimeInitialized, void ***SharedArgs, int32_t nArgs);
+EXTERN bool __kmpc_kernel_parallel(void **WorkFn, int16_t 
IsOMPRuntimeInitialized, void ***SharedArgs);
 EXTERN void __kmpc_kernel_end_parallel();

We have to agree on an order here: In D41012 I chose to put 
`IsOMPRuntimeInitialized` last which matches the other functions.


Repository:
  rL LLVM

https://reviews.llvm.org/D41485



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


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

2017-12-21 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld requested changes to this revision.
Hahnfeld added a comment.
This revision now requires changes to proceed.

https://reviews.llvm.org/D41012? This patch doesn't update the documentation 
with function signatures.


Repository:
  rL LLVM

https://reviews.llvm.org/D41486



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


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

2017-12-21 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D41486#961981, @Hahnfeld wrote:

> https://reviews.llvm.org/D41012? This patch doesn't update the documentation 
> with function signatures.


Ok so I see that your patch uses a different order of the arguments. I've just 
added the data sharing related arguments at the end and this matches the 
libomptarget patch I just posted. Which way do we want to do this?


Repository:
  rL LLVM

https://reviews.llvm.org/D41486



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


[PATCH] D41444: [ASTImporterTest] Make testing under '-fdelayed-template-parsing' mandatory

2017-12-21 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: unittests/AST/ASTImporterTest.cpp:32
+
+static RunOptions getRunOptionsForLanguage(Language Lang) {
+  ArgVector BasicArgs;

I wonder if in the future it would be worth to use something else, like 
LangOptions of clang instead of this enum. But I think this should be ok for 
now.


Repository:
  rC Clang

https://reviews.llvm.org/D41444



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


[PATCH] D40720: No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17

2017-12-21 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg updated this revision to Diff 127863.
sberg added a comment.

As suggested, solve the issue instead by removing any "noexcept" from the 
typeinfo emitted for the -fsanitize=function checks.


https://reviews.llvm.org/D40720

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
  compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp

Index: compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
===
--- compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
+++ compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
@@ -1,4 +1,4 @@
-// RUN: %clangxx -fsanitize=function %s -O3 -g -o %t
+// RUN: %clangxx -std=c++17 -fsanitize=function %s -O3 -g -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
 // Verify that we can disable symbolization if needed:
 // RUN: %env_ubsan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOSYM
@@ -23,9 +23,49 @@
   reinterpret_cast(reinterpret_cast(f))(42);
 }
 
+void f1(int) {}
+void f2(unsigned int) {}
+void f3(int) noexcept {}
+void f4(unsigned int) noexcept {}
+
+void check_noexcept_calls() {
+  void (*p1)(int);
+  p1 = &f1;
+  p1(0);
+  p1 = reinterpret_cast(&f2);
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f2(unsigned int) through pointer to incorrect function type 'void (*)(int)'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int)'
+  p1(0);
+  p1 = &f3;
+  p1(0);
+  p1 = reinterpret_cast(&f4);
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f4(unsigned int) through pointer to incorrect function type 'void (*)(int)'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int)'
+  p1(0);
+
+  void (*p2)(int) noexcept;
+  p2 = reinterpret_cast(&f1);
+  // TODO: Unclear whether calling a non-noexcept function through a pointer to
+  // nexcept function should cause an error.
+  // CHECK-NOT: function.cpp:[[@LINE+2]]:3: runtime error: call to function f1(int) through pointer to incorrect function type 'void (*)(int) noexcept'
+  // NOSYM-NOT: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int) noexcept'
+  p2(0);
+  p2 = reinterpret_cast(&f2);
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f2(unsigned int) through pointer to incorrect function type 'void (*)(int) noexcept'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int) noexcept'
+  p2(0);
+  p2 = &f3;
+  p2(0);
+  p2 = reinterpret_cast(&f4);
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f4(unsigned int) through pointer to incorrect function type 'void (*)(int) noexcept'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int) noexcept'
+  p2(0);
+}
+
 int main(void) {
   make_valid_call();
   make_invalid_call();
+  check_noexcept_calls();
   // Check that no more errors will be printed.
   // CHECK-NOT: runtime error: call to function
   // NOSYM-NOT: runtime error: call to function
Index: clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++17 -fsanitize=function -emit-llvm -triple x86_64-linux-gnu %s -o - | FileCheck %s
+
+// Check that typeinfo recorded in function prolog doesn't have "Do" noexcept
+// qualifier in its mangled name.
+// CHECK: @[[LABEL:[0-9]+]] = private constant i8* bitcast ({ i8*, i8* }* @_ZTIFvvE to i8*)
+// CHECK: define void @_Z1fv() #{{.*}} prologue <{ i32, i32 }> <{ i32 {{.*}}, i32 trunc (i64 sub (i64 ptrtoint (i8** @[[LABEL]] to i64), i64 ptrtoint (void ()* @_Z1fv to i64)) to i32) }>
+void f() noexcept {}
+
+// CHECK: define void @_Z1gPDoFvvE
+void g(void (*p)() noexcept) {
+  // Check that reference typeinfo at call site doesn't have "Do" noexcept
+  // qualifier in its mangled name, either.
+  // CHECK: icmp eq i8* %{{.*}}, bitcast ({ i8*, i8* }* @_ZTIFvvE to i8*), !nosanitize
+  p();
+}
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3415,7 +3415,7 @@
 
 /// Compute the flags for a __pbase_type_info, and remove the corresponding
 /// pieces from \p Type.
-static unsigned extractPBaseFlags(ASTContext &Ctx, QualType &Type) {
+static unsigned extractPBaseFlags(CodeGe

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

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

Address comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D41486

Files:
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  test/OpenMP/nvptx_data_sharing.cpp
  test/OpenMP/nvptx_target_teams_codegen.cpp

Index: test/OpenMP/nvptx_target_teams_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_codegen.cpp
@@ -60,7 +60,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i8*** %shared_args)
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i16 1, i8*** %shared_args)
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
@@ -148,7 +148,7 @@
   //
   // CHECK: [[AWAIT_WORK]]
   // CHECK: call void @llvm.nvvm.barrier0()
-  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i8*** %shared_args)
+  // CHECK: [[KPR:%.+]] = call i1 @__kmpc_kernel_parallel(i8** [[OMP_WORK_FN]], i16 1, i8*** %shared_args)
   // CHECK: [[KPRB:%.+]] = zext i1 [[KPR]] to i8
   // store i8 [[KPRB]], i8* [[OMP_EXEC_STATUS]], align 1
   // CHECK: [[WORK:%.+]] = load i8*, i8** [[OMP_WORK_FN]],
Index: test/OpenMP/nvptx_data_sharing.cpp
===
--- test/OpenMP/nvptx_data_sharing.cpp
+++ test/OpenMP/nvptx_data_sharing.cpp
@@ -24,15 +24,15 @@
 
 // CK1: define internal void @__omp_offloading_{{.*}}test_ds{{.*}}worker() [[ATTR1:#.*]] {
 // CK1: [[SHAREDARGS:%.+]] = alloca i8**
-// CK1: call i1 @__kmpc_kernel_parallel(i8** %work_fn, i8*** [[SHAREDARGS]])
+// CK1: call i1 @__kmpc_kernel_parallel(i8** %work_fn, i16 1, i8*** [[SHAREDARGS]])
 // CK1: [[SHARGSTMP:%.+]] = load i8**, i8*** [[SHAREDARGS]]
 // CK1: call void @__omp_outlined___wrapper{{.*}}({{.*}}, i8** [[SHARGSTMP]])
 
 /// = In the kernel function = ///
 
 // CK1: {{.*}}define void @__omp_offloading{{.*}}test_ds{{.*}}() [[ATTR2:#.*]] {
 // CK1: [[SHAREDARGS1:%.+]] = alloca i8**
-// CK1: call void @__kmpc_kernel_prepare_parallel({{.*}}, i8*** [[SHAREDARGS1]], i32 1)
+// CK1: call void @__kmpc_kernel_prepare_parallel({{.*}}, i16 1, i8*** [[SHAREDARGS1]], i32 1)
 // CK1: [[SHARGSTMP1:%.+]] = load i8**, i8*** [[SHAREDARGS1]]
 // CK1: [[SHARGSTMP2:%.+]] = getelementptr inbounds i8*, i8** [[SHARGSTMP1]]
 // CK1: [[SHAREDVAR:%.+]] = bitcast i32* {{.*}} to i8*
Index: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -33,10 +33,11 @@
   /// \brief Call to void __kmpc_spmd_kernel_deinit();
   OMPRTL_NVPTX__kmpc_spmd_kernel_deinit,
   /// \brief Call to void __kmpc_kernel_prepare_parallel(void
-  /// *outlined_function, void ***args, kmp_int32 nArgs);
+  /// *outlined_function, int16_t IsOMPRuntimeInitialized,
+  /// void ***args, kmp_int32 nArgs);
   OMPRTL_NVPTX__kmpc_kernel_prepare_parallel,
-  /// \brief Call to bool __kmpc_kernel_parallel(void **outlined_function, void
-  /// ***args);
+  /// \brief Call to bool __kmpc_kernel_parallel(void **outlined_function,
+  /// int16_t IsOMPRuntimeInitialized, void ***args);
   OMPRTL_NVPTX__kmpc_kernel_parallel,
   /// \brief Call to void __kmpc_kernel_end_parallel();
   OMPRTL_NVPTX__kmpc_kernel_end_parallel,
@@ -521,7 +522,9 @@
   // Set up shared arguments
   Address SharedArgs =
   CGF.CreateDefaultAlignTempAlloca(CGF.Int8PtrPtrTy, "shared_args");
-  llvm::Value *Args[] = {WorkFn.getPointer(), SharedArgs.getPointer()};
+  llvm::Value *Args[] = {WorkFn.getPointer(),
+ /*IsOMPRuntimeInitialized*/ Bld.getInt16(1),
+ SharedArgs.getPointer()};
   llvm::Value *Ret = CGF.EmitRuntimeCall(
   createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_parallel), Args);
   Bld.CreateStore(Bld.CreateZExt(Ret, CGF.Int8Ty), ExecStatus);
@@ -638,16 +641,16 @@
   case OMPRTL_NVPTX__kmpc_kernel_prepare_parallel: {
 /// Build void __kmpc_kernel_prepare_parallel(
 /// void *outlined_function, void ***args, kmp_int32 nArgs);
-llvm::Type *TypeParams[] = {CGM.Int8PtrTy,
+llvm::Type *TypeParams[] = {CGM.Int8PtrTy, CGM.Int16Ty,
 CGM.Int8PtrPtrTy->getPointerTo(0), CGM.Int32Ty};
 llvm::FunctionType *FnTy =
 llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
 RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_kernel_prepare_parallel");
 break;
   }
   case OMPRTL_NVPTX__kmpc_kernel_parallel: {
 /// Build bool __kmpc_kernel_parallel(void **outlined_function, void ***args);
-llvm::Type *TypeParams[] = {CGM.Int8PtrPtrTy,
+llvm::Type *TypeParams[] = {CGM.Int8PtrPtrTy, CGM.Int16Ty,
 C

[PATCH] D41444: [ASTImporterTest] Make testing under '-fdelayed-template-parsing' mandatory

2017-12-21 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added inline comments.



Comment at: unittests/AST/ASTImporterTest.cpp:32
+
+static RunOptions getRunOptionsForLanguage(Language Lang) {
+  ArgVector BasicArgs;

xazax.hun wrote:
> I wonder if in the future it would be worth to use something else, like 
> LangOptions of clang instead of this enum. But I think this should be ok for 
> now.
This was inspired by ASTMatchersTest. Reusing existing enum is nice but it is 
an item for a separate patch, I think.


Repository:
  rC Clang

https://reviews.llvm.org/D41444



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


[PATCH] D40451: [OpenMP] Add function attribute for triggering shared memory lowering in the LLVM backend

2017-12-21 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea closed this revision.
gtbercea added a comment.

Committed here https://reviews.llvm.org/D41123


Repository:
  rL LLVM

https://reviews.llvm.org/D40451



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


[PATCH] D41487: [clang-format] Adds a FormatStyleSet

2017-12-21 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir added reviewers: klimek, djasper.

This patch adds a FormatStyleSet for storing per-language FormatStyles for the
purposes of formatting code blocks inside the main code.


Repository:
  rC Clang

https://reviews.llvm.org/D41487

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp

Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -888,15 +888,24 @@
   // Look for a suitable configuration starting from the end, so we can
   // find the configuration for the specific language first, and the default
   // configuration (which can only be at slot 0) after it.
+  bool LanguageFound = false;
   for (int i = Styles.size() - 1; i >= 0; --i) {
-if (Styles[i].Language == Language ||
-Styles[i].Language == FormatStyle::LK_None) {
+if (!LanguageFound && (Styles[i].Language == Language ||
+   Styles[i].Language == FormatStyle::LK_None)) {
   *Style = Styles[i];
   Style->Language = Language;
-  return make_error_code(ParseError::Success);
+  LanguageFound = true;
+  break;
+}
+  }
+  if (!LanguageFound)
+return make_error_code(ParseError::Unsuitable);
+  for (int i = Styles.size() - 1; i >= 0; --i) {
+if (Styles[i].Language != FormatStyle::LK_None) {
+  Style->AddLanguageStyle(Styles[i]);
 }
   }
-  return make_error_code(ParseError::Unsuitable);
+  return make_error_code(ParseError::Success);
 }
 
 std::string configurationAsText(const FormatStyle &Style) {
@@ -910,6 +919,34 @@
   return Stream.str();
 }
 
+llvm::Optional
+FormatStyle::FormatStyleSet::Get(FormatStyle::LanguageKind Language) const {
+  if (!Styles)
+return None;
+  auto It = Styles->find(Language);
+  if (It == Styles->end())
+return None;
+  FormatStyle Style = *It->second;
+  Style.StyleSet = *this;
+  return Style;
+}
+
+void FormatStyle::FormatStyleSet::Add(FormatStyle Style) {
+  Style.StyleSet.Styles.reset();
+  if (!Styles)
+Styles = std::make_shared();
+  (*Styles)[Style.Language].reset(new FormatStyle(Style));
+}
+
+llvm::Optional
+FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind Language) const {
+  return StyleSet.Get(Language);
+}
+
+void FormatStyle::AddLanguageStyle(const FormatStyle& Style) {
+  StyleSet.Add(Style);
+}
+
 namespace {
 
 class JavaScriptRequoter : public TokenAnalyzer {
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -1685,6 +1685,29 @@
Standard == R.Standard && TabWidth == R.TabWidth &&
UseTab == R.UseTab;
   }
+
+  llvm::Optional GetLanguageStyle(LanguageKind Language) const;
+  void AddLanguageStyle(const FormatStyle& Style);
+
+ private:
+   // Stores per-language styles. A FormatStyle instance inside has an empty
+   // StyleSet. A FormatStyle instance returned by the Get method has its
+   // StyleSet set to a copy of the originating StyleSet, effectively keeping
+   // the internal representation of that StyleSet alive.
+   //
+   // The memory management and ownership reminds of a birds nest: chicks
+   // leaving the nest take photos of the nest with them.
+   struct FormatStyleSet {
+ typedef std::map>
+ MapType;
+ llvm::Optional Get(FormatStyle::LanguageKind Language) const;
+ void Add(FormatStyle Style);
+   private:
+ std::shared_ptr Styles;
+   };
+
+   FormatStyleSet StyleSet;
 };
 
 /// \brief Returns a format style complying with the LLVM coding standards:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41483: [clangd] Index symbols share storage within a slab.

2017-12-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/index/Index.h:136
+  // Intern table for strings. Not StringPool as we don't refcount, just 
insert.
+  llvm::StringSet Strings;
   llvm::DenseMap Symbols;

A comment on why we use `BumpPtrAllocator` here might be useful.
I.e., it uses more memory than malloc, but we're getting better data locality. 
(I hope that I got its intention right)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41483



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


r321266 - Added helper to get size of PrecompiledPreamble

2017-12-21 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Dec 21 06:04:39 2017
New Revision: 321266

URL: http://llvm.org/viewvc/llvm-project?rev=321266&view=rev
Log:
Added helper to get size of PrecompiledPreamble

Modified:
cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp

Modified: cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h?rev=321266&r1=321265&r2=321266&view=diff
==
--- cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h (original)
+++ cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h Thu Dec 21 06:04:39 
2017
@@ -19,6 +19,7 @@
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/AlignOf.h"
 #include "llvm/Support/MD5.h"
+#include 
 #include 
 #include 
 #include 
@@ -89,6 +90,11 @@ public:
   /// PreambleBounds used to build the preamble.
   PreambleBounds getBounds() const;
 
+  /// Returns the size, in bytes, that preamble takes on disk or in memory.
+  /// For on-disk preambles returns 0 if filesystem operations fail. Intended 
to
+  /// be used for logging and debugging purposes only.
+  std::size_t getSize() const;
+
   /// Check whether PrecompiledPreamble can be reused for the new contents(\p
   /// MainFileBuffer) of the main file.
   bool CanReuse(const CompilerInvocation &Invocation,
@@ -246,7 +252,8 @@ public:
 
   /// Called before FrontendAction::BeginSourceFile.
   /// Can be used to store references to various CompilerInstance fields
-  /// (e.g. SourceManager) that may be interesting to the consumers of other 
callbacks.
+  /// (e.g. SourceManager) that may be interesting to the consumers of other
+  /// callbacks.
   virtual void BeforeExecute(CompilerInstance &CI);
   /// Called after FrontendAction::Execute(), but before
   /// FrontendAction::EndSourceFile(). Can be used to transfer ownership of

Modified: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp?rev=321266&r1=321265&r2=321266&view=diff
==
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp (original)
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp Thu Dec 21 06:04:39 2017
@@ -30,7 +30,7 @@
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/MutexGuard.h"
 #include "llvm/Support/Process.h"
-
+#include 
 #include 
 
 using namespace clang;
@@ -381,6 +381,27 @@ PreambleBounds PrecompiledPreamble::getB
   return PreambleBounds(PreambleBytes.size(), PreambleEndsAtStartOfLine);
 }
 
+std::size_t PrecompiledPreamble::getSize() const {
+  switch (Storage.getKind()) {
+  case PCHStorage::Kind::Empty:
+assert(false && "Calling getSize() on invalid PrecompiledPreamble. "
+"Was it std::moved?");
+return 0;
+  case PCHStorage::Kind::InMemory:
+return Storage.asMemory().Data.size();
+  case PCHStorage::Kind::TempFile: {
+uint64_t Result;
+if (llvm::sys::fs::file_size(Storage.asFile().getFilePath(), Result))
+  return 0;
+
+assert(Result <= std::numeric_limits::max() &&
+   "file size did not fit into size_t");
+return Result;
+  }
+  }
+  llvm_unreachable("Unhandled storage kind");
+}
+
 bool PrecompiledPreamble::CanReuse(const CompilerInvocation &Invocation,
const llvm::MemoryBuffer *MainFileBuffer,
PreambleBounds Bounds,
@@ -506,8 +527,8 @@ PrecompiledPreamble::TempPCHFile::create
 StringRef Suffix) {
   llvm::SmallString<64> File;
   // Using a version of createTemporaryFile with a file descriptor guarantees
-  // that we would never get a race condition in a multi-threaded setting 
(i.e.,
-  // multiple threads getting the same temporary path).
+  // that we would never get a race condition in a multi-threaded setting
+  // (i.e., multiple threads getting the same temporary path).
   int FD;
   auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, FD, File);
   if (EC)


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


[PATCH] D41456: [clang-tidy] readability-else-after-return: also diagnose noreturn function calls.

2017-12-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D41456#961826, @malcolm.parsons wrote:

> This check could also handle else after goto.


Yes, certainly. Though i'm not too sure on the restrictions.
The obvious precondition is, the label can to be defined anywhere **except** 
after the `goto` in the same (or child) compound statement:

  if(condition) {
goto label:
label: ; // <- false-positive
  } else ...


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41456



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


[clang-tools-extra] r321267 - [clangd] Log more info about preambles

2017-12-21 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Dec 21 06:05:28 2017
New Revision: 321267

URL: http://llvm.org/viewvc/llvm-project?rev=321267&view=rev
Log:
[clangd] Log more info about preambles

Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=321267&r1=321266&r2=321267&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Thu Dec 21 06:05:28 2017
@@ -513,10 +513,13 @@ CppFile::deferRebuild(StringRef NewConte
   ComputePreambleBounds(*CI->getLangOpts(), ContentsBuffer.get(), 0);
   if (OldPreamble && OldPreamble->Preamble.CanReuse(
  *CI, ContentsBuffer.get(), Bounds, VFS.get())) {
+log(Ctx, "Reusing preamble for file " + Twine(That->FileName));
 return OldPreamble;
   }
-  // We won't need the OldPreamble anymore, release it so it can be deleted
-  // (if there are no other references to it).
+  log(Ctx, "Premble for file " + Twine(That->FileName) +
+   " cannot be reused. Attempting to rebuild it.");
+  // We won't need the OldPreamble anymore, release it so it can be
+  // deleted (if there are no other references to it).
   OldPreamble.reset();
 
   trace::Span Tracer(Ctx, "Preamble");
@@ -533,11 +536,16 @@ CppFile::deferRebuild(StringRef NewConte
   SerializedDeclsCollector);
 
   if (BuiltPreamble) {
+log(Ctx, "Built preamble of size " + Twine(BuiltPreamble->getSize()) +
+ " for file " + Twine(That->FileName));
+
 return std::make_shared(
 std::move(*BuiltPreamble),
 SerializedDeclsCollector.takeTopLevelDeclIDs(),
 std::move(PreambleDiags));
   } else {
+log(Ctx,
+"Could not build a preamble for file " + Twine(That->FileName));
 return nullptr;
   }
 };


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


[PATCH] D40705: Diagnose invalid decl-specifiers in non-type template parameter declarations (original author miyuki!)

2017-12-21 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki accepted this revision.
miyuki added a comment.
This revision is now accepted and ready to land.

LGTM, thanks a lot for fixing the patch.


Repository:
  rC Clang

https://reviews.llvm.org/D40705



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


[PATCH] D41444: [ASTImporterTest] Make testing under '-fdelayed-template-parsing' mandatory

2017-12-21 Thread Peter Szecsi via Phabricator via cfe-commits
szepet accepted this revision.
szepet added a comment.

In https://reviews.llvm.org/D41444#961110, @a.sidorin wrote:

> Test both with and without '-fdelayed-template-parsing' in C++ mode.


This solution LGTM as well. 
Just a small nit added inline.




Comment at: unittests/AST/ASTImporterTest.cpp:68
+   const std::string &FromCode, const std::string &ToCode,
+   MatchVerifier &Verifier, const MatcherType &AMatcher) {
   const char *const InputFileName = "input.cc";

Nit: Maybe the order of the parameters could stay similar as the original: 
FromCode, FromArgs, ToCode, ToArgs, Verifier, AMatcher. (Or just Codes before 
Args)

It seems more intuitive to me.


Repository:
  rC Clang

https://reviews.llvm.org/D41444



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


[PATCH] D41483: [clangd] Index symbols share storage within a slab.

2017-12-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Nice, LGTM.




Comment at: clangd/index/Index.h:108
 //
 // FIXME: Use a space-efficient implementation, a lot of Symbol fields could
 // share the same storage.

Do you want to remove this `FIXME` now or later?



Comment at: clangd/index/Index.h:129
 private:
+  void intern(llvm::StringRef &S) {
+S = S.empty() ? llvm::StringRef() : Strings.insert(S).first->getKey();

nit: worth a comment here.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41483



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


[PATCH] D41483: [clangd] Index symbols share storage within a slab.

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added inline comments.



Comment at: clangd/index/Index.h:136
+  // Intern table for strings. Not StringPool as we don't refcount, just 
insert.
+  llvm::StringSet Strings;
   llvm::DenseMap Symbols;

ilya-biryukov wrote:
> A comment on why we use `BumpPtrAllocator` here might be useful.
> I.e., it uses more memory than malloc, but we're getting better data 
> locality. (I hope that I got its intention right)
It's strictly better than malloc for us I think:
 - no malloc bookkeeping/padding memory overhead
 - we make lots of tiny allocations, they're much cheaper in CPU
 - the locality you mentioned
There's no extra memory usage: stringset doesn't use the allocator to allocate 
the hashtable, just the nodes.

Added a comment.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41483



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


[PATCH] D41483: [clangd] Index symbols share storage within a slab.

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 127877.
sammccall marked 4 inline comments as done.
sammccall added a comment.

Comment changes requiested in review.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41483

Files:
  clangd/index/Index.cpp
  clangd/index/Index.h
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/IndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -33,7 +33,7 @@
 // GMock helpers for matching Symbol.
 MATCHER_P(QName, Name, "") {
   return (arg.second.Scope + (arg.second.Scope.empty() ? "" : "::") +
-  arg.second.Name) == Name;
+  arg.second.Name).str() == Name;
 }
 
 namespace clang {
Index: unittests/clangd/IndexTests.cpp
===
--- unittests/clangd/IndexTests.cpp
+++ unittests/clangd/IndexTests.cpp
@@ -75,7 +75,8 @@
   std::vector Matches;
   auto Ctx = Context::empty();
   I.fuzzyFind(Ctx, Req, [&](const Symbol &Sym) {
-Matches.push_back(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name);
+Matches.push_back(
+(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name).str());
   });
   return Matches;
 }
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -93,7 +93,8 @@
   std::vector Matches;
   auto Ctx = Context::empty();
   I.fuzzyFind(Ctx, Req, [&](const Symbol &Sym) {
-Matches.push_back(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name);
+Matches.push_back(
+(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name).str());
   });
   return Matches;
 }
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -15,15 +15,16 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringSet.h"
 #include 
 #include 
 
 namespace clang {
 namespace clangd {
 
 struct SymbolLocation {
   // The absolute path of the source file where a symbol occurs.
-  std::string FilePath;
+  llvm::StringRef FilePath;
   // The 0-based offset to the first character of the symbol from the beginning
   // of the source file.
   unsigned StartOffset;
@@ -71,16 +72,19 @@
 
 // The class presents a C++ symbol, e.g. class, function.
 //
-// FIXME: instead of having own copy fields for each symbol, we can share
-// storage from SymbolSlab.
+// WARNING: Symbols do not own much of their underlying data - typically strings
+// are owned by a SymbolSlab. They should be treated as non-owning references.
+// Copies are shallow.
+// When adding new unowned data fields to Symbol, remember to update
+// SymbolSlab::insert to copy them to the slab's storage.
 struct Symbol {
   // The ID of the symbol.
   SymbolID ID;
   // The unqualified name of the symbol, e.g. "bar" (for "n1::n2::bar").
-  std::string Name;
+  llvm::StringRef Name;
   // The scope (e.g. namespace) of the symbol, e.g. "n1::n2" (for
   // "n1::n2::bar").
-  std::string Scope;
+  llvm::StringRef Scope;
   // The symbol information, like symbol kind.
   index::SymbolInfo SymInfo;
   // The location of the canonical declaration of the symbol.
@@ -100,9 +104,6 @@
 
 // A symbol container that stores a set of symbols. The container will maintain
 // the lifetime of the symbols.
-//
-// FIXME: Use a space-efficient implementation, a lot of Symbol fields could
-// share the same storage.
 class SymbolSlab {
 public:
   using const_iterator = llvm::DenseMap::const_iterator;
@@ -117,11 +118,21 @@
   // operation is irreversible.
   void freeze();
 
-  void insert(Symbol S);
+  // Adds the symbol to this slab.
+  // This is a deep copy: underlying strings will be owned by the slab.
+  void insert(const Symbol& S);
 
 private:
+  // Replaces S with a reference to the same string, owned by this slab.
+  void intern(llvm::StringRef &S) {
+S = S.empty() ? llvm::StringRef() : Strings.insert(S).first->getKey();
+  }
+
   bool Frozen = false;
 
+  // Intern table for strings. Not StringPool as we don't refcount, just insert.
+  // We use BumpPtrAllocator to avoid lots of tiny allocations for nodes.
+  llvm::StringSet Strings;
   llvm::DenseMap Symbols;
 };
 
Index: clangd/index/Index.cpp
===
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -38,9 +38,17 @@
 
 void SymbolSlab::freeze() { Frozen = true; }
 
-void SymbolSlab::insert(Symbol S) {
+void SymbolSlab::insert(const Symbol &S) {
   assert(!Frozen && "Can't insert a symbol after the slab has been frozen!");
-  Symbols[S.ID] = std::move(S);
+  auto ItInserted = Symbols.try_emplace(S.ID, S);

[clang-tools-extra] r321272 - [clangd] Index symbols share storage within a slab.

2017-12-21 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Dec 21 06:58:44 2017
New Revision: 321272

URL: http://llvm.org/viewvc/llvm-project?rev=321272&view=rev
Log:
[clangd] Index symbols share storage within a slab.

Summary:
Symbols are not self-contained - it's only safe to hand them out if you
guarantee the lifetime of the underlying data.

Before this lands, I'm going to measure the before/after memory usage of the
LLVM index loaded into memory in a single slab.

Reviewers: hokein

Subscribers: klimek, ilya-biryukov, cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/index/Index.cpp
clang-tools-extra/trunk/clangd/index/Index.h
clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
clang-tools-extra/trunk/unittests/clangd/IndexTests.cpp
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp

Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=321272&r1=321271&r2=321272&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Thu Dec 21 06:58:44 2017
@@ -38,9 +38,17 @@ SymbolSlab::const_iterator SymbolSlab::f
 
 void SymbolSlab::freeze() { Frozen = true; }
 
-void SymbolSlab::insert(Symbol S) {
+void SymbolSlab::insert(const Symbol &S) {
   assert(!Frozen && "Can't insert a symbol after the slab has been frozen!");
-  Symbols[S.ID] = std::move(S);
+  auto ItInserted = Symbols.try_emplace(S.ID, S);
+  if (!ItInserted.second)
+return;
+  auto &Sym = ItInserted.first->second;
+
+  // We inserted a new symbol, so copy the underlying data.
+  intern(Sym.Name);
+  intern(Sym.Scope);
+  intern(Sym.CanonicalDeclaration.FilePath);
 }
 
 } // namespace clangd

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=321272&r1=321271&r2=321272&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Thu Dec 21 06:58:44 2017
@@ -15,6 +15,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringSet.h"
 #include 
 #include 
 
@@ -23,7 +24,7 @@ namespace clangd {
 
 struct SymbolLocation {
   // The absolute path of the source file where a symbol occurs.
-  std::string FilePath;
+  llvm::StringRef FilePath;
   // The 0-based offset to the first character of the symbol from the beginning
   // of the source file.
   unsigned StartOffset;
@@ -71,16 +72,19 @@ void operator>>(llvm::StringRef HexStr,
 
 // The class presents a C++ symbol, e.g. class, function.
 //
-// FIXME: instead of having own copy fields for each symbol, we can share
-// storage from SymbolSlab.
+// WARNING: Symbols do not own much of their underlying data - typically 
strings
+// are owned by a SymbolSlab. They should be treated as non-owning references.
+// Copies are shallow.
+// When adding new unowned data fields to Symbol, remember to update
+// SymbolSlab::insert to copy them to the slab's storage.
 struct Symbol {
   // The ID of the symbol.
   SymbolID ID;
   // The unqualified name of the symbol, e.g. "bar" (for "n1::n2::bar").
-  std::string Name;
+  llvm::StringRef Name;
   // The scope (e.g. namespace) of the symbol, e.g. "n1::n2" (for
   // "n1::n2::bar").
-  std::string Scope;
+  llvm::StringRef Scope;
   // The symbol information, like symbol kind.
   index::SymbolInfo SymInfo;
   // The location of the canonical declaration of the symbol.
@@ -100,9 +104,6 @@ struct Symbol {
 
 // A symbol container that stores a set of symbols. The container will maintain
 // the lifetime of the symbols.
-//
-// FIXME: Use a space-efficient implementation, a lot of Symbol fields could
-// share the same storage.
 class SymbolSlab {
 public:
   using const_iterator = llvm::DenseMap::const_iterator;
@@ -117,11 +118,21 @@ public:
   // operation is irreversible.
   void freeze();
 
-  void insert(Symbol S);
+  // Adds the symbol to this slab.
+  // This is a deep copy: underlying strings will be owned by the slab.
+  void insert(const Symbol& S);
 
 private:
+  // Replaces S with a reference to the same string, owned by this slab.
+  void intern(llvm::StringRef &S) {
+S = S.empty() ? llvm::StringRef() : Strings.insert(S).first->getKey();
+  }
+
   bool Frozen = false;
 
+  // Intern table for strings. Not StringPool as we don't refcount, just 
insert.
+  // We use BumpPtrAllocator to avoid lots of tiny allocations for nodes.
+  llvm::StringSet Strings;
   llvm::DenseMap Symbols;
 };
 

Modified: clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FileIndexT

[PATCH] D41483: [clangd] Index symbols share storage within a slab.

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE321272: [clangd] Index symbols share storage within a 
slab. (authored by sammccall, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41483?vs=127877&id=127879#toc

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41483

Files:
  clangd/index/Index.cpp
  clangd/index/Index.h
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/IndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -93,7 +93,8 @@
   std::vector Matches;
   auto Ctx = Context::empty();
   I.fuzzyFind(Ctx, Req, [&](const Symbol &Sym) {
-Matches.push_back(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name);
+Matches.push_back(
+(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name).str());
   });
   return Matches;
 }
Index: unittests/clangd/IndexTests.cpp
===
--- unittests/clangd/IndexTests.cpp
+++ unittests/clangd/IndexTests.cpp
@@ -75,7 +75,8 @@
   std::vector Matches;
   auto Ctx = Context::empty();
   I.fuzzyFind(Ctx, Req, [&](const Symbol &Sym) {
-Matches.push_back(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name);
+Matches.push_back(
+(Sym.Scope + (Sym.Scope.empty() ? "" : "::") + Sym.Name).str());
   });
   return Matches;
 }
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -33,7 +33,7 @@
 // GMock helpers for matching Symbol.
 MATCHER_P(QName, Name, "") {
   return (arg.second.Scope + (arg.second.Scope.empty() ? "" : "::") +
-  arg.second.Name) == Name;
+  arg.second.Name).str() == Name;
 }
 
 namespace clang {
Index: clangd/index/Index.h
===
--- clangd/index/Index.h
+++ clangd/index/Index.h
@@ -15,15 +15,16 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringSet.h"
 #include 
 #include 
 
 namespace clang {
 namespace clangd {
 
 struct SymbolLocation {
   // The absolute path of the source file where a symbol occurs.
-  std::string FilePath;
+  llvm::StringRef FilePath;
   // The 0-based offset to the first character of the symbol from the beginning
   // of the source file.
   unsigned StartOffset;
@@ -71,16 +72,19 @@
 
 // The class presents a C++ symbol, e.g. class, function.
 //
-// FIXME: instead of having own copy fields for each symbol, we can share
-// storage from SymbolSlab.
+// WARNING: Symbols do not own much of their underlying data - typically strings
+// are owned by a SymbolSlab. They should be treated as non-owning references.
+// Copies are shallow.
+// When adding new unowned data fields to Symbol, remember to update
+// SymbolSlab::insert to copy them to the slab's storage.
 struct Symbol {
   // The ID of the symbol.
   SymbolID ID;
   // The unqualified name of the symbol, e.g. "bar" (for "n1::n2::bar").
-  std::string Name;
+  llvm::StringRef Name;
   // The scope (e.g. namespace) of the symbol, e.g. "n1::n2" (for
   // "n1::n2::bar").
-  std::string Scope;
+  llvm::StringRef Scope;
   // The symbol information, like symbol kind.
   index::SymbolInfo SymInfo;
   // The location of the canonical declaration of the symbol.
@@ -100,9 +104,6 @@
 
 // A symbol container that stores a set of symbols. The container will maintain
 // the lifetime of the symbols.
-//
-// FIXME: Use a space-efficient implementation, a lot of Symbol fields could
-// share the same storage.
 class SymbolSlab {
 public:
   using const_iterator = llvm::DenseMap::const_iterator;
@@ -117,11 +118,21 @@
   // operation is irreversible.
   void freeze();
 
-  void insert(Symbol S);
+  // Adds the symbol to this slab.
+  // This is a deep copy: underlying strings will be owned by the slab.
+  void insert(const Symbol& S);
 
 private:
+  // Replaces S with a reference to the same string, owned by this slab.
+  void intern(llvm::StringRef &S) {
+S = S.empty() ? llvm::StringRef() : Strings.insert(S).first->getKey();
+  }
+
   bool Frozen = false;
 
+  // Intern table for strings. Not StringPool as we don't refcount, just insert.
+  // We use BumpPtrAllocator to avoid lots of tiny allocations for nodes.
+  llvm::StringSet Strings;
   llvm::DenseMap Symbols;
 };
 
Index: clangd/index/Index.cpp
===
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -38,9 +38,17 @@
 
 void SymbolSlab::freeze() { Frozen = true; }
 
-void SymbolSlab::insert(Symbol S) {
+void SymbolSlab::insert(const Symbol &S) {
   assert(!Frozen && "Can't insert a symb

[PATCH] D41487: [clang-format] Adds a FormatStyleSet

2017-12-21 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added inline comments.



Comment at: lib/Format/Format.cpp:893
   for (int i = Styles.size() - 1; i >= 0; --i) {
-if (Styles[i].Language == Language ||
-Styles[i].Language == FormatStyle::LK_None) {
+if (!LanguageFound && (Styles[i].Language == Language ||
+   Styles[i].Language == FormatStyle::LK_None)) {

LanguageFound can't be true here.



Comment at: lib/Format/Format.cpp:903-907
+  for (int i = Styles.size() - 1; i >= 0; --i) {
+if (Styles[i].Language != FormatStyle::LK_None) {
+  Style->AddLanguageStyle(Styles[i]);
 }
   }

This seems a bit backwards. I'd have expected us to build up a Style structure 
after parsing above, and then just copy that into the result in the end.


Repository:
  rC Clang

https://reviews.llvm.org/D41487



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


[PATCH] D41487: [clang-format] Adds a FormatStyleSet

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



Comment at: lib/Format/Format.cpp:903-907
+  for (int i = Styles.size() - 1; i >= 0; --i) {
+if (Styles[i].Language != FormatStyle::LK_None) {
+  Style->AddLanguageStyle(Styles[i]);
 }
   }

klimek wrote:
> This seems a bit backwards. I'd have expected us to build up a Style 
> structure after parsing above, and then just copy that into the result in the 
> end.
Do you mean to build up a StyleSet structure?


Repository:
  rC Clang

https://reviews.llvm.org/D41487



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


[PATCH] D39239: [AST] Incorrectly qualified unscoped enumeration as template actual parameter.

2017-12-21 Thread Carlos Alberto Enciso via Phabricator via cfe-commits
CarlosAlbertoEnciso added a comment.

In https://reviews.llvm.org/D39239#961367, @probinson wrote:

> With the GDB test results and LLDB able to handle it, this LGTM.
>  Carlos, do you have commit access?


Hi Paul,

Thanks for the LGTM.

I do not have commit access.


https://reviews.llvm.org/D39239



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


[PATCH] D41491: [clangd] Add a tool to build YAML-format global symbols.

2017-12-21 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: ilya-biryukov, mgorny, klimek.

The tools is used to generate global symbols for clangd (global code 
completion),
The format is YAML, which is only for **experiment**.

TEST: used the tool to generate global symbols for LLVM (~72MB).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41491

Files:
  clangd/CMakeLists.txt
  clangd/global-symbol-builder/CMakeLists.txt
  clangd/global-symbol-builder/GlobalSymbolBuilderMain.cpp
  clangd/global-symbol-builder/run-global-symbol-builder.py
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h

Index: clangd/index/SymbolCollector.h
===
--- clangd/index/SymbolCollector.h
+++ clangd/index/SymbolCollector.h
@@ -10,6 +10,7 @@
 #include "Index.h"
 #include "clang/Index/IndexDataConsumer.h"
 #include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/SmallPtrSet.h"
 
 namespace clang {
 namespace clangd {
@@ -21,8 +22,24 @@
 // changed.
 class SymbolCollector : public index::IndexDataConsumer {
 public:
+  // Callback to get AST/Symbol information when collecting symbols.
+  class SymbolCallback {
+  public:
+virtual ~SymbolCallback() = default;
+// Called when SymbolCollector finish collecting all symbols.
+// Note: Symbols is a immutable object.
+virtual void onFinish(const ASTContext &ASTCtx, const SymbolSlab &Symbols) {
+}
+  };
+
   SymbolCollector() = default;
 
+  void addSymbolCallback(SymbolCallback* Callback) {
+AllCallbacks.insert(Callback);
+  }
+
+  void initialize(ASTContext &Ctx) override;
+
   bool
   handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
   ArrayRef Relations, FileID FID,
@@ -36,6 +53,11 @@
 private:
   // All Symbols collected from the AST.
   SymbolSlab Symbols;
+
+  ASTContext *ASTCtx;
+
+  // All symbol callbacks.
+  llvm::SmallPtrSet AllCallbacks;
 };
 
 } // namespace clangd
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -107,7 +107,15 @@
   return true;
 }
 
-void SymbolCollector::finish() { Symbols.freeze(); }
+void SymbolCollector::initialize(ASTContext &Ctx) {
+  ASTCtx = &Ctx;
+}
+
+void SymbolCollector::finish() {
+  Symbols.freeze();
+  for (auto *CB : AllCallbacks)
+CB->onFinish(*ASTCtx, Symbols);
+}
 
 } // namespace clangd
 } // namespace clang
Index: clangd/global-symbol-builder/run-global-symbol-builder.py
===
--- /dev/null
+++ clangd/global-symbol-builder/run-global-symbol-builder.py
@@ -0,0 +1,125 @@
+#!/usr/bin/env python
+#
+#=- run-global-symbol-builder.py ---*- python  -*-=#
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#======#
+
+"""
+Parallel global-symbol-builder runner
+
+
+Runs global-symbol-builder over all files in a compilation database.
+
+Example invocations.
+- Run global-symbol-builder on all files in the current working directory.
+run-global-symbol-builder.py 
+
+Compilation database setup:
+http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
+"""
+
+import argparse
+import json
+import multiprocessing
+import os
+import Queue
+import shutil
+import subprocess
+import sys
+import tempfile
+import threading
+
+
+def find_compilation_database(path):
+  """Adjusts the directory until a compilation database is found."""
+  result = './'
+  while not os.path.isfile(os.path.join(result, path)):
+if os.path.realpath(result) == '/':
+  print 'Error: could not find compilation database.'
+  sys.exit(1)
+result += '../'
+  return os.path.realpath(result)
+
+
+def MergeSymbols(directory, args):
+  """Merge all symbol files (yaml) in a given directory into a single file."""
+  invocation = [args.binary, '-merge-dir='+directory, args.saving_path]
+  subprocess.call(invocation)
+  print 'Merge is finished. Saving results in ' + args.saving_path
+
+
+def run_global_symbol_builder(args, tmpdir, build_path, queue):
+  """Takes filenames out of queue and runs global-symbol-builder on them."""
+  while True:
+name = queue.get()
+invocation = [args.binary, name, '-output-dir='+tmpdir, '-p='+build_path]
+sys.stdout.write(' '.join(invocation) + '\n')
+subprocess.call(invocation)
+queue.task_done()
+
+
+def main():
+  parser = argparse.ArgumentParser(description='Runs global-symbol-builder over'
+   ' all files in a compilation database.')
+  parser.add_argument('-binary', metavar='PATH',
+  default='./bin/global-symbol-builder'

[PATCH] D41492: [Frontend] Correctly handle instantiating ctors with skipped bodies

2017-12-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: sepavloff, klimek.

Previsouly clang tried instantiating member initializers even if ctor
body was skipped, this caused spurious errors (see the test).


Repository:
  rC Clang

https://reviews.llvm.org/D41492

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/Index/skipped-bodies-ctors.cpp


Index: test/Index/skipped-bodies-ctors.cpp
===
--- /dev/null
+++ test/Index/skipped-bodies-ctors.cpp
@@ -0,0 +1,16 @@
+// RUN: env CINDEXTEST_SKIP_FUNCTION_BODIES=1 c-index-test -test-load-source 
all %s 2>&1 \
+// RUN: | FileCheck --implicit-check-not "error:" %s
+
+
+template 
+struct Foo {
+  template 
+  Foo(int &a) : a(a) {
+  }
+
+  int &a;
+};
+
+
+int bar = Foo(bar).a + Foo(bar).a;
+// CHECK-NOT: error: constructor for 'Foo' must explicitly initialize the 
reference
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3928,22 +3928,22 @@
  TemplateArgs))
   return;
 
-if (CXXConstructorDecl *Ctor = dyn_cast(Function)) {
-  // If this is a constructor, instantiate the member initializers.
-  InstantiateMemInitializers(Ctor, cast(PatternDecl),
- TemplateArgs);
-
-  // If this is an MS ABI dllexport default constructor, instantiate any
-  // default arguments.
-  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
-  Ctor->isDefaultConstructor()) {
-InstantiateDefaultCtorDefaultArgs(*this, Ctor);
-  }
-}
-
 if (PatternDecl->hasSkippedBody()) {
   ActOnSkippedFunctionBody(Function);
 } else {
+  if (CXXConstructorDecl *Ctor = dyn_cast(Function)) {
+// If this is a constructor, instantiate the member initializers.
+InstantiateMemInitializers(Ctor, cast(PatternDecl),
+   TemplateArgs);
+
+// If this is an MS ABI dllexport default constructor, instantiate any
+// default arguments.
+if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+Ctor->isDefaultConstructor()) {
+  InstantiateDefaultCtorDefaultArgs(*this, Ctor);
+}
+  }
+
   // Instantiate the function body.
   StmtResult Body = SubstStmt(Pattern, TemplateArgs);
 


Index: test/Index/skipped-bodies-ctors.cpp
===
--- /dev/null
+++ test/Index/skipped-bodies-ctors.cpp
@@ -0,0 +1,16 @@
+// RUN: env CINDEXTEST_SKIP_FUNCTION_BODIES=1 c-index-test -test-load-source all %s 2>&1 \
+// RUN: | FileCheck --implicit-check-not "error:" %s
+
+
+template 
+struct Foo {
+  template 
+  Foo(int &a) : a(a) {
+  }
+
+  int &a;
+};
+
+
+int bar = Foo(bar).a + Foo(bar).a;
+// CHECK-NOT: error: constructor for 'Foo' must explicitly initialize the reference
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3928,22 +3928,22 @@
  TemplateArgs))
   return;
 
-if (CXXConstructorDecl *Ctor = dyn_cast(Function)) {
-  // If this is a constructor, instantiate the member initializers.
-  InstantiateMemInitializers(Ctor, cast(PatternDecl),
- TemplateArgs);
-
-  // If this is an MS ABI dllexport default constructor, instantiate any
-  // default arguments.
-  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
-  Ctor->isDefaultConstructor()) {
-InstantiateDefaultCtorDefaultArgs(*this, Ctor);
-  }
-}
-
 if (PatternDecl->hasSkippedBody()) {
   ActOnSkippedFunctionBody(Function);
 } else {
+  if (CXXConstructorDecl *Ctor = dyn_cast(Function)) {
+// If this is a constructor, instantiate the member initializers.
+InstantiateMemInitializers(Ctor, cast(PatternDecl),
+   TemplateArgs);
+
+// If this is an MS ABI dllexport default constructor, instantiate any
+// default arguments.
+if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+Ctor->isDefaultConstructor()) {
+  InstantiateDefaultCtorDefaultArgs(*this, Ctor);
+}
+  }
+
   // Instantiate the function body.
   StmtResult Body = SubstStmt(Pattern, TemplateArgs);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38639: [clangd] #include statements support for Open definition

2017-12-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/XRefs.cpp:183
+  unsigned CharNumber = SourceMgr.getSpellingColumnNumber(
+  DeclMacrosFinder->getSearchedLocation());
+

ilya-biryukov wrote:
> Replace with `DeclMacrosFinder->getSearchedLocation()` `SourceLocationBeg`, 
> it makes the code easier to read.
Sorry, the comment got messed up. Here's the correct version:

Replace `DeclMacrosFinder->getSearchedLocation()` with `SourceLocationBeg`, it 
makes the code easier to read.




Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38639



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


[PATCH] D41487: [clang-format] Adds a FormatStyleSet

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

- Address review comments


Repository:
  rC Clang

https://reviews.llvm.org/D41487

Files:
  ;
  include/clang/Format/Format.h
  lib/Format/Format.cpp

Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -1685,6 +1685,36 @@
Standard == R.Standard && TabWidth == R.TabWidth &&
UseTab == R.UseTab;
   }
+
+  llvm::Optional GetLanguageStyle(LanguageKind Language) const;
+
+  // Stores per-language styles. A FormatStyle instance inside has an empty
+  // StyleSet. A FormatStyle instance returned by the Get method has its
+  // StyleSet set to a copy of the originating StyleSet, effectively keeping the
+  // internal representation of that StyleSet alive.
+  //
+  // The memory management and ownership reminds of a birds nest: chicks
+  // leaving the nest take photos of the nest with them.
+  struct FormatStyleSet {
+typedef std::map>
+MapType;
+
+llvm::Optional Get(FormatStyle::LanguageKind Language) const;
+void Add(FormatStyle Style);
+
+  private:
+std::shared_ptr Styles;
+  };
+
+  static FormatStyleSet BuildStyleSetFromConfiguration(
+  const FormatStyle &MainStyle,
+  const std::vector &ConfigurationStyles);
+
+private:
+  FormatStyleSet StyleSet;
+
+  friend std::error_code parseConfiguration(StringRef Text, FormatStyle *Style);
 };
 
 /// \brief Returns a format style complying with the LLVM coding standards:
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -853,6 +853,20 @@
   return true;
 }
 
+FormatStyle::FormatStyleSet FormatStyle::BuildStyleSetFromConfiguration(
+const FormatStyle &MainStyle,
+const std::vector &ConfigurationStyles) {
+  FormatStyleSet StyleSet;
+  StyleSet.Add(MainStyle);
+  for (size_t i = 0; i < ConfigurationStyles.size(); ++i) {
+if (ConfigurationStyles[i].Language != FormatStyle::LK_None &&
+ConfigurationStyles[i].Language != MainStyle.Language) {
+  StyleSet.Add(ConfigurationStyles[i]);
+}
+  }
+  return StyleSet;
+}
+
 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style) {
   assert(Style);
   FormatStyle::LanguageKind Language = Style->Language;
@@ -888,15 +902,20 @@
   // Look for a suitable configuration starting from the end, so we can
   // find the configuration for the specific language first, and the default
   // configuration (which can only be at slot 0) after it.
+  bool LanguageFound = false;
   for (int i = Styles.size() - 1; i >= 0; --i) {
 if (Styles[i].Language == Language ||
 Styles[i].Language == FormatStyle::LK_None) {
   *Style = Styles[i];
   Style->Language = Language;
-  return make_error_code(ParseError::Success);
+  LanguageFound = true;
+  break;
 }
   }
-  return make_error_code(ParseError::Unsuitable);
+  if (!LanguageFound)
+return make_error_code(ParseError::Unsuitable);
+  Style->StyleSet = FormatStyle::BuildStyleSetFromConfiguration(*Style, Styles);
+  return make_error_code(ParseError::Success);
 }
 
 std::string configurationAsText(const FormatStyle &Style) {
@@ -910,6 +929,30 @@
   return Stream.str();
 }
 
+llvm::Optional
+FormatStyle::FormatStyleSet::Get(FormatStyle::LanguageKind Language) const {
+  if (!Styles)
+return None;
+  auto It = Styles->find(Language);
+  if (It == Styles->end())
+return None;
+  FormatStyle Style = *It->second;
+  Style.StyleSet = *this;
+  return Style;
+}
+
+void FormatStyle::FormatStyleSet::Add(FormatStyle Style) {
+  Style.StyleSet.Styles.reset();
+  if (!Styles)
+Styles = std::make_shared();
+  (*Styles)[Style.Language].reset(new FormatStyle(Style));
+}
+
+llvm::Optional
+FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind Language) const {
+  return StyleSet.Get(Language);
+}
+
 namespace {
 
 class JavaScriptRequoter : public TokenAnalyzer {
Index: ;
===
--- ;
+++ ;
@@ -853,6 +853,20 @@
   return true;
 }
 
+FormatStyle::FormatStyleSet FormatStyle::BuildStyleSetFromConfiguration(
+const FormatStyle &MainStyle,
+const std::vector &ConfigurationStyles) {
+  FormatStyleSet Styles;
+  Styles.Add(MainStyle);
+  for (int i = 0; i < ConfigurationStyles.size(); ++i) {
+if (Styles[i].Language != FormatStyle::LK_None &&
+Styles[i].Language != MainStyle.Language) {
+  Styles.Add(Styles[i]);
+}
+  }
+  return Styles;
+}
+
 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style) {
   assert(Style);
   FormatStyle::LanguageKind Language = Style->Language;
@@ -888,15 +902,21 @@
   // Look for a suitable configuration starting from the end, so we can
   // find the configuration for the specific language first, and the default
   // configuration (which can onl

Re: r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-21 Thread Martin Böhme via cfe-commits
This is causing problems in some internal builds that specify both
-mios-simulator-version-min=9.0 and --target=x86_64-apple-ios

My expectation would be for the code to take the minimum OS version number
from the -mios-simulator-version-min flag. In fact, however, the code seems
to be completely ignoring this flag.

Is my expectation wrong or does the code need to be modified to take this
situation into account?


On 19 December 2017 at 20:05, Alex Lorenz via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: arphaman
> Date: Tue Dec 19 11:05:04 2017
> New Revision: 321099
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321099&view=rev
> Log:
> [driver][darwin] Take the OS version specified in "-target" as the target
> OS instead of inferring it from SDK / environment
>
> The OS version is specified in -target should be used instead of the one
> in an
> environment variable / SDK name.
>
> rdar://35813850
>
> Differential Revision: https://reviews.llvm.org/D40998
>
> Modified:
> cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
> cfe/trunk/test/Driver/darwin-version.c
> cfe/trunk/test/Driver/objc-weak.m
> cfe/trunk/test/Driver/pic.c
> cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> ToolChains/Darwin.cpp?rev=321099&r1=321098&r2=321099&view=diff
> 
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Dec 19 11:05:04 2017
> @@ -1233,6 +1233,10 @@ struct DarwinPlatform {
>  llvm_unreachable("Unsupported Darwin Source Kind");
>}
>
> +  static DarwinPlatform createFromTarget(llvm::Triple::OSType OS,
> + StringRef OSVersion, Arg *A) {
> +return DarwinPlatform(TargetArg, getPlatformFromOS(OS), OSVersion, A);
> +  }
>static DarwinPlatform createOSVersionArg(DarwinPlatformKind Platform,
> Arg *A) {
>  return DarwinPlatform(OSVersionArg, Platform, A);
> @@ -1250,33 +1254,32 @@ struct DarwinPlatform {
>}
>static DarwinPlatform createFromArch(llvm::Triple::OSType OS,
> StringRef Value) {
> -DarwinPlatformKind Platform;
> +return DarwinPlatform(InferredFromArch, getPlatformFromOS(OS),
> Value);
> +  }
> +
> +private:
> +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, Arg
> *Argument)
> +  : Kind(Kind), Platform(Platform), Argument(Argument) {}
> +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, StringRef
> Value,
> + Arg *Argument = nullptr)
> +  : Kind(Kind), Platform(Platform), OSVersion(Value),
> Argument(Argument) {}
> +
> +  static DarwinPlatformKind getPlatformFromOS(llvm::Triple::OSType OS) {
>  switch (OS) {
>  case llvm::Triple::Darwin:
>  case llvm::Triple::MacOSX:
> -  Platform = DarwinPlatformKind::MacOS;
> -  break;
> +  return DarwinPlatformKind::MacOS;
>  case llvm::Triple::IOS:
> -  Platform = DarwinPlatformKind::IPhoneOS;
> -  break;
> +  return DarwinPlatformKind::IPhoneOS;
>  case llvm::Triple::TvOS:
> -  Platform = DarwinPlatformKind::TvOS;
> -  break;
> +  return DarwinPlatformKind::TvOS;
>  case llvm::Triple::WatchOS:
> -  Platform = DarwinPlatformKind::WatchOS;
> -  break;
> +  return DarwinPlatformKind::WatchOS;
>  default:
>llvm_unreachable("Unable to infer Darwin variant");
>  }
> -return DarwinPlatform(InferredFromArch, Platform, Value);
>}
>
> -private:
> -  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, Arg
> *Argument)
> -  : Kind(Kind), Platform(Platform), Argument(Argument) {}
> -  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, StringRef
> Value)
> -  : Kind(Kind), Platform(Platform), OSVersion(Value),
> Argument(nullptr) {}
> -
>SourceKind Kind;
>DarwinPlatformKind Platform;
>std::string OSVersion;
> @@ -1449,20 +1452,15 @@ inferDeploymentTargetFromArch(DerivedArg
>const Driver &TheDriver) {
>llvm::Triple::OSType OSTy = llvm::Triple::UnknownOS;
>
> -  // Set the OSTy based on -target if -arch isn't present.
> -  if (Args.hasArg(options::OPT_target) && !Args.hasArg(options::OPT_arch))
> {
> -OSTy = Triple.getOS();
> -  } else {
> -StringRef MachOArchName = Toolchain.getMachOArchName(Args);
> -if (MachOArchName == "armv7" || MachOArchName == "armv7s" ||
> -MachOArchName == "arm64")
> -  OSTy = llvm::Triple::IOS;
> -else if (MachOArchName == "armv7k")
> -  OSTy = llvm::Triple::WatchOS;
> -else if (MachOArchName != "armv6m" && MachOArchName != "armv7m" &&
> - MachOArchName != "armv7em")
> -  OSTy = llvm::Triple::MacOSX;
> -  }
> +  StringRef MachOArchName = Toolc

[PATCH] D41487: [clang-format] Adds a FormatStyleSet

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

- Remove accidentally created file


Repository:
  rC Clang

https://reviews.llvm.org/D41487

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp

Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -853,6 +853,20 @@
   return true;
 }
 
+FormatStyle::FormatStyleSet FormatStyle::BuildStyleSetFromConfiguration(
+const FormatStyle &MainStyle,
+const std::vector &ConfigurationStyles) {
+  FormatStyleSet StyleSet;
+  StyleSet.Add(MainStyle);
+  for (size_t i = 0; i < ConfigurationStyles.size(); ++i) {
+if (ConfigurationStyles[i].Language != FormatStyle::LK_None &&
+ConfigurationStyles[i].Language != MainStyle.Language) {
+  StyleSet.Add(ConfigurationStyles[i]);
+}
+  }
+  return StyleSet;
+}
+
 std::error_code parseConfiguration(StringRef Text, FormatStyle *Style) {
   assert(Style);
   FormatStyle::LanguageKind Language = Style->Language;
@@ -888,15 +902,20 @@
   // Look for a suitable configuration starting from the end, so we can
   // find the configuration for the specific language first, and the default
   // configuration (which can only be at slot 0) after it.
+  bool LanguageFound = false;
   for (int i = Styles.size() - 1; i >= 0; --i) {
 if (Styles[i].Language == Language ||
 Styles[i].Language == FormatStyle::LK_None) {
   *Style = Styles[i];
   Style->Language = Language;
-  return make_error_code(ParseError::Success);
+  LanguageFound = true;
+  break;
 }
   }
-  return make_error_code(ParseError::Unsuitable);
+  if (!LanguageFound)
+return make_error_code(ParseError::Unsuitable);
+  Style->StyleSet = FormatStyle::BuildStyleSetFromConfiguration(*Style, Styles);
+  return make_error_code(ParseError::Success);
 }
 
 std::string configurationAsText(const FormatStyle &Style) {
@@ -910,6 +929,30 @@
   return Stream.str();
 }
 
+llvm::Optional
+FormatStyle::FormatStyleSet::Get(FormatStyle::LanguageKind Language) const {
+  if (!Styles)
+return None;
+  auto It = Styles->find(Language);
+  if (It == Styles->end())
+return None;
+  FormatStyle Style = *It->second;
+  Style.StyleSet = *this;
+  return Style;
+}
+
+void FormatStyle::FormatStyleSet::Add(FormatStyle Style) {
+  Style.StyleSet.Styles.reset();
+  if (!Styles)
+Styles = std::make_shared();
+  (*Styles)[Style.Language].reset(new FormatStyle(Style));
+}
+
+llvm::Optional
+FormatStyle::GetLanguageStyle(FormatStyle::LanguageKind Language) const {
+  return StyleSet.Get(Language);
+}
+
 namespace {
 
 class JavaScriptRequoter : public TokenAnalyzer {
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -1685,6 +1685,36 @@
Standard == R.Standard && TabWidth == R.TabWidth &&
UseTab == R.UseTab;
   }
+
+  llvm::Optional GetLanguageStyle(LanguageKind Language) const;
+
+  // Stores per-language styles. A FormatStyle instance inside has an empty
+  // StyleSet. A FormatStyle instance returned by the Get method has its
+  // StyleSet set to a copy of the originating StyleSet, effectively keeping the
+  // internal representation of that StyleSet alive.
+  //
+  // The memory management and ownership reminds of a birds nest: chicks
+  // leaving the nest take photos of the nest with them.
+  struct FormatStyleSet {
+typedef std::map>
+MapType;
+
+llvm::Optional Get(FormatStyle::LanguageKind Language) const;
+void Add(FormatStyle Style);
+
+  private:
+std::shared_ptr Styles;
+  };
+
+  static FormatStyleSet BuildStyleSetFromConfiguration(
+  const FormatStyle &MainStyle,
+  const std::vector &ConfigurationStyles);
+
+private:
+  FormatStyleSet StyleSet;
+
+  friend std::error_code parseConfiguration(StringRef Text, FormatStyle *Style);
 };
 
 /// \brief Returns a format style complying with the LLVM coding standards:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-21 Thread James Y Knight via cfe-commits
I think if a version number isn't explicitly specified in the -target
value, the value from -m-version-min ought to still be used, as
it was before.

Currently, clang will ignore the -m-version-min version number if
the target has a particular OS specified, even if it has no version number
as part of it.

(We should be able to workaround this change backwards-compatibly by
specifying in both the -target argument and in the -m-version-min
arguments, but I do think the behavior should be fixed.)

On Thu, Dec 21, 2017 at 10:45 AM, Martin Böhme  wrote:

> This is causing problems in some internal builds that specify both
> -mios-simulator-version-min=9.0 and --target=x86_64-apple-ios
>
> My expectation would be for the code to take the minimum OS version number
> from the -mios-simulator-version-min flag. In fact, however, the code seems
> to be completely ignoring this flag.
>
> Is my expectation wrong or does the code need to be modified to take this
> situation into account?
>
>
> On 19 December 2017 at 20:05, Alex Lorenz via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: arphaman
>> Date: Tue Dec 19 11:05:04 2017
>> New Revision: 321099
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=321099&view=rev
>> Log:
>> [driver][darwin] Take the OS version specified in "-target" as the target
>> OS instead of inferring it from SDK / environment
>>
>> The OS version is specified in -target should be used instead of the one
>> in an
>> environment variable / SDK name.
>>
>> rdar://35813850
>>
>> Differential Revision: https://reviews.llvm.org/D40998
>>
>> Modified:
>> cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>> cfe/trunk/test/Driver/darwin-version.c
>> cfe/trunk/test/Driver/objc-weak.m
>> cfe/trunk/test/Driver/pic.c
>> cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
>> lChains/Darwin.cpp?rev=321099&r1=321098&r2=321099&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Dec 19 11:05:04 2017
>> @@ -1233,6 +1233,10 @@ struct DarwinPlatform {
>>  llvm_unreachable("Unsupported Darwin Source Kind");
>>}
>>
>> +  static DarwinPlatform createFromTarget(llvm::Triple::OSType OS,
>> + StringRef OSVersion, Arg *A) {
>> +return DarwinPlatform(TargetArg, getPlatformFromOS(OS), OSVersion,
>> A);
>> +  }
>>static DarwinPlatform createOSVersionArg(DarwinPlatformKind Platform,
>> Arg *A) {
>>  return DarwinPlatform(OSVersionArg, Platform, A);
>> @@ -1250,33 +1254,32 @@ struct DarwinPlatform {
>>}
>>static DarwinPlatform createFromArch(llvm::Triple::OSType OS,
>> StringRef Value) {
>> -DarwinPlatformKind Platform;
>> +return DarwinPlatform(InferredFromArch, getPlatformFromOS(OS),
>> Value);
>> +  }
>> +
>> +private:
>> +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, Arg
>> *Argument)
>> +  : Kind(Kind), Platform(Platform), Argument(Argument) {}
>> +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, StringRef
>> Value,
>> + Arg *Argument = nullptr)
>> +  : Kind(Kind), Platform(Platform), OSVersion(Value),
>> Argument(Argument) {}
>> +
>> +  static DarwinPlatformKind getPlatformFromOS(llvm::Triple::OSType OS) {
>>  switch (OS) {
>>  case llvm::Triple::Darwin:
>>  case llvm::Triple::MacOSX:
>> -  Platform = DarwinPlatformKind::MacOS;
>> -  break;
>> +  return DarwinPlatformKind::MacOS;
>>  case llvm::Triple::IOS:
>> -  Platform = DarwinPlatformKind::IPhoneOS;
>> -  break;
>> +  return DarwinPlatformKind::IPhoneOS;
>>  case llvm::Triple::TvOS:
>> -  Platform = DarwinPlatformKind::TvOS;
>> -  break;
>> +  return DarwinPlatformKind::TvOS;
>>  case llvm::Triple::WatchOS:
>> -  Platform = DarwinPlatformKind::WatchOS;
>> -  break;
>> +  return DarwinPlatformKind::WatchOS;
>>  default:
>>llvm_unreachable("Unable to infer Darwin variant");
>>  }
>> -return DarwinPlatform(InferredFromArch, Platform, Value);
>>}
>>
>> -private:
>> -  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, Arg
>> *Argument)
>> -  : Kind(Kind), Platform(Platform), Argument(Argument) {}
>> -  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, StringRef
>> Value)
>> -  : Kind(Kind), Platform(Platform), OSVersion(Value),
>> Argument(nullptr) {}
>> -
>>SourceKind Kind;
>>DarwinPlatformKind Platform;
>>std::string OSVersion;
>> @@ -1449,20 +1452,15 @@ inferDeploymentTargetFromArch(DerivedArg
>>const Driver &TheDriver) {
>>llvm::Triple::OSType OSTy = llvm::Triple::Unknow

[PATCH] D41495: [clangd] Skip function bodies when building the preamble

2017-12-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: sammccall.
Herald added a subscriber: klimek.

To make building preambles faster and keep them smaller.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41495

Files:
  clangd/ClangdUnit.cpp


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -529,12 +529,22 @@
   IntrusiveRefCntPtr PreambleDiagsEngine =
   CompilerInstance::createDiagnostics(
   &CI->getDiagnosticOpts(), &PreambleDiagnosticsConsumer, false);
+
+  // Skip function bodies when building the preamble to speed up building
+  // the preamble and make it smaller. CI is later reused to build the AST,
+  // so we set SkipFunctionBodies back to false after preamble is built.
+  assert(!CI->getFrontendOpts().SkipFunctionBodies);
+  CI->getFrontendOpts().SkipFunctionBodies = true;
+
   CppFilePreambleCallbacks SerializedDeclsCollector;
   auto BuiltPreamble = PrecompiledPreamble::Build(
   *CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine, VFS, PCHs,
   /*StoreInMemory=*/That->StorePreamblesInMemory,
   SerializedDeclsCollector);
 
+  // Preamble is built, restore SkipFunctionBodies.
+  CI->getFrontendOpts().SkipFunctionBodies = false;
+
   if (BuiltPreamble) {
 log(Ctx, "Built preamble of size " + Twine(BuiltPreamble->getSize()) +
  " for file " + Twine(That->FileName));


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -529,12 +529,22 @@
   IntrusiveRefCntPtr PreambleDiagsEngine =
   CompilerInstance::createDiagnostics(
   &CI->getDiagnosticOpts(), &PreambleDiagnosticsConsumer, false);
+
+  // Skip function bodies when building the preamble to speed up building
+  // the preamble and make it smaller. CI is later reused to build the AST,
+  // so we set SkipFunctionBodies back to false after preamble is built.
+  assert(!CI->getFrontendOpts().SkipFunctionBodies);
+  CI->getFrontendOpts().SkipFunctionBodies = true;
+
   CppFilePreambleCallbacks SerializedDeclsCollector;
   auto BuiltPreamble = PrecompiledPreamble::Build(
   *CI, ContentsBuffer.get(), Bounds, *PreambleDiagsEngine, VFS, PCHs,
   /*StoreInMemory=*/That->StorePreamblesInMemory,
   SerializedDeclsCollector);
 
+  // Preamble is built, restore SkipFunctionBodies.
+  CI->getFrontendOpts().SkipFunctionBodies = false;
+
   if (BuiltPreamble) {
 log(Ctx, "Built preamble of size " + Twine(BuiltPreamble->getSize()) +
  " for file " + Twine(That->FileName));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41495: [clangd] Skip function bodies when building the preamble

2017-12-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

I haven't done proper benchmarks, but here are some numbers from running this 
on my machine:

Sizes of preamble with (before the change) and without (after the change) 
functon bodies:

| File   | Before  | After   |
| ClangdUnit.cpp | 49.58MB | 34.79MB |
| SemaDecl.cpp   | 47.03MB | 31.51MB |
| All C++11 stl includes | 13.15MB | 8.75M   |
|

Time to build the preamble (just a single run, not a proper benchmark):

| File   | Before | After |
| ClangdUnit.cpp | 4.39s  | 2.49s |
| SemaDecl.cpp   | 4.28s  | 2.29s |
| All C++11 stl includes | 1.40s  | 0.80s |
|

Time to build AST and provide diagnostics after preamble is ready (just a 
single run, not a proper benchmark):

| File   | Before | After |
| ClangdUnit.cpp | 1.75s  | 0.18s |
| SemaDecl.cpp   | 2.30s  | 0.74s |
|


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41495



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


[PATCH] D41394: [CodeGen] Support generation of TBAA info in the new format

2017-12-21 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

That's great, thanks.  LGTM.


https://reviews.llvm.org/D41394



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


[PATCH] D41150: [CFG] Adding new CFGStmt LoopEntrance for the StaticAnalyzer

2017-12-21 Thread Peter Szecsi via Phabricator via cfe-commits
szepet updated this revision to Diff 127894.
szepet marked an inline comment as done.
szepet added a comment.

Comment added to LoopEntrance CFGElement.


https://reviews.llvm.org/D41150

Files:
  include/clang/Analysis/CFG.h
  lib/Analysis/CFG.cpp
  lib/StaticAnalyzer/Core/PathDiagnostic.cpp
  test/Analysis/loopexit-cfg-output.cpp

Index: test/Analysis/loopexit-cfg-output.cpp
===
--- test/Analysis/loopexit-cfg-output.cpp
+++ test/Analysis/loopexit-cfg-output.cpp
@@ -34,6 +34,7 @@
 // CHECK:   [B5]
 // CHECK-NEXT:   1: 0
 // CHECK-NEXT:   2: int i = 0;
+// CHECK-NEXT:   3: ForStmt (LoopEntrance)
 // CHECK-NEXT:   Preds (1): B6
 // CHECK-NEXT:   Succs (1): B4
 
@@ -46,8 +47,8 @@
   return;
 }
 
-// CHECK:   [B4 (ENTRY)]
-// CHECK-NEXT:   Succs (1): B3
+// CHECK:   [B5 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B4
 
 // CHECK:   [B1]
 // CHECK-NEXT:   1: ForStmt (LoopExit)
@@ -62,15 +63,20 @@
 // CHECK-NEXT:   Preds (2): B2 B4
 // CHECK-NEXT:   Succs (2): B2 NULL
 
+// CHECK:   [B4]
+// CHECK-NEXT:   1: ForStmt (LoopEntrance)
+// CHECK-NEXT:   Preds (1): B5
+// CHECK-NEXT:   Succs (1): B3
+
 // CHECK:   [B0 (EXIT)]
 // CHECK-NEXT:   Preds (1): B1
 void check_forloop2() {
   for (;;)
 ;
 }
 
-// CHECK:   [B5 (ENTRY)]
-// CHECK-NEXT:   Succs (1): B4
+// CHECK:   [B6 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B5
 
 // CHECK:   [B1]
 // CHECK-NEXT:   1: WhileStmt (LoopExit)
@@ -91,6 +97,11 @@
 // CHECK-NEXT:   Preds (2): B2 B5
 // CHECK-NEXT:   Succs (2): B3 NULL
 
+// CHECK:   [B5]
+// CHECK-NEXT:   1: WhileStmt (LoopEntrance)
+// CHECK-NEXT:   Preds (1): B6
+// CHECK-NEXT:   Succs (1): B4
+
 // CHECK:   [B0 (EXIT)]
 // CHECK-NEXT:   Preds (1): B1
 void check_while1() {
@@ -125,6 +136,7 @@
 
 // CHECK:   [B4]
 // CHECK-NEXT:   1: int l;
+// CHECK-NEXT:   2: WhileStmt (LoopEntrance)
 // CHECK-NEXT:   Preds (1): B5
 // CHECK-NEXT:   Succs (1): B3
 
@@ -138,8 +150,8 @@
   return;
 }
 
-// CHECK:   [B4 (ENTRY)]
-// CHECK-NEXT:   Succs (1): B3
+// CHECK:   [B5 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B4
 
 // CHECK:   [B1]
 // CHECK-NEXT:   1: WhileStmt (LoopExit)
@@ -155,16 +167,21 @@
 // CHECK-NEXT:   Preds (2): B2 B4
 // CHECK-NEXT:   Succs (2): NULL B1
 
+// CHECK:   [B4]
+// CHECK-NEXT:   1: WhileStmt (LoopEntrance)
+// CHECK-NEXT:   Preds (1): B5
+// CHECK-NEXT:   Succs (1): B3
+
 // CHECK:   [B0 (EXIT)]
 // CHECK-NEXT:   Preds (1): B1
 void check_while3() {
   while (false) {
 ;
   }
 }
 
-// CHECK:   [B4 (ENTRY)]
-// CHECK-NEXT:   Succs (1): B2
+// CHECK:   [B5 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B4
 
 // CHECK:   [B1]
 // CHECK-NEXT:   1: DoStmt (LoopExit)
@@ -180,6 +197,11 @@
 // CHECK:   [B3]
 // CHECK-NEXT:   Succs (1): B2
 
+// CHECK:   [B4]
+// CHECK-NEXT:   1: DoStmt (LoopEntrance)
+// CHECK-NEXT:   Preds (1): B5
+// CHECK-NEXT:   Succs (1): B2
+
 // CHECK:   [B0 (EXIT)]
 // CHECK-NEXT:   Preds (1): B1
 void check_dowhile1() {
@@ -221,6 +243,7 @@
 // CHECK:   [B5]
 // CHECK-NEXT:   1: 2
 // CHECK-NEXT:   2: int j = 2;
+// CHECK-NEXT:   3: DoStmt (LoopEntrance)
 // CHECK-NEXT:   Preds (1): B6
 // CHECK-NEXT:   Succs (1): B3
 
@@ -276,6 +299,7 @@
 // CHECK:   [B7]
 // CHECK-NEXT:   1: 1
 // CHECK-NEXT:   2: int j = 1;
+// CHECK-NEXT:   3: ForStmt (LoopEntrance)
 // CHECK-NEXT:   Preds (1): B8
 // CHECK-NEXT:   Succs (1): B6
 
@@ -292,6 +316,7 @@
 // CHECK-NEXT:   1: 40
 // CHECK-NEXT:   2: -[B9.1]
 // CHECK-NEXT:   3: int i = -40;
+// CHECK-NEXT:   4: WhileStmt (LoopEntrance)
 // CHECK-NEXT:   Preds (1): B10
 // CHECK-NEXT:   Succs (1): B8
 
@@ -305,19 +330,19 @@
   }
 }
 
-// CHECK:   [B9 (ENTRY)]
-// CHECK-NEXT:   Succs (1): B8
+// CHECK:   [B10 (ENTRY)]
+// CHECK-NEXT:   Succs (1): B9
 
 // CHECK:   [B1]
 // CHECK-NEXT:   1: ForStmt (LoopExit)
-// CHECK-NEXT:   Preds (1): B7
+// CHECK-NEXT:   Preds (1): B8
 // CHECK-NEXT:   Succs (1): B0
 
 // CHECK:   [B2]
 // CHECK-NEXT:   1: j
 // CHECK-NEXT:   2: [B2.1]++
 // CHECK-NEXT:   Preds (1): B3
-// CHECK-NEXT:   Succs (1): B7
+// CHECK-NEXT:   Succs (1): B8
 
 // CHECK:   [B3]
 // CHECK-NEXT:   1: DoStmt (LoopExit)
@@ -346,22 +371,28 @@
 // CHECK-NEXT:   Succs (1): B5
 
 // CHECK:   [B7]
+// CHECK-NEXT:   1: DoStmt (LoopEntrance)
+// CHECK-NEXT:   Preds (1): B8
+// CHECK-NEXT:   Succs (1): B5
+
+// CHECK:   [B8]
 // CHECK-NEXT:   1: j
-// CHECK-NEXT:   2: [B7.1] (ImplicitCastExpr, LValueToRValue, int)
+// CHECK-NEXT:   2: [B8.1] (ImplicitCastExpr, LValueToRValue, int)
 // CHECK-NEXT:   3: 6
-// CHECK-NEXT:   4: [B7.2] < [B7.3]
-// CHECK-NEXT:   T: for (...; [B7.4]; ...)
-// CHECK-NEXT:   Preds (2): B2 B8
-// CHECK-NEXT:   Succs (2): B5 B1
+// CHECK-NEXT:   4: [B8.2] < [B8.3]
+// CHECK-NEXT:   T: for (...; [B8.4]; ...)
+// CHECK-NEXT:   Preds (2): B2 B9
+// CHECK-NEXT:   Succs (2): B7 B1
 
-// CHECK:   [B8]
+// CHECK:   [B9]
 // CHECK-NEXT:   1: 40
-// CHECK-NEX

[PATCH] D40720: No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17

2017-12-21 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg updated this revision to Diff 127899.
sberg added a comment.

(need to call getAs instead of cast in 
one place, in case the name in the function decl is wrapped in parens, as 
happens in HarfBuzz's hb-buffer.cc)


https://reviews.llvm.org/D40720

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
  compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp

Index: compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
===
--- compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
+++ compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
@@ -1,4 +1,4 @@
-// RUN: %clangxx -fsanitize=function %s -O3 -g -o %t
+// RUN: %clangxx -std=c++17 -fsanitize=function %s -O3 -g -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
 // Verify that we can disable symbolization if needed:
 // RUN: %env_ubsan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOSYM
@@ -23,9 +23,49 @@
   reinterpret_cast(reinterpret_cast(f))(42);
 }
 
+void f1(int) {}
+void f2(unsigned int) {}
+void f3(int) noexcept {}
+void f4(unsigned int) noexcept {}
+
+void check_noexcept_calls() {
+  void (*p1)(int);
+  p1 = &f1;
+  p1(0);
+  p1 = reinterpret_cast(&f2);
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f2(unsigned int) through pointer to incorrect function type 'void (*)(int)'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int)'
+  p1(0);
+  p1 = &f3;
+  p1(0);
+  p1 = reinterpret_cast(&f4);
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f4(unsigned int) through pointer to incorrect function type 'void (*)(int)'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int)'
+  p1(0);
+
+  void (*p2)(int) noexcept;
+  p2 = reinterpret_cast(&f1);
+  // TODO: Unclear whether calling a non-noexcept function through a pointer to
+  // nexcept function should cause an error.
+  // CHECK-NOT: function.cpp:[[@LINE+2]]:3: runtime error: call to function f1(int) through pointer to incorrect function type 'void (*)(int) noexcept'
+  // NOSYM-NOT: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int) noexcept'
+  p2(0);
+  p2 = reinterpret_cast(&f2);
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f2(unsigned int) through pointer to incorrect function type 'void (*)(int) noexcept'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int) noexcept'
+  p2(0);
+  p2 = &f3;
+  p2(0);
+  p2 = reinterpret_cast(&f4);
+  // CHECK: function.cpp:[[@LINE+2]]:3: runtime error: call to function f4(unsigned int) through pointer to incorrect function type 'void (*)(int) noexcept'
+  // NOSYM: function.cpp:[[@LINE+1]]:3: runtime error: call to function (unknown) through pointer to incorrect function type 'void (*)(int) noexcept'
+  p2(0);
+}
+
 int main(void) {
   make_valid_call();
   make_invalid_call();
+  check_noexcept_calls();
   // Check that no more errors will be printed.
   // CHECK-NOT: runtime error: call to function
   // NOSYM-NOT: runtime error: call to function
Index: clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++17 -fsanitize=function -emit-llvm -triple x86_64-linux-gnu %s -o - | FileCheck %s
+
+// Check that typeinfo recorded in function prolog doesn't have "Do" noexcept
+// qualifier in its mangled name.
+// CHECK: @[[LABEL:[0-9]+]] = private constant i8* bitcast ({ i8*, i8* }* @_ZTIFvvE to i8*)
+// CHECK: define void @_Z1fv() #{{.*}} prologue <{ i32, i32 }> <{ i32 {{.*}}, i32 trunc (i64 sub (i64 ptrtoint (i8** @[[LABEL]] to i64), i64 ptrtoint (void ()* @_Z1fv to i64)) to i32) }>
+void f() noexcept {}
+
+// CHECK: define void @_Z1gPDoFvvE
+void g(void (*p)() noexcept) {
+  // Check that reference typeinfo at call site doesn't have "Do" noexcept
+  // qualifier in its mangled name, either.
+  // CHECK: icmp eq i8* %{{.*}}, bitcast ({ i8*, i8* }* @_ZTIFvvE to i8*), !nosanitize
+  p();
+}
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3415,7 +3415,7 @@
 
 /// Compute the flags for a __pbase_type_info, and remove the corresponding
 /// pieces from \p Type.
-static unsigned extractPBaseFlags(ASTContext &Ctx, QualType &Type) {
+static unsigned e

[PATCH] D38639: [clangd] #include statements support for Open definition

2017-12-21 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 127900.
Nebiroth marked 11 inline comments as done.
Nebiroth added a comment.

  Minor code cleanup


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D38639

Files:
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/Protocol.h
  clangd/XRefs.cpp
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-#include "ClangdLSPServer.h"
 #include "ClangdServer.h"
 #include "Context.h"
 #include "TestFS.h"
@@ -751,6 +750,75 @@
   EXPECT_FALSE(PathResult.hasValue());
 }
 
+TEST_F(ClangdVFSTest, CheckDefinitionIncludes) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*StorePreamblesInMemory=*/true,
+  EmptyLogger::getInstance());
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  const auto SourceContents = R"cpp(
+  #include "foo.h"
+  #include "invalid.h"
+  int b = a;
+  // test
+  int foo;
+  #include "foo.h"
+  )cpp";
+  FS.Files[FooCpp] = SourceContents;
+  auto FooH = getVirtualTestFilePath("foo.h");
+  const auto HeaderContents = "int a;";
+
+  FS.Files[FooCpp] = SourceContents;
+  FS.Files[FooH] = HeaderContents;
+
+  Server.addDocument(FooH, HeaderContents);
+  Server.addDocument(FooCpp, SourceContents);
+
+  Position P = Position{1, 11};
+
+  auto ExpectedLocations = Server.findDefinitions(FooCpp, P);
+  ASSERT_TRUE(!!ExpectedLocations);
+  std::vector Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(!Locations.empty());
+  std::string s("file:///");
+  std::string check = Locations[0].uri.uri;
+  check = check.erase(0, s.size() - 1);
+  check = check.substr(0, check.size());
+  ASSERT_EQ(check, FooH);
+  ASSERT_EQ(Locations[0].range.start.line, 0);
+  ASSERT_EQ(Locations[0].range.start.character, 0);
+  ASSERT_EQ(Locations[0].range.end.line, 0);
+  ASSERT_EQ(Locations[0].range.end.character, 0);
+
+  // Test ctrl-clicking on the #include part on the statement
+  Position P2 = Position{1, 3};
+
+  ExpectedLocations = Server.findDefinitions(FooCpp, P2);
+  ASSERT_TRUE(!!ExpectedLocations);
+  Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(!Locations.empty());
+
+  // Test invalid include
+  Position P3 = Position{2, 11};
+
+  ExpectedLocations = Server.findDefinitions(FooCpp, P3);
+  ASSERT_TRUE(!!ExpectedLocations);
+  Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(Locations.empty());
+
+  // Test include outside of Preamble
+  Position P4  = Position{6, 5};
+
+  ExpectedLocations = Server.findDefinitions(FooCpp, P4);
+  ASSERT_TRUE(!!ExpectedLocations);
+  Locations = ExpectedLocations->Value;
+  EXPECT_TRUE(!Locations.empty());
+}
+
 TEST_F(ClangdThreadingTest, NoConcurrentDiagnostics) {
   class NoConcurrentAccessDiagConsumer : public DiagnosticsConsumer {
   public:
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -18,6 +18,7 @@
 class DeclarationAndMacrosFinder : public index::IndexDataConsumer {
   std::vector Decls;
   std::vector MacroInfos;
+  std::vector DeclarationLocations;
   const SourceLocation &SearchedLocation;
   const ASTContext &AST;
   Preprocessor &PP;
@@ -37,14 +38,26 @@
 return std::move(Decls);
   }
 
+  std::vector takeLocations() {
+// Don't keep the same location multiple times.
+// This can happen when nodes in the AST are visited twice.
+std::sort(DeclarationLocations.begin(), DeclarationLocations.end());
+auto Last =
+std::unique(DeclarationLocations.begin(), DeclarationLocations.end());
+DeclarationLocations.erase(Last, DeclarationLocations.end());
+return std::move(DeclarationLocations);
+  }
+
   std::vector takeMacroInfos() {
 // Don't keep the same Macro info multiple times.
 std::sort(MacroInfos.begin(), MacroInfos.end());
 auto Last = std::unique(MacroInfos.begin(), MacroInfos.end());
 MacroInfos.erase(Last, MacroInfos.end());
 return std::move(MacroInfos);
   }
 
+  const SourceLocation &getSearchedLocation() { return SearchedLocation; };
+
   bool
   handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
   ArrayRef Relations, FileID FID,
@@ -62,6 +75,25 @@
SourceMgr.getFileID(SearchedLocation) == FID;
   }
 
+  void addDeclarationLocation(const SourceRange &ValSourceRange) {
+const SourceManager &SourceMgr = AST.getSourceManager();
+const LangOptions &LangOpts = AST.getLangOpts();
+SourceLocation LocStart = ValSourceRange.getBegin();
+SourceLocation LocEnd = Lexer::getLocForEndOfToken(ValSourceRange.getEnd(),
+   0, SourceMgr, LangOpts);
+

[PATCH] D41498: [libcxx] Add clang negative thread safety assertions to std::mutex

2017-12-21 Thread Luis Héctor Chávez via Phabricator via cfe-commits
lhchavez created this revision.
Herald added a reviewer: EricWF.
Herald added a subscriber: cfe-commits.

This adds clang negative thread safery assertion support to std::mutex,
as documented in:

https://clang.llvm.org/docs/ThreadSafetyAnalysis.html

Fixes #34951.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41498

Files:
  include/__mutex_base
  test/libcxx/thread/thread.mutex/thread_safety_annotations_negative.fail.cpp
  test/libcxx/thread/thread.mutex/thread_safety_annotations_negative.pass.cpp
  utils/libcxx/test/config.py

Index: utils/libcxx/test/config.py
===
--- utils/libcxx/test/config.py
+++ utils/libcxx/test/config.py
@@ -135,6 +135,7 @@
 self.configure_cxx_library_root()
 self.configure_use_clang_verify()
 self.configure_use_thread_safety()
+self.configure_use_thread_safety_negative()
 self.configure_execute_external()
 self.configure_ccache()
 self.configure_compile_flags()
@@ -354,6 +355,15 @@
 self.config.available_features.add('thread-safety')
 self.lit_config.note("enabling thread-safety annotations")
 
+def configure_use_thread_safety_negative(self):
+'''If set, run clang with -verify on failing tests.'''
+has_thread_safety_negative = self.cxx.hasCompileFlag(
+'-Werror=thread-safety-negative')
+if has_thread_safety_negative:
+self.cxx.compile_flags += ['-Werror=thread-safety-negative']
+self.config.available_features.add('thread-safety-negative')
+self.lit_config.note("enabling thread-safety-negative annotations")
+
 def configure_execute_external(self):
 # Choose between lit's internal shell pipeline runner and a real shell.
 # If LIT_USE_INTERNAL_SHELL is in the environment, we use that as the
Index: test/libcxx/thread/thread.mutex/thread_safety_annotations_negative.pass.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_annotations_negative.pass.cpp
@@ -0,0 +1,29 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// REQUIRES: thread-safety, thread-safety-negative
+
+// 
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+void increment() __attribute__((requires_capability(!m))) {
+  m.lock();
+  foo++;
+  m.unlock();
+}
+
+int main() {
+  increment();
+}
Index: test/libcxx/thread/thread.mutex/thread_safety_annotations_negative.fail.cpp
===
--- /dev/null
+++ test/libcxx/thread/thread.mutex/thread_safety_annotations_negative.fail.cpp
@@ -0,0 +1,31 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// REQUIRES: thread-safety, thread-safety-negative
+
+// 
+
+#define _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS
+
+#include 
+
+std::mutex m;
+int foo __attribute__((guarded_by(m)));
+
+void increment() __attribute__((requires_capability(!m))) {
+  m.lock();
+  foo++;
+  m.unlock();
+}
+
+int main() {
+  m.lock();
+  increment();
+  m.unlock();
+}
Index: include/__mutex_base
===
--- include/__mutex_base
+++ include/__mutex_base
@@ -62,6 +62,9 @@
 void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability());
 bool try_lock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true));
 void unlock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
+#ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+const mutex& operator!() const { return *this; }
+#endif
 
 typedef __libcpp_mutex_t* native_handle_type;
 _LIBCPP_INLINE_VISIBILITY native_handle_type native_handle() {return &__m_;}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321285 - [ASTImporterTest] Add mandatory testing with '-fdelayed-template-parsing'

2017-12-21 Thread Aleksei Sidorin via cfe-commits
Author: a.sidorin
Date: Thu Dec 21 09:41:06 2017
New Revision: 321285

URL: http://llvm.org/viewvc/llvm-project?rev=321285&view=rev
Log:
[ASTImporterTest] Add mandatory testing with '-fdelayed-template-parsing'

 * While running ASTImporterTests, we often forget about Windows MSVC
   buildbots which enable '-fdelayed-template-parsing' by default.
   This leads to AST import errors because templates are not parsed
   and corresponding parts of AST are not built so importer cannot import them.
   It takes both reviewing time to find such issues and post-commit time
   to fix unexpected buildbot failures. To solve this issue, we enable testing
   with '-fdelayed-template-parsing' option enabled by default in addition
   to testing with default compiler options. This allows us to catch
   the problem during development.

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


Modified:
cfe/trunk/unittests/AST/ASTImporterTest.cpp

Modified: cfe/trunk/unittests/AST/ASTImporterTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/ASTImporterTest.cpp?rev=321285&r1=321284&r2=321285&view=diff
==
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp (original)
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp Thu Dec 21 09:41:06 2017
@@ -22,38 +22,50 @@
 namespace clang {
 namespace ast_matchers {
 
-typedef std::vector StringVector;
+typedef std::vector ArgVector;
+typedef std::vector RunOptions;
 
-void getLangArgs(Language Lang, StringVector &Args) {
+static bool isCXX(Language Lang) {
+  return Lang == Lang_CXX || Lang == Lang_CXX11;
+}
+
+static RunOptions getRunOptionsForLanguage(Language Lang) {
+  ArgVector BasicArgs;
+  // Test with basic arguments.
   switch (Lang) {
   case Lang_C:
-Args.insert(Args.end(), { "-x", "c", "-std=c99" });
+BasicArgs = {"-x", "c", "-std=c99"};
 break;
   case Lang_C89:
-Args.insert(Args.end(), { "-x", "c", "-std=c89" });
+BasicArgs = {"-x", "c", "-std=c89"};
 break;
   case Lang_CXX:
-Args.push_back("-std=c++98");
+BasicArgs = {"-std=c++98"};
 break;
   case Lang_CXX11:
-Args.push_back("-std=c++11");
+BasicArgs = {"-std=c++11"};
 break;
   case Lang_OpenCL:
   case Lang_OBJCXX:
-break;
+llvm_unreachable("Not implemented yet!");
   }
+
+  // For C++, test with "-fdelayed-template-parsing" enabled to handle MSVC
+  // default behaviour.
+  if (isCXX(Lang)) {
+ArgVector ArgsForDelayedTemplateParse = BasicArgs;
+ArgsForDelayedTemplateParse.emplace_back("-fdelayed-template-parsing");
+return {BasicArgs, ArgsForDelayedTemplateParse};
+  }
+
+  return {BasicArgs};
 }
 
 template
 testing::AssertionResult
-testImport(const std::string &FromCode, Language FromLang,
-   const std::string &ToCode, Language ToLang,
-   MatchVerifier &Verifier,
-   const MatcherType &AMatcher) {
-  StringVector FromArgs, ToArgs;
-  getLangArgs(FromLang, FromArgs);
-  getLangArgs(ToLang, ToArgs);
-
+testImport(const std::string &FromCode, const ArgVector &FromArgs,
+   const std::string &ToCode, const ArgVector &ToArgs,
+   MatchVerifier &Verifier, const MatcherType &AMatcher) {
   const char *const InputFileName = "input.cc";
   const char *const OutputFileName = "output.cc";
 
@@ -92,7 +104,7 @@ testImport(const std::string &FromCode,
 return testing::AssertionFailure() << "Import failed, nullptr returned!";
 
   // This should dump source locations and assert if some source locations
-  // were not imported
+  // were not imported.
   SmallString<1024> ImportChecker;
   llvm::raw_svector_ostream ToNothing(ImportChecker);
   ToCtx.getTranslationUnitDecl()->print(ToNothing);
@@ -104,148 +116,154 @@ testImport(const std::string &FromCode,
   return Verifier.match(Imported, AMatcher);
 }
 
+template
+void testImport(const std::string &FromCode, Language FromLang,
+const std::string &ToCode, Language ToLang,
+MatchVerifier &Verifier,
+const MatcherType &AMatcher) {
+  auto RunOptsFrom = getRunOptionsForLanguage(FromLang);
+  auto RunOptsTo = getRunOptionsForLanguage(ToLang);
+  for (const auto &FromArgs : RunOptsFrom)
+for (const auto &ToArgs : RunOptsTo)
+  EXPECT_TRUE(testImport(FromCode, FromArgs, ToCode, ToArgs,
+ Verifier, AMatcher));
+}
+
+
 TEST(ImportExpr, ImportStringLiteral) {
   MatchVerifier Verifier;
-  EXPECT_TRUE(testImport("void declToImport() { \"foo\"; }",
- Lang_CXX, "", Lang_CXX, Verifier,
- functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- stringLiteral(
-   hasType(
- asString("const char [4]");
-  EXPECT_TRUE(testImport("void declToImport() { L\"foo\"; }",
-   

[PATCH] D41444: [ASTImporterTest] Make testing under '-fdelayed-template-parsing' mandatory

2017-12-21 Thread Aleksei Sidorin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321285: [ASTImporterTest] Add mandatory testing with 
'-fdelayed-template-parsing' (authored by a.sidorin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41444?vs=127748&id=127903#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41444

Files:
  cfe/trunk/unittests/AST/ASTImporterTest.cpp

Index: cfe/trunk/unittests/AST/ASTImporterTest.cpp
===
--- cfe/trunk/unittests/AST/ASTImporterTest.cpp
+++ cfe/trunk/unittests/AST/ASTImporterTest.cpp
@@ -22,38 +22,50 @@
 namespace clang {
 namespace ast_matchers {
 
-typedef std::vector StringVector;
+typedef std::vector ArgVector;
+typedef std::vector RunOptions;
 
-void getLangArgs(Language Lang, StringVector &Args) {
+static bool isCXX(Language Lang) {
+  return Lang == Lang_CXX || Lang == Lang_CXX11;
+}
+
+static RunOptions getRunOptionsForLanguage(Language Lang) {
+  ArgVector BasicArgs;
+  // Test with basic arguments.
   switch (Lang) {
   case Lang_C:
-Args.insert(Args.end(), { "-x", "c", "-std=c99" });
+BasicArgs = {"-x", "c", "-std=c99"};
 break;
   case Lang_C89:
-Args.insert(Args.end(), { "-x", "c", "-std=c89" });
+BasicArgs = {"-x", "c", "-std=c89"};
 break;
   case Lang_CXX:
-Args.push_back("-std=c++98");
+BasicArgs = {"-std=c++98"};
 break;
   case Lang_CXX11:
-Args.push_back("-std=c++11");
+BasicArgs = {"-std=c++11"};
 break;
   case Lang_OpenCL:
   case Lang_OBJCXX:
-break;
+llvm_unreachable("Not implemented yet!");
   }
+
+  // For C++, test with "-fdelayed-template-parsing" enabled to handle MSVC
+  // default behaviour.
+  if (isCXX(Lang)) {
+ArgVector ArgsForDelayedTemplateParse = BasicArgs;
+ArgsForDelayedTemplateParse.emplace_back("-fdelayed-template-parsing");
+return {BasicArgs, ArgsForDelayedTemplateParse};
+  }
+
+  return {BasicArgs};
 }
 
 template
 testing::AssertionResult
-testImport(const std::string &FromCode, Language FromLang,
-   const std::string &ToCode, Language ToLang,
-   MatchVerifier &Verifier,
-   const MatcherType &AMatcher) {
-  StringVector FromArgs, ToArgs;
-  getLangArgs(FromLang, FromArgs);
-  getLangArgs(ToLang, ToArgs);
-
+testImport(const std::string &FromCode, const ArgVector &FromArgs,
+   const std::string &ToCode, const ArgVector &ToArgs,
+   MatchVerifier &Verifier, const MatcherType &AMatcher) {
   const char *const InputFileName = "input.cc";
   const char *const OutputFileName = "output.cc";
 
@@ -92,7 +104,7 @@
 return testing::AssertionFailure() << "Import failed, nullptr returned!";
 
   // This should dump source locations and assert if some source locations
-  // were not imported
+  // were not imported.
   SmallString<1024> ImportChecker;
   llvm::raw_svector_ostream ToNothing(ImportChecker);
   ToCtx.getTranslationUnitDecl()->print(ToNothing);
@@ -104,148 +116,154 @@
   return Verifier.match(Imported, AMatcher);
 }
 
+template
+void testImport(const std::string &FromCode, Language FromLang,
+const std::string &ToCode, Language ToLang,
+MatchVerifier &Verifier,
+const MatcherType &AMatcher) {
+  auto RunOptsFrom = getRunOptionsForLanguage(FromLang);
+  auto RunOptsTo = getRunOptionsForLanguage(ToLang);
+  for (const auto &FromArgs : RunOptsFrom)
+for (const auto &ToArgs : RunOptsTo)
+  EXPECT_TRUE(testImport(FromCode, FromArgs, ToCode, ToArgs,
+ Verifier, AMatcher));
+}
+
+
 TEST(ImportExpr, ImportStringLiteral) {
   MatchVerifier Verifier;
-  EXPECT_TRUE(testImport("void declToImport() { \"foo\"; }",
- Lang_CXX, "", Lang_CXX, Verifier,
- functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- stringLiteral(
-   hasType(
- asString("const char [4]");
-  EXPECT_TRUE(testImport("void declToImport() { L\"foo\"; }",
- Lang_CXX, "", Lang_CXX, Verifier,
- functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- stringLiteral(
-   hasType(
- asString("const wchar_t [4]");
-  EXPECT_TRUE(testImport("void declToImport() { \"foo\" \"bar\"; }",
- Lang_CXX, "", Lang_CXX, Verifier,
- functionDecl(
-   hasBody(
- compoundStmt(
-   has(
- stringLiteral(
-   hasType(
-   

[clang-tools-extra] r321286 - [clangd] Fix use after free.

2017-12-21 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Thu Dec 21 09:51:35 2017
New Revision: 321286

URL: http://llvm.org/viewvc/llvm-project?rev=321286&view=rev
Log:
[clangd] Fix use after free.

Found by asan.

Modified:
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp

Modified: clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp?rev=321286&r1=321285&r2=321286&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Thu Dec 21 
09:51:35 2017
@@ -95,9 +95,10 @@ bool SymbolCollector::handleDeclOccurenc
   return true;
 
 auto &SM = ND->getASTContext().getSourceManager();
-SymbolLocation Location = {
-makeAbsolutePath(SM, SM.getFilename(D->getLocation())),
-SM.getFileOffset(D->getLocStart()), SM.getFileOffset(D->getLocEnd())};
+std::string FilePath =
+makeAbsolutePath(SM, SM.getFilename(D->getLocation()));
+SymbolLocation Location = {FilePath, SM.getFileOffset(D->getLocStart()),
+   SM.getFileOffset(D->getLocEnd())};
 std::string QName = ND->getQualifiedNameAsString();
 auto ScopeAndName = splitQualifiedName(QName);
 Symbols.insert({std::move(ID), ScopeAndName.second, ScopeAndName.first,


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


[PATCH] D41500: ananas: Add shared library support

2017-12-21 Thread Rink via Phabricator via cfe-commits
zhmu created this revision.
zhmu added a reviewer: ed.
Herald added a subscriber: cfe-commits.

The Ananas Operating System (https://github.com/zhmu/ananas) has shared library 
support as of commit 57739c0b6ece56dd4872aedf30264ed4b9412c77.

This change adds the necessary settings to clang so that shared executables and 
libraries can be build correctly.


Repository:
  rC Clang

https://reviews.llvm.org/D41500

Files:
  lib/Driver/ToolChains/Ananas.cpp
  test/Driver/ananas.c


Index: test/Driver/ananas.c
===
--- test/Driver/ananas.c
+++ test/Driver/ananas.c
@@ -7,3 +7,11 @@
 // CHECK-STATIC: crtbegin.o
 // CHECK-STATIC: crtend.o
 // CHECK-STATIC: crtn.o
+
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-ananas -shared %s 
\
+// RUN:   --sysroot=%S/Inputs/ananas-tree -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
+// CHECK-SHARED: crti.o
+// CHECK-SHARED: crtbeginS.o
+// CHECK-SHARED: crtendS.o
+// CHECK-SHARED: crtn.o
Index: lib/Driver/ToolChains/Ananas.cpp
===
--- lib/Driver/ToolChains/Ananas.cpp
+++ lib/Driver/ToolChains/Ananas.cpp
@@ -64,8 +64,19 @@
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
-  // Ananas only supports static linkage for now.
-  CmdArgs.push_back("-Bstatic");
+  if (Args.hasArg(options::OPT_static)) {
+CmdArgs.push_back("-Bstatic");
+  } else {
+if (Args.hasArg(options::OPT_rdynamic))
+  CmdArgs.push_back("-export-dynamic");
+if (Args.hasArg(options::OPT_shared)) {
+  CmdArgs.push_back("-Bshareable");
+} else {
+  Args.AddAllArgs(CmdArgs, options::OPT_pie);
+  CmdArgs.push_back("-dynamic-linker");
+  CmdArgs.push_back("/lib/ld-ananas.so");
+}
+  }
 
   if (Output.isFilename()) {
 CmdArgs.push_back("-o");
@@ -75,9 +86,15 @@
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+if (!Args.hasArg(options::OPT_shared)) {
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+}
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie)) {
+  
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbeginS.o")));
+} else {
+  
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtbegin.o")));
+}
   }
 
   Args.AddAllArgs(CmdArgs, options::OPT_L);
@@ -98,7 +115,10 @@
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
+if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
+  
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtendS.o")));
+else
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
   }
 


Index: test/Driver/ananas.c
===
--- test/Driver/ananas.c
+++ test/Driver/ananas.c
@@ -7,3 +7,11 @@
 // CHECK-STATIC: crtbegin.o
 // CHECK-STATIC: crtend.o
 // CHECK-STATIC: crtn.o
+
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-ananas -shared %s \
+// RUN:   --sysroot=%S/Inputs/ananas-tree -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-SHARED %s
+// CHECK-SHARED: crti.o
+// CHECK-SHARED: crtbeginS.o
+// CHECK-SHARED: crtendS.o
+// CHECK-SHARED: crtn.o
Index: lib/Driver/ToolChains/Ananas.cpp
===
--- lib/Driver/ToolChains/Ananas.cpp
+++ lib/Driver/ToolChains/Ananas.cpp
@@ -64,8 +64,19 @@
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
-  // Ananas only supports static linkage for now.
-  CmdArgs.push_back("-Bstatic");
+  if (Args.hasArg(options::OPT_static)) {
+CmdArgs.push_back("-Bstatic");
+  } else {
+if (Args.hasArg(options::OPT_rdynamic))
+  CmdArgs.push_back("-export-dynamic");
+if (Args.hasArg(options::OPT_shared)) {
+  CmdArgs.push_back("-Bshareable");
+} else {
+  Args.AddAllArgs(CmdArgs, options::OPT_pie);
+  CmdArgs.push_back("-dynamic-linker");
+  CmdArgs.push_back("/lib/ld-ananas.so");
+}
+  }
 
   if (Output.isFilename()) {
 CmdArgs.push_back("-o");
@@ -75,9 +86,15 @@
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
-CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+if (!Args.hasArg(options::OPT_shared)) {
+  CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
+}
 CmdArgs.push_back(Args.MakeArgString(ToolChain

[PATCH] D39053: [Bitfield] Add more cases to making the bitfield a separate location

2017-12-21 Thread Strahinja Petrovic via Phabricator via cfe-commits
spetrovic added a comment.

ping


https://reviews.llvm.org/D39053



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


[PATCH] D40478: Added control flow architecture protection Flag

2017-12-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Are we sure we want a different command line option name from gcc? From our 
internal conversations with the gcc folks I thought they were suggesting that 
-fcf-protection could imply a software mechanism if a hardware mechanism was 
not available thorugh -mibt or -march?

Should we emit an error to the user if -mibt isn't available?  We should be 
able to add virtual methods on TargetInfo that X86 can customize to check for 
ibt and shstk.

Can you provide more information about the miscompile on MSVC? I think we 
should do more to understand that, this sounds like it could be a time bomb 
waiting to fail somewhere else.


Repository:
  rL LLVM

https://reviews.llvm.org/D40478



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


[PATCH] D24933: Enable configuration files in clang

2017-12-21 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 127911.
sepavloff marked 2 inline comments as done.
sepavloff added a comment.

Small corrections to the patch

- Avoid quick return in the case of error, it may cause fails of clang tools.
- Fixed typo.


Repository:
  rC Clang

https://reviews.llvm.org/D24933

Files:
  docs/UsersManual.rst
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Config/config.h.cmake
  include/clang/Driver/Driver.h
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/Inputs/config-1.cfg
  test/Driver/Inputs/config-2.cfg
  test/Driver/Inputs/config-2a.cfg
  test/Driver/Inputs/config-3.cfg
  test/Driver/Inputs/config-4.cfg
  test/Driver/Inputs/config-5.cfg
  test/Driver/Inputs/config-6.cfg
  test/Driver/Inputs/config/config-4.cfg
  test/Driver/Inputs/config/i386-qqq.cfg
  test/Driver/Inputs/config/i386-qqq3.cfg
  test/Driver/Inputs/config/x86_64-qqq.cfg
  test/Driver/Inputs/config/x86_64-qqq2.cfg
  test/Driver/Inputs/config/x86_64.cfg
  test/Driver/Inputs/config2/config-4.cfg
  test/Driver/Inputs/config2/i386.cfg
  test/Driver/config-file-errs.c
  test/Driver/config-file.c
  test/Driver/config-file2.c
  test/Driver/config-file3.c

Index: test/Driver/config-file3.c
===
--- /dev/null
+++ test/Driver/config-file3.c
@@ -0,0 +1,98 @@
+// REQUIRES: shell
+// REQUIRES: x86-registered-target
+
+//--- If config file is specified by relative path (workdir/cfg-s2), it is searched for by that path.
+//
+// RUN: mkdir -p %T/workdir
+// RUN: echo "@subdir/cfg-s2" > %T/workdir/cfg-1
+// RUN: mkdir -p %T/workdir/subdir
+// RUN: echo "-Wundefined-var-template" > %T/workdir/subdir/cfg-s2
+//
+// RUN: ( cd %T && %clang --config workdir/cfg-1 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-REL )
+//
+// CHECK-REL: Configuration file: {{.*}}/workdir/cfg-1
+// CHECK-REL: -Wundefined-var-template
+
+
+//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg first.
+//
+// RUN: mkdir -p %T/testdmode
+// RUN: [ ! -s %T/testdmode/qqq-clang-g++ ] || rm %T/testdmode/qqq-clang-g++
+// RUN: ln -s %clang %T/testdmode/qqq-clang-g++
+// RUN: echo "-Wundefined-func-template" > %T/testdmode/qqq-clang-g++.cfg
+// RUN: echo "-Werror" > %T/testdmode/qqq.cfg
+// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix FULL-NAME
+//
+// FULL-NAME: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
+// FULL-NAME: -Wundefined-func-template
+// FULL-NAME-NOT: -Werror
+//
+//--- File specified by --config overrides config inferred from clang executable.
+//
+// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir=%S/Inputs/config --config-user-dir= --config i386-qqq -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-EXPLICIT
+//
+// CHECK-EXPLICIT: Configuration file: {{.*}}/Inputs/config/i386-qqq.cfg
+//
+//--- Invocation qqq-clang-g++ tries to find config file qqq.cfg if qqq-clang-g++.cfg is not found.
+//
+// RUN: rm %T/testdmode/qqq-clang-g++.cfg
+// RUN: %T/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix SHORT-NAME
+//
+// SHORT-NAME: Configuration file: {{.*}}/testdmode/qqq.cfg
+// SHORT-NAME: -Werror
+// SHORT-NAME-NOT: -Wundefined-func-template
+
+
+//--- Config files are searched for in binary directory as well.
+//
+// RUN: mkdir -p %T/testbin
+// RUN: [ ! -s %T/testbin/clang ] || rm %T/testbin/clang
+// RUN: ln -s %clang %T/testbin/clang
+// RUN: echo "-Werror" > %T/testbin/aaa.cfg
+// RUN: %T/testbin/clang --config-system-dir= --config-user-dir= --config aaa.cfg -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-BIN
+//
+// CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg
+// CHECK-BIN: -Werror
+
+
+//--- If command line contains options that change triple (for instance, -m32), clang tries
+//reloading config file.
+
+//--- When reloading config file, x86_64-clang-g++ tries to find config i386-clang-g++.cfg first.
+//
+// RUN: mkdir -p %T/testreload
+// RUN: [ ! -s %T/testreload/x86_64-clang-g++ ] || rm %T/testreload/x86_64-clang-g++
+// RUN: ln -s %clang %T/testreload/x86_64-clang-g++
+// RUN: echo "-Wundefined-func-template" > %T/testreload/i386-clang-g++.cfg
+// RUN: echo "-Werror" > %T/testreload/i386.cfg
+// RUN: %T/testreload/x86_64-clang-g++ --config-system-dir= --config-user-dir= -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD
+//
+// CHECK-RELOAD: Configuration file: {{.*}}/testreload/i386-clang-g++.cfg
+// CHECK-RELOAD: -Wundefined-func-template
+// CHECK-RELOAD-NOT: -Werror
+
+//--- If config file is specified by --config and its name does not start with architecture, it is used without reloading.
+//
+// RUN: %T/testreload/x86_64-clang-g++ --config-system-dir=%S/Inputs --config-user-dir= --config config-3 -c -m32 -no-canonical-prefixes %

[PATCH] D41242: [Solaris] Silence -pthread warning on Solaris

2017-12-21 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev accepted this revision.
fedor.sergeev added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D41242



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


[PATCH] D41478: [analyzer] Fix zero-initialization of stack VLAs under ARC.

2017-12-21 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

LGTM. The tests are great!!


Repository:
  rC Clang

https://reviews.llvm.org/D41478



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


[PATCH] D40720: No -fsanitize=function warning when calling noexcept function through non-noexcept pointer in C++17

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



Comment at: clang/lib/CodeGen/CodeGenTypes.h:378
+  /// specification removed.
+  QualType removeNothrowQualification(const FunctionProtoType *Proto) const;
 };

Please use the frontend language terminology here: "nothrow" is appropriate 
when talking about an LLVM function, but for the frontend type we should call 
this "removeExceptionSpecification" or similar. It would make sense for this to 
live on `ASTContext` instead of `CodeGenTypes`, since it's an AST type 
transformation utility not something related to IR generation. (There's a call 
to `getFunctionType` in `Sema::IsFunctionConversion` that you could also 
convert to use this `ASTContext` utility function.)

Perhaps exposing the currently-internal `getFunctionTypeWithExceptionSpec` from 
ASTContext.cpp would be a good way forward. (That function also handles 
wrapping, unwrapping, and adjusting type sugar nodes, but has the same effect 
as this one on the canonical type.)



Comment at: clang/test/CodeGenCXX/ubsan-function-noexcept.cpp:5
+// qualifier in its mangled name.
+// CHECK: @[[LABEL:[0-9]+]] = private constant i8* bitcast ({ i8*, i8* }* 
@_ZTIFvvE to i8*)
+// CHECK: define void @_Z1fv() #{{.*}} prologue <{ i32, i32 }> <{ i32 {{.*}}, 
i32 trunc (i64 sub (i64 ptrtoint (i8** @[[LABEL]] to i64), i64 ptrtoint (void 
()* @_Z1fv to i64)) to i32) }>

A name more meaningful than "LABEL" would be more useful to future readers of 
this code.


https://reviews.llvm.org/D40720



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


r321290 - [analyzer] Fix zero-initialization of stack VLAs under ObjC ARC.

2017-12-21 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Dec 21 10:43:02 2017
New Revision: 321290

URL: http://llvm.org/viewvc/llvm-project?rev=321290&view=rev
Log:
[analyzer] Fix zero-initialization of stack VLAs under ObjC ARC.

Using ARC, strong, weak, and autoreleasing stack variables are implicitly
initialized with nil. This includes variable-length arrays of Objective-C object
pointers. However, in the analyzer we don't zero-initialize them. We used to,
but it accidentally regressed after r289618.

Under ARC, the array variable's initializer within DeclStmt is an
ImplicitValueInitExpr. Environment doesn't maintain any bindings for this
expression kind - instead it always knows that it's a known constant
(0 in our case), so it just returns the known value by calling
SValBuilder::makeZeroVal() (see EnvironmentManager::getSVal().
Commit r289618 had introduced reasonable behavior of SValBuilder::makeZeroVal()
for the arrays, which produces a zero-length compoundVal{}. When such value
is bound to arrays, in RegionStoreManager::bindArray() "remaining" items in the
array are default-initialized with zero, as in
RegionStoreManager::setImplicitDefaultValue(). The similar mechanism works when
an array is initialized by an initializer list that is too short, eg.
  int a[3] = { 1, 2 };
would result in a[2] initialized with 0. However, in case of variable-length
arrays it didn't know if any more items need to be added,
because, well, the length is variable.

Add the default binding anyway, regardless of how many actually need
to be added. We don't really care how many, because the default binding covers
the whole array anyway.

Differential Revision: https://reviews.llvm.org/D41478
rdar://problem/35477763

Added:
cfe/trunk/test/Analysis/arc-zero-init.m
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=321290&r1=321289&r2=321290&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Thu Dec 21 10:43:02 2017
@@ -2132,9 +2132,10 @@ RegionStoreManager::bindArray(RegionBind
   NewB = bind(NewB, loc::MemRegionVal(ER), *VI);
   }
 
-  // If the init list is shorter than the array length, set the
-  // array default value.
-  if (Size.hasValue() && i < Size.getValue())
+  // If the init list is shorter than the array length (or the array has
+  // variable length), set the array default value. Values that are already set
+  // are not overwritten.
+  if (!Size.hasValue() || i < Size.getValue())
 NewB = setImplicitDefaultValue(NewB, R, ElementTy);
 
   return NewB;

Added: cfe/trunk/test/Analysis/arc-zero-init.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/arc-zero-init.m?rev=321290&view=auto
==
--- cfe/trunk/test/Analysis/arc-zero-init.m (added)
+++ cfe/trunk/test/Analysis/arc-zero-init.m Thu Dec 21 10:43:02 2017
@@ -0,0 +1,46 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -fobjc-arc %s
+
+#if __has_feature(objc_arc)
+// expected-no-diagnostics
+#endif
+
+@interface SomeClass
+@end
+
+void simpleStrongPointerValue() {
+  SomeClass *x;
+  if (x) {}
+#if !__has_feature(objc_arc)
+// expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void simpleArray() {
+  SomeClass *vlaArray[5];
+
+  if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+// expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void variableLengthArray() {
+   int count = 1;
+   SomeClass * vlaArray[count];
+
+   if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+  // expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void variableLengthArrayWithExplicitStrongAttribute() {
+   int count = 1;
+   __attribute__((objc_ownership(strong))) SomeClass * vlaArray[count];
+
+   if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+  // expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}


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


[PATCH] D41478: [analyzer] Fix zero-initialization of stack VLAs under ARC.

2017-12-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321290: [analyzer] Fix zero-initialization of stack VLAs 
under ObjC ARC. (authored by dergachev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D41478

Files:
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/arc-zero-init.m


Index: test/Analysis/arc-zero-init.m
===
--- test/Analysis/arc-zero-init.m
+++ test/Analysis/arc-zero-init.m
@@ -0,0 +1,46 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -fobjc-arc %s
+
+#if __has_feature(objc_arc)
+// expected-no-diagnostics
+#endif
+
+@interface SomeClass
+@end
+
+void simpleStrongPointerValue() {
+  SomeClass *x;
+  if (x) {}
+#if !__has_feature(objc_arc)
+// expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void simpleArray() {
+  SomeClass *vlaArray[5];
+
+  if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+// expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void variableLengthArray() {
+   int count = 1;
+   SomeClass * vlaArray[count];
+
+   if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+  // expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void variableLengthArrayWithExplicitStrongAttribute() {
+   int count = 1;
+   __attribute__((objc_ownership(strong))) SomeClass * vlaArray[count];
+
+   if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+  // expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2132,9 +2132,10 @@
   NewB = bind(NewB, loc::MemRegionVal(ER), *VI);
   }
 
-  // If the init list is shorter than the array length, set the
-  // array default value.
-  if (Size.hasValue() && i < Size.getValue())
+  // If the init list is shorter than the array length (or the array has
+  // variable length), set the array default value. Values that are already set
+  // are not overwritten.
+  if (!Size.hasValue() || i < Size.getValue())
 NewB = setImplicitDefaultValue(NewB, R, ElementTy);
 
   return NewB;


Index: test/Analysis/arc-zero-init.m
===
--- test/Analysis/arc-zero-init.m
+++ test/Analysis/arc-zero-init.m
@@ -0,0 +1,46 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -fobjc-arc %s
+
+#if __has_feature(objc_arc)
+// expected-no-diagnostics
+#endif
+
+@interface SomeClass
+@end
+
+void simpleStrongPointerValue() {
+  SomeClass *x;
+  if (x) {}
+#if !__has_feature(objc_arc)
+// expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void simpleArray() {
+  SomeClass *vlaArray[5];
+
+  if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+// expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void variableLengthArray() {
+   int count = 1;
+   SomeClass * vlaArray[count];
+
+   if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+  // expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
+
+void variableLengthArrayWithExplicitStrongAttribute() {
+   int count = 1;
+   __attribute__((objc_ownership(strong))) SomeClass * vlaArray[count];
+
+   if (vlaArray[0]) {}
+#if !__has_feature(objc_arc)
+  // expected-warning@-2{{Branch condition evaluates to a garbage value}}
+#endif
+}
Index: lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- lib/StaticAnalyzer/Core/RegionStore.cpp
+++ lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2132,9 +2132,10 @@
   NewB = bind(NewB, loc::MemRegionVal(ER), *VI);
   }
 
-  // If the init list is shorter than the array length, set the
-  // array default value.
-  if (Size.hasValue() && i < Size.getValue())
+  // If the init list is shorter than the array length (or the array has
+  // variable length), set the array default value. Values that are already set
+  // are not overwritten.
+  if (!Size.hasValue() || i < Size.getValue())
 NewB = setImplicitDefaultValue(NewB, R, ElementTy);
 
   return NewB;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41506: [clangd] Use Builder for symbol slabs, and use sorted-vector for storage

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, mgrang, klimek.

This improves a few things:

- the insert -> freeze -> read sequence is now enforced/communicated by the 
type system
- SymbolSlab::const_iterator iterates over symbols, not over id-symbol pairs
- we avoid permanently storing a second copy of the IDs, and the string map's 
hashtable

The slab size is now down to 21.8MB for the LLVM project.
Of this only 2.7MB is strings, the rest is #symbols * `sizeof(Symbol)`.
`sizeof(Symbol)` is currently 96, which seems too big - I think
SymbolInfo isn't efficiently packed. That's a topic for another patch!

Also added simple API to see the memory usage/#symbols of a slab, since
it seems likely we will continue to care about this.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41506

Files:
  clangd/index/FileIndex.cpp
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  clangd/index/SymbolYAML.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/IndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -32,8 +32,7 @@
 
 // GMock helpers for matching Symbol.
 MATCHER_P(QName, Name, "") {
-  return (arg.second.Scope + (arg.second.Scope.empty() ? "" : "::") +
-  arg.second.Name).str() == Name;
+  return (arg.Scope + (arg.Scope.empty() ? "" : "::") + arg.Name).str() == Name;
 }
 
 namespace clang {
Index: unittests/clangd/IndexTests.cpp
===
--- unittests/clangd/IndexTests.cpp
+++ unittests/clangd/IndexTests.cpp
@@ -45,18 +45,18 @@
 std::shared_ptr>
 generateSymbols(std::vector QualifiedNames,
 std::weak_ptr *WeakSymbols = nullptr) {
-  auto Slab = std::make_shared();
-  if (WeakSymbols)
-*WeakSymbols = Slab;
-
+  SymbolSlab::Builder Slab;
   for (llvm::StringRef QName : QualifiedNames)
-Slab->Slab.insert(symbol(QName));
+Slab.insert(symbol(QName));
 
-  for (const auto &Sym : Slab->Slab)
-Slab->Pointers.push_back(&Sym.second);
-
-  auto *Pointers = &Slab->Pointers;
-  return {std::move(Slab), Pointers};
+  auto Storage = std::make_shared();
+  Storage->Slab = std::move(Slab).build();
+  for (const auto &Sym : Storage->Slab)
+Storage->Pointers.push_back(&Sym);
+  if (WeakSymbols)
+*WeakSymbols = Storage;
+  auto *Pointers = &Storage->Pointers;
+  return {std::move(Storage), Pointers};
 }
 
 // Create a slab of symbols with IDs and names [Begin, End], otherwise identical
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -28,9 +28,11 @@
   return Sym;
 }
 
-void addNumSymbolsToSlab(int Begin, int End, SymbolSlab *Slab) {
+std::unique_ptr numSlab(int Begin, int End) {
+  SymbolSlab::Builder Slab;
   for (int i = Begin; i <= End; i++)
-Slab->insert(symbol(std::to_string(i)));
+Slab.insert(symbol(std::to_string(i)));
+  return llvm::make_unique(std::move(Slab).build());
 }
 
 std::vector
@@ -45,46 +47,29 @@
   FileSymbols FS;
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()), UnorderedElementsAre());
 
-  auto Slab = llvm::make_unique();
-  addNumSymbolsToSlab(1, 3, Slab.get());
-
-  FS.update("f1", std::move(Slab));
-
+  FS.update("f1", numSlab(1, 3));
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()),
   UnorderedElementsAre("1", "2", "3"));
 }
 
 TEST(FileSymbolsTest, Overlap) {
   FileSymbols FS;
-
-  auto Slab = llvm::make_unique();
-  addNumSymbolsToSlab(1, 3, Slab.get());
-
-  FS.update("f1", std::move(Slab));
-
-  Slab = llvm::make_unique();
-  addNumSymbolsToSlab(3, 5, Slab.get());
-
-  FS.update("f2", std::move(Slab));
-
+  FS.update("f1", numSlab(1, 3));
+  FS.update("f2", numSlab(3, 5));
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()),
   UnorderedElementsAre("1", "2", "3", "3", "4", "5"));
 }
 
 TEST(FileSymbolsTest, SnapshotAliveAfterRemove) {
   FileSymbols FS;
 
-  auto Slab = llvm::make_unique();
-  addNumSymbolsToSlab(1, 3, Slab.get());
-
-  FS.update("f1", std::move(Slab));
+  FS.update("f1", numSlab(1, 3));
 
   auto Symbols = FS.allSymbols();
   EXPECT_THAT(getSymbolNames(*Symbols), UnorderedElementsAre("1", "2", "3"));
 
   FS.update("f1", nullptr);
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()), UnorderedElementsAre());
-
   EXPECT_THAT(getSymbolNames(*Symbols), UnorderedElementsAre("1", "2", "3"));
 }
 
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -44

Re: r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-21 Thread Alex L via cfe-commits
Thanks for raising your concerns.

We decided to avoid -m-version-min flag in favor of -target to simplify
the driver logic and to encourage the adoption of -target. Now after r321145
we only warn about -m-version-min flag when the OS version specified in
it is different to the OS version specified in target, or when target has
no OS version.

There are two possible solutions here:
1) You can still use -target with -mios-simulator-version-min as before but
you'd have to use '-target=x86_64-apple-darwin' to ensure that the iOS
version specified by  '-mios-simulator-version-min' is used.
2) I also do have a patch that implements the logic that you propose (use
the OS version in -m-version-min flag if target has none). If you
believe that the first solution is not suitable for your code then I can
commit it. At the same time I believe that we would rather not use this
patch, but if it's urgent for your projects then maybe I can land it now
and then we can establish some sort of timeline for when it can be reverted?

Thanks,
Alex


On 21 December 2017 at 08:00, James Y Knight  wrote:

> I think if a version number isn't explicitly specified in the -target
> value, the value from -m-version-min ought to still be used, as
> it was before.
>
> Currently, clang will ignore the -m-version-min version number
> if the target has a particular OS specified, even if it has no version
> number as part of it.
>
> (We should be able to workaround this change backwards-compatibly by
> specifying in both the -target argument and in the -m-version-min
> arguments, but I do think the behavior should be fixed.)
>
> On Thu, Dec 21, 2017 at 10:45 AM, Martin Böhme  wrote:
>
>> This is causing problems in some internal builds that specify both
>> -mios-simulator-version-min=9.0 and --target=x86_64-apple-ios
>>
>> My expectation would be for the code to take the minimum OS version
>> number from the -mios-simulator-version-min flag. In fact, however, the
>> code seems to be completely ignoring this flag.
>>
>> Is my expectation wrong or does the code need to be modified to take this
>> situation into account?
>>
>>
>> On 19 December 2017 at 20:05, Alex Lorenz via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: arphaman
>>> Date: Tue Dec 19 11:05:04 2017
>>> New Revision: 321099
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=321099&view=rev
>>> Log:
>>> [driver][darwin] Take the OS version specified in "-target" as the target
>>> OS instead of inferring it from SDK / environment
>>>
>>> The OS version is specified in -target should be used instead of the one
>>> in an
>>> environment variable / SDK name.
>>>
>>> rdar://35813850
>>>
>>> Differential Revision: https://reviews.llvm.org/D40998
>>>
>>> Modified:
>>> cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>>> cfe/trunk/test/Driver/darwin-version.c
>>> cfe/trunk/test/Driver/objc-weak.m
>>> cfe/trunk/test/Driver/pic.c
>>> cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp
>>>
>>> Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
>>> lChains/Darwin.cpp?rev=321099&r1=321098&r2=321099&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
>>> +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Dec 19 11:05:04 2017
>>> @@ -1233,6 +1233,10 @@ struct DarwinPlatform {
>>>  llvm_unreachable("Unsupported Darwin Source Kind");
>>>}
>>>
>>> +  static DarwinPlatform createFromTarget(llvm::Triple::OSType OS,
>>> + StringRef OSVersion, Arg *A) {
>>> +return DarwinPlatform(TargetArg, getPlatformFromOS(OS), OSVersion,
>>> A);
>>> +  }
>>>static DarwinPlatform createOSVersionArg(DarwinPlatformKind Platform,
>>> Arg *A) {
>>>  return DarwinPlatform(OSVersionArg, Platform, A);
>>> @@ -1250,33 +1254,32 @@ struct DarwinPlatform {
>>>}
>>>static DarwinPlatform createFromArch(llvm::Triple::OSType OS,
>>> StringRef Value) {
>>> -DarwinPlatformKind Platform;
>>> +return DarwinPlatform(InferredFromArch, getPlatformFromOS(OS),
>>> Value);
>>> +  }
>>> +
>>> +private:
>>> +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, Arg
>>> *Argument)
>>> +  : Kind(Kind), Platform(Platform), Argument(Argument) {}
>>> +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform,
>>> StringRef Value,
>>> + Arg *Argument = nullptr)
>>> +  : Kind(Kind), Platform(Platform), OSVersion(Value),
>>> Argument(Argument) {}
>>> +
>>> +  static DarwinPlatformKind getPlatformFromOS(llvm::Triple::OSType OS)
>>> {
>>>  switch (OS) {
>>>  case llvm::Triple::Darwin:
>>>  case llvm::Triple::MacOSX:
>>> -  Platform = DarwinPlatformKind::MacOS;
>>> -  break;
>>> +  return DarwinPlatformKind::MacOS;
>>>  

[PATCH] D41506: [clangd] Use Builder for symbol slabs, and use sorted-vector for storage

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 127918.
sammccall added a comment.

minor doc and code layout tweaks


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41506

Files:
  clangd/index/FileIndex.cpp
  clangd/index/Index.cpp
  clangd/index/Index.h
  clangd/index/SymbolCollector.cpp
  clangd/index/SymbolCollector.h
  clangd/index/SymbolYAML.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/IndexTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -32,8 +32,7 @@
 
 // GMock helpers for matching Symbol.
 MATCHER_P(QName, Name, "") {
-  return (arg.second.Scope + (arg.second.Scope.empty() ? "" : "::") +
-  arg.second.Name).str() == Name;
+  return (arg.Scope + (arg.Scope.empty() ? "" : "::") + arg.Name).str() == Name;
 }
 
 namespace clang {
Index: unittests/clangd/IndexTests.cpp
===
--- unittests/clangd/IndexTests.cpp
+++ unittests/clangd/IndexTests.cpp
@@ -45,18 +45,18 @@
 std::shared_ptr>
 generateSymbols(std::vector QualifiedNames,
 std::weak_ptr *WeakSymbols = nullptr) {
-  auto Slab = std::make_shared();
-  if (WeakSymbols)
-*WeakSymbols = Slab;
-
+  SymbolSlab::Builder Slab;
   for (llvm::StringRef QName : QualifiedNames)
-Slab->Slab.insert(symbol(QName));
+Slab.insert(symbol(QName));
 
-  for (const auto &Sym : Slab->Slab)
-Slab->Pointers.push_back(&Sym.second);
-
-  auto *Pointers = &Slab->Pointers;
-  return {std::move(Slab), Pointers};
+  auto Storage = std::make_shared();
+  Storage->Slab = std::move(Slab).build();
+  for (const auto &Sym : Storage->Slab)
+Storage->Pointers.push_back(&Sym);
+  if (WeakSymbols)
+*WeakSymbols = Storage;
+  auto *Pointers = &Storage->Pointers;
+  return {std::move(Storage), Pointers};
 }
 
 // Create a slab of symbols with IDs and names [Begin, End], otherwise identical
Index: unittests/clangd/FileIndexTests.cpp
===
--- unittests/clangd/FileIndexTests.cpp
+++ unittests/clangd/FileIndexTests.cpp
@@ -28,9 +28,11 @@
   return Sym;
 }
 
-void addNumSymbolsToSlab(int Begin, int End, SymbolSlab *Slab) {
+std::unique_ptr numSlab(int Begin, int End) {
+  SymbolSlab::Builder Slab;
   for (int i = Begin; i <= End; i++)
-Slab->insert(symbol(std::to_string(i)));
+Slab.insert(symbol(std::to_string(i)));
+  return llvm::make_unique(std::move(Slab).build());
 }
 
 std::vector
@@ -45,46 +47,29 @@
   FileSymbols FS;
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()), UnorderedElementsAre());
 
-  auto Slab = llvm::make_unique();
-  addNumSymbolsToSlab(1, 3, Slab.get());
-
-  FS.update("f1", std::move(Slab));
-
+  FS.update("f1", numSlab(1, 3));
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()),
   UnorderedElementsAre("1", "2", "3"));
 }
 
 TEST(FileSymbolsTest, Overlap) {
   FileSymbols FS;
-
-  auto Slab = llvm::make_unique();
-  addNumSymbolsToSlab(1, 3, Slab.get());
-
-  FS.update("f1", std::move(Slab));
-
-  Slab = llvm::make_unique();
-  addNumSymbolsToSlab(3, 5, Slab.get());
-
-  FS.update("f2", std::move(Slab));
-
+  FS.update("f1", numSlab(1, 3));
+  FS.update("f2", numSlab(3, 5));
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()),
   UnorderedElementsAre("1", "2", "3", "3", "4", "5"));
 }
 
 TEST(FileSymbolsTest, SnapshotAliveAfterRemove) {
   FileSymbols FS;
 
-  auto Slab = llvm::make_unique();
-  addNumSymbolsToSlab(1, 3, Slab.get());
-
-  FS.update("f1", std::move(Slab));
+  FS.update("f1", numSlab(1, 3));
 
   auto Symbols = FS.allSymbols();
   EXPECT_THAT(getSymbolNames(*Symbols), UnorderedElementsAre("1", "2", "3"));
 
   FS.update("f1", nullptr);
   EXPECT_THAT(getSymbolNames(*FS.allSymbols()), UnorderedElementsAre());
-
   EXPECT_THAT(getSymbolNames(*Symbols), UnorderedElementsAre("1", "2", "3"));
 }
 
Index: unittests/clangd/CodeCompleteTests.cpp
===
--- unittests/clangd/CodeCompleteTests.cpp
+++ unittests/clangd/CodeCompleteTests.cpp
@@ -449,6 +449,7 @@
 std::vector Pointers;
   };
   auto Snap = std::make_shared();
+  SymbolSlab::Builder Slab;
   for (const auto &Pair : Symbols) {
 Symbol Sym;
 Sym.ID = SymbolID(Pair.first);
@@ -462,10 +463,11 @@
   Sym.Scope = QName.substr(0, Pos);
 }
 Sym.SymInfo.Kind = Pair.second;
-Snap->Slab.insert(std::move(Sym));
+Slab.insert(Sym);
   }
+  Snap->Slab = std::move(Slab).build();
   for (auto &Iter : Snap->Slab)
-Snap->Pointers.push_back(&Iter.second);
+Snap->Pointers.push_back(&Iter);
   auto S = std::shared_ptr>(std::move(Snap),
 &Snap->Pointers);
   I->build(std::move(S));
Index: clangd/ind

[PATCH] D41498: [libcxx] Add clang negative thread safety assertions to std::mutex

2017-12-21 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/__mutex_base:65
 void unlock() _NOEXCEPT 
_LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
+#ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS
+const mutex& operator!() const { return *this; }

We don't get to add public member functions to classes defined in the standard 
- at least not ones with pronounceable names.



Repository:
  rCXX libc++

https://reviews.llvm.org/D41498



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


[PATCH] D40443: [Modules TS] Make imports from an interface unit visible to its implementation units

2017-12-21 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood added a comment.

Ping


https://reviews.llvm.org/D40443



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


[PATCH] D41507: avxintrin.h documentation fixes and updates

2017-12-21 Thread Douglas Yung via Phabricator via cfe-commits
dyung created this revision.

This is the result of several patches we made internally to update the 
documentation that we would like to have reviewed for possible submission.

The changes include:

1. Fix incorrect wording in various intrinsic descriptions. Previously the 
descriptions used "low-order" and "high-order" when the intended meaning was 
"even-indexed" and "odd-indexed".
2. Fix a few typos and errors found during review.
3. Restore new line endings and change to use hex suffixes (0h instead of 0x0).

These patches were made by Craig Flores


https://reviews.llvm.org/D41507

Files:
  lib/Headers/avxintrin.h

Index: lib/Headers/avxintrin.h
===
--- lib/Headers/avxintrin.h
+++ lib/Headers/avxintrin.h
@@ -1120,7 +1120,7 @@
 /// \param A
 ///A 256-bit vector of [8 x float].
 /// \param C
-///An immediate integer operand specifying how the values are to be \n
+///An immediate integer operand specifying how the values are to be
 ///copied. \n
 ///Bits [1:0]: \n
 ///  00: Bits [31:0] of the source are copied to bits [31:0] of the
@@ -1150,7 +1150,7 @@
 ///  11: Bits [127:96] of the source are copied to bits [95:64] of the
 ///  returned vector. \n
 ///Bits [7:6]: \n
-///  00: Bits [31:qq0] of the source are copied to bits [127:96] of the
+///  00: Bits [31:0] of the source are copied to bits [127:96] of the
 ///  returned vector. \n
 ///  01: Bits [63:32] of the source are copied to bits [127:96] of the
 ///  returned vector. \n
@@ -1665,38 +1665,38 @@
 /// \param c
 ///An immediate integer operand, with bits [4:0] specifying which comparison
 ///operation to use: \n
-///0x00 : Equal (ordered, non-signaling)
-///0x01 : Less-than (ordered, signaling)
-///0x02 : Less-than-or-equal (ordered, signaling)
-///0x03 : Unordered (non-signaling)
-///0x04 : Not-equal (unordered, non-signaling)
-///0x05 : Not-less-than (unordered, signaling)
-///0x06 : Not-less-than-or-equal (unordered, signaling)
-///0x07 : Ordered (non-signaling)
-///0x08 : Equal (unordered, non-signaling)
-///0x09 : Not-greater-than-or-equal (unordered, signaling)
-///0x0a : Not-greater-than (unordered, signaling)
-///0x0b : False (ordered, non-signaling)
-///0x0c : Not-equal (ordered, non-signaling)
-///0x0d : Greater-than-or-equal (ordered, signaling)
-///0x0e : Greater-than (ordered, signaling)
-///0x0f : True (unordered, non-signaling)
-///0x10 : Equal (ordered, signaling)
-///0x11 : Less-than (ordered, non-signaling)
-///0x12 : Less-than-or-equal (ordered, non-signaling)
-///0x13 : Unordered (signaling)
-///0x14 : Not-equal (unordered, signaling)
-///0x15 : Not-less-than (unordered, non-signaling)
-///0x16 : Not-less-than-or-equal (unordered, non-signaling)
-///0x17 : Ordered (signaling)
-///0x18 : Equal (unordered, signaling)
-///0x19 : Not-greater-than-or-equal (unordered, non-signaling)
-///0x1a : Not-greater-than (unordered, non-signaling)
-///0x1b : False (ordered, signaling)
-///0x1c : Not-equal (ordered, signaling)
-///0x1d : Greater-than-or-equal (ordered, non-signaling)
-///0x1e : Greater-than (ordered, non-signaling)
-///0x1f : True (unordered, signaling)
+///00h: Equal (ordered, non-signaling) \n
+///01h: Less-than (ordered, signaling) \n
+///02h: Less-than-or-equal (ordered, signaling) \n
+///03h: Unordered (non-signaling) \n
+///04h: Not-equal (unordered, non-signaling) \n
+///05h: Not-less-than (unordered, signaling) \n
+///06h: Not-less-than-or-equal (unordered, signaling) \n
+///07h: Ordered (non-signaling) \n
+///08h: Equal (unordered, non-signaling) \n
+///09h: Not-greater-than-or-equal (unordered, signaling) \n
+///0Ah: Not-greater-than (unordered, signaling) \n
+///0Bh: False (ordered, non-signaling) \n
+///0Ch: Not-equal (ordered, non-signaling) \n
+///0Dh: Greater-than-or-equal (ordered, signaling) \n
+///0Eh: Greater-than (ordered, signaling) \n
+///0Fh: True (unordered, non-signaling) \n
+///10h: Equal (ordered, signaling) \n
+///11h: Less-than (ordered, non-signaling) \n
+///12h: Less-than-or-equal (ordered, non-signaling) \n
+///13h: Unordered (signaling) \n
+///14h: Not-equal (unordered, signaling) \n
+///15h: Not-less-than (unordered, non-signaling) \n
+///16h: Not-less-than-or-equal (unordered, non-signaling) \n
+///17h: Ordered (signaling) \n
+///18h: Equal (unordered, signaling) \n
+///19h: Not-greater-than-or-equal (unordered, non-signaling) \n
+///1Ah: Not-greater-than (unordered, non-signaling) \n
+///1Bh: False (ordered, signaling) \n
+///1Ch: Not-equal (ordered, signaling) \n
+///1Dh: Greater-than-or-equal (ordered, non-signaling) \n
+///1Eh: Greater-than (ordered, non-signaling) \n
+///1Fh: True (unordered, signal

r321296 - [CodeGen] Fix crash when a function taking transparent union is redeclared.

2017-12-21 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Thu Dec 21 11:42:37 2017
New Revision: 321296

URL: http://llvm.org/viewvc/llvm-project?rev=321296&view=rev
Log:
[CodeGen] Fix crash when a function taking transparent union is redeclared.

When a function taking transparent union is declared as taking one of
union members earlier in the translation unit, clang would hit an
"Invalid cast" assertion during EmitFunctionProlog. This case
corresponds to function f1 in test/CodeGen/transparent-union-redecl.c.
We decided to cast i32 to union because after merging function
declarations function parameter type becomes int,
CGFunctionInfo::ArgInfo type matches with ABIArgInfo type, so we decide
it is a trivial case. But these types should also be castable to
parameter declaration type which is not the case here.

The fix is in checking for the trivial case if ABIArgInfo type matches with
parameter declaration type. It exposed inconsistency that we check
hasScalarEvaluationKind for different types in EmitParmDecl and
EmitFunctionProlog, and comment says they should match.

Additional tests in Sema/transparent-union.c capture current behavior and make
sure there are no regressions.

rdar://problem/34949329

Reviewers: rjmccall, rafael

Reviewed By: rjmccall

Subscribers: aemerson, cfe-commits, kristof.beyls

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

Added:
cfe/trunk/test/CodeGen/transparent-union-redecl.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGen/kr-func-promote.c
cfe/trunk/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
cfe/trunk/test/Sema/transparent-union.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=321296&r1=321295&r2=321296&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Dec 21 11:42:37 2017
@@ -2317,7 +2317,7 @@ void CodeGenFunction::EmitFunctionProlog
 
   // If we have the trivial case, handle it with no muss and fuss.
   if (!isa(ArgI.getCoerceToType()) &&
-  ArgI.getCoerceToType() == ConvertType(Ty) &&
+  ArgI.getCoerceToType() == ConvertType(Arg->getType()) &&
   ArgI.getDirectOffset() == 0) {
 assert(NumIRArgs == 1);
 llvm::Value *V = FnArgs[FirstIRArg];
@@ -2414,8 +2414,8 @@ void CodeGenFunction::EmitFunctionProlog
 break;
   }
 
-  Address Alloca = CreateMemTemp(Ty, getContext().getDeclAlign(Arg),
- Arg->getName());
+  Address Alloca = CreateMemTemp(
+  Arg->getType(), getContext().getDeclAlign(Arg), Arg->getName());
 
   // Pointer to store into.
   Address Ptr = emitAddressAtOffset(*this, Alloca, ArgI);
@@ -2461,9 +2461,9 @@ void CodeGenFunction::EmitFunctionProlog
   }
 
   // Match to what EmitParmDecl is expecting for this type.
-  if (CodeGenFunction::hasScalarEvaluationKind(Ty)) {
+  if (CodeGenFunction::hasScalarEvaluationKind(Arg->getType())) {
 llvm::Value *V =
-  EmitLoadOfScalar(Alloca, false, Ty, Arg->getLocStart());
+EmitLoadOfScalar(Alloca, false, Arg->getType(), 
Arg->getLocStart());
 if (isPromoted)
   V = emitArgumentDemotion(*this, Arg, V);
 ArgVals.push_back(ParamValue::forDirect(V));

Modified: cfe/trunk/test/CodeGen/kr-func-promote.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/kr-func-promote.c?rev=321296&r1=321295&r2=321296&view=diff
==
--- cfe/trunk/test/CodeGen/kr-func-promote.c (original)
+++ cfe/trunk/test/CodeGen/kr-func-promote.c Thu Dec 21 11:42:37 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck 
%s
-// CHECK: i32 @a(i32)
+// CHECK: i32 @a(i32
 
 int a();
 int a(x) short x; {return x;}

Added: cfe/trunk/test/CodeGen/transparent-union-redecl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/transparent-union-redecl.c?rev=321296&view=auto
==
--- cfe/trunk/test/CodeGen/transparent-union-redecl.c (added)
+++ cfe/trunk/test/CodeGen/transparent-union-redecl.c Thu Dec 21 11:42:37 2017
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
+
+// Test that different order of declarations is acceptable and that
+// implementing different redeclarations is acceptable.
+// rdar://problem/34949329
+
+typedef union {
+  int i;
+  float f;
+} TU __attribute__((transparent_union));
+
+// CHECK-LABEL: define void @f0(i32 %tu.coerce)
+// CHECK: %tu = alloca %union.TU, align 4
+// CHECK: %coerce.dive = getelementptr inbounds %union.

[PATCH] D41311: [CodeGen] Fix crash when a function taking transparent union is redeclared.

2017-12-21 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321296: [CodeGen] Fix crash when a function taking 
transparent union is redeclared. (authored by vsapsai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41311?vs=127779&id=127923#toc

Repository:
  rC Clang

https://reviews.llvm.org/D41311

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGen/kr-func-promote.c
  test/CodeGen/transparent-union-redecl.c
  test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
  test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
  test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
  test/Sema/transparent-union.c

Index: test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
===
--- test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
+++ test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
@@ -115,9 +115,15 @@
 // B::foo gets 'this' cast to VBase* in ECX (i.e. this+8) so we
 // need to adjust 'this' before use.
 //
-// Store initial this:
+// Coerce this to correct type:
+// CHECK:   %[[THIS_STORE:.*]] = alloca %struct.B*
 // CHECK:   %[[THIS_ADDR:.*]] = alloca %struct.B*
-// CHECK:   store %struct.B* %{{.*}}, %struct.B** %[[THIS_ADDR]], align 4
+// CHECK:   %[[COERCE_VAL:.*]] = bitcast i8* %{{.*}} to %struct.B*
+// CHECK:   store %struct.B* %[[COERCE_VAL]], %struct.B** %[[THIS_STORE]], align 4
+//
+// Store initial this:
+// CHECK:   %[[THIS_INIT:.*]] = load %struct.B*, %struct.B** %[[THIS_STORE]]
+// CHECK:   store %struct.B* %[[THIS_INIT]], %struct.B** %[[THIS_ADDR]], align 4
 //
 // Reload and adjust the this parameter:
 // CHECK:   %[[THIS_RELOAD:.*]] = load %struct.B*, %struct.B** %[[THIS_ADDR]]
Index: test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
===
--- test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
+++ test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
@@ -25,6 +25,7 @@
 
 // CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@D@@$4PPPM@A@AEXXZ"
 // Note that the vtordisp is applied before really adjusting to D*.
+// CHECK: %[[COERCE_LOAD:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX_i8:.*]] = bitcast %struct.D* %[[ECX]] to i8*
 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -4
@@ -36,6 +37,7 @@
 // CHECK: ret void
 
 // CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@D@@$4PPPI@3AEXXZ"
+// CHECK: %[[COERCE_LOAD:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX:.*]] = load %struct.D*, %struct.D** %{{.*}}
 // CHECK: %[[ECX_i8:.*]] = bitcast %struct.D* %[[ECX]] to i8*
 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -8
@@ -64,7 +66,8 @@
 
 G::G() {}  // Forces vftable emission.
 
-// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@E@@$R4BA@M@PPPM@7AEXXZ"(i8*)
+// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"\01?f@E@@$R4BA@M@PPPM@7AEXXZ"(i8*
+// CHECK: %[[COERCE_LOAD:.*]] = load %struct.E*, %struct.E** %{{.*}}
 // CHECK: %[[ECX:.*]] = load %struct.E*, %struct.E** %{{.*}}
 // CHECK: %[[ECX_i8:.*]] = bitcast %struct.E* %[[ECX]] to i8*
 // CHECK: %[[VTORDISP_PTR_i8:.*]] = getelementptr inbounds i8, i8* %[[ECX_i8]], i32 -4
Index: test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
===
--- test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
+++ test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
@@ -88,8 +88,11 @@
 // ChildOverride::right gets 'this' cast to Right* in ECX (i.e. this+4) so we
 // need to adjust 'this' before use.
 //
+// CHECK: %[[THIS_STORE:.*]] = alloca %struct.ChildOverride*, align 4
 // CHECK: %[[THIS_ADDR:.*]] = alloca %struct.ChildOverride*, align 4
-// CHECK: %[[THIS_INIT:.*]] = bitcast i8* %[[ECX:.*]] to %struct.ChildOverride*
+// CHECK: %[[COERCE_VAL:.*]] = bitcast i8* %[[ECX:.*]] to %struct.ChildOverride*
+// CHECK: store %struct.ChildOverride* %[[COERCE_VAL]], %struct.ChildOverride** %[[THIS_STORE]], align 4
+// CHECK: %[[THIS_INIT:.*]] = load %struct.ChildOverride*, %struct.ChildOverride** %[[THIS_STORE]], align 4
 // CHECK: store %struct.ChildOverride* %[[THIS_INIT]], %struct.ChildOverride** %[[THIS_ADDR]], align 4
 // CHECK: %[[THIS_RELOAD:.*]] = load %struct.ChildOverride*, %struct.ChildOverride** %[[THIS_ADDR]]
 // CHECK: %[[THIS_i8:.*]] = bitcast %struct.ChildOverride* %[[THIS_RELOAD]] to i8*
@@ -132,8 +135,11 @@
 void GrandchildOverride::right() {
 // CHECK-LABEL: define x86_thiscallcc void @"\01?right@GrandchildOverride@@UAEXXZ"(i8*
 //
+// CHECK: %[[THIS_STORE:.*]] = alloca %struct.GrandchildOverride*, align 4
 // CHECK: %[[THIS_ADDR:.*]] = alloca %struct.GrandchildOverride*, align 4
-// CHECK: %[[THIS_INIT:

r321297 - When instantiating a deduction guide, transform its name.

2017-12-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec 21 11:43:39 2017
New Revision: 321297

URL: http://llvm.org/viewvc/llvm-project?rev=321297&view=rev
Log:
When instantiating a deduction guide, transform its name.

Otherwise it will serve as a deduction guide for the wrong class template.

Added:
cfe/trunk/test/SemaTemplate/nested-deduction-guides.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=321297&r1=321296&r2=321297&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Thu Dec 21 11:43:39 2017
@@ -1587,9 +1587,10 @@ static QualType adjustFunctionTypeForIns
 }
 
 /// Normal class members are of more specific types and therefore
-/// don't make it here.  This function serves two purposes:
+/// don't make it here.  This function serves three purposes:
 ///   1) instantiating function templates
 ///   2) substituting friend declarations
+///   3) substituting deduction guide declarations for nested class templates
 Decl *TemplateDeclInstantiator::VisitFunctionDecl(FunctionDecl *D,
TemplateParameterList *TemplateParams) {
   // Check whether there is already a function template specialization for
@@ -1650,16 +1651,19 @@ Decl *TemplateDeclInstantiator::VisitFun
  TemplateArgs);
   }
 
+  DeclarationNameInfo NameInfo
+= SemaRef.SubstDeclarationNameInfo(D->getNameInfo(), TemplateArgs);
+
   FunctionDecl *Function;
   if (auto *DGuide = dyn_cast(D)) {
 Function = CXXDeductionGuideDecl::Create(
   SemaRef.Context, DC, D->getInnerLocStart(), DGuide->isExplicit(),
-  D->getNameInfo(), T, TInfo, D->getSourceRange().getEnd());
+  NameInfo, T, TInfo, D->getSourceRange().getEnd());
 if (DGuide->isCopyDeductionCandidate())
   cast(Function)->setIsCopyDeductionCandidate();
   } else {
 Function = FunctionDecl::Create(
-SemaRef.Context, DC, D->getInnerLocStart(), D->getNameInfo(), T, TInfo,
+SemaRef.Context, DC, D->getInnerLocStart(), NameInfo, T, TInfo,
 D->getCanonicalDecl()->getStorageClass(), D->isInlineSpecified(),
 D->hasWrittenPrototype(), D->isConstexpr());
 Function->setRangeEnd(D->getSourceRange().getEnd());

Added: cfe/trunk/test/SemaTemplate/nested-deduction-guides.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/nested-deduction-guides.cpp?rev=321297&view=auto
==
--- cfe/trunk/test/SemaTemplate/nested-deduction-guides.cpp (added)
+++ cfe/trunk/test/SemaTemplate/nested-deduction-guides.cpp Thu Dec 21 11:43:39 
2017
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+// expected-no-diagnostics
+
+template struct A {
+  template struct B {
+B(...);
+  };
+  template B(U) -> B;
+};
+A::B b = 123;
+
+using T = decltype(b);
+using T = A::B;


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


r321298 - Revert "Fix for PR32990"

2017-12-21 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Dec 21 11:44:23 2017
New Revision: 321298

URL: http://llvm.org/viewvc/llvm-project?rev=321298&view=rev
Log:
Revert "Fix for PR32990"

This reverts commit r321239. It broke the Chromium DLL build:

[8834/50217] LINK(DLL) icui18n.dll icui18n.dll.lib icui18n.dll.pdb
FAILED: icui18n.dll icui18n.dll.lib icui18n.dll.pdb
zrule.obj : error LNK2001: unresolved external symbol
"__declspec(dllimport) public: void __cdecl icu_60::UnicodeString::`vbase 
destructor'(void)"
(__imp_??_DUnicodeString@icu_60@@QEAAXXZ)

Removed:
cfe/trunk/test/CodeGenCXX/dllimport-virtual-base.cpp
cfe/trunk/test/CodeGenCXX/external-linkage.cpp
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp
cfe/trunk/test/CodeGenCXX/dllimport-members.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=321298&r1=321297&r2=321298&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Dec 21 11:44:23 2017
@@ -856,25 +856,14 @@ CodeGenModule::getFunctionLinkage(Global
   GVALinkage Linkage = getContext().GetGVALinkageForFunction(D);
 
   if (isa(D) &&
-  Context.getTargetInfo().getCXXABI().isMicrosoft()) {
-switch (GD.getDtorType()) {
-case CXXDtorType::Dtor_Base:
-  break;
-case CXXDtorType::Dtor_Comdat:
-case CXXDtorType::Dtor_Complete:
-  if (D->hasAttr() &&
- (cast(D)->getParent()->getNumVBases() ||
-  (Linkage == GVA_AvailableExternally ||
-   Linkage == GVA_StrongExternal)))
-   return llvm::Function::AvailableExternallyLinkage;
-  else
-return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage
-   : llvm::GlobalValue::LinkOnceODRLinkage;
-case CXXDtorType::Dtor_Deleting:
-  return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage
- : llvm::GlobalValue::LinkOnceODRLinkage;
-}
+  getCXXABI().useThunkForDtorVariant(cast(D),
+ GD.getDtorType())) {
+// Destructor variants in the Microsoft C++ ABI are always internal or
+// linkonce_odr thunks emitted on an as-needed basis.
+return Linkage == GVA_Internal ? llvm::GlobalValue::InternalLinkage
+   : llvm::GlobalValue::LinkOnceODRLinkage;
   }
+
   if (isa(D) &&
   cast(D)->isInheritingConstructor() &&
   Context.getTargetInfo().getCXXABI().isMicrosoft()) {
@@ -890,25 +879,12 @@ CodeGenModule::getFunctionLinkage(Global
 void CodeGenModule::setFunctionDLLStorageClass(GlobalDecl GD, llvm::Function 
*F) {
   const auto *FD = cast(GD.getDecl());
 
-  if (dyn_cast_or_null(FD)) {
-switch (GD.getDtorType()) {
-case CXXDtorType::Dtor_Comdat:
-case CXXDtorType::Dtor_Deleting: {
+  if (const auto *Dtor = dyn_cast_or_null(FD)) {
+if (getCXXABI().useThunkForDtorVariant(Dtor, GD.getDtorType())) {
   // Don't dllexport/import destructor thunks.
   F->setDLLStorageClass(llvm::GlobalValue::DefaultStorageClass);
   return;
 }
-case CXXDtorType::Dtor_Complete:
-  if (FD->hasAttr())
-F->setDLLStorageClass(llvm::GlobalVariable::DLLImportStorageClass);
-  else if (FD->hasAttr())
-F->setDLLStorageClass(llvm::GlobalVariable::DLLExportStorageClass);
-  else
-F->setDLLStorageClass(llvm::GlobalVariable::DefaultStorageClass);
-  return;
-case CXXDtorType::Dtor_Base:
-  break;
-}
   }
 
   if (FD->hasAttr())

Modified: cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp?rev=321298&r1=321297&r2=321298&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport-dtor-thunks.cpp Thu Dec 21 11:44:23 2017
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -mconstructor-aliases %s -triple x86_64-windows-msvc 
-fms-extensions -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 -mconstructor-aliases %s -triple x86_64-windows-msvc 
-fms-extensions -emit-llvm -O1 -disable-llvm-passes -o - | FileCheck 
--check-prefix=MO1 %s
 
 // FIXME: We should really consider removing -mconstructor-aliases for MS C++
 // ABI. The risk of bugs introducing ABI incompatibility under
@@ -24,7 +23,9 @@ struct __declspec(dllimport) ImportOverr
   virtual ~ImportOverrideVDtor() {}
 };
 
-// Virtually inherits from a non-dllimport base class. Emit the vbase 
destructor.
+// Virtually inherits from a non-dllimport base class. This time we need to 
call
+// the complete destructor and emit it inline. It's not exported from the DLL,
+// and it must be emitte

[PATCH] D41103: [CMake] Allow passing extra CMake arguments to custom libc++

2017-12-21 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321299: [CMake] Allow passing extra CMake arguments to 
custom libc++ (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41103?vs=126488&id=127924#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41103

Files:
  compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake


Index: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
===
--- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
@@ -469,7 +469,7 @@
 message(FATAL_ERROR "libcxx not found!")
   endif()
 
-  cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS" ${ARGN})
+  cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS;CMAKE_ARGS" ${ARGN})
   foreach(flag ${LIBCXX_CFLAGS})
 set(flagstr "${flagstr} ${flag}")
   endforeach()
@@ -491,6 +491,7 @@
-DCMAKE_INSTALL_PREFIX:PATH=
-DLLVM_PATH=${LLVM_MAIN_SRC_DIR}
-DLIBCXX_STANDALONE_BUILD=On
+   ${LIBCXX_CMAKE_ARGS}
 LOG_BUILD 1
 LOG_CONFIGURE 1
 LOG_INSTALL 1


Index: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
===
--- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake
@@ -469,7 +469,7 @@
 message(FATAL_ERROR "libcxx not found!")
   endif()
 
-  cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS" ${ARGN})
+  cmake_parse_arguments(LIBCXX "" "" "DEPS;CFLAGS;CMAKE_ARGS" ${ARGN})
   foreach(flag ${LIBCXX_CFLAGS})
 set(flagstr "${flagstr} ${flag}")
   endforeach()
@@ -491,6 +491,7 @@
-DCMAKE_INSTALL_PREFIX:PATH=
-DLLVM_PATH=${LLVM_MAIN_SRC_DIR}
-DLIBCXX_STANDALONE_BUILD=On
+   ${LIBCXX_CMAKE_ARGS}
 LOG_BUILD 1
 LOG_CONFIGURE 1
 LOG_INSTALL 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321301 - [AArch64] Enable fp16 data type for the Builtin for AArch64 only.

2017-12-21 Thread Abderrazek Zaafrani via cfe-commits
Author: az
Date: Thu Dec 21 12:10:03 2017
New Revision: 321301

URL: http://llvm.org/viewvc/llvm-project?rev=321301&view=rev
Log:
[AArch64] Enable fp16 data type for the Builtin for AArch64 only.

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/arm_neon_intrinsics.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=321301&r1=321300&r2=321301&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Dec 21 12:10:03 2017
@@ -3334,10 +3334,10 @@ static Value *EmitTargetArchBuiltinExpr(
   case llvm::Triple::armeb:
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb:
-return CGF->EmitARMBuiltinExpr(BuiltinID, E);
+return CGF->EmitARMBuiltinExpr(BuiltinID, E, Arch);
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be:
-return CGF->EmitAArch64BuiltinExpr(BuiltinID, E);
+return CGF->EmitAArch64BuiltinExpr(BuiltinID, E, Arch);
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
 return CGF->EmitX86BuiltinExpr(BuiltinID, E);
@@ -3378,6 +3378,7 @@ Value *CodeGenFunction::EmitTargetBuilti
 
 static llvm::VectorType *GetNeonType(CodeGenFunction *CGF,
  NeonTypeFlags TypeFlags,
+ llvm::Triple::ArchType Arch,
  bool V1Ty=false) {
   int IsQuad = TypeFlags.isQuad();
   switch (TypeFlags.getEltType()) {
@@ -3388,7 +3389,12 @@ static llvm::VectorType *GetNeonType(Cod
   case NeonTypeFlags::Poly16:
 return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
   case NeonTypeFlags::Float16:
-return llvm::VectorType::get(CGF->HalfTy, V1Ty ? 1 : (4 << IsQuad));
+// FIXME: Only AArch64 backend can so far properly handle half types.
+// Remove else part once ARM backend support for half is complete.
+if (Arch == llvm::Triple::aarch64)
+  return llvm::VectorType::get(CGF->HalfTy, V1Ty ? 1 : (4 << IsQuad));
+else
+  return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
   case NeonTypeFlags::Int32:
 return llvm::VectorType::get(CGF->Int32Ty, V1Ty ? 1 : (2 << IsQuad));
   case NeonTypeFlags::Int64:
@@ -4226,7 +4232,8 @@ static Value *EmitCommonNeonSISDBuiltinE
 Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
 unsigned BuiltinID, unsigned LLVMIntrinsic, unsigned AltLLVMIntrinsic,
 const char *NameHint, unsigned Modifier, const CallExpr *E,
-SmallVectorImpl &Ops, Address PtrOp0, Address PtrOp1) {
+SmallVectorImpl &Ops, Address PtrOp0, Address PtrOp1,
+llvm::Triple::ArchType Arch) {
   // Get the last argument, which specifies the vector type.
   llvm::APSInt NeonTypeConst;
   const Expr *Arg = E->getArg(E->getNumArgs() - 1);
@@ -4238,7 +4245,7 @@ Value *CodeGenFunction::EmitCommonNeonBu
   bool Usgn = Type.isUnsigned();
   bool Quad = Type.isQuad();
 
-  llvm::VectorType *VTy = GetNeonType(this, Type);
+  llvm::VectorType *VTy = GetNeonType(this, Type, Arch);
   llvm::Type *Ty = VTy;
   if (!Ty)
 return nullptr;
@@ -4312,13 +4319,13 @@ Value *CodeGenFunction::EmitCommonNeonBu
   case NEON::BI__builtin_neon_vcvt_f32_v:
   case NEON::BI__builtin_neon_vcvtq_f32_v:
 Ops[0] = Builder.CreateBitCast(Ops[0], Ty);
-Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float32, false, Quad));
+Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float32, false, Quad), 
Arch);
 return Usgn ? Builder.CreateUIToFP(Ops[0], Ty, "vcvt")
 : Builder.CreateSIToFP(Ops[0], Ty, "vcvt");
   case NEON::BI__builtin_neon_vcvt_f16_v:
   case NEON::BI__builtin_neon_vcvtq_f16_v:
 Ops[0] = Builder.CreateBitCast(Ops[0], Ty);
-Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float16, false, Quad));
+Ty = GetNeonType(this, NeonTypeFlags(NeonTypeFlags::Float16, false, Quad), 
Arch);
 return Usgn ? Builder.CreateUIToFP(Ops[0], Ty, "vcvt")
 : Builder.CreateSIToFP(Ops[0], Ty, "vcvt");
   case NEON::BI__builtin_neon_vcvt_n_f16_v:
@@ -4887,7 +4894,8 @@ static bool HasExtraNeonArgument(unsigne
 }
 
 Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
-   const CallExpr *E) {
+   const CallExpr *E,
+   llvm::Triple::ArchType Arch) {
   if (auto Hint = GetValueForARMHint(BuiltinID))
 return Hint;
 
@@ -5426,7 +5434,7 @@ Value *CodeGenFunction::EmitARMBuiltinEx
   bool usgn = Type.isUnsigned();
   bool rightShift = false;
 
-  llvm::VectorType *VTy = GetNeonType(this, Type);
+  llvm::VectorType *VTy = GetNeonType(this, Type, Arch);
   llvm::Type *Ty = VTy;
   if (!Ty)
 return nullptr;
@@ -5439,7 +5447,7 @@ Value

[clang-tools-extra] r321302 - [clangd] Don't re-hash SymbolID in maps, just use the SHA1 data

2017-12-21 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Dec 21 12:11:46 2017
New Revision: 321302

URL: http://llvm.org/viewvc/llvm-project?rev=321302&view=rev
Log:
[clangd] Don't re-hash SymbolID in maps, just use the SHA1 data

Modified:
clang-tools-extra/trunk/clangd/index/Index.cpp
clang-tools-extra/trunk/clangd/index/Index.h

Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=321302&r1=321301&r2=321302&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Thu Dec 21 12:11:46 2017
@@ -24,7 +24,7 @@ llvm::raw_ostream &operator<<(llvm::raw_
 
 void operator>>(llvm::StringRef Str, SymbolID &ID) {
   std::string HexString = fromHex(Str);
-  assert(HexString.size() == 20);
+  assert(HexString.size() == ID.HashValue.size());
   std::copy(HexString.begin(), HexString.end(), ID.HashValue.begin());
 }
 

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=321302&r1=321301&r2=321302&view=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Thu Dec 21 12:11:46 2017
@@ -52,7 +52,9 @@ public:
 
 private:
   friend llvm::hash_code hash_value(const SymbolID &ID) {
-return hash_value(ArrayRef(ID.HashValue));
+// We already have a good hash, just return the first bytes.
+static_assert(sizeof(size_t) <= 20, "size_t longer than SHA1!");
+return *reinterpret_cast(ID.HashValue.data());
   }
   friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const SymbolID &ID);


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


Re: r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-21 Thread Martin Böhme via cfe-commits
Thanks for the quick response and your suggestions!

I believe the workaround you suggest in 1) will work for us, so there's no
need for an urgent change. Thanks again!

On 21 December 2017 at 20:11, Alex L  wrote:

> Thanks for raising your concerns.
>
> We decided to avoid -m-version-min flag in favor of -target to
> simplify the driver logic and to encourage the adoption of -target. Now
> after r321145 we only warn about -m-version-min flag when the OS
> version specified in it is different to the OS version specified in target,
> or when target has no OS version.
>
> There are two possible solutions here:
> 1) You can still use -target with -mios-simulator-version-min as before
> but you'd have to use '-target=x86_64-apple-darwin' to ensure that the iOS
> version specified by  '-mios-simulator-version-min' is used.
> 2) I also do have a patch that implements the logic that you propose (use
> the OS version in -m-version-min flag if target has none). If you
> believe that the first solution is not suitable for your code then I can
> commit it. At the same time I believe that we would rather not use this
> patch, but if it's urgent for your projects then maybe I can land it now
> and then we can establish some sort of timeline for when it can be reverted?
>
> Thanks,
> Alex
>
>
> On 21 December 2017 at 08:00, James Y Knight  wrote:
>
>> I think if a version number isn't explicitly specified in the -target
>> value, the value from -m-version-min ought to still be used, as
>> it was before.
>>
>> Currently, clang will ignore the -m-version-min version number
>> if the target has a particular OS specified, even if it has no version
>> number as part of it.
>>
>> (We should be able to workaround this change backwards-compatibly by
>> specifying in both the -target argument and in the -m-version-min
>> arguments, but I do think the behavior should be fixed.)
>>
>> On Thu, Dec 21, 2017 at 10:45 AM, Martin Böhme 
>> wrote:
>>
>>> This is causing problems in some internal builds that specify both
>>> -mios-simulator-version-min=9.0 and --target=x86_64-apple-ios
>>>
>>> My expectation would be for the code to take the minimum OS version
>>> number from the -mios-simulator-version-min flag. In fact, however, the
>>> code seems to be completely ignoring this flag.
>>>
>>> Is my expectation wrong or does the code need to be modified to take
>>> this situation into account?
>>>
>>>
>>> On 19 December 2017 at 20:05, Alex Lorenz via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: arphaman
 Date: Tue Dec 19 11:05:04 2017
 New Revision: 321099

 URL: http://llvm.org/viewvc/llvm-project?rev=321099&view=rev
 Log:
 [driver][darwin] Take the OS version specified in "-target" as the
 target
 OS instead of inferring it from SDK / environment

 The OS version is specified in -target should be used instead of the
 one in an
 environment variable / SDK name.

 rdar://35813850

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

 Modified:
 cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
 cfe/trunk/test/Driver/darwin-version.c
 cfe/trunk/test/Driver/objc-weak.m
 cfe/trunk/test/Driver/pic.c
 cfe/trunk/test/Driver/unavailable_aligned_allocation.cpp

 Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Too
 lChains/Darwin.cpp?rev=321099&r1=321098&r2=321099&view=diff
 
 ==
 --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
 +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Dec 19 11:05:04 2017
 @@ -1233,6 +1233,10 @@ struct DarwinPlatform {
  llvm_unreachable("Unsupported Darwin Source Kind");
}

 +  static DarwinPlatform createFromTarget(llvm::Triple::OSType OS,
 + StringRef OSVersion, Arg *A) {
 +return DarwinPlatform(TargetArg, getPlatformFromOS(OS), OSVersion,
 A);
 +  }
static DarwinPlatform createOSVersionArg(DarwinPlatformKind
 Platform,
 Arg *A) {
  return DarwinPlatform(OSVersionArg, Platform, A);
 @@ -1250,33 +1254,32 @@ struct DarwinPlatform {
}
static DarwinPlatform createFromArch(llvm::Triple::OSType OS,
 StringRef Value) {
 -DarwinPlatformKind Platform;
 +return DarwinPlatform(InferredFromArch, getPlatformFromOS(OS),
 Value);
 +  }
 +
 +private:
 +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform, Arg
 *Argument)
 +  : Kind(Kind), Platform(Platform), Argument(Argument) {}
 +  DarwinPlatform(SourceKind Kind, DarwinPlatformKind Platform,
 StringRef Value,
 + Arg *Argument = nullptr)
 +  : Kind(Kind), Pla

Re: r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-21 Thread James Y Knight via cfe-commits
I totally agree with moving towards eliminating the -m-version-min
flags, it's much better to put it in the target, and will clean up a lot of
cruft in the driver, eventually.

Now -- we (or anyone else who runs into this) can simply start specifying
the version in both locations ("-target x86_64-apple-ios10
-mios-simulator-version-min=10"), so as to work with both new and old
clang, and be closer to the ultimate goal of having only -target. That's an
overall nicer workaround to suggest than switching to -darwin. But, yea,
there's no need for *temporary* patch to fix things just for us.

However, I do not understand why you're against committing the patch you
mention as option #2 -- that seems like it'd be best for all users, by
preserving compatibility with existing command-lines. So, I'd still like
that change to be committed, permanently, not temporarily. I'm sure we
can't be the only ones running clang like "-target x86_64-apple-ios
-mios-simulator-version-min=10", and it seems unfortunate and unnecessary
to break that, even if it can be worked around.

In the future, I'd hope the -m-version-min arguments can be deprecated
more and more -- warning whenever you use them to modify the platform or
version at all, rather just on specification conflict; then, warn anytime
you use them at all; then, remove them. But in the meantime, it seems
strictly better to preserve compatibility, don't you think?



On Dec 21, 2017 2:11 PM, "Alex L"  wrote:

Thanks for raising your concerns.

We decided to avoid -m-version-min flag in favor of -target to simplify
the driver logic and to encourage the adoption of -target. Now after r321145
we only warn about -m-version-min flag when the OS version specified in
it is different to the OS version specified in target, or when target has
no OS version.

There are two possible solutions here:
1) You can still use -target with -mios-simulator-version-min as before but
you'd have to use '-target=x86_64-apple-darwin' to ensure that the iOS
version specified by  '-mios-simulator-version-min' is used.
2) I also do have a patch that implements the logic that you propose (use
the OS version in -m-version-min flag if target has none). If you
believe that the first solution is not suitable for your code then I can
commit it. At the same time I believe that we would rather not use this
patch, but if it's urgent for your projects then maybe I can land it now
and then we can establish some sort of timeline for when it can be reverted?

Thanks,
Alex


On 21 December 2017 at 08:00, James Y Knight  wrote:

> I think if a version number isn't explicitly specified in the -target
> value, the value from -m-version-min ought to still be used, as
> it was before.
>
> Currently, clang will ignore the -m-version-min version number
> if the target has a particular OS specified, even if it has no version
> number as part of it.
>
> (We should be able to workaround this change backwards-compatibly by
> specifying in both the -target argument and in the -m-version-min
> arguments, but I do think the behavior should be fixed.)
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321304 - Don't produce redundant parentheses warning for "A (::B); " and the like.

2017-12-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Dec 21 12:50:39 2017
New Revision: 321304

URL: http://llvm.org/viewvc/llvm-project?rev=321304&view=rev
Log:
Don't produce redundant parentheses warning for "A (::B);" and the like.

The parentheses here are not redundant as they affect the binding of the
'::' token.

Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Parser/cxx-decl.cpp

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=321304&r1=321303&r2=321304&view=diff
==
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Thu Dec 21 12:50:39 2017
@@ -3137,10 +3137,14 @@ static void warnAboutRedundantParens(Sem
   (T->isRecordType() || T->isDependentType()) &&
   D.getDeclSpec().getTypeQualifiers() == 0 && D.isFirstDeclarator();
 
+  bool StartsWithDeclaratorId = true;
   for (auto &C : D.type_objects()) {
 switch (C.Kind) {
-case DeclaratorChunk::Pointer:
 case DeclaratorChunk::Paren:
+  if (&C == &Paren)
+continue;
+case DeclaratorChunk::Pointer:
+  StartsWithDeclaratorId = false;
   continue;
 
 case DeclaratorChunk::Array:
@@ -3154,6 +3158,7 @@ static void warnAboutRedundantParens(Sem
   // We assume that something like 'T (&x) = y;' is highly likely to not
   // be intended to be a temporary object.
   CouldBeTemporaryObject = false;
+  StartsWithDeclaratorId = false;
   continue;
 
 case DeclaratorChunk::Function:
@@ -3166,6 +3171,7 @@ static void warnAboutRedundantParens(Sem
 case DeclaratorChunk::Pipe:
   // These cannot appear in expressions.
   CouldBeTemporaryObject = false;
+  StartsWithDeclaratorId = false;
   continue;
 }
   }
@@ -3186,6 +3192,18 @@ static void warnAboutRedundantParens(Sem
   SourceRange ParenRange(Paren.Loc, Paren.EndLoc);
 
   if (!CouldBeTemporaryObject) {
+// If we have A (::B), the parentheses affect the meaning of the program.
+// Suppress the warning in that case. Don't bother looking at the DeclSpec
+// here: even (e.g.) "int ::x" is visually ambiguous even though it's
+// formally unambiguous.
+if (StartsWithDeclaratorId && D.getCXXScopeSpec().isValid()) {
+  for (NestedNameSpecifier *NNS = D.getCXXScopeSpec().getScopeRep(); NNS;
+   NNS = NNS->getPrefix()) {
+if (NNS->getKind() == NestedNameSpecifier::Global)
+  return;
+  }
+}
+
 S.Diag(Paren.Loc, diag::warn_redundant_parens_around_declarator)
 << ParenRange << FixItHint::CreateRemoval(Paren.Loc)
 << FixItHint::CreateRemoval(Paren.EndLoc);

Modified: cfe/trunk/test/Parser/cxx-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-decl.cpp?rev=321304&r1=321303&r2=321304&view=diff
==
--- cfe/trunk/test/Parser/cxx-decl.cpp (original)
+++ cfe/trunk/test/Parser/cxx-decl.cpp Thu Dec 21 12:50:39 2017
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors 
-fcxx-exceptions -fexceptions %s
-// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors 
-fcxx-exceptions -fexceptions -std=c++98 %s
-// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors 
-fcxx-exceptions -fexceptions -std=c++11 %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens 
-pedantic-errors -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens 
-pedantic-errors -fcxx-exceptions -fexceptions -std=c++98 %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -Wredundant-parens 
-pedantic-errors -fcxx-exceptions -fexceptions -std=c++11 %s
 
 const char const *x10; // expected-error {{duplicate 'const' declaration 
specifier}}
 
@@ -83,7 +83,7 @@ namespace Commas {
 
   int global1,
   __attribute__(()) global2,
-  (global5),
+  (global5), // expected-warning {{redundant parentheses surrounding 
declarator}}
   *global6,
   &global7 = global1,
   &&global8 = static_cast(global1),
@@ -263,6 +263,25 @@ namespace DuplicateFriend {
   };
 }
 
+namespace NNS {
+  struct A {};
+  namespace B { extern A C1, C2, *C3, C4[], C5; }
+  // Do not produce a redundant parentheses warning here; removing these parens
+  // changes the meaning of the program.
+  A (::NNS::B::C1);
+  A (NNS::B::C2); // expected-warning {{redundant parentheses surrounding 
declarator}}
+  A (*::NNS::B::C3); // expected-warning {{redundant parentheses surrounding 
declarator}}
+  A (::NNS::B::C4[2]);
+  // Removing one of these sets of parentheses would be reasonable.
+  A ((::NNS::B::C5)); // expected-warning {{redundant parentheses surrounding 
declarator}}
+
+  void f() {
+// FIXME: A vexing-parse warning here would be useful.
+A(::NNS::B::C1); // expected-error {{definition or rede

r321306 - Revert "[CodeGen] Fix crash when a function taking transparent union is redeclared."

2017-12-21 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Thu Dec 21 12:52:59 2017
New Revision: 321306

URL: http://llvm.org/viewvc/llvm-project?rev=321306&view=rev
Log:
Revert "[CodeGen] Fix crash when a function taking transparent union is 
redeclared."

This reverts commit r321296. It caused performance regressions
FAIL: imp.execution_time
FAIL: 2007-01-04-KNR-Args.execution_time
FAIL: sse_expandfft.execution_time
FAIL: sse_stepfft.execution_time


Removed:
cfe/trunk/test/CodeGen/transparent-union-redecl.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGen/kr-func-promote.c
cfe/trunk/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance-vtordisps.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
cfe/trunk/test/Sema/transparent-union.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=321306&r1=321305&r2=321306&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Dec 21 12:52:59 2017
@@ -2317,7 +2317,7 @@ void CodeGenFunction::EmitFunctionProlog
 
   // If we have the trivial case, handle it with no muss and fuss.
   if (!isa(ArgI.getCoerceToType()) &&
-  ArgI.getCoerceToType() == ConvertType(Arg->getType()) &&
+  ArgI.getCoerceToType() == ConvertType(Ty) &&
   ArgI.getDirectOffset() == 0) {
 assert(NumIRArgs == 1);
 llvm::Value *V = FnArgs[FirstIRArg];
@@ -2414,8 +2414,8 @@ void CodeGenFunction::EmitFunctionProlog
 break;
   }
 
-  Address Alloca = CreateMemTemp(
-  Arg->getType(), getContext().getDeclAlign(Arg), Arg->getName());
+  Address Alloca = CreateMemTemp(Ty, getContext().getDeclAlign(Arg),
+ Arg->getName());
 
   // Pointer to store into.
   Address Ptr = emitAddressAtOffset(*this, Alloca, ArgI);
@@ -2461,9 +2461,9 @@ void CodeGenFunction::EmitFunctionProlog
   }
 
   // Match to what EmitParmDecl is expecting for this type.
-  if (CodeGenFunction::hasScalarEvaluationKind(Arg->getType())) {
+  if (CodeGenFunction::hasScalarEvaluationKind(Ty)) {
 llvm::Value *V =
-EmitLoadOfScalar(Alloca, false, Arg->getType(), 
Arg->getLocStart());
+  EmitLoadOfScalar(Alloca, false, Ty, Arg->getLocStart());
 if (isPromoted)
   V = emitArgumentDemotion(*this, Arg, V);
 ArgVals.push_back(ParamValue::forDirect(V));

Modified: cfe/trunk/test/CodeGen/kr-func-promote.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/kr-func-promote.c?rev=321306&r1=321305&r2=321306&view=diff
==
--- cfe/trunk/test/CodeGen/kr-func-promote.c (original)
+++ cfe/trunk/test/CodeGen/kr-func-promote.c Thu Dec 21 12:52:59 2017
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck 
%s
-// CHECK: i32 @a(i32
+// CHECK: i32 @a(i32)
 
 int a();
 int a(x) short x; {return x;}

Removed: cfe/trunk/test/CodeGen/transparent-union-redecl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/transparent-union-redecl.c?rev=321305&view=auto
==
--- cfe/trunk/test/CodeGen/transparent-union-redecl.c (original)
+++ cfe/trunk/test/CodeGen/transparent-union-redecl.c (removed)
@@ -1,36 +0,0 @@
-// RUN: %clang_cc1 -Werror -triple i386-linux -emit-llvm -o - %s | FileCheck %s
-
-// Test that different order of declarations is acceptable and that
-// implementing different redeclarations is acceptable.
-// rdar://problem/34949329
-
-typedef union {
-  int i;
-  float f;
-} TU __attribute__((transparent_union));
-
-// CHECK-LABEL: define void @f0(i32 %tu.coerce)
-// CHECK: %tu = alloca %union.TU, align 4
-// CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 
0, i32 0
-// CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
-void f0(TU tu) {}
-void f0(int i);
-
-// CHECK-LABEL: define void @f1(i32 %tu.coerce)
-// CHECK: %tu = alloca %union.TU, align 4
-// CHECK: %coerce.dive = getelementptr inbounds %union.TU, %union.TU* %tu, i32 
0, i32 0
-// CHECK: store i32 %tu.coerce, i32* %coerce.dive, align 4
-void f1(int i);
-void f1(TU tu) {}
-
-// CHECK-LABEL: define void @f2(i32 %i)
-// CHECK: %i.addr = alloca i32, align 4
-// CHECK: store i32 %i, i32* %i.addr, align 4
-void f2(TU tu);
-void f2(int i) {}
-
-// CHECK-LABEL: define void @f3(i32 %i)
-// CHECK: %i.addr = alloca i32, align 4
-// CHECK: store i32 %i, i32* %i.addr, align 4
-void f3(int i) {}
-void f3(TU tu);

Modified: 
cfe/trunk/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual-inheritance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-multiple-nonvirtual

[PATCH] D41228: [ObjC] Enable __strong pointers in structs under ARC

2017-12-21 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: include/clang/AST/Type.h:1152
+NTFK_Struct,  // non-trivial C struct.
+NTFK_Array// array that has non-trivial elements.
+  };

rjmccall wrote:
> ahatanak wrote:
> > rjmccall wrote:
> > > We don't actually distinguish arrays in DestructionKind.  Is it important 
> > > here?  You can't actually do anything with that information.
> > > 
> > > Regarding your naming question, I wonder if it would be useful to just 
> > > invent a new term here, something meaning "non-trivial" but without the 
> > > C++ baggage.  Maybe just "PrimitiveCopyKind", with the understanding that 
> > > C++ can never do a "primitive" copy?  And for consistency with 
> > > DestructionKind, maybe you should lowercase the second words.
> > > 
> > > I'm not sure how isNonTrivialToCopy is supposed to be used.  Where does 
> > > the function come from?  And why is a context required when it isn't 
> > > required for isDestructedType?
> > Enum NonTrivialCopyKind and isNonTrivialToCopy() are used just to 
> > distinguish the different types of fields in a C struct. Currently, there 
> > are four types that are handled by visitField functions in 
> > CGNonTrivialStruct.cpp:
> > 
> > - struct field
> > - array field
> > - __strong field
> > - trivial field that can be copied using memcpy
> > 
> > I thought using enums would make the code easier to read, but of course 
> > it's possible to remove them and instead just check the field types calling 
> > functions like getAsArrayType or getAs. ASTContext is passed to 
> > isNonTrivialToCopy so that it can call ASTContext::getAsArrayType to 
> > determine whether the type is an array. Maybe there is another way to 
> > detect an array that doesn't require ASTContext?
> > 
> > As for the naming, PrimitiveCopyKind seems find if we want to distinguish 
> > it from C++ non-trivial classes (I don't have a better name). If we are 
> > going to call non-trivial C structs primitiveCopyKind, what should we call 
> > the C structs that are trivial (those that can be copied using memcpy)?
> I think "trivial" is a reasonable kind of primitive-copy semantics.  
> Basically, we're saying that all complete object types other than non-trivial 
> C++ types have some sort of primitive-copy semantics, and this enum tells us 
> what those semantics are.
> 
> DestructionKind has to deal with arrays as well, but it does so by just 
> reporting the appropriate value for the underlying element type without 
> mentioning that it's specifically an *array* of the type.  I think that's a 
> reasonable design, since most places do not need to distinguish arrays from 
> non-arrays.  IRGen does, but only when you're actually finally emitting code; 
> prior to that (when e.g. deciding that a field is non-trivial to copy) you 
> can just use the enum value.
> 
> You can do without getAsArrayType the same way that isDestructedType() does: 
> the more complex operation is only necessary in order to preserve qualifiers 
> on the element type, but that's unnecessary for this operation because the 
> array type itself is considered to have the same qualifiers as its element 
> type.  That is, you can ask the original type whether it's 
> __strong/__weak-qualified without having to specifically handle array types, 
> and once you've done all of those queries, you can use the "unsafe" 
> operations to drill down to the element type because you no longer care about 
> qualification.
So QualType::hasNonTrivialToDefaultInitializeStruct should be renamed to 
QualType::hasPrimitiveDefaultInitializeStruct and 
RecordDecl::isNonTrivialToPrimitiveDefaultInitialize to 
RecordDecl::isPrimitiveDefaultInitialize, for example?

Also, I realized that, after I made the changes that removed the NonTrivial 
flags from RecordDecl, CGNonTrivialStruct.cpp is the only user of enum 
NonTrivialCopyKind and the following methods of QualType 
(Sema::isValidVarArgType calls nonTrivialToDestroy, but it should call methods 
like hasNonTrivialToDestroyStruct that detect non-trivial C structs instead):

nonTrivialToDefaultInitialize
nonTrivialToCopy
nonTrivialToDestructiveMove
nonTrivialToDestroy

Maybe we should make these enums and functions local to CGNonTrivialStruct.cpp 
to avoid adding something that is not used outside CGNonTrivialStruct.cpp?


https://reviews.llvm.org/D41228



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


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

2017-12-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: aaron.ballman, rsmith, smeenai, rjmccall, rnk, 
mclow.lists.
lebedev.ri added a project: clang.

The diagnostic was mostly introduced in https://reviews.llvm.org/D38101 by me, 
as a reaction to wasting a lot of time, see mail 
.
However, the diagnostic is pretty dumb. While it works with no false-positives,
there are some questionable cases that are diagnosed when one would argue that 
they should not be.

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

I.e. the common pattern is: (pseudocode)

  #include 
  #include 
  int main() {
using T1 = long;
using T2 = int;
  
T1 r;
if (r < std::numeric_limits::min()) {}
if (r > std::numeric_limits::max()) {}
  }

As an example, https://reviews.llvm.org/D39149 was trying to fix this 
diagnostic in libc++, and it was not well-received.

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

So to stop causing trouble, and avoid contaminating upcoming release, lets do 
this workaround:

- disable `warn_tautological_constant_compare` by default, make sure it is not 
part of `-Wall`

  FIXME: it appears `warn_unsigned_enum_always_true_comparison` also got 
disabled by default, which is not intentional. Do we want that?
- Add `-Wtautological-constant-compare` into `-Wextra`.


Repository:
  rC Clang

https://reviews.llvm.org/D41512

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


Index: test/SemaCXX/compare.cpp
===
--- test/SemaCXX/compare.cpp
+++ test/SemaCXX/compare.cpp
@@ -1,7 +1,7 @@
 // Force x86-64 because some of our heuristics are actually based
 // on integer sizes.
 
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify 
-Wsign-compare -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify 
-Wsign-compare -Wtautological-constant-compare -std=c++11 %s
 
 int test0(long a, unsigned long b) {
   enum EnumA {A};
Index: test/Sema/tautological-constant-enum-compare.c
===
--- test/Sema/tautological-constant-enum-compare.c
+++ test/Sema/tautological-constant-enum-compare.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED 
-verify %s
-// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED 
-Wtautological-constant-compare -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED 
-Wtautological-constant-compare -verify %s
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED 
-DSILENCE -Wno-tautological-constant-compare -verify %s
 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -DSILENCE 
-Wno-tautological-constant-compare -verify %s
 
Index: test/Sema/tautological-constant-compare.c
===
--- test/Sema/tautological-constant-compare.c
+++ test/Sema/tautological-constant-compare.c
@@ -1,7 +1,11 @@
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -DTEST -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only 
-Wno-tautological-constant-compare -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -DTEST -verify -x 
c++ %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only 
-Wno-tautological-constant-compare -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only 
-Wtautological-constant-compare -DTEST -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -DTEST -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only 
-Wtautological-constant-compare -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra 
-Wno-sign-compare -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu

[PATCH] D40983: Generate Libclang invocation reproducers using a new -cc1gen-reproducer option

2017-12-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman marked 2 inline comments as done.
arphaman added a comment.

In https://reviews.llvm.org/D40983#958809, @bruno wrote:

> Hi Alex,
>
> Thanks for improving this.
>
> - Instead of adding `-cc1gen-reproducer`, why can't you run that through 
> `-cc1` and have a flag similar to `-###`, which just prints the reproducer 
> line?


It would be difficult to add this logic to the regular `-cc1`, as it would need 
to construct a real compiler invocation on top of the pseudo one which takes 
the libclang invocation file (because it has to load the actual compiler 
arguments from the libclang file). This would be difficult and quite disruptive 
to the code in the cc1 driver and the compiler invocation. The approach in this 
patch is much simpler to implement and maintain, and does not disrupt the code 
in the `cc1` driver. This patch makes it more of a tool rather than a clang 
driver invocation.

> - I didn't  understand how you can use the final output information, can you 
> give an example to illustrate?

Given a sample output like:

REPRODUCER:
{
 "files":["/tmp/a.c","/tmp/a.sh"]
}

The tool's client (also a libclang client) will parse the JSON object with the 
files that make up the reproducer. It will then be able to do whatever it needs 
with those specific files.




Comment at: include/clang/Driver/Driver.h:394
+  struct CompilationDiagnosticReport {
+std::vector TemporaryFiles;
+  };

bruno wrote:
> I assume the number of temporary files are usually small, can you switch to 
> SmallVector here?
Yep.


Repository:
  rC Clang

https://reviews.llvm.org/D40983



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


[PATCH] D40983: Generate Libclang invocation reproducers using a new -cc1gen-reproducer option

2017-12-21 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 127935.
arphaman marked an inline comment as done.
arphaman added a comment.

Address review comments


https://reviews.llvm.org/D40983

Files:
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp
  test/Index/create-libclang-completion-reproducer.c
  test/Index/create-libclang-parsing-reproducer.c
  tools/driver/CMakeLists.txt
  tools/driver/cc1gen_reproducer_main.cpp
  tools/driver/driver.cpp

Index: tools/driver/driver.cpp
===
--- tools/driver/driver.cpp
+++ tools/driver/driver.cpp
@@ -205,6 +205,8 @@
 void *MainAddr);
 extern int cc1as_main(ArrayRef Argv, const char *Argv0,
   void *MainAddr);
+extern int cc1gen_reproducer_main(ArrayRef Argv,
+  const char *Argv0, void *MainAddr);
 
 static void insertTargetAndModeArgs(const ParsedClangName &NameParts,
 SmallVectorImpl &ArgVector,
@@ -309,6 +311,8 @@
 return cc1_main(argv.slice(2), argv[0], GetExecutablePathVP);
   if (Tool == "as")
 return cc1as_main(argv.slice(2), argv[0], GetExecutablePathVP);
+  if (Tool == "gen-reproducer")
+return cc1gen_reproducer_main(argv.slice(2), argv[0], GetExecutablePathVP);
 
   // Reject unknown tools.
   llvm::errs() << "error: unknown integrated tool '" << Tool << "'\n";
Index: tools/driver/cc1gen_reproducer_main.cpp
===
--- /dev/null
+++ tools/driver/cc1gen_reproducer_main.cpp
@@ -0,0 +1,196 @@
+//===-- cc1gen_reproducer_main.cpp - Clang reproducer generator  --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This is the entry point to the clang -cc1gen-reproducer functionality, which
+// generates reproducers for invocations for clang-based tools.
+//
+//===--===//
+
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/YAMLTraits.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace clang;
+
+namespace {
+
+struct UnsavedFileHash {
+  std::string Name;
+  std::string MD5;
+};
+
+struct ClangInvocationInfo {
+  std::string Toolchain;
+  std::string LibclangOperation;
+  std::string LibclangOptions;
+  std::vector Arguments;
+  std::vector InvocationArguments;
+  std::vector UnsavedFileHashes;
+  bool Dump = false;
+};
+
+} // end anonymous namespace
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(UnsavedFileHash)
+
+namespace llvm {
+namespace yaml {
+
+template <> struct MappingTraits {
+  static void mapping(IO &IO, UnsavedFileHash &Info) {
+IO.mapRequired("name", Info.Name);
+IO.mapRequired("md5", Info.MD5);
+  }
+};
+
+template <> struct MappingTraits {
+  static void mapping(IO &IO, ClangInvocationInfo &Info) {
+IO.mapRequired("toolchain", Info.Toolchain);
+IO.mapOptional("libclang.operation", Info.LibclangOperation);
+IO.mapOptional("libclang.opts", Info.LibclangOptions);
+IO.mapRequired("args", Info.Arguments);
+IO.mapOptional("invocation-args", Info.InvocationArguments);
+IO.mapOptional("unsaved_file_hashes", Info.UnsavedFileHashes);
+  }
+};
+
+} // end namespace yaml
+} // end namespace llvm
+
+static std::string generateReproducerMetaInfo(const ClangInvocationInfo &Info) {
+  std::string Result;
+  llvm::raw_string_ostream OS(Result);
+  OS << '{';
+  bool NeedComma = false;
+  auto EmitKey = [&](StringRef Key) {
+if (NeedComma)
+  OS << ", ";
+NeedComma = true;
+OS << '"' << Key << "\": ";
+  };
+  auto EmitStringKey = [&](StringRef Key, StringRef Value) {
+if (Value.empty())
+  return;
+EmitKey(Key);
+OS << '"' << Value << '"';
+  };
+  EmitStringKey("libclang.operation", Info.LibclangOperation);
+  EmitStringKey("libclang.opts", Info.LibclangOptions);
+  if (!Info.InvocationArguments.empty()) {
+EmitKey("invocation-args");
+OS << '[';
+for (const auto &Arg : llvm::enumerate(Info.InvocationArguments)) {
+  if (Arg.index())
+OS << ',';
+  OS << '"' << Arg.value() << '"';
+}
+OS << ']';
+  }
+  OS << '}';
+  // FIXME: Compare unsaved file hashes and report mismatch in the reproducer.
+  if (Info.Dump)
+llvm::outs() << "REPRODUCER METAINFO: " << OS.str() << "\n";
+  return std::move(OS.str());
+}
+
+/// Generates a reproducer for a set of arguments from a specific invocation.
+static llvm::Optional
+generateReproducerForInvocationArgum

Re: r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-21 Thread Alex L via cfe-commits
On 21 December 2017 at 12:34, James Y Knight  wrote:

> I totally agree with moving towards eliminating the -m-version-min
> flags, it's much better to put it in the target, and will clean up a lot of
> cruft in the driver, eventually.
>
> Now -- we (or anyone else who runs into this) can simply start specifying
> the version in both locations ("-target x86_64-apple-ios10
> -mios-simulator-version-min=10"), so as to work with both new and old
> clang, and be closer to the ultimate goal of having only -target. That's an
> overall nicer workaround to suggest than switching to -darwin. But, yea,
> there's no need for *temporary* patch to fix things just for us.
>
> However, I do not understand why you're against committing the patch you
> mention as option #2 -- that seems like it'd be best for all users, by
> preserving compatibility with existing command-lines. So, I'd still like
> that change to be committed, permanently, not temporarily. I'm sure we
> can't be the only ones running clang like "-target x86_64-apple-ios
> -mios-simulator-version-min=10", and it seems unfortunate and unnecessary
> to break that, even if it can be worked around.
>
> In the future, I'd hope the -m-version-min arguments can be deprecated
> more and more -- warning whenever you use them to modify the platform or
> version at all, rather just on specification conflict; then, warn anytime
> you use them at all; then, remove them. But in the meantime, it seems
> strictly better to preserve compatibility, don't you think?
>

+ Duncan

Thanks, I think your argument is convincing. I think I will commit the
change that you're proposing in the near future if there are no further
objections.



>
>
>
> On Dec 21, 2017 2:11 PM, "Alex L"  wrote:
>
> Thanks for raising your concerns.
>
> We decided to avoid -m-version-min flag in favor of -target to
> simplify the driver logic and to encourage the adoption of -target. Now
> after r321145 we only warn about -m-version-min flag when the OS
> version specified in it is different to the OS version specified in target,
> or when target has no OS version.
>
> There are two possible solutions here:
> 1) You can still use -target with -mios-simulator-version-min as before
> but you'd have to use '-target=x86_64-apple-darwin' to ensure that the iOS
> version specified by  '-mios-simulator-version-min' is used.
> 2) I also do have a patch that implements the logic that you propose (use
> the OS version in -m-version-min flag if target has none). If you
> believe that the first solution is not suitable for your code then I can
> commit it. At the same time I believe that we would rather not use this
> patch, but if it's urgent for your projects then maybe I can land it now
> and then we can establish some sort of timeline for when it can be reverted?
>
> Thanks,
> Alex
>
>
> On 21 December 2017 at 08:00, James Y Knight  wrote:
>
>> I think if a version number isn't explicitly specified in the -target
>> value, the value from -m-version-min ought to still be used, as
>> it was before.
>>
>> Currently, clang will ignore the -m-version-min version number
>> if the target has a particular OS specified, even if it has no version
>> number as part of it.
>>
>> (We should be able to workaround this change backwards-compatibly by
>> specifying in both the -target argument and in the -m-version-min
>> arguments, but I do think the behavior should be fixed.)
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39239: [AST] Incorrectly qualified unscoped enumeration as template actual parameter.

2017-12-21 Thread Paul Robinson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321312: [AST] Incorrectly qualified unscoped enumeration as 
template actual parameter. (authored by probinson, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D39239?vs=120066&id=127937#toc

Repository:
  rC Clang

https://reviews.llvm.org/D39239

Files:
  lib/AST/Decl.cpp
  test/Modules/odr.cpp
  test/SemaCXX/return-noreturn.cpp
  test/SemaTemplate/temp_arg_enum_printing.cpp
  test/SemaTemplate/temp_arg_enum_printing_more.cpp
  unittests/AST/NamedDeclPrinterTest.cpp

Index: unittests/AST/NamedDeclPrinterTest.cpp
===
--- unittests/AST/NamedDeclPrinterTest.cpp
+++ unittests/AST/NamedDeclPrinterTest.cpp
@@ -143,7 +143,7 @@
   ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
 "enum X { A };",
 "A",
-"X::A"));
+"A"));
 }
 
 TEST(NamedDeclPrinter, TestScopedNamedEnum) {
@@ -164,7 +164,7 @@
   ASSERT_TRUE(PrintedWrittenNamedDeclCXX11Matches(
 "class X { enum Y { A }; };",
 "A",
-"X::Y::A"));
+"X::A"));
 }
 
 TEST(NamedDeclPrinter, TestClassWithScopedNamedEnum) {
Index: test/SemaTemplate/temp_arg_enum_printing_more.cpp
===
--- test/SemaTemplate/temp_arg_enum_printing_more.cpp
+++ test/SemaTemplate/temp_arg_enum_printing_more.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -ast-print %s -std=c++11 | FileCheck %s
+
+// Make sure that for template value arguments that are unscoped enumerators,
+// no qualified enum information is included in their name, as their visibility
+// is global. In the case of scoped enumerators, they must include information
+// about their enum enclosing scope.
+
+enum E1 { e1 };
+template struct tmpl_1 {};
+// CHECK: template<> struct tmpl_1
+tmpl_1 TMPL_1;  // Name must be 'e1'.
+
+namespace nsp_1 { enum E2 { e2 }; }
+template struct tmpl_2 {};
+// CHECK: template<> struct tmpl_2
+tmpl_2 TMPL_2;   // Name must be 'nsp_1::e2'.
+
+enum class E3 { e3 };
+template struct tmpl_3 {};
+// CHECK: template<> struct tmpl_3
+tmpl_3 TMPL_3;  // Name must be 'E3::e3'.
+
+namespace nsp_2 { enum class E4 { e4 }; }
+template struct tmpl_4 {};
+// CHECK: template<> struct tmpl_4
+tmpl_4 TMPL_4;   // Name must be 'nsp_2::E4::e4'.
Index: test/SemaTemplate/temp_arg_enum_printing.cpp
===
--- test/SemaTemplate/temp_arg_enum_printing.cpp
+++ test/SemaTemplate/temp_arg_enum_printing.cpp
@@ -13,9 +13,9 @@
 void foo();
   
 void test() {
-  // CHECK: template<> void foo()
+  // CHECK: template<> void foo()
   NamedEnumNS::foo();
-  // CHECK: template<> void foo()
+  // CHECK: template<> void foo()
   NamedEnumNS::foo<(NamedEnum)1>();
   // CHECK: template<> void foo<2>()
   NamedEnumNS::foo<(NamedEnum)2>();
Index: test/SemaCXX/return-noreturn.cpp
===
--- test/SemaCXX/return-noreturn.cpp
+++ test/SemaCXX/return-noreturn.cpp
@@ -143,7 +143,7 @@
 } // expected-warning {{control reaches end of non-void function}}
 
 void PR9412_f() {
-PR9412_t(); // expected-note {{in instantiation of function template specialization 'PR9412_t' requested here}}
+PR9412_t(); // expected-note {{in instantiation of function template specialization 'PR9412_t' requested here}}
 }
 
 struct NoReturn {
Index: test/Modules/odr.cpp
===
--- test/Modules/odr.cpp
+++ test/Modules/odr.cpp
@@ -18,6 +18,6 @@
 // expected-note@a.h:3 {{declaration of 'f' does not match}}
 // expected-note@a.h:1 {{definition has no member 'm'}}
 
-// expected-error@b.h:5 {{'E::e2' from module 'b' is not present in definition of 'E' in module 'a'}}
+// expected-error@b.h:5 {{'e2' from module 'b' is not present in definition of 'E' in module 'a'}}
 // expected-error@b.h:3 {{'Y::f' from module 'b' is not present in definition of 'Y' in module 'a'}}
 // expected-error@b.h:2 {{'Y::m' from module 'b' is not present in definition of 'Y' in module 'a'}}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1548,7 +1548,10 @@
   // enumerator is declared in the scope that immediately contains
   // the enum-specifier. Each scoped enumerator is declared in the
   // scope of the enumeration.
-  if (ED->isScoped() || ED->getIdentifier())
+  // For the case of unscoped enumerator, do not include in the qualified
+  // name any information about its enum enclosing scope, as is visibility
+  // is global.
+  if (ED->isScoped())
 OS << *ED;
   else
 continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commi

r321312 - [AST] Incorrectly qualified unscoped enumeration as template actual parameter.

2017-12-21 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Thu Dec 21 13:47:22 2017
New Revision: 321312

URL: http://llvm.org/viewvc/llvm-project?rev=321312&view=rev
Log:
[AST] Incorrectly qualified unscoped enumeration as template actual parameter.

An unscoped enumeration used as template argument, should not have any
qualified information about its enclosing scope, as its visibility is
global.

In the case of scoped enumerations, they must include information
about their enclosing scope.

Patch by Carlos Alberto Enciso!

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

Added:
cfe/trunk/test/SemaTemplate/temp_arg_enum_printing_more.cpp
Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/Modules/odr.cpp
cfe/trunk/test/SemaCXX/return-noreturn.cpp
cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp
cfe/trunk/unittests/AST/NamedDeclPrinterTest.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=321312&r1=321311&r2=321312&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Dec 21 13:47:22 2017
@@ -1548,7 +1548,10 @@ void NamedDecl::printQualifiedName(raw_o
   // enumerator is declared in the scope that immediately contains
   // the enum-specifier. Each scoped enumerator is declared in the
   // scope of the enumeration.
-  if (ED->isScoped() || ED->getIdentifier())
+  // For the case of unscoped enumerator, do not include in the qualified
+  // name any information about its enum enclosing scope, as is visibility
+  // is global.
+  if (ED->isScoped())
 OS << *ED;
   else
 continue;

Modified: cfe/trunk/test/Modules/odr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/odr.cpp?rev=321312&r1=321311&r2=321312&view=diff
==
--- cfe/trunk/test/Modules/odr.cpp (original)
+++ cfe/trunk/test/Modules/odr.cpp Thu Dec 21 13:47:22 2017
@@ -18,6 +18,6 @@ int x = f() + g();
 // expected-note@a.h:3 {{declaration of 'f' does not match}}
 // expected-note@a.h:1 {{definition has no member 'm'}}
 
-// expected-error@b.h:5 {{'E::e2' from module 'b' is not present in definition 
of 'E' in module 'a'}}
+// expected-error@b.h:5 {{'e2' from module 'b' is not present in definition of 
'E' in module 'a'}}
 // expected-error@b.h:3 {{'Y::f' from module 'b' is not present in definition 
of 'Y' in module 'a'}}
 // expected-error@b.h:2 {{'Y::m' from module 'b' is not present in definition 
of 'Y' in module 'a'}}

Modified: cfe/trunk/test/SemaCXX/return-noreturn.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/return-noreturn.cpp?rev=321312&r1=321311&r2=321312&view=diff
==
--- cfe/trunk/test/SemaCXX/return-noreturn.cpp (original)
+++ cfe/trunk/test/SemaCXX/return-noreturn.cpp Thu Dec 21 13:47:22 2017
@@ -143,7 +143,7 @@ template  int PR9
 } // expected-warning {{control reaches end of non-void function}}
 
 void PR9412_f() {
-PR9412_t(); // expected-note {{in instantiation of function 
template specialization 'PR9412_t' requested 
here}}
+PR9412_t(); // expected-note {{in instantiation of function 
template specialization 'PR9412_t' requested here}}
 }
 
 struct NoReturn {

Modified: cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp?rev=321312&r1=321311&r2=321312&view=diff
==
--- cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_enum_printing.cpp Thu Dec 21 13:47:22 
2017
@@ -13,9 +13,9 @@ template 
 void foo();
   
 void test() {
-  // CHECK: template<> void foo()
+  // CHECK: template<> void foo()
   NamedEnumNS::foo();
-  // CHECK: template<> void foo()
+  // CHECK: template<> void foo()
   NamedEnumNS::foo<(NamedEnum)1>();
   // CHECK: template<> void foo<2>()
   NamedEnumNS::foo<(NamedEnum)2>();

Added: cfe/trunk/test/SemaTemplate/temp_arg_enum_printing_more.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_enum_printing_more.cpp?rev=321312&view=auto
==
--- cfe/trunk/test/SemaTemplate/temp_arg_enum_printing_more.cpp (added)
+++ cfe/trunk/test/SemaTemplate/temp_arg_enum_printing_more.cpp Thu Dec 21 
13:47:22 2017
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -ast-print %s -std=c++11 | FileCheck %s
+
+// Make sure that for template value arguments that are unscoped enumerators,
+// no qualified enum information is included in their name, as their visibility
+// is global. In the case of scoped enumerators, they must include information
+// about their enum enclosing scope.
+

r321314 - [scudo] Add -fsanitize=scudo option to Fuchsia

2017-12-21 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Dec 21 14:04:31 2017
New Revision: 321314

URL: http://llvm.org/viewvc/llvm-project?rev=321314&view=rev
Log:
[scudo] Add -fsanitize=scudo option to Fuchsia

Apparently the -fsanitize flag hadn't been added for Scudo upstream yet.

Patch By: flowerhack

Reviewers: cryptoad, alekseyshl, mcgrathr, phosek

Reviewed By: mcgrathr, phosek

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
cfe/trunk/test/Driver/fuchsia.c

Modified: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp?rev=321314&r1=321313&r2=321314&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp Thu Dec 21 14:04:31 2017
@@ -280,5 +280,6 @@ SanitizerMask Fuchsia::getSupportedSanit
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::SafeStack;
   Res |= SanitizerKind::Address;
+  Res |= SanitizerKind::Scudo;
   return Res;
 }

Modified: cfe/trunk/test/Driver/fuchsia.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fuchsia.c?rev=321314&r1=321313&r2=321314&view=diff
==
--- cfe/trunk/test/Driver/fuchsia.c (original)
+++ cfe/trunk/test/Driver/fuchsia.c Thu Dec 21 14:04:31 2017
@@ -79,3 +79,20 @@
 // CHECK-ASAN-SHARED: "-fsanitize-address-globals-dead-stripping"
 // CHECK-ASAN-SHARED: "{{.*[/\\]}}libclang_rt.asan-x86_64.so"
 // CHECK-ASAN-SHARED-NOT: "{{.*[/\\]}}libclang_rt.asan-preinit-x86_64.a"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fsanitize=scudo 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-X86
+// CHECK-SCUDO-X86: "-fsanitize=scudo"
+// CHECK-SCUDO-X86: "-pie"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -fsanitize=scudo 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-AARCH64
+// CHECK-SCUDO-AARCH64: "-fsanitize=scudo"
+// CHECK-SCUDO-AARCH64: "-pie"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fsanitize=scudo -fPIC -shared 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
+// CHECK-SCUDO-SHARED: "-fsanitize=scudo"


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


[PATCH] D41413: [scudo] Add -fsanitize=scudo option to Fuchsia.

2017-12-21 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC321314: [scudo] Add -fsanitize=scudo option to Fuchsia 
(authored by phosek, committed by ).
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D41413

Files:
  lib/Driver/ToolChains/Fuchsia.cpp
  test/Driver/fuchsia.c


Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -280,5 +280,6 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::SafeStack;
   Res |= SanitizerKind::Address;
+  Res |= SanitizerKind::Scudo;
   return Res;
 }
Index: test/Driver/fuchsia.c
===
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -79,3 +79,20 @@
 // CHECK-ASAN-SHARED: "-fsanitize-address-globals-dead-stripping"
 // CHECK-ASAN-SHARED: "{{.*[/\\]}}libclang_rt.asan-x86_64.so"
 // CHECK-ASAN-SHARED-NOT: "{{.*[/\\]}}libclang_rt.asan-preinit-x86_64.a"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fsanitize=scudo 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-X86
+// CHECK-SCUDO-X86: "-fsanitize=scudo"
+// CHECK-SCUDO-X86: "-pie"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -fsanitize=scudo 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-AARCH64
+// CHECK-SCUDO-AARCH64: "-fsanitize=scudo"
+// CHECK-SCUDO-AARCH64: "-pie"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fsanitize=scudo -fPIC -shared 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
+// CHECK-SCUDO-SHARED: "-fsanitize=scudo"


Index: lib/Driver/ToolChains/Fuchsia.cpp
===
--- lib/Driver/ToolChains/Fuchsia.cpp
+++ lib/Driver/ToolChains/Fuchsia.cpp
@@ -280,5 +280,6 @@
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::SafeStack;
   Res |= SanitizerKind::Address;
+  Res |= SanitizerKind::Scudo;
   return Res;
 }
Index: test/Driver/fuchsia.c
===
--- test/Driver/fuchsia.c
+++ test/Driver/fuchsia.c
@@ -79,3 +79,20 @@
 // CHECK-ASAN-SHARED: "-fsanitize-address-globals-dead-stripping"
 // CHECK-ASAN-SHARED: "{{.*[/\\]}}libclang_rt.asan-x86_64.so"
 // CHECK-ASAN-SHARED-NOT: "{{.*[/\\]}}libclang_rt.asan-preinit-x86_64.a"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fsanitize=scudo 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-X86
+// CHECK-SCUDO-X86: "-fsanitize=scudo"
+// CHECK-SCUDO-X86: "-pie"
+
+// RUN: %clang %s -### --target=aarch64-fuchsia \
+// RUN: -fsanitize=scudo 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-AARCH64
+// CHECK-SCUDO-AARCH64: "-fsanitize=scudo"
+// CHECK-SCUDO-AARCH64: "-pie"
+
+// RUN: %clang %s -### --target=x86_64-fuchsia \
+// RUN: -fsanitize=scudo -fPIC -shared 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-SCUDO-SHARED
+// CHECK-SCUDO-SHARED: "-fsanitize=scudo"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41363: [clang-tidy] Adding Fuchsia checker for overloaded operators

2017-12-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Are the Fuchsia library headers intended to also comply with this rule? I 
notice there's mention of a unique_ptr class, and I can't imagine that working 
without overloading more operators than just assignment. Perhaps this check 
should not be triggered for system headers?




Comment at: docs/clang-tidy/checks/fuchsia-overloaded-operator.rst:15
+
+  B &operator=(const B& other);  // No warning
+  B &operator=(B &&other) // No warning

`&` should bind to `other` here.



Comment at: test/clang-tidy/fuchsia-overloaded-operator.cpp:11
+public:
+  B &operator=(const B& other);
+  // CHECK-MESSAGES-NOT: [[@LINE-1]]:3: warning: cannot overload 'operator=' 
[fuchsia-overloaded-operator]

The `&` should bind to `other`. Same below. Also, the param identifier should 
start with a capital letter (also same below).


https://reviews.llvm.org/D41363



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


Re: r315984 - [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with LValue base info

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

This commit has caused a new regression in LLVM 6. I filed the following
PR: https://bugs.llvm.org/show_bug.cgi?id=35724 .
Could you please take a look?

Thanks,
Alex

On 17 October 2017 at 02:12, Ivan A. Kosarev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: kosarev
> Date: Tue Oct 17 02:12:13 2017
> New Revision: 315984
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315984&view=rev
> Log:
> [CodeGen] EmitPointerWithAlignment() to generate TBAA info along with
> LValue base info
>
> Differential Revision: https://reviews.llvm.org/D38796
>
> Added:
> cfe/trunk/test/CodeGen/tbaa-cast.cpp
> Modified:
> cfe/trunk/lib/CodeGen/CGExpr.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> cfe/trunk/lib/CodeGen/CodeGenModule.h
> cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
> cfe/trunk/lib/CodeGen/CodeGenTBAA.h
>
> Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGExpr.cpp?rev=315984&r1=315983&r2=315984&view=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Oct 17 02:12:13 2017
> @@ -916,7 +916,8 @@ void CodeGenModule::EmitExplicitCastExpr
>  /// EmitPointerWithAlignment - Given an expression of pointer type, try to
>  /// derive a more accurate bound on the alignment of the pointer.
>  Address CodeGenFunction::EmitPointerWithAlignment(const Expr *E,
> -  LValueBaseInfo
> *BaseInfo) {
> +  LValueBaseInfo
> *BaseInfo,
> +  TBAAAccessInfo
> *TBAAInfo) {
>// We allow this with ObjC object pointers because of fragile ABIs.
>assert(E->getType()->isPointerType() ||
>   E->getType()->isObjCObjectPointerType());
> @@ -936,20 +937,30 @@ Address CodeGenFunction::EmitPointerWith
>  if (PtrTy->getPointeeType()->isVoidType())
>break;
>
> -LValueBaseInfo InnerInfo;
> -Address Addr = EmitPointerWithAlignment(CE->getSubExpr(),
> &InnerInfo);
> -if (BaseInfo) *BaseInfo = InnerInfo;
> -
> -// If this is an explicit bitcast, and the source l-value is
> -// opaque, honor the alignment of the casted-to type.
> -if (isa(CE) &&
> -InnerInfo.getAlignmentSource() != AlignmentSource::Decl) {
> -  LValueBaseInfo ExpInfo;
> +LValueBaseInfo InnerBaseInfo;
> +TBAAAccessInfo InnerTBAAInfo;
> +Address Addr = EmitPointerWithAlignment(CE->getSubExpr(),
> +&InnerBaseInfo,
> +&InnerTBAAInfo);
> +if (BaseInfo) *BaseInfo = InnerBaseInfo;
> +if (TBAAInfo) *TBAAInfo = InnerTBAAInfo;
> +
> +if (isa(CE)) {
> +  LValueBaseInfo TargetTypeBaseInfo;
> +  TBAAAccessInfo TargetTypeTBAAInfo;
>CharUnits Align = getNaturalPointeeTypeAlignment(E->getType(),
> -   &ExpInfo);
> -  if (BaseInfo)
> -BaseInfo->mergeForCast(ExpInfo);
> -  Addr = Address(Addr.getPointer(), Align);
> +
>  &TargetTypeBaseInfo,
> +
>  &TargetTypeTBAAInfo);
> +  if (TBAAInfo)
> +*TBAAInfo = CGM.mergeTBAAInfoForCast(*TBAAInfo,
> + TargetTypeTBAAInfo);
> +  // If the source l-value is opaque, honor the alignment of the
> +  // casted-to type.
> +  if (InnerBaseInfo.getAlignmentSource() !=
> AlignmentSource::Decl) {
> +if (BaseInfo)
> +  BaseInfo->mergeForCast(TargetTypeBaseInfo);
> +Addr = Address(Addr.getPointer(), Align);
> +  }
>  }
>
>  if (SanOpts.has(SanitizerKind::CFIUnrelatedCast) &&
> @@ -969,12 +980,13 @@ Address CodeGenFunction::EmitPointerWith
>
>  // Array-to-pointer decay.
>  case CK_ArrayToPointerDecay:
> -  return EmitArrayToPointerDecay(CE->getSubExpr(), BaseInfo);
> +  return EmitArrayToPointerDecay(CE->getSubExpr(), BaseInfo,
> TBAAInfo);
>
>  // Derived-to-base conversions.
>  case CK_UncheckedDerivedToBase:
>  case CK_DerivedToBase: {
> -  Address Addr = EmitPointerWithAlignment(CE->getSubExpr(),
> BaseInfo);
> +  Address Addr = EmitPointerWithAlignment(CE->getSubExpr(), BaseInfo,
> +  TBAAInfo);
>auto Derived = CE->getSubExpr()->getType()->
> getPointeeCXXRecordDecl();
>return GetAddressOfBaseClass(Addr, Derived,
> CE->path_begin(), CE->path_end(),
> @@ -994,6 +1006,7 @@ Address CodeGenFunction::EmitPointerWith
>  if (UO->getOpcode() == UO_AddrOf) {
>LValue LV = EmitLValu

Re: r321301 - [AArch64] Enable fp16 data type for the Builtin for AArch64 only.

2017-12-21 Thread Ahmed Bougacha via cfe-commits
On Thu, Dec 21, 2017 at 12:10 PM, Abderrazek Zaafrani via cfe-commits
 wrote:
> Author: az
> Date: Thu Dec 21 12:10:03 2017
> New Revision: 321301
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321301&view=rev
> Log:
> [AArch64] Enable fp16 data type for the Builtin for AArch64 only.
>
> Differential Revision: https:://reviews.llvm.org/D41360
>
> Modified:
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/lib/CodeGen/CodeGenFunction.h
> cfe/trunk/test/CodeGen/arm_neon_intrinsics.c
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=321301&r1=321300&r2=321301&view=diff
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Thu Dec 21 12:10:03 2017
> @@ -3334,10 +3334,10 @@ static Value *EmitTargetArchBuiltinExpr(
>case llvm::Triple::armeb:
>case llvm::Triple::thumb:
>case llvm::Triple::thumbeb:
> -return CGF->EmitARMBuiltinExpr(BuiltinID, E);
> +return CGF->EmitARMBuiltinExpr(BuiltinID, E, Arch);
>case llvm::Triple::aarch64:
>case llvm::Triple::aarch64_be:
> -return CGF->EmitAArch64BuiltinExpr(BuiltinID, E);
> +return CGF->EmitAArch64BuiltinExpr(BuiltinID, E, Arch);
>case llvm::Triple::x86:
>case llvm::Triple::x86_64:
>  return CGF->EmitX86BuiltinExpr(BuiltinID, E);
> @@ -3378,6 +3378,7 @@ Value *CodeGenFunction::EmitTargetBuilti
>
>  static llvm::VectorType *GetNeonType(CodeGenFunction *CGF,
>   NeonTypeFlags TypeFlags,
> + llvm::Triple::ArchType Arch,
>   bool V1Ty=false) {
>int IsQuad = TypeFlags.isQuad();
>switch (TypeFlags.getEltType()) {
> @@ -3388,7 +3389,12 @@ static llvm::VectorType *GetNeonType(Cod
>case NeonTypeFlags::Poly16:
>  return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));
>case NeonTypeFlags::Float16:
> -return llvm::VectorType::get(CGF->HalfTy, V1Ty ? 1 : (4 << IsQuad));
> +// FIXME: Only AArch64 backend can so far properly handle half types.
> +// Remove else part once ARM backend support for half is complete.
> +if (Arch == llvm::Triple::aarch64)
> +  return llvm::VectorType::get(CGF->HalfTy, V1Ty ? 1 : (4 << IsQuad));
> +else
> +  return llvm::VectorType::get(CGF->Int16Ty, V1Ty ? 1 : (4 << IsQuad));

Hey Abderrazek,

I don't think you need to pass 'Arch' around.  You're already in CGF,
which has a triple:
  CGF->getTarget().getTriple().getArch()
It is slightly different from what's passed in EmitTargetArchBuiltinExpr:
   CGF->getContext().getAuxTargetInfo()->getTriple().getArch()

though IIRC the 'aux target' is only different for GPU target offloading.

More importantly, should you check for:
  LangOpts.HalfArgsAndReturns
and:
  LangOpts.NativeHalfType
instead?

I think that mirrors the actual requirement.   -fnative-half-type is
disabled by default on ARM.  And on AArch64, always picking 'half'
makes -fnative-half-type mandatory.  I don't remember the
ramifications off the top of my head, but that seems like a larger
discussion to be had.

Thanks for taking a look!
-Ahmed
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321316 - [CMake][Fuchsia] Enable assertions

2017-12-21 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Dec 21 14:10:27 2017
New Revision: 321316

URL: http://llvm.org/viewvc/llvm-project?rev=321316&view=rev
Log:
[CMake][Fuchsia] Enable assertions

Enable assertions in both stages.
Release+Asserts is fast enough.
No need to let insanity through.

Patch By: mcgrathr

Reviewers: phosek

Reviewed By: phosek

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

Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
cfe/trunk/cmake/caches/Fuchsia.cmake

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=321316&r1=321315&r2=321316&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Thu Dec 21 14:10:27 2017
@@ -23,6 +23,7 @@ if(APPLE)
   set(LLDB_CODESIGN_IDENTITY "" CACHE STRING "")
 endif()
 
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")

Modified: cfe/trunk/cmake/caches/Fuchsia.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia.cmake?rev=321316&r1=321315&r2=321316&view=diff
==
--- cfe/trunk/cmake/caches/Fuchsia.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia.cmake Thu Dec 21 14:10:27 2017
@@ -13,6 +13,7 @@ set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL
 set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")


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


[PATCH] D41471: [CMake][Fuchsia] Enable assertions

2017-12-21 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321316: [CMake][Fuchsia] Enable assertions (authored by 
phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41471?vs=127801&id=127943#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41471

Files:
  cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
  cfe/trunk/cmake/caches/Fuchsia.cmake


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -23,6 +23,7 @@
   set(LLDB_CODESIGN_IDENTITY "" CACHE STRING "")
 endif()
 
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE 
STRING "")
Index: cfe/trunk/cmake/caches/Fuchsia.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia.cmake
+++ cfe/trunk/cmake/caches/Fuchsia.cmake
@@ -13,6 +13,7 @@
 set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -23,6 +23,7 @@
   set(LLDB_CODESIGN_IDENTITY "" CACHE STRING "")
 endif()
 
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "")
 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "")
Index: cfe/trunk/cmake/caches/Fuchsia.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia.cmake
+++ cfe/trunk/cmake/caches/Fuchsia.cmake
@@ -13,6 +13,7 @@
 set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 
 set(BOOTSTRAP_LLVM_ENABLE_LTO ON CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D41514: [Index] Reduce size of SymbolInfo struct.

2017-12-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: akyrtzi.
Herald added subscribers: cfe-commits, ilya-biryukov.

This is currently 16 bytes, the patch reduces it to 4.
(Building with clang on linux x84, I guess others are similar)

The only subfield that might need a bigger type is SymbolPropertySet,
I've moved it to the end of the struct so if it grows, SymbolInfo will
only be 8 bytes.

With a full index of namespace-scope symbols from the LLVM project (200k)
loaded into clangd, this saves ~2MB of RAM.


Repository:
  rC Clang

https://reviews.llvm.org/D41514

Files:
  include/clang/Index/IndexSymbol.h
  lib/Index/IndexSymbol.cpp
  tools/libclang/CXIndexDataConsumer.cpp

Index: tools/libclang/CXIndexDataConsumer.cpp
===
--- tools/libclang/CXIndexDataConsumer.cpp
+++ tools/libclang/CXIndexDataConsumer.cpp
@@ -1304,11 +1304,11 @@
 
 static CXIdxEntityCXXTemplateKind
 getEntityKindFromSymbolProperties(SymbolPropertySet K) {
-  if (K & (unsigned)SymbolProperty::TemplatePartialSpecialization)
+  if (K & (SymbolPropertySet)SymbolProperty::TemplatePartialSpecialization)
 return CXIdxEntity_TemplatePartialSpecialization;
-  if (K & (unsigned)SymbolProperty::TemplateSpecialization)
+  if (K & (SymbolPropertySet)SymbolProperty::TemplateSpecialization)
 return CXIdxEntity_TemplateSpecialization;
-  if (K & (unsigned)SymbolProperty::Generic)
+  if (K & (SymbolPropertySet)SymbolProperty::Generic)
 return CXIdxEntity_Template;
   return CXIdxEntity_NonTemplate;
 }
Index: lib/Index/IndexSymbol.cpp
===
--- lib/Index/IndexSymbol.cpp
+++ lib/Index/IndexSymbol.cpp
@@ -42,10 +42,10 @@
 
 static void checkForIBOutlets(const Decl *D, SymbolPropertySet &PropSet) {
   if (D->hasAttr()) {
-PropSet |= (unsigned)SymbolProperty::IBAnnotated;
+PropSet |= (SymbolPropertySet)SymbolProperty::IBAnnotated;
   } else if (D->hasAttr()) {
-PropSet |= (unsigned)SymbolProperty::IBAnnotated;
-PropSet |= (unsigned)SymbolProperty::IBOutletCollection;
+PropSet |= (SymbolPropertySet)SymbolProperty::IBAnnotated;
+PropSet |= (SymbolPropertySet)SymbolProperty::IBOutletCollection;
   }
 }
 
@@ -93,7 +93,7 @@
   Info.Lang = SymbolLanguage::C;
 
   if (isFunctionLocalSymbol(D)) {
-Info.Properties |= (unsigned)SymbolProperty::Local;
+Info.Properties |= (SymbolPropertySet)SymbolProperty::Local;
   }
 
   if (const TagDecl *TD = dyn_cast(D)) {
@@ -118,17 +118,19 @@
   if (!CXXRec->isCLike()) {
 Info.Lang = SymbolLanguage::CXX;
 if (CXXRec->getDescribedClassTemplate()) {
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
 }
   }
 }
 
 if (isa(D)) {
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
-  Info.Properties |= (unsigned)SymbolProperty::TemplatePartialSpecialization;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+  Info.Properties |=
+  (SymbolPropertySet)SymbolProperty::TemplatePartialSpecialization;
 } else if (isa(D)) {
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
-  Info.Properties |= (unsigned)SymbolProperty::TemplateSpecialization;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+  Info.Properties |=
+  (SymbolPropertySet)SymbolProperty::TemplateSpecialization;
 }
 
   } else if (auto *VD = dyn_cast(D)) {
@@ -142,15 +144,17 @@
 
 if (isa(D)) {
   Info.Lang = SymbolLanguage::CXX;
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
-  Info.Properties |= (unsigned)SymbolProperty::TemplatePartialSpecialization;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+  Info.Properties |=
+  (SymbolPropertySet)SymbolProperty::TemplatePartialSpecialization;
 } else if (isa(D)) {
   Info.Lang = SymbolLanguage::CXX;
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
-  Info.Properties |= (unsigned)SymbolProperty::TemplateSpecialization;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+  Info.Properties |=
+  (SymbolPropertySet)SymbolProperty::TemplateSpecialization;
 } else if (VD->getDescribedVarTemplate()) {
   Info.Lang = SymbolLanguage::CXX;
-  Info.Properties |= (unsigned)SymbolProperty::Generic;
+  Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
 }
 
   } else {
@@ -181,7 +185,7 @@
   if (!ClsD)
 ClsD = cast(D)->getClassInterface();
   if (isUnitTestCase(ClsD))
-Info.Properties |= (unsigned)SymbolProperty::UnitTest;
+Info.Properties |= (SymbolPropertySet)SymbolProperty::UnitTest;
   break;
 }
 case Decl::ObjCProtocol:
@@ -198,7 +202,7 @@
   else
 ClsD = cast(D)->getClassInterface();
   if (isUnitTestCase(ClsD))
-Info.Properties

  1   2   >