[PATCH] D57219: [Fixed Point Arithmetic] Fixed Point Comparisons

2019-01-28 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: clang/test/Frontend/fixed_point_comparisons.c:56
+
+void TestComparisons() {
+  short _Accum sa;

leonardchan wrote:
> ebevhan wrote:
> > Missing saturating and saturating/non-saturating comparisons. I'd like to 
> > see the differences between unsigned padding and not there, if there are 
> > any.
> I don't think there should be since we compare by converting to a common type 
> that should fit both operands, but it does help to have tests that also 
> confirm this. Added some saturation cases under `TestSaturationComparisons`.
> 
> As for padding, `TestSaturationComparisons` have cases comparing signed with 
> unsigned types, and there are other cases in `TestComparisons` and 
> `TestIntComparisons` that deal with unsigned comparisons. The way the lit 
> tests are organized, lines marked with `CHECK` mean that those lines are 
> produced for both the padding and no padding cases whereas `SIGNED` or 
> `UNSIGNED` are produced exclusively for no padding and padding cases, 
> respectively.
There is a difference between saturating signed types and saturating unsigned 
types, though; the common type of two of the same saturating unsigned type is 
one bit less due to padding.

Unless there is something in the type commoning that I've missed?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57219



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


Re: r352079 - [FileManager] Revert r347205 to avoid PCH file-descriptor leak.

2019-01-28 Thread Sam McCall via cfe-commits
This is kind of expected: r347205 was a bugfix.
Reverting it causes a real bug, and the tests are failing. The bug is
acceptable for 8.0 - it affects only a marginal case (go-to-definition on a
#include *outside* the preamble section of a file that was also
transitively #included in the preamble).

One mystery: why are the tests failing on the branch but not on trunk?
I do want to dig into this today/tomorrow, but I don't think it affects
what we do on the branch.

The right fix for the branch is just to delete the three failing assertions
(for locations 5, 6, 7 in that test).
Is it possible to do this directly on the branch (without deleting them on
trunk)?

On Sat, Jan 26, 2019 at 1:30 AM Hans Wennborg  wrote:

> Sorry to bring more bad news, but merging this seems to have regressed
> a clangd test on the branch (I didn't notice at the time, because I
> ran the wrong set of tests, d'oh).
>
> I've searched my inbox but couldn't find any recent commits touching
> the test. Do you have any idea what might be happening?
>
>  TEST 'Extra Tools Unit Tests ::
> clangd/./ClangdTests/GoToInclude.All' FAILED 
> Note: Google Test filter = GoToInclude.All
> [==] Running 1 test from 1 test case.
> [--] Global test environment set-up.
> [--] 1 test from GoToInclude
> [ RUN  ] GoToInclude.All
>
> /work/llvm-8/llvm/tools/clang/tools/extra/unittests/clangd/XRefsTests.cpp:1086:
> Failure
> Value of: *Locations
> Expected: has 1 element that file range ("/clangd-test/foo.h", 0:0-0:0)
>   Actual: {}
>
> /work/llvm-8/llvm/tools/clang/tools/extra/unittests/clangd/XRefsTests.cpp:1096:
> Failure
> Value of: *Locations
> Expected: has 1 element that file range ("/clangd-test/foo.h", 0:0-0:0)
>   Actual: {}
>
> /work/llvm-8/llvm/tools/clang/tools/extra/unittests/clangd/XRefsTests.cpp:1101:
> Failure
> Value of: *Locations
> Expected: has 1 element that file range ("/clangd-test/foo.h", 0:0-0:0)
>   Actual: {}
> [  FAILED  ] GoToInclude.All (14 ms)
> [--] 1 test from GoToInclude (14 ms total)
>
> [--] Global test environment tear-down
> [==] 1 test from 1 test case ran. (14 ms total)
> [  PASSED  ] 0 tests.
> [  FAILED  ] 1 test, listed below:
> [  FAILED  ] GoToInclude.All
>
>  1 FAILED TEST
> Updating file /clangd-test/foo.h with command [/clangd-test] clang
> -ffreestanding /clangd-test/foo.h
> Updating file /clangd-test/foo.cpp with command [/clangd-test] clang
> -ffreestanding /clangd-test/foo.cpp
> Preamble for file /clangd-test/foo.h cannot be reused. Attempting to
> rebuild it.
> Preamble for file /clangd-test/foo.cpp cannot be reused. Attempting to
> rebuild it.
> Built preamble of size 169108 for file /clangd-test/foo.h
> Built preamble of size 173056 for file /clangd-test/foo.cpp
>
> 
> Testing Time: 5.30s
> 
> Failing Tests (1):
> Extra Tools Unit Tests :: clangd/./ClangdTests/GoToInclude.All
>
>   Expected Passes: 1123
>   Expected Failures  : 1
>   Unsupported Tests  : 3
>   Unexpected Failures: 1
>
> On Fri, Jan 25, 2019 at 10:18 AM Hans Wennborg  wrote:
> >
> > Merged to 8.0 in r352225.
> >
> > On Thu, Jan 24, 2019 at 10:55 AM Sam McCall via cfe-commits
> >  wrote:
> > >
> > > Author: sammccall
> > > Date: Thu Jan 24 10:55:24 2019
> > > New Revision: 352079
> > >
> > > URL: http://llvm.org/viewvc/llvm-project?rev=352079&view=rev
> > > Log:
> > > [FileManager] Revert r347205 to avoid PCH file-descriptor leak.
> > >
> > > Summary:
> > > r347205 fixed a bug in FileManager: first calling
> > > getFile(shouldOpen=false) and then getFile(shouldOpen=true) results in
> > > the file not being open.
> > >
> > > Unfortunately, some code was (inadvertently?) relying on this bug: when
> > > building with a PCH, the file entries are obtained first by passing
> > > shouldOpen=false, and then later shouldOpen=true, without any intention
> > > of reading them. After r347205, they do get unneccesarily opened.
> > > Aside from extra operations, this means they need to be closed.
> Normally
> > > files are closed when their contents are read. As these files are never
> > > read, they stay open until clang exits. On platforms with a low
> > > open-files limit (e.g. Mac), this can lead to spurious file-not-found
> > > errors when building large projects with PCH enabled, e.g.
> > >   https://bugs.chromium.org/p/chromium/issues/detail?id=924225
> > >
> > > Fixing the callsites to pass shouldOpen=false when the file won't be
> > > read is not quite trivial (that info isn't available at the direct
> > > callsite), and passing shouldOpen=false is a performance regression (it
> > > results in open+fstat pairs being replaced by stat+open).
> > >
> > > So an ideal fix is going to be a little risky and we need some fix soon
> > > (especially for the llvm 8 branch).
> > > The problem addressed by r347205 is rare and has only been observed in
> > > clangd. It was present in llvm-7, so we can live with it for 

r352345 - [AST] Add structural eq tests for template args

2019-01-28 Thread Gabor Marton via cfe-commits
Author: martong
Date: Mon Jan 28 02:01:11 2019
New Revision: 352345

URL: http://llvm.org/viewvc/llvm-project?rev=352345&view=rev
Log:
[AST] Add structural eq tests for template args

Summary:
New tests added to verify equivalency of templates when their
parameters are different.

Reviewers: a_sidorin, shafik

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

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

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

Modified: cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp?rev=352345&r1=352344&r2=352345&view=diff
==
--- cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp (original)
+++ cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp Mon Jan 28 02:01:11 
2019
@@ -802,6 +802,25 @@ TEST_F(StructuralEquivalenceEnumTest, En
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+struct StructuralEquivalenceTemplateTest : StructuralEquivalenceTest {};
+
+TEST_F(StructuralEquivalenceTemplateTest, ExactlySameTemplates) {
+  auto t = makeNamedDecls("template  struct foo;",
+  "template  struct foo;", Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceTemplateTest, DifferentTemplateArgName) {
+  auto t = makeNamedDecls("template  struct foo;",
+  "template  struct foo;", Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceTemplateTest, DifferentTemplateArgKind) {
+  auto t = makeNamedDecls("template  struct foo;",
+  "template  struct foo;", Lang_CXX);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
 
 } // end namespace ast_matchers
 } // end namespace clang


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


[PATCH] D57235: [AST] Add structural eq tests for template args

2019-01-28 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352345: [AST] Add structural eq tests for template args 
(authored by martong, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57235?vs=183525&id=183810#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57235

Files:
  unittests/AST/StructuralEquivalenceTest.cpp


Index: unittests/AST/StructuralEquivalenceTest.cpp
===
--- unittests/AST/StructuralEquivalenceTest.cpp
+++ unittests/AST/StructuralEquivalenceTest.cpp
@@ -802,6 +802,25 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+struct StructuralEquivalenceTemplateTest : StructuralEquivalenceTest {};
+
+TEST_F(StructuralEquivalenceTemplateTest, ExactlySameTemplates) {
+  auto t = makeNamedDecls("template  struct foo;",
+  "template  struct foo;", Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceTemplateTest, DifferentTemplateArgName) {
+  auto t = makeNamedDecls("template  struct foo;",
+  "template  struct foo;", Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceTemplateTest, DifferentTemplateArgKind) {
+  auto t = makeNamedDecls("template  struct foo;",
+  "template  struct foo;", Lang_CXX);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
 
 } // end namespace ast_matchers
 } // end namespace clang


Index: unittests/AST/StructuralEquivalenceTest.cpp
===
--- unittests/AST/StructuralEquivalenceTest.cpp
+++ unittests/AST/StructuralEquivalenceTest.cpp
@@ -802,6 +802,25 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+struct StructuralEquivalenceTemplateTest : StructuralEquivalenceTest {};
+
+TEST_F(StructuralEquivalenceTemplateTest, ExactlySameTemplates) {
+  auto t = makeNamedDecls("template  struct foo;",
+  "template  struct foo;", Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceTemplateTest, DifferentTemplateArgName) {
+  auto t = makeNamedDecls("template  struct foo;",
+  "template  struct foo;", Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceTemplateTest, DifferentTemplateArgKind) {
+  auto t = makeNamedDecls("template  struct foo;",
+  "template  struct foo;", Lang_CXX);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
 
 } // end namespace ast_matchers
 } // end namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D33440: clang-format: better handle statement macros

2019-01-28 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@Typz
I think this should be part of the release notes for v8. 
This is changing the output on some code base and this is a new feature.

By the way, an example in the doc would be great (including with the 
configuration)

merci!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D33440



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


[PATCH] D56803: clang -dumpversion returns 4.2.1 for legacy reason, update it

2019-01-28 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

ping?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56803



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


[PATCH] D57185: [clang-tidy] Add the abseil-duration-addition check

2019-01-28 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth accepted this revision.
JonasToth added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D57185



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


[PATCH] D54395: [clang-tidy] implement utility-function to add 'const' to variables

2019-01-28 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

ping.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D54395



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


r352349 - Rename getTypeQualifiers to getMethodQualifiers.

2019-01-28 Thread Anastasia Stulova via cfe-commits
Author: stulova
Date: Mon Jan 28 03:37:49 2019
New Revision: 352349

URL: http://llvm.org/viewvc/llvm-project?rev=352349&view=rev
Log:
Rename getTypeQualifiers to getMethodQualifiers.

Use more descriptive name for the method qualifiers getter.

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


Modified:
cfe/trunk/include/clang/AST/CanonicalType.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/AST/VTableBuilder.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/CanonicalType.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CanonicalType.h?rev=352349&r1=352348&r2=352349&view=diff
==
--- cfe/trunk/include/clang/AST/CanonicalType.h (original)
+++ cfe/trunk/include/clang/AST/CanonicalType.h Mon Jan 28 03:37:49 2019
@@ -509,7 +509,7 @@ struct CanProxyAdaptor;

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=352349&r1=352348&r2=352349&view=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Jan 28 03:37:49 2019
@@ -2184,8 +2184,8 @@ public:
   static QualType getThisType(const FunctionProtoType *FPT,
   const CXXRecordDecl *Decl);
 
-  Qualifiers getTypeQualifiers() const {
-return getType()->getAs()->getTypeQuals();
+  Qualifiers getMethodQualifiers() const {
+return getType()->getAs()->getMethodQuals();
   }
 
   /// Retrieve the ref-qualifier associated with this method.

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=352349&r1=352348&r2=352349&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Mon Jan 28 03:37:49 2019
@@ -3901,7 +3901,7 @@ public:
 EPI.Variadic = isVariadic();
 EPI.HasTrailingReturn = hasTrailingReturn();
 EPI.ExceptionSpec.Type = getExceptionSpecType();
-EPI.TypeQuals = getTypeQuals();
+EPI.TypeQuals = getMethodQuals();
 EPI.RefQualifier = getRefQualifier();
 if (EPI.ExceptionSpec.Type == EST_Dynamic) {
   EPI.ExceptionSpec.Exceptions = exceptions();
@@ -4011,7 +4011,7 @@ public:
   /// Whether this function prototype has a trailing return type.
   bool hasTrailingReturn() const { return FunctionTypeBits.HasTrailingReturn; }
 
-  Qualifiers getTypeQuals() const {
+  Qualifiers getMethodQuals() const {
 if (hasExtQualifiers())
   return *getTrailingObjects();
 else

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=352349&r1=352348&r2=352349&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Jan 28 03:37:49 2019
@@ -8580,7 +8580,7 @@ QualType ASTContext::mergeFunctionTypes(
 if (lproto->isVariadic() != rproto->isVariadic())
   return {};
 
-if (lproto->getTypeQuals() != rproto->getTypeQuals())
+if (lproto->getMethodQuals() != rproto->getMethodQuals())
   return {};
 
 SmallVector newParamInfos;

Modified: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp?rev=352349&r1=352348&r2=352349&view=diff
==
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp (original)
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp Mon Jan 28 03:37:49 2019
@@ -528,7 +528,7 @@ static bool IsStructurallyEquivalent(Str
 if (Proto1->isVariadic() != Proto2->isVariadic())
   return false;
 
-if (Proto1->getTypeQuals() != Proto2->getTypeQuals())
+if (Proto1->getMethodQuals() != Proto2->getMethodQuals())
   return false;
 
 // Check exceptions, this information is lost in canonical type.

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http

[PATCH] D56792: Rename getTypeQualifiers to getMethodQualifiers

2019-01-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352349: Rename getTypeQualifiers to getMethodQualifiers. 
(authored by stulova, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56792?vs=182066&id=183821#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56792

Files:
  cfe/trunk/include/clang/AST/CanonicalType.h
  cfe/trunk/include/clang/AST/DeclCXX.h
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/lib/AST/ASTContext.cpp
  cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
  cfe/trunk/lib/AST/DeclCXX.cpp
  cfe/trunk/lib/AST/ItaniumMangle.cpp
  cfe/trunk/lib/AST/MicrosoftMangle.cpp
  cfe/trunk/lib/AST/TypePrinter.cpp
  cfe/trunk/lib/AST/VTableBuilder.cpp
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/Index/USRGeneration.cpp
  cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
  cfe/trunk/lib/Sema/SemaCodeComplete.cpp
  cfe/trunk/lib/Sema/SemaDecl.cpp
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
  cfe/trunk/lib/Sema/SemaType.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/tools/libclang/CIndex.cpp

Index: cfe/trunk/lib/Serialization/ASTWriter.cpp
===
--- cfe/trunk/lib/Serialization/ASTWriter.cpp
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp
@@ -309,7 +309,7 @@
 
   Record.push_back(T->isVariadic());
   Record.push_back(T->hasTrailingReturn());
-  Record.push_back(T->getTypeQuals().getAsOpaqueValue());
+  Record.push_back(T->getMethodQuals().getAsOpaqueValue());
   Record.push_back(static_cast(T->getRefQualifier()));
   addExceptionSpec(T, Record);
 
@@ -322,7 +322,7 @@
   Record.push_back(T->getExtParameterInfo(I).getOpaqueValue());
   }
 
-  if (T->isVariadic() || T->hasTrailingReturn() || T->getTypeQuals() ||
+  if (T->isVariadic() || T->hasTrailingReturn() || T->getMethodQuals() ||
   T->getRefQualifier() || T->getExceptionSpecType() != EST_None ||
   T->hasExtParameterInfos())
 AbbrevToUse = 0;
Index: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
===
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
@@ -415,7 +415,7 @@
   Method = cast(LM.Method);
 
 Sema::CXXThisScopeRAII ThisScope(Actions, Method->getParent(),
- Method->getTypeQualifiers(),
+ Method->getMethodQualifiers(),
  getLangOpts().CPlusPlus11);
 
 // Parse the exception-specification.
Index: cfe/trunk/lib/Index/USRGeneration.cpp
===
--- cfe/trunk/lib/Index/USRGeneration.cpp
+++ cfe/trunk/lib/Index/USRGeneration.cpp
@@ -270,7 +270,7 @@
 if (MD->isStatic())
   Out << 'S';
 // FIXME: OpenCL: Need to consider address spaces
-if (unsigned quals = MD->getTypeQualifiers().getCVRUQualifiers())
+if (unsigned quals = MD->getMethodQualifiers().getCVRUQualifiers())
   Out << (char)('0' + quals);
 switch (MD->getRefQualifier()) {
 case RQ_None: break;
Index: cfe/trunk/lib/CodeGen/CGCall.cpp
===
--- cfe/trunk/lib/CodeGen/CGCall.cpp
+++ cfe/trunk/lib/CodeGen/CGCall.cpp
@@ -73,7 +73,7 @@
const CXXMethodDecl *MD) {
   QualType RecTy = Context.getTagDeclType(RD)->getCanonicalTypeInternal();
   if (MD)
-RecTy = Context.getAddrSpaceQualType(RecTy, MD->getTypeQualifiers().getAddressSpace());
+RecTy = Context.getAddrSpaceQualType(RecTy, MD->getMethodQualifiers().getAddressSpace());
   return Context.getPointerType(CanQualType::CreateUnsafe(RecTy));
 }
 
Index: cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
===
--- cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
+++ cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
@@ -528,7 +528,7 @@
 if (Proto1->isVariadic() != Proto2->isVariadic())
   return false;
 
-if (Proto1->getTypeQuals() != Proto2->getTypeQuals())
+if (Proto1->getMethodQuals() != Proto2->getMethodQuals())
   return false;
 
 // Check exceptions, this information is lost in canonical type.
Index: cfe/trunk/lib/AST/ItaniumMangle.cpp
===
--- cfe/trunk/lib/AST/ItaniumMangle.cpp
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp
@@ -1502,7 +1502,7 @@
 
   Out << 'N';
   if (const CXXMethodDecl *Method = dyn_cast(ND)) {
-Qualifiers MethodQuals = Method->getTypeQualifiers();
+Qualifiers MethodQuals = Method->getMethodQualifiers();
 // We do not consider restrict a distinguishing attribute for overloading
 

[PATCH] D56852: [AArch64] Use LL for 64-bit arguments

2019-01-28 Thread Sam Parker via Phabricator via cfe-commits
samparker updated this revision to Diff 183820.
samparker added reviewers: phosek, rnk.
samparker added a comment.

Changed the builtins to use W instead of LL. I've also updated the tests, 
adding a test for rbitl.


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

https://reviews.llvm.org/D56852

Files:
  include/clang/Basic/BuiltinsAArch64.def
  test/CodeGen/arm64-crc32.c
  test/CodeGen/builtins-arm64.c

Index: test/CodeGen/builtins-arm64.c
===
--- test/CodeGen/builtins-arm64.c
+++ test/CodeGen/builtins-arm64.c
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple arm64-unknown-linux -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-unknown-linux -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LINUX
+// RUN: %clang_cc1 -triple aarch64-windows -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-WIN
 #include 
 
 void f0(void *a, void *b) {
@@ -16,8 +17,15 @@
   return __builtin_arm_rbit(a);
 }
 
+// CHECK-WIN: [[A64:%[^ ]+]] = zext i32 %a to i64
+// CHECK-WIN: call i64 @llvm.bitreverse.i64(i64 [[A64]])
+// CHECK-LINUX: call i64 @llvm.bitreverse.i64(i64 %a)
+unsigned long rbitl(unsigned long a) {
+  return __builtin_arm_rbit64(a);
+}
+
 // CHECK: call {{.*}} @llvm.bitreverse.i64(i64 %a)
-unsigned long long rbit64(unsigned long long a) {
+uint64_t rbit64(uint64_t a) {
   return __builtin_arm_rbit64(a);
 }
 
@@ -60,7 +68,7 @@
 
 __typeof__(__builtin_arm_rsr64("1:2:3:4:5")) rsr64(void);
 
-uint64_t rsr64() {
+uint64_t rsr64(void) {
   // CHECK: call i64 @llvm.read_register.i64(metadata ![[M0:[0-9]]])
   return __builtin_arm_rsr64("1:2:3:4:5");
 }
@@ -71,13 +79,17 @@
   return __builtin_arm_rsrp("1:2:3:4:5");
 }
 
+__typeof__(__builtin_arm_wsr("1:2:3:4:5", 0)) wsr(unsigned);
+
 void wsr(unsigned v) {
   // CHECK: [[V0:[%A-Za-z0-9.]+]] = zext i32 %v to i64
   // CHECK-NEXT: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 [[V0]])
   __builtin_arm_wsr("1:2:3:4:5", v);
 }
 
-void wsr64(unsigned long v) {
+__typeof__(__builtin_arm_wsr64("1:2:3:4:5", 0)) wsr64(uint64_t);
+
+void wsr64(uint64_t v) {
   // CHECK: call void @llvm.write_register.i64(metadata ![[M0:[0-9]]], i64 %v)
   __builtin_arm_wsr64("1:2:3:4:5", v);
 }
Index: test/CodeGen/arm64-crc32.c
===
--- test/CodeGen/arm64-crc32.c
+++ test/CodeGen/arm64-crc32.c
@@ -1,54 +1,57 @@
 // REQUIRES: aarch64-registered-target
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu \
 // RUN:  -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-windows \
+// RUN:  -disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+#include 
 
-int crc32b(int a, char b)
+uint32_t crc32b(uint32_t a, uint8_t b)
 {
 return __builtin_arm_crc32b(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i8 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32b(i32 %a, i32 [[T0]])
 }
 
-int crc32cb(int a, char b)
+uint32_t crc32cb(uint32_t a, uint8_t b)
 {
 return __builtin_arm_crc32cb(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i8 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32cb(i32 %a, i32 [[T0]])
 }
 
-int crc32h(int a, short b)
+uint32_t crc32h(uint32_t a, uint16_t b)
 {
 return __builtin_arm_crc32h(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i16 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32h(i32 %a, i32 [[T0]])
 }
 
-int crc32ch(int a, short b)
+uint32_t crc32ch(uint32_t a, uint16_t b)
 {
 return __builtin_arm_crc32ch(a,b);
 // CHECK: [[T0:%[0-9]+]] = zext i16 %b to i32
 // CHECK: call i32 @llvm.aarch64.crc32ch(i32 %a, i32 [[T0]])
 }
 
-int crc32w(int a, int b)
+uint32_t crc32w(uint32_t a, uint32_t b)
 {
 return __builtin_arm_crc32w(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32w(i32 %a, i32 %b)
 }
 
-int crc32cw(int a, int b)
+uint32_t crc32cw(uint32_t a, uint32_t b)
 {
 return __builtin_arm_crc32cw(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32cw(i32 %a, i32 %b)
 }
 
-int crc32d(int a, long b)
+uint32_t crc32d(uint32_t a, uint64_t b)
 {
 return __builtin_arm_crc32d(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32x(i32 %a, i64 %b)
 }
 
-int crc32cd(int a, long b)
+uint32_t crc32cd(uint32_t a, uint64_t b)
 {
 return __builtin_arm_crc32cd(a,b);
 // CHECK: call i32 @llvm.aarch64.crc32cx(i32 %a, i64 %b)
Index: include/clang/Basic/BuiltinsAArch64.def
===
--- include/clang/Basic/BuiltinsAArch64.def
+++ include/clang/Basic/BuiltinsAArch64.def
@@ -32,7 +32,7 @@
 
 // Bit manipulation
 BUILTIN(__builtin_arm_rbit, "UiUi", "nc")
-BUILTIN(__builtin_arm_rbit64, "LUiLUi", "nc")
+BUILTIN(__builtin_arm_rbit64, "WUiWUi", "nc")
 
 // HINT
 BUILTIN(__builtin_arm_nop, "v", "")
@@ -49,8 +49,8 @@
 BUILTIN(_

[PATCH] D57232: [ASTImporter] Check visibility/linkage of functions and variables

2019-01-28 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 183826.
martong marked 5 inline comments as done.
martong added a comment.

- Remove dumpDeclContext() call
- Remove superfluous else


Repository:
  rC Clang

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

https://reviews.llvm.org/D57232

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -10,6 +10,10 @@
 //
 //===--===//
 
+// Define this to have ::testing::Combine available.
+// FIXME: Better solution for this?
+#define GTEST_HAS_COMBINE 1
+
 #include "clang/AST/ASTImporter.h"
 #include "MatchVerifier.h"
 #include "clang/AST/ASTContext.h"
@@ -58,23 +62,31 @@
 // Common base for the different families of ASTImporter tests that are
 // parameterized on the compiler options which may result a different AST. E.g.
 // -fms-compatibility or -fdelayed-template-parsing.
-struct ParameterizedTestsFixture : ::testing::TestWithParam {
+class CompilerOptionSpecificTest : public ::testing::Test {
+protected:
+  // Return the extra arguments appended to runtime options at compilation.
+  virtual ArgVector getExtraArgs() const { return ArgVector(); }
 
   // Returns the argument vector used for a specific language option, this set
   // can be tweaked by the test parameters.
   ArgVector getArgVectorForLanguage(Language Lang) const {
 ArgVector Args = getBasicRunOptionsForLanguage(Lang);
-ArgVector ExtraArgs = GetParam();
+ArgVector ExtraArgs = getExtraArgs();
 for (const auto &Arg : ExtraArgs) {
   Args.push_back(Arg);
 }
 return Args;
   }
-
 };
 
+auto DefaultTestValuesForRunOptions = ::testing::Values(
+ArgVector(), ArgVector{"-fdelayed-template-parsing"},
+ArgVector{"-fms-compatibility"},
+ArgVector{"-fdelayed-template-parsing", "-fms-compatibility"});
+
 // Base class for those tests which use the family of `testImport` functions.
-class TestImportBase : public ParameterizedTestsFixture {
+class TestImportBase : public CompilerOptionSpecificTest,
+   public ::testing::WithParamInterface {
 
   template 
   NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter &Importer,
@@ -159,6 +171,9 @@
 VerificationMatcher);
   }
 
+protected:
+  ArgVector getExtraArgs() const override { return GetParam(); }
+
 public:
 
   /// Test how AST node named "declToImport" located in the translation unit
@@ -284,7 +299,7 @@
 // This class provides generic methods to write tests which can check internal
 // attributes of AST nodes like getPreviousDecl(), isVirtual(), etc. Also,
 // this fixture makes it possible to import from several "From" contexts.
-class ASTImporterTestBase : public ParameterizedTestsFixture {
+class ASTImporterTestBase : public CompilerOptionSpecificTest {
 
   const char *const InputFileName = "input.cc";
   const char *const OutputFileName = "output.cc";
@@ -450,6 +465,10 @@
 return FromTU->import(*LookupTablePtr, ToAST.get(), From);
   }
 
+  template  DeclT *Import(DeclT *From, Language Lang) {
+return cast_or_null(Import(cast(From), Lang));
+  }
+
   QualType ImportType(QualType FromType, Decl *TUDecl, Language ToLang) {
 lazyInitToAST(ToLang, "", OutputFileName);
 TU *FromTU = findFromTU(TUDecl);
@@ -473,11 +492,18 @@
   }
 };
 
+class ASTImporterOptionSpecificTestBase
+: public ASTImporterTestBase,
+  public ::testing::WithParamInterface {
+protected:
+  ArgVector getExtraArgs() const override { return GetParam(); }
+};
+
 struct ImportExpr : TestImportBase {};
 struct ImportType : TestImportBase {};
 struct ImportDecl : TestImportBase {};
 
-struct CanonicalRedeclChain : ASTImporterTestBase {};
+struct CanonicalRedeclChain : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(CanonicalRedeclChain, ShouldBeConsequentWithMatchers) {
   Decl *FromTU = getTuDecl("void f();", Lang_CXX);
@@ -1000,7 +1026,7 @@
  has(declStmt(hasSingleDecl(varDecl(hasName("d");
 }
 
-TEST_P(ASTImporterTestBase, ImportRecordTypeInFunc) {
+TEST_P(ASTImporterOptionSpecificTestBase, ImportRecordTypeInFunc) {
   Decl *FromTU = getTuDecl("int declToImport() { "
"  struct data_t {int a;int b;};"
"  struct data_t d;"
@@ -1015,7 +1041,7 @@
   EXPECT_FALSE(ToType.isNull());
 }
 
-TEST_P(ASTImporterTestBase, ImportRecordDeclInFuncParams) {
+TEST_P(ASTImporterOptionSpecificTestBase, ImportRecordDeclInFuncParams) {
   // This construct is not supported by ASTImporter.
   Decl *FromTU = getTuDecl(
   "int declToImport(struct data_t{int a;int b;} ***d){ return 0; }",
@@ -1027,7 +1053,7 @@
   EXPECT_EQ(To, nullptr);
 }
 
-TEST_P(ASTImporterTestBase, ImportRecordDeclInFuncFromMacro) {
+TEST_P(ASTImporterOptionS

[PATCH] D57232: [ASTImporter] Check visibility/linkage of functions and variables

2019-01-28 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: lib/AST/ASTImporter.cpp:2954
+return Found->hasExternalFormalLinkage();
+  else if (Importer.GetFromTU(Found) == From->getTranslationUnitDecl()) {
+if (From->isInAnonymousNamespace())

shafik wrote:
> We don't really need an `else ` here and it would be more like an early exit 
> which is what llvm style guide suggests.
> 
> In the same vein I would do:
> 
> if (Importer.GetFromTU(Found) != From->getTranslationUnitDecl())
>return false; 
> 
> so a second early exit and remove a level of nesting at the same time.
It's a good catch, thanks.



Comment at: unittests/AST/ASTImporterTest.cpp:65
 // -fms-compatibility or -fdelayed-template-parsing.
-struct ParameterizedTestsFixture : ::testing::TestWithParam {
+class CompilerOptionSpecificTest : public ::testing::Test {
+protected:

shafik wrote:
> Are these changes directly related to the visibility change? There is a lot 
> of noise that is not obviously related to the description in the PR.
> 
> 
> If not maybe it should be a separate PR?
Actually, it will be more precise to create first a patch which contains the 
tests related refactor, I agree. I'll do that and this patch will be dependent 
upon that.



Comment at: unittests/AST/ASTImporterTest.cpp:2523
+  Decl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+  cast(ToTU)->dumpDeclContext();
+  ASSERT_EQ(DeclCounter().match(ToTU, 
functionDecl(hasName("f"))),

balazske wrote:
> Is this dump needed? (The test should not write unnecessary text output. But 
> debug statements can be leaved in the test, possibly in comment.)
Thanks for catching this, good point.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57232



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


[PATCH] D57100: [clang-tidy] refactor bugprone-exception-escape analysis into class

2019-01-28 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

Hello! I am glad to see that this check gets improved by the community. I also 
think a "modernize" check which marks functions with `noexcept` is also useful.

As for the comma or semicolon, I think semicolon would be better. I see that 
this part is reverted now, but is there any reason for using `std::string` 
instead of `llvm::StringRef`? I always thought this latter is the standard for 
LLVM code wherever possible.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57100



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


[PATCH] D57100: [clang-tidy] refactor bugprone-exception-escape analysis into class

2019-01-28 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

In D57100#1373430 , 
@baloghadamsoftware wrote:

> Hello! I am glad to see that this check gets improved by the community. I 
> also think a "modernize" check which marks functions with `noexcept` is also 
> useful.


Great to hear!

> As for the comma or semicolon, I think semicolon would be better. I see that 
> this part is reverted now, but is there any reason for using `std::string` 
> instead of `llvm::StringRef`? I always thought this latter is the standard 
> for LLVM code wherever possible.

Which part to you mean? The original semicolon-splitting?
I think there the issue is, that `StringRef` is just a handle, but if you split 
a big string into smaller ones you want the result to be owning its own memory 
instead of just pointing to a span in the original full string.
Even though that would be correct in some cases it has a subtle dangling-bug if 
you work further with the result of the split or the underlying string 
disappears for some reason.
Otherwise `StringRef` is definitly the goto-class for string operations (that 
dont change underlying memory).

For now the comma-vs-semicolon thingie will stay as is, because its a breaking 
change in the configurations and the gain for switching to semicolon is small, 
whereas the pain to figuring out that changed is big.

@baloghadamsoftware Do you see any problems with the refactoring, especially 
the new `FunctionDecl*`-Caching is not exactly a refactoring. If you have any 
thoughts on that would be great to hear!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57100



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


[PATCH] D57106: [AST] Introduce GenericSelectionExpr::Association

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

LGTM aside from some possible minor nits. Thank you for working on this!




Comment at: include/clang/AST/Expr.h:5122
+AssociationIteratorTy() = default;
+AssociationTy operator*() const {
+  return AssociationTy(cast(*E), *TSI,

Can this continue to return `reference` instead of the concrete type? (Same in 
the cast expression.)



Comment at: include/clang/AST/Expr.h:5126
+}
+AssociationTy operator->() const { return **this; }
+using BaseTy::operator++;

Can this return `pointer` instead?



Comment at: include/clang/AST/Expr.h:5254
+/*Offset=*/NumAssocs, ResultIndex);
+return {Begin, End};
   }

If you like being explicit, you could use `llvm::make_range()` here, but I 
don't insist. Same below.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57106



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


[PATCH] D57322: [ASTImporter] Refactor unittests to be able to parameterize them in a more flexible way

2019-01-28 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: a_sidorin, shafik.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp, rnkovacs.
Herald added a reviewer: a.sidorin.

Currently `TestImportBase` is derived from `ParameterizedTestsFixture`
which explicitly states that the gtest parameter can be only an
`ArgVector`. This is a limitation when we want to create tests which may
have different parameters.
E.g. we would like to create tests where we can combine different test
parameters. So, for example we'd like gtest to be able to provide
parameters of `` instead of a simple
`ArgVector`.


Repository:
  rC Clang

https://reviews.llvm.org/D57322

Files:
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -10,6 +10,10 @@
 //
 //===--===//
 
+// Define this to have ::testing::Combine available.
+// FIXME: Better solution for this?
+#define GTEST_HAS_COMBINE 1
+
 #include "clang/AST/ASTImporter.h"
 #include "MatchVerifier.h"
 #include "clang/AST/ASTContext.h"
@@ -58,23 +62,31 @@
 // Common base for the different families of ASTImporter tests that are
 // parameterized on the compiler options which may result a different AST. E.g.
 // -fms-compatibility or -fdelayed-template-parsing.
-struct ParameterizedTestsFixture : ::testing::TestWithParam {
+class CompilerOptionSpecificTest : public ::testing::Test {
+protected:
+  // Return the extra arguments appended to runtime options at compilation.
+  virtual ArgVector getExtraArgs() const { return ArgVector(); }
 
   // Returns the argument vector used for a specific language option, this set
   // can be tweaked by the test parameters.
   ArgVector getArgVectorForLanguage(Language Lang) const {
 ArgVector Args = getBasicRunOptionsForLanguage(Lang);
-ArgVector ExtraArgs = GetParam();
+ArgVector ExtraArgs = getExtraArgs();
 for (const auto &Arg : ExtraArgs) {
   Args.push_back(Arg);
 }
 return Args;
   }
-
 };
 
+auto DefaultTestValuesForRunOptions = ::testing::Values(
+ArgVector(), ArgVector{"-fdelayed-template-parsing"},
+ArgVector{"-fms-compatibility"},
+ArgVector{"-fdelayed-template-parsing", "-fms-compatibility"});
+
 // Base class for those tests which use the family of `testImport` functions.
-class TestImportBase : public ParameterizedTestsFixture {
+class TestImportBase : public CompilerOptionSpecificTest,
+   public ::testing::WithParamInterface {
 
   template 
   NodeType importNode(ASTUnit *From, ASTUnit *To, ASTImporter &Importer,
@@ -159,6 +171,9 @@
 VerificationMatcher);
   }
 
+protected:
+  ArgVector getExtraArgs() const override { return GetParam(); }
+
 public:
 
   /// Test how AST node named "declToImport" located in the translation unit
@@ -284,7 +299,7 @@
 // This class provides generic methods to write tests which can check internal
 // attributes of AST nodes like getPreviousDecl(), isVirtual(), etc. Also,
 // this fixture makes it possible to import from several "From" contexts.
-class ASTImporterTestBase : public ParameterizedTestsFixture {
+class ASTImporterTestBase : public CompilerOptionSpecificTest {
 
   const char *const InputFileName = "input.cc";
   const char *const OutputFileName = "output.cc";
@@ -450,6 +465,10 @@
 return FromTU->import(*LookupTablePtr, ToAST.get(), From);
   }
 
+  template  DeclT *Import(DeclT *From, Language Lang) {
+return cast_or_null(Import(cast(From), Lang));
+  }
+
   QualType ImportType(QualType FromType, Decl *TUDecl, Language ToLang) {
 lazyInitToAST(ToLang, "", OutputFileName);
 TU *FromTU = findFromTU(TUDecl);
@@ -473,11 +492,18 @@
   }
 };
 
+class ASTImporterOptionSpecificTestBase
+: public ASTImporterTestBase,
+  public ::testing::WithParamInterface {
+protected:
+  ArgVector getExtraArgs() const override { return GetParam(); }
+};
+
 struct ImportExpr : TestImportBase {};
 struct ImportType : TestImportBase {};
 struct ImportDecl : TestImportBase {};
 
-struct CanonicalRedeclChain : ASTImporterTestBase {};
+struct CanonicalRedeclChain : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(CanonicalRedeclChain, ShouldBeConsequentWithMatchers) {
   Decl *FromTU = getTuDecl("void f();", Lang_CXX);
@@ -1000,7 +1026,7 @@
  has(declStmt(hasSingleDecl(varDecl(hasName("d");
 }
 
-TEST_P(ASTImporterTestBase, ImportRecordTypeInFunc) {
+TEST_P(ASTImporterOptionSpecificTestBase, ImportRecordTypeInFunc) {
   Decl *FromTU = getTuDecl("int declToImport() { "
"  struct data_t {int a;int b;};"
"  struct data_t d;"
@@ -1015,7 +1041,7 @@
   EXPECT_FALSE(ToType.isNull());
 }
 
-TEST_P(ASTImporterTestBase, ImportRecordDeclInFuncParams) {
+TEST_P(ASTImporterOptionSpecificTestBase, ImportRecordDeclIn

[PATCH] D54438: [analyzer] Reimplement dependencies between checkers

2019-01-28 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added inline comments.



Comment at: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td:230
 
 def NullReturnedFromNonnullChecker : Checker<"NullReturnedFromNonnull">,
   HelpText<"Warns when a null pointer is returned from a function that has "

Any reason this checker shouldn't get a dependecy too?

If I run it with

 clang -cc1 -analyze -analyzer-checker=core 
-analyzer-checker=nullability.NullReturnedFromNonnull empty.c

on an empty file empty.c I get

clang: ../tools/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:171: 
CHECKER *clang::ento::CheckerManager::getChecker() [CHECKER = (anonymous 
namespace)::NullabilityChecker]: Assertion `CheckerTags.count(tag) != 0 && 
"Requested checker is not registered! Maybe you should add it as a " 
"dependency in Checkers.td?"' failed.

If I add
 Dependencies<[NullabilityBase]>,
to it, then it doesn't trigger the assert.

I don't know anything about this code, what do you think about it?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D54438



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


[PATCH] D57232: [ASTImporter] Check visibility/linkage of functions and variables

2019-01-28 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 183834.
martong added a comment.

I have created a separate patch for the test related refactor, this patch now
depends on that patch and contains merely the visibility related change and
their tests.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57232

Files:
  include/clang/AST/ASTImporter.h
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -2264,6 +2264,266 @@
 }).match(ToTU, functionDecl()));
 }
 
+//FIXME Move these tests to a separate test file.
+namespace TypeAndValueParameterizedTests {
+
+// Type parameters for type-parameterized test fixtures.
+struct GetFunPattern {
+  using DeclTy = FunctionDecl;
+  BindableMatcher operator()() { return functionDecl(hasName("f")); }
+};
+struct GetVarPattern {
+  using DeclTy = VarDecl;
+  BindableMatcher operator()() { return varDecl(hasName("v")); }
+};
+
+// Values for the value-parameterized test fixtures.
+// FunctionDecl:
+auto *ExternF = "void f();";
+auto *StaticF = "static void f();";
+auto *AnonF = "namespace { void f(); }";
+// VarDecl:
+auto *ExternV = "extern int v;";
+auto *StaticV = "static int v;";
+auto *AnonV = "namespace { extern int v; }";
+
+// First value in tuple: Compile options.
+// Second value in tuple: Source code to be used in the test.
+using ImportVisibilityChainParams =
+::testing::WithParamInterface>;
+// Fixture to test the redecl chain of Decls with the same visibility.  Gtest
+// makes it possible to have either value-parameterized or type-parameterized
+// fixtures.  However, we cannot have both value- and type-parameterized test
+// fixtures.  This is a value-parameterized test fixture in the gtest sense. We
+// intend to mimic gtest's type-parameters via the PatternFactory template
+// parameter.  We manually instantiate the different tests with the each types.
+template 
+class ImportVisibilityChain
+: public ASTImporterTestBase, public ImportVisibilityChainParams {
+protected:
+  using DeclTy = typename PatternFactory::DeclTy;
+  ArgVector getExtraArgs() const override { return std::get<0>(GetParam()); }
+  std::string getCode() const { return std::get<1>(GetParam()); }
+  BindableMatcher getPattern() const { return PatternFactory()(); }
+
+  // Type-parameterized test.
+  void TypedTest_ImportChain() {
+std::string Code = getCode() + getCode();
+auto Pattern = getPattern();
+
+TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_CXX, "input0.cc");
+
+auto *FromF0 = FirstDeclMatcher().match(FromTu, Pattern);
+auto *FromF1 = LastDeclMatcher().match(FromTu, Pattern);
+
+auto *ToF0 = Import(FromF0, Lang_CXX);
+auto *ToF1 = Import(FromF1, Lang_CXX);
+
+EXPECT_TRUE(ToF0);
+ASSERT_TRUE(ToF1);
+EXPECT_NE(ToF0, ToF1);
+EXPECT_EQ(ToF1->getPreviousDecl(), ToF0);
+  }
+};
+
+// Manual instantiation of the fixture with each type.
+using ImportFunctionsVisibilityChain = ImportVisibilityChain;
+using ImportVariablesVisibilityChain = ImportVisibilityChain;
+// Value-parameterized test for the first type.
+TEST_P(ImportFunctionsVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
+// Value-parameterized test for the second type.
+TEST_P(ImportVariablesVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
+
+// Automatic instantiation of the value-parameterized tests.
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportFunctionsVisibilityChain,
+::testing::Combine(
+   DefaultTestValuesForRunOptions,
+   ::testing::Values(ExternF, StaticF, AnonF)), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportVariablesVisibilityChain,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+// There is no point to instantiate with StaticV, because in C++ we can
+// forward declare a variable only with the 'extern' keyword.
+// Consequently, each fwd declared variable has external linkage.  This
+// is different in the C language where any declaration without an
+// initializer is a tentative definition, subsequent definitions may be
+// provided but they must have the same linkage.  See also the test
+// ImportVariableChainInC which test for this special C Lang case.
+::testing::Values(ExternV, AnonV)), );
+
+// First value in tuple: Compile options.
+// Second value in tuple: Tuple with informations for the test.
+// Code for first import (or initial code), code to import, whether the `f`
+// functions are expected to be linked in a declaration chain.
+// One value of this tuple is combined with every value of compile options.
+// The test can have a single tuple as parameter only.
+using ImportVisibilityParams 

Re: r352079 - [FileManager] Revert r347205 to avoid PCH file-descriptor leak.

2019-01-28 Thread Hans Wennborg via cfe-commits
Thanks for looking into this. I've reverted the test assertions on the
branch in r352354.

On Mon, Jan 28, 2019 at 1:14 AM Sam McCall  wrote:
>
> This is kind of expected: r347205 was a bugfix.
> Reverting it causes a real bug, and the tests are failing. The bug is 
> acceptable for 8.0 - it affects only a marginal case (go-to-definition on a 
> #include *outside* the preamble section of a file that was also transitively 
> #included in the preamble).
>
> One mystery: why are the tests failing on the branch but not on trunk?
> I do want to dig into this today/tomorrow, but I don't think it affects what 
> we do on the branch.
>
> The right fix for the branch is just to delete the three failing assertions 
> (for locations 5, 6, 7 in that test).
> Is it possible to do this directly on the branch (without deleting them on 
> trunk)?
>
> On Sat, Jan 26, 2019 at 1:30 AM Hans Wennborg  wrote:
>>
>> Sorry to bring more bad news, but merging this seems to have regressed
>> a clangd test on the branch (I didn't notice at the time, because I
>> ran the wrong set of tests, d'oh).
>>
>> I've searched my inbox but couldn't find any recent commits touching
>> the test. Do you have any idea what might be happening?
>>
>>  TEST 'Extra Tools Unit Tests ::
>> clangd/./ClangdTests/GoToInclude.All' FAILED 
>> Note: Google Test filter = GoToInclude.All
>> [==] Running 1 test from 1 test case.
>> [--] Global test environment set-up.
>> [--] 1 test from GoToInclude
>> [ RUN  ] GoToInclude.All
>> /work/llvm-8/llvm/tools/clang/tools/extra/unittests/clangd/XRefsTests.cpp:1086:
>> Failure
>> Value of: *Locations
>> Expected: has 1 element that file range ("/clangd-test/foo.h", 0:0-0:0)
>>   Actual: {}
>> /work/llvm-8/llvm/tools/clang/tools/extra/unittests/clangd/XRefsTests.cpp:1096:
>> Failure
>> Value of: *Locations
>> Expected: has 1 element that file range ("/clangd-test/foo.h", 0:0-0:0)
>>   Actual: {}
>> /work/llvm-8/llvm/tools/clang/tools/extra/unittests/clangd/XRefsTests.cpp:1101:
>> Failure
>> Value of: *Locations
>> Expected: has 1 element that file range ("/clangd-test/foo.h", 0:0-0:0)
>>   Actual: {}
>> [  FAILED  ] GoToInclude.All (14 ms)
>> [--] 1 test from GoToInclude (14 ms total)
>>
>> [--] Global test environment tear-down
>> [==] 1 test from 1 test case ran. (14 ms total)
>> [  PASSED  ] 0 tests.
>> [  FAILED  ] 1 test, listed below:
>> [  FAILED  ] GoToInclude.All
>>
>>  1 FAILED TEST
>> Updating file /clangd-test/foo.h with command [/clangd-test] clang
>> -ffreestanding /clangd-test/foo.h
>> Updating file /clangd-test/foo.cpp with command [/clangd-test] clang
>> -ffreestanding /clangd-test/foo.cpp
>> Preamble for file /clangd-test/foo.h cannot be reused. Attempting to rebuild 
>> it.
>> Preamble for file /clangd-test/foo.cpp cannot be reused. Attempting to
>> rebuild it.
>> Built preamble of size 169108 for file /clangd-test/foo.h
>> Built preamble of size 173056 for file /clangd-test/foo.cpp
>>
>> 
>> Testing Time: 5.30s
>> 
>> Failing Tests (1):
>> Extra Tools Unit Tests :: clangd/./ClangdTests/GoToInclude.All
>>
>>   Expected Passes: 1123
>>   Expected Failures  : 1
>>   Unsupported Tests  : 3
>>   Unexpected Failures: 1
>>
>> On Fri, Jan 25, 2019 at 10:18 AM Hans Wennborg  wrote:
>> >
>> > Merged to 8.0 in r352225.
>> >
>> > On Thu, Jan 24, 2019 at 10:55 AM Sam McCall via cfe-commits
>> >  wrote:
>> > >
>> > > Author: sammccall
>> > > Date: Thu Jan 24 10:55:24 2019
>> > > New Revision: 352079
>> > >
>> > > URL: http://llvm.org/viewvc/llvm-project?rev=352079&view=rev
>> > > Log:
>> > > [FileManager] Revert r347205 to avoid PCH file-descriptor leak.
>> > >
>> > > Summary:
>> > > r347205 fixed a bug in FileManager: first calling
>> > > getFile(shouldOpen=false) and then getFile(shouldOpen=true) results in
>> > > the file not being open.
>> > >
>> > > Unfortunately, some code was (inadvertently?) relying on this bug: when
>> > > building with a PCH, the file entries are obtained first by passing
>> > > shouldOpen=false, and then later shouldOpen=true, without any intention
>> > > of reading them. After r347205, they do get unneccesarily opened.
>> > > Aside from extra operations, this means they need to be closed. Normally
>> > > files are closed when their contents are read. As these files are never
>> > > read, they stay open until clang exits. On platforms with a low
>> > > open-files limit (e.g. Mac), this can lead to spurious file-not-found
>> > > errors when building large projects with PCH enabled, e.g.
>> > >   https://bugs.chromium.org/p/chromium/issues/detail?id=924225
>> > >
>> > > Fixing the callsites to pass shouldOpen=false when the file won't be
>> > > read is not quite trivial (that info isn't available at the direct
>> > > callsite), and passing shouldOpen=false is a performance regression (it
>> > > results in open+fstat pairs being replaced by stat+open).

[PATCH] D57106: [AST] Introduce GenericSelectionExpr::Association

2019-01-28 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno marked 3 inline comments as done.
riccibruno added inline comments.



Comment at: include/clang/AST/Expr.h:5122
+AssociationIteratorTy() = default;
+AssociationTy operator*() const {
+  return AssociationTy(cast(*E), *TSI,

aaron.ballman wrote:
> Can this continue to return `reference` instead of the concrete type? (Same 
> in the cast expression.)
Not literally `reference` since the base is dependent, but `typename 
BaseTy::reference` should work. Is that what you mean ?



Comment at: include/clang/AST/Expr.h:5254
+/*Offset=*/NumAssocs, ResultIndex);
+return {Begin, End};
   }

aaron.ballman wrote:
> If you like being explicit, you could use `llvm::make_range()` here, but I 
> don't insist. Same below.
I have no special preference on this, so `llvm::make_range()` it is.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57106



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


[PATCH] D57106: [AST] Introduce GenericSelectionExpr::Association

2019-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/Expr.h:5122
+AssociationIteratorTy() = default;
+AssociationTy operator*() const {
+  return AssociationTy(cast(*E), *TSI,

riccibruno wrote:
> aaron.ballman wrote:
> > Can this continue to return `reference` instead of the concrete type? (Same 
> > in the cast expression.)
> Not literally `reference` since the base is dependent, but `typename 
> BaseTy::reference` should work. Is that what you mean ?
Yes, that's what I meant, sorry. :-)


Repository:
  rC Clang

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

https://reviews.llvm.org/D57106



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


[PATCH] D57322: [ASTImporter] Refactor unittests to be able to parameterize them in a more flexible way

2019-01-28 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: unittests/AST/ASTImporterTest.cpp:15
+// FIXME: Better solution for this?
+#define GTEST_HAS_COMBINE 1
+

Define of this is related to the new visibility tests, but not a problem is 
this remains here (there is another not strictly related thing: The new 
`Import` template).


Repository:
  rC Clang

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

https://reviews.llvm.org/D57322



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


[PATCH] D57266: [AST] Update the comments of the various Expr::Ignore* + Related cleanups

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

LGTM with some nits. Thank you for the cleaned up comments, these are helpful!




Comment at: include/clang/AST/Expr.h:749-750
+  /// reaching a fixed point. Skips:
+  /// * ImplicitCastExpr.
+  /// * FullExpr.
   Expr *IgnoreImpCasts() LLVM_READONLY;

I'd remove the full stops from the list elements (same elsewhere).



Comment at: include/clang/AST/Expr.h:848
+  ///   CK_UncheckedDerivedToBase and CK_NoOp).
   Expr *ignoreParenBaseCasts() LLVM_READONLY;
+  const Expr *ignoreParenBaseCasts() const {

Want to fix up this name to match the coding conventions (in a separate patch, 
no review needed)?



Comment at: lib/AST/Expr.cpp:2561
+  Expr *E = this;
+  while (true)
+if (ImplicitCastExpr *ICE = dyn_cast(E))

I would appreciate some braces around the loop body -- I know they're not 
strictly required, but this is not a particularly simple body either.



Comment at: lib/AST/Expr.cpp:2562
+  while (true)
+if (ImplicitCastExpr *ICE = dyn_cast(E))
+  E = ICE->getSubExpr();

`auto *` and same below.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57266



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


[PATCH] D57106: [AST] Introduce GenericSelectionExpr::Association

2019-01-28 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno marked 5 inline comments as done.
riccibruno added inline comments.



Comment at: include/clang/AST/Expr.h:5122
+AssociationIteratorTy() = default;
+AssociationTy operator*() const {
+  return AssociationTy(cast(*E), *TSI,

aaron.ballman wrote:
> riccibruno wrote:
> > aaron.ballman wrote:
> > > Can this continue to return `reference` instead of the concrete type? 
> > > (Same in the cast expression.)
> > Not literally `reference` since the base is dependent, but `typename 
> > BaseTy::reference` should work. Is that what you mean ?
> Yes, that's what I meant, sorry. :-)
Right. I will land this today when I have some time. Thanks for the review !


Repository:
  rC Clang

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

https://reviews.llvm.org/D57106



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


[PATCH] D54438: [analyzer] Reimplement dependencies between checkers

2019-01-28 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked an inline comment as done.
Szelethus added inline comments.



Comment at: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td:230
 
 def NullReturnedFromNonnullChecker : Checker<"NullReturnedFromNonnull">,
   HelpText<"Warns when a null pointer is returned from a function that has "

uabelho wrote:
> Any reason this checker shouldn't get a dependecy too?
> 
> If I run it with
> 
>  clang -cc1 -analyze -analyzer-checker=core 
> -analyzer-checker=nullability.NullReturnedFromNonnull empty.c
> 
> on an empty file empty.c I get
> 
> clang: ../tools/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:171: 
> CHECKER *clang::ento::CheckerManager::getChecker() [CHECKER = (anonymous 
> namespace)::NullabilityChecker]: Assertion `CheckerTags.count(tag) != 0 && 
> "Requested checker is not registered! Maybe you should add it as a " 
> "dependency in Checkers.td?"' failed.
> 
> If I add
>  Dependencies<[NullabilityBase]>,
> to it, then it doesn't trigger the assert.
> 
> I don't know anything about this code, what do you think about it?
Yup, should be there. Thanks for catching this one! I'll be able to commit the 
fix in about 4ish hours, or if it blocks you, feel free to so before that.

Since I didnt add test for each and every affected checker, I wonder whether 
there is any more of these that I forgot/messed up while rebasing.

Thanks again! :)


Repository:
  rL LLVM

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

https://reviews.llvm.org/D54438



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


Re: r352323 - [SemaCXX] Fix ICE with structure bindings to members of template

2019-01-28 Thread Hans Wennborg via cfe-commits
Thanks for letting me know! Merged in r352356.

On Sun, Jan 27, 2019 at 12:06 PM Richard Smith  wrote:
>
> Hi Hans,
>
> This is a safe change that fixes a crash; it'd be good to get this into clang 
> 8.
>
> Thanks!
>
> On Sun, 27 Jan 2019, 11:19 Nicolas Lesser via cfe-commits, 
>  wrote:
>>
>> Author: rakete
>> Date: Sun Jan 27 11:19:59 2019
>> New Revision: 352323
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=352323&view=rev
>> Log:
>> [SemaCXX] Fix ICE with structure bindings to members of template
>>
>> Summary:
>> Trying to use structure binding with a structure that doesn't implement
>> std::tuple_size, should unpack the data members. When the struct is a
>> template though, clang might hit an assertion (if the type has not been
>> completed before), because CXXRecordDecl::DefinitionData is nullptr.
>>
>> This commit fixes the problem by completing the type while trying to
>> decompose the structured binding.
>>
>> The ICE happens in real world code, for example, when trying to iterate
>> a protobuf generated map with a range-based for loop and structure
>> bindings (because google::protobuf::MapPair is a template and doesn't
>> support std::tuple_size).
>>
>> Reported-by: nicholas@nlsun.com
>>
>> Patch by Daniele Di Proietto
>>
>> Reviewers: #clang, rsmith
>>
>> Reviewed By: #clang, rsmith
>>
>> Subscribers: cpplearner, Rakete, cfe-commits
>>
>> Tags: #clang
>>
>> Differential Revision: https://reviews.llvm.org/D56974
>>
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=352323&r1=352322&r2=352323&view=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Jan 27 11:19:59 2019
>> @@ -1300,6 +1300,10 @@ static DeclAccessPair findDecomposableBa
>>  static bool checkMemberDecomposition(Sema &S, ArrayRef 
>> Bindings,
>>   ValueDecl *Src, QualType DecompType,
>>   const CXXRecordDecl *OrigRD) {
>> +  if (S.RequireCompleteType(Src->getLocation(), DecompType,
>> +diag::err_incomplete_type))
>> +return true;
>> +
>>CXXCastPath BasePath;
>>DeclAccessPair BasePair =
>>findDecomposableBaseClass(S, Src->getLocation(), OrigRD, BasePath);
>>
>> Modified: cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp?rev=352323&r1=352322&r2=352323&view=diff
>> ==
>> --- cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp (original)
>> +++ cfe/trunk/test/SemaCXX/cxx1z-decomposition.cpp Sun Jan 27 11:19:59 2019
>> @@ -81,4 +81,21 @@ struct PR37352 {
>>void f() { static auto [a] = *this; } // expected-error {{cannot be 
>> declared 'static'}}
>>  };
>>
>> +namespace instantiate_template {
>> +
>> +template 
>> +struct pair {
>> +  T1 a;
>> +  T2 b;
>> +};
>> +
>> +const pair &f1();
>> +
>> +int f2() {
>> +  const auto &[a, b] = f1();
>> +  return a + b;
>> +}
>> +
>> +} // namespace instantiate_template
>> +
>>  // FIXME: by-value array copies
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D54438: [analyzer] Reimplement dependencies between checkers

2019-01-28 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added inline comments.



Comment at: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td:230
 
 def NullReturnedFromNonnullChecker : Checker<"NullReturnedFromNonnull">,
   HelpText<"Warns when a null pointer is returned from a function that has "

Szelethus wrote:
> uabelho wrote:
> > Any reason this checker shouldn't get a dependecy too?
> > 
> > If I run it with
> > 
> >  clang -cc1 -analyze -analyzer-checker=core 
> > -analyzer-checker=nullability.NullReturnedFromNonnull empty.c
> > 
> > on an empty file empty.c I get
> > 
> > clang: 
> > ../tools/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:171: 
> > CHECKER *clang::ento::CheckerManager::getChecker() [CHECKER = (anonymous 
> > namespace)::NullabilityChecker]: Assertion `CheckerTags.count(tag) != 0 && 
> > "Requested checker is not registered! Maybe you should add it as a " 
> > "dependency in Checkers.td?"' failed.
> > 
> > If I add
> >  Dependencies<[NullabilityBase]>,
> > to it, then it doesn't trigger the assert.
> > 
> > I don't know anything about this code, what do you think about it?
> Yup, should be there. Thanks for catching this one! I'll be able to commit 
> the fix in about 4ish hours, or if it blocks you, feel free to so before that.
> 
> Since I didnt add test for each and every affected checker, I wonder whether 
> there is any more of these that I forgot/messed up while rebasing.
> 
> Thanks again! :)
Sounds good, no panic!

Thanks!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D54438



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


[PATCH] D57266: [AST] Update the comments of the various Expr::Ignore* + Related cleanups

2019-01-28 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno marked 8 inline comments as done.
riccibruno added inline comments.



Comment at: include/clang/AST/Expr.h:749-750
+  /// reaching a fixed point. Skips:
+  /// * ImplicitCastExpr.
+  /// * FullExpr.
   Expr *IgnoreImpCasts() LLVM_READONLY;

aaron.ballman wrote:
> I'd remove the full stops from the list elements (same elsewhere).
Will do.



Comment at: include/clang/AST/Expr.h:848
+  ///   CK_UncheckedDerivedToBase and CK_NoOp).
   Expr *ignoreParenBaseCasts() LLVM_READONLY;
+  const Expr *ignoreParenBaseCasts() const {

aaron.ballman wrote:
> Want to fix up this name to match the coding conventions (in a separate 
> patch, no review needed)?
Yeah I only see a few uses of `ignoreParenBaseCasts` so this should be easy to 
do.



Comment at: lib/AST/Expr.cpp:2561
+  Expr *E = this;
+  while (true)
+if (ImplicitCastExpr *ICE = dyn_cast(E))

aaron.ballman wrote:
> I would appreciate some braces around the loop body -- I know they're not 
> strictly required, but this is not a particularly simple body either.
Will do before landing. I am getting rid of all of these loops in the next 
patch anyway but I agree that braces are better here.



Comment at: lib/AST/Expr.cpp:2562
+  while (true)
+if (ImplicitCastExpr *ICE = dyn_cast(E))
+  E = ICE->getSubExpr();

aaron.ballman wrote:
> `auto *` and same below.
Yep.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57266



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


Re: r352099 - [WebAssembly] Factor commonality between wasm32 and wasm64 in test/Preprocessor/init.c

2019-01-28 Thread Hans Wennborg via cfe-commits
Merged to 8.0 in r352359.

On Thu, Jan 24, 2019 at 12:31 PM Dan Gohman via cfe-commits
 wrote:
>
> Author: djg
> Date: Thu Jan 24 12:31:11 2019
> New Revision: 352099
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352099&view=rev
> Log:
> [WebAssembly] Factor commonality between wasm32 and wasm64 in 
> test/Preprocessor/init.c
>
> Use the -check-prefixes= feature to merge most of the WEBASSEMBLY32 and
> WEBASSEMBLY64 test checks into a shared WEBASSEMBLY test check.
>
> Differential Revision: https://reviews.llvm.org/D57153
>
> Modified:
> cfe/trunk/test/Preprocessor/init.c
>
> Modified: cfe/trunk/test/Preprocessor/init.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=352099&r1=352098&r2=352099&view=diff
> ==
> --- cfe/trunk/test/Preprocessor/init.c (original)
> +++ cfe/trunk/test/Preprocessor/init.c Thu Jan 24 12:31:11 2019
> @@ -9110,667 +9110,376 @@
>  //
>  // RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm32-unknown-unknown \
>  // RUN:   < /dev/null \
> -// RUN:   | FileCheck -match-full-lines -check-prefix=WEBASSEMBLY32 %s
> +// RUN:   | FileCheck -match-full-lines 
> -check-prefixes=WEBASSEMBLY,WEBASSEMBLY32 %s
> +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm64-unknown-unknown \
> +// RUN:   < /dev/null \
> +// RUN:   | FileCheck -match-full-lines 
> -check-prefixes=WEBASSEMBLY,WEBASSEMBLY64 %s
>  //
>  // WEBASSEMBLY32:#define _ILP32 1
>  // WEBASSEMBLY32-NOT:#define _LP64
> -// WEBASSEMBLY32-NEXT:#define __ATOMIC_ACQUIRE 2
> -// WEBASSEMBLY32-NEXT:#define __ATOMIC_ACQ_REL 4
> -// WEBASSEMBLY32-NEXT:#define __ATOMIC_CONSUME 1
> -// WEBASSEMBLY32-NEXT:#define __ATOMIC_RELAXED 0
> -// WEBASSEMBLY32-NEXT:#define __ATOMIC_RELEASE 3
> -// WEBASSEMBLY32-NEXT:#define __ATOMIC_SEQ_CST 5
> -// WEBASSEMBLY32-NEXT:#define __BIGGEST_ALIGNMENT__ 16
> -// WEBASSEMBLY32-NEXT:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
> -// WEBASSEMBLY32-NEXT:#define __CHAR16_TYPE__ unsigned short
> -// WEBASSEMBLY32-NEXT:#define __CHAR32_TYPE__ unsigned int
> -// WEBASSEMBLY32-NEXT:#define __CHAR_BIT__ 8
> -// WEBASSEMBLY32-NOT:#define __CHAR_UNSIGNED__
> -// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_BOOL_LOCK_FREE 2
> -// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 2
> -// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 2
> -// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_CHAR_LOCK_FREE 2
> -// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_INT_LOCK_FREE 2
> -// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_LLONG_LOCK_FREE 2
> -// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_LONG_LOCK_FREE 2
> -// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_POINTER_LOCK_FREE 2
> -// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
> -// WEBASSEMBLY32-NEXT:#define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
> -// WEBASSEMBLY32-NEXT:#define __CONSTANT_CFSTRINGS__ 1
> -// WEBASSEMBLY32-NEXT:#define __DBL_DECIMAL_DIG__ 17
> -// WEBASSEMBLY32-NEXT:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
> -// WEBASSEMBLY32-NEXT:#define __DBL_DIG__ 15
> -// WEBASSEMBLY32-NEXT:#define __DBL_EPSILON__ 2.2204460492503131e-16
> -// WEBASSEMBLY32-NEXT:#define __DBL_HAS_DENORM__ 1
> -// WEBASSEMBLY32-NEXT:#define __DBL_HAS_INFINITY__ 1
> -// WEBASSEMBLY32-NEXT:#define __DBL_HAS_QUIET_NAN__ 1
> -// WEBASSEMBLY32-NEXT:#define __DBL_MANT_DIG__ 53
> -// WEBASSEMBLY32-NEXT:#define __DBL_MAX_10_EXP__ 308
> -// WEBASSEMBLY32-NEXT:#define __DBL_MAX_EXP__ 1024
> -// WEBASSEMBLY32-NEXT:#define __DBL_MAX__ 1.7976931348623157e+308
> -// WEBASSEMBLY32-NEXT:#define __DBL_MIN_10_EXP__ (-307)
> -// WEBASSEMBLY32-NEXT:#define __DBL_MIN_EXP__ (-1021)
> -// WEBASSEMBLY32-NEXT:#define __DBL_MIN__ 2.2250738585072014e-308
> -// WEBASSEMBLY32-NEXT:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
> -// WEBASSEMBLY32-NOT:#define __ELF__
> -// WEBASSEMBLY32-NEXT:#define __FINITE_MATH_ONLY__ 0
> -// WEBASSEMBLY32:#define __FLT_DECIMAL_DIG__ 9
> -// WEBASSEMBLY32-NEXT:#define __FLT_DENORM_MIN__ 1.40129846e-45F
> -// WEBASSEMBLY32-NEXT:#define __FLT_DIG__ 6
> -// WEBASSEMBLY32-NEXT:#define __FLT_EPSILON__ 1.19209290e-7F
> -// WEBASSEMBLY32-NEXT:#define __FLT_EVAL_METHOD__ 0
> -// WEBASSEMBLY32-NEXT:#define __FLT_HAS_DENORM__ 1
> -// WEBASSEMBLY32-NEXT:#define __FLT_HAS_INFINITY__ 1
> -// WEBASSEMBLY32-NEXT:#define __FLT_HAS_QUIET_NAN__ 1
> -// WEBASSEMBLY32-NEXT:#define __FLT_MANT_DIG__ 24
> -// WEBASSEMBLY32-NEXT:#define __FLT_MAX_10_EXP__ 38
> -// WEBASSEMBLY32-NEXT:#define __FLT_MAX_EXP__ 128
> -// WEBASSEMBLY32-NEXT:#define __FLT_MAX__ 3.40282347e+38F
> -// WEBASSEMBLY32-NEXT:#define __FLT_MIN_10_EXP__ (-37)
> -// WEBASSEMBLY32-NEXT:#define __FLT_MIN_EXP__ (-125)
> -// WEBASSEMBLY32-NEXT:#define __FLT_MIN__ 1.17549435e-38F
> -// WEBASSEMBLY32-NEXT:#define __FLT_RADIX__ 2
> -// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_BOOL_LOCK_FREE 2
> -// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
> -// WEBASSEMBLY32-NEXT:#define __GCC_ATOMIC

Re: r352105 - [WebAssembly] Add a __wasi__ target macro

2019-01-28 Thread Hans Wennborg via cfe-commits
Merged in r352360.

On Thu, Jan 24, 2019 at 1:05 PM Dan Gohman via cfe-commits
 wrote:
>
> Author: djg
> Date: Thu Jan 24 13:05:11 2019
> New Revision: 352105
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352105&view=rev
> Log:
> [WebAssembly] Add a __wasi__ target macro
>
> This adds a `__wasi__` macro for the wasi OS, similar to `__linux__` etc. for
> other OS's.
>
> Differential Revision: https://reviews.llvm.org/D57155
>
> Modified:
> cfe/trunk/lib/Basic/Targets.cpp
> cfe/trunk/lib/Basic/Targets/OSTargets.h
> cfe/trunk/test/Preprocessor/init.c
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=352105&r1=352104&r2=352105&view=diff
> ==
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Thu Jan 24 13:05:11 2019
> @@ -569,19 +569,27 @@ TargetInfo *AllocateTarget(const llvm::T
>  Triple.getVendor() != llvm::Triple::UnknownVendor ||
>  !Triple.isOSBinFormatWasm())
>return nullptr;
> -if (Triple.getOS() != llvm::Triple::UnknownOS &&
> -Triple.getOS() != llvm::Triple::WASI)
> -  return nullptr;
> -return new WebAssemblyOSTargetInfo(Triple, 
> Opts);
> +switch (Triple.getOS()) {
> +  case llvm::Triple::WASI:
> +return new WASITargetInfo(Triple, Opts);
> +  case llvm::Triple::UnknownOS:
> +return new WebAssemblyOSTargetInfo(Triple, 
> Opts);
> +  default:
> +return nullptr;
> +}
>case llvm::Triple::wasm64:
>  if (Triple.getSubArch() != llvm::Triple::NoSubArch ||
>  Triple.getVendor() != llvm::Triple::UnknownVendor ||
>  !Triple.isOSBinFormatWasm())
>return nullptr;
> -if (Triple.getOS() != llvm::Triple::UnknownOS &&
> -Triple.getOS() != llvm::Triple::WASI)
> -  return nullptr;
> -return new WebAssemblyOSTargetInfo(Triple, 
> Opts);
> +switch (Triple.getOS()) {
> +  case llvm::Triple::WASI:
> +return new WASITargetInfo(Triple, Opts);
> +  case llvm::Triple::UnknownOS:
> +return new WebAssemblyOSTargetInfo(Triple, 
> Opts);
> +  default:
> +return nullptr;
> +}
>
>case llvm::Triple::renderscript32:
>  return new LinuxTargetInfo(Triple, Opts);
>
> Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=352105&r1=352104&r2=352105&view=diff
> ==
> --- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
> +++ cfe/trunk/lib/Basic/Targets/OSTargets.h Thu Jan 24 13:05:11 2019
> @@ -763,8 +763,9 @@ public:
>  template 
>  class LLVM_LIBRARY_VISIBILITY WebAssemblyOSTargetInfo
>  : public OSTargetInfo {
> +protected:
>void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
> -MacroBuilder &Builder) const final {
> +MacroBuilder &Builder) const {
>  // A common platform macro.
>  if (Opts.POSIXThreads)
>Builder.defineMacro("_REENTRANT");
> @@ -785,6 +786,21 @@ public:
>}
>  };
>
> +// WASI target
> +template 
> +class LLVM_LIBRARY_VISIBILITY WASITargetInfo
> +: public WebAssemblyOSTargetInfo {
> +  void getOSDefines(const LangOptions &Opts, const llvm::Triple &Triple,
> +MacroBuilder &Builder) const final {
> +WebAssemblyOSTargetInfo::getOSDefines(Opts, Triple, Builder);
> +Builder.defineMacro("__wasi__");
> +  }
> +
> +public:
> +  explicit WASITargetInfo(const llvm::Triple &Triple, const TargetOptions 
> &Opts)
> +  : WebAssemblyOSTargetInfo(Triple, Opts) {}
> +};
> +
>  } // namespace targets
>  } // namespace clang
>  #endif // LLVM_CLANG_LIB_BASIC_TARGETS_OSTARGETS_H
>
> Modified: cfe/trunk/test/Preprocessor/init.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=352105&r1=352104&r2=352105&view=diff
> ==
> --- cfe/trunk/test/Preprocessor/init.c (original)
> +++ cfe/trunk/test/Preprocessor/init.c Thu Jan 24 13:05:11 2019
> @@ -9114,6 +9114,12 @@
>  // RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm64-unknown-unknown \
>  // RUN:   < /dev/null \
>  // RUN:   | FileCheck -match-full-lines 
> -check-prefixes=WEBASSEMBLY,WEBASSEMBLY64 %s
> +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm32-unknown-wasi \
> +// RUN:   < /dev/null \
> +// RUN:   | FileCheck -match-full-lines 
> -check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,WEBASSEMBLY-WASI %s
> +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=wasm64-unknown-wasi \
> +// RUN:   < /dev/null \
> +// RUN:   | FileCheck -match-full-lines 
> -check-prefixes=WEBASSEMBLY,WEBASSEMBLY64,WEBASSEMBLY-WASI %s
>  //
>  // WEBASSEMBLY32:#define _ILP32 1
>  // WEBASSEMBLY32-NOT:#define _LP64
> @@ -9468,6 +9474,7 @@

[PATCH] D56903: [clangd] Suggest adding missing includes for incomplete type diagnostics.

2019-01-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 183838.
ioeric marked 12 inline comments as done.
ioeric added a comment.

- address review comments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56903

Files:
  clangd/CMakeLists.txt
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/CodeComplete.cpp
  clangd/Compiler.h
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  clangd/Headers.cpp
  clangd/Headers.h
  clangd/IncludeFixer.cpp
  clangd/IncludeFixer.h
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  clangd/tool/ClangdMain.cpp
  unittests/clangd/CMakeLists.txt
  unittests/clangd/ClangdUnitTests.cpp
  unittests/clangd/CodeCompleteTests.cpp
  unittests/clangd/DiagnosticsTests.cpp
  unittests/clangd/FileIndexTests.cpp
  unittests/clangd/TUSchedulerTests.cpp
  unittests/clangd/TestIndex.cpp
  unittests/clangd/TestIndex.h
  unittests/clangd/TestTU.cpp
  unittests/clangd/TestTU.h

Index: unittests/clangd/TestTU.h
===
--- unittests/clangd/TestTU.h
+++ unittests/clangd/TestTU.h
@@ -49,6 +49,8 @@
   std::vector ExtraArgs;
 
   llvm::Optional ClangTidyChecks;
+  // Index to use when building AST.
+  const SymbolIndex *ExternalIndex = nullptr;
 
   ParsedAST build() const;
   SymbolSlab headerSymbols() const;
Index: unittests/clangd/TestTU.cpp
===
--- unittests/clangd/TestTU.cpp
+++ unittests/clangd/TestTU.cpp
@@ -35,8 +35,11 @@
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
   Inputs.FS = buildTestFS({{FullFilename, Code}, {FullHeaderName, HeaderCode}});
-  Inputs.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
-  Inputs.ClangTidyOpts.Checks = ClangTidyChecks;
+  Inputs.Opts = ParseOptions();
+  Inputs.Opts.ClangTidyOpts.Checks = ClangTidyChecks;
+  Inputs.Index = ExternalIndex;
+  if (Inputs.Index)
+Inputs.Opts.SuggestMissingIncludes = true;
   auto PCHs = std::make_shared();
   auto CI = buildCompilerInvocation(Inputs);
   assert(CI && "Failed to build compilation invocation.");
Index: unittests/clangd/TestIndex.h
===
--- unittests/clangd/TestIndex.h
+++ unittests/clangd/TestIndex.h
@@ -18,6 +18,19 @@
 // Creates Symbol instance and sets SymbolID to given QualifiedName.
 Symbol symbol(llvm::StringRef QName);
 
+// Helpers to produce fake index symbols with proper SymbolID.
+// USRFormat is a regex replacement string for the unqualified part of the USR.
+Symbol sym(llvm::StringRef QName, index::SymbolKind Kind,
+   llvm::StringRef USRFormat);
+// Creats a function symbol assuming no function arg.
+Symbol func(llvm::StringRef Name);
+// Creates a class symbol.
+Symbol cls(llvm::StringRef Name);
+// Creates a variable symbol.
+Symbol var(llvm::StringRef Name);
+// Creates a namespace symbol.
+Symbol ns(llvm::StringRef Name);
+
 // Create a slab of symbols with the given qualified names as IDs and names.
 SymbolSlab generateSymbols(std::vector QualifiedNames);
 
Index: unittests/clangd/TestIndex.cpp
===
--- unittests/clangd/TestIndex.cpp
+++ unittests/clangd/TestIndex.cpp
@@ -7,6 +7,8 @@
 //===--===//
 
 #include "TestIndex.h"
+#include "clang/Index/IndexSymbol.h"
+#include "llvm/Support/Regex.h"
 
 namespace clang {
 namespace clangd {
@@ -25,6 +27,58 @@
   return Sym;
 }
 
+static std::string replace(llvm::StringRef Haystack, llvm::StringRef Needle,
+   llvm::StringRef Repl) {
+  std::string Result;
+  llvm::raw_string_ostream OS(Result);
+  std::pair Split;
+  for (Split = Haystack.split(Needle); !Split.second.empty();
+   Split = Split.first.split(Needle))
+OS << Split.first << Repl;
+  Result += Split.first;
+  OS.flush();
+  return Result;
+}
+
+// Helpers to produce fake index symbols for memIndex() or completions().
+// USRFormat is a regex replacement string for the unqualified part of the USR.
+Symbol sym(llvm::StringRef QName, index::SymbolKind Kind,
+   llvm::StringRef USRFormat) {
+  Symbol Sym;
+  std::string USR = "c:"; // We synthesize a few simple cases of USRs by hand!
+  size_t Pos = QName.rfind("::");
+  if (Pos == llvm::StringRef::npos) {
+Sym.Name = QName;
+Sym.Scope = "";
+  } else {
+Sym.Name = QName.substr(Pos + 2);
+Sym.Scope = QName.substr(0, Pos + 2);
+USR += "@N@" + replace(QName.substr(0, Pos), "::", "@N@"); // ns:: -> @N@ns
+  }
+  USR += llvm::Regex("^.*$").sub(USRFormat, Sym.Name); // e.g. func -> @F@func#
+  Sym.ID = SymbolID(USR);
+  Sym.SymInfo.Kind = Kind;
+  Sym.Flags |= Symbol::IndexedForCodeCompletion;
+  Sym.Origin = SymbolOrigin::Static;
+  return Sym;
+}
+
+Symbol func(llvm::StringRef Name) { // Assumes the function has no a

[clang-tools-extra] r352361 - [clangd] Suggest adding missing includes for incomplete type diagnostics.

2019-01-28 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Mon Jan 28 06:01:55 2019
New Revision: 352361

URL: http://llvm.org/viewvc/llvm-project?rev=352361&view=rev
Log:
[clangd] Suggest adding missing includes for incomplete type diagnostics.

Summary:
This enables clangd to intercept compiler diagnostics and attach fixes (e.g. by
querying index). This patch adds missing includes for incomplete types e.g.
member access into class with only forward declaration. This would allow adding
missing includes for user-typed symbol names that are missing declarations
(e.g. typos) in the future.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, mgrang, 
arphaman, kadircet, cfe-commits

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

Added:
clang-tools-extra/trunk/clangd/IncludeFixer.cpp
clang-tools-extra/trunk/clangd/IncludeFixer.h
clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp
  - copied, changed from r352290, 
clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/Compiler.h
clang-tools-extra/trunk/clangd/Diagnostics.cpp
clang-tools-extra/trunk/clangd/Diagnostics.h
clang-tools-extra/trunk/clangd/Headers.cpp
clang-tools-extra/trunk/clangd/Headers.h
clang-tools-extra/trunk/clangd/SourceCode.cpp
clang-tools-extra/trunk/clangd/SourceCode.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
clang-tools-extra/trunk/unittests/clangd/TestIndex.cpp
clang-tools-extra/trunk/unittests/clangd/TestIndex.h
clang-tools-extra/trunk/unittests/clangd/TestTU.cpp
clang-tools-extra/trunk/unittests/clangd/TestTU.h

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=352361&r1=352360&r2=352361&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Mon Jan 28 06:01:55 2019
@@ -40,6 +40,7 @@ add_clang_library(clangDaemon
   FuzzyMatch.cpp
   GlobalCompilationDatabase.cpp
   Headers.cpp
+  IncludeFixer.cpp
   JSONTransport.cpp
   Logger.cpp
   Protocol.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=352361&r1=352360&r2=352361&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Jan 28 06:01:55 2019
@@ -7,6 +7,7 @@
 //===---===//
 
 #include "ClangdServer.h"
+#include "ClangdUnit.h"
 #include "CodeComplete.h"
 #include "FindSymbols.h"
 #include "Headers.h"
@@ -106,6 +107,7 @@ ClangdServer::ClangdServer(const GlobalC
  ? new FileIndex(Opts.HeavyweightDynamicSymbolIndex)
  : nullptr),
   ClangTidyOptProvider(Opts.ClangTidyOptProvider),
+  SuggestMissingIncludes(Opts.SuggestMissingIncludes),
   WorkspaceRoot(Opts.WorkspaceRoot),
   PCHs(std::make_shared()),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
@@ -141,17 +143,22 @@ ClangdServer::ClangdServer(const GlobalC
 
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
WantDiagnostics WantDiags) {
-  tidy::ClangTidyOptions Options = tidy::ClangTidyOptions::getDefaults();
+  ParseOptions Opts;
+  Opts.ClangTidyOpts = tidy::ClangTidyOptions::getDefaults();
   if (ClangTidyOptProvider)
-Options = ClangTidyOptProvider->getOptions(File);
+Opts.ClangTidyOpts = ClangTidyOptProvider->getOptions(File);
+  Opts.SuggestMissingIncludes = SuggestMissingIncludes;
   // FIXME: some build systems like Bazel will take time to preparing
   // environment to build the file, it would be nice if we could emit a
   // "PreparingBuild" status to inform users, it is non-trivial given the
   // current implementation.
-  WorkScheduler.update(File, ParseInputs{getCompileCommand(File),
- FSProvider.getFileSystem(),
- Contents.str(), Options},
-   Wan

[clang-tools-extra] r352362 - [clang-tidy] Add the abseil-duration-addition check

2019-01-28 Thread Hyrum Wright via cfe-commits
Author: hwright
Date: Mon Jan 28 06:03:09 2019
New Revision: 352362

URL: http://llvm.org/viewvc/llvm-project?rev=352362&view=rev
Log:
[clang-tidy] Add the abseil-duration-addition check

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

Added:
clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp
clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-duration-addition.rst
clang-tools-extra/trunk/test/clang-tidy/abseil-duration-addition.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/time/time.h

Modified: clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp?rev=352362&r1=352361&r2=352362&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp Mon Jan 28 
06:03:09 2019
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "DurationAdditionCheck.h"
 #include "DurationComparisonCheck.h"
 #include "DurationConversionCastCheck.h"
 #include "DurationDivisionCheck.h"
@@ -30,6 +31,8 @@ namespace abseil {
 class AbseilModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"abseil-duration-addition");
 CheckFactories.registerCheck(
 "abseil-duration-comparison");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt?rev=352362&r1=352361&r2=352362&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt Mon Jan 28 
06:03:09 2019
@@ -2,6 +2,7 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangTidyAbseilModule
   AbseilTidyModule.cpp
+  DurationAdditionCheck.cpp
   DurationComparisonCheck.cpp
   DurationConversionCastCheck.cpp
   DurationDivisionCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp?rev=352362&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp Mon Jan 
28 06:03:09 2019
@@ -0,0 +1,73 @@
+//===--- DurationAdditionCheck.cpp - 
clang-tidy===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DurationAdditionCheck.h"
+#include "DurationRewriter.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace abseil {
+
+void DurationAdditionCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  binaryOperator(hasOperatorName("+"),
+ hasEitherOperand(expr(ignoringParenImpCasts(
+ callExpr(callee(functionDecl(TimeFactoryFunction())
+ .bind("function_decl")))
+ .bind("call")
+  .bind("binop"),
+  this);
+}
+
+void DurationAdditionCheck::check(const MatchFinder::MatchResult &Result) {
+  const BinaryOperator *Binop =
+  Result.Nodes.getNodeAs("binop");
+  const CallExpr *Call = Result.Nodes.getNodeAs("call");
+
+  // Don't try to replace things inside of macro definitions.
+  if (Binop->getExprLoc().isMacroID() || Binop->getExprLoc().isInvalid())
+return;
+
+  llvm::Optional Scale = getScaleForTimeInverse(
+  Result.Nodes.getNodeAs("function_decl")->getName());
+  if (!Scale)
+return;
+
+  llvm::StringRef TimeFactory = getTimeFactoryForScale(*Scale);
+
+  FixItHint Hint;
+  if (Call == Binop->getLHS()->IgnoreParenIm

[PATCH] D56903: [clangd] Suggest adding missing includes for incomplete type diagnostics.

2019-01-28 Thread Eric Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352361: [clangd] Suggest adding missing includes for 
incomplete type diagnostics. (authored by ioeric, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D56903?vs=183838&id=183839#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56903

Files:
  clang-tools-extra/trunk/clangd/CMakeLists.txt
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/clangd/ClangdUnit.h
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/Compiler.h
  clang-tools-extra/trunk/clangd/Diagnostics.cpp
  clang-tools-extra/trunk/clangd/Diagnostics.h
  clang-tools-extra/trunk/clangd/Headers.cpp
  clang-tools-extra/trunk/clangd/Headers.h
  clang-tools-extra/trunk/clangd/IncludeFixer.cpp
  clang-tools-extra/trunk/clangd/IncludeFixer.h
  clang-tools-extra/trunk/clangd/SourceCode.cpp
  clang-tools-extra/trunk/clangd/SourceCode.h
  clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
  clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
  clang-tools-extra/trunk/unittests/clangd/ClangdUnitTests.cpp
  clang-tools-extra/trunk/unittests/clangd/CodeCompleteTests.cpp
  clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp
  clang-tools-extra/trunk/unittests/clangd/FileIndexTests.cpp
  clang-tools-extra/trunk/unittests/clangd/TUSchedulerTests.cpp
  clang-tools-extra/trunk/unittests/clangd/TestIndex.cpp
  clang-tools-extra/trunk/unittests/clangd/TestIndex.h
  clang-tools-extra/trunk/unittests/clangd/TestTU.cpp
  clang-tools-extra/trunk/unittests/clangd/TestTU.h

Index: clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
===
--- clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
+++ clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
@@ -18,6 +18,7 @@
   CodeCompletionStringsTests.cpp
   ContextTests.cpp
   DexTests.cpp
+  DiagnosticsTests.cpp
   DraftStoreTests.cpp
   ExpectedTypeTest.cpp
   FileDistanceTests.cpp
Index: clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/DiagnosticsTests.cpp
@@ -0,0 +1,351 @@
+//===--- DiagnosticsTests.cpp *- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Annotations.h"
+#include "ClangdUnit.h"
+#include "SourceCode.h"
+#include "TestIndex.h"
+#include "TestTU.h"
+#include "index/MemIndex.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using testing::ElementsAre;
+using testing::Field;
+using testing::IsEmpty;
+using testing::Pair;
+using testing::UnorderedElementsAre;
+
+testing::Matcher WithFix(testing::Matcher FixMatcher) {
+  return Field(&Diag::Fixes, ElementsAre(FixMatcher));
+}
+
+testing::Matcher WithNote(testing::Matcher NoteMatcher) {
+  return Field(&Diag::Notes, ElementsAre(NoteMatcher));
+}
+
+MATCHER_P2(Diag, Range, Message,
+   "Diag at " + llvm::to_string(Range) + " = [" + Message + "]") {
+  return arg.Range == Range && arg.Message == Message;
+}
+
+MATCHER_P3(Fix, Range, Replacement, Message,
+   "Fix " + llvm::to_string(Range) + " => " +
+   testing::PrintToString(Replacement) + " = [" + Message + "]") {
+  return arg.Message == Message && arg.Edits.size() == 1 &&
+ arg.Edits[0].range == Range && arg.Edits[0].newText == Replacement;
+}
+
+MATCHER_P(EqualToLSPDiag, LSPDiag,
+  "LSP diagnostic " + llvm::to_string(LSPDiag)) {
+  return std::tie(arg.range, arg.severity, arg.message) ==
+ std::tie(LSPDiag.range, LSPDiag.severity, LSPDiag.message);
+}
+
+MATCHER_P(EqualToFix, Fix, "LSP fix " + llvm::to_string(Fix)) {
+  if (arg.Message != Fix.Message)
+return false;
+  if (arg.Edits.size() != Fix.Edits.size())
+return false;
+  for (std::size_t I = 0; I < arg.Edits.size(); ++I) {
+if (arg.Edits[I].range != Fix.Edits[I].range ||
+arg.Edits[I].newText != Fix.Edits[I].newText)
+  return false;
+  }
+  return true;
+}
+
+
+// Helper function to make tests shorter.
+Position pos(int line, int character) {
+  Position Res;
+  Res.line = line;
+  Res.character = character;
+  return Res;
+}
+
+TEST(DiagnosticsTest, DiagnosticRanges) {
+  // Check we report correct ranges, including various edge

[PATCH] D57185: [clang-tidy] Add the abseil-duration-addition check

2019-01-28 Thread Hyrum Wright via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352362: [clang-tidy] Add the abseil-duration-addition check 
(authored by hwright, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57185?vs=183583&id=183840#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57185

Files:
  clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/abseil/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp
  clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.h
  clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
  clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/abseil-duration-addition.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/test/clang-tidy/Inputs/absl/time/time.h
  clang-tools-extra/trunk/test/clang-tidy/abseil-duration-addition.cpp

Index: clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
===
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
@@ -103,6 +103,25 @@
   llvm_unreachable("unknown scaling factor");
 }
 
+/// Returns the Time factory function name for a given `Scale`.
+llvm::StringRef getTimeFactoryForScale(DurationScale scale) {
+  switch (scale) {
+  case DurationScale::Hours:
+return "absl::ToUnixHours";
+  case DurationScale::Minutes:
+return "absl::ToUnixMinutes";
+  case DurationScale::Seconds:
+return "absl::ToUnixSeconds";
+  case DurationScale::Milliseconds:
+return "absl::ToUnixMillis";
+  case DurationScale::Microseconds:
+return "absl::ToUnixMicros";
+  case DurationScale::Nanoseconds:
+return "absl::ToUnixNanos";
+  }
+  llvm_unreachable("unknown scaling factor");
+}
+
 /// Returns `true` if `Node` is a value which evaluates to a literal `0`.
 bool IsLiteralZero(const MatchFinder::MatchResult &Result, const Expr &Node) {
   auto ZeroMatcher =
@@ -197,6 +216,22 @@
   return ScaleIter->second;
 }
 
+llvm::Optional getScaleForTimeInverse(llvm::StringRef Name) {
+  static const llvm::StringMap ScaleMap(
+  {{"ToUnixHours", DurationScale::Hours},
+   {"ToUnixMinutes", DurationScale::Minutes},
+   {"ToUnixSeconds", DurationScale::Seconds},
+   {"ToUnixMillis", DurationScale::Milliseconds},
+   {"ToUnixMicros", DurationScale::Microseconds},
+   {"ToUnixNanos", DurationScale::Nanoseconds}});
+
+  auto ScaleIter = ScaleMap.find(std::string(Name));
+  if (ScaleIter == ScaleMap.end())
+return llvm::None;
+
+  return ScaleIter->second;
+}
+
 std::string rewriteExprFromNumberToDuration(
 const ast_matchers::MatchFinder::MatchResult &Result, DurationScale Scale,
 const Expr *Node) {
Index: clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/abseil/AbseilTidyModule.cpp
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "DurationAdditionCheck.h"
 #include "DurationComparisonCheck.h"
 #include "DurationConversionCastCheck.h"
 #include "DurationDivisionCheck.h"
@@ -30,6 +31,8 @@
 class AbseilModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"abseil-duration-addition");
 CheckFactories.registerCheck(
 "abseil-duration-comparison");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp
@@ -0,0 +1,73 @@
+//===--- DurationAdditionCheck.cpp - clang-tidy===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DurationAdditionCheck.h"
+#include "DurationRewriter.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/FixIt.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace abseil {
+
+void DurationAdditionCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMat

[clang-tools-extra] r352364 - [clang-tidy] Fix a build error.

2019-01-28 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Jan 28 06:07:45 2019
New Revision: 352364

URL: http://llvm.org/viewvc/llvm-project?rev=352364&view=rev
Log:
[clang-tidy] Fix a build error.

Modified:
clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp?rev=352364&r1=352363&r2=352364&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp Mon Jan 
28 06:07:45 2019
@@ -54,7 +54,7 @@ void DurationAdditionCheck::check(const
  rewriteExprFromNumberToDuration(Result, *Scale, Binop->getRHS()) + 
")")
 .str());
   } else {
-assert(Call == Binop->getRHS()->IgnoreParenImpCast() &&
+assert(Call == Binop->getRHS()->IgnoreParenImpCasts() &&
"Call should be found on the RHS");
 Hint = FixItHint::CreateReplacement(
 Binop->getSourceRange(),


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


Re: r352221 - Disable _Float16 for non ARM/SPIR Targets

2019-01-28 Thread Hans Wennborg via cfe-commits
Merged together with r35 to 8.0 in r352363.

On Fri, Jan 25, 2019 at 9:27 AM Erich Keane via cfe-commits
 wrote:
>
> Author: erichkeane
> Date: Fri Jan 25 09:27:57 2019
> New Revision: 352221
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352221&view=rev
> Log:
> Disable _Float16 for non ARM/SPIR Targets
>
> As Discussed here:
> http://lists.llvm.org/pipermail/llvm-dev/2019-January/129543.html
>
> There are problems exposing the _Float16 type on architectures that
> haven't defined the ABI/ISel for the type yet, so we're temporarily
> disabling the type and making it opt-in.
>
> Differential Revision: https://reviews.llvm.org/D57188
>
> Change-Id: I5db7366dedf1deb9485adb8948b1deb7e612a736
>
> Added:
> cfe/trunk/test/Sema/Float16.c   (with props)
> Modified:
> cfe/trunk/docs/LanguageExtensions.rst
> cfe/trunk/include/clang/Basic/TargetInfo.h
> cfe/trunk/lib/Basic/TargetInfo.cpp
> cfe/trunk/lib/Basic/Targets/AArch64.cpp
> cfe/trunk/lib/Basic/Targets/ARM.cpp
> cfe/trunk/lib/Basic/Targets/SPIR.h
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/test/AST/float16.cpp
> cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
> cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
> cfe/trunk/test/Lexer/half-literal.cpp
>
> Modified: cfe/trunk/docs/LanguageExtensions.rst
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=352221&r1=352220&r2=352221&view=diff
> ==
> --- cfe/trunk/docs/LanguageExtensions.rst (original)
> +++ cfe/trunk/docs/LanguageExtensions.rst Fri Jan 25 09:27:57 2019
> @@ -474,44 +474,58 @@ Half-Precision Floating Point
>  =
>
>  Clang supports two half-precision (16-bit) floating point types: ``__fp16`` 
> and
> -``_Float16``. ``__fp16`` is defined in the ARM C Language Extensions (`ACLE
> -`_)
> -and ``_Float16`` in ISO/IEC TS 18661-3:2015.
> -
> -``__fp16`` is a storage and interchange format only. This means that values 
> of
> -``__fp16`` promote to (at least) float when used in arithmetic operations.
> -There are two ``__fp16`` formats. Clang supports the IEEE 754-2008 format and
> -not the ARM alternative format.
> -
> -ISO/IEC TS 18661-3:2015 defines C support for additional floating point 
> types.
> -``_FloatN`` is defined as a binary floating type, where the N suffix denotes
> -the number of bits and is 16, 32, 64, or greater and equal to 128 and a
> -multiple of 32. Clang supports ``_Float16``. The difference from ``__fp16`` 
> is
> -that arithmetic on ``_Float16`` is performed in half-precision, thus it is 
> not
> -a storage-only format. ``_Float16`` is available as a source language type in
> -both C and C++ mode.
> -
> -It is recommended that portable code use the ``_Float16`` type because
> -``__fp16`` is an ARM C-Language Extension (ACLE), whereas ``_Float16`` is
> -defined by the C standards committee, so using ``_Float16`` will not prevent
> -code from being ported to architectures other than Arm.  Also, ``_Float16``
> -arithmetic and operations will directly map on half-precision instructions 
> when
> -they are available (e.g. Armv8.2-A), avoiding conversions to/from
> -single-precision, and thus will result in more performant code. If
> -half-precision instructions are unavailable, values will be promoted to
> -single-precision, similar to the semantics of ``__fp16`` except that the
> -results will be stored in single-precision.
> -
> -In an arithmetic operation where one operand is of ``__fp16`` type and the
> -other is of ``_Float16`` type, the ``_Float16`` type is first converted to
> -``__fp16`` type and then the operation is completed as if both operands were 
> of
> -``__fp16`` type.
> -
> -To define a ``_Float16`` literal, suffix ``f16`` can be appended to the 
> compile-time
> -constant declaration. There is no default argument promotion for 
> ``_Float16``; this
> -applies to the standard floating types only. As a consequence, for example, 
> an
> -explicit cast is required for printing a ``_Float16`` value (there is no 
> string
> -format specifier for ``_Float16``).
> +``_Float16``.  These types are supported in all language modes.
> +
> +``__fp16`` is supported on every target, as it is purely a storage format; 
> see below.
> +``_Float16`` is currently only supported on the following targets, with 
> further
> +targets pending ABI standardization:
> +- 32-bit ARM
> +- 64-bit ARM (AArch64)
> +- SPIR
> +``_Float16`` will be supported on more targets as they define ABIs for it.
> +
> +``__fp16`` is a storage and interchange format only.  This means that values 
> of
> +``__fp16`` are immediately promoted to (at least) ``float`` when used in 
> arithmetic
> +operations, so that e.g. the result of adding two ``__fp16`` values has type 
> ``float``.
> +The behavior of ``__fp16`` is specified by the ARM C Language Extens

Re: r352229 - Remove F16 literal support based on Float16 support.

2019-01-28 Thread Hans Wennborg via cfe-commits
Merged to 8.0 in r352365.

On Fri, Jan 25, 2019 at 10:36 AM Erich Keane via cfe-commits
 wrote:
>
> Author: erichkeane
> Date: Fri Jan 25 10:36:20 2019
> New Revision: 352229
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352229&view=rev
> Log:
> Remove F16 literal support based on Float16 support.
>
> Float16 support was disabled recently on many platforms, however that
> commit still allowed literals of Float16 type to work.  This commit
> removes those based on the same logic as Float16 disable.
>
> Change-Id: I72243048ae2db3dc47bd3d699843e3edf9c395ea
>
> Added:
> cfe/trunk/test/SemaCXX/Float16.cpp   (with props)
> Modified:
> cfe/trunk/lib/Lex/LiteralSupport.cpp
>
> Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=352229&r1=352228&r2=352229&view=diff
> ==
> --- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
> +++ cfe/trunk/lib/Lex/LiteralSupport.cpp Fri Jan 25 10:36:20 2019
> @@ -616,10 +616,11 @@ NumericLiteralParser::NumericLiteralPars
>if (isHalf || isFloat || isLong || isFloat128)
>  break; // HF, FF, LF, QF invalid.
>
> -  if (s + 2 < ThisTokEnd && s[1] == '1' && s[2] == '6') {
> -  s += 2; // success, eat up 2 characters.
> -  isFloat16 = true;
> -  continue;
> +  if (PP.getTargetInfo().hasFloat16Type() && s + 2 < ThisTokEnd &&
> +  s[1] == '1' && s[2] == '6') {
> +s += 2; // success, eat up 2 characters.
> +isFloat16 = true;
> +continue;
>}
>
>isFloat = true;
>
> Added: cfe/trunk/test/SemaCXX/Float16.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/Float16.cpp?rev=352229&view=auto
> ==
> --- cfe/trunk/test/SemaCXX/Float16.cpp (added)
> +++ cfe/trunk/test/SemaCXX/Float16.cpp Fri Jan 25 10:36:20 2019
> @@ -0,0 +1,18 @@
> +// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s
> +// RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s 
> -DHAVE
> +// RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s -DHAVE
> +// RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE
> +
> +#ifdef HAVE
> +// expected-no-diagnostics
> +#endif // HAVE
> +
> +#ifndef HAVE
> +// expected-error@+2{{_Float16 is not supported on this target}}
> +#endif // !HAVE
> +_Float16 f;
> +
> +#ifndef HAVE
> +// expected-error@+2{{invalid suffix 'F16' on floating constant}}
> +#endif // !HAVE
> +const auto g = 1.1F16;
>
> Propchange: cfe/trunk/test/SemaCXX/Float16.cpp
> --
> svn:eol-style = native
>
> Propchange: cfe/trunk/test/SemaCXX/Float16.cpp
> --
> svn:keywords = "Author Date Id Rev URL"
>
> Propchange: cfe/trunk/test/SemaCXX/Float16.cpp
> --
> svn:mime-type = text/plain
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r352367 - [clangd] Index main-file macros (bug 39761)

2019-01-28 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Jan 28 06:11:49 2019
New Revision: 352367

URL: http://llvm.org/viewvc/llvm-project?rev=352367&view=rev
Log:
[clangd] Index main-file macros (bug 39761)

Patch by Nathan Ridge!

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

Modified:
clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp
clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.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=352367&r1=352366&r2=352367&view=diff
==
--- clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/SymbolCollector.cpp Mon Jan 28 
06:11:49 2019
@@ -379,13 +379,21 @@ bool SymbolCollector::handleMacroOccuren
 
   const auto &SM = PP->getSourceManager();
   auto DefLoc = MI->getDefinitionLoc();
-  if (SM.isInMainFile(SM.getExpansionLoc(DefLoc)))
-return true;
+
   // Header guards are not interesting in index. Builtin macros don't have
   // useful locations and are not needed for code completions.
   if (MI->isUsedForHeaderGuard() || MI->isBuiltinMacro())
 return true;
 
+  // Skip main-file symbols if we are not collecting them.
+  bool IsMainFileSymbol = SM.isInMainFile(SM.getExpansionLoc(DefLoc));
+  if (IsMainFileSymbol && !Opts.CollectMainFileSymbols)
+return false;
+
+  // Also avoid storing predefined macros like __DBL_MIN__.
+  if (SM.isWrittenInBuiltinFile(DefLoc))
+return true;
+
   // Mark the macro as referenced if this is a reference coming from the main
   // file. The macro may not be an interesting symbol, but it's cheaper to 
check
   // at the end.
@@ -410,7 +418,10 @@ bool SymbolCollector::handleMacroOccuren
   Symbol S;
   S.ID = std::move(*ID);
   S.Name = Name->getName();
-  S.Flags |= Symbol::IndexedForCodeCompletion;
+  if (!IsMainFileSymbol) {
+S.Flags |= Symbol::IndexedForCodeCompletion;
+S.Flags |= Symbol::VisibleOutsideFile;
+  }
   S.SymInfo = index::getSymbolInfoForMacro(*MI);
   std::string FileURI;
   // FIXME: use the result to filter out symbols.

Modified: clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp?rev=352367&r1=352366&r2=352367&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/FindSymbolsTests.cpp Mon Jan 28 
06:11:49 2019
@@ -87,13 +87,16 @@ protected:
 
 } // namespace
 
-TEST_F(WorkspaceSymbolsTest, NoMacro) {
+TEST_F(WorkspaceSymbolsTest, Macros) {
   addFile("foo.cpp", R"cpp(
-  #define MACRO X
-  )cpp");
+   #define MACRO X
+   )cpp");
 
-  // Macros are not in the index.
-  EXPECT_THAT(getSymbols("macro"), IsEmpty());
+  // LSP's SymbolKind doesn't have a "Macro" kind, and
+  // indexSymbolKindToSymbolKind() currently maps macros
+  // to SymbolKind::String.
+  EXPECT_THAT(getSymbols("macro"),
+  ElementsAre(AllOf(QName("MACRO"), 
WithKind(SymbolKind::String;
 }
 
 TEST_F(WorkspaceSymbolsTest, NoLocals) {

Modified: clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp?rev=352367&r1=352366&r2=352367&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/SymbolCollectorTests.cpp Mon Jan 
28 06:11:49 2019
@@ -1069,21 +1069,27 @@ TEST_F(SymbolCollectorTest, CollectMacro
 
 MAC(p);
   )");
-  const std::string Main = R"(
-#define MAIN 1  // not indexed
-USED(t);
-  )";
+
+  Annotations Main(R"(
+#define $main[[MAIN]] 1
+ USED(t);
+  )");
   CollectorOpts.CountReferences = true;
   CollectorOpts.CollectMacro = true;
-  runSymbolCollector(Header.code(), Main);
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("p"), QName("t"),
-   AllOf(QName("X"), DeclURI(TestHeaderURI),
- IncludeHeader(TestHeaderURI)),
-   AllOf(Labeled("MAC(x)"), RefCount(0),
- DeclRange(Header.range("mac"))),
-   AllOf(Labeled("USED(y)"), RefCount(1),
- DeclRange(Header.range("used");
+  runSymbolCollector(Header.code(), Main.code());
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAre(
+  QName("p"), QName("t"),
+  AllOf(QName("X"), DeclURI(TestHeaderURI),
+  

[PATCH] D55739: [Clangd] Index main-file macros (bug 39761)

2019-01-28 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE352367: [clangd] Index main-file macros (bug 39761) 
(authored by hokein, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55739?vs=183320&id=183843#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55739

Files:
  clangd/index/SymbolCollector.cpp
  unittests/clangd/FindSymbolsTests.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -379,13 +379,21 @@
 
   const auto &SM = PP->getSourceManager();
   auto DefLoc = MI->getDefinitionLoc();
-  if (SM.isInMainFile(SM.getExpansionLoc(DefLoc)))
-return true;
+
   // Header guards are not interesting in index. Builtin macros don't have
   // useful locations and are not needed for code completions.
   if (MI->isUsedForHeaderGuard() || MI->isBuiltinMacro())
 return true;
 
+  // Skip main-file symbols if we are not collecting them.
+  bool IsMainFileSymbol = SM.isInMainFile(SM.getExpansionLoc(DefLoc));
+  if (IsMainFileSymbol && !Opts.CollectMainFileSymbols)
+return false;
+
+  // Also avoid storing predefined macros like __DBL_MIN__.
+  if (SM.isWrittenInBuiltinFile(DefLoc))
+return true;
+
   // Mark the macro as referenced if this is a reference coming from the main
   // file. The macro may not be an interesting symbol, but it's cheaper to check
   // at the end.
@@ -410,7 +418,10 @@
   Symbol S;
   S.ID = std::move(*ID);
   S.Name = Name->getName();
-  S.Flags |= Symbol::IndexedForCodeCompletion;
+  if (!IsMainFileSymbol) {
+S.Flags |= Symbol::IndexedForCodeCompletion;
+S.Flags |= Symbol::VisibleOutsideFile;
+  }
   S.SymInfo = index::getSymbolInfoForMacro(*MI);
   std::string FileURI;
   // FIXME: use the result to filter out symbols.
Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -1069,21 +1069,27 @@
 
 MAC(p);
   )");
-  const std::string Main = R"(
-#define MAIN 1  // not indexed
-USED(t);
-  )";
+
+  Annotations Main(R"(
+#define $main[[MAIN]] 1
+ USED(t);
+  )");
   CollectorOpts.CountReferences = true;
   CollectorOpts.CollectMacro = true;
-  runSymbolCollector(Header.code(), Main);
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("p"), QName("t"),
-   AllOf(QName("X"), DeclURI(TestHeaderURI),
- IncludeHeader(TestHeaderURI)),
-   AllOf(Labeled("MAC(x)"), RefCount(0),
- DeclRange(Header.range("mac"))),
-   AllOf(Labeled("USED(y)"), RefCount(1),
- DeclRange(Header.range("used");
+  runSymbolCollector(Header.code(), Main.code());
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAre(
+  QName("p"), QName("t"),
+  AllOf(QName("X"), DeclURI(TestHeaderURI),
+IncludeHeader(TestHeaderURI)),
+  AllOf(Labeled("MAC(x)"), RefCount(0),
+
+DeclRange(Header.range("mac")), VisibleOutsideFile()),
+  AllOf(Labeled("USED(y)"), RefCount(1),
+DeclRange(Header.range("used")), VisibleOutsideFile()),
+  AllOf(Labeled("MAIN"), RefCount(0), DeclRange(Main.range("main")),
+Not(VisibleOutsideFile();
 }
 
 TEST_F(SymbolCollectorTest, DeprecatedSymbols) {
Index: unittests/clangd/FindSymbolsTests.cpp
===
--- unittests/clangd/FindSymbolsTests.cpp
+++ unittests/clangd/FindSymbolsTests.cpp
@@ -87,13 +87,16 @@
 
 } // namespace
 
-TEST_F(WorkspaceSymbolsTest, NoMacro) {
+TEST_F(WorkspaceSymbolsTest, Macros) {
   addFile("foo.cpp", R"cpp(
-  #define MACRO X
-  )cpp");
+   #define MACRO X
+   )cpp");
 
-  // Macros are not in the index.
-  EXPECT_THAT(getSymbols("macro"), IsEmpty());
+  // LSP's SymbolKind doesn't have a "Macro" kind, and
+  // indexSymbolKindToSymbolKind() currently maps macros
+  // to SymbolKind::String.
+  EXPECT_THAT(getSymbols("macro"),
+  ElementsAre(AllOf(QName("MACRO"), WithKind(SymbolKind::String;
 }
 
 TEST_F(WorkspaceSymbolsTest, NoLocals) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46871: [AMDGPU] Add interpolation builtins

2019-01-28 Thread Tim Corringham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352358: [AMDGPU] Add interpolation builtins (authored by 
timcorringham, committed by ).
Herald added a subscriber: jvesely.

Changed prior to commit:
  https://reviews.llvm.org/D46871?vs=147460&id=183837#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D46871

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  test/CodeGenOpenCL/builtins-amdgcn-interp.cl


Index: test/CodeGenOpenCL/builtins-amdgcn-interp.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn-interp.cl
+++ test/CodeGenOpenCL/builtins-amdgcn-interp.cl
@@ -0,0 +1,34 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx900 -S 
-emit-llvm -o - %s | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+// CHECK-LABEL: test_interp_f16
+// CHECK: call float @llvm.amdgcn.interp.p1.f16
+// CHECK: call half @llvm.amdgcn.interp.p2.f16
+// CHECK: call float @llvm.amdgcn.interp.p1.f16
+// CHECK: call half @llvm.amdgcn.interp.p2.f16
+void test_interp_f16(global half* out, float i, float j, int m0)
+{
+  float p1_0 = __builtin_amdgcn_interp_p1_f16(i, 2, 3, false, m0);
+  half p2_0 = __builtin_amdgcn_interp_p2_f16(p1_0, j, 2, 3, false, m0);
+  float p1_1 = __builtin_amdgcn_interp_p1_f16(i, 2, 3, true, m0);
+  half p2_1 = __builtin_amdgcn_interp_p2_f16(p1_1, j, 2, 3, true, m0);
+  *out = p2_0 + p2_1;
+}
+
+// CHECK-LABEL: test_interp_f32
+// CHECK: call float @llvm.amdgcn.interp.p1
+// CHECK: call float @llvm.amdgcn.interp.p2
+void test_interp_f32(global float* out, float i, float j, int m0)
+{
+  float p1 = __builtin_amdgcn_interp_p1(i, 1, 4, m0);
+  *out = __builtin_amdgcn_interp_p2(p1, j, 1, 4, m0);
+}
+
+// CHECK-LABEL: test_interp_mov
+// CHECK: call float @llvm.amdgcn.interp.mov
+void test_interp_mov(global float* out, float i, float j, int m0)
+{
+  *out = __builtin_amdgcn_interp_mov(2, 3, 4, m0);
+}
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -106,6 +106,15 @@
 TARGET_BUILTIN(__builtin_amdgcn_buffer_wbinvl1_vol, "v", "n", "ci-insts")
 
 
//===--===//
+// Interpolation builtins.
+//===--===//
+BUILTIN(__builtin_amdgcn_interp_p1_f16, "ffUiUibUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p2_f16, "hffUiUibUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p1, "ffUiUiUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p2, "fffUiUiUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_mov, "fUiUiUiUi", "nc")
+
+//===--===//
 // VI+ only builtins.
 
//===--===//
 


Index: test/CodeGenOpenCL/builtins-amdgcn-interp.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn-interp.cl
+++ test/CodeGenOpenCL/builtins-amdgcn-interp.cl
@@ -0,0 +1,34 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx900 -S -emit-llvm -o - %s | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+// CHECK-LABEL: test_interp_f16
+// CHECK: call float @llvm.amdgcn.interp.p1.f16
+// CHECK: call half @llvm.amdgcn.interp.p2.f16
+// CHECK: call float @llvm.amdgcn.interp.p1.f16
+// CHECK: call half @llvm.amdgcn.interp.p2.f16
+void test_interp_f16(global half* out, float i, float j, int m0)
+{
+  float p1_0 = __builtin_amdgcn_interp_p1_f16(i, 2, 3, false, m0);
+  half p2_0 = __builtin_amdgcn_interp_p2_f16(p1_0, j, 2, 3, false, m0);
+  float p1_1 = __builtin_amdgcn_interp_p1_f16(i, 2, 3, true, m0);
+  half p2_1 = __builtin_amdgcn_interp_p2_f16(p1_1, j, 2, 3, true, m0);
+  *out = p2_0 + p2_1;
+}
+
+// CHECK-LABEL: test_interp_f32
+// CHECK: call float @llvm.amdgcn.interp.p1
+// CHECK: call float @llvm.amdgcn.interp.p2
+void test_interp_f32(global float* out, float i, float j, int m0)
+{
+  float p1 = __builtin_amdgcn_interp_p1(i, 1, 4, m0);
+  *out = __builtin_amdgcn_interp_p2(p1, j, 1, 4, m0);
+}
+
+// CHECK-LABEL: test_interp_mov
+// CHECK: call float @llvm.amdgcn.interp.mov
+void test_interp_mov(global float* out, float i, float j, int m0)
+{
+  *out = __builtin_amdgcn_interp_mov(2, 3, 4, m0);
+}
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -106,6 +106,15 @@
 TARGET_BUILTIN(__builtin_amdgcn_buffer_wbinvl1_vol, "v", "n", "ci-insts")
 
 //===--===//
+// Interpolation builtin

r352358 - [AMDGPU] Add interpolation builtins

2019-01-28 Thread Tim Corringham via cfe-commits
Author: timcorringham
Date: Mon Jan 28 05:50:37 2019
New Revision: 352358

URL: http://llvm.org/viewvc/llvm-project?rev=352358&view=rev
Log:
[AMDGPU] Add interpolation builtins

Summary:
Added builtins for the interpolation intrinsics, and related LIT
test.

Reviewers: arsenm, tpr, dstuttard, #amdgpu

Reviewed By: arsenm, #amdgpu

Subscribers: kzhuravl, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, 
cfe-commits

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

Added:
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-interp.cl
Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=352358&r1=352357&r2=352358&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Mon Jan 28 05:50:37 2019
@@ -106,6 +106,15 @@ TARGET_BUILTIN(__builtin_amdgcn_s_dcache
 TARGET_BUILTIN(__builtin_amdgcn_buffer_wbinvl1_vol, "v", "n", "ci-insts")
 
 
//===--===//
+// Interpolation builtins.
+//===--===//
+BUILTIN(__builtin_amdgcn_interp_p1_f16, "ffUiUibUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p2_f16, "hffUiUibUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p1, "ffUiUiUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_p2, "fffUiUiUi", "nc")
+BUILTIN(__builtin_amdgcn_interp_mov, "fUiUiUiUi", "nc")
+
+//===--===//
 // VI+ only builtins.
 
//===--===//
 

Added: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-interp.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-interp.cl?rev=352358&view=auto
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-interp.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-interp.cl Mon Jan 28 05:50:37 
2019
@@ -0,0 +1,34 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx900 -S 
-emit-llvm -o - %s | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+
+// CHECK-LABEL: test_interp_f16
+// CHECK: call float @llvm.amdgcn.interp.p1.f16
+// CHECK: call half @llvm.amdgcn.interp.p2.f16
+// CHECK: call float @llvm.amdgcn.interp.p1.f16
+// CHECK: call half @llvm.amdgcn.interp.p2.f16
+void test_interp_f16(global half* out, float i, float j, int m0)
+{
+  float p1_0 = __builtin_amdgcn_interp_p1_f16(i, 2, 3, false, m0);
+  half p2_0 = __builtin_amdgcn_interp_p2_f16(p1_0, j, 2, 3, false, m0);
+  float p1_1 = __builtin_amdgcn_interp_p1_f16(i, 2, 3, true, m0);
+  half p2_1 = __builtin_amdgcn_interp_p2_f16(p1_1, j, 2, 3, true, m0);
+  *out = p2_0 + p2_1;
+}
+
+// CHECK-LABEL: test_interp_f32
+// CHECK: call float @llvm.amdgcn.interp.p1
+// CHECK: call float @llvm.amdgcn.interp.p2
+void test_interp_f32(global float* out, float i, float j, int m0)
+{
+  float p1 = __builtin_amdgcn_interp_p1(i, 1, 4, m0);
+  *out = __builtin_amdgcn_interp_p2(p1, j, 1, 4, m0);
+}
+
+// CHECK-LABEL: test_interp_mov
+// CHECK: call float @llvm.amdgcn.interp.mov
+void test_interp_mov(global float* out, float i, float j, int m0)
+{
+  *out = __builtin_amdgcn_interp_mov(2, 3, 4, m0);
+}


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


Re: [clang-tools-extra] r352231 - [clang-tidy] fix unit tests for dropped _Float16 support in X86

2019-01-28 Thread Hans Wennborg via cfe-commits
Merged to 8.0 in r352368.

On Fri, Jan 25, 2019 at 11:05 AM Jonas Toth via cfe-commits
 wrote:
>
> Author: jonastoth
> Date: Fri Jan 25 11:05:12 2019
> New Revision: 352231
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352231&view=rev
> Log:
> [clang-tidy] fix unit tests for dropped _Float16 support in X86
>
> Summary:
> Because _Float16 was disabled for X86 targets the unit-tests started failing.
> Extract the pieces for _Float16 and run theses tests under AArch64.
>
> Reviewers: aaron.ballman, erichkeane, lebedev.ri
>
> Reviewed By: erichkeane
>
> Subscribers: javed.absar, xazax.hun, kristof.beyls, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D57249
>
> Added:
> 
> clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-float16.cpp
> Modified:
> 
> clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
> 
> clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp
>
> Added: 
> clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-float16.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-float16.cpp?rev=352231&view=auto
> ==
> --- 
> clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-float16.cpp
>  (added)
> +++ 
> clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-float16.cpp
>  Fri Jan 25 11:05:12 2019
> @@ -0,0 +1,51 @@
> +// RUN: %check_clang_tidy %s readability-uppercase-literal-suffix %t -- -- 
> -target aarch64-linux-gnu -I %S
> +
> +#include "readability-uppercase-literal-suffix.h"
> +
> +void float16_normal_literals() {
> +  // _Float16
> +
> +  static constexpr auto v14 = 1.f16;
> +  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has 
> suffix 'f16', which is not uppercase
> +  // CHECK-MESSAGES-NEXT: static constexpr auto v14 = 1.f16;
> +  // CHECK-MESSAGES-NEXT: ^ ~
> +  // CHECK-MESSAGES-NEXT: {{^ *}}F16{{$}}
> +  // CHECK-FIXES: static constexpr auto v14 = 1.F16;
> +  static_assert(is_same::value, "");
> +  static_assert(v14 == 1.F16, "");
> +
> +  static constexpr auto v15 = 1.e0f16;
> +  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has 
> suffix 'f16', which is not uppercase
> +  // CHECK-MESSAGES-NEXT: static constexpr auto v15 = 1.e0f16;
> +  // CHECK-MESSAGES-NEXT: ^ ~
> +  // CHECK-MESSAGES-NEXT: {{^ *}}F16{{$}}
> +  // CHECK-FIXES: static constexpr auto v15 = 1.e0F16;
> +  static_assert(is_same::value, "");
> +  static_assert(v15 == 1.F16, "");
> +
> +  static constexpr auto v16 = 1.F16; // OK.
> +  static_assert(is_same::value, "");
> +  static_assert(v16 == 1.F16, "");
> +
> +  static constexpr auto v17 = 1.e0F16; // OK.
> +  static_assert(is_same::value, "");
> +  static_assert(v17 == 1.F16, "");
> +}
> +
> +void float16_hexadecimal_literals() {
> +// _Float16
> +
> +  static constexpr auto v13 = 0xfp0f16;
> +  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: floating point literal has 
> suffix 'f16', which is not uppercase
> +  // CHECK-MESSAGES-NEXT: static constexpr auto v13 = 0xfp0f16;
> +  // CHECK-MESSAGES-NEXT: ^~
> +  // CHECK-MESSAGES-NEXT: {{^ *}}F16{{$}}
> +  // CHECK-FIXES: static constexpr auto v13 = 0xfp0F16;
> +  static_assert(is_same::value, "");
> +  static_assert(v13 == 0xfp0F16, "");
> +
> +  static constexpr auto v14 = 0xfp0F16; // OK.
> +  static_assert(is_same::value, "");
> +  static_assert(v14 == 0xfp0F16, "");
> +
> +}
>
> Modified: 
> clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp?rev=352231&r1=352230&r2=352231&view=diff
> ==
> --- 
> clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
>  (original)
> +++ 
> clang-tools-extra/trunk/test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
>  Fri Jan 25 11:05:12 2019
> @@ -3,8 +3,6 @@
>  // RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
> -fix -- -target x86_64-pc-linux-gnu -I %S
>  // RUN: clang-tidy %t.cpp -checks='-*,readability-uppercase-literal-suffix' 
> -warnings-as-errors='-*,readability-uppercase-literal-suffix' -- -target 
> x86_64-pc-linux-gnu -I %S
>
> -// REQUIRES: disabled
> -
>  #include "readability-uppercase-literal-suffix.h"
>
>  void floating_point_suffix() {
> @@ -99,34 +97,6 @@ void floating_point_suffix() {
>static constexpr auto v13 = 1.e0Q; // OK.
>static_assert(is_same::value, "");
>static_assert(v13 == 1., "");
> -
> -  // _Float16
> -
> -  static constexpr auto v14 = 1.f16;
> -  // CHECK-MESSAGES: :[[@LINE-1]]:3

r352369 - [AST] Introduce GenericSelectionExpr::Association

2019-01-28 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Mon Jan 28 06:18:11 2019
New Revision: 352369

URL: http://llvm.org/viewvc/llvm-project?rev=352369&view=rev
Log:
[AST] Introduce GenericSelectionExpr::Association

Introduce a new class GenericSelectionExpr::Association which bundle together
an association expression and its TypeSourceInfo.

An iterator GenericSelectionExpr::AssociationIterator is additionally added to
make it possible to iterate over ranges of Associations. This iterator is a
kind of proxy iterator which abstract over how exactly the expressions and the
TypeSourceInfos are stored.

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

Reviewed By: aaron.ballman

Reviewers: aaron.ballman, steveire, dblaikie, mclow.lists


Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/StmtDataCollectors.td
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaPseudoObject.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=352369&r1=352368&r2=352369&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon Jan 28 06:18:11 2019
@@ -28,6 +28,8 @@
 #include "clang/Basic/TypeTraits.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/iterator.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/AtomicOrdering.h"
@@ -5052,6 +5054,86 @@ class GenericSelectionExpr final
 return getNumAssocs();
   }
 
+  template  class AssociationIteratorTy;
+  /// Bundle together an association expression and its TypeSourceInfo.
+  /// The Const template parameter is for the const and non-const versions
+  /// of AssociationTy.
+  template  class AssociationTy {
+friend class GenericSelectionExpr;
+template  friend class AssociationIteratorTy;
+using ExprPtrTy =
+typename std::conditional::type;
+using TSIPtrTy = typename std::conditional::type;
+ExprPtrTy E;
+TSIPtrTy TSI;
+bool Selected;
+AssociationTy(ExprPtrTy E, TSIPtrTy TSI, bool Selected)
+: E(E), TSI(TSI), Selected(Selected) {}
+
+  public:
+ExprPtrTy getAssociationExpr() const { return E; }
+TSIPtrTy getTypeSourceInfo() const { return TSI; }
+QualType getType() const { return TSI ? TSI->getType() : QualType(); }
+bool isSelected() const { return Selected; }
+AssociationTy *operator->() { return this; }
+const AssociationTy *operator->() const { return this; }
+  }; // class AssociationTy
+
+  /// Iterator over const and non-const Association objects. The Association
+  /// objects are created on the fly when the iterator is dereferenced.
+  /// This abstract over how exactly the association expressions and the
+  /// corresponding TypeSourceInfo * are stored.
+  template 
+  class AssociationIteratorTy
+  : public llvm::iterator_facade_base<
+AssociationIteratorTy, std::input_iterator_tag,
+AssociationTy, std::ptrdiff_t, AssociationTy,
+AssociationTy> {
+friend class GenericSelectionExpr;
+// FIXME: This iterator could conceptually be a random access iterator, and
+// it would be nice if we could strengthen the iterator category someday.
+// However this iterator does not satisfy two requirements of forward
+// iterators:
+// a) reference = T& or reference = const T&
+// b) If It1 and It2 are both dereferenceable, then It1 == It2 if and only
+//if *It1 and *It2 are bound to the same objects.
+// An alternative design approach was discussed during review;
+// store an Association object inside the iterator, and return a reference
+// to it when dereferenced. This idea was discarded beacuse of nasty
+// lifetime issues:
+//AssociationIterator It = ...;
+//const Association &Assoc = *It++; // Oops, Assoc is dangling.
+using BaseTy = typename AssociationIteratorTy::iterator_facade_base;
+using StmtPtrPtrTy =
+typename std::conditional::type;
+using TSIPtrPtrTy =
+typename std::conditional::type;
+StmtPtrPtrTy E = nullptr;
+TSIPtrPtrTy TSI = nullptr; // Kept in sync with E.
+unsigned Offset = 0, SelectedOffset = 0;
+AssociationIteratorTy(StmtPtrPtrTy E, TSIPtrPtrTy TSI, unsigned Offset,
+  unsigned SelectedOffset)
+: E(E), TSI(TSI), Offset(Offset), SelectedOffset(SelectedOffset) {}
+
+  public:
+AssociationIteratorTy() = default;
+typename BaseTy::reference operator*() const {
+  return AssociationTy(cast(*E), *TSI,
+  Offset == SelectedOffset);

[PATCH] D57106: [AST] Introduce GenericSelectionExpr::Association

2019-01-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352369: [AST] Introduce GenericSelectionExpr::Association 
(authored by brunoricci, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57106?vs=183755&id=183844#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57106

Files:
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
  cfe/trunk/include/clang/AST/StmtDataCollectors.td
  cfe/trunk/lib/AST/ASTDumper.cpp
  cfe/trunk/lib/AST/StmtPrinter.cpp
  cfe/trunk/lib/AST/StmtProfile.cpp
  cfe/trunk/lib/Sema/SemaExprObjC.cpp
  cfe/trunk/lib/Sema/SemaPseudoObject.cpp
  cfe/trunk/lib/Sema/TreeTransform.h

Index: cfe/trunk/include/clang/AST/Expr.h
===
--- cfe/trunk/include/clang/AST/Expr.h
+++ cfe/trunk/include/clang/AST/Expr.h
@@ -28,6 +28,8 @@
 #include "clang/Basic/TypeTraits.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APSInt.h"
+#include "llvm/ADT/iterator.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/AtomicOrdering.h"
@@ -5052,6 +5054,86 @@
 return getNumAssocs();
   }
 
+  template  class AssociationIteratorTy;
+  /// Bundle together an association expression and its TypeSourceInfo.
+  /// The Const template parameter is for the const and non-const versions
+  /// of AssociationTy.
+  template  class AssociationTy {
+friend class GenericSelectionExpr;
+template  friend class AssociationIteratorTy;
+using ExprPtrTy =
+typename std::conditional::type;
+using TSIPtrTy = typename std::conditional::type;
+ExprPtrTy E;
+TSIPtrTy TSI;
+bool Selected;
+AssociationTy(ExprPtrTy E, TSIPtrTy TSI, bool Selected)
+: E(E), TSI(TSI), Selected(Selected) {}
+
+  public:
+ExprPtrTy getAssociationExpr() const { return E; }
+TSIPtrTy getTypeSourceInfo() const { return TSI; }
+QualType getType() const { return TSI ? TSI->getType() : QualType(); }
+bool isSelected() const { return Selected; }
+AssociationTy *operator->() { return this; }
+const AssociationTy *operator->() const { return this; }
+  }; // class AssociationTy
+
+  /// Iterator over const and non-const Association objects. The Association
+  /// objects are created on the fly when the iterator is dereferenced.
+  /// This abstract over how exactly the association expressions and the
+  /// corresponding TypeSourceInfo * are stored.
+  template 
+  class AssociationIteratorTy
+  : public llvm::iterator_facade_base<
+AssociationIteratorTy, std::input_iterator_tag,
+AssociationTy, std::ptrdiff_t, AssociationTy,
+AssociationTy> {
+friend class GenericSelectionExpr;
+// FIXME: This iterator could conceptually be a random access iterator, and
+// it would be nice if we could strengthen the iterator category someday.
+// However this iterator does not satisfy two requirements of forward
+// iterators:
+// a) reference = T& or reference = const T&
+// b) If It1 and It2 are both dereferenceable, then It1 == It2 if and only
+//if *It1 and *It2 are bound to the same objects.
+// An alternative design approach was discussed during review;
+// store an Association object inside the iterator, and return a reference
+// to it when dereferenced. This idea was discarded beacuse of nasty
+// lifetime issues:
+//AssociationIterator It = ...;
+//const Association &Assoc = *It++; // Oops, Assoc is dangling.
+using BaseTy = typename AssociationIteratorTy::iterator_facade_base;
+using StmtPtrPtrTy =
+typename std::conditional::type;
+using TSIPtrPtrTy =
+typename std::conditional::type;
+StmtPtrPtrTy E = nullptr;
+TSIPtrPtrTy TSI = nullptr; // Kept in sync with E.
+unsigned Offset = 0, SelectedOffset = 0;
+AssociationIteratorTy(StmtPtrPtrTy E, TSIPtrPtrTy TSI, unsigned Offset,
+  unsigned SelectedOffset)
+: E(E), TSI(TSI), Offset(Offset), SelectedOffset(SelectedOffset) {}
+
+  public:
+AssociationIteratorTy() = default;
+typename BaseTy::reference operator*() const {
+  return AssociationTy(cast(*E), *TSI,
+  Offset == SelectedOffset);
+}
+typename BaseTy::pointer operator->() const { return **this; }
+using BaseTy::operator++;
+AssociationIteratorTy &operator++() {
+  ++E;
+  ++TSI;
+  ++Offset;
+  return *this;
+}
+bool operator==(AssociationIteratorTy Other) const { return E == Other.E; }
+  }; // class AssociationIterator
+
   /// Build a non-result-dependent generic selection expression.
   GenericSelectionExpr(const ASTContext &Context, SourceLocation GenericLoc,
   

[PATCH] D57280: [clang][OpenMP] OMPFlushClause is synthetic, no such clause exists

2019-01-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG with a nit




Comment at: lib/Basic/OpenMPKinds.cpp:56
 #define OPENMP_CLAUSE(Name, Class) .Case(#Name, OMPC_##Name)
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"

Just `.Case("flush", OMPC_flush)`, similar to `uniform`


Repository:
  rC Clang

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

https://reviews.llvm.org/D57280



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


[PATCH] D57021: [clangd] Suggest adding missing includes for typos (like include-fixer).

2019-01-28 Thread Eric Liu via Phabricator via cfe-commits
ioeric updated this revision to Diff 183845.
ioeric added a comment.

- Rebase on origin/master


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57021

Files:
  clangd/ClangdUnit.cpp
  clangd/IncludeFixer.cpp
  clangd/IncludeFixer.h
  clangd/SourceCode.h
  unittests/clangd/DiagnosticsTests.cpp

Index: unittests/clangd/DiagnosticsTests.cpp
===
--- unittests/clangd/DiagnosticsTests.cpp
+++ unittests/clangd/DiagnosticsTests.cpp
@@ -30,6 +30,11 @@
   return Field(&Diag::Fixes, ElementsAre(FixMatcher));
 }
 
+testing::Matcher WithFix(testing::Matcher FixMatcher1,
+   testing::Matcher FixMatcher2) {
+  return Field(&Diag::Fixes, UnorderedElementsAre(FixMatcher1, FixMatcher2));
+}
+
 testing::Matcher WithNote(testing::Matcher NoteMatcher) {
   return Field(&Diag::Notes, ElementsAre(NoteMatcher));
 }
@@ -280,6 +285,26 @@
   Pair(EqualToLSPDiag(NoteInMainLSP), IsEmpty(;
 }
 
+struct SymbolWithHeader {
+  std::string QName;
+  std::string DeclaringFile;
+  std::string IncludeHeader;
+};
+
+std::unique_ptr
+buildIndexWithSymbol(llvm::ArrayRef Syms) {
+  SymbolSlab::Builder Slab;
+  for (const auto &S : Syms) {
+Symbol Sym = cls(S.QName);
+Sym.Flags |= Symbol::IndexedForCodeCompletion;
+Sym.CanonicalDeclaration.FileURI = S.DeclaringFile.c_str();
+Sym.Definition.FileURI = S.DeclaringFile.c_str();
+Sym.IncludeHeaders.emplace_back(S.IncludeHeader, 1);
+Slab.insert(Sym);
+  }
+  return MemIndex::build(std::move(Slab).build(), RefSlab());
+}
+
 TEST(IncludeFixerTest, IncompleteType) {
   Annotations Test(R"cpp(
 $insert[[]]namespace ns {
@@ -292,15 +317,8 @@
 }
   )cpp");
   auto TU = TestTU::withCode(Test.code());
-  Symbol Sym = cls("ns::X");
-  Sym.Flags |= Symbol::IndexedForCodeCompletion;
-  Sym.CanonicalDeclaration.FileURI = "unittest:///x.h";
-  Sym.Definition.FileURI = "unittest:///x.h";
-  Sym.IncludeHeaders.emplace_back("\"x.h\"", 1);
-
-  SymbolSlab::Builder Slab;
-  Slab.insert(Sym);
-  auto Index = MemIndex::build(std::move(Slab).build(), RefSlab());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""}});
   TU.ExternalIndex = Index.get();
 
   EXPECT_THAT(
@@ -345,6 +363,65 @@
"member access into incomplete type 'ns::X'")));
 }
 
+TEST(IncludeFixerTest, Typo) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace ns {
+void foo() {
+  $unqualified[[X]] x;
+}
+}
+void bar() {
+  ns::$qualified[[X]] x; // ns:: is valid.
+  ::$global[[Global]] glob;
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"ns::X", "unittest:///x.h", "\"x.h\""},
+   SymbolWithHeader{"Global", "unittest:///global.h", "\"global.h\""}});
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(
+  TU.build().getDiagnostics(),
+  UnorderedElementsAre(
+  AllOf(Diag(Test.range("unqualified"), "unknown type name 'X'"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("qualified"),
+ "no type named 'X' in namespace 'ns'"),
+WithFix(Fix(Test.range("insert"), "#include \"x.h\"\n",
+"Add include \"x.h\" for symbol ns::X"))),
+  AllOf(Diag(Test.range("global"),
+ "no type named 'Global' in the global namespace"),
+WithFix(Fix(Test.range("insert"), "#include \"global.h\"\n",
+"Add include \"global.h\" for symbol Global");
+}
+
+TEST(IncludeFixerTest, MultipleMatchedSymbols) {
+  Annotations Test(R"cpp(
+$insert[[]]namespace na {
+namespace nb {
+void foo() {
+  $unqualified[[X]] x;
+}
+}
+}
+  )cpp");
+  auto TU = TestTU::withCode(Test.code());
+  auto Index = buildIndexWithSymbol(
+  {SymbolWithHeader{"na::X", "unittest:///a.h", "\"a.h\""},
+   SymbolWithHeader{"na::nb::X", "unittest:///b.h", "\"b.h\""}});
+  TU.ExternalIndex = Index.get();
+
+  EXPECT_THAT(TU.build().getDiagnostics(),
+  UnorderedElementsAre(AllOf(
+  Diag(Test.range("unqualified"), "unknown type name 'X'"),
+  WithFix(Fix(Test.range("insert"), "#include \"a.h\"\n",
+  "Add include \"a.h\" for symbol na::X"),
+  Fix(Test.range("insert"), "#include \"b.h\"\n",
+  "Add include \"b.h\" for symbol na::nb::X");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clangd/SourceCode.h
===
--- clangd/SourceCode.h
+++ clangd/SourceCode.h
@@ -46,7 +46,7 @@
 /// The returned value is in the range [0, Code.size()].
 llvm::Expected
 posit

[PATCH] D56943: [clang-format][NFC] Allow getLLVMStyle() to take a language

2019-01-28 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D56943



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


[PATCH] D56851: [ASTMatchers] Adds `CXXMemberCallExpr` matcher `invokedAtType`.

2019-01-28 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3300
+///   matches `x.m()` and `p->m()`.
+AST_MATCHER_P_OVERLOAD(clang::CXXMemberCallExpr, invokedAtType,
+   clang::ast_matchers::internal::Matcher,

aaron.ballman wrote:
> ymandel wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > ymandel wrote:
> > > > > ymandel wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > alexfh wrote:
> > > > > > > > The name of the matcher doesn't tell me much. I had to 
> > > > > > > > carefully read the documentation to understand what is it 
> > > > > > > > about. I don't have a name that would raise no questions and 
> > > > > > > > wouldn't be too verbose at the same time, but a bit of 
> > > > > > > > verbosity wouldn't hurt I guess. How about 
> > > > > > > > `objectTypeAsWritten`?
> > > > > > > Yeah, I think this would be a better name. Also, having some 
> > > > > > > examples that demonstrate where this behavior differs from 
> > > > > > > `thisPointerType` would be helpful.
> > > > > > Agreed that it needs a new name, but I'm having trouble finding one 
> > > > > > I'm satisfied with.  Here's the full description: "the type of the 
> > > > > > written implicit object argument".  I base this phrasing on the 
> > > > > > class CXXMemberCallExpr's terminology.  In `x.f(5)`, `x` is the 
> > > > > > implicit object argument, whether or not it is also implicitly 
> > > > > > surrounded by a cast.  That is, "implicit" has two different 
> > > > > > meanings in this context.
> > > > > > 
> > > > > > So, with that, how about `writtenObjectType`? It's close to 
> > > > > > `objectTypeAsWritten` but I'm hoping it makes more clear that the 
> > > > > > "written" part is the object not the type.
> > > > > I've contrasted the behavior with thisPointerType in both of the 
> > > > > examples. Do you think this helps or do you want something more 
> > > > > explicit?
> > > > Here's a totally different direction: `onOrPointsToType()`
> > > > ```
> > > > cxxMemberCallExpr(onOrPointsToType(hasDeclaration(cxxRecordDecl(hasName("Y")
> > > > ```
> > > > 
> > > I think more explicit would be better. e.g.,
> > > ```
> > > cxxMemberCallExpr(invokedAtType(hasDeclaration(cxxRecordDecl(hasName("X")
> > > matches 'x.m()' and 'p->m()'.
> > > cxxMemberCallExpr(on(thisPointerType(hasDeclaration(cxxRecordDecl(hasName("X"))
> > > matches nothing because the type of 'this' is 'Y' in both cases.
> > > ```
> > But, what about even simpler: onType? I think this parallels the intuition 
> > of the name thisPointerType.  onType(T) should match x.f and x->f, where x 
> > is type T.  
> You've pointed out why I don't think `onType` works -- it doesn't match on 
> type T -- it matches on type T, or a pointer/reference to type T, which is 
> pretty different. Someone reading the matcher may expect an exact type match 
> and insert a `pointerType()` or something there thinking they need to do that 
> to match a call through a pointer.
> 
> @alexfh, opinions?
True.  I should have explained more.  

1. Ultimately, I think that none of these names really make sense on their own 
and the user will need some familiarity with the documentation. I spent quite a 
while trying to come up with better names and didn't find anything compelling.  
I think that `onType` benefits from not carrying much information -- reducing 
the likelihood of misunderstanding it (they'll have to read the documentation) 
while paralleling the meaning of the matcher `on` and the behavior of 
`thisPointerType` (which also allows either the type or the pointer to that 
type).  

2. My particular concern with `onOrPointsToType` is that it sounds like the 
"or" applies to the `on` but it really means "on (type or points to type)".  


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

https://reviews.llvm.org/D56851



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


[PATCH] D57325: [clangd] Collect macros in static index.

2019-01-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ioeric, 
ilya-biryukov.

We are missing macros in static index.

symbols: before 407 K vs after 420 K
dex memory usage (static index): before 299 MB vs 304 MB


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57325

Files:
  clangd/index/IndexAction.cpp
  unittests/clangd/BackgroundIndexTests.cpp


Index: unittests/clangd/BackgroundIndexTests.cpp
===
--- unittests/clangd/BackgroundIndexTests.cpp
+++ unittests/clangd/BackgroundIndexTests.cpp
@@ -136,6 +136,7 @@
   // B_CC is dropped as we don't collect symbols from A.h in this compilation.
   EXPECT_THAT(runFuzzyFind(Idx, ""),
   UnorderedElementsAre(Named("common"), Named("A_CC"), Named("g"),
+   Named("A"),
AllOf(Named("f_b"), Declared(), 
Defined(;
 
   auto Syms = runFuzzyFind(Idx, "common");
Index: clangd/index/IndexAction.cpp
===
--- clangd/index/IndexAction.cpp
+++ clangd/index/IndexAction.cpp
@@ -174,6 +174,7 @@
   index::IndexingOptions::SystemSymbolFilterKind::All;
   Opts.CollectIncludePath = true;
   Opts.CountReferences = true;
+  Opts.CollectMacro = true;
   Opts.Origin = SymbolOrigin::Static;
   if (RefsCallback != nullptr) {
 Opts.RefFilter = RefKind::All;


Index: unittests/clangd/BackgroundIndexTests.cpp
===
--- unittests/clangd/BackgroundIndexTests.cpp
+++ unittests/clangd/BackgroundIndexTests.cpp
@@ -136,6 +136,7 @@
   // B_CC is dropped as we don't collect symbols from A.h in this compilation.
   EXPECT_THAT(runFuzzyFind(Idx, ""),
   UnorderedElementsAre(Named("common"), Named("A_CC"), Named("g"),
+   Named("A"),
AllOf(Named("f_b"), Declared(), Defined(;
 
   auto Syms = runFuzzyFind(Idx, "common");
Index: clangd/index/IndexAction.cpp
===
--- clangd/index/IndexAction.cpp
+++ clangd/index/IndexAction.cpp
@@ -174,6 +174,7 @@
   index::IndexingOptions::SystemSymbolFilterKind::All;
   Opts.CollectIncludePath = true;
   Opts.CountReferences = true;
+  Opts.CollectMacro = true;
   Opts.Origin = SymbolOrigin::Static;
   if (RefsCallback != nullptr) {
 Opts.RefFilter = RefKind::All;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56326: [OpenMP 5.0] Parsing/sema support for "omp declare mapper" directive

2019-01-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

LG


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

https://reviews.llvm.org/D56326



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


Re: r346652 - Make clang-based tools find libc++ on MacOS

2019-01-28 Thread Nico Weber via cfe-commits
I think c-index-test has the same problem:

$ cat test.cc
#include 
$ out/gn/bin/c-index-test -write-pch foo.pch test.cc
test.cc:1:10: fatal error: 'iostream' file not found

Since https://reviews.llvm.org/rL350714 was a driver-side fix and
c-index-test doesn't use lib/Driver, it didn't do anything here. Can you
take a look at c-index-test too?

On Wed, Jan 9, 2019 at 8:15 AM Ilya Biryukov  wrote:

> Glad to help. The fix has landed. Let me know if the problem persists
> after it's integrated.
>
> On Tue, Jan 8, 2019 at 7:36 PM Nico Weber  wrote:
>
>> That looks like it should help. Thanks for the quick fix!
>>
>> On Tue, Jan 8, 2019 at 1:11 PM Ilya Biryukov 
>> wrote:
>>
>>> Hi Nico,
>>>
>>> This is clearly a bug, it's supposed to search in a sibling directory.
>>> Are you running clang as './clang' in the scripts?  The code seems to
>>> break in that case, https://reviews.llvm.org/D56446 should fix this.
>>>
>>> On Tue, Jan 8, 2019 at 5:12 PM Nico Weber  wrote:
>>>
 It looks like clang now looks for libc++ headers in -internal-isystem
 Release+Asserts/bin/include/c++/v1 , compared to -internal-isystem
 Release+Asserts/include/c++/v1. `make install` puts the libc++ headers in
 Release+Asserts/include, the old location. Was this an intentional change?

 As-is, this seems to break chromium's clang ability to find libc++
 headers (https://crbug.com/919761) because we bundle libc++ headers in
 an "include" directory that's a sibling to the "bin" directory (and have
 been doing so for 4.5 years, since
 https://codereview.chromium.org/281753002).

 On Mon, Nov 12, 2018 at 8:58 AM Ilya Biryukov via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: ibiryukov
> Date: Mon Nov 12 05:55:55 2018
> New Revision: 346652
>
> URL: http://llvm.org/viewvc/llvm-project?rev=346652&view=rev
> Log:
> Make clang-based tools find libc++ on MacOS
>
> Summary:
> When they read compiler args from compile_commands.json.
> This change allows to run clang-based tools, like clang-tidy or clangd,
> built from head using the compile_commands.json file produced for XCode
> toolchains.
>
> On MacOS clang can find the C++ standard library relative to the
> compiler installation dir.
>
> The logic to do this was based on resource dir as an approximation of
> where the compiler is installed. This broke the tools that read
> 'compile_commands.json' and don't ship with the compiler, as they
> typically change resource dir.
>
> To workaround this, we now use compiler install dir detected by the
> driver
> to better mimic the behavior of the original compiler when replaying
> the
> compilations using other tools.
>
> Reviewers: sammccall, arphaman, EricWF
>
> Reviewed By: sammccall
>
> Subscribers: ioeric, christof, kadircet, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D54310
>
> Added:
> cfe/trunk/test/Tooling/Inputs/mock-libcxx/
> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/
> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/
> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/
>
> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
> cfe/trunk/test/Tooling/clang-check-mac-libcxx-abspath.cpp
> cfe/trunk/test/Tooling/clang-check-mac-libcxx-relpath.cpp
> Modified:
> cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
> cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
> cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
> cfe/trunk/lib/Tooling/Tooling.cpp
>
> Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=346652&r1=346651&r2=346652&view=diff
>
> ==
> --- cfe/trunk/include/clang/Lex/HeaderSearchOptions.h (original)
> +++ cfe/trunk/include/clang/Lex/HeaderSearchOptions.h Mon Nov 12
> 05:55:55 2018
> @@ -108,6 +108,13 @@ public:
>/// etc.).
>std::string ResourceDir;
>
> +  /// Compiler install dir as detected by the Driver.
> +  /// This is typically the directory that contains the clang
> executable, i.e.
> +  /// the 'bin/' subdir of a clang distribution.
> +  /// Only used to add include dirs for libc++ on Darwin. Please
> avoid relying
> +  /// on this field for other purposes.
> +  std::string InstallDir;
> +
>/// The directory used for the module cache.
>std::string ModuleCachePath;
>
>
> Modified: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp?rev=346652&r1=346

[PATCH] D57267: [AST] Factor out the logic of the various Expr::Ignore*

2019-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: rsmith.
aaron.ballman added a comment.

Adding Richard for opinions on whether `IgnoreParenImpCasts` should skip full 
expressions, and also the changes to accepting null expressions as arguments in 
more places.




Comment at: lib/AST/Expr.cpp:2559
 
-Expr *Expr::IgnoreImpCasts() {
-  Expr *E = this;
-  while (true)
-if (ImplicitCastExpr *ICE = dyn_cast(E))
-  E = ICE->getSubExpr();
-else if (FullExpr *FE = dyn_cast(E))
-  E = FE->getSubExpr();
-else
-  break;
+/* Logic for the various Expr::Ignore* 
/
+

I'd remove this comment.



Comment at: lib/AST/Expr.cpp:2562
+static Expr *IgnoreImpCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast_or_null(E))
+return ICE->getSubExpr();

Do we really need to accept null arguments? We didn't previously, and this 
increases the overhead of something we do pretty often (though it's probably 
only a negligible performance hit).



Comment at: lib/AST/Expr.cpp:2686
 
-Expr *Expr::IgnoreCasts() {
-  Expr *E = this;
-  while (true) {
-if (CastExpr *P = dyn_cast(E)) {
-  E = P->getSubExpr();
-  continue;
-}
-if (MaterializeTemporaryExpr *Materialize
-= dyn_cast(E)) {
-  E = Materialize->GetTemporaryExpr();
-  continue;
-}
-if (SubstNonTypeTemplateParmExpr *NTTP
-= dyn_cast(E)) {
-  E = NTTP->getReplacement();
-  continue;
-}
-if (FullExpr *FE = dyn_cast(E)) {
-  E = FE->getSubExpr();
-  continue;
-}
-return E;
+/* Implementation of the various Expr::Ignore* 
/
+

I'd remove this comment as well.



Comment at: lib/AST/Expr.cpp:2705
+template 
+Expr *IgnoreExprNodes(Expr *E, FnTy1 Fn1, FnTy2 Fn2) {
+  Expr *LastE = nullptr;

I wonder if it would make more sense to use a parameter pack here so that this 
can be expanded to an arbitrary combination of single steps? The inner part of 
the while loop would look something like:
```
template 
Expr *IgnoreExprNodes(Expr *E, Func&& ...Fns) {
  ...
  while (E != LastE) {
LastE = E;
for (auto &&Fn : {Fns...})
  E = std::forward(Fn)(E);
  }
  ...
}
```


Repository:
  rC Clang

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

https://reviews.llvm.org/D57267



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


[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D56160#1372766 , @bernhardmgruber 
wrote:

> Thank you for the feedback!
>
> @JonasToth I added tests for `decltype` and i can rewrite all signatures 
> where `decltype` is not the top level expression. The reason is, that the 
> source range of a `clang::DecltypeType` is not accurate, as it does not 
> include the expression within the parenthesis following the `decltype` 
> keyword. There is even a FIXME somewhere in the corresponding source file.
>
> @aaron.ballman I am not sure what you mean and maybe you have not understood 
> my issue correctly.
>
> In D56160#1369986 , @aaron.ballman 
> wrote:
>
> > > ...
> >
> > I think you may be able to skip the lookup (which could get expensive) and 
> > instead rely on the fact that the user must have explicitly written that 
> > type as an elaborated type specifier when trying to calculate the source 
> > range for the return type. I suspect what's happening right now is that 
> > `findReturnTypeAndCVSourceRange()` isn't noticing the `struct` specifier 
> > and that's why it's getting dropped. If the user wrote it as an elaborated 
> > type specifier, we should probably retain that when shifting it to a 
> > trailing return type.
>
>
> Given the following source code before the rewriting:
>
>   struct Object { long long value; };
>   class C {
> int Object;
> struct Object m();
>   };
>   Object C::m() { return {0}; }
>
>
> The member function `struct Object m();` needs to have a `struct` before 
> `Object`, because otherwise, the return type would conflict with the member 
> variable of the same name.
>  On the contrary, the out-of-line definition `Object C::m() { return {0}; }` 
> does not need the `struct`, as the scope of the return type does not include 
> the member variables of class `C`. However, rewriting the out-of-line 
> definition from `Object C::m() { return {0}; }` to `auto C::m() -> Object { 
> return {0}; }` changes the scope of the return type, which now includes the 
> member variable `int Object;` and results in a compilation error.


Understood. I was saying that if the inline member declaration uses an 
elaborated type specifier, the out-of-line, trailing-return-type variant needs 
to do so as well.

> I do not understand what you meant by
> 
>> the user must have explicitly written that type as an elaborated type 
>> specifier
> 
> because in case of the out-of-line defintion, the user is not required to do 
> so.

But in the *declaration*, they had to, right?

> Also, when my check rewrites `struct Object m();`, it correctly produces 
> `auto m() -> struct Object;` (`findReturnTypeAndCVSourceRange()` includes the 
> `struct`).

Ah, that's good to know. I was taking a stab as to why it was misbehaving and 
it seems I stabbed wrong. :-P

> I tried to circumvent the problem doing something like (F is the matched 
> `FunctionDecl`)
> 
>   if (auto M = dyn_cast(F)) {
> if (auto Name = M->getDeclaredReturnType().getBaseTypeIdentifier()) {
>   auto result = M->getDeclContext()->lookup(Name);
>   if (!result.empty()) {
> // cannot do rewrite, collision
>   }
> }
>   }
>
> 
> but then I noticed, the lookup is only performed in the scope of the member 
> function's class, not including e.g. inherited classes. So if we extend the 
> example with
> 
>   class D : public C {
>   ::Object g();
>   };
>   Object D::g() {
> 
> 
> (note that instead of `struct Object` we can also qualify the type with the 
> namespace it comes from), then the `DeclContext` of the out-of-line 
> definition of the member function `g` is empty (it least, I do not get an 
> output when i call `dumpDeclContext`). So maybe the `DeclContext` is not the 
> right tool for the job. How else can I query all visible names in which a 
> given object (in this case the matched (member) function) is declared? So I 
> can check that the name of the return type is not already taken in the scope 
> of the trailing return type.
> 
> Here is btw. the function case:
> 
>   struct Object { long long value; };
>   Object j1(unsigned Object) { return {Object * 2}; }
> 
> 
> After the rewrite, the return type conflicts with the parameter name.

Ah, that's a very good point. :-/

> I appreciate any input! I will continue to explore the problem. Maybe I can 
> get it working by inspecting a multitude of `DeclContext`s.

I suspect the lookup operations you'd need to implement may not even be 
feasible from within clang-tidy. Sema is what handles the lookup logic (see 
SemaLookup.cpp) and you do not have access to that from within clang-tidy. It 
may be that we document this as a best-effort and add test cases (and update 
documentation) to demonstrate the problematic corner cases with FIXME comments.


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

https://reviews.llvm.org/D56160




[PATCH] D56928: Support attribute used in member funcs of class templates

2019-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:2182
+  if (Method->hasAttr()) {
+if (auto *A = dyn_cast(Owner)) {
+  SourceLocation Loc;

`const auto *`?



Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:2184
+  SourceLocation Loc;
+  if (MemberSpecializationInfo *MSInfo = A->getMemberSpecializationInfo()) 
{
+Loc = MSInfo->getPointOfInstantiation();

`const MemberSpecializationInfo  *`?



Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:2186
+Loc = MSInfo->getPointOfInstantiation();
+  } else if (ClassTemplateSpecializationDecl *Spec =
+ dyn_cast(A)) {

`const auto *`?



Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:2191
+
+  SemaRef.MarkFunctionReferenced(Loc, Method, /*MightBeOdrUse=*/true);
+}

You can elide the last argument.



Comment at: 
test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp:1
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -O0 -o - %s \
+// RUN:  | FileCheck %s

Meinersbur wrote:
> Could you mention PR17480 in this test file as well?
Also, can you bump this comment down below the RUN lines?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56928



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


[PATCH] D57330: Adjust documentation for git migration.

2019-01-28 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.
jyknight added reviewers: jlebar, rnk, mehdi_amini.
Herald added subscribers: jsji, jfb, arphaman, christof, delcypher, hiraditya, 
nhaehnle, jvesely, nemanjai, kubamracek, arsenm.
Herald added a reviewer: bollu.
Herald added a reviewer: serge-sans-paille.

This fixes most references to the paths:
 llvm.org/svn/
 llvm.org/git/
 llvm.org/viewvc/
 github.com/llvm-mirror/
 github.com/llvm-project/
 reviews.llvm.org/diffusion/

to instead point to https://github.com/llvm/llvm-project.

This is *not* a trivial substitution, because additionally, all the
checkout instructions had to be migrated to instruct users on how to
use the monorepo layout, setting LLVM_ENABLE_PROJECTS instead of
checking out various projects into various subdirectories.

I've attempted to *NOT* change any scripts here, only
documentation. The scripts will have to be addressed separately.


https://reviews.llvm.org/D57330

Files:
  clang-tools-extra/docs/clang-rename.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/Integrations.rst
  clang/.gitignore
  clang/docs/ClangPlugins.rst
  clang/docs/ClangTools.rst
  clang/docs/ControlFlowIntegrityDesign.rst
  clang/docs/InternalsManual.rst
  clang/docs/LibASTMatchersTutorial.rst
  clang/docs/LibTooling.rst
  clang/docs/Toolchain.rst
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/www/analyzer/checker_dev_manual.html
  clang/www/get_started.html
  clang/www/hacking.html
  clang/www/menu.html.incl
  compiler-rt/include/sanitizer/tsan_interface_atomic.h
  compiler-rt/lib/tsan/rtl/tsan_interface.h
  compiler-rt/www/index.html
  compiler-rt/www/menu.html.incl
  libclc/www/index.html
  libcxx/docs/BuildingLibcxx.rst
  libcxx/docs/index.rst
  libcxx/www/TS_deprecation.html
  libcxx/www/atomic_design.html
  libcxx/www/atomic_design_a.html
  libcxx/www/atomic_design_b.html
  libcxx/www/atomic_design_c.html
  libcxx/www/cxx1y_status.html
  libcxx/www/cxx1z_status.html
  libcxx/www/cxx2a_status.html
  libcxx/www/index.html
  libcxx/www/ts1z_status.html
  libcxx/www/type_traits_design.html
  libcxx/www/upcoming_meeting.html
  libcxxabi/www/index.html
  libunwind/docs/BuildingLibunwind.rst
  libunwind/docs/index.rst
  lld/docs/getting_started.rst
  lld/docs/index.rst
  lldb/docs/building-with-debug-llvm.txt
  
lldb/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py
  
lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py
  lldb/utils/vim-lldb/doc/lldb.txt
  lldb/www/adding-language-support.html
  lldb/www/build.html
  lldb/www/index.html
  lldb/www/python-reference.html
  lldb/www/scripting.html
  lldb/www/sidebar.incl
  lldb/www/source.html
  lldb/www/symbolication.html
  lldb/www/varformats.html
  llgo/README.TXT
  llvm/docs/CompileCudaWithLLVM.rst
  llvm/docs/LibFuzzer.rst
  llvm/docs/TestSuiteMakefileGuide.rst
  llvm/docs/TestingGuide.rst
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
  llvm/test/CodeGen/PowerPC/pr24546.ll
  llvm/utils/lit/setup.py
  openmp/www/index.html
  polly/docs/TipsAndTricks.rst
  polly/www/get_started.html
  polly/www/menu.html.incl
  polly/www/todo.html

Index: polly/www/todo.html
===
--- polly/www/todo.html
+++ polly/www/todo.html
@@ -411,12 +411,6 @@
 >http://llvm.org/svn/llvm-project/polly
  Tobias
 
-
-
- Git mirror
-
-git://llvm.org/git/polly.git
- Tobias
 
 
  Commit mails
Index: polly/www/menu.html.incl
===
--- polly/www/menu.html.incl
+++ polly/www/menu.html.incl
@@ -34,7 +34,7 @@
 http://lab.llvm.org:8080/coverage/coverage-reports/polly/index.html";>Code Coverage
 http://llvm.org/reports/scan-build/";>Static analysis
 Doxygen
-https://github.com/llvm-mirror/polly";>Source @ GitHub
+https://github.com/llvm/llvm-project/tree/master/polly";>Source @ GitHub
   
 
   
Index: polly/www/get_started.html
===
--- polly/www/get_started.html
+++ polly/www/get_started.html
@@ -33,20 +33,14 @@
  Manual 
  Get the code 
 
-Warning: Polly/LLVM/clang need to be checked out at the same time.
-
 
-git clone http://llvm.org/git/llvm.git llvm_git
-git clone http://llvm.org/git/polly.git llvm_git/tools/polly
-
-# Also build the matching clang-version (optional)
-git clone http://llvm.org/git/clang.git llvm_git/tools/clang
+git clone http://github.com/llvm/llvm-project.git llvm_git
 
 Build Polly
 
 
 mkdir llvm_build && cd llvm_build
-cmake ../llvm_git && make
+cmake -DLLVM_ENABLE_PROJECTS='polly;clang' ../llvm_git/llvm && make
 
 
  Test Polly
@@ -59,7 +53,7 @@
 build. To configure Polly to use a pre-built LLVM, set the
 -DCMAKE_PREFIX_PATH option:
 
-cmake -DCMAKE_PREFIX_PATH=${LLVM_PREFIX}/lib/cmake/llvm
+cmake -DCMAKE_PREFIX_PATH=${LLVM_PREFIX}/lib/cmake/llvm ../llvm_git/polly
 
 To run unittests,

[PATCH] D57280: [clang][OpenMP] OMPFlushClause is synthetic, no such clause exists

2019-01-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D57280#1373547 , @ABataev wrote:

> LG with a nit


Thank you for the review!


Repository:
  rC Clang

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

https://reviews.llvm.org/D57280



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


[PATCH] D56851: [ASTMatchers] Adds `CXXMemberCallExpr` matcher `invokedAtType`.

2019-01-28 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3300
+///   matches `x.m()` and `p->m()`.
+AST_MATCHER_P_OVERLOAD(clang::CXXMemberCallExpr, invokedAtType,
+   clang::ast_matchers::internal::Matcher,

ymandel wrote:
> aaron.ballman wrote:
> > ymandel wrote:
> > > aaron.ballman wrote:
> > > > aaron.ballman wrote:
> > > > > ymandel wrote:
> > > > > > ymandel wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > alexfh wrote:
> > > > > > > > > The name of the matcher doesn't tell me much. I had to 
> > > > > > > > > carefully read the documentation to understand what is it 
> > > > > > > > > about. I don't have a name that would raise no questions and 
> > > > > > > > > wouldn't be too verbose at the same time, but a bit of 
> > > > > > > > > verbosity wouldn't hurt I guess. How about 
> > > > > > > > > `objectTypeAsWritten`?
> > > > > > > > Yeah, I think this would be a better name. Also, having some 
> > > > > > > > examples that demonstrate where this behavior differs from 
> > > > > > > > `thisPointerType` would be helpful.
> > > > > > > Agreed that it needs a new name, but I'm having trouble finding 
> > > > > > > one I'm satisfied with.  Here's the full description: "the type 
> > > > > > > of the written implicit object argument".  I base this phrasing 
> > > > > > > on the class CXXMemberCallExpr's terminology.  In `x.f(5)`, `x` 
> > > > > > > is the implicit object argument, whether or not it is also 
> > > > > > > implicitly surrounded by a cast.  That is, "implicit" has two 
> > > > > > > different meanings in this context.
> > > > > > > 
> > > > > > > So, with that, how about `writtenObjectType`? It's close to 
> > > > > > > `objectTypeAsWritten` but I'm hoping it makes more clear that the 
> > > > > > > "written" part is the object not the type.
> > > > > > I've contrasted the behavior with thisPointerType in both of the 
> > > > > > examples. Do you think this helps or do you want something more 
> > > > > > explicit?
> > > > > Here's a totally different direction: `onOrPointsToType()`
> > > > > ```
> > > > > cxxMemberCallExpr(onOrPointsToType(hasDeclaration(cxxRecordDecl(hasName("Y")
> > > > > ```
> > > > > 
> > > > I think more explicit would be better. e.g.,
> > > > ```
> > > > cxxMemberCallExpr(invokedAtType(hasDeclaration(cxxRecordDecl(hasName("X")
> > > > matches 'x.m()' and 'p->m()'.
> > > > cxxMemberCallExpr(on(thisPointerType(hasDeclaration(cxxRecordDecl(hasName("X"))
> > > > matches nothing because the type of 'this' is 'Y' in both cases.
> > > > ```
> > > But, what about even simpler: onType? I think this parallels the 
> > > intuition of the name thisPointerType.  onType(T) should match x.f and 
> > > x->f, where x is type T.  
> > You've pointed out why I don't think `onType` works -- it doesn't match on 
> > type T -- it matches on type T, or a pointer/reference to type T, which is 
> > pretty different. Someone reading the matcher may expect an exact type 
> > match and insert a `pointerType()` or something there thinking they need to 
> > do that to match a call through a pointer.
> > 
> > @alexfh, opinions?
> True.  I should have explained more.  
> 
> 1. Ultimately, I think that none of these names really make sense on their 
> own and the user will need some familiarity with the documentation. I spent 
> quite a while trying to come up with better names and didn't find anything 
> compelling.  I think that `onType` benefits from not carrying much 
> information -- reducing the likelihood of misunderstanding it (they'll have 
> to read the documentation) while paralleling the meaning of the matcher `on` 
> and the behavior of `thisPointerType` (which also allows either the type or 
> the pointer to that type).  
> 
> 2. My particular concern with `onOrPointsToType` is that it sounds like the 
> "or" applies to the `on` but it really means "on (type or points to type)".  
So far, my observations are:
1. three engineers quite familiar with the topic can't come up with a name that 
would explain the concept behind this matcher
2. anyone reading that name would have to look up the documentation
3. the implementation of the matcher is straightforward and even shorter than 
the documentation

Should we give up and let users just type `on(anyOf(hasType(Q), 
hasType(pointsTo(Q`?

If we want a bit more brevity here, maybe introduce a `hasTypeOrPointsToType` 
matcher (any bikeshed color will do ;) to shorten the expression above?


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

https://reviews.llvm.org/D56851



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


[PATCH] D57280: [clang][OpenMP] OMPFlushClause is synthetic, no such clause exists

2019-01-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/Basic/OpenMPKinds.cpp:56
 #define OPENMP_CLAUSE(Name, Class) .Case(#Name, OMPC_##Name)
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"

ABataev wrote:
> Just `.Case("flush", OMPC_flush)`, similar to `uniform`
Hm, we won't ever trigger that case, since we have `if (Str == "flush") return 
OMPC_unknown;` before this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57280



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


[PATCH] D57267: [AST] Factor out the logic of the various Expr::Ignore*

2019-01-28 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 183865.
riccibruno marked 4 inline comments as done.
riccibruno added a comment.

Removed the separator comments in `Expr.cpp`
Mode `IgnoreExprNodes` work with an arbitrary number of functions.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57267

Files:
  include/clang/AST/Expr.h
  lib/AST/Expr.cpp

Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2556,192 +2556,176 @@
   return QualType();
 }
 
-Expr *Expr::IgnoreImpCasts() {
-  Expr *E = this;
-  while (true)
-if (ImplicitCastExpr *ICE = dyn_cast(E))
-  E = ICE->getSubExpr();
-else if (FullExpr *FE = dyn_cast(E))
-  E = FE->getSubExpr();
-else
-  break;
+static Expr *IgnoreImpCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast_or_null(E))
+return ICE->getSubExpr();
+
+  else if (auto *FE = dyn_cast_or_null(E))
+return FE->getSubExpr();
+
+  return E;
+}
+
+static Expr *IgnoreImpCastsExtraSingleStep(Expr *E) {
+  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
+  // addition to what IgnoreImpCasts() skips to account for the current
+  // behaviour of IgnoreParenImpCasts().
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast_or_null(E))
+return MTE->GetTemporaryExpr();
+
+  else if (auto *NTTP = dyn_cast_or_null(E))
+return NTTP->getReplacement();
+
   return E;
 }
 
-Expr *Expr::IgnoreImplicit() {
-  Expr *E = this;
+static Expr *IgnoreCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast_or_null(E))
+return CE->getSubExpr();
+
+  else if (auto *FE = dyn_cast_or_null(E))
+return FE->getSubExpr();
+
+  else if (auto *MTE = dyn_cast_or_null(E))
+return MTE->GetTemporaryExpr();
+
+  else if (auto *NTTP = dyn_cast_or_null(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+static Expr *IgnoreLValueCastsSingleStep(Expr *E) {
+  // Skip what IgnoreCastsSingleStep skips, except that only
+  // lvalue-to-rvalue casts are skipped.
+  if (auto *CE = dyn_cast_or_null(E))
+if (CE->getCastKind() != CK_LValueToRValue)
+  return E;
+
+  return IgnoreCastsSingleStep(E);
+}
+
+static Expr *IgnoreBaseCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast_or_null(E))
+if (CE->getCastKind() == CK_DerivedToBase ||
+CE->getCastKind() == CK_UncheckedDerivedToBase ||
+CE->getCastKind() == CK_NoOp)
+  return CE->getSubExpr();
+
+  return E;
+}
+
+static Expr *IgnoreImplicitSingleStep(Expr *E) {
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast_or_null(E))
+return MTE->GetTemporaryExpr();
+
+  else if (auto *BTE = dyn_cast_or_null(E))
+return BTE->getSubExpr();
+
+  return E;
+}
+
+static Expr *IgnoreParensSingleStep(Expr *E) {
+  if (auto *PE = dyn_cast_or_null(E))
+return PE->getSubExpr();
+
+  else if (auto *UO = dyn_cast_or_null(E)) {
+if (UO->getOpcode() == UO_Extension)
+  return UO->getSubExpr();
+  }
+
+  else if (auto *GSE = dyn_cast_or_null(E)) {
+if (!GSE->isResultDependent())
+  return GSE->getResultExpr();
+  }
+
+  else if (auto *CE = dyn_cast_or_null(E)) {
+if (!CE->isConditionDependent())
+  return CE->getChosenSubExpr();
+  }
+
+  else if (auto *CE = dyn_cast_or_null(E))
+return CE->getSubExpr();
+
+  return E;
+}
+
+static Expr *IgnoreNoopCastsSingleStep(const ASTContext &Ctx, Expr *E) {
+  if (auto *CE = dyn_cast_or_null(E)) {
+// We ignore integer <-> casts that are of the same width, ptr<->ptr and
+// ptr<->int casts of the same width. We also ignore all identity casts.
+Expr *SubExpr = CE->getSubExpr();
+bool IsIdentityCast =
+Ctx.hasSameUnqualifiedType(E->getType(), SubExpr->getType());
+bool IsSameWidthCast =
+(E->getType()->isPointerType() || E->getType()->isIntegralType(Ctx)) &&
+(SubExpr->getType()->isPointerType() ||
+ SubExpr->getType()->isIntegralType(Ctx)) &&
+(Ctx.getTypeSize(E->getType()) == Ctx.getTypeSize(SubExpr->getType()));
+
+if (IsIdentityCast || IsSameWidthCast)
+  return SubExpr;
+  }
+
+  else if (auto *NTTP = dyn_cast_or_null(E))
+return NTTP->getReplacement();
+
+  return E;
+}
+
+namespace {
+
+Expr *IgnoreExprNodesImpl(Expr *E) { return E; }
+template 
+Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) {
+  return IgnoreExprNodesImpl(Fn(E), std::forward(Fns)...);
+}
+
+/// Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *,
+/// Recursively apply each of the functions to E until reaching a fixed point.
+/// Note that a null E is valid; in this case nothing is done.
+template  Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
   Expr *LastE = nullptr;
   while (E != LastE) {
 LastE = E;
-
-if (auto *ICE = dyn_cast(E))
-  E = ICE->getSubExpr();
-
-

[PATCH] D57267: [AST] Factor out the logic of the various Expr::Ignore*

2019-01-28 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: lib/AST/Expr.cpp:2562
+static Expr *IgnoreImpCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast_or_null(E))
+return ICE->getSubExpr();

aaron.ballman wrote:
> Do we really need to accept null arguments? We didn't previously, and this 
> increases the overhead of something we do pretty often (though it's probably 
> only a negligible performance hit).
I did benchmark it to see if there is any difference but could not measure any 
(looking at the generated code this adds a single null check at the start). My 
concern was that it could be possible that some AST node has a null child, 
perhaps when the AST is malformed. I will however defer to you or Richard since 
I probably lack some of the background needed to make this choice.



Comment at: lib/AST/Expr.cpp:2705
+template 
+Expr *IgnoreExprNodes(Expr *E, FnTy1 Fn1, FnTy2 Fn2) {
+  Expr *LastE = nullptr;

aaron.ballman wrote:
> I wonder if it would make more sense to use a parameter pack here so that 
> this can be expanded to an arbitrary combination of single steps? The inner 
> part of the while loop would look something like:
> ```
> template 
> Expr *IgnoreExprNodes(Expr *E, Func&& ...Fns) {
>   ...
>   while (E != LastE) {
> LastE = E;
> for (auto &&Fn : {Fns...})
>   E = std::forward(Fn)(E);
>   }
>   ...
> }
> ```
I like it! Thanks for the suggestion. This particular solution did not work 
because it requires I believe all the types to be equal for the `auto` 
deduction to succeed. However a recursive solution works fine. I looked quickly 
at the generated code and it is identical as far as I can tell. Let me know if 
there are issues with it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57267



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


[PATCH] D57280: [clang][OpenMP] OMPFlushClause is synthetic, no such clause exists

2019-01-28 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Basic/OpenMPKinds.cpp:56
 #define OPENMP_CLAUSE(Name, Class) .Case(#Name, OMPC_##Name)
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"

lebedev.ri wrote:
> ABataev wrote:
> > Just `.Case("flush", OMPC_flush)`, similar to `uniform`
> Hm, we won't ever trigger that case, since we have `if (Str == "flush") 
> return OMPC_unknown;` before this.
Then just remove this new line completely.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57280



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


[PATCH] D56851: [ASTMatchers] Adds `CXXMemberCallExpr` matcher `invokedAtType`.

2019-01-28 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3300
+///   matches `x.m()` and `p->m()`.
+AST_MATCHER_P_OVERLOAD(clang::CXXMemberCallExpr, invokedAtType,
+   clang::ast_matchers::internal::Matcher,

alexfh wrote:
> ymandel wrote:
> > aaron.ballman wrote:
> > > ymandel wrote:
> > > > aaron.ballman wrote:
> > > > > aaron.ballman wrote:
> > > > > > ymandel wrote:
> > > > > > > ymandel wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > alexfh wrote:
> > > > > > > > > > The name of the matcher doesn't tell me much. I had to 
> > > > > > > > > > carefully read the documentation to understand what is it 
> > > > > > > > > > about. I don't have a name that would raise no questions 
> > > > > > > > > > and wouldn't be too verbose at the same time, but a bit of 
> > > > > > > > > > verbosity wouldn't hurt I guess. How about 
> > > > > > > > > > `objectTypeAsWritten`?
> > > > > > > > > Yeah, I think this would be a better name. Also, having some 
> > > > > > > > > examples that demonstrate where this behavior differs from 
> > > > > > > > > `thisPointerType` would be helpful.
> > > > > > > > Agreed that it needs a new name, but I'm having trouble finding 
> > > > > > > > one I'm satisfied with.  Here's the full description: "the type 
> > > > > > > > of the written implicit object argument".  I base this phrasing 
> > > > > > > > on the class CXXMemberCallExpr's terminology.  In `x.f(5)`, `x` 
> > > > > > > > is the implicit object argument, whether or not it is also 
> > > > > > > > implicitly surrounded by a cast.  That is, "implicit" has two 
> > > > > > > > different meanings in this context.
> > > > > > > > 
> > > > > > > > So, with that, how about `writtenObjectType`? It's close to 
> > > > > > > > `objectTypeAsWritten` but I'm hoping it makes more clear that 
> > > > > > > > the "written" part is the object not the type.
> > > > > > > I've contrasted the behavior with thisPointerType in both of the 
> > > > > > > examples. Do you think this helps or do you want something more 
> > > > > > > explicit?
> > > > > > Here's a totally different direction: `onOrPointsToType()`
> > > > > > ```
> > > > > > cxxMemberCallExpr(onOrPointsToType(hasDeclaration(cxxRecordDecl(hasName("Y")
> > > > > > ```
> > > > > > 
> > > > > I think more explicit would be better. e.g.,
> > > > > ```
> > > > > cxxMemberCallExpr(invokedAtType(hasDeclaration(cxxRecordDecl(hasName("X")
> > > > > matches 'x.m()' and 'p->m()'.
> > > > > cxxMemberCallExpr(on(thisPointerType(hasDeclaration(cxxRecordDecl(hasName("X"))
> > > > > matches nothing because the type of 'this' is 'Y' in both cases.
> > > > > ```
> > > > But, what about even simpler: onType? I think this parallels the 
> > > > intuition of the name thisPointerType.  onType(T) should match x.f and 
> > > > x->f, where x is type T.  
> > > You've pointed out why I don't think `onType` works -- it doesn't match 
> > > on type T -- it matches on type T, or a pointer/reference to type T, 
> > > which is pretty different. Someone reading the matcher may expect an 
> > > exact type match and insert a `pointerType()` or something there thinking 
> > > they need to do that to match a call through a pointer.
> > > 
> > > @alexfh, opinions?
> > True.  I should have explained more.  
> > 
> > 1. Ultimately, I think that none of these names really make sense on their 
> > own and the user will need some familiarity with the documentation. I spent 
> > quite a while trying to come up with better names and didn't find anything 
> > compelling.  I think that `onType` benefits from not carrying much 
> > information -- reducing the likelihood of misunderstanding it (they'll have 
> > to read the documentation) while paralleling the meaning of the matcher 
> > `on` and the behavior of `thisPointerType` (which also allows either the 
> > type or the pointer to that type).  
> > 
> > 2. My particular concern with `onOrPointsToType` is that it sounds like the 
> > "or" applies to the `on` but it really means "on (type or points to type)". 
> >  
> So far, my observations are:
> 1. three engineers quite familiar with the topic can't come up with a name 
> that would explain the concept behind this matcher
> 2. anyone reading that name would have to look up the documentation
> 3. the implementation of the matcher is straightforward and even shorter than 
> the documentation
> 
> Should we give up and let users just type `on(anyOf(hasType(Q), 
> hasType(pointsTo(Q`?
> 
> If we want a bit more brevity here, maybe introduce a `hasTypeOrPointsToType` 
> matcher (any bikeshed color will do ;) to shorten the expression above?
Yes to both suggestions (dropping this one and adding `hasTypeOrPointsToType`). 
It seems a rather obvious conclusion now that you've said it. :)  

Personally, I'd go with `hasOrPointsToType`, but agreed that its just bike 
shedding.

[PATCH] D57230: [analyzer] Toning down invalidation a bit

2019-01-28 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

I tried to creduce one file where the result differed and this is the result:

  typedef struct {
int a;
int b
  } c;
  d;
  e(c *f) {
d < f->a;
c g;
h(&g.b);
e(&g);
  }

I think this the core idea is quite straightforward but this example is a bit 
convoluted due to the recursion. I do not see any value of adding this to the 
regression tests as this case is already covered there. Do you think I should 
try to reduce additional files?


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

https://reviews.llvm.org/D57230



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


Re: r346652 - Make clang-based tools find libc++ on MacOS

2019-01-28 Thread Nico Weber via cfe-commits
This seems to fix it, but I don't know if it's the right fix:

diff --git a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
index b62416ffd9e..d933f8c1b70 100644
--- a/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
+++ b/clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
@@ -47,6 +47,10 @@ std::unique_ptr
clang::createInvocationFromCommandLine(
   driver::Driver TheDriver(Args[0], llvm::sys::getDefaultTargetTriple(),
*Diags, VFS);

+  StringRef InstalledPathParent(llvm::sys::path::parent_path(Args[0]));
+  if (llvm::sys::fs::exists(InstalledPathParent))
+TheDriver.setInstalledDir(InstalledPathParent);
+
   // Don't check that inputs exist, they may have been remapped.
   TheDriver.setCheckInputsExist(false);



On Mon, Jan 28, 2019 at 10:08 AM Nico Weber  wrote:

> I think c-index-test has the same problem:
>
> $ cat test.cc
> #include 
> $ out/gn/bin/c-index-test -write-pch foo.pch test.cc
> test.cc:1:10: fatal error: 'iostream' file not found
>
> Since https://reviews.llvm.org/rL350714 was a driver-side fix and
> c-index-test doesn't use lib/Driver, it didn't do anything here. Can you
> take a look at c-index-test too?
>
> On Wed, Jan 9, 2019 at 8:15 AM Ilya Biryukov  wrote:
>
>> Glad to help. The fix has landed. Let me know if the problem persists
>> after it's integrated.
>>
>> On Tue, Jan 8, 2019 at 7:36 PM Nico Weber  wrote:
>>
>>> That looks like it should help. Thanks for the quick fix!
>>>
>>> On Tue, Jan 8, 2019 at 1:11 PM Ilya Biryukov 
>>> wrote:
>>>
 Hi Nico,

 This is clearly a bug, it's supposed to search in a sibling directory.
 Are you running clang as './clang' in the scripts?  The code seems to
 break in that case, https://reviews.llvm.org/D56446 should fix this.

 On Tue, Jan 8, 2019 at 5:12 PM Nico Weber  wrote:

> It looks like clang now looks for libc++ headers in -internal-isystem
> Release+Asserts/bin/include/c++/v1 , compared to -internal-isystem
> Release+Asserts/include/c++/v1. `make install` puts the libc++ headers in
> Release+Asserts/include, the old location. Was this an intentional change?
>
> As-is, this seems to break chromium's clang ability to find libc++
> headers (https://crbug.com/919761) because we bundle libc++ headers
> in an "include" directory that's a sibling to the "bin" directory (and 
> have
> been doing so for 4.5 years, since
> https://codereview.chromium.org/281753002).
>
> On Mon, Nov 12, 2018 at 8:58 AM Ilya Biryukov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ibiryukov
>> Date: Mon Nov 12 05:55:55 2018
>> New Revision: 346652
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=346652&view=rev
>> Log:
>> Make clang-based tools find libc++ on MacOS
>>
>> Summary:
>> When they read compiler args from compile_commands.json.
>> This change allows to run clang-based tools, like clang-tidy or
>> clangd,
>> built from head using the compile_commands.json file produced for
>> XCode
>> toolchains.
>>
>> On MacOS clang can find the C++ standard library relative to the
>> compiler installation dir.
>>
>> The logic to do this was based on resource dir as an approximation of
>> where the compiler is installed. This broke the tools that read
>> 'compile_commands.json' and don't ship with the compiler, as they
>> typically change resource dir.
>>
>> To workaround this, we now use compiler install dir detected by the
>> driver
>> to better mimic the behavior of the original compiler when replaying
>> the
>> compilations using other tools.
>>
>> Reviewers: sammccall, arphaman, EricWF
>>
>> Reviewed By: sammccall
>>
>> Subscribers: ioeric, christof, kadircet, cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D54310
>>
>> Added:
>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/
>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/
>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/
>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/
>>
>> cfe/trunk/test/Tooling/Inputs/mock-libcxx/include/c++/v1/mock_vector
>> cfe/trunk/test/Tooling/clang-check-mac-libcxx-abspath.cpp
>> cfe/trunk/test/Tooling/clang-check-mac-libcxx-relpath.cpp
>> Modified:
>> cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
>> cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
>> cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
>> cfe/trunk/lib/Tooling/Tooling.cpp
>>
>> Modified: cfe/trunk/include/clang/Lex/HeaderSearchOptions.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearchOptions.h?rev=346652&r1=346651&r2=346652&view=diff
>>
>> 

[libunwind] r352384 - [libunwind] Drop the dependency on , add placement new inline

2019-01-28 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Jan 28 08:44:56 2019
New Revision: 352384

URL: http://llvm.org/viewvc/llvm-project?rev=352384&view=rev
Log:
[libunwind] Drop the dependency on , add placement new inline

We haven't eliminated C++ library dependency altogether in D57251,
UnwindCursor.hpp had an unused dependency on  which was
pulling in other C++ headers. Removing that dependency also revealed
(correctly) that we need our own global placement new declaration. Now
libunwind should be independent of the C++ library.

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

Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/src/Unwind-seh.cpp
libunwind/trunk/src/UnwindCursor.hpp
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=352384&r1=352383&r2=352384&view=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Mon Jan 28 08:44:56 2019
@@ -287,6 +287,9 @@ unwind_append_if(LIBUNWIND_CXX_FLAGS LIB
 
 unwind_append_if(LIBUNWIND_C_FLAGS LIBUNWIND_HAS_FUNWIND_TABLES 
-funwind-tables)
 
+# Ensure that we don't depend on C++ standard library.
+unwind_append_if(LIBUNWIND_CXX_FLAGS LIBUNWIND_HAS_NOSTDINCXX_FLAG -nostdinc++)
+
 # Assert
 string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
 if (LIBUNWIND_ENABLE_ASSERTIONS)
@@ -341,28 +344,6 @@ endif()
 
 include_directories(include)
 
-find_path(
-  LIBUNWIND_LIBCXX_INCLUDES_INTERNAL
-  __libcpp_version
-  PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxx/include
-${LLVM_MAIN_SRC_DIR}/runtimes/libcxx/include
-${LLVM_MAIN_SRC_DIR}/../libcxx/include
-  NO_DEFAULT_PATH
-  NO_CMAKE_FIND_ROOT_PATH
-  )
-if ((NOT LIBUNWIND_STANDALONE_BUILD OR HAVE_LIBCXX) AND
-IS_DIRECTORY "${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
-  set(LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT 
"${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
-endif()
-
-set(LIBUNWIND_CXX_INCLUDE_PATHS "${LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT}" CACHE 
PATH
-"Paths to C++ header directories separated by ';'.")
-
-if (NOT LIBUNWIND_CXX_INCLUDE_PATHS STREQUAL "")
-  list(APPEND LIBUNWIND_CXX_FLAGS -nostdinc++)
-  include_directories("${LIBUNWIND_CXX_INCLUDE_PATHS}")
-endif()
-
 add_subdirectory(src)
 
 if (LIBUNWIND_INCLUDE_DOCS)

Modified: libunwind/trunk/src/Unwind-seh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-seh.cpp?rev=352384&r1=352383&r2=352384&view=diff
==
--- libunwind/trunk/src/Unwind-seh.cpp (original)
+++ libunwind/trunk/src/Unwind-seh.cpp Mon Jan 28 08:44:56 2019
@@ -49,6 +49,10 @@ using namespace libunwind;
 /// Class of foreign exceptions based on unrecognized SEH exceptions.
 static const uint64_t kSEHExceptionClass = 0x434C4E4753454800; // CLNGSEH\0
 
+// libunwind does not and should not depend on C++ library which means that we
+// need our own declaration of global placement new.
+void *operator new(size_t, void*);
+
 /// Exception cleanup routine used by \c _GCC_specific_handler to
 /// free foreign exceptions.
 static void seh_exc_cleanup(_Unwind_Reason_Code urc, _Unwind_Exception *exc) {

Modified: libunwind/trunk/src/UnwindCursor.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindCursor.hpp?rev=352384&r1=352383&r2=352384&view=diff
==
--- libunwind/trunk/src/UnwindCursor.hpp (original)
+++ libunwind/trunk/src/UnwindCursor.hpp Mon Jan 28 08:44:56 2019
@@ -11,7 +11,6 @@
 #ifndef __UNWINDCURSOR_HPP__
 #define __UNWINDCURSOR_HPP__
 
-#include 
 #include 
 #include 
 #include 

Modified: libunwind/trunk/src/libunwind.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/libunwind.cpp?rev=352384&r1=352383&r2=352384&view=diff
==
--- libunwind/trunk/src/libunwind.cpp (original)
+++ libunwind/trunk/src/libunwind.cpp Mon Jan 28 08:44:56 2019
@@ -11,10 +11,6 @@
 
 #include 
 
-#ifndef NDEBUG
-#include  // getenv
-#endif
-
 #include "libunwind_ext.h"
 #include "config.h"
 
@@ -27,6 +23,10 @@
 
 using namespace libunwind;
 
+// libunwind does not and should not depend on C++ library which means that we
+// need our own declaration of global placement new.
+void *operator new(size_t, void*);
+
 /// internal object to represent this processes address space
 LocalAddressSpace LocalAddressSpace::sThisAddressSpace;
 


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


[PATCH] D53329: Generate DIFile with main program if source is not available

2019-01-28 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@dblaikie As I mentioned in one of my earlier comments, after some analysis, I 
think this patch definitely not the right way to fix the problem. We just 
cannot default to the main file if the DIFile source is not available.

I have a bug filed for the same issue 
(https://bugs.llvm.org/show_bug.cgi?id=40170) Maybe I should close this patch 
and put the information on the bug report. Do you agree?


Repository:
  rC Clang

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

https://reviews.llvm.org/D53329



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


r352390 - [clang][OpenMP] OMPFlushClause is synthetic, no such clause exists

2019-01-28 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Mon Jan 28 09:04:11 2019
New Revision: 352390

URL: http://llvm.org/viewvc/llvm-project?rev=352390&view=rev
Log:
[clang][OpenMP] OMPFlushClause is synthetic, no such clause exists

Summary:
As discussed in https://reviews.llvm.org/D57112#inline-506781,
'flush' clause does not exist in the OpenMP spec, it can not be
specified, and `OMPFlushClause` class is just a helper class.

Therefore `OPENMP_CLAUSE()` in `clang/Basic/OpenMPKinds.def`
should not contain 'flush' "clause".

I have simply removed the `OPENMP_CLAUSE(flush, OMPFlushClause)`
from `clang/Basic/OpenMPKinds.def`, grepped for `OPENMP_CLAUSE`
and added `OPENMP_CLAUSE(flush, OMPFlushClause)` back to the **every**
place where `OPENMP_CLAUSE` is defined and `clang/Basic/OpenMPKinds.def`
is then included.

So as-is, this patch is a NFC. Possibly, some of these
`OPENMP_CLAUSE(flush, OMPFlushClause)` should be dropped,
i don't really know.

Test plan: `ninja check-clang`

Reviewers: ABataev

Reviewed By: ABataev

Subscribers: guansong, arphaman, cfe-commits

Tags: #openmp

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

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=352390&r1=352389&r2=352390&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Jan 28 09:04:11 2019
@@ -5318,6 +5318,7 @@ public:
 
 #define OPENMP_CLAUSE(Name, Class)  \
   RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); }
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
 
   RetTy Visit(PTR(OMPClause) S) {
@@ -5326,6 +5327,7 @@ public:
 default: llvm_unreachable("Unknown clause kind!");
 #define OPENMP_CLAUSE(Name, Class)  \
 case OMPC_ ## Name : return Visit ## Class(static_cast(S));
+OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
 }
   }
@@ -5357,6 +5359,7 @@ public:
   : OS(OS), Policy(Policy) {}
 
 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *S);
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
 };
 

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=352390&r1=352389&r2=352390&view=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Jan 28 09:04:11 2019
@@ -529,6 +529,7 @@ private:
   bool TraverseOMPLoopDirective(OMPLoopDirective *S);
   bool TraverseOMPClause(OMPClause *C);
 #define OPENMP_CLAUSE(Name, Class) bool Visit##Class(Class *C);
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
   /// Process clauses with list of variables.
   template  bool VisitOMPClauseList(T *Node);
@@ -2788,6 +2789,7 @@ bool RecursiveASTVisitor::Trave
   case OMPC_##Name:
\
 TRY_TO(Visit##Class(static_cast(C))); 
\
 break;
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
   case OMPC_threadprivate:
   case OMPC_uniform:

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=352390&r1=352389&r2=352390&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Mon Jan 28 09:04:11 2019
@@ -258,7 +258,6 @@ OPENMP_CLAUSE(ordered, OMPOrderedClause)
 OPENMP_CLAUSE(nowait, OMPNowaitClause)
 OPENMP_CLAUSE(untied, OMPUntiedClause)
 OPENMP_CLAUSE(mergeable, OMPMergeableClause)
-OPENMP_CLAUSE(flush, OMPFlushClause)
 OPENMP_CLAUSE(read, OMPReadClause)
 OPENMP_CLAUSE(write, OMPWriteClause)
 OPENMP_CLAUSE(update, OMPUpdateClause)

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=352390&r1=352389&r2=352390&view=diff
==
--- cfe/trunk/include/clang/Basic/O

[PATCH] D57280: [clang][OpenMP] OMPFlushClause is synthetic, no such clause exists

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



Comment at: lib/Basic/OpenMPKinds.cpp:56
 #define OPENMP_CLAUSE(Name, Class) .Case(#Name, OMPC_##Name)
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"

ABataev wrote:
> lebedev.ri wrote:
> > ABataev wrote:
> > > Just `.Case("flush", OMPC_flush)`, similar to `uniform`
> > Hm, we won't ever trigger that case, since we have `if (Str == "flush") 
> > return OMPC_unknown;` before this.
> Then just remove this new line completely.
Yep, great idea, did that.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57280



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


[PATCH] D57280: [clang][OpenMP] OMPFlushClause is synthetic, no such clause exists

2019-01-28 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352390: [clang][OpenMP] OMPFlushClause is synthetic, no such 
clause exists (authored by lebedevri, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57280?vs=183689&id=183883#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57280

Files:
  cfe/trunk/include/clang/AST/OpenMPClause.h
  cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
  cfe/trunk/include/clang/Basic/OpenMPKinds.def
  cfe/trunk/include/clang/Basic/OpenMPKinds.h
  cfe/trunk/include/clang/Serialization/ASTReader.h
  cfe/trunk/include/clang/Serialization/ASTWriter.h
  cfe/trunk/lib/AST/OpenMPClause.cpp
  cfe/trunk/lib/AST/StmtProfile.cpp
  cfe/trunk/lib/Basic/OpenMPKinds.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/tools/libclang/CIndex.cpp

Index: cfe/trunk/lib/AST/OpenMPClause.cpp
===
--- cfe/trunk/lib/AST/OpenMPClause.cpp
+++ cfe/trunk/lib/AST/OpenMPClause.cpp
@@ -30,6 +30,7 @@
 #define OPENMP_CLAUSE(Name, Class) \
   case OMPC_##Name:\
 return static_cast(this)->children();
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
   }
   llvm_unreachable("unknown OMPClause");
Index: cfe/trunk/lib/AST/StmtProfile.cpp
===
--- cfe/trunk/lib/AST/StmtProfile.cpp
+++ cfe/trunk/lib/AST/StmtProfile.cpp
@@ -412,6 +412,7 @@
   OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
 #define OPENMP_CLAUSE(Name, Class) \
   void Visit##Class(const Class *C);
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
   void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
   void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
Index: cfe/trunk/lib/Sema/TreeTransform.h
===
--- cfe/trunk/lib/Sema/TreeTransform.h
+++ cfe/trunk/lib/Sema/TreeTransform.h
@@ -681,6 +681,7 @@
 #define OPENMP_CLAUSE(Name, Class)\
   LLVM_ATTRIBUTE_NOINLINE \
   OMPClause *Transform ## Class(Class *S);
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
 
   /// Build a new qualified type given its unqualified type and type location.
@@ -3311,6 +3312,7 @@
 #define OPENMP_CLAUSE(Name, Class) \
   case OMPC_ ## Name : \
 return getDerived().Transform ## Class(cast(S));
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
   }
 
Index: cfe/trunk/lib/Basic/OpenMPKinds.cpp
===
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp
@@ -67,6 +67,8 @@
   case OMPC_##Name:\
 return #Name;
 #include "clang/Basic/OpenMPKinds.def"
+  case OMPC_flush:
+return "flush";
   case OMPC_uniform:
 return "uniform";
   case OMPC_threadprivate:
Index: cfe/trunk/tools/libclang/CIndex.cpp
===
--- cfe/trunk/tools/libclang/CIndex.cpp
+++ cfe/trunk/tools/libclang/CIndex.cpp
@@ -2130,6 +2130,7 @@
   OMPClauseEnqueue(EnqueueVisitor *Visitor) : Visitor(Visitor) { }
 #define OPENMP_CLAUSE(Name, Class) \
   void Visit##Class(const Class *C);
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
   void VisitOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
   void VisitOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
Index: cfe/trunk/include/clang/AST/OpenMPClause.h
===
--- cfe/trunk/include/clang/AST/OpenMPClause.h
+++ cfe/trunk/include/clang/AST/OpenMPClause.h
@@ -5318,6 +5318,7 @@
 
 #define OPENMP_CLAUSE(Name, Class)  \
   RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); }
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
 
   RetTy Visit(PTR(OMPClause) S) {
@@ -5326,6 +5327,7 @@
 default: llvm_unreachable("Unknown clause kind!");
 #define OPENMP_CLAUSE(Name, Class)  \
 case OMPC_ ## Name : return Visit ## Class(static_cast(S));
+OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
 }
   }
@@ -5357,6 +5359,7 @@
   : OS(OS), Policy(Policy) {}
 
 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *S);
+  OPENMP_CLAUSE(flush, OMPFlushClause)
 #include "clang/Basic/OpenMPKinds.def"
 };
 
Index: c

[PATCH] D56868: Add -fapply-global-visibility-to-externs for -cc1

2019-01-28 Thread Scott Linder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352391: Add -fapply-global-visibility-to-externs for -cc1 
(authored by scott.linder, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56868?vs=182559&id=183886#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56868

Files:
  cfe/trunk/include/clang/Basic/LangOptions.def
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/lib/CodeGen/CodeGenModule.cpp
  cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
  cfe/trunk/lib/Driver/ToolChains/HIP.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/set-visibility-for-decls.c
  cfe/trunk/test/Driver/amdgpu-visibility.cl
  cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip
  cfe/trunk/test/Driver/hip-toolchain-rdc.hip

Index: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp
@@ -731,9 +731,11 @@
   }
   if (!D)
 return;
-  // Set visibility for definitions.
+  // Set visibility for definitions, and for declarations if requested globally
+  // or set explicitly.
   LinkageInfo LV = D->getLinkageAndVisibility();
-  if (LV.isVisibilityExplicit() || !GV->isDeclarationForLinker())
+  if (LV.isVisibilityExplicit() || getLangOpts().SetVisibilityForExternDecls ||
+  !GV->isDeclarationForLinker())
 GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
 }
 
Index: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp
@@ -293,8 +293,10 @@
   // Default to "hidden" visibility, as object level linking will not be
   // supported for the foreseeable future.
   if (!DriverArgs.hasArg(options::OPT_fvisibility_EQ,
- options::OPT_fvisibility_ms_compat))
+ options::OPT_fvisibility_ms_compat)) {
 CC1Args.append({"-fvisibility", "hidden"});
+CC1Args.push_back("-fapply-global-visibility-to-externs");
+  }
 }
 
 llvm::opt::DerivedArgList *
Index: cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
+++ cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
@@ -108,5 +108,6 @@
  options::OPT_fvisibility_ms_compat)) {
 CC1Args.push_back("-fvisibility");
 CC1Args.push_back("hidden");
+CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
 }
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2501,6 +2501,9 @@
   if (Args.hasArg(OPT_fvisibility_global_new_delete_hidden))
 Opts.GlobalAllocationFunctionVisibilityHidden = 1;
 
+  if (Args.hasArg(OPT_fapply_global_visibility_to_externs))
+Opts.SetVisibilityForExternDecls = 1;
+
   if (Args.hasArg(OPT_ftrapv)) {
 Opts.setSignedOverflowBehavior(LangOptions::SOB_Trapping);
 // Set the handler, if one is specified.
Index: cfe/trunk/include/clang/Driver/CC1Options.td
===
--- cfe/trunk/include/clang/Driver/CC1Options.td
+++ cfe/trunk/include/clang/Driver/CC1Options.td
@@ -702,6 +702,8 @@
   HelpText<"Default type and symbol visibility">;
 def ftype_visibility : Separate<["-"], "ftype-visibility">,
   HelpText<"Default type visibility">;
+def fapply_global_visibility_to_externs : Flag<["-"], "fapply-global-visibility-to-externs">,
+  HelpText<"Apply global symbol visibility to external declarations without an explicit visibility">;
 def ftemplate_depth : Separate<["-"], "ftemplate-depth">,
   HelpText<"Maximum depth of recursive template instantiation">;
 def foperator_arrow_depth : Separate<["-"], "foperator-arrow-depth">,
Index: cfe/trunk/include/clang/Basic/LangOptions.def
===
--- cfe/trunk/include/clang/Basic/LangOptions.def
+++ cfe/trunk/include/clang/Basic/LangOptions.def
@@ -261,6 +261,8 @@
  "default visibility for functions and variables [-fvisibility]")
 ENUM_LANGOPT(TypeVisibilityMode, Visibility, 3, DefaultVisibility,
  "default visibility for types [-ftype-visibility]")
+LANGOPT(SetVisibilityForExternDecls, 1, 0,
+"apply global symbol visibility to external declarations without an explicit visibility")
 ENUM_LANGOPT(StackProtector, StackProtectorMode, 2, SSPOff,
  "stack protector mode")
 ENUM_LANGOPT(TrivialAutoVarInit, TrivialAutoVarInitKind, 2, TrivialAutoVarInitKind::Uninitialized,
Index: cfe/trunk/test/CodeGen/set-visibility-for-decls.c
==

r352391 - Add -fapply-global-visibility-to-externs for -cc1

2019-01-28 Thread Scott Linder via cfe-commits
Author: scott.linder
Date: Mon Jan 28 09:12:19 2019
New Revision: 352391

URL: http://llvm.org/viewvc/llvm-project?rev=352391&view=rev
Log:
Add -fapply-global-visibility-to-externs for -cc1

Introduce an option to request global visibility settings be applied to
declarations without a definition or an explicit visibility, rather than
the existing behavior of giving these default visibility. When the
visibility of all or most extern definitions are known this allows for
the same optimisations -fvisibility permits without updating source code
to annotate all declarations.

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

Added:
cfe/trunk/test/CodeGen/set-visibility-for-decls.c
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
cfe/trunk/lib/Driver/ToolChains/HIP.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/amdgpu-visibility.cl
cfe/trunk/test/Driver/hip-toolchain-no-rdc.hip
cfe/trunk/test/Driver/hip-toolchain-rdc.hip

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=352391&r1=352390&r2=352391&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Jan 28 09:12:19 2019
@@ -261,6 +261,8 @@ ENUM_LANGOPT(ValueVisibilityMode, Visibi
  "default visibility for functions and variables [-fvisibility]")
 ENUM_LANGOPT(TypeVisibilityMode, Visibility, 3, DefaultVisibility,
  "default visibility for types [-ftype-visibility]")
+LANGOPT(SetVisibilityForExternDecls, 1, 0,
+"apply global symbol visibility to external declarations without an 
explicit visibility")
 ENUM_LANGOPT(StackProtector, StackProtectorMode, 2, SSPOff,
  "stack protector mode")
 ENUM_LANGOPT(TrivialAutoVarInit, TrivialAutoVarInitKind, 2, 
TrivialAutoVarInitKind::Uninitialized,

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=352391&r1=352390&r2=352391&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Jan 28 09:12:19 2019
@@ -702,6 +702,8 @@ def fvisibility : Separate<["-"], "fvisi
   HelpText<"Default type and symbol visibility">;
 def ftype_visibility : Separate<["-"], "ftype-visibility">,
   HelpText<"Default type visibility">;
+def fapply_global_visibility_to_externs : Flag<["-"], 
"fapply-global-visibility-to-externs">,
+  HelpText<"Apply global symbol visibility to external declarations without an 
explicit visibility">;
 def ftemplate_depth : Separate<["-"], "ftemplate-depth">,
   HelpText<"Maximum depth of recursive template instantiation">;
 def foperator_arrow_depth : Separate<["-"], "foperator-arrow-depth">,

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=352391&r1=352390&r2=352391&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Jan 28 09:12:19 2019
@@ -731,9 +731,11 @@ void CodeGenModule::setGlobalVisibility(
   }
   if (!D)
 return;
-  // Set visibility for definitions.
+  // Set visibility for definitions, and for declarations if requested globally
+  // or set explicitly.
   LinkageInfo LV = D->getLinkageAndVisibility();
-  if (LV.isVisibilityExplicit() || !GV->isDeclarationForLinker())
+  if (LV.isVisibilityExplicit() || getLangOpts().SetVisibilityForExternDecls ||
+  !GV->isDeclarationForLinker())
 GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
 }
 

Modified: cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp?rev=352391&r1=352390&r2=352391&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/AMDGPU.cpp Mon Jan 28 09:12:19 2019
@@ -108,5 +108,6 @@ void AMDGPUToolChain::addClangTargetOpti
  options::OPT_fvisibility_ms_compat)) {
 CC1Args.push_back("-fvisibility");
 CC1Args.push_back("hidden");
+CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
 }

Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/HIP.cpp?rev=352391&r1=352390&r2=352391&view=diff
==
--- cfe/t

[PATCH] D57330: Adjust documentation for git migration.

2019-01-28 Thread James Y Knight via Phabricator via cfe-commits
jyknight updated this revision to Diff 183891.
jyknight added a comment.

Fix some warnings I added.

Restore TestSuiteMakefileGuide.rst, which apparently isn't 100%
obsolete. (But it is incorrect, and I'm not sure exactly how to fix
it, so I just left a FIXME).


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

https://reviews.llvm.org/D57330

Files:
  clang-tools-extra/docs/clang-rename.rst
  clang-tools-extra/docs/clang-tidy/Contributing.rst
  clang-tools-extra/docs/clang-tidy/Integrations.rst
  clang/.gitignore
  clang/docs/ClangPlugins.rst
  clang/docs/ClangTools.rst
  clang/docs/ControlFlowIntegrityDesign.rst
  clang/docs/InternalsManual.rst
  clang/docs/LibASTMatchersTutorial.rst
  clang/docs/LibTooling.rst
  clang/docs/Toolchain.rst
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/www/analyzer/checker_dev_manual.html
  clang/www/get_started.html
  clang/www/hacking.html
  clang/www/menu.html.incl
  compiler-rt/include/sanitizer/tsan_interface_atomic.h
  compiler-rt/lib/tsan/rtl/tsan_interface.h
  compiler-rt/www/index.html
  compiler-rt/www/menu.html.incl
  libclc/www/index.html
  libcxx/docs/BuildingLibcxx.rst
  libcxx/docs/index.rst
  libcxx/www/TS_deprecation.html
  libcxx/www/atomic_design.html
  libcxx/www/atomic_design_a.html
  libcxx/www/atomic_design_b.html
  libcxx/www/atomic_design_c.html
  libcxx/www/cxx1y_status.html
  libcxx/www/cxx1z_status.html
  libcxx/www/cxx2a_status.html
  libcxx/www/index.html
  libcxx/www/ts1z_status.html
  libcxx/www/type_traits_design.html
  libcxx/www/upcoming_meeting.html
  libcxxabi/www/index.html
  libunwind/docs/BuildingLibunwind.rst
  libunwind/docs/index.rst
  lld/docs/getting_started.rst
  lld/docs/index.rst
  lldb/docs/building-with-debug-llvm.txt
  
lldb/packages/Python/lldbsuite/test/functionalities/command_source/TestCommandSource.py
  
lldb/packages/Python/lldbsuite/test/lang/objc/objc-optimized/TestObjcOptimized.py
  lldb/utils/vim-lldb/doc/lldb.txt
  lldb/www/adding-language-support.html
  lldb/www/build.html
  lldb/www/index.html
  lldb/www/python-reference.html
  lldb/www/scripting.html
  lldb/www/sidebar.incl
  lldb/www/source.html
  lldb/www/symbolication.html
  lldb/www/varformats.html
  llgo/README.TXT
  llvm/docs/CompileCudaWithLLVM.rst
  llvm/docs/LibFuzzer.rst
  llvm/docs/TestSuiteGuide.md
  llvm/docs/TestSuiteMakefileGuide.rst
  llvm/docs/TestingGuide.rst
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
  llvm/test/CodeGen/PowerPC/pr24546.ll
  llvm/utils/lit/setup.py
  openmp/www/index.html
  polly/docs/TipsAndTricks.rst
  polly/www/get_started.html
  polly/www/menu.html.incl
  polly/www/todo.html

Index: polly/www/todo.html
===
--- polly/www/todo.html
+++ polly/www/todo.html
@@ -411,12 +411,6 @@
 >http://llvm.org/svn/llvm-project/polly
  Tobias
 
-
-
- Git mirror
-
-git://llvm.org/git/polly.git
- Tobias
 
 
  Commit mails
Index: polly/www/menu.html.incl
===
--- polly/www/menu.html.incl
+++ polly/www/menu.html.incl
@@ -34,7 +34,7 @@
 http://lab.llvm.org:8080/coverage/coverage-reports/polly/index.html";>Code Coverage
 http://llvm.org/reports/scan-build/";>Static analysis
 Doxygen
-https://github.com/llvm-mirror/polly";>Source @ GitHub
+https://github.com/llvm/llvm-project/tree/master/polly";>Source @ GitHub
   
 
   
Index: polly/www/get_started.html
===
--- polly/www/get_started.html
+++ polly/www/get_started.html
@@ -33,20 +33,14 @@
  Manual 
  Get the code 
 
-Warning: Polly/LLVM/clang need to be checked out at the same time.
-
 
-git clone http://llvm.org/git/llvm.git llvm_git
-git clone http://llvm.org/git/polly.git llvm_git/tools/polly
-
-# Also build the matching clang-version (optional)
-git clone http://llvm.org/git/clang.git llvm_git/tools/clang
+git clone http://github.com/llvm/llvm-project.git llvm_git
 
 Build Polly
 
 
 mkdir llvm_build && cd llvm_build
-cmake ../llvm_git && make
+cmake -DLLVM_ENABLE_PROJECTS='polly;clang' ../llvm_git/llvm && make
 
 
  Test Polly
@@ -59,7 +53,7 @@
 build. To configure Polly to use a pre-built LLVM, set the
 -DCMAKE_PREFIX_PATH option:
 
-cmake -DCMAKE_PREFIX_PATH=${LLVM_PREFIX}/lib/cmake/llvm
+cmake -DCMAKE_PREFIX_PATH=${LLVM_PREFIX}/lib/cmake/llvm ../llvm_git/polly
 
 To run unittests, however, you need to have the LLVM source directory around.
 Polly will use the llvm-config of the LLVM you're building against
Index: polly/docs/TipsAndTricks.rst
===
--- polly/docs/TipsAndTricks.rst
+++ polly/docs/TipsAndTricks.rst
@@ -47,7 +47,7 @@
 the regression.
 
 LLVM has a single repository that contains all projects. It can be cloned at:
-``_. How to bisect on a
+``_. Ho

[PATCH] D57337: [Targets] Adjust ARM data layout

2019-01-28 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings updated this revision to Diff 183893.
michaelplatings added a comment.

Diff with -U9


Repository:
  rC Clang

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

https://reviews.llvm.org/D57337

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/test/CodeGen/armv7k-abi.c
  clang/test/CodeGen/target-data.c

Index: clang/test/CodeGen/target-data.c
===
--- clang/test/CodeGen/target-data.c
+++ clang/test/CodeGen/target-data.c
@@ -96,7 +96,7 @@
 
 // RUN: %clang_cc1 -triple arm-nacl -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=ARM-NACL
-// ARM-NACL: target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S128"
+// ARM-NACL: target datalayout = "e-m:e-p:32:32-F8-i64:64-v128:64:128-a:0:32-n32-S128"
 
 // RUN: %clang_cc1 -triple mipsel-nacl -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-NACL
@@ -165,19 +165,19 @@
 
 // RUN: %clang_cc1 -triple thumb-unknown-gnueabi -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=THUMB
-// THUMB: target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+// THUMB: target datalayout = "e-m:e-p:32:32-F8-i64:64-v128:64:128-a:0:32-n32-S64"
 
 // RUN: %clang_cc1 -triple arm-unknown-gnueabi -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=ARM
-// ARM: target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+// ARM: target datalayout = "e-m:e-p:32:32-F8-i64:64-v128:64:128-a:0:32-n32-S64"
 
 // RUN: %clang_cc1 -triple thumb-unknown -o - -emit-llvm -target-abi apcs-gnu \
 // RUN: %s | FileCheck %s -check-prefix=THUMB-GNU
-// THUMB-GNU: target datalayout = "e-m:e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
+// THUMB-GNU: target datalayout = "e-m:e-p:32:32-F8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
 
 // RUN: %clang_cc1 -triple arm-unknown -o - -emit-llvm -target-abi apcs-gnu \
 // RUN: %s | FileCheck %s -check-prefix=ARM-GNU
-// ARM-GNU: target datalayout = "e-m:e-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
+// ARM-GNU: target datalayout = "e-m:e-p:32:32-F8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
 
 // RUN: %clang_cc1 -triple arc-unknown-unknown -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=ARC
Index: clang/test/CodeGen/armv7k-abi.c
===
--- clang/test/CodeGen/armv7k-abi.c
+++ clang/test/CodeGen/armv7k-abi.c
@@ -4,7 +4,7 @@
 
 // Make sure 64 and 128 bit types are naturally aligned by the v7k ABI:
 
-// CHECK: target datalayout = "e-m:o-p:32:32-i64:64-a:0:32-n32-S128"
+// CHECK: target datalayout = "e-m:o-p:32:32-F8-i64:64-a:0:32-n32-S128"
 
 typedef struct {
   float arr[4];
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -40,13 +40,14 @@
   // so set preferred for small types to 32.
   if (T.isOSBinFormatMachO()) {
 resetDataLayout(BigEndian
-? "E-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-: "e-m:o-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64");
+? "E-m:o-p:32:32-F8-i64:64-v128:64:128-a:0:32-n32-S64"
+: "e-m:o-p:32:32-F8-i64:64-v128:64:128-a:0:32-n32-S64");
   } else if (T.isOSWindows()) {
 assert(!BigEndian && "Windows on ARM does not support big endian");
 resetDataLayout("e"
 "-m:w"
 "-p:32:32"
+"-F8"
 "-i64:64"
 "-v128:64:128"
 "-a:0:32"
@@ -54,11 +55,11 @@
 "-S64");
   } else if (T.isOSNaCl()) {
 assert(!BigEndian && "NaCl on ARM does not support big endian");
-resetDataLayout("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S128");
+resetDataLayout("e-m:e-p:32:32-F8-i64:64-v128:64:128-a:0:32-n32-S128");
   } else {
 resetDataLayout(BigEndian
-? "E-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-: "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64");
+? "E-m:e-p:32:32-F8-i64:64-v128:64:128-a:0:32-n32-S64"
+: "e-m:e-p:32:32-F8-i64:64-v128:64:128-a:0:32-n32-S64");
   }
 
   // FIXME: Enumerated types are variable width in straight AAPCS.
@@ -87,17 +88,17 @@
 
   if (T.isOSBinFormatMachO() && IsAAPCS16) {
 assert(!BigEndian && "AAPCS16 does not support big-endian");
-resetDataLayout("e-m:o-p:32:32-i64:64-a:0:32-n32-S128");
+resetDataLayout("e-m:o-p:32:32-F8-i64:64-a:0:32-n32-S128");
   } else if (T.isOSBinFormatMachO())
 resetDataLayout(
 BigEndian
-? "E-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
-: "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32");
+? "E-m:o-p:32:32-F8-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
+ 

[PATCH] D57127: [analyzer] Port RetainSummaryManager to the new GenericCall interface, decouple ARCMT from the analyzer

2019-01-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D57127#1371562 , @george.karpenkov 
wrote:

> > Can you elaborate a bit in what sense this decouples ARCMT from the 
> > analyzer?
>
> ARCMT now does not need to link against the analyzer
>
> > Can CLANG_ENABLE_STATIC_ANALYZER now be set independently of 
> > CLANG_ENABLE_ARCMT?
>
> Yes


Should we remove this check that currently requires ENABLE_ARCMT => ENABLE_SA? 
http://llvm-cs.pcc.me.uk/tools/clang/CMakeLists.txt#441


Repository:
  rC Clang

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

https://reviews.llvm.org/D57127



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


[PATCH] D57127: [analyzer] Port RetainSummaryManager to the new GenericCall interface, decouple ARCMT from the analyzer

2019-01-28 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D57127#1371563 , @george.karpenkov 
wrote:

> > Also, isn't lib/Analysis a strange place for this? lib/Analysis is used by 
> > the compiler proper (CodeGen, Sema, …), while RetainSummaryManager is only 
> > used by tooling-like things (static analyzer, arcmigrate).
>
> Not only, it has utilities used by the static analyzer which are too generic 
> to be in the static analyzer itself - ProgramPoint.cpp, BodyFarm.cpp, 
> CocoaConventions.cpp to name a few.


ProgramPoint.cpp and BodyFarm.cpp are used by StaticAnalyzer/Core, which the 
compiler itself uses for CFG-based warnings. Sema also uses CocoaConventions.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57127



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


Re: r352369 - [AST] Introduce GenericSelectionExpr::Association

2019-01-28 Thread Hans Wennborg via cfe-commits
Hi,

This doesn't compile when using GCC 4.8.4:

372/372] Building CXX object
tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
FAILED: 
tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
/work/gccprefix/bin/g++  -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Itools/clang/tools/clang-import-test
-I/work/llvm.monorepo/clang/tools/clang-import-test
-I/work/llvm.monorepo/clang/include -Itools/clang/include
-I/usr/include/libxml2 -Iinclude -I/work/llvm.monorepo/llvm/include
-fPIC -fvisibility-inlines-hidden -std=c++11 -Wall -Wextra
-Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wno-missing-field-initializers -pedantic -Wno-long-long
-Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual
-fno-strict-aliasing -O3-UNDEBUG  -fno-exceptions -fno-rtti -MD
-MT 
tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
-MF 
tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o.d
-o 
tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
-c /work/llvm.monorepo/clang/tools/clang-import-test/clang-import-test.cpp
In file included from /work/llvm.monorepo/clang/include/clang/AST/Attr.h:19:0,
 from /work/llvm.monorepo/clang/include/clang/AST/TypeLoc.h:17,
 from
/work/llvm.monorepo/clang/include/clang/AST/ASTTypeTraits.h:23,
 from
/work/llvm.monorepo/clang/include/clang/AST/ASTContext.h:18,
 from
/work/llvm.monorepo/clang/tools/clang-import-test/clang-import-test.cpp:9:
/work/llvm.monorepo/clang/include/clang/AST/Expr.h:5113:22: error:
invalid use of dependent type
‘clang::GenericSelectionExpr::AssociationIteratorTy::StmtPtrPtrTy’
 StmtPtrPtrTy E = nullptr;
  ^
/work/llvm.monorepo/clang/include/clang/AST/Expr.h:5114:23: error:
invalid use of dependent type
‘clang::GenericSelectionExpr::AssociationIteratorTy::TSIPtrPtrTy’
 TSIPtrPtrTy TSI = nullptr; // Kept in sync with E.
   ^
ninja: build stopped: subcommand failed.

Something like this makes the compiler happy:

diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index c7b015ab804..45d12401970 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -5110,15 +5110,15 @@ class GenericSelectionExpr final
 using TSIPtrPtrTy =
 typename std::conditional::type;
-StmtPtrPtrTy E = nullptr;
-TSIPtrPtrTy TSI = nullptr; // Kept in sync with E.
+StmtPtrPtrTy E;
+TSIPtrPtrTy TSI; // Kept in sync with E.
 unsigned Offset = 0, SelectedOffset = 0;
 AssociationIteratorTy(StmtPtrPtrTy E, TSIPtrPtrTy TSI, unsigned Offset,
   unsigned SelectedOffset)
 : E(E), TSI(TSI), Offset(Offset), SelectedOffset(SelectedOffset) {}

   public:
-AssociationIteratorTy() = default;
+AssociationIteratorTy() : E(0), TSI(0) {}
 typename BaseTy::reference operator*() const {
   return AssociationTy(cast(*E), *TSI,
   Offset == SelectedOffset);


But on our end (Chromium), we're looking at solving it by using Clang
for our build instead.

On Mon, Jan 28, 2019 at 9:18 AM Bruno Ricci via cfe-commits
 wrote:
>
> Author: brunoricci
> Date: Mon Jan 28 06:18:11 2019
> New Revision: 352369
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352369&view=rev
> Log:
> [AST] Introduce GenericSelectionExpr::Association
>
> Introduce a new class GenericSelectionExpr::Association which bundle together
> an association expression and its TypeSourceInfo.
>
> An iterator GenericSelectionExpr::AssociationIterator is additionally added to
> make it possible to iterate over ranges of Associations. This iterator is a
> kind of proxy iterator which abstract over how exactly the expressions and the
> TypeSourceInfos are stored.
>
> Differential Revision: https://reviews.llvm.org/D57106
>
> Reviewed By: aaron.ballman
>
> Reviewers: aaron.ballman, steveire, dblaikie, mclow.lists
>
>
> Modified:
> cfe/trunk/include/clang/AST/Expr.h
> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> cfe/trunk/include/clang/AST/StmtDataCollectors.td
> cfe/trunk/lib/AST/ASTDumper.cpp
> cfe/trunk/lib/AST/StmtPrinter.cpp
> cfe/trunk/lib/AST/StmtProfile.cpp
> cfe/trunk/lib/Sema/SemaExprObjC.cpp
> cfe/trunk/lib/Sema/SemaPseudoObject.cpp
> cfe/trunk/lib/Sema/TreeTransform.h
>
> Modified: cfe/trunk/include/clang/AST/Expr.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=352369&r1=352368&r2=352369&view=diff
> ==
> --- cfe/trunk/include/clang/AST/Expr.h (original)
> +++ cfe/trunk/include/clang/AST/Expr

[PATCH] D57127: [analyzer] Port RetainSummaryManager to the new GenericCall interface, decouple ARCMT from the analyzer

2019-01-28 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

@thakis Sorry I don't understand your point. At the end of the day, 
ProgramPoint and BodyFarm are only used by the static analyzer.
If you disagree, what is your proposed directory structure? What would be the 
benefits?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57127



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


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-01-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 183902.
lebedev.ri marked an inline comment as done.
lebedev.ri added a comment.

- Rebased
- Go back to storing the actual AST class type as string in 
`ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[]`.
- Add `OpenMPClauseKind ASTNodeKind::getOMPClauseKind()` to address the 
regression of D57113  due to the previous ^ 
change. This is better anyway, since it avoids string comparisons, and is a 
simple switch over an enum.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112

Files:
  include/clang/AST/ASTTypeTraits.h
  lib/AST/ASTTypeTraits.cpp

Index: lib/AST/ASTTypeTraits.cpp
===
--- lib/AST/ASTTypeTraits.cpp
+++ lib/AST/ASTTypeTraits.cpp
@@ -37,6 +37,9 @@
   { NKI_None, "Type" },
 #define TYPE(DERIVED, BASE) { NKI_##BASE, #DERIVED "Type" },
 #include "clang/AST/TypeNodes.def"
+  { NKI_None, "OMPClause" },
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) { NKI_OMPClause, #DERIVED },
+#include "clang/Basic/OpenMPKinds.def"
 };
 
 bool ASTNodeKind::isBaseOf(ASTNodeKind Other, unsigned *Distance) const {
@@ -58,6 +61,19 @@
 
 StringRef ASTNodeKind::asStringRef() const { return AllKindInfo[KindId].Name; }
 
+OpenMPClauseKind ASTNodeKind::getOMPClauseKind() const {
+  assert(isBaseOf(NKI_OMPClause, KindId, nullptr) && KindId != NKI_OMPClause &&
+ "Should be an OpenMP clause node");
+  switch (KindId) {
+  default:
+llvm_unreachable("Unknown clause kind!");
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED)\
+  case NKI_##DERIVED:  \
+return OMPC_##TextualSpelling;
+#include "clang/Basic/OpenMPKinds.def"
+  }
+}
+
 ASTNodeKind ASTNodeKind::getMostDerivedType(ASTNodeKind Kind1,
 ASTNodeKind Kind2) {
   if (Kind1.isBaseOf(Kind2)) return Kind2;
@@ -103,6 +119,20 @@
 #include "clang/AST/TypeNodes.def"
   }
   llvm_unreachable("invalid type kind");
+ }
+
+ASTNodeKind ASTNodeKind::getFromNode(const OMPClause &C) {
+  switch (C.getClauseKind()) {
+#define OPENMP_CLAUSE(Name, Class) \
+case OMPC_##Name: return ASTNodeKind(NKI_##Class);
+#include "clang/Basic/OpenMPKinds.def"
+case OMPC_flush:
+case OMPC_threadprivate:
+case OMPC_uniform:
+case OMPC_unknown:
+  llvm_unreachable("unexpected OpenMP clause kind");
+  }
+  llvm_unreachable("invalid stmt kind");
 }
 
 void DynTypedNode::print(llvm::raw_ostream &OS,
@@ -151,6 +181,8 @@
 return D->getSourceRange();
   if (const Stmt *S = get())
 return S->getSourceRange();
+  if (const auto *C = get())
+return SourceRange(C->getBeginLoc(), C->getEndLoc());
   return SourceRange();
 }
 
Index: include/clang/AST/ASTTypeTraits.h
===
--- include/clang/AST/ASTTypeTraits.h
+++ include/clang/AST/ASTTypeTraits.h
@@ -18,6 +18,7 @@
 #include "clang/AST/ASTFwd.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TypeLoc.h"
@@ -58,6 +59,7 @@
   static ASTNodeKind getFromNode(const Decl &D);
   static ASTNodeKind getFromNode(const Stmt &S);
   static ASTNodeKind getFromNode(const Type &T);
+  static ASTNodeKind getFromNode(const OMPClause &C);
   /// \}
 
   /// Returns \c true if \c this and \c Other represent the same kind.
@@ -76,6 +78,11 @@
   /// String representation of the kind.
   StringRef asStringRef() const;
 
+  /// \{
+  /// Return the AST node kind of this ASTNodeKind.
+  OpenMPClauseKind getOMPClauseKind() const;
+  /// \}
+
   /// Strict weak ordering for ASTNodeKind.
   bool operator<(const ASTNodeKind &Other) const {
 return KindId < Other.KindId;
@@ -136,6 +143,9 @@
 NKI_Type,
 #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
 #include "clang/AST/TypeNodes.def"
+NKI_OMPClause,
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) NKI_##DERIVED,
+#include "clang/Basic/OpenMPKinds.def"
 NKI_NumberOfKinds
   };
 
@@ -183,12 +193,15 @@
 KIND_TO_KIND_ID(Decl)
 KIND_TO_KIND_ID(Stmt)
 KIND_TO_KIND_ID(Type)
+KIND_TO_KIND_ID(OMPClause)
 #define DECL(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Decl)
 #include "clang/AST/DeclNodes.inc"
 #define STMT(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED)
 #include "clang/AST/StmtNodes.inc"
 #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
 #include "clang/AST/TypeNodes.def"
+#define OPENMP_CLAUSE(TextualSpelling, DERIVED) KIND_TO_KIND_ID(DERIVED)
+#include "clang/Basic/OpenMPKinds.def"
 #undef KIND_TO_KIND_ID
 
 inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) {
@@ -459,6 +472,11 @@
 T, typename std::enable_if::value>::type>
 : public DynCastPtrConverter {};
 
+template 
+

[PATCH] D57113: [clang-tidy] openmp-use-default-none - a new module and a check

2019-01-28 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 183903.
lebedev.ri added a comment.

NFC.

- Rebased
- Switched to `OpenMPClauseKind ASTNodeKind::getOMPClauseKind()`. This is 
better anyway, since it avoids string comparisons, and is a simple switch over 
an enum.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57113

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/ClangTidyForceLinker.h
  clang-tidy/openmp/CMakeLists.txt
  clang-tidy/openmp/OpenMPTidyModule.cpp
  clang-tidy/openmp/UseDefaultNoneCheck.cpp
  clang-tidy/openmp/UseDefaultNoneCheck.h
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/openmp-use-default-none.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/openmp-use-default-none.cpp

Index: test/clang-tidy/openmp-use-default-none.cpp
===
--- /dev/null
+++ test/clang-tidy/openmp-use-default-none.cpp
@@ -0,0 +1,160 @@
+// RUN: %check_clang_tidy %s openmp-use-default-none %t -- -- -x c++ -fopenmp -fopenmp-version=40
+// RUN: %check_clang_tidy %s openmp-use-default-none %t -- -- -x c   -fopenmp -fopenmp-version=40
+
+////
+// Null cases.
+////
+
+// 'for' directive can not have 'default' clause, no diagnostics.
+void n0(const int a) {
+#pragma omp for
+  for (int b = 0; b < a; b++)
+;
+}
+
+////
+// Single-directive positive cases.
+////
+
+// 'parallel' directive.
+
+// 'parallel' directive can have 'default' clause, but said clause is not
+// specified, diagnosed.
+void p0_0() {
+#pragma omp parallel
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'parallel' does not specify 'default' clause. Consider specifying 'default(none)' clause.
+}
+
+// 'parallel' directive can have 'default' clause, and said clause is specified,
+// with 'none' kind, all good.
+void p0_1() {
+#pragma omp parallel default(none)
+  ;
+}
+
+// 'parallel' directive can have 'default' clause, and said clause is specified,
+// but with 'shared' kind, which is not 'none', diagnose.
+void p0_2() {
+#pragma omp parallel default(shared)
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'parallel' specifies 'default(shared)' clause. Consider using 'default(none)' clause instead.
+  // CHECK-NOTES: :[[@LINE-3]]:22: note: Existing 'default' clause is specified here.
+}
+
+// 'task' directive.
+
+// 'task' directive can have 'default' clause, but said clause is not
+// specified, diagnosed.
+void p1_0() {
+#pragma omp task
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'task' does not specify 'default' clause. Consider specifying 'default(none)' clause.
+}
+
+// 'task' directive can have 'default' clause, and said clause is specified,
+// with 'none' kind, all good.
+void p1_1() {
+#pragma omp task default(none)
+  ;
+}
+
+// 'task' directive can have 'default' clause, and said clause is specified,
+// but with 'shared' kind, which is not 'none', diagnose.
+void p1_2() {
+#pragma omp task default(shared)
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'task' specifies 'default(shared)' clause. Consider using 'default(none)' clause instead.
+  // CHECK-NOTES: :[[@LINE-3]]:18: note: Existing 'default' clause is specified here.
+}
+
+// 'teams' directive. (has to be inside of 'target' directive)
+
+// 'teams' directive can have 'default' clause, but said clause is not
+// specified, diagnosed.
+void p2_0() {
+#pragma omp target
+#pragma omp teams
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'teams' does not specify 'default' clause. Consider specifying 'default(none)' clause.
+}
+
+// 'teams' directive can have 'default' clause, and said clause is specified,
+// with 'none' kind, all good.
+void p2_1() {
+#pragma omp target
+#pragma omp teams default(none)
+  ;
+}
+
+// 'teams' directive can have 'default' clause, and said clause is specified,
+// but with 'shared' kind, which is not 'none', diagnose.
+void p2_2() {
+#pragma omp target
+#pragma omp teams default(shared)
+  ;
+  // CHECK-NOTES: :[[@LINE-2]]:9: warning: OpenMP directive 'teams' specifies 'default(shared)' clause. Consider using 'default(none)' clause instead.
+  // CHECK-NOTES: :[[@LINE-3]]:19: note: Existing 'default' clause is specified here.
+}
+
+// 'taskloop' directive.
+
+// 'taskloop' directive can have 'default' clause, but said clause is not
+// specified, diagnosed.
+void p3_0(const int a) {
+#pragma omp taskloop
+  for (int b = 0; b < a; b++)
+;
+  // CHECK-NOTES: :[[@LINE-3]]:9: warning: OpenMP directive 'taskloop' does not sp

r352403 - Revert "[AST] Introduce GenericSelectionExpr::Association"

2019-01-28 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Mon Jan 28 10:40:26 2019
New Revision: 352403

URL: http://llvm.org/viewvc/llvm-project?rev=352403&view=rev
Log:
Revert "[AST] Introduce GenericSelectionExpr::Association"

This breaks GCC 4.8.4. Reported by email by Hans Wennborg.


Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/include/clang/AST/StmtDataCollectors.td
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/StmtProfile.cpp
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/lib/Sema/SemaPseudoObject.cpp
cfe/trunk/lib/Sema/TreeTransform.h

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=352403&r1=352402&r2=352403&view=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon Jan 28 10:40:26 2019
@@ -28,8 +28,6 @@
 #include "clang/Basic/TypeTraits.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APSInt.h"
-#include "llvm/ADT/iterator.h"
-#include "llvm/ADT/iterator_range.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/AtomicOrdering.h"
@@ -5054,86 +5052,6 @@ class GenericSelectionExpr final
 return getNumAssocs();
   }
 
-  template  class AssociationIteratorTy;
-  /// Bundle together an association expression and its TypeSourceInfo.
-  /// The Const template parameter is for the const and non-const versions
-  /// of AssociationTy.
-  template  class AssociationTy {
-friend class GenericSelectionExpr;
-template  friend class AssociationIteratorTy;
-using ExprPtrTy =
-typename std::conditional::type;
-using TSIPtrTy = typename std::conditional::type;
-ExprPtrTy E;
-TSIPtrTy TSI;
-bool Selected;
-AssociationTy(ExprPtrTy E, TSIPtrTy TSI, bool Selected)
-: E(E), TSI(TSI), Selected(Selected) {}
-
-  public:
-ExprPtrTy getAssociationExpr() const { return E; }
-TSIPtrTy getTypeSourceInfo() const { return TSI; }
-QualType getType() const { return TSI ? TSI->getType() : QualType(); }
-bool isSelected() const { return Selected; }
-AssociationTy *operator->() { return this; }
-const AssociationTy *operator->() const { return this; }
-  }; // class AssociationTy
-
-  /// Iterator over const and non-const Association objects. The Association
-  /// objects are created on the fly when the iterator is dereferenced.
-  /// This abstract over how exactly the association expressions and the
-  /// corresponding TypeSourceInfo * are stored.
-  template 
-  class AssociationIteratorTy
-  : public llvm::iterator_facade_base<
-AssociationIteratorTy, std::input_iterator_tag,
-AssociationTy, std::ptrdiff_t, AssociationTy,
-AssociationTy> {
-friend class GenericSelectionExpr;
-// FIXME: This iterator could conceptually be a random access iterator, and
-// it would be nice if we could strengthen the iterator category someday.
-// However this iterator does not satisfy two requirements of forward
-// iterators:
-// a) reference = T& or reference = const T&
-// b) If It1 and It2 are both dereferenceable, then It1 == It2 if and only
-//if *It1 and *It2 are bound to the same objects.
-// An alternative design approach was discussed during review;
-// store an Association object inside the iterator, and return a reference
-// to it when dereferenced. This idea was discarded beacuse of nasty
-// lifetime issues:
-//AssociationIterator It = ...;
-//const Association &Assoc = *It++; // Oops, Assoc is dangling.
-using BaseTy = typename AssociationIteratorTy::iterator_facade_base;
-using StmtPtrPtrTy =
-typename std::conditional::type;
-using TSIPtrPtrTy =
-typename std::conditional::type;
-StmtPtrPtrTy E = nullptr;
-TSIPtrPtrTy TSI = nullptr; // Kept in sync with E.
-unsigned Offset = 0, SelectedOffset = 0;
-AssociationIteratorTy(StmtPtrPtrTy E, TSIPtrPtrTy TSI, unsigned Offset,
-  unsigned SelectedOffset)
-: E(E), TSI(TSI), Offset(Offset), SelectedOffset(SelectedOffset) {}
-
-  public:
-AssociationIteratorTy() = default;
-typename BaseTy::reference operator*() const {
-  return AssociationTy(cast(*E), *TSI,
-  Offset == SelectedOffset);
-}
-typename BaseTy::pointer operator->() const { return **this; }
-using BaseTy::operator++;
-AssociationIteratorTy &operator++() {
-  ++E;
-  ++TSI;
-  ++Offset;
-  return *this;
-}
-bool operator==(AssociationIteratorTy Other) const { return E == Other.E; }
-  }; // class AssociationIterator
-
   /// Build a non-result-dependent generic selection expression.
   GenericSelectionExpr(const ASTContext &Context, SourceLoca

r352404 - Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib=

2019-01-28 Thread Sterling Augustine via cfe-commits
Author: saugustine
Date: Mon Jan 28 10:56:43 2019
New Revision: 352404

URL: http://llvm.org/viewvc/llvm-project?rev=352404&view=rev
Log:
Add --unwindlib=[libgcc|compiler-rt] to parallel --rtlib=

Summary:
"clang++ hello.cc --rtlib=compiler-rt"

now works without specifying additional unwind or exception
handling libraries.

Reviewers: rsmith

Subscribers: srhines, dberris, aheejin, llvm-commits

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

Added:
cfe/trunk/test/Driver/compiler-rt-unwind.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=352404&r1=352403&r2=352404&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Jan 28 10:56:43 
2019
@@ -51,6 +51,10 @@ def err_drv_invalid_rtlib_name : Error<
   "invalid runtime library name in argument '%0'">;
 def err_drv_unsupported_rtlib_for_platform : Error<
   "unsupported runtime library '%0' for platform '%1'">;
+def err_drv_invalid_unwindlib_name : Error<
+  "invalid unwind library name in argument '%0'">;
+def err_drv_incompatible_unwindlib : Error<
+  "--rtlib=libgcc requires --unwindlib=libgcc">;
 def err_drv_invalid_stdlib_name : Error<
   "invalid library name in argument '%0'">;
 def err_drv_invalid_output_with_multiple_archs : Error<

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=352404&r1=352403&r2=352404&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jan 28 10:56:43 2019
@@ -2568,6 +2568,8 @@ def std_EQ : Joined<["-", "--"], "std=">
   }]>;
 def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
   HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
+def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>,
+  HelpText<"Unwind library to use">, 
Values<"libgcc_eh,compiler-rt-unwind,platform">;
 def sub__library : JoinedOrSeparate<["-"], "sub_library">;
 def sub__umbrella : JoinedOrSeparate<["-"], "sub_umbrella">;
 def system_header_prefix : Joined<["--"], "system-header-prefix=">,

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=352404&r1=352403&r2=352404&view=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Jan 28 10:56:43 2019
@@ -367,6 +367,10 @@ public:
 return ToolChain::CST_Libstdcxx;
   }
 
+  virtual RuntimeLibType GetDefaultUnwindLibType() const {
+return ToolChain::RLT_Libgcc;
+  }
+
   virtual std::string getCompilerRTPath() const;
 
   virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
@@ -511,6 +515,10 @@ public:
   // given compilation arguments.
   virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const;
 
+  // GetUnwindLibType - Determine the unwind library type to use with the
+  // given compilation arguments.
+  virtual RuntimeLibType GetUnwindLibType(const llvm::opt::ArgList &Args) 
const;
+
   /// AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set
   /// the include paths to use for the given C++ standard library type.
   virtual void

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=352404&r1=352403&r2=352404&view=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Jan 28 10:56:43 2019
@@ -679,6 +679,33 @@ ToolChain::RuntimeLibType ToolChain::Get
   return GetDefaultRuntimeLibType();
 }
 
+ToolChain::RuntimeLibType ToolChain
+::GetUnwindLibType(
+const ArgList &Args) const {
+  const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ);
+  // If nothing has been specified, follow the runtime lib type.
+  if (!A)
+return GetRuntimeLibType(Args);
+
+  StringRef LibName = A->getValue();
+  if (LibName == "compiler-rt") {
+if (GetRuntimeLibType(Args) == RLT_Libgcc)
+  getDriver().Diag(diag::err_drv_incompatible_unwindlib);
+return ToolChain::RLT_CompilerRT;
+  }
+  else if (LibName == "libgcc")
+return ToolChain::RLT_Libgcc;
+  else if (LibName == "platform") {
+return GetRun

r352405 - Correct help text for --unwindlib options.

2019-01-28 Thread Sterling Augustine via cfe-commits
Author: saugustine
Date: Mon Jan 28 10:56:44 2019
New Revision: 352405

URL: http://llvm.org/viewvc/llvm-project?rev=352405&view=rev
Log:
Correct help text for --unwindlib options.

Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=352405&r1=352404&r2=352405&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jan 28 10:56:44 2019
@@ -2569,7 +2569,7 @@ def std_EQ : Joined<["-", "--"], "std=">
 def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
   HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
 def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>,
-  HelpText<"Unwind library to use">, 
Values<"libgcc_eh,compiler-rt-unwind,platform">;
+  HelpText<"Unwind library to use">, Values<"libgcc,compiler-rt,platform">;
 def sub__library : JoinedOrSeparate<["-"], "sub_library">;
 def sub__umbrella : JoinedOrSeparate<["-"], "sub_umbrella">;
 def system_header_prefix : Joined<["--"], "system-header-prefix=">,


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


[PATCH] D55782: Fix isInSystemMacro to handle pasted token

2019-01-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/Basic/SourceManager.h:1458-1460
+   // This happens when the macro is the result of a paste, in that 
case
+   // its spelling is the scratch memory, so we take the parent 
context.
+isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc;

I think this also matches things like:

```
// system header
#define BAR FOO

// user code
#define FOO x
BAR
```

... where the location of `x` token produced by the `BAR` macro will now be 
considered to be in a system macro. Can you make this more targeted? (Maybe we 
could change the `SLocEntry` for the token-paste scratch buffer to be 
considered a system header if the `##` token is in a system macro -- that'll 
need the preprocessor to store two `ScratchBuffer`s, one for system headers and 
one for user code, but that seems acceptable.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D55782



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


[PATCH] D57343: lit: Let lit.util.which() return a normcase()ed path

2019-01-28 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: zturner.
Herald added a subscriber: delcypher.
Herald added a reviewer: serge-sans-paille.

`LLVMConfig.with_environment()` uses `os.path.normcase(os.path.normpath(x))` to 
normalize temporary env vars. `LLVMConfig.use_clang()` uses 
`with_environment()` to temporarily set `PATH` and then look for clang there. 
This means that on Windows, clang will be run with a path like 
`c:\foo\bin\clang.EXE` (with a lower-case "C:").

`lit.util.which()` used to not do this, which means the executables added in 
clang/test/lit.cfg.py (e.g. c-index-test) were run with a path like 
`C:\foo\bin\c-index-test.EXE` (because both CMake and GN happen to write 
`clang_tools_dir` with an upper-case C to lit.site.cfg.py).

clang/test/Index/pch-from-libclang.c requires that both c-index-test and clang 
use _exactly_ the same resource dir path (same case and everything), because a 
hash of the resource directory is used as module cache path.

This patch is necessary but not sufficient to make pch-from-libclang.c pass on 
Windows.


https://reviews.llvm.org/D57343

Files:
  llvm/utils/lit/lit/util.py


Index: llvm/utils/lit/lit/util.py
===
--- llvm/utils/lit/lit/util.py
+++ llvm/utils/lit/lit/util.py
@@ -197,7 +197,7 @@
 
 # Check for absolute match first.
 if os.path.isabs(command) and os.path.isfile(command):
-return os.path.normpath(command)
+return os.path.normcase(os.path.normpath(command))
 
 # Would be nice if Python had a lib function for this.
 if not paths:
@@ -215,7 +215,7 @@
 for ext in pathext:
 p = os.path.join(path, command + ext)
 if os.path.exists(p) and not os.path.isdir(p):
-return os.path.normpath(p)
+return os.path.normcase(os.path.normpath(p))
 
 return None
 


Index: llvm/utils/lit/lit/util.py
===
--- llvm/utils/lit/lit/util.py
+++ llvm/utils/lit/lit/util.py
@@ -197,7 +197,7 @@
 
 # Check for absolute match first.
 if os.path.isabs(command) and os.path.isfile(command):
-return os.path.normpath(command)
+return os.path.normcase(os.path.normpath(command))
 
 # Would be nice if Python had a lib function for this.
 if not paths:
@@ -215,7 +215,7 @@
 for ext in pathext:
 p = os.path.join(path, command + ext)
 if os.path.exists(p) and not os.path.isdir(p):
-return os.path.normpath(p)
+return os.path.normcase(os.path.normpath(p))
 
 return None
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57343: lit: Let lit.util.which() return a normcase()ed path

2019-01-28 Thread Zachary Turner via Phabricator via cfe-commits
zturner added a comment.

Shouldn't the hash be case-insensitive on windows?


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

https://reviews.llvm.org/D57343



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


[PATCH] D57345: Make clang/test/Index/pch-from-libclang.c pass in more places

2019-01-28 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: arphaman.

- fixes the test on macOS with LLVM_ENABLE_PIC=OFF
- together with D57343 , gets the test to pass 
on Windows
- makes it run everywhere (it seems to just pass on Linux)

The main change is in CIndexer.cpp, see comments there.


https://reviews.llvm.org/D57345

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Index/pch-from-libclang.c
  clang/tools/libclang/CIndexer.cpp


Index: clang/tools/libclang/CIndexer.cpp
===
--- clang/tools/libclang/CIndexer.cpp
+++ clang/tools/libclang/CIndexer.cpp
@@ -14,6 +14,7 @@
 #include "CXString.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/MD5.h"
@@ -73,10 +74,20 @@
   LibClangPath += llvm::sys::path::parent_path(info.dli_fname);
 #endif
 
-  llvm::sys::path::append(LibClangPath, "clang", CLANG_VERSION_STRING);
+  // On Windows, libclang.dll is in bin/.
+  // On non-Windows, libclang.so/.dylib is in lib/.
+  // With a static-library build of libclang, LibClangPath will contain the
+  // path of the embedding binary, which for LLVM binaries will be in bin/.
+  // ../lib gets us to lib/ in both cases.
+  // This should be similar to CompilerInvocation::GetResourcesPath() and
+  // Driver::Driver().
+  SmallString<128> P;
+  P = llvm::sys::path::parent_path(LibClangPath);
+  llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang",
+  CLANG_VERSION_STRING);
 
   // Cache our result.
-  ResourcesPath = LibClangPath.str();
+  ResourcesPath = P.str();
   return ResourcesPath;
 }
 
Index: clang/test/Index/pch-from-libclang.c
===
--- clang/test/Index/pch-from-libclang.c
+++ clang/test/Index/pch-from-libclang.c
@@ -1,7 +1,11 @@
 // Check that clang can use a PCH created from libclang.
 
-// FIXME: Non-darwin bots fail. Would need investigation using 
-module-file-info to see what is the difference in modules generated from 
libclang vs the compiler invocation, in those systems.
-// REQUIRES: system-darwin
+// This test doesn't use -fdisable-module-hash and hence requires that
+// CompilerInvocation::getModuleHash() computes exactly the same hash
+// for c-index-test and clang, which in turn requires that the both use
+// exactly the same resource-dir, even without calling realpath() on it:
+// - a/../b/ and b/ are not considered the same
+// - on Windows, c:\ and C:\ (only different in case) are not the same
 
 // RUN: %clang_cc1 -fsyntax-only %s -verify
 // RUN: c-index-test -write-pch %t.h.pch %s -fmodules 
-fmodules-cache-path=%t.mcp -Xclang -triple -Xclang x86_64-apple-darwin
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1891,6 +1891,8 @@
 
 std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
  void *MainAddr) {
+  // This should be similar to CIndexer::getClangResourcesPath() and
+  // Driver::Driver().
   std::string ClangExecutable =
   llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
   StringRef Dir = llvm::sys::path::parent_path(ClangExecutable);
@@ -1900,9 +1902,11 @@
   SmallString<128> P(Dir);
   if (ClangResourceDir != "")
 llvm::sys::path::append(P, ClangResourceDir);
-  else
-llvm::sys::path::append(P, "..", Twine("lib") + CLANG_LIBDIR_SUFFIX,
+  else {
+P = llvm::sys::path::parent_path(Dir);
+llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX,
 "clang", CLANG_VERSION_STRING);
+  }
 
   return P.str();
 }
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -119,6 +119,8 @@
 #endif
 
   // Compute the path to the resource directory.
+  // This should be similar to CompilerInvocation::GetResourcesPath() and
+  // CIndexer::getClangResourcesPath().
   StringRef ClangResourceDir(CLANG_RESOURCE_DIR);
   SmallString<128> P(Dir);
   if (ClangResourceDir != "") {


Index: clang/tools/libclang/CIndexer.cpp
===
--- clang/tools/libclang/CIndexer.cpp
+++ clang/tools/libclang/CIndexer.cpp
@@ -14,6 +14,7 @@
 #include "CXString.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/Version.h"
+#include "clang/Config/config.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/MD5.h"
@@ -73,10 +74,20 @@
   LibClangPath += llvm::sys::path::parent_path(info.dli_fname);
 #endif
 
-  llvm::sys::path::append(LibClangPath, "clang", 

[libunwind] r352411 - Revert "[CMake] Use __libc_start_main rather than fopen when checking for C library"

2019-01-28 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Jan 28 11:26:41 2019
New Revision: 352411

URL: http://llvm.org/viewvc/llvm-project?rev=352411&view=rev
Log:
Revert "[CMake] Use __libc_start_main rather than fopen when checking for C 
library"

This reverts commit r352341: it broke the build on macOS which doesn't
seem to provide __libc_start_main in its C library.

Modified:
libunwind/trunk/cmake/config-ix.cmake

Modified: libunwind/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/cmake/config-ix.cmake?rev=352411&r1=352410&r2=352411&view=diff
==
--- libunwind/trunk/cmake/config-ix.cmake (original)
+++ libunwind/trunk/cmake/config-ix.cmake Mon Jan 28 11:26:41 2019
@@ -3,7 +3,7 @@ include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
 include(CheckLibraryExists)
 
-check_library_exists(c __libc_start_main "" LIBUNWIND_HAS_C_LIB)
+check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)
 
 if (NOT LIBUNWIND_USE_COMPILER_RT)
   check_library_exists(gcc_s __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_S_LIB)


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


[PATCH] D56936: Fix handling of overriden methods during ASTImport

2019-01-28 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 183923.
shafik marked 2 inline comments as done.
shafik added a comment.

Addressing comments on commenting and naming.


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

https://reviews.llvm.org/D56936

Files:
  lib/AST/ASTImporter.cpp
  test/Analysis/Inputs/ctu-other.cpp
  test/Analysis/ctu-main.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -2233,6 +2233,191 @@
 }).match(ToTU, functionDecl()));
 }
 
+TEST_P(ImportFunctions, ImportOverriddenMethodTwice) {
+  auto Code =
+  R"(
+  struct B { virtual void f(); };
+  struct D:B { void f(); };
+  )";
+  auto BFP =
+  cxxMethodDecl(hasName("f"), hasParent(cxxRecordDecl(hasName("B";
+  auto DFP =
+  cxxMethodDecl(hasName("f"), hasParent(cxxRecordDecl(hasName("D";
+
+  Decl *FromTU0 = getTuDecl(Code, Lang_CXX);
+  auto *DF = FirstDeclMatcher().match(FromTU0, DFP);
+  Import(DF, Lang_CXX);
+
+  Decl *FromTU1 = getTuDecl(Code, Lang_CXX, "input1.cc");
+  auto *BF = FirstDeclMatcher().match(FromTU1, BFP);
+  Import(BF, Lang_CXX);
+
+  auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+
+  EXPECT_EQ(DeclCounter().match(ToTU, BFP), 1u);
+  EXPECT_EQ(DeclCounter().match(ToTU, DFP), 1u);
+}
+
+TEST_P(ImportFunctions, ImportOverriddenMethodTwiceDefinitionFirst) {
+  auto CodeWithoutDef =
+  R"(
+  struct B { virtual void f(); };
+  struct D:B { void f(); };
+  )";
+  auto CodeWithDef =
+  R"(
+struct B { virtual void f(){}; };
+struct D:B { void f(){}; };
+  )";
+  auto BFP =
+  cxxMethodDecl(hasName("f"), hasParent(cxxRecordDecl(hasName("B";
+  auto DFP =
+  cxxMethodDecl(hasName("f"), hasParent(cxxRecordDecl(hasName("D";
+  auto BFDefP = cxxMethodDecl(
+  hasName("f"), hasParent(cxxRecordDecl(hasName("B"))), isDefinition());
+  auto DFDefP = cxxMethodDecl(
+  hasName("f"), hasParent(cxxRecordDecl(hasName("D"))), isDefinition());
+  auto FDefAllP = cxxMethodDecl(hasName("f"), isDefinition());
+
+  {
+Decl *FromTU = getTuDecl(CodeWithDef, Lang_CXX, "input0.cc");
+auto *FromD = FirstDeclMatcher().match(FromTU, DFP);
+Import(FromD, Lang_CXX);
+  }
+  {
+Decl *FromTU = getTuDecl(CodeWithoutDef, Lang_CXX, "input1.cc");
+auto *FromB = FirstDeclMatcher().match(FromTU, BFP);
+Import(FromB, Lang_CXX);
+  }
+
+  auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+
+  EXPECT_EQ(DeclCounter().match(ToTU, BFP), 1u);
+  EXPECT_EQ(DeclCounter().match(ToTU, DFP), 1u);
+  EXPECT_EQ(DeclCounter().match(ToTU, BFDefP), 1u);
+  EXPECT_EQ(DeclCounter().match(ToTU, DFDefP), 1u);
+  EXPECT_EQ(DeclCounter().match(ToTU, FDefAllP), 2u);
+}
+
+TEST_P(ImportFunctions, ImportOverriddenMethodTwiceOutOfClassDef) {
+  auto Code =
+  R"(
+  struct B { virtual void f(); };
+  struct D:B { void f(); };
+  void B::f(){};
+  )";
+
+  auto BFP =
+  cxxMethodDecl(hasName("f"), hasParent(cxxRecordDecl(hasName("B";
+  auto BFDefP = cxxMethodDecl(
+  hasName("f"), hasParent(cxxRecordDecl(hasName("B"))), isDefinition());
+  auto DFP = cxxMethodDecl(hasName("f"), hasParent(cxxRecordDecl(hasName("D"))),
+   unless(isDefinition()));
+
+  Decl *FromTU0 = getTuDecl(Code, Lang_CXX);
+  auto *D = FirstDeclMatcher().match(FromTU0, DFP);
+  Import(D, Lang_CXX);
+
+  Decl *FromTU1 = getTuDecl(Code, Lang_CXX, "input1.cc");
+  auto *B = FirstDeclMatcher().match(FromTU1, BFP);
+  Import(B, Lang_CXX);
+
+  auto *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+
+  EXPECT_EQ(DeclCounter().match(ToTU, BFP), 1u);
+  EXPECT_EQ(DeclCounter().match(ToTU, BFDefP), 0u);
+
+  auto *ToB = FirstDeclMatcher().match(
+  ToTU, cxxRecordDecl(hasName("B")));
+  auto *ToBFInClass = FirstDeclMatcher().match(ToTU, BFP);
+  auto *ToBFOutOfClass = FirstDeclMatcher().match(
+  ToTU, cxxMethodDecl(hasName("f"), isDefinition()));
+
+  // The definition should be out-of-class.
+  EXPECT_NE(ToBFInClass, ToBFOutOfClass);
+  EXPECT_NE(ToBFInClass->getLexicalDeclContext(),
+ToBFOutOfClass->getLexicalDeclContext());
+  EXPECT_EQ(ToBFOutOfClass->getDeclContext(), ToB);
+  EXPECT_EQ(ToBFOutOfClass->getLexicalDeclContext(), ToTU);
+
+  // Check that the redecl chain is intact.
+  EXPECT_EQ(ToBFOutOfClass->getPreviousDecl(), ToBFInClass);
+}
+
+TEST_P(ImportFunctions,
+   ImportOverriddenMethodTwiceOutOfClassDefInSeparateCode) {
+  auto CodeTU0 =
+  R"(
+  struct B { virtual void f(); };
+  struct D:B { void f(); };
+  )";
+  auto CodeTU1 =
+  R"(
+  struct B { virtual void f(); };
+  struct D:B { void f(); };
+  void B::f(){}
+  void D::f(){}
+  void foo(B &b, D &d) { b.f(); d.f(); }
+  )";
+
+  auto BFP =
+  cxxMethodDecl(hasName("f"), hasParent(cxxRec

[PATCH] D57349: AMDGPU: Add ds append/consume builtins

2019-01-28 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: yaxunl, rampitec, b-sumner.
Herald added subscribers: t-tye, tpr, dstuttard, nhaehnle, wdng, jvesely, 
kzhuravl.

https://reviews.llvm.org/D57349

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/builtins-amdgcn.cl


Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -536,6 +536,18 @@
   *out = __builtin_amdgcn_s_getpc();
 }
 
+// CHECK-LABEL: @test_ds_append_lds(
+// CHECK: call i32 @llvm.amdgcn.ds.append.p3i32(i32 addrspace(3)* %ptr, i1 
false)
+kernel void test_ds_append_lds(global int* out, local int* ptr) {
+  *out = __builtin_amdgcn_ds_append(ptr);
+}
+
+// CHECK-LABEL: @test_ds_consume_lds(
+// CHECK: call i32 @llvm.amdgcn.ds.consume.p3i32(i32 addrspace(3)* %ptr, i1 
false)
+kernel void test_ds_consume_lds(global int* out, local int* ptr) {
+  *out = __builtin_amdgcn_ds_consume(ptr);
+}
+
 // CHECK-DAG: [[$WI_RANGE]] = !{i32 0, i32 1024}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[$READ_EXEC_ATTRS]] = { convergent }
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -12478,6 +12478,14 @@
   case AMDGPU::BI__builtin_amdgcn_fmed3f:
   case AMDGPU::BI__builtin_amdgcn_fmed3h:
 return emitTernaryBuiltin(*this, E, Intrinsic::amdgcn_fmed3);
+  case AMDGPU::BI__builtin_amdgcn_ds_append:
+  case AMDGPU::BI__builtin_amdgcn_ds_consume: {
+Intrinsic::ID Intrin = BuiltinID == AMDGPU::BI__builtin_amdgcn_ds_append ?
+  Intrinsic::amdgcn_ds_append : Intrinsic::amdgcn_ds_consume;
+Value *Src0 = EmitScalarExpr(E->getArg(0));
+Function *F = CGM.getIntrinsic(Intrin, { Src0->getType() });
+return Builder.CreateCall(F, { Src0, Builder.getFalse() });
+  }
   case AMDGPU::BI__builtin_amdgcn_read_exec: {
 CallInst *CI = cast(
   EmitSpecialRegisterBuiltin(*this, E, Int64Ty, Int64Ty, true, "exec"));
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -98,6 +98,8 @@
 BUILTIN(__builtin_amdgcn_ds_faddf, "ff*3fIiIiIb", "n")
 BUILTIN(__builtin_amdgcn_ds_fminf, "ff*3fIiIiIb", "n")
 BUILTIN(__builtin_amdgcn_ds_fmaxf, "ff*3fIiIiIb", "n")
+BUILTIN(__builtin_amdgcn_ds_append, "ii*3", "n")
+BUILTIN(__builtin_amdgcn_ds_consume, "ii*3", "n")
 
 
//===--===//
 // CI+ only builtins.


Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -536,6 +536,18 @@
   *out = __builtin_amdgcn_s_getpc();
 }
 
+// CHECK-LABEL: @test_ds_append_lds(
+// CHECK: call i32 @llvm.amdgcn.ds.append.p3i32(i32 addrspace(3)* %ptr, i1 false)
+kernel void test_ds_append_lds(global int* out, local int* ptr) {
+  *out = __builtin_amdgcn_ds_append(ptr);
+}
+
+// CHECK-LABEL: @test_ds_consume_lds(
+// CHECK: call i32 @llvm.amdgcn.ds.consume.p3i32(i32 addrspace(3)* %ptr, i1 false)
+kernel void test_ds_consume_lds(global int* out, local int* ptr) {
+  *out = __builtin_amdgcn_ds_consume(ptr);
+}
+
 // CHECK-DAG: [[$WI_RANGE]] = !{i32 0, i32 1024}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[$READ_EXEC_ATTRS]] = { convergent }
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -12478,6 +12478,14 @@
   case AMDGPU::BI__builtin_amdgcn_fmed3f:
   case AMDGPU::BI__builtin_amdgcn_fmed3h:
 return emitTernaryBuiltin(*this, E, Intrinsic::amdgcn_fmed3);
+  case AMDGPU::BI__builtin_amdgcn_ds_append:
+  case AMDGPU::BI__builtin_amdgcn_ds_consume: {
+Intrinsic::ID Intrin = BuiltinID == AMDGPU::BI__builtin_amdgcn_ds_append ?
+  Intrinsic::amdgcn_ds_append : Intrinsic::amdgcn_ds_consume;
+Value *Src0 = EmitScalarExpr(E->getArg(0));
+Function *F = CGM.getIntrinsic(Intrin, { Src0->getType() });
+return Builder.CreateCall(F, { Src0, Builder.getFalse() });
+  }
   case AMDGPU::BI__builtin_amdgcn_read_exec: {
 CallInst *CI = cast(
   EmitSpecialRegisterBuiltin(*this, E, Int64Ty, Int64Ty, true, "exec"));
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -98,6 +98,8 @@
 BUILTIN(__builtin_amdgcn_ds_faddf, "ff*3fIiIiIb", "n")
 BUILTIN(__builtin_amdgcn_ds_fminf, "ff*3fIiIiIb", "n")
 BUILTIN(__builtin_amdgcn_ds_fmaxf, "ff*3fIiIiIb"

[PATCH] D56936: Fix handling of overriden methods during ASTImport

2019-01-28 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor accepted this revision.
teemperor added a comment.

LGTM, thanks!




Comment at: unittests/AST/ASTImporterTest.cpp:2271
+struct D:B { void f(){}; };
+  )";
+  auto BFP =

I think this should be formatted in the same way as the snippet above.



Comment at: unittests/AST/ASTImporterTest.cpp:2344
+  // Check that the redecl chain is intact.
+  EXPECT_EQ(ToBFOutOfClass->getPreviousDecl(), ToBFInClass);
+}

I'm actually wondering if we should do a full redecl chain check in the 
ASTImporter tests. E.g. iterating from the most recent decl and just make sure 
our redecl chain invariants are met (first one returns null and all 
getMostRecentDecl() calls returns the same decl). i assume usually this is 
implicitly done when we code gen or so, but this doesn't happen in the 
ASTImporter tests.


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

https://reviews.llvm.org/D56936



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


[PATCH] D57349: AMDGPU: Add ds append/consume builtins

2019-01-28 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec accepted this revision.
rampitec added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D57349



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


[PATCH] D56723: [CodeComplete] Propagate preferred types through parser in more cases

2019-01-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.



Comment at: lib/Sema/SemaCodeComplete.cpp:373
+}
+Type = QualType();
+  });

ilya-biryukov wrote:
> kadircet wrote:
> > nit: maybe move this into top and get rid of the return statements inside 
> > `if`s(also by changing them to `else if`s)
> FWIW I find ifs with return to be more readable than a bunch of if+else 
> statements. The reason is that return clearly states function is done, while 
> trailing `else` suggests it will go further.
> 
> But this particular function is short, so it's not a strong argument, can 
> change it if you insist.
On a second thought, I think my approach makes it uglier. The function is 
small, so the added "return R" everywhere only make it uglier.

Changed the code per your suggestions, thanks!


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

https://reviews.llvm.org/D56723



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


[PATCH] D56723: [CodeComplete] Propagate preferred types through parser in more cases

2019-01-28 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 183937.
ilya-biryukov added a comment.

- Use 'else if' to simplify the code


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

https://reviews.llvm.org/D56723

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/unittests/Sema/CodeCompleteTest.cpp

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -339,4 +339,103 @@
   EXPECT_THAT(collectPreferredTypes(Code), Each("NULL TYPE"));
 }
 
+TEST(PreferredTypeTest, Members) {
+  StringRef Code = R"cpp(
+struct vector {
+  int *begin();
+  vector clone();
+};
+
+void test(int *a) {
+  a = ^vector().^clone().^begin();
+}
+  )cpp";
+  EXPECT_THAT(collectPreferredTypes(Code), Each("int *"));
+}
+
+TEST(PreferredTypeTest, Conditions) {
+  StringRef Code = R"cpp(
+struct vector {
+  bool empty();
+};
+
+void test() {
+  if (^vector().^empty()) {}
+  while (^vector().^empty()) {}
+  for (; ^vector().^empty();) {}
+}
+  )cpp";
+  EXPECT_THAT(collectPreferredTypes(Code), Each("_Bool"));
+}
+
+TEST(PreferredTypeTest, InitAndAssignment) {
+  StringRef Code = R"cpp(
+struct vector {
+  int* begin();
+};
+
+void test() {
+  const int* x = ^vector().^begin();
+  x = ^vector().^begin();
+
+  if (const int* y = ^vector().^begin()) {}
+}
+  )cpp";
+  EXPECT_THAT(collectPreferredTypes(Code), Each("const int *"));
+}
+
+TEST(PreferredTypeTest, UnaryExprs) {
+  StringRef Code = R"cpp(
+void test(long long a) {
+  a = +^a;
+  a = -^a
+  a = ++^a;
+  a = --^a;
+}
+  )cpp";
+  EXPECT_THAT(collectPreferredTypes(Code), Each("long long"));
+
+  Code = R"cpp(
+void test(int a, int *ptr) {
+  !^a;
+  !^ptr;
+  !!!^a;
+
+  a = !^a;
+  a = !^ptr;
+  a = !!!^a;
+}
+  )cpp";
+  EXPECT_THAT(collectPreferredTypes(Code), Each("_Bool"));
+
+  Code = R"cpp(
+void test(int a) {
+  const int* x = &^a;
+}
+  )cpp";
+  EXPECT_THAT(collectPreferredTypes(Code), Each("const int"));
+
+  Code = R"cpp(
+void test(int *a) {
+  int x = *^a;
+  int &r = *^a;
+}
+  )cpp";
+  EXPECT_THAT(collectPreferredTypes(Code), Each("int *"));
+
+  Code = R"cpp(
+void test(int a) {
+  *^a;
+  &^a;
+}
+
+  )cpp";
+}
+
+TEST(PreferredTypeTest, ParenExpr) {
+  StringRef Code = R"cpp(
+const int *i = ^(^(^(^10)));
+  )cpp";
+  EXPECT_THAT(collectPreferredTypes(Code), Each("const int *"));
+}
 } // namespace
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -347,6 +347,205 @@
 };
 } // namespace
 
+PreferredTypeBuilder::RestoreRAII
+PreferredTypeBuilder::enterReturn(Sema &S, SourceLocation Tok) {
+  RestoreRAII R(*this);
+  if (isa(S.CurContext)) {
+if (sema::BlockScopeInfo *BSI = S.getCurBlock()) {
+  Type = BSI->ReturnType;
+  ExpectedLoc = Tok;
+}
+  } else if (const auto *Function = dyn_cast(S.CurContext)) {
+Type = Function->getReturnType();
+ExpectedLoc = Tok;
+  } else if (const auto *Method = dyn_cast(S.CurContext)) {
+Type = Method->getReturnType();
+ExpectedLoc = Tok;
+  }
+  return R;
+}
+
+PreferredTypeBuilder::RestoreRAII
+PreferredTypeBuilder::enterVariableInit(SourceLocation Tok, Decl *D) {
+  RestoreRAII R(*this);
+  auto *VD = llvm::dyn_cast_or_null(D);
+  Type = VD ? VD->getType() : QualType();
+  ExpectedLoc = Tok;
+  return R;
+}
+
+PreferredTypeBuilder::RestoreRAII
+PreferredTypeBuilder::enterParenExpr(SourceLocation Tok,
+ SourceLocation LParLoc) {
+  RestoreRAII R(*this);
+  // expected type for parenthesized expression does not change.
+  if (ExpectedLoc == LParLoc)
+ExpectedLoc = Tok;
+  return R;
+}
+
+static QualType getPreferredTypeOfBinaryRHS(Sema &S, Expr *LHS,
+tok::TokenKind Op) {
+  if (!LHS)
+return QualType();
+
+  QualType LHSType = LHS->getType();
+  if (LHSType->isPointerType()) {
+if (Op == tok::plus || Op == tok::plusequal || Op == tok::minusequal)
+  return S.getASTContext().getPointerDiffType();
+// Pointer difference is more common than subtracting an int from a pointer.
+if (Op == tok::minus)
+  return LHSType;
+  }
+
+  switch (Op) {
+  // No way to infer the type of RHS from LHS.
+  case tok::comma:
+return QualType();
+  // Prefer the type of the left operand for all of these.
+  // Arithmetic operations.
+  case tok::plus:
+  case tok::plus

r352421 - [OPENMP][NVPTX]Emit service debug variable for NVPTX.

2019-01-28 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Jan 28 12:03:02 2019
New Revision: 352421

URL: http://llvm.org/viewvc/llvm-project?rev=352421&view=rev
Log:
[OPENMP][NVPTX]Emit service debug variable for NVPTX.

In case of the empty module, the ptxas tool may emit error message about
empty debug info sections. This patch fixes this bug.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=352421&r1=352420&r2=352421&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Jan 28 12:03:02 2019
@@ -4494,6 +4494,20 @@ static std::pair get
 }
 
 void CGOpenMPRuntimeNVPTX::clear() {
+  if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
+if (CGM.getCodeGenOpts().getDebugInfo() >=
+codegenoptions::LimitedDebugInfo) {
+  ASTContext &C = CGM.getContext();
+  auto *VD = VarDecl::Create(
+  C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(),
+  &C.Idents.get("_$_"), C.IntTy, /*TInfo=*/nullptr, SC_Static);
+  auto *Var = cast(
+  CGM.CreateRuntimeVariable(CGM.IntTy, "_$_"));
+  Var->setInitializer(llvm::ConstantInt::getNullValue(CGM.IntTy));
+  Var->setLinkage(llvm::GlobalVariable::CommonLinkage);
+  CGM.addCompilerUsedGlobal(Var);
+  DI->EmitGlobalVariable(Var, VD);
+}
   if (!GlobalizedRecords.empty()) {
 ASTContext &C = CGM.getContext();
 llvm::SmallVector GlobalRecs;

Modified: cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp?rev=352421&r1=352420&r2=352421&view=diff
==
--- cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp Mon Jan 28 
12:03:02 2019
@@ -16,6 +16,7 @@ struct TT {
 // TCHECK:  [[TT:%.+]] = type { i64, i8 }
 // TCHECK:  [[S1:%.+]] = type { double }
 
+// TCHECK: @{{.*}}_$_{{.*}} = common global i32 0, !dbg !{{[0-9]+}}
 int foo(int n, double *ptr) {
   int a = 0;
   short aa = 0;


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


[PATCH] D53329: Generate DIFile with main program if source is not available

2019-01-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D53329#1373799 , @yonghong-song 
wrote:

> @dblaikie As I mentioned in one of my earlier comments, after some analysis, 
> I think this patch definitely not the right way to fix the problem. We just 
> cannot default to the main file if the DIFile source is not available.
>
> I have a bug filed for the same issue 
> (https://bugs.llvm.org/show_bug.cgi?id=40170) Maybe I should close this patch 
> and put the information on the bug report. Do you agree?


Ah, I understand now - thanks for explaining. Yeah, if you feel like this patch 
isn't the right direction, please mark it "abandoned" & if you're not sure how 
to proceed, probably worth having some discussion on the bug or in an llvm-dev 
thread. (or if you're not sure you have the bandwidth to continue - yeah, 
documenting in the bug anything we've learned so you/someone else can pick it 
up another time would be great)

Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D53329



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


[PATCH] D57353: [clang-tidy] Add the abseil-duration-double-conversion check

2019-01-28 Thread Hyrum Wright via Phabricator via cfe-commits
hwright created this revision.
hwright added reviewers: hokein, JonasToth, aaron.ballman.
hwright added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57353

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationDoubleConversionCheck.cpp
  clang-tidy/abseil/DurationDoubleConversionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-duration-double-conversion.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/absl/time/time.h
  test/clang-tidy/abseil-duration-double-conversion.cpp

Index: test/clang-tidy/abseil-duration-double-conversion.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-duration-double-conversion.cpp
@@ -0,0 +1,69 @@
+// RUN: %check_clang_tidy %s abseil-duration-double-conversion %t -- -- -I%S/Inputs
+
+#include "absl/time/time.h"
+
+void f() {
+  absl::Duration d1, d2;
+
+  // Floating point
+  d2 = absl::Hours(absl::ToDoubleHours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Minutes(absl::ToDoubleMinutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Seconds(absl::ToDoubleSeconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Milliseconds(absl::ToDoubleMilliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Microseconds(absl::ToDoubleMicroseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Nanoseconds(absl::ToDoubleNanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+
+  // Integer point
+  d2 = absl::Hours(absl::ToInt64Hours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Minutes(absl::ToInt64Minutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Seconds(absl::ToInt64Seconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Milliseconds(absl::ToInt64Milliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Microseconds(absl::ToInt64Microseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+  d2 = absl::Nanoseconds(absl::ToInt64Nanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: d1
+
+  // As macro argument
+#define PLUS_FIVE_S(x) x + absl::Seconds(5)
+  d2 = PLUS_FIVE_S(absl::Seconds(absl::ToInt64Seconds(d1)));
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: remove double conversion of absl::Duration [abseil-duration-double-conversion]
+  // CHECK-FIXES: PLUS_FIVE_S(d1)
+#undef PLUS_FIVE_S
+
+  // Split by macro: should not change
+#define TOSECONDS(x) absl::Seconds(x)
+  d2 = TOSECONDS(absl::ToInt64Seconds(d1));
+#undef TOSECONDS
+
+  // Don't change something inside a macro definition
+#define VALUE(x) absl::Hours(absl::ToInt64Hours(x));
+  d2 = VALUE(d1);
+#undef VALUE
+
+  // These should not match
+  d2 = absl::Seconds(absl::ToDoubleMilliseconds(d1));
+  d2 = absl::Seconds(4);
+  int i = absl::ToInt64Milliseconds(d1);
+}
Index: test/clang-tidy/Inputs/absl/time/time.h
===
--- test/clang-tidy/Inputs/absl/time/time.h
+++ test/clang-tidy/Inputs/absl/time/time.h
@@ -14,6 +14,8 @@
   Duration &operator/=(float r);
   Duration &operator/=(double r);
   template  Duration &operator/=(T r);
+
+  Duration &operator+(Duration d);
 };
 
 template  Duration operator*(Duration lhs, T rhs);
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -8,6 +8,7 @@
abseil-duration-comparison
abseil-duration-conversion-cast
abseil-duration-division
+   abseil-duration-doubl

[libunwind] r352427 - Revert "[libunwind] Drop the dependency on , add placement new inline"

2019-01-28 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Jan 28 12:55:12 2019
New Revision: 352427

URL: http://llvm.org/viewvc/llvm-project?rev=352427&view=rev
Log:
Revert "[libunwind] Drop the dependency on , add placement new 
inline"

This reverts commit r352384: this broke on ARM as UnwindCursor.hpp
still has some C++ library dependencies.

Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/src/Unwind-seh.cpp
libunwind/trunk/src/UnwindCursor.hpp
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=352427&r1=352426&r2=352427&view=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Mon Jan 28 12:55:12 2019
@@ -287,9 +287,6 @@ unwind_append_if(LIBUNWIND_CXX_FLAGS LIB
 
 unwind_append_if(LIBUNWIND_C_FLAGS LIBUNWIND_HAS_FUNWIND_TABLES 
-funwind-tables)
 
-# Ensure that we don't depend on C++ standard library.
-unwind_append_if(LIBUNWIND_CXX_FLAGS LIBUNWIND_HAS_NOSTDINCXX_FLAG -nostdinc++)
-
 # Assert
 string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
 if (LIBUNWIND_ENABLE_ASSERTIONS)
@@ -344,6 +341,28 @@ endif()
 
 include_directories(include)
 
+find_path(
+  LIBUNWIND_LIBCXX_INCLUDES_INTERNAL
+  __libcpp_version
+  PATHS ${LLVM_MAIN_SRC_DIR}/projects/libcxx/include
+${LLVM_MAIN_SRC_DIR}/runtimes/libcxx/include
+${LLVM_MAIN_SRC_DIR}/../libcxx/include
+  NO_DEFAULT_PATH
+  NO_CMAKE_FIND_ROOT_PATH
+  )
+if ((NOT LIBUNWIND_STANDALONE_BUILD OR HAVE_LIBCXX) AND
+IS_DIRECTORY "${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
+  set(LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT 
"${LIBUNWIND_LIBCXX_INCLUDES_INTERNAL}")
+endif()
+
+set(LIBUNWIND_CXX_INCLUDE_PATHS "${LIBUNWIND_CXX_INCLUDE_PATHS_DEFAULT}" CACHE 
PATH
+"Paths to C++ header directories separated by ';'.")
+
+if (NOT LIBUNWIND_CXX_INCLUDE_PATHS STREQUAL "")
+  list(APPEND LIBUNWIND_CXX_FLAGS -nostdinc++)
+  include_directories("${LIBUNWIND_CXX_INCLUDE_PATHS}")
+endif()
+
 add_subdirectory(src)
 
 if (LIBUNWIND_INCLUDE_DOCS)

Modified: libunwind/trunk/src/Unwind-seh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-seh.cpp?rev=352427&r1=352426&r2=352427&view=diff
==
--- libunwind/trunk/src/Unwind-seh.cpp (original)
+++ libunwind/trunk/src/Unwind-seh.cpp Mon Jan 28 12:55:12 2019
@@ -49,10 +49,6 @@ using namespace libunwind;
 /// Class of foreign exceptions based on unrecognized SEH exceptions.
 static const uint64_t kSEHExceptionClass = 0x434C4E4753454800; // CLNGSEH\0
 
-// libunwind does not and should not depend on C++ library which means that we
-// need our own declaration of global placement new.
-void *operator new(size_t, void*);
-
 /// Exception cleanup routine used by \c _GCC_specific_handler to
 /// free foreign exceptions.
 static void seh_exc_cleanup(_Unwind_Reason_Code urc, _Unwind_Exception *exc) {

Modified: libunwind/trunk/src/UnwindCursor.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindCursor.hpp?rev=352427&r1=352426&r2=352427&view=diff
==
--- libunwind/trunk/src/UnwindCursor.hpp (original)
+++ libunwind/trunk/src/UnwindCursor.hpp Mon Jan 28 12:55:12 2019
@@ -11,6 +11,7 @@
 #ifndef __UNWINDCURSOR_HPP__
 #define __UNWINDCURSOR_HPP__
 
+#include 
 #include 
 #include 
 #include 

Modified: libunwind/trunk/src/libunwind.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/libunwind.cpp?rev=352427&r1=352426&r2=352427&view=diff
==
--- libunwind/trunk/src/libunwind.cpp (original)
+++ libunwind/trunk/src/libunwind.cpp Mon Jan 28 12:55:12 2019
@@ -11,6 +11,10 @@
 
 #include 
 
+#ifndef NDEBUG
+#include  // getenv
+#endif
+
 #include "libunwind_ext.h"
 #include "config.h"
 
@@ -23,10 +27,6 @@
 
 using namespace libunwind;
 
-// libunwind does not and should not depend on C++ library which means that we
-// need our own declaration of global placement new.
-void *operator new(size_t, void*);
-
 /// internal object to represent this processes address space
 LocalAddressSpace LocalAddressSpace::sThisAddressSpace;
 


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


[PATCH] D57114: Remove Expr sugar decorating the CXXUuidofExpr node.

2019-01-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks for following up!


Repository:
  rC Clang

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

https://reviews.llvm.org/D57114



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


  1   2   >