[PATCH] D62115: fix a issue that clang is incompatible with gcc with -H option.

2019-05-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/Frontend/HeaderIncludeGen.cpp:55
+  // Simplify Filename that starts with "./"
+  if (Filename.startswith("./"));
+Filename=Filename.substr(2);

skan wrote:
> craig.topper wrote:
> > skan wrote:
> > > lebedev.ri wrote:
> > > > xiangzhangllvm wrote:
> > > > > Need remove ";" ? 
> > > > This was fixed but no test was added?
> > > > Was some existing test failing previously? Which one?
> > > The test is in the file 'clang_H_opt.c'  which is included in this patch.
> > The extra semicolon would have caused the body of the 'if' to execute 
> > unconditionally. Did any existing test case fail for that in your local 
> > testing? Or did you not test with that mistake?
> i fixed the mistake in the updated patch.  I ran the test in 'clang_H_opt.c' 
> alone for this patch. The extra semicolon caused the body of `if` to exeute 
> always, which didn't cause the test to fail. 
> The extra semicolon caused the body of if to exeute always, which didn't 
> cause the test to fail.

That is the question.
Is there test coverage with that error?


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

https://reviews.llvm.org/D62115



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


[PATCH] D60763: Prototype OpenCL BIFs using Tablegen

2019-05-21 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin added inline comments.



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:298-302
+def write_imagef : Builtin<"write_imagef",
+[void_t,
+  image2d_WO_t,
+  VectorType,
+  VectorType]>;

It seems like there is something wrong with access qualifiers for images. I 
have applied this patch and tried to compile the following code:

```
typedef int int2 __attribute__((ext_vector_type(2)));
typedef float float4 __attribute__((ext_vector_type(4)));

void kernel k(write_only image2d_t image, int2 coord, float4 data) {
  write_imagef(image, coord, data);
}

```
I got the following output:
```
clang -cc1 -triple spir /work/tmp/tmp.cl -emit-llvm -o -  -fadd-opencl-builtins
/work/tmp/tmp.cl:5:16: error: passing '__write_only image2d_t' to parameter of 
incompatible type '__read_only image2d_t'
  write_imagef(image, coord, data);
 ^
1 error generated.
```


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

https://reviews.llvm.org/D60763



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


[clang-tools-extra] r361225 - [clang-tidy] New option for misc-throw-by-value-catch-by-reference

2019-05-21 Thread Adam Balogh via cfe-commits
Author: baloghadamsoftware
Date: Tue May 21 00:25:06 2019
New Revision: 361225

URL: http://llvm.org/viewvc/llvm-project?rev=361225&view=rev
Log:
[clang-tidy] New option for misc-throw-by-value-catch-by-reference

Catching trivial objects by value is not dangerous but may be
inefficient if they are too large. This patch adds an option
`WarnOnLargeObject` to the checker to also warn if such an object
is caught by value. An object is considered as "large" if its
size is greater than `MaxSize` which is another option. Default
value is the machine word of the architecture (size of the type
`size_t`).

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


Modified:

clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp?rev=361225&r1=361224&r2=361225&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp 
Tue May 21 00:25:06 2019
@@ -20,7 +20,10 @@ namespace misc {
 ThrowByValueCatchByReferenceCheck::ThrowByValueCatchByReferenceCheck(
 StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  CheckAnonymousTemporaries(Options.get("CheckThrowTemporaries", true)) {}
+  CheckAnonymousTemporaries(Options.get("CheckThrowTemporaries", true)),
+  WarnOnLargeObject(Options.get("WarnOnLargeObject", false)),
+  // Cannot access `ASTContext` from here so set it to an extremal value.
+  MaxSize(Options.get("MaxSize", std::numeric_limits::max())) {}
 
 void ThrowByValueCatchByReferenceCheck::registerMatchers(MatchFinder *Finder) {
   // This is a C++ only check thus we register the matchers only for C++
@@ -150,8 +153,19 @@ void ThrowByValueCatchByReferenceCheck::
 // If it's not a pointer and not a reference then it must be caught "by
 // value". In this case we should emit a diagnosis message unless the type
 // is trivial.
-if (!caughtType.isTrivialType(context))
+if (!caughtType.isTrivialType(context)) {
   diag(varDecl->getBeginLoc(), diagMsgCatchReference);
+} else if (WarnOnLargeObject) {
+  // If the type is trivial, then catching it by reference is not 
dangerous.
+  // However, catching large objects by value decreases the performance.
+
+  // We can now access `ASTContext` so if `MaxSize` is an extremal value
+  // then set it to the size of `size_t`.
+  if (MaxSize == std::numeric_limits::max())
+MaxSize = context.getTypeSize(context.getSizeType());
+  if (context.getTypeSize(caughtType) > MaxSize)
+diag(varDecl->getBeginLoc(), diagMsgCatchReference);
+}
   }
 }
 

Modified: 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h?rev=361225&r1=361224&r2=361225&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h 
Tue May 21 00:25:06 2019
@@ -41,6 +41,8 @@ private:
   bool isCatchVariable(const DeclRefExpr *declRefExpr);
   bool isFunctionOrCatchVar(const DeclRefExpr *declRefExpr);
   const bool CheckAnonymousTemporaries;
+  const bool WarnOnLargeObject;
+  uint64_t MaxSize; // No `const` because we have to set it in two steps.
 };
 
 } // namespace misc

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=361225&r1=361224&r2=361225&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Tue May 21 00:25:06 2019
@@ -170,6 +170,11 @@ Improvements to clang-tidy
 
   Rewrites function signatures to use a trailing return type.
 
+- The :doc:`misc-throw-by-value-catch-by-reference
+  ` now supports
+  `WarnOnLargeObject` and `MaxSize` options to warn on any large trivial
+  object caught by value.
+
 Improvements to include-fixer
 -
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-thro

[PATCH] D61851: [clang-tidy] New option for misc-throw-by-value-catch-by-reference

2019-05-21 Thread Balogh, Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361225: [clang-tidy] New option for 
misc-throw-by-value-catch-by-reference (authored by baloghadamsoftware, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61851?vs=200266&id=200414#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61851

Files:
  clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst


Index: 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
+++ clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.h
@@ -41,6 +41,8 @@
   bool isCatchVariable(const DeclRefExpr *declRefExpr);
   bool isFunctionOrCatchVar(const DeclRefExpr *declRefExpr);
   const bool CheckAnonymousTemporaries;
+  const bool WarnOnLargeObject;
+  uint64_t MaxSize; // No `const` because we have to set it in two steps.
 };
 
 } // namespace misc
Index: 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
@@ -20,7 +20,10 @@
 ThrowByValueCatchByReferenceCheck::ThrowByValueCatchByReferenceCheck(
 StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  CheckAnonymousTemporaries(Options.get("CheckThrowTemporaries", true)) {}
+  CheckAnonymousTemporaries(Options.get("CheckThrowTemporaries", true)),
+  WarnOnLargeObject(Options.get("WarnOnLargeObject", false)),
+  // Cannot access `ASTContext` from here so set it to an extremal value.
+  MaxSize(Options.get("MaxSize", std::numeric_limits::max())) {}
 
 void ThrowByValueCatchByReferenceCheck::registerMatchers(MatchFinder *Finder) {
   // This is a C++ only check thus we register the matchers only for C++
@@ -150,8 +153,19 @@
 // If it's not a pointer and not a reference then it must be caught "by
 // value". In this case we should emit a diagnosis message unless the type
 // is trivial.
-if (!caughtType.isTrivialType(context))
+if (!caughtType.isTrivialType(context)) {
   diag(varDecl->getBeginLoc(), diagMsgCatchReference);
+} else if (WarnOnLargeObject) {
+  // If the type is trivial, then catching it by reference is not 
dangerous.
+  // However, catching large objects by value decreases the performance.
+
+  // We can now access `ASTContext` so if `MaxSize` is an extremal value
+  // then set it to the size of `size_t`.
+  if (MaxSize == std::numeric_limits::max())
+MaxSize = context.getTypeSize(context.getSizeType());
+  if (context.getTypeSize(caughtType) > MaxSize)
+diag(varDecl->getBeginLoc(), diagMsgCatchReference);
+}
   }
 }
 
Index: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
===
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-throw-by-value-catch-by-reference.rst
@@ -32,3 +32,18 @@

`_.
Default is `1`.
 
+.. option:: WarnOnLargeObject
+
+   Also warns for any large, trivial object caught by value. Catching a large
+   object by value is not dangerous but affects the performance negatively. The
+   maximum size of an object allowed to be caught without warning can be set
+   using the `MaxSize` option.
+   Default is `0`.
+
+.. option:: MaxSize
+
+   Determines the maximum size of an object allowed to be caught without
+   warning. Only applicable if `WarnOnLargeObject` is set to `1`. If option is
+   set by the user to `std::numeric_limits::max()` then it reverts to
+   the default value.
+   Default is the size of `size_t`.
Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -170,6 +170,11 @@
 
   Rewrites function signatures to use a trailing return type.
 
+- The :doc:`misc-throw-by-value-catch-by-reference
+  ` now supports
+  `WarnOnLargeObject` and `MaxSize` options to warn on any large trivial
+  object caught by value.

r361226 - [Preamble] Reuse preamble even if an unsaved file does not exist

2019-05-21 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Tue May 21 00:26:59 2019
New Revision: 361226

URL: http://llvm.org/viewvc/llvm-project?rev=361226&view=rev
Log:
[Preamble] Reuse preamble even if an unsaved file does not exist

When a preamble is created an unsaved file not existing on disk is
already part of PrecompiledPreamble::FilesInPreamble. However, when
checking whether the preamble can be re-used, a failed stat of such an
unsaved file invalidated the preamble, which led to pointless and time
consuming preamble regenerations on subsequent reparses.

Do not require anymore that unsaved files should exist on disk.

This avoids costly preamble invalidations depending on timing issues for
the cases where the file on disk might be removed just to be regenerated
a bit later.

It also allows an IDE to provide in-memory files that might not exist on
disk, e.g. because the build system hasn't generated those yet.

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

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

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=361226&r1=361225&r2=361226&view=diff
==
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue May 21 00:26:59 2019
@@ -205,7 +205,10 @@ private:
   /// we'll attempt to rebuild the precompiled header. This way, if
   /// building the precompiled preamble fails, we won't try again for
   /// some number of calls.
-  unsigned PreambleRebuildCounter = 0;
+  unsigned PreambleRebuildCountdown = 0;
+
+  /// Counter indicating how often the preamble was build in total.
+  unsigned PreambleCounter = 0;
 
   /// Cache pairs "filename - source location"
   ///
@@ -574,6 +577,8 @@ public:
mapLocationToPreamble(R.getEnd()));
   }
 
+  unsigned getPreambleCounterForTests() const { return PreambleCounter; }
+
   // Retrieve the diagnostics associated with this AST
   using stored_diag_iterator = StoredDiagnostic *;
   using stored_diag_const_iterator = const StoredDiagnostic *;

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=361226&r1=361225&r2=361226&view=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Tue May 21 00:26:59 2019
@@ -1304,22 +1304,22 @@ ASTUnit::getMainBufferWithPrecompiledPre
 PreambleInvocationIn.getDiagnosticOpts());
   getDiagnostics().setNumWarnings(NumWarningsInPreamble);
 
-  PreambleRebuildCounter = 1;
+  PreambleRebuildCountdown = 1;
   return MainFileBuffer;
 } else {
   Preamble.reset();
   PreambleDiagnostics.clear();
   TopLevelDeclsInPreamble.clear();
   PreambleSrcLocCache.clear();
-  PreambleRebuildCounter = 1;
+  PreambleRebuildCountdown = 1;
 }
   }
 
   // If the preamble rebuild counter > 1, it's because we previously
   // failed to build a preamble and we're not yet ready to try
   // again. Decrement the counter and return a failure.
-  if (PreambleRebuildCounter > 1) {
---PreambleRebuildCounter;
+  if (PreambleRebuildCountdown > 1) {
+--PreambleRebuildCountdown;
 return nullptr;
   }
 
@@ -1329,6 +1329,8 @@ ASTUnit::getMainBufferWithPrecompiledPre
   if (!AllowRebuild)
 return nullptr;
 
+  ++PreambleCounter;
+
   SmallVector NewPreambleDiagsStandalone;
   SmallVector NewPreambleDiags;
   ASTUnitPreambleCallbacks Callbacks;
@@ -1356,18 +1358,18 @@ ASTUnit::getMainBufferWithPrecompiledPre
 
 if (NewPreamble) {
   Preamble = std::move(*NewPreamble);
-  PreambleRebuildCounter = 1;
+  PreambleRebuildCountdown = 1;
 } else {
   switch (static_cast(NewPreamble.getError().value())) 
{
   case BuildPreambleError::CouldntCreateTempFile:
 // Try again next time.
-PreambleRebuildCounter = 1;
+PreambleRebuildCountdown = 1;
 return nullptr;
   case BuildPreambleError::CouldntCreateTargetInfo:
   case BuildPreambleError::BeginSourceFileFailed:
   case BuildPreambleError::CouldntEmitPCH:
 // These erros are more likely to repeat, retry after some period.
-PreambleRebuildCounter = DefaultPreambleRebuildInterval;
+PreambleRebuildCountdown = DefaultPreambleRebuildInterval;
 return nullptr;
   }
   llvm_unreachable("unexpected BuildPreambleError");
@@ -1507,7 +1509,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvoca
   AST->OnlyLocalDecls = OnlyLocalDecls;
   AST->CaptureDiagnostics = CaptureDiagnostics;
   if (PrecompilePreambleAfterNParses > 0)
-AST->PreambleRebuildCounter = Prec

[PATCH] D41005: Reuse preamble even if an unsaved file does not exist

2019-05-21 Thread Nikolai Kosjar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361226: [Preamble] Reuse preamble even if an unsaved file 
does not exist (authored by nik, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41005?vs=198809&id=200415#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D41005

Files:
  include/clang/Frontend/ASTUnit.h
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/PrecompiledPreamble.cpp
  unittests/Frontend/PCHPreambleTest.cpp

Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -1304,22 +1304,22 @@
 PreambleInvocationIn.getDiagnosticOpts());
   getDiagnostics().setNumWarnings(NumWarningsInPreamble);
 
-  PreambleRebuildCounter = 1;
+  PreambleRebuildCountdown = 1;
   return MainFileBuffer;
 } else {
   Preamble.reset();
   PreambleDiagnostics.clear();
   TopLevelDeclsInPreamble.clear();
   PreambleSrcLocCache.clear();
-  PreambleRebuildCounter = 1;
+  PreambleRebuildCountdown = 1;
 }
   }
 
   // If the preamble rebuild counter > 1, it's because we previously
   // failed to build a preamble and we're not yet ready to try
   // again. Decrement the counter and return a failure.
-  if (PreambleRebuildCounter > 1) {
---PreambleRebuildCounter;
+  if (PreambleRebuildCountdown > 1) {
+--PreambleRebuildCountdown;
 return nullptr;
   }
 
@@ -1329,6 +1329,8 @@
   if (!AllowRebuild)
 return nullptr;
 
+  ++PreambleCounter;
+
   SmallVector NewPreambleDiagsStandalone;
   SmallVector NewPreambleDiags;
   ASTUnitPreambleCallbacks Callbacks;
@@ -1356,18 +1358,18 @@
 
 if (NewPreamble) {
   Preamble = std::move(*NewPreamble);
-  PreambleRebuildCounter = 1;
+  PreambleRebuildCountdown = 1;
 } else {
   switch (static_cast(NewPreamble.getError().value())) {
   case BuildPreambleError::CouldntCreateTempFile:
 // Try again next time.
-PreambleRebuildCounter = 1;
+PreambleRebuildCountdown = 1;
 return nullptr;
   case BuildPreambleError::CouldntCreateTargetInfo:
   case BuildPreambleError::BeginSourceFileFailed:
   case BuildPreambleError::CouldntEmitPCH:
 // These erros are more likely to repeat, retry after some period.
-PreambleRebuildCounter = DefaultPreambleRebuildInterval;
+PreambleRebuildCountdown = DefaultPreambleRebuildInterval;
 return nullptr;
   }
   llvm_unreachable("unexpected BuildPreambleError");
@@ -1507,7 +1509,7 @@
   AST->OnlyLocalDecls = OnlyLocalDecls;
   AST->CaptureDiagnostics = CaptureDiagnostics;
   if (PrecompilePreambleAfterNParses > 0)
-AST->PreambleRebuildCounter = PrecompilePreambleAfterNParses;
+AST->PreambleRebuildCountdown = PrecompilePreambleAfterNParses;
   AST->TUKind = Action ? Action->getTranslationUnitKind() : TU_Complete;
   AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults;
   AST->IncludeBriefCommentsInCodeCompletion
@@ -1641,7 +1643,7 @@
 
   std::unique_ptr OverrideMainBuffer;
   if (PrecompilePreambleAfterNParses > 0) {
-PreambleRebuildCounter = PrecompilePreambleAfterNParses;
+PreambleRebuildCountdown = PrecompilePreambleAfterNParses;
 OverrideMainBuffer =
 getMainBufferWithPrecompiledPreamble(PCHContainerOps, *Invocation, VFS);
 getDiagnostics().Reset();
@@ -1819,7 +1821,7 @@
   // If we have a preamble file lying around, or if we might try to
   // build a precompiled preamble, do so now.
   std::unique_ptr OverrideMainBuffer;
-  if (Preamble || PreambleRebuildCounter > 0)
+  if (Preamble || PreambleRebuildCountdown > 0)
 OverrideMainBuffer =
 getMainBufferWithPrecompiledPreamble(PCHContainerOps, *Invocation, VFS);
 
Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -454,20 +454,33 @@
 Status.getSize(), llvm::sys::toTimeT(Status.getLastModificationTime()));
   }
 
+  // OverridenFileBuffers tracks only the files not found in VFS.
+  llvm::StringMap OverridenFileBuffers;
   for (const auto &RB : PreprocessorOpts.RemappedFileBuffers) {
-llvm::vfs::Status Status;
-if (!moveOnNoError(VFS->status(RB.first), Status))
-  return false;
-
-OverriddenFiles[Status.getUniqueID()] =
+const PrecompiledPreamble::PreambleFileHash PreambleHash =
 PreambleFileHash::createForMemoryBuffer(RB.second);
+llvm::vfs::Status Status;
+if (moveOnNoError(VFS->status(RB.first), Status))
+  OverriddenFiles[Status.getUniqueID()] = PreambleHash;
+else
+  OverridenFileBuffers[RB.first] = PreambleHash;
   }
 
   // Check whether anything has changed.
   for (const auto &F : FilesInPreamble) {
+auto OverridenFileBuff

[PATCH] D62049: [clang-tidy] Add a close-on-exec check on pipe2() in Android module.

2019-05-21 Thread Stephen Hines via Phabricator via cfe-commits
srhines added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/android-cloexec-pipe2.rst:19
+
+  pipe2(pipefd, O_CLOEXEC);

Shouldn't this be "O_NONBLOCK | O_CLOEXEC" instead? Why drop the O_NONBLOCK?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62049



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


[PATCH] D61487: [clang-tidy] Make the plugin honor NOLINT

2019-05-21 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Ping.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61487



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


[PATCH] D61865: [clangd] improve help message for limit-results

2019-05-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61865



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


[PATCH] D53847: [C++2a] P0634r3: Down with typename!

2019-05-21 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 200423.
Rakete marked 10 inline comments as done.
Rakete added a comment.

- Addressed review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D53847

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/drs/dr4xx.cpp
  clang/test/CXX/drs/dr5xx.cpp
  clang/test/CXX/temp/temp.res/p5.cpp
  clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp
  clang/test/FixIt/fixit.cpp
  clang/test/Parser/cxx-member-initializers.cpp
  clang/test/Parser/editor-placeholder-recovery.cpp
  clang/test/SemaCXX/MicrosoftCompatibility.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/MicrosoftSuper.cpp
  clang/test/SemaCXX/unknown-type-name.cpp

Index: clang/test/SemaCXX/unknown-type-name.cpp
===
--- clang/test/SemaCXX/unknown-type-name.cpp
+++ clang/test/SemaCXX/unknown-type-name.cpp
@@ -36,15 +36,15 @@
 
   static int n;
   static type m;
-  static int h(T::type, int); // expected-error{{missing 'typename'}}
-  static int h(T::type x, char); // expected-error{{missing 'typename'}}
+  static int h(T::type, int); // expected-warning{{implicit 'typename' is a C++2a extension}}
+  static int h(T::type x, char); // expected-warning{{implicit 'typename' is a C++2a extension}}
 };
 
 template
-A::type g(T t) { return t; } // expected-error{{missing 'typename'}}
+A::type g(T t) { return t; } // expected-warning{{implicit 'typename' is a C++2a extension}}
 
 template
-A::type A::f() { return type(); } // expected-error{{missing 'typename'}}
+A::type A::f() { return type(); } // expected-warning{{implicit 'typename' is a C++2a extension}}
 
 template
 void f(T::type) { } // expected-error{{missing 'typename'}}
@@ -72,9 +72,7 @@
 
 int *p;
 
-// FIXME: We should assume that 'undeclared' is a type, not a parameter name
-//here, and produce an 'unknown type name' diagnostic instead.
-int f1(undeclared, int); // expected-error{{requires a type specifier}}
+int f1(undeclared, int); // expected-error{{unknown type name 'undeclared'}}
 
 int f2(undeclared, 0); // expected-error{{undeclared identifier}}
 
@@ -86,11 +84,11 @@
 
 template int A::n(T::value); // ok
 template
-A::type // expected-error{{missing 'typename'}}
+A::type // expected-warning {{implicit 'typename' is a C++2a extension}}
 A::m(T::value, 0); // ok
 
-template int A::h(T::type, int) {} // expected-error{{missing 'typename'}}
-template int A::h(T::type x, char) {} // expected-error{{missing 'typename'}}
+template int A::h(T::type, int) {} // expected-warning{{implicit 'typename' is a C++2a extension}}
+template int A::h(T::type x, char) {} // expected-warning{{implicit 'typename' is a C++2a extension}}
 
 template int h(T::type, int); // expected-error{{missing 'typename'}}
 template int h(T::type x, char); // expected-error{{missing 'typename'}}
@@ -118,4 +116,5 @@
 // FIXME: We know which type specifier should have been specified here. Provide
 //a fix-it to add 'typename A::type'
 template
-A::g() { } // expected-error{{requires a type specifier}}
+A::g() { } // expected-error{{expected unqualified-id}}
+// expected-warning@-1{{implicit 'typename' is a C++2a extension}}
Index: clang/test/SemaCXX/MicrosoftSuper.cpp
===
--- clang/test/SemaCXX/MicrosoftSuper.cpp
+++ clang/test/SemaCXX/MicrosoftSuper.cpp
@@ -108,8 +108,8 @@
   typename __super::XXX a;
   typedef typename __super::XXX b;
 
-  __super::XXX c; // expected-error {{missing 'typename'}}
-  typedef __super::XXX d; // expected-error {{missing 'typename'}}
+  __super::XXX c; // expected-warning {{implicit 'typename' is a C++2a extension}}
+  typedef __super::XXX d; // expected-warning {{implicit 'typename' is a C++2a extension}}
 
   void foo() {
 typename __super::XXX e;
@@ -127,8 +127,8 @@
   typename __super::XXX a;
   typedef typename __super::XXX b;
 
-  __super::XXX c; // expected-error {{missing 'typename'}}
-  typedef __super::XXX d; // expected-error {{missing 'typename'}}
+  __super::XXX c; // expected-warning {{implicit 'typename' is a C++2a extension}}
+  typedef __super::XXX d; // expected-warning {{implicit 'typename' is a C++2a extension}}
 
   void foo() {
 typename __super::XXX e;
Index: clang/test/SemaCXX/MicrosoftExtensions.cpp

[PATCH] D62151: [clangd] Add tweak to convert normal to raw string literal, when it contains escapes.

2019-05-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62151



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


[PATCH] D60672: [libclang] visit c++14 lambda capture init expressions

2019-05-21 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

> Are you sure you have compiled this patch? If I comment out the visit of the 
> InitExpr in CIndex.cpp again, then I get the same failure as you...

Huch, I've indeed somehow missed to compile. Sorry for that. Works fine after 
compilation :)

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60672



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


[PATCH] D53847: [C++2a] P0634r3: Down with typename!

2019-05-21 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete marked an inline comment as done.
Rakete added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:4859
 // recurse to handle whatever we get.
-if (TryAnnotateTypeOrScopeToken())
+if (TryAnnotateTypeOrScopeToken(!getCurScope()->isTemplateParamScope()))
   return true;

rsmith wrote:
> This seems surprising to me; I'd expect to have an implicit `typename` here 
> approximately when not `DisambiguatingWithExpression`. Also basing this off 
> the scope seems wrong, as we can switch into and out of implicit `typename` 
> contexts multiple times within a scope. Eg, in `template T::template U>` we get an implicit `typename` for `T::template U` but 
> not for `T::V` despite them being in the same scope.
> 
> Should the callers of this function be passing in an "implicit `typename`" 
> flag?
Seems like `template >` isn't accepted as a 
context with an implicit typename (for the `T::template`). I'll look into it :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D53847



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


[PATCH] D60672: [libclang] visit c++14 lambda capture init expressions

2019-05-21 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

Do you have commit rights? Can you push that for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60672



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


r361234 - [libclang] visit c++14 lambda capture init expressions

2019-05-21 Thread Nikolai Kosjar via cfe-commits
Author: nik
Date: Tue May 21 02:21:35 2019
New Revision: 361234

URL: http://llvm.org/viewvc/llvm-project?rev=361234&view=rev
Log:
[libclang] visit c++14 lambda capture init expressions

Patch by Milian Wolff.

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

Added:
cfe/trunk/test/Index/cxx14-lambdas.cpp
Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Added: cfe/trunk/test/Index/cxx14-lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/cxx14-lambdas.cpp?rev=361234&view=auto
==
--- cfe/trunk/test/Index/cxx14-lambdas.cpp (added)
+++ cfe/trunk/test/Index/cxx14-lambdas.cpp Tue May 21 02:21:35 2019
@@ -0,0 +1,38 @@
+// Test is line- and column-sensitive; see below.
+
+typedef int Integer;
+struct X {
+  void f() {
+int localA, localB;
+auto lambda = [ptr = &localA, copy = localB] (Integer x) -> Integer {
+  return *ptr + copy + x;
+};
+  }
+};
+
+// RUN: c-index-test -test-load-source all -std=c++14 %s | FileCheck 
-check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx14-lambdas.cpp:7:5: DeclStmt= Extent=[7:5 - 9:7]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:10: VarDecl=lambda:7:10 (Definition) 
Extent=[7:5 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: UnexposedExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: CallExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: UnexposedExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: LambdaExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:20: VariableRef=ptr:7:20 Extent=[7:20 - 
7:23]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:35: VariableRef=copy:7:35 Extent=[7:35 - 
7:39]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:27: DeclRefExpr=localA:6:9 Extent=[7:27 - 
7:33]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:42: DeclRefExpr=localB:6:17 Extent=[7:42 - 
7:48]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:59: ParmDecl=x:7:59 (Definition) 
Extent=[7:51 - 7:60]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:51: TypeRef=Integer:3:13 Extent=[7:51 - 
7:58]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:65: TypeRef=Integer:3:13 Extent=[7:65 - 
7:72]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:73: CompoundStmt= Extent=[7:73 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:8:7: ReturnStmt= Extent=[8:7 - 8:29]
+
+// RUN: env CINDEXTEST_INDEXLOCALSYMBOLS=1 c-index-test -index-file -std=c++14 
%s | FileCheck -check-prefix=CHECK-INDEX %s
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: ptr | USR: 
c:cxx14-lambdas.cpp@139@S@X@F@f#@Sa@F@operator()#I#1@ptr | lang: C | cursor: 
VariableRef=ptr:7:20 | loc: 7:20
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: copy | USR: 
c:cxx14-lambdas.cpp@154@S@X@F@f#@Sa@F@operator()#I#1@copy | lang: C | cursor: 
VariableRef=copy:7:35 | loc: 7:35
+// CHECK-INDEX: [indexDeclaration]: kind: variable | name: x | USR: 
c:cxx14-lambdas.cpp@170@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: 
ParmDecl=x:7:59 (Definition) | loc: 7:59
+// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: 
c:cxx14-lambdas.cpp@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 
7:51
+// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: 
c:cxx14-lambdas.cpp@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 
7:65
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: ptr | USR: 
c:cxx14-lambdas.cpp@139@S@X@F@f#@Sa@F@operator()#I#1@ptr | lang: C | cursor: 
DeclRefExpr=ptr:7:20 | loc: 8:15
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: copy | USR: 
c:cxx14-lambdas.cpp@154@S@X@F@f#@Sa@F@operator()#I#1@copy | lang: C | cursor: 
DeclRefExpr=copy:7:35 | loc: 8:21
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: x | USR: 
c:cxx14-lambdas.cpp@170@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: 
DeclRefExpr=x:7:59 | loc: 8:28

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=361234&r1=361233&r2=361234&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Tue May 21 02:21:35 2019
@@ -3134,12 +3134,11 @@ bool CursorVisitor::RunVisitorWorkList(V
   }
 
   case VisitorJob::LambdaExprPartsKind: {
-// Visit captures.
+// Visit non-init captures.
 const LambdaExpr *E = cast(&LI)->get();
 for (LambdaExpr::capture_iterator C = E->explicit_capture_begin(),
CEnd = E->explicit_capture_end();
  C != CEnd; ++C) {
-  // FIXME: Lambda init-captures.
   if (!C->capturesVariable())
 continue;
 
@@ -3148,6 +3147,11 @@ bool CursorVisitor::RunVisitorWorkList(V
   TU)))
 return true;
 }
+// Visit init captures
+for (auto InitExpr : E->capture_inits()) {
+  if (Visit(

[PATCH] D60672: [libclang] visit c++14 lambda capture init expressions

2019-05-21 Thread Nikolai Kosjar via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361234: [libclang] visit c++14 lambda capture init 
expressions (authored by nik, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60672?vs=195077&id=200431#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D60672

Files:
  test/Index/cxx14-lambdas.cpp
  tools/libclang/CIndex.cpp


Index: test/Index/cxx14-lambdas.cpp
===
--- test/Index/cxx14-lambdas.cpp
+++ test/Index/cxx14-lambdas.cpp
@@ -0,0 +1,38 @@
+// Test is line- and column-sensitive; see below.
+
+typedef int Integer;
+struct X {
+  void f() {
+int localA, localB;
+auto lambda = [ptr = &localA, copy = localB] (Integer x) -> Integer {
+  return *ptr + copy + x;
+};
+  }
+};
+
+// RUN: c-index-test -test-load-source all -std=c++14 %s | FileCheck 
-check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx14-lambdas.cpp:7:5: DeclStmt= Extent=[7:5 - 9:7]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:10: VarDecl=lambda:7:10 (Definition) 
Extent=[7:5 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: UnexposedExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: CallExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: UnexposedExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:19: LambdaExpr= Extent=[7:19 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:20: VariableRef=ptr:7:20 Extent=[7:20 - 
7:23]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:35: VariableRef=copy:7:35 Extent=[7:35 - 
7:39]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:27: DeclRefExpr=localA:6:9 Extent=[7:27 - 
7:33]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:42: DeclRefExpr=localB:6:17 Extent=[7:42 - 
7:48]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:59: ParmDecl=x:7:59 (Definition) 
Extent=[7:51 - 7:60]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:51: TypeRef=Integer:3:13 Extent=[7:51 - 
7:58]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:65: TypeRef=Integer:3:13 Extent=[7:65 - 
7:72]
+// CHECK-LOAD: cxx14-lambdas.cpp:7:73: CompoundStmt= Extent=[7:73 - 9:6]
+// CHECK-LOAD: cxx14-lambdas.cpp:8:7: ReturnStmt= Extent=[8:7 - 8:29]
+
+// RUN: env CINDEXTEST_INDEXLOCALSYMBOLS=1 c-index-test -index-file -std=c++14 
%s | FileCheck -check-prefix=CHECK-INDEX %s
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: ptr | USR: 
c:cxx14-lambdas.cpp@139@S@X@F@f#@Sa@F@operator()#I#1@ptr | lang: C | cursor: 
VariableRef=ptr:7:20 | loc: 7:20
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: copy | USR: 
c:cxx14-lambdas.cpp@154@S@X@F@f#@Sa@F@operator()#I#1@copy | lang: C | cursor: 
VariableRef=copy:7:35 | loc: 7:35
+// CHECK-INDEX: [indexDeclaration]: kind: variable | name: x | USR: 
c:cxx14-lambdas.cpp@170@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: 
ParmDecl=x:7:59 (Definition) | loc: 7:59
+// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: 
c:cxx14-lambdas.cpp@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 
7:51
+// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | USR: 
c:cxx14-lambdas.cpp@T@Integer | lang: C | cursor: TypeRef=Integer:3:13 | loc: 
7:65
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: ptr | USR: 
c:cxx14-lambdas.cpp@139@S@X@F@f#@Sa@F@operator()#I#1@ptr | lang: C | cursor: 
DeclRefExpr=ptr:7:20 | loc: 8:15
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: copy | USR: 
c:cxx14-lambdas.cpp@154@S@X@F@f#@Sa@F@operator()#I#1@copy | lang: C | cursor: 
DeclRefExpr=copy:7:35 | loc: 8:21
+// CHECK-INDEX: [indexEntityReference]: kind: variable | name: x | USR: 
c:cxx14-lambdas.cpp@170@S@X@F@f#@Sa@F@operator()#I#1@x | lang: C | cursor: 
DeclRefExpr=x:7:59 | loc: 8:28
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -3134,12 +3134,11 @@
   }
 
   case VisitorJob::LambdaExprPartsKind: {
-// Visit captures.
+// Visit non-init captures.
 const LambdaExpr *E = cast(&LI)->get();
 for (LambdaExpr::capture_iterator C = E->explicit_capture_begin(),
CEnd = E->explicit_capture_end();
  C != CEnd; ++C) {
-  // FIXME: Lambda init-captures.
   if (!C->capturesVariable())
 continue;
 
@@ -3148,6 +3147,11 @@
   TU)))
 return true;
 }
+// Visit init captures
+for (auto InitExpr : E->capture_inits()) {
+  if (Visit(InitExpr))
+return true;
+}
 
 TypeLoc TL = E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
 // Visit parameters and return type, if present.


Index: test/Index/cxx14-lambdas.cpp
===

[PATCH] D50993: [clangd] Increase stack size of the new threads on macOS

2019-05-21 Thread Dmitry via Phabricator via cfe-commits
Dmitry.Kozhevnikov updated this revision to Diff 200432.
Dmitry.Kozhevnikov changed the repository for this revision from rCTE Clang 
Tools Extra to rG LLVM Github Monorepo.
Dmitry.Kozhevnikov added a comment.

moved to the monorepo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D50993

Files:
  clang-tools-extra/clangd/Threading.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp


Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -1154,6 +1154,27 @@
 Field(&CodeCompletion::Scope, "ns::";
 }
 
+TEST_F(ClangdVFSTest, TestStackOverflow) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  const auto SourceContents = R"cpp(
+constexpr int foo() { return foo(); }
+static_assert(foo());
+  )cpp";
+
+  auto FooCpp = testPath("foo.cpp");
+  FS.Files[FooCpp] = SourceContents;
+
+  Server.addDocument(FooCpp, SourceContents);
+  ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
+  // check that we got a constexpr depth error, and not crashed by stack
+  // overflow
+  EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Threading.cpp
===
--- clang-tools-extra/clangd/Threading.cpp
+++ clang-tools-extra/clangd/Threading.cpp
@@ -1,5 +1,6 @@
 #include "Threading.h"
 #include "Trace.h"
+#include "clang/Basic/Stack.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Threading.h"
@@ -84,16 +85,25 @@
 }
   });
 
-  std::thread(
-  [](std::string Name, decltype(Action) Action, decltype(CleanupTask)) {
-llvm::set_thread_name(Name);
-Action();
-// Make sure function stored by Action is destroyed before CleanupTask
-// is run.
-Action = nullptr;
-  },
-  Name.str(), std::move(Action), std::move(CleanupTask))
-  .detach();
+  // Manually capture Action and CleanupTask for the lack of C++14 generalized
+  // lambda captures
+  struct Callable {
+std::string ThreadName;
+decltype(Action) ThreadFunc;
+decltype(CleanupTask) Cleanup;
+
+void operator()() {
+  llvm::set_thread_name(ThreadName);
+  ThreadFunc();
+  // Make sure function stored by ThreadFunc is destroyed before Cleanup is
+  // run.
+  ThreadFunc = nullptr;
+}
+  };
+
+  llvm::llvm_execute_on_thread_async(
+  Callable{Name.str(), std::move(Action), std::move(CleanupTask)},
+  clang::DesiredStackSize);
 }
 
 Deadline timeoutSeconds(llvm::Optional Seconds) {


Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -1154,6 +1154,27 @@
 Field(&CodeCompletion::Scope, "ns::";
 }
 
+TEST_F(ClangdVFSTest, TestStackOverflow) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB;
+  ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+  const auto SourceContents = R"cpp(
+constexpr int foo() { return foo(); }
+static_assert(foo());
+  )cpp";
+
+  auto FooCpp = testPath("foo.cpp");
+  FS.Files[FooCpp] = SourceContents;
+
+  Server.addDocument(FooCpp, SourceContents);
+  ASSERT_TRUE(Server.blockUntilIdleForTest()) << "Waiting for diagnostics";
+  // check that we got a constexpr depth error, and not crashed by stack
+  // overflow
+  EXPECT_TRUE(DiagConsumer.hadErrorInLastDiags());
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/Threading.cpp
===
--- clang-tools-extra/clangd/Threading.cpp
+++ clang-tools-extra/clangd/Threading.cpp
@@ -1,5 +1,6 @@
 #include "Threading.h"
 #include "Trace.h"
+#include "clang/Basic/Stack.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Threading.h"
@@ -84,16 +85,25 @@
 }
   });
 
-  std::thread(
-  [](std::string Name, decltype(Action) Action, decltype(CleanupTask)) {
-llvm::set_thread_name(Name);
-Action();
-// Make sure function stored by Action is destroyed before CleanupTask
-// is run.
-Action = nullptr;
-  },
-  Name.str(), std::move(Action), std::move(CleanupTask))
-  .detach();
+  // Manually capture Action and CleanupTask for the lack of C++14 generalized

[PATCH] D48116: [libclang] Allow skipping warnings from all included files

2019-05-21 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik added a comment.

Jan?


Repository:
  rC Clang

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

https://reviews.llvm.org/D48116



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


[PATCH] D62064: [ASTImporter] Fix unhandled cases in ASTImporterLookupTable

2019-05-21 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:4259
 static const RecordDecl * getRecordDeclOfFriend(FriendDecl *FD) {
   QualType Ty = FD->getFriendType()->getType();
+  if (auto *Inner = dyn_cast(Ty.getTypePtr())) {

a_sidorin wrote:
> Will getCanonicalType() do the job?
That's a good catch! Thank you for pointing out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62064



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


[PATCH] D62064: [ASTImporter] Fix unhandled cases in ASTImporterLookupTable

2019-05-21 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 200435.
martong marked an inline comment as done.
martong added a comment.

- Remove getUnderlyingType


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62064

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTImporterLookupTable.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4248,11 +4248,16 @@
 
 static const RecordDecl * getRecordDeclOfFriend(FriendDecl *FD) {
   QualType Ty = FD->getFriendType()->getType();
-  QualType NamedTy = cast(Ty)->getNamedType();
-  return cast(NamedTy)->getDecl();
+  if (auto *Inner = dyn_cast(Ty.getTypePtr())) {
+Ty = Ty.getCanonicalType();
+  }
+  if (isa(Ty))
+Ty = cast(Ty)->getNamedType();
+  return cast(Ty)->getDecl();
 }
 
-TEST_P(ASTImporterLookupTableTest, LookupFindsFwdFriendClassDecl) {
+TEST_P(ASTImporterLookupTableTest,
+   LookupFindsFwdFriendClassDeclWithElaboratedType) {
   TranslationUnitDecl *ToTU = getToTuDecl(
   R"(
   class Y { friend class F; };
@@ -4276,6 +4281,52 @@
   EXPECT_EQ(Res.size(), 0u);
 }
 
+TEST_P(ASTImporterLookupTableTest,
+   LookupFindsFwdFriendClassDeclWithUnelaboratedType) {
+  TranslationUnitDecl *ToTU = getToTuDecl(
+  R"(
+  class F;
+  class Y { friend F; };
+  )",
+  Lang_CXX11);
+
+  // In this case, the CXXRecordDecl is hidden, the FriendDecl is not a parent.
+  // So we must dig up the underlying CXXRecordDecl.
+  ASTImporterLookupTable LT(*ToTU);
+  auto *FriendD = FirstDeclMatcher().match(ToTU, friendDecl());
+  const RecordDecl *RD = getRecordDeclOfFriend(FriendD);
+  auto *Y = FirstDeclMatcher().match(ToTU, cxxRecordDecl(hasName("Y")));
+
+  DeclarationName Name = RD->getDeclName();
+  auto Res = LT.lookup(ToTU, Name);
+  EXPECT_EQ(Res.size(), 1u);
+  EXPECT_EQ(*Res.begin(), RD);
+
+  Res = LT.lookup(Y, Name);
+  EXPECT_EQ(Res.size(), 0u);
+}
+
+TEST_P(ASTImporterLookupTableTest,
+   LookupFindsFriendClassDeclWithTypeAliasDoesNotAssert) {
+  TranslationUnitDecl *ToTU = getToTuDecl(
+  R"(
+  class F;
+  using alias_of_f = F;
+  class Y { friend alias_of_f; };
+  )",
+  Lang_CXX11);
+
+  // ASTImporterLookupTable constructor handles using declarations correctly,
+  // no assert is expected.
+  ASTImporterLookupTable LT(*ToTU);
+
+  auto *Alias = FirstDeclMatcher().match(
+  ToTU, typeAliasDecl(hasName("alias_of_f")));
+  DeclarationName Name = Alias->getDeclName();
+  auto Res = LT.lookup(ToTU, Name);
+  EXPECT_EQ(Res.count(Alias), 1u);
+}
+
 TEST_P(ASTImporterLookupTableTest, LookupFindsFwdFriendClassTemplateDecl) {
   TranslationUnitDecl *ToTU = getToTuDecl(
   R"(
Index: clang/lib/AST/ASTImporterLookupTable.cpp
===
--- clang/lib/AST/ASTImporterLookupTable.cpp
+++ clang/lib/AST/ASTImporterLookupTable.cpp
@@ -26,17 +26,30 @@
 LT.add(D);
 return true;
   }
+  // In most cases the FriendDecl contains the declaration of the befriended
+  // class as a child node, so it is discovered during the recursive
+  // visitation. However, there are cases when the befriended class is not a
+  // child, thus it must be fetched explicitly from the FriendDecl, and only
+  // then can we add it to the lookup table.
   bool VisitFriendDecl(FriendDecl *D) {
 if (D->getFriendType()) {
   QualType Ty = D->getFriendType()->getType();
-  // FIXME Can this be other than elaborated?
-  QualType NamedTy = cast(Ty)->getNamedType();
-  if (!NamedTy->isDependentType()) {
-if (const auto *RTy = dyn_cast(NamedTy))
+  if (isa(Ty))
+Ty = cast(Ty)->getNamedType();
+  // A FriendDecl with a dependent type (e.g. ClassTemplateSpecialization)
+  // always has that decl as child node.
+  // However, there are non-dependent cases which does not have the
+  // type as a child node. We have to dig up that type now.
+  if (!Ty->isDependentType()) {
+if (const auto *RTy = dyn_cast(Ty))
   LT.add(RTy->getAsCXXRecordDecl());
-else if (const auto *SpecTy =
- dyn_cast(NamedTy)) {
+else if (const auto *SpecTy = dyn_cast(Ty))
   LT.add(SpecTy->getAsCXXRecordDecl());
+else if (isa(Ty)) {
+  // We do not put friend typedefs to the lookup table because
+  // ASTImporter does not organize typedefs into redecl chains.
+} else {
+  llvm_unreachable("Unhandled type of friend class");
 }
   }
 }
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -2256,7 +2256,8 @@
   if (!FromUT->isIncompleteType() &

[PATCH] D62135: [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag to force it.

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



Comment at: clangd/CodeComplete.h:128
+/// Always use text-based completion.
+NeverParse,
+  } RunParser = ParseIfReady;

kadircet wrote:
> Do we really have any real use case for this option apart from testing ?
I don't think so. (If testing includes manual testing/quality tuning, rather 
than just automated tests)


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62135



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


[PATCH] D62135: [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag to force it.

2019-05-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 200438.
sammccall marked an inline comment as done.
sammccall added a comment.

deduplicate default


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62135

Files:
  clangd/ClangdServer.cpp
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  clangd/tool/ClangdMain.cpp
  clangd/unittests/ClangdTests.cpp

Index: clangd/unittests/ClangdTests.cpp
===
--- clangd/unittests/ClangdTests.cpp
+++ clangd/unittests/ClangdTests.cpp
@@ -9,6 +9,7 @@
 #include "Annotations.h"
 #include "ClangdLSPServer.h"
 #include "ClangdServer.h"
+#include "CodeComplete.h"
 #include "GlobalCompilationDatabase.h"
 #include "Matchers.h"
 #include "SyncAPI.h"
@@ -1072,7 +1073,7 @@
   FS.Files[FooCpp] = FooCpp;
 
   auto Opts = clangd::CodeCompleteOptions();
-  Opts.AllowFallback = true;
+  Opts.RunParser = CodeCompleteOptions::ParseIfReady;
 
   // This will make compile command broken and preamble absent.
   CDB.ExtraClangFlags = {"yolo.cc"};
@@ -1089,11 +1090,17 @@
   CDB.ExtraClangFlags = {"-std=c++11"};
   Server.addDocument(FooCpp, Code.code());
   ASSERT_TRUE(Server.blockUntilIdleForTest());
-  EXPECT_THAT(cantFail(runCodeComplete(Server, FooCpp, Code.point(),
-   clangd::CodeCompleteOptions()))
-  .Completions,
-  ElementsAre(AllOf(Field(&CodeCompletion::Name, "xyz"),
-Field(&CodeCompletion::Scope, "ns::";
+  EXPECT_THAT(
+  cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts)).Completions,
+  ElementsAre(AllOf(Field(&CodeCompletion::Name, "xyz"),
+Field(&CodeCompletion::Scope, "ns::";
+
+  // Now force identifier-based completion.
+  Opts.RunParser = CodeCompleteOptions::NeverParse;
+  EXPECT_THAT(
+  cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts)).Completions,
+  ElementsAre(AllOf(Field(&CodeCompletion::Name, "xyz"),
+Field(&CodeCompletion::Scope, "";
 }
 
 TEST_F(ClangdVFSTest, FallbackWhenWaitingForCompileCommand) {
@@ -1140,7 +1147,7 @@
   // hasn't been scheduled.
   std::this_thread::sleep_for(std::chrono::milliseconds(10));
   auto Opts = clangd::CodeCompleteOptions();
-  Opts.AllowFallback = true;
+  Opts.RunParser = CodeCompleteOptions::ParseIfReady;
 
   auto Res = cantFail(runCodeComplete(Server, FooCpp, Code.point(), Opts));
   EXPECT_EQ(Res.Context, CodeCompletionContext::CCC_Recovery);
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -256,13 +256,18 @@
 "Offsets are in UTF-16 code units")),
 llvm::cl::init(OffsetEncoding::UnsupportedEncoding));
 
-static llvm::cl::opt AllowFallbackCompletion(
-"allow-fallback-completion",
-llvm::cl::desc(
-"Allow falling back to code completion without compiling files (using "
-"identifiers and symbol indexes), when file cannot be built or the "
-"build is not ready."),
-llvm::cl::init(false));
+static llvm::cl::opt
+CodeCompletionParse(
+"completion-parse",
+llvm::cl::desc("Whether the clang-parser is used for code-completion"),
+llvm::cl::values(clEnumValN(CodeCompleteOptions::AlwaysParse, "always",
+"Block until the parser can be used"),
+ clEnumValN(CodeCompleteOptions::ParseIfReady, "auto",
+"Use text-based completion if the parser "
+"is not ready"),
+ clEnumValN(CodeCompleteOptions::NeverParse, "never",
+"Always used text-based completion")),
+llvm::cl::init(CodeCompleteOptions().RunParser), llvm::cl::Hidden);
 
 namespace {
 
@@ -475,7 +480,7 @@
   CCOpts.SpeculativeIndexRequest = Opts.StaticIndex;
   CCOpts.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
   CCOpts.AllScopes = AllScopesCompletion;
-  CCOpts.AllowFallback = AllowFallbackCompletion;
+  CCOpts.RunParser = CodeCompletionParse;
 
   RealFileSystemProvider FSProvider;
   // Initialize and run ClangdLSPServer.
Index: clangd/CodeComplete.h
===
--- clangd/CodeComplete.h
+++ clangd/CodeComplete.h
@@ -115,11 +115,18 @@
   /// Such completions can insert scope qualifiers.
   bool AllScopes = false;
 
-  /// Whether to allow falling back to code completion without compiling files
-  /// (using identifiers in the current file and symbol indexes), when file
-  /// cannot be built (e.g. missing compile command), or the build is not ready
-  /// (e.g. preamble is still being built).
-  bool AllowFallback = false;
+  /// Whether to use the clang parser, or fallback to text-ba

[PATCH] D53847: [C++2a] P0634r3: Down with typename!

2019-05-21 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete updated this revision to Diff 200440.
Rakete added a comment.

Add support for implicit typenames of the form T::template U


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D53847

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/basic/basic.lookup/basic.lookup.qual/class.qual/p2.cpp
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/drs/dr2xx.cpp
  clang/test/CXX/drs/dr4xx.cpp
  clang/test/CXX/drs/dr5xx.cpp
  clang/test/CXX/temp/temp.res/p3.cpp
  clang/test/CXX/temp/temp.res/p5.cpp
  clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p1.cpp
  clang/test/FixIt/fixit.cpp
  clang/test/Parser/cxx-member-initializers.cpp
  clang/test/Parser/editor-placeholder-recovery.cpp
  clang/test/SemaCXX/MicrosoftCompatibility.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/MicrosoftSuper.cpp
  clang/test/SemaCXX/unknown-type-name.cpp
  clang/test/SemaTemplate/alias-templates.cpp
  clang/test/SemaTemplate/typename-specifier-3.cpp

Index: clang/test/SemaTemplate/typename-specifier-3.cpp
===
--- clang/test/SemaTemplate/typename-specifier-3.cpp
+++ clang/test/SemaTemplate/typename-specifier-3.cpp
@@ -27,7 +27,7 @@
   typedef int arg;
 };
 struct C {
-  typedef B::X x; // expected-error {{missing 'typename'}}
+  typedef B::X x; // expected-warning {{missing 'typename'}}
 };
   };
 
Index: clang/test/SemaTemplate/alias-templates.cpp
===
--- clang/test/SemaTemplate/alias-templates.cpp
+++ clang/test/SemaTemplate/alias-templates.cpp
@@ -195,11 +195,10 @@
   struct base {
 template  struct derived;
   };
-  // FIXME: The diagnostics here are terrible.
   template 
-  using derived = base::template derived; // expected-error {{expected a type}} expected-error {{expected ';'}}
+  using derived = base::template derived; // expected-warning {{missing 'typename'}}
   template 
-  using derived2 = ::PR16904::base::template derived; // expected-error {{expected a type}} expected-error {{expected ';'}}
+  using derived2 = ::PR16904::base::template derived; // expected-warning {{missing 'typename'}}
 }
 
 namespace PR14858 {
Index: clang/test/SemaCXX/unknown-type-name.cpp
===
--- clang/test/SemaCXX/unknown-type-name.cpp
+++ clang/test/SemaCXX/unknown-type-name.cpp
@@ -36,15 +36,15 @@
 
   static int n;
   static type m;
-  static int h(T::type, int); // expected-error{{missing 'typename'}}
-  static int h(T::type x, char); // expected-error{{missing 'typename'}}
+  static int h(T::type, int); // expected-warning{{implicit 'typename' is a C++2a extension}}
+  static int h(T::type x, char); // expected-warning{{implicit 'typename' is a C++2a extension}}
 };
 
 template
-A::type g(T t) { return t; } // expected-error{{missing 'typename'}}
+A::type g(T t) { return t; } // expected-warning{{implicit 'typename' is a C++2a extension}}
 
 template
-A::type A::f() { return type(); } // expected-error{{missing 'typename'}}
+A::type A::f() { return type(); } // expected-warning{{implicit 'typename' is a C++2a extension}}
 
 template
 void f(T::type) { } // expected-error{{missing 'typename'}}
@@ -72,9 +72,7 @@
 
 int *p;
 
-// FIXME: We should assume that 'undeclared' is a type, not a parameter name
-//here, and produce an 'unknown type name' diagnostic instead.
-int f1(undeclared, int); // expected-error{{requires a type specifier}}
+int f1(undeclared, int); // expected-error{{unknown type name 'undeclared'}}
 
 int f2(undeclared, 0); // expected-error{{undeclared identifier}}
 
@@ -86,11 +84,11 @@
 
 template int A::n(T::value); // ok
 template
-A::type // expected-error{{missing 'typename'}}
+A::type // expected-warning {{implicit 'typename' is a C++2a extension}}
 A::m(T::value, 0); // ok
 
-template int A::h(T::type, int) {} // expected-error{{missing 'typename'}}
-template int A::h(T::type x, char) {} // expected-error{{missing 'typename'}}
+template int A::h(T::type, int) {} // expected-warning{{implicit 'typename' is a C++2a extension}}
+template int A::h(T::type x, char) {} // expected-warning{{implicit 'typename' is a C++2a extension}}
 
 template int h(T::type, int); // expected-error{{missing 'typename'}}
 template int h(T::type x, char); // expected-error{{missing 'typename'}}
@@ -118,4 +116,5 @@
 // FIXME: We know which type specifier should have

[PATCH] D62181: [OpenCL] Support pipe keyword in C++ mode

2019-05-21 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
Herald added subscribers: cfe-commits, yaxunl.
Herald added a project: clang.

Support the OpenCL C pipe feature in C++ for OpenCL mode, to preserve backwards 
compatibility with OpenCL C.


Repository:
  rC Clang

https://reviews.llvm.org/D62181

Files:
  include/clang/Basic/TokenKinds.def
  lib/Basic/Builtins.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaType.cpp
  test/SemaOpenCL/invalid-pipes-cl2.0.cl

Index: test/SemaOpenCL/invalid-pipes-cl2.0.cl
===
--- test/SemaOpenCL/invalid-pipes-cl2.0.cl
+++ test/SemaOpenCL/invalid-pipes-cl2.0.cl
@@ -1,9 +1,10 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
 
 global pipe int gp;// expected-error {{type '__global read_only pipe int' can only be used as a function parameter in OpenCL}}
 global reserve_id_t rid;  // expected-error {{the '__global reserve_id_t' type cannot be used to declare a program scope variable}}
 
-extern pipe write_only int get_pipe(); // expected-error {{type '__global write_only pipe int (void)' can only be used as a function parameter in OpenCL}}
+extern pipe write_only int get_pipe(); // expected-error-re{{type '__global write_only pipe int ({{(void)?}})' can only be used as a function parameter in OpenCL}}
 
 kernel void test_invalid_reserved_id(reserve_id_t ID) { // expected-error {{'reserve_id_t' cannot be used as the type of a kernel parameter}}
 }
@@ -35,6 +36,7 @@
 }
 
 // Tests ASTContext::mergeTypes rejects this.
+#ifndef __OPENCL_CPP_VERSION__
 int f(pipe int x, int y); // expected-note {{previous declaration is here}}
 int f(x, y) // expected-error {{conflicting types for 'f}}
 pipe short x;
@@ -42,3 +44,4 @@
 {
 return y;
 }
+#endif
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -1356,7 +1356,7 @@
   // "At least one type specifier shall be given in the declaration
   // specifiers in each declaration, and in the specifier-qualifier list in
   // each struct declaration and type name."
-  if (S.getLangOpts().CPlusPlus) {
+  if (S.getLangOpts().CPlusPlus && !DS.isTypeSpecPipe()) {
 S.Diag(DeclLoc, diag::err_missing_type_specifier)
   << DS.getSourceRange();
 
@@ -1364,7 +1364,9 @@
 // value being declared, poison it as invalid so we don't get chains of
 // errors.
 declarator.setInvalidType(true);
-  } else if (S.getLangOpts().OpenCLVersion >= 200 && DS.isTypeSpecPipe()){
+  } else if ((S.getLangOpts().OpenCLVersion >= 200 ||
+  S.getLangOpts().OpenCLCPlusPlus) &&
+ DS.isTypeSpecPipe()) {
 S.Diag(DeclLoc, diag::err_missing_actual_pipe_type)
   << DS.getSourceRange();
 declarator.setInvalidType(true);
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -9288,7 +9288,7 @@
 
 // OpenCL 2.0 pipe restrictions forbids pipe packet types to be non-value
 // types.
-if (getLangOpts().OpenCLVersion >= 200) {
+if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
   if(const PipeType *PipeTy = PT->getAs()) {
 QualType ElemTy = PipeTy->getElementType();
   if (ElemTy->isReferenceType() || ElemTy->isPointerType()) {
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -1437,6 +1437,8 @@
   case tok::kw___read_only:
   case tok::kw___write_only:
   case tok::kw___read_write:
+// OpenCL pipe
+  case tok::kw_pipe:
 
 // GNU
   case tok::kw_restrict:
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -2560,6 +2560,11 @@
 return false;
   }
 
+  // Early exit as Sema has a dedicated missing_actual_pipe_type diagnostic
+  // for incomplete declarations such as `pipe p`.
+  if (getLangOpts().OpenCLCPlusPlus && DS.isTypeSpecPipe())
+return false;
+
   if (getLangOpts().CPlusPlus &&
   DS.getStorageClassSpec() == DeclSpec::SCS_auto) {
 // Don't require a type specifier if we have the 'auto' storage class
@@ -3769,7 +3774,8 @@
   isInvalid = DS.SetTypeAltiVecBool(true, Loc, PrevSpec, DiagID, Policy);
   break;
 case tok::kw_pipe:
-  if (!getLangOpts().OpenCL || (getLangOpts().OpenCLVersion < 200)) {
+  if (!getLangOpts().OpenCL || (getLangOpts().OpenCLVersion < 200 &&
+!getLangOpts().OpenCLCPlusPlus)) {
 // OpenCL 2.0 defined this keyword. OpenCL 1.2 and earlier should
 

[PATCH] D62115: fix a issue that clang is incompatible with gcc with -H option.

2019-05-21 Thread Kan Shengchen via Phabricator via cfe-commits
skan added a comment.

In D62115#1509536 , @kimgr wrote:

> Should you also consider Windows path separators here?


Do you mean "\\" separator? i build llvm on windows, and use clang to complie 
file with -H option. The output pathname also use "/" as path separator, so i 
think we don't need to consider the "\\" separator.


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

https://reviews.llvm.org/D62115



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


[PATCH] D60763: Prototype OpenCL BIFs using Tablegen

2019-05-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:243
+// == Builtin definitions ==
+// This section defines builtin functions found in the OpenCL 1.2 specification
+

Anastasia wrote:
> found in -> from
ping!



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:13
+// prototypes. In case of an unresolved function names in OpenCL, Clang will
+// check the function is not a builtin function.
+//

How about - Clang will check for functions described in this file?



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:26
+//Base definitions
+// These classes/ definitions are representing simple information.
+//===--===//

simple -> basic



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:305
+
+// == Builtin definitions (Examples) ==
+

Why Examples?



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:307
+
+// Example to show use of the "Version" field.
+let Version = CL20 in {

Let's remove Example please!



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:312
+
+// Example to show use of the "Extension" field.
+let Extension = "cl_khr_subgroups" in {

Please rename Example here too! We can just say something like builting 
functions that belong to extensions.



Comment at: clang/lib/Sema/SemaLookup.cpp:679
+// prototypes are added to the LookUpResult.
+// S  : The sema instance
+// LR : The lookupResult instance

Anastasia wrote:
> This does not match Clang documentation format. Can you please align with 
> other functions in this file.
Ping. The format here still doesn't match the rest. Here is an example how we 
document functions.




```
 6205 /// Look up the special member function that would be called by a special
 6206 /// member function for a subobject of class type.
 6207 ///
 6208 /// \param Class The class type of the subobject.
 6209 /// \param CSM The kind of special member function.
 6210 /// \param FieldQuals If the subobject is a field, its cv-qualifiers.
 6211 /// \param ConstRHS True if this is a copy operation with a const object
 6212 ///on its RHS, that is, if the argument to the outer special 
member
 6213 ///function is 'const' and this is not a field marked 'mutable'.
 6214 static Sema::SpecialMemberOverloadResult lookupCallFromSpecialMember(
 6215 Sema &S, CXXRecordDecl *Class, Sema::CXXSpecialMember CSM,
 6216 unsigned FieldQuals, bool ConstRHS) {

```




Comment at: clang/test/SemaOpenCL/builtin-new.cl:15
+
+kernel void version(float a) {
+  size_t b;

I think we should name the functions based on what BIFs they tests. Otherwise 
it will become too hard to navigate and track.



Comment at: clang/test/SemaOpenCL/builtin-new.cl:28
+
+// TODO Maybe overloads can be available in different CL version. Check this.
+#ifdef CL20

Is this TODO still needed?



Comment at: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp:97
+  // static QualType OCL2Qual(ASTContext &Context, OpenCLType Ty);
+  // TODO: Should not need clang::
+  void EmitQualTypeFinder();

Anastasia wrote:
> Should we remove the TODO?
ping!

line 97 now.



Comment at: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp:107
+  //<, 35>.
+  // TODO: Check the other types of vector available for performance purpose
+  std::vector, unsigned>> SignatureSet;

Is this TODO still relevant?



Comment at: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp:126
+void BuiltinNameEmitter::Emit() {
+  // Generate the file containing OpenCL builtin functions checking code.
+

This should be moved above?


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

https://reviews.llvm.org/D60763



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


[PATCH] D62184: [AST] Add RecoveryExpr; produce it on overload resolution failure and missing member.

2019-05-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, ilya-biryukov.
Herald added a project: clang.

In many places, Sema refuses to create an Expr if it encounters an error.
This means that broken code has no representation in the AST. As well as
the broken node itself, child Exprs and parent Exprs are usually dropped.

This is terrible for tools that rely on the AST and see a lot of broken
code (e.g. libclang-based IDEs and clangd).
In the expression `foo(a, takes2args(b))`, "go to definition" doesn't
work on any of the subexpressions. And after `takes2args(x).`, member
completion doesn't work, although in practice we almost always know the type.

This patch introduces RecoveryExpr. This AST node represents broken
code, and has very weak semantics. It's part of the final AST (unlike TypoExpr)
but can't produce code, as it's always accompanied by an error.
It captures valid subexpressions without checking or assigning them meaning.
Some RecoveryExprs have a known type (e.g. a broken non-overloaded call).
Where the type is unknown, it is modeled as a new type ErrorTy.

In this patch, ErrorTy is not dependent. See D61722 
 for that approach.
Here ErrorTy must be explicitly handled on many paths, similar to dependent
types (though also for C). I've certainly missed some that tests didn't flag.

Initiallly, RecoveryExpr is emitted in two common cases:

- a function call where overload resolution failed (most typically: wrong args) 
Callee is captured as an UnresolvedLookupExpr, and args are captured. Type is 
available if the "best" candidates have the same return type.
- access of a nonexistent member Base expression is captured, type is never 
available.

Test changes:

- SemaCXX/enable_if.cpp: we now emit more detailed diagnostics (the 
non-constexpr subexpression is inside a function call), which breaks the 
heuristic that tries to move the whole diagnostic to the subexpression 
location. This case (IMO) doesn't matter much: the subexpression is invalid, 
flagging it as non-constexpr isn't very useful to start with.
- SemaTemplate/instantiate-function-params.cpp: it looks like the testcase was 
minimized in an unrealistic way: the only version of if_ doesn't have `type` 
and the only version of `requirement_` doesn't have `failed`, and it seems 
reasonable to diagnose this. If the precise invalid form is required, I can add 
another 17 expect-*s to the test, or remove -verify so we only fail on 
crashing. Original patch adding this test is very terse: 
https://github.com/llvm/llvm-project/commit/5112157958438005095aff805853f9b14ba974eb
 Testcase subsequently modified to test for a crash: 
https://github.com/llvm/llvm-project/commit/a02bb341552b2b91c93e708645c32d11cc4133d2
- CodeGen/builtins-systemz-zvector[2]-error.c: these tests now generate extra 
noisy (but correct) diagnostics: vecintrin.h uses a cast to an invalid type to 
suppress them, and the cast now succeeds. The right fix is probably to rewrite 
the builtin header somehow, I haven't investigated fully yet.


Repository:
  rC Clang

https://reviews.llvm.org/D62184

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/Expr.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/Stmt.h
  include/clang/AST/TextNodeDumper.h
  include/clang/AST/Type.h
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Initialization.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/AST/TextNodeDumper.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaPseudoObject.cpp
  lib/Sema/SemaStmt.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
  test/CodeCompletion/member-access.cpp
  test/Index/getcursor-recovery.cpp
  test/Parser/recovery.c
  test/SemaCXX/constructor-initializer.cpp
  test/SemaCXX/enable_if.cpp
  test/SemaTemplate/dependent-names.cpp
  test/SemaTemplate/instantiate-function-params.cpp
  test/SemaTemplate/instantiate-init.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===

[PATCH] D62181: [OpenCL] Support pipe keyword in C++ mode

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

LGTM! Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D62181



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


[PATCH] D60763: Prototype OpenCL BIFs using Tablegen

2019-05-21 Thread Pierre via Phabricator via cfe-commits
Pierre marked an inline comment as done.
Pierre added inline comments.



Comment at: clang/include/clang/Basic/OpenCLBuiltins.td:298-302
+def write_imagef : Builtin<"write_imagef",
+[void_t,
+  image2d_WO_t,
+  VectorType,
+  VectorType]>;

AlexeySotkin wrote:
> It seems like there is something wrong with access qualifiers for images. I 
> have applied this patch and tried to compile the following code:
> 
> ```
> typedef int int2 __attribute__((ext_vector_type(2)));
> typedef float float4 __attribute__((ext_vector_type(4)));
> 
> void kernel k(write_only image2d_t image, int2 coord, float4 data) {
>   write_imagef(image, coord, data);
> }
> 
> ```
> I got the following output:
> ```
> clang -cc1 -triple spir /work/tmp/tmp.cl -emit-llvm -o -  
> -fadd-opencl-builtins
> /work/tmp/tmp.cl:5:16: error: passing '__write_only image2d_t' to parameter 
> of incompatible type '__read_only image2d_t'
>   write_imagef(image, coord, data);
>  ^
> 1 error generated.
> ```
What you are saying is right. This patch is incomplete and some features are 
missing/ broken. 
I have a new version of the tablegen builtin feature where the access 
qualifiers are actually taken into account, but I cannot extract only this from 
my version. This would imply uploading the whole new version. 
The new version will hopefully be on top of this patch, making access 
qualifiers work.


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

https://reviews.llvm.org/D60763



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


r361238 - [CGBuiltin] dumpRecord - remove unused field offset. NFCI.

2019-05-21 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue May 21 03:48:42 2019
New Revision: 361238

URL: http://llvm.org/viewvc/llvm-project?rev=361238&view=rev
Log:
[CGBuiltin] dumpRecord - remove unused field offset. NFCI.

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

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=361238&r1=361237&r2=361238&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue May 21 03:48:42 2019
@@ -1400,8 +1400,6 @@ static llvm::Value *dumpRecord(CodeGenFu
   const auto *RT = RType->getAs();
   ASTContext &Context = CGF.getContext();
   RecordDecl *RD = RT->getDecl()->getDefinition();
-  ASTContext &Ctx = RD->getASTContext();
-  const ASTRecordLayout &RL = Ctx.getASTRecordLayout(RD);
   std::string Pad = std::string(Lvl * 4, ' ');
 
   Value *GString =
@@ -1431,9 +1429,6 @@ static llvm::Value *dumpRecord(CodeGenFu
   }
 
   for (const auto *FD : RD->fields()) {
-uint64_t Off = RL.getFieldOffset(FD->getFieldIndex());
-Off = Ctx.toCharUnitsFromBits(Off).getQuantity();
-
 Value *FieldPtr = RecordPtr;
 if (RD->isUnion())
   FieldPtr = CGF.Builder.CreatePointerCast(


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


r361242 - [CodeGenModule] BlockByrefHelpers - add missing uninitialized variables to constructor. NFCI.

2019-05-21 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue May 21 04:37:54 2019
New Revision: 361242

URL: http://llvm.org/viewvc/llvm-project?rev=361242&view=rev
Log:
[CodeGenModule] BlockByrefHelpers - add missing uninitialized variables to 
constructor. NFCI.

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=361242&r1=361241&r2=361242&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Tue May 21 04:37:54 2019
@@ -254,7 +254,8 @@ public:
   /// have different helper functions.
   CharUnits Alignment;
 
-  BlockByrefHelpers(CharUnits alignment) : Alignment(alignment) {}
+  BlockByrefHelpers(CharUnits alignment)
+  : CopyHelper(nullptr), DisposeHelper(nullptr), Alignment(alignment) {}
   BlockByrefHelpers(const BlockByrefHelpers &) = default;
   virtual ~BlockByrefHelpers();
 


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


[PATCH] D60672: [libclang] visit c++14 lambda capture init expressions

2019-05-21 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D60672



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


[PATCH] D62187: Delete default constructors, copy constructors, move constructors, copy assignment, move assignment operators on Expr, Stmt and Decl

2019-05-21 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added reviewers: ilya-biryukov, rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62187

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/Stmt.h
  clang/lib/CodeGen/CGBuiltin.cpp

Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -1134,9 +1134,10 @@
 return F;
 
   llvm::SmallVector ArgTys;
-  llvm::SmallVector Params;
-  Params.emplace_back(Ctx, nullptr, SourceLocation(), &Ctx.Idents.get("buffer"),
-  Ctx.VoidPtrTy, ImplicitParamDecl::Other);
+  FunctionArgList Args;
+  Args.push_back(ImplicitParamDecl::Create(
+  Ctx, nullptr, SourceLocation(), &Ctx.Idents.get("buffer"), Ctx.VoidPtrTy,
+  ImplicitParamDecl::Other));
   ArgTys.emplace_back(Ctx.VoidPtrTy);
 
   for (unsigned int I = 0, E = Layout.Items.size(); I < E; ++I) {
@@ -1145,17 +1146,13 @@
   continue;
 
 QualType ArgTy = getOSLogArgType(Ctx, Size);
-Params.emplace_back(
+Args.push_back(ImplicitParamDecl::Create(
 Ctx, nullptr, SourceLocation(),
 &Ctx.Idents.get(std::string("arg") + llvm::to_string(I)), ArgTy,
-ImplicitParamDecl::Other);
+ImplicitParamDecl::Other));
 ArgTys.emplace_back(ArgTy);
   }
 
-  FunctionArgList Args;
-  for (auto &P : Params)
-Args.push_back(&P);
-
   QualType ReturnTy = Ctx.VoidTy;
   QualType FuncionTy = Ctx.getFunctionType(ReturnTy, ArgTys, {});
 
@@ -1188,7 +1185,7 @@
   auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   CharUnits Offset;
-  Address BufAddr(Builder.CreateLoad(GetAddrOfLocalVar(&Params[0]), "buf"),
+  Address BufAddr(Builder.CreateLoad(GetAddrOfLocalVar(Args[0]), "buf"),
   BufferAlignment);
   Builder.CreateStore(Builder.getInt8(Layout.getSummaryByte()),
   Builder.CreateConstByteGEP(BufAddr, Offset++, "summary"));
@@ -1208,7 +1205,7 @@
 if (!Size.getQuantity())
   continue;
 
-Address Arg = GetAddrOfLocalVar(&Params[I]);
+Address Arg = GetAddrOfLocalVar(Args[I]);
 Address Addr = Builder.CreateConstByteGEP(BufAddr, Offset, "argData");
 Addr = Builder.CreateBitCast(Addr, Arg.getPointer()->getType(),
  "argDataCast");
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -1054,6 +1054,7 @@
 return static_cast(StmtBits.sClass);
   }
 
+  Stmt() = delete;
   Stmt(const Stmt &) = delete;
   Stmt(Stmt &&) = delete;
   Stmt &operator=(const Stmt &) = delete;
Index: clang/include/clang/AST/Expr.h
===
--- clang/include/clang/AST/Expr.h
+++ clang/include/clang/AST/Expr.h
@@ -108,6 +108,13 @@
 class Expr : public ValueStmt {
   QualType TR;
 
+public:
+  Expr() = delete;
+  Expr(const Expr&) = delete;
+  Expr(Expr &&) = delete;
+  Expr &operator=(const Expr&) = delete;
+  Expr &operator=(Expr&&) = delete;
+
 protected:
   Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK,
bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -368,6 +368,13 @@
 return ModuleOwnershipKind::Unowned;
   }
 
+public:
+  Decl() = delete;
+  Decl(const Decl&) = delete;
+  Decl(Decl &&) = delete;
+  Decl &operator=(const Decl&) = delete;
+  Decl &operator=(Decl&&) = delete;
+
 protected:
   Decl(Kind DK, DeclContext *DC, SourceLocation L)
   : NextInContextAndBits(nullptr, getModuleOwnershipKindForChildOf(DC)),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61508: [clang-tidy] bugprone-header-guard : a simple version of llvm-header-guard

2019-05-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D61508#1509368 , @trixirt wrote:

> Latest change addresses most of issues.
>  Outstanding is adding a test when garbage GuardStyle value is fed into 
> config.
>  The trial testcase used only CHECK-*-NOT which caused complaining from test 
> harness looking for the CHECK- cases.
>  Looking for something similar in the other checker tests did not turn up 
> anything.
>  In general it seems like clang-tidy assumes developers get the string names 
> of the options and their values correct and does not provide a lot of (any?)  
> checking.


We're probably quite inconsistent in this regard, and it seems like something 
we may want to address across the board (not suggesting that you have to fix 
it, or even as part of this patch). I was envisioning the test as being 
something like `CHECK-MESSAGES-ERROR: 1:1: error: %s is an unsupported header 
guard style` or something along those lines.




Comment at: clang-tidy/bugprone/HeaderGuardCheck.cpp:30
+}
+std::string BugproneHeaderGuardCheck::getHeaderGuard(StringRef Filename,
+ StringRef OldGuard) {

Can you add a newline for some visual separation?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61508



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


[PATCH] D62151: [clangd] Add tweak to convert normal to raw string literal, when it contains escapes.

2019-05-21 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361252: [clangd] Add tweak to convert normal to raw string 
literal, when it contains… (authored by sammccall, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62151

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

Index: clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp
@@ -105,9 +105,10 @@
 }
 
 void checkTransform(llvm::StringRef ID, llvm::StringRef Input,
-llvm::StringRef Output) {
-  EXPECT_THAT_EXPECTED(apply(ID, Input), HasValue(Output))
-  << "action id is" << ID;
+std::string Output) {
+  auto Result = apply(ID, Input);
+  ASSERT_TRUE(bool(Result)) << llvm::toString(Result.takeError()) << Input;
+  EXPECT_EQ(Output, std::string(*Result)) << Input;
 }
 
 TEST(TweakTest, SwapIfBranches) {
@@ -185,6 +186,37 @@
   )cpp");
 }
 
+TEST(TweakTest, RawStringLiteral) {
+  llvm::StringLiteral ID = "RawStringLiteral";
+
+  checkAvailable(ID, R"cpp(
+const char *A = ^"^f^o^o^\^n^";
+const char *B = R"(multi )" ^"token " "str\ning";
+  )cpp");
+
+  checkNotAvailable(ID, R"cpp(
+const char *A = ^"f^o^o^o^"; // no chars need escaping
+const char *B = R"(multi )" ^"token " u8"str\ning"; // not all ascii
+const char *C = ^R^"^(^multi )" "token " "str\ning"; // chunk is raw
+const char *D = ^"token\n" __FILE__; // chunk is macro expansion
+const char *E = ^"a\r\n"; // contains forbidden escape character
+  )cpp");
+
+  const char *Input = R"cpp(
+const char *X = R"(multi
+token)" "\nst^ring\n" "literal";
+}
+  )cpp";
+  const char *Output = R"cpp(
+const char *X = R"(multi
+token
+string
+literal)";
+}
+  )cpp";
+  checkTransform(ID, Input, Output);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/refactor/tweaks/RawStringLiteral.cpp
===
--- clang-tools-extra/trunk/clangd/refactor/tweaks/RawStringLiteral.cpp
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/RawStringLiteral.cpp
@@ -0,0 +1,103 @@
+//===--- RawStringLiteral.cpp *- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "ClangdUnit.h"
+#include "Logger.h"
+#include "SourceCode.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+/// Converts a string literal to a raw string.
+/// Before:
+///   printf("\"a\"\nb");
+///  ^
+/// After:
+///   printf(R"("a"
+/// b)");
+class RawStringLiteral : public Tweak {
+public:
+  const char *id() const override final;
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+  const clang::StringLiteral *Str = nullptr;
+};
+
+REGISTER_TWEAK(RawStringLiteral)
+
+static bool isNormalString(const StringLiteral &Str, SourceLocation Cursor,
+  SourceManager &SM) {
+  // All chunks must be normal ASCII strings, not u8"..." etc.
+  if (!Str.isAscii())
+return false;
+  SourceLocation LastTokenBeforeCursor;
+  for (auto I = Str.tokloc_begin(), E = Str.tokloc_end(); I != E; ++I) {
+if (I->isMacroID()) // No tokens in the string may be macro expansions.
+  return false;
+if (SM.isBeforeInTranslationUnit(*I, Cursor) || *I == Cursor)
+  LastTokenBeforeCursor = *I;
+  }
+  // Token we care about must be a normal "string": not raw, u8, etc.
+  const char* Data = SM.getCharacterData(LastTokenBeforeCursor);
+  return Data && *Data == '"';
+}
+
+static bool needsRaw(llvm::StringRef Content) {
+  return Content.find_first_of("\"\n\t") != StringRef::npos;
+}
+
+static bool can

[clang-tools-extra] r361252 - [clangd] Add tweak to convert normal to raw string literal, when it contains escapes.

2019-05-21 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue May 21 06:04:24 2019
New Revision: 361252

URL: http://llvm.org/viewvc/llvm-project?rev=361252&view=rev
Log:
[clangd] Add tweak to convert normal to raw string literal, when it contains 
escapes.

Reviewers: ilya-biryukov

Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt?rev=361252&r1=361251&r2=361252&view=diff
==
--- clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt Tue May 21 
06:04:24 2019
@@ -12,6 +12,7 @@ set(LLVM_LINK_COMPONENTS
 # $ to a list of sources, see
 # clangd/tool/CMakeLists.txt for an example.
 add_clang_library(clangDaemonTweaks OBJECT
+  RawStringLiteral.cpp
   SwapIfBranches.cpp
 
   LINK_LIBS

Added: clang-tools-extra/trunk/clangd/refactor/tweaks/RawStringLiteral.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/RawStringLiteral.cpp?rev=361252&view=auto
==
--- clang-tools-extra/trunk/clangd/refactor/tweaks/RawStringLiteral.cpp (added)
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/RawStringLiteral.cpp Tue May 
21 06:04:24 2019
@@ -0,0 +1,103 @@
+//===--- RawStringLiteral.cpp *- 
C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "ClangdUnit.h"
+#include "Logger.h"
+#include "SourceCode.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+/// Converts a string literal to a raw string.
+/// Before:
+///   printf("\"a\"\nb");
+///  ^
+/// After:
+///   printf(R"("a"
+/// b)");
+class RawStringLiteral : public Tweak {
+public:
+  const char *id() const override final;
+
+  bool prepare(const Selection &Inputs) override;
+  Expected apply(const Selection &Inputs) override;
+  std::string title() const override;
+
+private:
+  const clang::StringLiteral *Str = nullptr;
+};
+
+REGISTER_TWEAK(RawStringLiteral)
+
+static bool isNormalString(const StringLiteral &Str, SourceLocation Cursor,
+  SourceManager &SM) {
+  // All chunks must be normal ASCII strings, not u8"..." etc.
+  if (!Str.isAscii())
+return false;
+  SourceLocation LastTokenBeforeCursor;
+  for (auto I = Str.tokloc_begin(), E = Str.tokloc_end(); I != E; ++I) {
+if (I->isMacroID()) // No tokens in the string may be macro expansions.
+  return false;
+if (SM.isBeforeInTranslationUnit(*I, Cursor) || *I == Cursor)
+  LastTokenBeforeCursor = *I;
+  }
+  // Token we care about must be a normal "string": not raw, u8, etc.
+  const char* Data = SM.getCharacterData(LastTokenBeforeCursor);
+  return Data && *Data == '"';
+}
+
+static bool needsRaw(llvm::StringRef Content) {
+  return Content.find_first_of("\"\n\t") != StringRef::npos;
+}
+
+static bool canBeRaw(llvm::StringRef Content) {
+  for (char C : Content)
+if (!llvm::isPrint(C) && C != '\n' && C != '\t')
+  return false;
+  return !Content.contains(")\"");
+}
+
+bool RawStringLiteral::prepare(const Selection &Inputs) {
+  const SelectionTree::Node *N = Inputs.ASTSelection.commonAncestor();
+  if (!N)
+return false;
+  Str = dyn_cast_or_null(N->ASTNode.get());
+  return Str &&
+ isNormalString(*Str, Inputs.Cursor,
+Inputs.AST.getASTContext().getSourceManager()) &&
+ needsRaw(Str->getBytes()) && canBeRaw(Str->getBytes());
+}
+
+Expected
+RawStringLiteral::apply(const Selection &Inputs) {
+  return tooling::Replacements(
+  tooling::Replacement(Inputs.AST.getASTContext().getSourceManager(), Str,
+   ("R\"(" + Str->getBytes() + ")\"").str(),

[PATCH] D62192: [clang-tidy]: Add cert-oop54-cpp alias for bugprone-unhandled-self-assignment

2019-05-21 Thread Tamás Zolnai via Phabricator via cfe-commits
ztamas created this revision.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Added WarnOnlyIfThisHasSuspiciousField option to allow
to catch any copy assignment operator independently from
the container class's fields.
Added the cert alias using this option.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62192

Files:
  clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-self-assignment.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-oop54-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/bugprone-unhandled-self-assignment-warn-only-if-this-has-suspicious-field.cpp
  clang-tools-extra/test/clang-tidy/cert-oop54-cpp.cpp

Index: clang-tools-extra/test/clang-tidy/cert-oop54-cpp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/cert-oop54-cpp.cpp
@@ -0,0 +1,16 @@
+// RUN: %check_clang_tidy %s cert-oop54-cpp %t
+
+// Test whether bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField option is set correctly.
+class TrivialFields {
+public:
+  TrivialFields &operator=(const TrivialFields &object) {
+// CHECK-MESSAGES: [[@LINE-1]]:18: warning: operator=() does not handle self-assignment properly [cert-oop54-cpp]
+return *this;
+  }
+
+private:
+  int m;
+  float f;
+  double d;
+  bool b;
+};
Index: clang-tools-extra/test/clang-tidy/bugprone-unhandled-self-assignment-warn-only-if-this-has-suspicious-field.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/bugprone-unhandled-self-assignment-warn-only-if-this-has-suspicious-field.cpp
@@ -0,0 +1,41 @@
+// RUN: %check_clang_tidy %s bugprone-unhandled-self-assignment %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField, \
+// RUN:   value: 0}]}"
+
+// Classes with pointer field are still caught.
+class PtrField {
+public:
+  PtrField &operator=(const PtrField &object) {
+// CHECK-MESSAGES: [[@LINE-1]]:13: warning: operator=() does not handle self-assignment properly [bugprone-unhandled-self-assignment]
+return *this;
+  }
+
+private:
+  int *p;
+};
+
+// With the option, check catches classes with trivial fields.
+class TrivialFields {
+public:
+  TrivialFields &operator=(const TrivialFields &object) {
+// CHECK-MESSAGES: [[@LINE-1]]:18: warning: operator=() does not handle self-assignment properly [bugprone-unhandled-self-assignment]
+return *this;
+  }
+
+private:
+  int m;
+  float f;
+  double d;
+  bool b;
+};
+
+// The check warns also when there is no field at all.
+// In this case, user-defined copy assignment operator is useless anyway.
+class ClassWithoutFields {
+public:
+  ClassWithoutFields &operator=(const ClassWithoutFields &object) {
+// CHECK-MESSAGES: [[@LINE-1]]:23: warning: operator=() does not handle self-assignment properly [bugprone-unhandled-self-assignment]
+return *this;
+  }
+};
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -98,6 +98,7 @@
cert-msc50-cpp
cert-msc51-cpp
cert-oop11-cpp (redirects to performance-move-constructor-init) 
+   cert-oop54-cpp (redirects to bugprone-unhandled-self-assignment) 
cppcoreguidelines-avoid-c-arrays (redirects to modernize-avoid-c-arrays) 
cppcoreguidelines-avoid-goto
cppcoreguidelines-avoid-magic-numbers (redirects to readability-magic-numbers) 
Index: clang-tools-extra/docs/clang-tidy/checks/cert-oop54-cpp.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cert-oop54-cpp.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - cert-oop54-cpp
+.. meta::
+   :http-equiv=refresh: 5;URL=bugprone-unhandled-self-assignment.html
+
+cert-oop54-cpp
+==
+
+The cert-oop54-cpp check is an alias, please see
+`bugprone-unhandled-self-assignment `_
+for more information.
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-self-assignment.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-self-assignment.rst
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-self-assignment.rst
@@ -3,11 +3,14 @@
 bugprone-unhandled-self-assignment
 ==
 
+`cert-oop54-cpp` redirects here as an alias for this check. For the cert alias
+WarnOnlyIfThisHasSuspiciousField option is set to `0`.
+
 Finds user-defined copy

[PATCH] D62115: fix a issue that clang is incompatible with gcc with -H option.

2019-05-21 Thread Kan Shengchen via Phabricator via cfe-commits
skan marked an inline comment as done.
skan added inline comments.



Comment at: lib/Frontend/HeaderIncludeGen.cpp:55
+  // Simplify Filename that starts with "./"
+  if (Filename.startswith("./"));
+Filename=Filename.substr(2);

lebedev.ri wrote:
> skan wrote:
> > craig.topper wrote:
> > > skan wrote:
> > > > lebedev.ri wrote:
> > > > > xiangzhangllvm wrote:
> > > > > > Need remove ";" ? 
> > > > > This was fixed but no test was added?
> > > > > Was some existing test failing previously? Which one?
> > > > The test is in the file 'clang_H_opt.c'  which is included in this 
> > > > patch.
> > > The extra semicolon would have caused the body of the 'if' to execute 
> > > unconditionally. Did any existing test case fail for that in your local 
> > > testing? Or did you not test with that mistake?
> > i fixed the mistake in the updated patch.  I ran the test in 
> > 'clang_H_opt.c' alone for this patch. The extra semicolon caused the body 
> > of `if` to exeute always, which didn't cause the test to fail. 
> > The extra semicolon caused the body of if to exeute always, which didn't 
> > cause the test to fail.
> 
> That is the question.
> Is there test coverage with that error?
No. I just run alll the tests for clang, and all of them can pass even if the 
extra semicolon exits. If we want to add  a test to cover that error, we have 
to add a headerfile outside the 'test/Driver' directory. Do we need to add the 
test to cover that error?


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

https://reviews.llvm.org/D62115



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


[PATCH] D62115: fix a issue that clang is incompatible with gcc with -H option.

2019-05-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/Frontend/HeaderIncludeGen.cpp:55
+  // Simplify Filename that starts with "./"
+  if (Filename.startswith("./"));
+Filename=Filename.substr(2);

skan wrote:
> lebedev.ri wrote:
> > skan wrote:
> > > craig.topper wrote:
> > > > skan wrote:
> > > > > lebedev.ri wrote:
> > > > > > xiangzhangllvm wrote:
> > > > > > > Need remove ";" ? 
> > > > > > This was fixed but no test was added?
> > > > > > Was some existing test failing previously? Which one?
> > > > > The test is in the file 'clang_H_opt.c'  which is included in this 
> > > > > patch.
> > > > The extra semicolon would have caused the body of the 'if' to execute 
> > > > unconditionally. Did any existing test case fail for that in your local 
> > > > testing? Or did you not test with that mistake?
> > > i fixed the mistake in the updated patch.  I ran the test in 
> > > 'clang_H_opt.c' alone for this patch. The extra semicolon caused the body 
> > > of `if` to exeute always, which didn't cause the test to fail. 
> > > The extra semicolon caused the body of if to exeute always, which didn't 
> > > cause the test to fail.
> > 
> > That is the question.
> > Is there test coverage with that error?
> No. I just run alll the tests for clang, and all of them can pass even if the 
> extra semicolon exits. If we want to add  a test to cover that error, we have 
> to add a headerfile outside the 'test/Driver' directory. Do we need to add 
> the test to cover that error?
Then yes please, do add test coverage for that bug :)


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

https://reviews.llvm.org/D62115



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-21 Thread Ethan Sommer via Phabricator via cfe-commits
E5ten added a comment.

I might be doing something wrong but this seems to have broken 
BUILD_SHARED_LIBS for me in that even with that enabled clang is built as a 
bunch of static libraries linked into a shared one like this patch is supposed 
to make it do, while I thought that BUILD_SHARED_LIBS was supposed to make it 
create a bunch of shared libraries as it did before with libclang and still 
does with libLLVM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61909



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


[PATCH] D59329: [LibTooling] Add NodeId, a strong type for AST-matcher node identifiers.

2019-05-21 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel abandoned this revision.
ymandel marked an inline comment as done.
ymandel added inline comments.



Comment at: clang/include/clang/Tooling/Refactoring/NodeId.h:29
+public:
+  explicit NodeId(std::string Id) : Id(std::move(Id)) {}
+

ilya-biryukov wrote:
> What are the use-cases for passing a custom id to this class?
> If the purpose is to hide the IDs from the user, exposing this constructor 
> seems to be against this goal.
If there are errors relating to the id (say, referencing it in a stencil when 
it wasn't bound in the match), the errors are hard to understand when the id is 
auto-generated. In general, I'd say that best practice is to explicitly specify 
the id so that dynamic failures print a meaningful id.  The default constructor 
is a compromise and perhaps shouldn't be exported.

that said, if we could find another way to give good error messages (for 
example, if we could somehow grab the line number of the declaration), then the 
default construction would be the preferred approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59329



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2019-05-21 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

And this patch actually fixes the bug. Thanks.


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

https://reviews.llvm.org/D43576



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


[PATCH] D43576: Solution to fix PR27066 - Redefinition with same mangled name as another definition (dllexport and uuid)

2019-05-21 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 200484.

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

https://reviews.llvm.org/D43576

Files:
  include/clang/AST/Decl.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DeclNodes.td
  include/clang/Sema/ParsedAttr.h
  include/clang/Sema/Sema.h
  lib/AST/Decl.cpp
  lib/AST/DeclBase.cpp
  lib/AST/DeclCXX.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTCommon.cpp
  test/Sema/ms-uuid-1.cpp
  test/Sema/ms-uuid-2.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -321,12 +321,15 @@
 OS << "\" << get" << getUpperName() << "().getAsString() << \"";
   else if (type == "ParamIdx")
 OS << "\" << get" << getUpperName() << "().getSourceIndex() << \"";
-  else
+  else if (type == "DeclSpecUuidDecl *") {
+OS << "\" << get" << getUpperName() << "() << \"";
+  } else
 OS << "\" << get" << getUpperName() << "() << \"";
 }
 
 void writeDump(raw_ostream &OS) const override {
-  if (type == "FunctionDecl *" || type == "NamedDecl *") {
+  if (type == "FunctionDecl *" || type == "NamedDecl *" ||
+  type == "DeclSpecUuidDecl *") {
 OS << "OS << \" \";\n";
 OS << "dumpBareDeclRef(SA->get" << getUpperName() << "());\n"; 
   } else if (type == "IdentifierInfo *") {
@@ -1296,6 +1299,9 @@
 Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "VersionArgument")
 Ptr = llvm::make_unique(Arg, Attr);
+  else if (ArgName == "DeclSpecUuidDeclArgument")
+Ptr = llvm::make_unique(Arg, Attr, "DeclSpecUuidDecl *");
+
 
   if (!Ptr) {
 // Search in reverse order so that the most-derived type is handled first.
Index: test/Sema/ms-uuid-2.cpp
===
--- /dev/null
+++ test/Sema/ms-uuid-2.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -fms-compatibility -std=c++14  %s
+
+
+typedef struct _GUID
+{
+unsigned long  Data1;
+unsigned short Data2;
+unsigned short Data3;
+unsigned char  Data4[8];
+} GUID;
+
+// expected-error@+5 {{C++ requires a type specifier for all declarations}}
+// expected-error@+4 {{invalid digit 'a' in decimal constant}}
+// expected-error@+3 {{use of undeclared identifier 'def0'}}
+// expected-error@+2 {{invalid digit 'a' in decimal constant}}
+// expected-error@+1 {{expected ';' after top level declarator}}
+uuid(12345678-9abc-def0-1234-56789abcdef0) struct S2;
+
Index: test/Sema/ms-uuid-1.cpp
===
--- /dev/null
+++ test/Sema/ms-uuid-1.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -fms-compatibility -std=c++14 %s
+// expected-no-diagnostics
+typedef struct _GUID {
+  int i;
+} IID;
+template 
+class A {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S1 {};
+
+struct
+__declspec(uuid("{DDB47A6A-0F23-11D5-9109-00E0296B75D3}"))
+S2 {};
+
+struct __declspec(dllexport)
+C1 : public A<&__uuidof(S1)> {};
+
+struct __declspec(dllexport)
+C2 : public A<&__uuidof(S2)> {};
+int printf(const char *, ...);
+int main() {
+
+  if (&__uuidof(S1) == &__uuidof(S2))
+printf("OK\n");
+  else
+printf("ERROR\n");
+
+  return 0;
+}
Index: lib/Serialization/ASTCommon.cpp
===
--- lib/Serialization/ASTCommon.cpp
+++ lib/Serialization/ASTCommon.cpp
@@ -348,6 +348,7 @@
   case Decl::ObjCProtocol:
   case Decl::ObjCInterface:
   case Decl::Empty:
+  case Decl::DeclSpecUuid:
 return true;
 
   // Never redeclarable.
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -630,6 +630,11 @@
   return Inst;
 }
 
+ Decl *
+ TemplateDeclInstantiator::VisitDeclSpecUuidDecl(DeclSpecUuidDecl *D) {
+   llvm_unreachable("DeclSpecUuidDecl cannot be instantiated");
+}
+
 Decl *TemplateDeclInstantiator::InstantiateTypedefNameDecl(TypedefNameDecl *D,
bool IsTypeAlias) {
   bool Invalid = false;
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -628,11 +628,12 @@
   return ExprError(Diag(TypeidLoc, diag::err_uuidof_without_guid));
 if (UuidAttrs.size() > 1)
   return ExprError(Diag(TypeidLoc, diag::err_uuidof_with_multiple_guids));
-UuidStr = UuidA

[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-21 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Ping.  Is anyone willing to be the reviewer for this revision?

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386



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


[PATCH] D56933: [Tooling][RFC] Introduce Stencil library to simplify source code generation in refactorings.

2019-05-21 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel abandoned this revision.
ymandel added a comment.

This ideas in this revisions are gradually being committed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56933



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


[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-05-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:2840
   Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device);
+  Opts.OpenMPHasTargets =
+  Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_targets_EQ);

We already have `Opts.OMPTargetTripples`. We use it currently to check if the 
offloading enabled `!CGM.getLangOpts().OMPTargetTriples.empty()`, so, probably, 
we don't need this new flag.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D58033: Add option for emitting dbg info for call site parameters

2019-05-21 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 200485.
djtodoro added a comment.

-Set `EnableDebugEntryValues` only for a higher level of optimizations (-O1 and 
higher)


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

https://reviews.llvm.org/D58033

Files:
  include/clang/Basic/CodeGenOptions.def
  include/clang/Driver/CC1Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGenCXX/dbg-info-all-calls-described.cpp


Index: test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- test/CodeGenCXX/dbg-info-all-calls-described.cpp
+++ test/CodeGenCXX/dbg-info-all-calls-described.cpp
@@ -15,6 +15,13 @@
 // RUN: | FileCheck %s -check-prefix=HAS-ATTR \
 // RUN: -implicit-check-not=DISubprogram 
-implicit-check-not=DIFlagAllCallsDescribed
 
+// Supported: DWARF4 + GDB tuning by using '-femit-debug-entry-values'
+// RUN: %clang_cc1 -femit-debug-entry-values -emit-llvm %s -o - \
+// RUN:   -O1 -disable-llvm-passes -debugger-tuning=gdb \
+// RUN:   -debug-info-kind=standalone -dwarf-version=4 \
+// RUN: | FileCheck %s -check-prefix=HAS-ATTR \
+// RUN: -implicit-check-not=DIFlagAllCallsDescribed
+
 // Supported: DWARF4 + LLDB tuning, -O1, line-tables only DI
 // RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -O1 -disable-llvm-passes \
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -746,6 +746,8 @@
 
   Opts.DisableLLVMPasses = Args.hasArg(OPT_disable_llvm_passes);
   Opts.DisableLifetimeMarkers = Args.hasArg(OPT_disable_lifetimemarkers);
+  if (Opts.OptimizationLevel > 0)
+Opts.EnableDebugEntryValues = Args.hasArg(OPT_femit_debug_entry_values);
   Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
   Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
   Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4558,7 +4558,10 @@
   // were part of DWARF v4.
   bool SupportsDWARFv4Ext =
   CGM.getCodeGenOpts().DwarfVersion == 4 &&
-  CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB;
+  (CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::LLDB ||
+   (CGM.getCodeGenOpts().EnableDebugEntryValues &&
+   CGM.getCodeGenOpts().getDebuggerTuning() == llvm::DebuggerKind::GDB));
+
   if (!SupportsDWARFv4Ext && CGM.getCodeGenOpts().DwarfVersion < 5)
 return llvm::DINode::FlagZero;
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -463,6 +463,7 @@
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
+  Options.EnableDebugEntryValues = CodeGenOpts.EnableDebugEntryValues;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
 Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Index: include/clang/Driver/CC1Options.td
===
--- include/clang/Driver/CC1Options.td
+++ include/clang/Driver/CC1Options.td
@@ -364,6 +364,8 @@
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
 def fthin_link_bitcode_EQ : Joined<["-"], "fthin-link-bitcode=">,
 HelpText<"Write minimized bitcode to  for the ThinLTO thin link 
only">;
+def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
+HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
 HelpText<"Prints debug information for the new pass manager">;
 def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
Index: include/clang/Basic/CodeGenOptions.def
===
--- include/clang/Basic/CodeGenOptions.def
+++ include/clang/Basic/CodeGenOptions.def
@@ -61,6 +61,7 @@
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
+CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.


Index: test/CodeGenCXX/dbg-info-all-calls-described.cpp
===
--- test/CodeGenCXX/dbg-info-all-calls-described.cpp

[clang-tools-extra] r361258 - [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag to force it.

2019-05-21 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue May 21 06:40:31 2019
New Revision: 361258

URL: http://llvm.org/viewvc/llvm-project?rev=361258&view=rev
Log:
[clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag to 
force it.

Reviewers: kadircet

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

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/CodeComplete.cpp
clang-tools-extra/trunk/clangd/CodeComplete.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
clang-tools-extra/trunk/clangd/unittests/ClangdTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=361258&r1=361257&r2=361258&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue May 21 06:40:31 2019
@@ -200,10 +200,12 @@ void ClangdServer::codeComplete(PathRef
   };
 
   // We use a potentially-stale preamble because latency is critical here.
-  WorkScheduler.runWithPreamble("CodeComplete", File,
-Opts.AllowFallback ? TUScheduler::StaleOrAbsent
-   : TUScheduler::Stale,
-Bind(Task, File.str(), std::move(CB)));
+  WorkScheduler.runWithPreamble(
+  "CodeComplete", File,
+  (Opts.RunParser == CodeCompleteOptions::AlwaysParse)
+  ? TUScheduler::Stale
+  : TUScheduler::StaleOrAbsent,
+  Bind(Task, File.str(), std::move(CB)));
 }
 
 void ClangdServer::signatureHelp(PathRef File, Position Pos,

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=361258&r1=361257&r2=361258&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Tue May 21 06:40:31 2019
@@ -1738,9 +1738,10 @@ codeComplete(PathRef FileName, const too
   auto Flow = CodeCompleteFlow(
   FileName, Preamble ? Preamble->Includes : IncludeStructure(),
   SpecFuzzyFind, Opts);
-  return Preamble ? std::move(Flow).run(
-{FileName, Command, Preamble, Contents, *Offset, VFS})
-  : std::move(Flow).runWithoutSema(Contents, *Offset, VFS);
+  return (!Preamble || Opts.RunParser == CodeCompleteOptions::NeverParse)
+ ? std::move(Flow).runWithoutSema(Contents, *Offset, VFS)
+ : std::move(Flow).run(
+   {FileName, Command, Preamble, Contents, *Offset, VFS});
 }
 
 SignatureHelp signatureHelp(PathRef FileName,

Modified: clang-tools-extra/trunk/clangd/CodeComplete.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.h?rev=361258&r1=361257&r2=361258&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.h (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.h Tue May 21 06:40:31 2019
@@ -115,11 +115,18 @@ struct CodeCompleteOptions {
   /// Such completions can insert scope qualifiers.
   bool AllScopes = false;
 
-  /// Whether to allow falling back to code completion without compiling files
-  /// (using identifiers in the current file and symbol indexes), when file
-  /// cannot be built (e.g. missing compile command), or the build is not ready
-  /// (e.g. preamble is still being built).
-  bool AllowFallback = false;
+  /// Whether to use the clang parser, or fallback to text-based completion
+  /// (using identifiers in the current file and symbol indexes).
+  enum CodeCompletionParse {
+/// Block until we can run the parser (e.g. preamble is built).
+/// Return an error if this fails.
+AlwaysParse,
+/// Run the parser if inputs (preamble) are ready.
+/// Otherwise, use text-based completion.
+ParseIfReady,
+/// Always use text-based completion.
+NeverParse,
+  } RunParser = ParseIfReady;
 };
 
 // Semi-structured representation of a code-complete suggestion for our C++ 
API.

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp?rev=361258&r1=361257&r2=361258&view=diff
==
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp Tue May 21 06:40:31 2019
@@ -256,13 +256,18 @@ static llvm::cl::opt For
 "Offsets are in UTF-16 code units")),
 llvm::cl::init(OffsetEncoding::UnsupportedEncoding));
 
-static llvm::cl::

[PATCH] D62135: [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag to force it.

2019-05-21 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361258: [clangd] Turn no-parse-completion on by when 
preamble isn't ready. Add flag to… (authored by sammccall, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62135

Files:
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/CodeComplete.cpp
  clang-tools-extra/trunk/clangd/CodeComplete.h
  clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
  clang-tools-extra/trunk/clangd/unittests/ClangdTests.cpp

Index: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
@@ -256,13 +256,18 @@
 "Offsets are in UTF-16 code units")),
 llvm::cl::init(OffsetEncoding::UnsupportedEncoding));
 
-static llvm::cl::opt AllowFallbackCompletion(
-"allow-fallback-completion",
-llvm::cl::desc(
-"Allow falling back to code completion without compiling files (using "
-"identifiers and symbol indexes), when file cannot be built or the "
-"build is not ready."),
-llvm::cl::init(false));
+static llvm::cl::opt
+CodeCompletionParse(
+"completion-parse",
+llvm::cl::desc("Whether the clang-parser is used for code-completion"),
+llvm::cl::values(clEnumValN(CodeCompleteOptions::AlwaysParse, "always",
+"Block until the parser can be used"),
+ clEnumValN(CodeCompleteOptions::ParseIfReady, "auto",
+"Use text-based completion if the parser "
+"is not ready"),
+ clEnumValN(CodeCompleteOptions::NeverParse, "never",
+"Always used text-based completion")),
+llvm::cl::init(CodeCompleteOptions().RunParser), llvm::cl::Hidden);
 
 namespace {
 
@@ -475,7 +480,7 @@
   CCOpts.SpeculativeIndexRequest = Opts.StaticIndex;
   CCOpts.EnableFunctionArgSnippets = EnableFunctionArgSnippets;
   CCOpts.AllScopes = AllScopesCompletion;
-  CCOpts.AllowFallback = AllowFallbackCompletion;
+  CCOpts.RunParser = CodeCompletionParse;
 
   RealFileSystemProvider FSProvider;
   // Initialize and run ClangdLSPServer.
Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -200,10 +200,12 @@
   };
 
   // We use a potentially-stale preamble because latency is critical here.
-  WorkScheduler.runWithPreamble("CodeComplete", File,
-Opts.AllowFallback ? TUScheduler::StaleOrAbsent
-   : TUScheduler::Stale,
-Bind(Task, File.str(), std::move(CB)));
+  WorkScheduler.runWithPreamble(
+  "CodeComplete", File,
+  (Opts.RunParser == CodeCompleteOptions::AlwaysParse)
+  ? TUScheduler::Stale
+  : TUScheduler::StaleOrAbsent,
+  Bind(Task, File.str(), std::move(CB)));
 }
 
 void ClangdServer::signatureHelp(PathRef File, Position Pos,
Index: clang-tools-extra/trunk/clangd/CodeComplete.cpp
===
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp
@@ -1738,9 +1738,10 @@
   auto Flow = CodeCompleteFlow(
   FileName, Preamble ? Preamble->Includes : IncludeStructure(),
   SpecFuzzyFind, Opts);
-  return Preamble ? std::move(Flow).run(
-{FileName, Command, Preamble, Contents, *Offset, VFS})
-  : std::move(Flow).runWithoutSema(Contents, *Offset, VFS);
+  return (!Preamble || Opts.RunParser == CodeCompleteOptions::NeverParse)
+ ? std::move(Flow).runWithoutSema(Contents, *Offset, VFS)
+ : std::move(Flow).run(
+   {FileName, Command, Preamble, Contents, *Offset, VFS});
 }
 
 SignatureHelp signatureHelp(PathRef FileName,
Index: clang-tools-extra/trunk/clangd/CodeComplete.h
===
--- clang-tools-extra/trunk/clangd/CodeComplete.h
+++ clang-tools-extra/trunk/clangd/CodeComplete.h
@@ -115,11 +115,18 @@
   /// Such completions can insert scope qualifiers.
   bool AllScopes = false;
 
-  /// Whether to allow falling back to code completion without compiling files
-  /// (using identifiers in the current file and symbol indexes), when file
-  /// cannot be built (e.g. missing compile command), or the build is not ready
-  /// (e.g. preamble is still being built).
-  bool AllowFallback = false;
+  /// Whe

[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-05-21 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 200486.
djtodoro added a comment.

-Use `SPCache` instead of `DeclCache`
-Refactor the code by addressing suggestions


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

https://reviews.llvm.org/D58035

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParamCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3515,6 +3516,12 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  // We use the SPCache only in the case when the debug entry values option is
+  // set, in order to speed up parameters modification analysis.
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl &&
+  isa(D))
+SPCache[cast(D)->getCanonicalDecl()].reset(SP);
+
   if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
 // Starting with DWARF V5 method declarations are emitted as children of
 // the interface type.
@@ -3880,6 +3887,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, 
CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && ArgNo) {
+if (auto *PD = dyn_cast(VD))
+  ParamCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4454,6 +4466,26 @@
   TheCU->setDWOId(Signature);
 }
 
+static void analyzeParametersModification(
+ASTContext &Ctx,
+llvm::DenseMap &SPCache,
+llvm::DenseMap &ParamCache) {
+  for (auto &SP : SPCache) {
+auto *FD = SP.first;
+const Stmt *FuncBody = (*FD).getBody();
+for (auto Parm : FD->parameters()) {
+  ExprMutationAnalyzer FuncAnalyzer(*FuncBody, Ctx);
+  if (!FuncAnalyzer.isMutated(Parm)) {
+auto I = ParamCache.find(Parm);
+if (I != ParamCache.end()) {
+  auto *DIParm = cast(I->second);
+  DIParm->setIsNotModified();
+}
+  }
+}
+  }
+}
+
 void CGDebugInfo::finalize() {
   // Creating types might create further types - invalidating the current
   // element and the size(), so don't cache/reference them.
@@ -4526,6 +4558,10 @@
 if (auto MD = TypeCache[RT])
   DBuilder.retainType(cast(MD));
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues)
+// This will be used to emit debug entry values.
+analyzeParametersModification(CGM.getContext(), SPCache, ParamCache);
+
   DBuilder.finalize();
 }
 


Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -133,6 +133,7 @@
 
   llvm::DenseMap DIFileCache;
   llvm::DenseMap SPCache;
+  llvm::DenseMap ParamCache;
   /// Cache declarations relevant to DW_TAG_imported_declarations (C++
   /// using declarations) that aren't covered by other more specific caches.
   llvm::DenseMap DeclCache;
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -18,6 +18,7 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
+#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclFriend.h"
 #include "clang/AST/DeclObjC.h"
@@ -3515,6 +3516,12 @@
   if (HasDecl && isa(D))
 DeclCache[D->getCanonicalDecl()].reset(SP);
 
+  // We use the SPCache only in the case when the debug entry values option is
+  // set, in order to speed up parameters modification analysis.
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl &&
+  isa(D))
+SPCache[cast(D)->getCanonicalDecl()].reset(SP);
+
   if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
 // Starting with DWARF V5 method declarations are emitted as children of
 // the interface type.
@@ -3880,6 +3887,11 @@
  llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
  Builder.GetInsertBlock());
 
+  if (CGM.getCodeGenOpts().EnableDebugEntryValues && ArgNo) {
+if (auto *PD = dyn_cast(VD))
+  ParamCache[PD].reset(D);
+  }
+
   return D;
 }
 
@@ -4454,6 +4466,26 @@
   TheCU->setDWOId(Signature);
 }
 
+static void analyzeParametersMo

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-05-21 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:2840
   Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_is_device);
+  Opts.OpenMPHasTargets =
+  Opts.OpenMP && Args.hasArg(options::OPT_fopenmp_targets_EQ);

ABataev wrote:
> We already have `Opts.OMPTargetTripples`. We use it currently to check if the 
> offloading enabled `!CGM.getLangOpts().OMPTargetTriples.empty()`, so, 
> probably, we don't need this new flag.
Even better!! I'll make the change!


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D60763: Prototype OpenCL BIFs using Tablegen

2019-05-21 Thread Pierre via Phabricator via cfe-commits
Pierre added a comment.

The wrong patch was uploaded. Sorry for this.




Comment at: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp:107
+  //<, 35>.
+  // TODO: Check the other types of vector available for performance purpose
+  std::vector, unsigned>> SignatureSet;

Anastasia wrote:
> Is this TODO still relevant?
This is still relevant, but not for this patch I think.


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

https://reviews.llvm.org/D60763



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


[PATCH] D60763: Prototype OpenCL BIFs using Tablegen

2019-05-21 Thread Pierre via Phabricator via cfe-commits
Pierre updated this revision to Diff 200499.
Pierre marked 9 inline comments as done.

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

https://reviews.llvm.org/D60763

Files:
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/OpenCLBuiltins.td
  clang/include/clang/Driver/CC1Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCL/builtin-new.cl
  clang/utils/TableGen/CMakeLists.txt
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -80,6 +80,7 @@
 void EmitTestPragmaAttributeSupportedAttributes(llvm::RecordKeeper &Records,
 llvm::raw_ostream &OS);
 
+void EmitClangOpenCLBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 } // end namespace clang
 
 #endif
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -61,7 +61,8 @@
   GenDiagDocs,
   GenOptDocs,
   GenDataCollectors,
-  GenTestPragmaAttributeSupportedAttributes
+  GenTestPragmaAttributeSupportedAttributes,
+  GenClangOpenCLBuiltins,
 };
 
 namespace {
@@ -163,7 +164,9 @@
 clEnumValN(GenTestPragmaAttributeSupportedAttributes,
"gen-clang-test-pragma-attribute-supported-attributes",
"Generate a list of attributes supported by #pragma clang "
-   "attribute for testing purposes")));
+   "attribute for testing purposes"),
+clEnumValN(GenClangOpenCLBuiltins, "gen-clang-opencl-builtins",
+   "Generate OpenCL builtin handlers")));
 
 cl::opt
 ClangComponent("clang-component",
@@ -293,6 +296,9 @@
   case GenTestPragmaAttributeSupportedAttributes:
 EmitTestPragmaAttributeSupportedAttributes(Records, OS);
 break;
+  case GenClangOpenCLBuiltins:
+EmitClangOpenCLBuiltins(Records, OS);
+break;
   }
 
   return false;
Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- /dev/null
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -0,0 +1,325 @@
+//===- ClangOpenCLBuiltinEmitter.cpp - Generate Clang OpenCL Builtin handling
+//=-*- C++ -*--=//
+//
+// The LLVM Compiler Infrastructure
+//
+// 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
+//
+//===--===//
+//
+// This tablegen backend emits code allowing to check whether a function
+// belongs to OpenCL builtin functions. In the following case, all overloads
+// of this function are added to the LookupResult.
+// The code is generated in "OpenCLBuiltins.inc" and included by Clang
+// SemaLookup.cpp
+//
+// The resolution of a function name and its overload is follwing these steps:
+// for the function "cos", which has the overloads:
+//- float   cos(float)
+//- double  cos(double)
+//
+// 1-  = isOpenCLBuiltin("cos")
+// 2- OpenCLBuiltins[Index - Index + Len] contains the pairs
+//   of the overloads of "cos".
+// 3- OpenCLSignature[SignatureIndex, SignatureIndex + SignatureLen] contains
+//  one of the signaures of "cos". This OpenCLSignature table can be
+//  referenced by other functions, i.e. "sin", since multiple functions
+//  can have the same signature.
+//===--===//
+
+#include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/TableGen/Error.h"
+#include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/StringMatcher.h"
+#include "llvm/TableGen/TableGenBackend.h"
+#include 
+
+using namespace llvm;
+
+namespace {
+class BuiltinNameEmitter {
+public:
+  BuiltinNameEmitter(RecordKeeper &Records, raw_ostream &OS)
+  : Records(Records), OS(OS) {}
+
+  // Entrypoint to generate the functions/ structures allowing to check
+  // whether a function is part of OpenCL builtin functions.
+  void Emit();
+
+private:
+  // Contains OpenCL builtin functions and related information, stored as
+  // Record instances. They are coming from the associated TableGen file.
+  RecordKeeper &Records;
+  // The output file we are writing to.
+  raw_ostream &OS;

[PATCH] D61989: [clang-tidy] enable modernize-concat-nested-namespaces on header files

2019-05-21 Thread Xiao Shi via Phabricator via cfe-commits
shixiao added a comment.

@JonasToth, does this look reasonable to you? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61989



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


Re: r361152 - [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-21 Thread Nico Weber via cfe-commits
I'm suggesting you make the below change. For testing, I'd just try
building locally.

$ git diff
diff --git a/clang/unittests/Tooling/CMakeLists.txt
b/clang/unittests/Tooling/CMakeLists.txt
index 8c383be2d74..af8a35d9251 100644
--- a/clang/unittests/Tooling/CMakeLists.txt
+++ b/clang/unittests/Tooling/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Support
+  TestingSupport
   )

 # By default MSVC has a 2^16 limit on the number of sections in an object
file,
@@ -70,8 +71,6 @@ target_link_libraries(ToolingTests
   clangToolingCore
   clangToolingInclusions
   clangToolingRefactor
-  LLVMSupport
-  LLVMTestingSupport
   )

On Mon, May 20, 2019 at 9:49 PM Yitzhak Mandelbaum 
wrote:

> Nice, thanks for r361208.  As for support -- no, I didn't try that. I was
> following a pattern I saw elsewhere.  Do you suggest that I make that
> change? If so, any particular way to test it?
>
> thanks
>
> On Mon, May 20, 2019 at 8:26 PM Nico Weber  wrote:
>
>> +  LLVMSupport
>> +  LLVMTestingSupport
>>
>> clang/unittests/Tooling/CMakeLists already has this at the top:
>> set(LLVM_LINK_COMPONENTS
>>   ${LLVM_TARGETS_TO_BUILD}
>>   Support
>>   )
>>
>> I think we link Support twice now. Did adding TestingSupport up there not
>> work? I'd expect that your addition would break shared library builds, or
>> something like that.
>>
>> (Also, I tried to fix a build error that old gcc versions had with this
>> change in r361208.)
>>
>> *From: *Yitzhak Mandelbaum via cfe-commits 
>> *Date: *Mon, May 20, 2019 at 9:12 AM
>> *To: * 
>>
>> Author: ymandel
>>> Date: Mon May 20 06:15:14 2019
>>> New Revision: 361152
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=361152&view=rev
>>> Log:
>>> [LibTooling] Add RangeSelector library for defining source ranges based
>>> on bound AST nodes.
>>>
>>> Summary:
>>>
>>> The RangeSelector library defines a combinator language for specifying
>>> source
>>> ranges based on bound ids for AST nodes.  The combinator approach
>>> follows the
>>> design of the AST matchers.  The RangeSelectors defined here will be
>>> used in
>>> both RewriteRule, for specifying source affected by edit, and in Stencil
>>> for
>>> specifying source to use constructively in a replacement.
>>>
>>> Reviewers: ilya-biryukov
>>>
>>> Subscribers: mgorny, cfe-commits
>>>
>>> Tags: #clang
>>>
>>> Differential Revision: https://reviews.llvm.org/D61774
>>>
>>> Added:
>>> cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h
>>> cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
>>> cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp
>>> Modified:
>>> cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
>>> cfe/trunk/unittests/Tooling/CMakeLists.txt
>>>
>>> Added: cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h?rev=361152&view=auto
>>>
>>> ==
>>> --- cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h (added)
>>> +++ cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h Mon May
>>> 20 06:15:14 2019
>>> @@ -0,0 +1,80 @@
>>> +//===--- RangeSelector.h - Source-selection library -*- 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
>>> +//
>>>
>>> +//===--===//
>>> +///
>>> +///  \file
>>> +///  Defines a combinator library supporting the definition of
>>> _selectors_,
>>> +///  which select source ranges based on (bound) AST nodes.
>>> +///
>>>
>>> +//===--===//
>>> +
>>> +#ifndef LLVM_CLANG_TOOLING_REFACTOR_RANGE_SELECTOR_H_
>>> +#define LLVM_CLANG_TOOLING_REFACTOR_RANGE_SELECTOR_H_
>>> +
>>> +#include "clang/ASTMatchers/ASTMatchFinder.h"
>>> +#include "clang/Basic/SourceLocation.h"
>>> +#include "llvm/ADT/StringRef.h"
>>> +#include "llvm/Support/Error.h"
>>> +#include 
>>> +
>>> +namespace clang {
>>> +namespace tooling {
>>> +using RangeSelector = std::function(
>>> +const ast_matchers::MatchFinder::MatchResult &)>;
>>> +
>>> +inline RangeSelector charRange(CharSourceRange R) {
>>> +  return [R](const ast_matchers::MatchFinder::MatchResult &)
>>> + -> Expected { return R; };
>>> +}
>>> +
>>> +/// Selects from the start of \p Begin and to the end of \p End.
>>> +RangeSelector range(RangeSelector Begin, RangeSelector End);
>>> +
>>> +/// Convenience version of \c range where end-points are bound nodes.
>>> +RangeSelector range(StringRef BeginID, StringRef EndID);
>>> +
>>> +/// Selects a node, including trailing semicolon (for non-expression
>>> +/// statements). \p ID is the node's binding in the match result.
>>> +

r361261 - [ARM][CMSE] Add commandline option and feature macro

2019-05-21 Thread Javed Absar via cfe-commits
Author: javed.absar
Date: Tue May 21 07:21:26 2019
New Revision: 361261

URL: http://llvm.org/viewvc/llvm-project?rev=361261&view=rev
Log:
[ARM][CMSE] Add commandline option and feature macro

Defines macro ARM_FEATURE_CMSE to 1 for v8-M targets and introduces
-mcmse option which for v8-M targets sets ARM_FEATURE_CMSE to 3.
A diagnostic is produced when the option is given on architectures
without support for Security Extensions.
Reviewed By: dmgreen, snidertm
Differential Revision: https://reviews.llvm.org/D59879


Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/ARM.cpp
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Preprocessor/arm-target-features.c

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=361261&r1=361260&r2=361261&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue May 21 07:21:26 2019
@@ -299,6 +299,9 @@ def ObjC : LangOpt<"ObjC">;
 def BlocksSupported : LangOpt<"Blocks">;
 def ObjCAutoRefCount : LangOpt<"ObjCAutoRefCount">;
 
+// Language option for CMSE extensions
+def Cmse : LangOpt<"Cmse">;
+
 // Defines targets for target-specific attributes. Empty lists are unchecked.
 class TargetSpec {
   // Specifies Architectures for which the target applies, based off the

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=361261&r1=361260&r2=361261&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Tue May 21 07:21:26 
2019
@@ -252,6 +252,8 @@ def err_target_unsupported_unaligned : E
   "the %0 sub-architecture does not support unaligned accesses">;
 def err_target_unsupported_execute_only : Error<
   "execute only is not supported for the %0 sub-architecture">;
+def err_target_unsupported_mcmse : Error<
+  "-mcmse is not supported for %0">;
 def err_opt_not_valid_with_opt : Error<
   "option '%0' cannot be specified with '%1'">;
 def err_opt_not_valid_without_opt : Error<

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=361261&r1=361260&r2=361261&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Tue May 21 07:21:26 2019
@@ -300,6 +300,8 @@ LANGOPT(SanitizeAddressFieldPadding, 2,
"field padding (0: none, 1:least "
"aggressive, 2: more aggressive)")
 
+LANGOPT(Cmse, 1, 0, "ARM Security extensions support")
+
 LANGOPT(XRayInstrument, 1, 0, "controls whether to do XRay instrumentation")
 LANGOPT(XRayAlwaysEmitCustomEvents, 1, 0,
 "controls whether to always emit intrinsic calls to "

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=361261&r1=361260&r2=361261&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue May 21 07:21:26 2019
@@ -2143,6 +2143,9 @@ def mnocrc : Flag<["-"], "mnocrc">, Grou
   HelpText<"Disallow use of CRC instructions (ARM only)">;
 def mno_neg_immediates: Flag<["-"], "mno-neg-immediates">, 
Group,
   HelpText<"Disallow converting instructions with negative immediates to their 
negation or inversion.">;
+def mcmse : Flag<["-"], "mcmse">, Group,
+  Flags<[DriverOption,CC1Option]>,
+  HelpText<"Allow use of CMSE (Armv8-M Security Extensions)">;
 
 def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, 
Group,
   HelpText<"Generate code which only uses the general purpose registers 
(AArch64 only)">;

Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=361261&r1=361260&r2=361261&view=diff
==
--- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/ARM.cpp Tue May 21 07:21:26 2019
@@ -434,6 +434,11 @@ bool ARMTargetInfo::handleTargetFeatures
   DSP = 1;
 } else if (Feature == "+fp-only-sp") {
   HW_FP_remove |= HW_FP_DP;
+} els

[PATCH] D62152: [ARM][AArch64] Fix incorrect handling of alignment in va_arg code generation

2019-05-21 Thread John Brawn via Phabricator via cfe-commits
john.brawn added a comment.

In D62152#1508979 , @efriedma wrote:

> Please verify my understanding of the following is correct:
>
> 1. getTypeUnadjustedAlign() is currently only used to compute calling 
> convention alignment for ARM and AArch64.


Yes, the only places it's called are AArch64ABIInfo::classifyArgumentType and 
ARMABIInfo::classifyArgumentType.

> 2. Without this patch, we use the unadjusted alignment to pass arguments, but 
> the adjusted alignment to compute the alignment for the corresponding va_arg 
> calls.

Yes.

> 3. Without this patch, the unadjusted alignment for non-struct types is 
> actually adjusted based on attributes on typedefs.

Only in va_arg. For example if you look at

  typedef int aligned_int __attribute__((aligned(8)));
  aligned_int called_fn(int a1, aligned_int a2) {
return a2;
  }
  aligned_int calling_fn() {
return called_fn(1,2);
  }

a2 is passed in r1 by calling_fn, and read from it in called_fn (both before 
and after this patch). However for

  typedef int aligned_int __attribute__((aligned(8)));
  aligned_int called_fn(int a1, ...) {
va_list ap;
va_start(ap, a1);
aligned_int a2 = va_arg(ap, aligned_int);
va_end(ap);
return a2;
  }
  aligned_int calling_fn() {
return called_fn(1,2);
  }

a2 is still passed in r1 by calling_fn, but the current clang behaviour in 
called_fn is that it pushes r1-r3 then loads the next 8-byte-aligned value, 
which will be the pushed r2 value.  This patch fixes this so that it doesn't 
8-byte align the load address, and so gets the pushed r1.

> I'm not confident about changing the calling convention again at this point 
> for non-struct types.  I guess it's obscure enough that changing it is 
> probably okay.  But would you mind splitting it into a separate followup, 
> with a better description of the impact?

This patch only changes the va_arg behaviour, and this whole thing with 
unadjusted alignment is from the published pcs 
(https://developer.arm.com/docs/ihi0042/latest/procedure-call-standard-for-the-arm-architecture-abi-2019q1-documentation
 and 
https://developer.arm.com/docs/ihi0055/latest/procedure-call-standard-for-the-arm-64-bit-architecture,
 though it's called "natural alignment" there).


Repository:
  rC Clang

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

https://reviews.llvm.org/D62152



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


[PATCH] D59879: [ARM][CMSE] Add commandline option and feature macro

2019-05-21 Thread Javed Absar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361261: [ARM][CMSE] Add commandline option and feature macro 
(authored by javed.absar, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D59879

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/ARM.cpp
  lib/Driver/ToolChains/Arch/ARM.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Preprocessor/arm-target-features.c

Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -2143,6 +2143,9 @@
   HelpText<"Disallow use of CRC instructions (ARM only)">;
 def mno_neg_immediates: Flag<["-"], "mno-neg-immediates">, Group,
   HelpText<"Disallow converting instructions with negative immediates to their negation or inversion.">;
+def mcmse : Flag<["-"], "mcmse">, Group,
+  Flags<[DriverOption,CC1Option]>,
+  HelpText<"Allow use of CMSE (Armv8-M Security Extensions)">;
 
 def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group,
   HelpText<"Generate code which only uses the general purpose registers (AArch64 only)">;
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -299,6 +299,9 @@
 def BlocksSupported : LangOpt<"Blocks">;
 def ObjCAutoRefCount : LangOpt<"ObjCAutoRefCount">;
 
+// Language option for CMSE extensions
+def Cmse : LangOpt<"Cmse">;
+
 // Defines targets for target-specific attributes. Empty lists are unchecked.
 class TargetSpec {
   // Specifies Architectures for which the target applies, based off the
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -300,6 +300,8 @@
"field padding (0: none, 1:least "
"aggressive, 2: more aggressive)")
 
+LANGOPT(Cmse, 1, 0, "ARM Security extensions support")
+
 LANGOPT(XRayInstrument, 1, 0, "controls whether to do XRay instrumentation")
 LANGOPT(XRayAlwaysEmitCustomEvents, 1, 0,
 "controls whether to always emit intrinsic calls to "
Index: include/clang/Basic/DiagnosticCommonKinds.td
===
--- include/clang/Basic/DiagnosticCommonKinds.td
+++ include/clang/Basic/DiagnosticCommonKinds.td
@@ -252,6 +252,8 @@
   "the %0 sub-architecture does not support unaligned accesses">;
 def err_target_unsupported_execute_only : Error<
   "execute only is not supported for the %0 sub-architecture">;
+def err_target_unsupported_mcmse : Error<
+  "-mcmse is not supported for %0">;
 def err_opt_not_valid_with_opt : Error<
   "option '%0' cannot be specified with '%1'">;
 def err_opt_not_valid_without_opt : Error<
Index: test/Preprocessor/arm-target-features.c
===
--- test/Preprocessor/arm-target-features.c
+++ test/Preprocessor/arm-target-features.c
@@ -198,6 +198,7 @@
 // V8M_BASELINE: #define __ARM_ARCH_ISA_THUMB 1
 // V8M_BASELINE: #define __ARM_ARCH_PROFILE 'M'
 // V8M_BASELINE-NOT: __ARM_FEATURE_CRC32
+// V8M_BASELINE: #define __ARM_FEATURE_CMSE 1
 // V8M_BASELINE-NOT: __ARM_FEATURE_DSP
 // V8M_BASELINE-NOT: __ARM_FP 0x{{.*}}
 // V8M_BASELINE-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
@@ -210,6 +211,7 @@
 // V8M_MAINLINE: #define __ARM_ARCH_ISA_THUMB 2
 // V8M_MAINLINE: #define __ARM_ARCH_PROFILE 'M'
 // V8M_MAINLINE-NOT: __ARM_FEATURE_CRC32
+// V8M_MAINLINE: #define __ARM_FEATURE_CMSE 1
 // V8M_MAINLINE-NOT: __ARM_FEATURE_DSP
 // V8M_MAINLINE-NOT: #define __ARM_FP 0x
 // V8M_MAINLINE: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
@@ -675,6 +677,24 @@
 // M7-THUMB-ALLOW-FP-INSTR:#define __ARM_FP 0xe
 // M7-THUMB-ALLOW-FP-INSTR:#define __ARM_FPV5__ 1
 
+// Check that -mcmse (security extension) option works correctly for v8-M targets
+// RUN: %clang -target armv8m.base-none-linux-gnu -mcmse -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=V8M_CMSE %s
+// RUN: %clang -target armv8m.main-none-linux-gnu -mcmse -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=V8M_CMSE %s
+// RUN: %clang -target arm-none-linux-gnu -mcpu=cortex-m33 -mcmse -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=V8M_CMSE %s
+// RUN: %clang -target arm -mcpu=cortex-m23 -mcmse -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=V8M_CMSE %s
+// V8M_CMSE-NOT: __ARM_FEATURE_CMSE 1
+// V8M_CMSE: #define __ARM_FEATURE_CMSE 3
+
+// Check that CMSE is not defined on architectures w/o support for security extension
+// RUN: %

[PATCH] D61643: [PragmaHandler][NFC] Expose `#pragma` location

2019-05-21 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked an inline comment as done.
jdenny added inline comments.



Comment at: clang/docs/ClangPlugins.rst:58
 ExamplePragmaHandler() : PragmaHandler("example_pragma") { }
-void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
   Token &PragmaTok) {

lebedev.ri wrote:
> jdenny wrote:
> > lebedev.ri wrote:
> > > Hmm.
> > > This will have effects on out-of-tree plugins that define pragmas.
> > > I'm not sure how to proceed here, just notify cfe-dev and move on?
> > We could do something like this in `PragmaHandler`:
> > 
> > ```
> >   virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind 
> > Introducer,
> > Token &FirstToken) {
> > llvm_unreachable("deprecated HandlePragma unexpectedly called");
> >   }
> >   virtual void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
> > Token &FirstToken) {
> > HandlePragma(PP, Introducer.Kind, FirstToken);
> >   }
> > ```
> > 
> > The derived class could override either one.  Unfortunately, if it didn't 
> > override either, the error is then at run time instead of compile time as 
> > it is now.
> > 
> > Whether this is worth it, I don't know.  Who's the right person to answer 
> > this question?
> I think mailing cfe-dev will get this question the most visibility.
> Though i //think// the solution will be to go with the current patch.
I tried that at

http://lists.llvm.org/pipermail/cfe-dev/2019-May/062297.htm

but it's been a week without a response.  I'm happy to try again, perhaps with 
a shorter more general email about `PragmaHandler` backward compatibility that 
might catch a different set of eyes.  Is it worth it, or should we just assume 
no response so far means no one thinks it's an issue?  Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61643



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


[PATCH] D61637: [Syntax] Introduce syntax trees

2019-05-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Definitely like the choice of CompositeNode owning the concrete storage!




Comment at: clang/include/clang/Tooling/Syntax/Arena.h:1
+//===- Arena.h - memory arena and bookkeeping for syntax trees --- C++ -*-===//
+//

From a user's point of view, this looks a lot like part of the tree structure 
in some sense.

If you expect that users will need to keep the arena rather than the 
TokenBuffer around (e.g. so nodes can be allocated), then it might make sense 
to declare it at the bottom of `Cascade.h`



Comment at: clang/include/clang/Tooling/Syntax/Corpus.h:38
+  std::pair>
+  tokenizeBuffer(std::unique_ptr Buffer);
+

ilya-biryukov wrote:
> sammccall wrote:
> > Are you planning to have a way to add tokens directly? Having to turn them 
> > into text and re-lex them seems like it might be inconvenient.
> The tokens have source locations and refer to a text in some buffer. 
> `tokenizeBuffer` makes is easier, not harder, to mock tokens.
Fair enough.

`lexBuffer` might be a slightly clearer name?

Who are the intended non-test users of this function? Are they better served by 
being able (and responsible) for constructing a MemoryBuffer with e.g. a 
sensible name and ownership, or would it be better to pass a StringRef and have 
the Arena come up with a sensible "anonymous" name?



Comment at: clang/include/clang/Tooling/Syntax/Corpus.h:40
+
+  /// Construct a new syntax node of a specified kind. The memory for a node is
+  /// owned by the corpus and will be freed when the corpus is destroyed.

ilya-biryukov wrote:
> sammccall wrote:
> > Now there's two ways to do this: `new (C.allocator()) T(...)` or 
> > `C.construct(...)`. Do we need both?
> > 
> > (If we do, is the syntax `new (C) T(...)` more natural?)
> I think `C.construct()` read better than `new (C) T(...)`. Not a big fan 
> of placement new exprs.
They are fairly consistently used in llvm/clang for this sort of thing, though.

I find it valuable because arena allocations look otherwise a lot like buggy 
ownership patterns. The dedicated syntax calls out the unusual case: we're 
creating a new thing, and someone else owns it, but won't do anything with it.



Comment at: clang/include/clang/Tooling/Syntax/Tree.h:11
+//
+// The code is divided in the following way:
+//   - 'Tree/Cascade.h' defines the basic structure of the syntax tree,

As discussed offline:
 - I don't think (at this point) we need an umbrella header. Generic tree 
structure, specific node semantics, and operations like "build a tree" are 
distinct enough from a user POV that asking them to include headers is fine. 
 - We may want an umbrella for the node types, if we end up splitting that, but 
no need yet.
 - Splitting generic tree stuff vs specific node stuff sounds good, but I think 
having them be sibling headers in `Tooling/Syntax` is enough - not sure about 
the `Tree/` subdirectory.

So I'd suggest something like:
 - `Tree/Cascade.h` + `Arena.h` --> `Tree.h`
 - `Tree.h` -> `BuildTree.h`
 - `Tree/Nodes.h` + `NodeKind.h` --> `Nodes.h`
(have comments on some of these throughout)



Comment at: clang/include/clang/Tooling/Syntax/Tree/Cascade.h:1
+//===- Tree.h - cascade of the syntax tree *- C++ 
-*-=//
+//

ilya-biryukov wrote:
> sammccall wrote:
> > sammccall wrote:
> > > sammccall wrote:
> > > > this is Cascade.h, not tree.h
> > > why "cascade"?
> > The Tree/ subdirectory seems superfluous - why are these separate from 
> > Syntax/?
> Cascade defines a few base nodes: a composite node (`TreeNode`) and a leaf 
> node that holds tokens.
> I'd really like to isolate them from language-specific nodes, so 
> language-specific nodes live in a separate file (`Nodes.h`).
> However, they need to see the definition of a composite node, hence the split.
> 
> Users are advised to use an umbrella header, `Tree.h`. The extra directory is 
> to minimize the number of headers in the top-level directory, having too many 
> is confusing.
I like the separation - my concern here was the specific word "Cascade".
I'd suggest "Tree" here as it really does define the structure.
The existing "Tree.h" defines operations, and can be named after them. As 
discussed, I think the design is clean and doesn't need to be hidden by an 
umbrella header.



Comment at: clang/include/clang/Tooling/Syntax/Tree/Cascade.h:74
+/// A composite tree node that has children.
+class TreeNode : public Node {
+public:

ilya-biryukov wrote:
> sammccall wrote:
> > This use of "tree node" to mean specifically internal node seems confusing 
> > - is it common?
> I don't think it's common, can use `CompositeNode` - seems like a better 
> alternative
What about Subtree?



Comment at: clang/include/clang/Tooling/Syntax/Tree/Cascade.h:39
+public:
+  Node(NodeKind Kind) :

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-05-21 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 200504.
gtbercea added a comment.

- Remove new option.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  lib/CodeGen/CodeGenModule.cpp
  test/OpenMP/openmp_offload_registration.cpp
  test/OpenMP/target_codegen.cpp
  test/OpenMP/target_codegen_registration.cpp
  test/OpenMP/target_depend_codegen.cpp
  test/OpenMP/target_parallel_codegen.cpp
  test/OpenMP/target_parallel_codegen_registration.cpp
  test/OpenMP/target_parallel_depend_codegen.cpp
  test/OpenMP/target_parallel_for_codegen.cpp
  test/OpenMP/target_parallel_for_codegen_registration.cpp
  test/OpenMP/target_parallel_for_depend_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen.cpp
  test/OpenMP/target_parallel_for_simd_codegen_registration.cpp
  test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_parallel_if_codegen.cpp
  test/OpenMP/target_parallel_num_threads_codegen.cpp
  test/OpenMP/target_simd_codegen.cpp
  test/OpenMP/target_simd_codegen_registration.cpp
  test/OpenMP/target_simd_depend_codegen.cpp
  test/OpenMP/target_teams_codegen.cpp
  test/OpenMP/target_teams_codegen_registration.cpp
  test/OpenMP/target_teams_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen.cpp
  test/OpenMP/target_teams_distribute_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen.cpp
  test/OpenMP/target_teams_distribute_simd_codegen_registration.cpp
  test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
  test/OpenMP/target_teams_num_teams_codegen.cpp
  test/OpenMP/target_teams_thread_limit_codegen.cpp

Index: test/OpenMP/target_teams_thread_limit_codegen.cpp
===
--- test/OpenMP/target_teams_thread_limit_codegen.cpp
+++ test/OpenMP/target_teams_thread_limit_codegen.cpp
@@ -76,7 +76,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: test/OpenMP/target_teams_num_teams_codegen.cpp
===
--- test/OpenMP/target_teams_num_teams_codegen.cpp
+++ test/OpenMP/target_teams_num_teams_codegen.cpp
@@ -76,7 +76,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
===
--- test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
+++ test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
@@ -64,7 +64,7 @@
 // CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
 
 // Check target registration is registered as a Ctor.
-// CHECK: appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
+// CHECK: appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* @.omp_offloading.requires_reg, i8* null }, { i32, void ()*, i8* } { i32 0, void ()* @[[REGFN]], i8* bitcast (void ()* @[[REGFN]] to i8*) }]
 
 
 template
Index: test/OpenMP/target_teams_distribute_simd_co

[PATCH] D61865: [clangd] improve help message for limit-results

2019-05-21 Thread Brennan Vincent via Phabricator via cfe-commits
umanwizard added a comment.

@kadircet what are the next steps? This is my first diff in llvm. I'm not a 
project member so presumably someone else will have to land it for me.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61865



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


[PATCH] D61643: [PragmaHandler][NFC] Expose `#pragma` location

2019-05-21 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked an inline comment as done.
jdenny added inline comments.



Comment at: clang/docs/ClangPlugins.rst:58
 ExamplePragmaHandler() : PragmaHandler("example_pragma") { }
-void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
   Token &PragmaTok) {

jdenny wrote:
> lebedev.ri wrote:
> > jdenny wrote:
> > > lebedev.ri wrote:
> > > > Hmm.
> > > > This will have effects on out-of-tree plugins that define pragmas.
> > > > I'm not sure how to proceed here, just notify cfe-dev and move on?
> > > We could do something like this in `PragmaHandler`:
> > > 
> > > ```
> > >   virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind 
> > > Introducer,
> > > Token &FirstToken) {
> > > llvm_unreachable("deprecated HandlePragma unexpectedly called");
> > >   }
> > >   virtual void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
> > > Token &FirstToken) {
> > > HandlePragma(PP, Introducer.Kind, FirstToken);
> > >   }
> > > ```
> > > 
> > > The derived class could override either one.  Unfortunately, if it didn't 
> > > override either, the error is then at run time instead of compile time as 
> > > it is now.
> > > 
> > > Whether this is worth it, I don't know.  Who's the right person to answer 
> > > this question?
> > I think mailing cfe-dev will get this question the most visibility.
> > Though i //think// the solution will be to go with the current patch.
> I tried that at
> 
> http://lists.llvm.org/pipermail/cfe-dev/2019-May/062297.htm
> 
> but it's been a week without a response.  I'm happy to try again, perhaps 
> with a shorter more general email about `PragmaHandler` backward 
> compatibility that might catch a different set of eyes.  Is it worth it, or 
> should we just assume no response so far means no one thinks it's an issue?  
> Thanks.
Sorry, copy and paste error.  The URL is:

http://lists.llvm.org/pipermail/cfe-dev/2019-May/062297.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61643



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


[PATCH] D59887: [Syntax] Introduce TokenBuffer, start clangToolingSyntax library

2019-05-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D59887#1508991 , @thakis wrote:

> Out of interest: The RecursiveASTVisitorTests are part of the ToolingTests 
> binary while this adds a new binary TokensTest. Can you say why?
>
> (No change needed, just curious.)


The syntax library is mostly independent from the rest of tooling, so I'd 
rather keep everything related to it separate including the tests.
I don't think we'll get anything in terms of code reuse from merging them into 
the same test binary either.

In D59887#1508993 , @thakis wrote:

> Another comment: The new binary is called TokensTest but is in a directory 
> "Syntax". For consistency with all other unit test binaries, please either 
> rename the binary to SyntaxTests, or rename the directory to "Tokens". (From 
> the patch description, the former seems more appropriate.) Note the missing 
> trailing "s" in the binary name too.


Agree with renaming the binary. In fact, the not-yet-landed revisions also use 
`SyntaxTests`, and I should've named it this way from the start. I'll land a 
patch.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59887



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


r361264 - [Syntax] Rename TokensTest to SyntaxTests. NFC

2019-05-21 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue May 21 07:37:41 2019
New Revision: 361264

URL: http://llvm.org/viewvc/llvm-project?rev=361264&view=rev
Log:
[Syntax] Rename TokensTest to SyntaxTests. NFC

To be more consistent with conventions used in the codebase. The new
name will be a better fit when more bits of the syntax library land.

Modified:
cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt

Modified: cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt?rev=361264&r1=361263&r2=361264&view=diff
==
--- cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Tooling/Syntax/CMakeLists.txt Tue May 21 07:37:41 2019
@@ -3,11 +3,11 @@ set(LLVM_LINK_COMPONENTS
   Support
   )
 
-add_clang_unittest(TokensTest
+add_clang_unittest(SyntaxTests
   TokensTest.cpp
 )
 
-target_link_libraries(TokensTest
+target_link_libraries(SyntaxTests
   PRIVATE
   clangAST
   clangBasic


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


[PATCH] D62197: [OpenCL] Fix file-scope const sampler variable for 2.0

2019-05-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: Anastasia.

OpenCL spec v2.0 s6.13.14:

  Samplers can also be declared as global constants in the program
  source using the following syntax.
  
 const sampler_t  = 

This works fine for OpenCL 1.2 but fails for 2.0, because clang duduces
address space of file-scope const sampler variable to be in global address
space whereas spec v2.0 s6.9.b forbids file-scope sampler variable to be
in global address space.

The fix is not to deduce address space for file-scope sampler variables.


https://reviews.llvm.org/D62197

Files:
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
 
 #define CLK_ADDRESS_CLAMP_TO_EDGE   2
 #define CLK_NORMALIZED_COORDS_TRUE  1
@@ -55,7 +58,11 @@
   sampler_t sa[] = {argsmp, glb_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
 }
 
+#if __OPENCL_C_VERSION__ == 200
+void bad(sampler_t*); // expected-error{{pointer to type '__generic sampler_t' is invalid in OpenCL}}
+#else
 void bad(sampler_t*); // expected-error{{pointer to type 'sampler_t' is invalid in OpenCL}}
+#endif
 
 void bar() {
   sampler_t smp1 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
Index: test/CodeGenOpenCL/sampler.cl
===
--- test/CodeGenOpenCL/sampler.cl
+++ test/CodeGenOpenCL/sampler.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -O0 | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -triple spir-unknown-unknown -o - -O0 | FileCheck %s
 //
 // This test covers 5 cases of sampler initialzation:
 //   1. function argument passing
@@ -6,8 +7,9 @@
 //  1b. argument is a function-scope variable
 //  1c. argument is one of caller function's parameters
 //   2. variable initialization
-//  2a. initializing a file-scope variable
+//  2a. initializing a file-scope variable with constant addr space qualifier
 //  2b. initializing a function-scope variable
+//  2c. initializing a file-scope variable with const qualifier
 
 #define CLK_ADDRESS_CLAMP_TO_EDGE   2
 #define CLK_NORMALIZED_COORDS_TRUE  1
@@ -20,6 +22,10 @@
 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 // CHECK-NOT: glb_smp
 
+// Case 2c
+const sampler_t glb_smp_const = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+// CHECK-NOT: glb_smp_const
+
 int get_sampler_initializer(void);
 
 void fnc4smp(sampler_t s) {}
@@ -47,11 +53,16 @@
   // CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, %opencl.sampler_t addrspace(2)** [[smp_ptr]]
   // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]])
 
-  // Case 1a
+  // Case 1a/2a
   fnc4smp(glb_smp);
   // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35)
   // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]])
 
+  // Case 1a/2c
+  fnc4smp(glb_smp_const);
+  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35)
+  // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]])
+
   // Case 1c
   fnc4smp(smp_par);
   // CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, %opencl.sampler_t addrspace(2)** [[smp_par_ptr]]
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7326,7 +7326,21 @@
   T->isDependentType() ||
   // Do not deduce addr space of decltype because it will be taken from
   // its argument.
-  T->isDecltypeType())
+  T->isDecltypeType() ||
+  // OpenCL spec v2.0 s6.9.b:
+  // The sampler type cannot be used with the __local and __global address
+  // space qualifiers.
+  // OpenCL spec v2.0 s6.13.14:
+  // Samplers can also be declared as global constants in the program
+  // source using the following syntax.
+  //   const sampler_t  = 
+  // In codegen, file-scope sampler type variable has special ha

r361265 - Add support for dumping AST comment nodes to JSON.

2019-05-21 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue May 21 07:38:29 2019
New Revision: 361265

URL: http://llvm.org/viewvc/llvm-project?rev=361265&view=rev
Log:
Add support for dumping AST comment nodes to JSON.

Added:
cfe/trunk/test/AST/ast-dump-comment-json.cpp
Modified:
cfe/trunk/include/clang/AST/JSONNodeDumper.h
cfe/trunk/lib/AST/ASTDumper.cpp
cfe/trunk/lib/AST/JSONNodeDumper.cpp

Modified: cfe/trunk/include/clang/AST/JSONNodeDumper.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/JSONNodeDumper.h?rev=361265&r1=361264&r2=361265&view=diff
==
--- cfe/trunk/include/clang/AST/JSONNodeDumper.h (original)
+++ cfe/trunk/include/clang/AST/JSONNodeDumper.h Tue May 21 07:38:29 2019
@@ -111,6 +111,8 @@ public:
 // information presented is correct.
 class JSONNodeDumper
 : public ConstAttrVisitor,
+  public comments::ConstCommentVisitor,
   public ConstTemplateArgumentVisitor,
   public ConstStmtVisitor,
   public TypeVisitor,
@@ -120,8 +122,12 @@ class JSONNodeDumper
 
   const SourceManager &SM;
   PrintingPolicy PrintPolicy;
+  const comments::CommandTraits *Traits;
 
   using InnerAttrVisitor = ConstAttrVisitor;
+  using InnerCommentVisitor =
+  comments::ConstCommentVisitor;
   using InnerTemplateArgVisitor = ConstTemplateArgumentVisitor;
   using InnerStmtVisitor = ConstStmtVisitor;
   using InnerTypeVisitor = TypeVisitor;
@@ -163,10 +169,14 @@ class JSONNodeDumper
   }
   void addPreviousDeclaration(const Decl *D);
 
+  StringRef getCommentCommandName(unsigned CommandID) const;
+
 public:
   JSONNodeDumper(raw_ostream &OS, const SourceManager &SrcMgr,
- const PrintingPolicy &PrintPolicy)
-  : NodeStreamer(OS), SM(SrcMgr), PrintPolicy(PrintPolicy) {}
+ const PrintingPolicy &PrintPolicy,
+ const comments::CommandTraits *Traits)
+  : NodeStreamer(OS), SM(SrcMgr), PrintPolicy(PrintPolicy), Traits(Traits) 
{
+  }
 
   void Visit(const Attr *A);
   void Visit(const Stmt *Node);
@@ -237,6 +247,28 @@ public:
   void VisitLabelStmt(const LabelStmt *LS);
   void VisitGotoStmt(const GotoStmt *GS);
   void VisitWhileStmt(const WhileStmt *WS);
+
+  void visitTextComment(const comments::TextComment *C,
+const comments::FullComment *);
+  void visitInlineCommandComment(const comments::InlineCommandComment *C,
+ const comments::FullComment *);
+  void visitHTMLStartTagComment(const comments::HTMLStartTagComment *C,
+const comments::FullComment *);
+  void visitHTMLEndTagComment(const comments::HTMLEndTagComment *C,
+  const comments::FullComment *);
+  void visitBlockCommandComment(const comments::BlockCommandComment *C,
+const comments::FullComment *);
+  void visitParamCommandComment(const comments::ParamCommandComment *C,
+const comments::FullComment *FC);
+  void visitTParamCommandComment(const comments::TParamCommandComment *C,
+ const comments::FullComment *FC);
+  void visitVerbatimBlockComment(const comments::VerbatimBlockComment *C,
+ const comments::FullComment *);
+  void
+  visitVerbatimBlockLineComment(const comments::VerbatimBlockLineComment *C,
+const comments::FullComment *);
+  void visitVerbatimLineComment(const comments::VerbatimLineComment *C,
+const comments::FullComment *);
 };
 
 class JSONDumper : public ASTNodeTraverser {
@@ -314,8 +346,9 @@ class JSONDumper : public ASTNodeTravers
 
 public:
   JSONDumper(raw_ostream &OS, const SourceManager &SrcMgr,
- const PrintingPolicy &PrintPolicy)
-  : NodeDumper(OS, SrcMgr, PrintPolicy) {}
+ const PrintingPolicy &PrintPolicy,
+ const comments::CommandTraits *Traits)
+  : NodeDumper(OS, SrcMgr, PrintPolicy, Traits) {}
 
   JSONNodeDumper &doGetNodeDelegate() { return NodeDumper; }
 

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=361265&r1=361264&r2=361265&view=diff
==
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Tue May 21 07:38:29 2019
@@ -184,7 +184,8 @@ LLVM_DUMP_METHOD void Decl::dump(raw_ost
   const SourceManager &SM = Ctx.getSourceManager();
 
   if (ADOF_JSON == Format) {
-JSONDumper P(OS, SM, Ctx.getPrintingPolicy());
+JSONDumper P(OS, SM, Ctx.getPrintingPolicy(),
+ &Ctx.getCommentCommandTraits());
 (void)Deserialize; // FIXME?
 P.Visit(this);
   } else {

Modified: cfe/trunk/lib/AST/JSONNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/JSONNodeDumper.cpp?rev=361265&r1=361264&r2=361265&view=

[PATCH] D60568: [OpenMP] Add support for registering requires directives with the runtime

2019-05-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.

LG. Please, commit it only after the runtime part is committed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60568



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


[PATCH] D62197: [OpenCL] Fix file-scope const sampler variable for 2.0

2019-05-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 200509.
yaxunl added a comment.

Add full diff.


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

https://reviews.llvm.org/D62197

Files:
  lib/Sema/SemaType.cpp
  test/CodeGenOpenCL/sampler.cl
  test/SemaOpenCL/sampler_t.cl

Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -Wspir-compat -triple amdgcn--amdhsa
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -pedantic -fsyntax-only -DCHECK_SAMPLER_VALUE -triple spir-unknown-unknown
 
 #define CLK_ADDRESS_CLAMP_TO_EDGE   2
 #define CLK_NORMALIZED_COORDS_TRUE  1
@@ -55,7 +58,11 @@
   sampler_t sa[] = {argsmp, glb_smp}; // expected-error {{array of 'sampler_t' type is invalid in OpenCL}}
 }
 
+#if __OPENCL_C_VERSION__ == 200
+void bad(sampler_t*); // expected-error{{pointer to type '__generic sampler_t' is invalid in OpenCL}}
+#else
 void bad(sampler_t*); // expected-error{{pointer to type 'sampler_t' is invalid in OpenCL}}
+#endif
 
 void bar() {
   sampler_t smp1 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
Index: test/CodeGenOpenCL/sampler.cl
===
--- test/CodeGenOpenCL/sampler.cl
+++ test/CodeGenOpenCL/sampler.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -emit-llvm -triple spir-unknown-unknown -o - -O0 | FileCheck %s
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -emit-llvm -triple spir-unknown-unknown -o - -O0 | FileCheck %s
 //
 // This test covers 5 cases of sampler initialzation:
 //   1. function argument passing
@@ -6,8 +7,9 @@
 //  1b. argument is a function-scope variable
 //  1c. argument is one of caller function's parameters
 //   2. variable initialization
-//  2a. initializing a file-scope variable
+//  2a. initializing a file-scope variable with constant addr space qualifier
 //  2b. initializing a function-scope variable
+//  2c. initializing a file-scope variable with const qualifier
 
 #define CLK_ADDRESS_CLAMP_TO_EDGE   2
 #define CLK_NORMALIZED_COORDS_TRUE  1
@@ -20,6 +22,10 @@
 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 // CHECK-NOT: glb_smp
 
+// Case 2c
+const sampler_t glb_smp_const = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
+// CHECK-NOT: glb_smp_const
+
 int get_sampler_initializer(void);
 
 void fnc4smp(sampler_t s) {}
@@ -47,11 +53,16 @@
   // CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, %opencl.sampler_t addrspace(2)** [[smp_ptr]]
   // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]])
 
-  // Case 1a
+  // Case 1a/2a
   fnc4smp(glb_smp);
   // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35)
   // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]])
 
+  // Case 1a/2c
+  fnc4smp(glb_smp_const);
+  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* @__translate_sampler_initializer(i32 35)
+  // CHECK: call spir_func void @fnc4smp(%opencl.sampler_t addrspace(2)* [[SAMP]])
+
   // Case 1c
   fnc4smp(smp_par);
   // CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, %opencl.sampler_t addrspace(2)** [[smp_par_ptr]]
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7326,7 +7326,21 @@
   T->isDependentType() ||
   // Do not deduce addr space of decltype because it will be taken from
   // its argument.
-  T->isDecltypeType())
+  T->isDecltypeType() ||
+  // OpenCL spec v2.0 s6.9.b:
+  // The sampler type cannot be used with the __local and __global address
+  // space qualifiers.
+  // OpenCL spec v2.0 s6.13.14:
+  // Samplers can also be declared as global constants in the program
+  // source using the following syntax.
+  //   const sampler_t  = 
+  // In codegen, file-scope sampler type variable has special handing and
+  // does not rely on address space qualifier. On the other hand, deducing
+  // address space of const sampler file-scope variable as global address
+  // space causes spurious diagnostic about __global address space
+  // qualifier, therefore do not deduce address space of file-scope sampler
+  // type variable.
+  (D.getContext() == DeclaratorContext::File

[PATCH] D62174: [Analysis] Link library dependencies to Analysis plugins

2019-05-21 Thread Don Hinton via Phabricator via cfe-commits
hintonda accepted this revision.
hintonda added a comment.
This revision is now accepted and ready to land.

LGTM.  Build and check-llvm were both clean on my Mac for static build.  Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D62174



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


[PATCH] D61637: [Syntax] Introduce syntax trees

2019-05-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Corpus.h:38
+  std::pair>
+  tokenizeBuffer(std::unique_ptr Buffer);
+

sammccall wrote:
> ilya-biryukov wrote:
> > sammccall wrote:
> > > Are you planning to have a way to add tokens directly? Having to turn 
> > > them into text and re-lex them seems like it might be inconvenient.
> > The tokens have source locations and refer to a text in some buffer. 
> > `tokenizeBuffer` makes is easier, not harder, to mock tokens.
> Fair enough.
> 
> `lexBuffer` might be a slightly clearer name?
> 
> Who are the intended non-test users of this function? Are they better served 
> by being able (and responsible) for constructing a MemoryBuffer with e.g. a 
> sensible name and ownership, or would it be better to pass a StringRef and 
> have the Arena come up with a sensible "anonymous" name?
The only use-case in my prototype so far is creating token nodes for 
punctuation nodes, e.g. say you want to create an expr of the form `+`, 
where both `a` and `b` are existing expressions and you need to synthesize a 
leaf node for `+`.
We use this function to synthesize a buffer with the corresponding token.

All the use-cases I can imagine are around synthesizing syntax trees (as 
opposed to constructing them from the AST).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61637



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


[PATCH] D62192: [clang-tidy]: Add cert-oop54-cpp alias for bugprone-unhandled-self-assignment

2019-05-21 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 nits, thank you for this!




Comment at: 
clang-tools-extra/clang-tidy/bugprone/UnhandledSelfAssignmentCheck.cpp:89-91
+AdditionalMatcher = cxxMethodDecl(ofClass(cxxRecordDecl(
+has(fieldDecl(anyOf(hasType(pointerType()), hasType(SmartPointerType),
+hasType(arrayType(;

Nothing to be changed here, but it sure would be nice to have a 
clang-tidy-specific matcher to be used for option handling so we could do this 
modification using something like `unless(!WarnOnlyIfThisHasSuspiciousField)`.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-self-assignment.rst:6
 
+`cert-oop54-cpp` redirects here as an alias for this check. For the cert alias
+WarnOnlyIfThisHasSuspiciousField option is set to `0`.

cert alias -> CERT alias, the





Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-self-assignment.rst:7
+`cert-oop54-cpp` redirects here as an alias for this check. For the cert alias
+WarnOnlyIfThisHasSuspiciousField option is set to `0`.
+

Add backticks around the option name.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-unhandled-self-assignment.rst:124
+  When non-zero, the check will warn only if the container class of the copy 
assignment operator
+  has any suspicious field (pointer or C array). This option is set to `1` by 
default.

field -> fields


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62192



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


[PATCH] D61643: [PragmaHandler][NFC] Expose `#pragma` location

2019-05-21 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!




Comment at: clang/docs/ClangPlugins.rst:58
 ExamplePragmaHandler() : PragmaHandler("example_pragma") { }
-void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
   Token &PragmaTok) {

jdenny wrote:
> jdenny wrote:
> > lebedev.ri wrote:
> > > jdenny wrote:
> > > > lebedev.ri wrote:
> > > > > Hmm.
> > > > > This will have effects on out-of-tree plugins that define pragmas.
> > > > > I'm not sure how to proceed here, just notify cfe-dev and move on?
> > > > We could do something like this in `PragmaHandler`:
> > > > 
> > > > ```
> > > >   virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind 
> > > > Introducer,
> > > > Token &FirstToken) {
> > > > llvm_unreachable("deprecated HandlePragma unexpectedly called");
> > > >   }
> > > >   virtual void HandlePragma(Preprocessor &PP, PragmaIntroducer 
> > > > Introducer,
> > > > Token &FirstToken) {
> > > > HandlePragma(PP, Introducer.Kind, FirstToken);
> > > >   }
> > > > ```
> > > > 
> > > > The derived class could override either one.  Unfortunately, if it 
> > > > didn't override either, the error is then at run time instead of 
> > > > compile time as it is now.
> > > > 
> > > > Whether this is worth it, I don't know.  Who's the right person to 
> > > > answer this question?
> > > I think mailing cfe-dev will get this question the most visibility.
> > > Though i //think// the solution will be to go with the current patch.
> > I tried that at
> > 
> > http://lists.llvm.org/pipermail/cfe-dev/2019-May/062297.htm
> > 
> > but it's been a week without a response.  I'm happy to try again, perhaps 
> > with a shorter more general email about `PragmaHandler` backward 
> > compatibility that might catch a different set of eyes.  Is it worth it, or 
> > should we just assume no response so far means no one thinks it's an issue? 
> >  Thanks.
> Sorry, copy and paste error.  The URL is:
> 
> http://lists.llvm.org/pipermail/cfe-dev/2019-May/062297.html
I don't think we make guarantees about the stability of these APIs and this is 
a loud break for out-of-tree users rather than a silent behavioral change. I 
think the approach taken in this patch is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61643



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


[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-05-21 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 200513.
Fznamznon added a comment.
Herald added a subscriber: mgorny.

Added semantics for new attributes

- Added semantics for new attributes. Now complier can separate SYCL

device code from host code using new arrtributes.

- Removed spelling for sycl_device attribute and its documentation because

it can be added only implicitly by the compiler for now

- Removed docs for sycl_kernel attribute because this attribute is not

presented in SYCL spec and not for public use - it's some implemetation detail.
It will be used in SYCL headers implemetation to help compiler find device code
entry point in single source file. So I think no need to add documentation for
it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Parse/ParseAST.cpp
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaSYCL.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGenSYCL/device-functions.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaSYCL/device-attributes-on-non-sycl.cpp
  clang/test/SemaSYCL/device-attributes.cpp

Index: clang/test/SemaSYCL/device-attributes.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/device-attributes.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -fsycl-is-device -verify %s
+
+[[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to functions}}
+__attribute((sycl_kernel)) int gv3 = 0; // expected-warning {{'sycl_kernel' attribute only applies to functions}}
+
+__attribute((sycl_kernel)) void foo();
+[[clang::sycl_kernel]] void foo1();
+
+__attribute((sycl_kernel(1))) void foo(); // expected-error {{'sycl_kernel' attribute takes no arguments}}
+[[clang::sycl_kernel(1)]] void foo2(); // expected-error {{'sycl_kernel' attribute takes no arguments}}
Index: clang/test/SemaSYCL/device-attributes-on-non-sycl.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/device-attributes-on-non-sycl.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -fsycl-is-device -verify %s
+// Now pretend that we're compiling regular C++ file without SYCL mode enabled.
+// There should be warnings.
+// RUN: %clang_cc1 -fsyntax-only -verify -x c++ %s
+
+#if not defined(__SYCL_DEVICE_ONLY__)
+// expected-warning@+6 {{'sycl_kernel' attribute ignored}}
+// expected-warning@+6 {{'sycl_kernel' attribute ignored}}
+#else
+// expected-no-diagnostics
+#endif
+
+__attribute((sycl_kernel)) void foo();
+[[clang::sycl_kernel]] void foo2();
+
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -124,6 +124,7 @@
 // CHECK-NEXT: ReturnTypestate (SubjectMatchRule_function, SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: ReturnsNonNull (SubjectMatchRule_objc_method, SubjectMatchRule_function)
 // CHECK-NEXT: ReturnsTwice (SubjectMatchRule_function)
+// CHECK-NEXT: SYCLKernel (SubjectMatchRule_function)
 // CHECK-NEXT: ScopedLockable (SubjectMatchRule_record)
 // CHECK-NEXT: Section (SubjectMatchRule_function, SubjectMatchRule_variable_is_global, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property)
 // CHECK-NEXT: SetTypestate (SubjectMatchRule_function_is_member)
Index: clang/test/CodeGenSYCL/device-functions.cpp
===
--- /dev/null
+++ clang/test/CodeGenSYCL/device-functions.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -triple spir64-unknown-unknown -std=c++11 -fsycl-is-device -S -emit-llvm %s -o - | FileCheck %s
+
+template 
+T bar(T arg);
+
+void foo() {
+  int a = 1 + 1 + bar(1);
+}
+
+template 
+T bar(T arg) {
+  return arg;
+}
+
+template 
+__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
+  kernelFunc();
+}
+
+int main() {
+  kernel_single_task([]() { foo(); });
+  return 0;
+}
+// CHECK: define spir_func void @{{.*}}foo
+// CHECK: define linkonce_odr spir_func i32 @{{.*}}bar
+// CHECK: define internal spir_func void @{{.*}}kernel_single_task
+// FIXME: Next function is lambda () operator. spir_func calling convention
+// is missed for C++ methods.
+// CHECK: define internal void @"_ZZ4mainENK3$_0clEv"(%class.anon* %this)
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -5517,14 +5517,30 @@
 Function, [

[PATCH] D62200: [Driver][Windows] Add dependent lib argument for -fprofile-generate and -fcs-profile-generate

2019-05-21 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop created this revision.
russell.gallop added reviewers: rnk, hans, bogner.
russell.gallop added a project: clang.

Follows on from r360674 which added it for -fprofile-instr-generate.

Identified when doing: https://reviews.llvm.org/D62063


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62200

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -62,12 +62,16 @@
 // RUN: %clang_cl /Z7 -### -- %s 2>&1 | FileCheck -check-prefix=gdefcolumn %s
 // gdefcolumn-NOT: -dwarf-column-info
 
-// RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-GENERATE %s
-// RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- 
%s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
+// RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-INSTR-GENERATE %s
+// RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- 
%s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE-FILE %s
+// CHECK-PROFILE-INSTR-GENERATE: "-fprofile-instrument=clang" 
"--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
+// CHECK-PROFILE-INSTR-GENERATE-FILE: 
"-fprofile-instrument-path=/tmp/somefile.profraw"
+
+// RUN: %clang_cl -### /FA -fprofile-generate -- %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-GENERATE %s
+// CHECK-PROFILE-GENERATE: "-fprofile-instrument=llvm" 
"--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
+
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 
2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file 
-- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
-// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang" 
"--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
-// CHECK-PROFILE-GENERATE-FILE: 
"-fprofile-instrument-path=/tmp/somefile.profraw"
 // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
 
 // RUN: %clang_cl -### /FA -fprofile-instr-use -- %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-USE %s
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -803,6 +803,10 @@
 CmdArgs.push_back("-fprofile-instrument=csllvm");
   }
   if (PGOGenArg) {
+if (TC.getTriple().isWindowsMSVCEnvironment()) {
+  CmdArgs.push_back(Args.MakeArgString("--dependent-lib=" +
+   TC.getCompilerRT(Args, "profile")));
+}
 if (PGOGenArg->getOption().matches(
 PGOGenerateArg ? options::OPT_fprofile_generate_EQ
: options::OPT_fcs_profile_generate_EQ)) {


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -62,12 +62,16 @@
 // RUN: %clang_cl /Z7 -### -- %s 2>&1 | FileCheck -check-prefix=gdefcolumn %s
 // gdefcolumn-NOT: -dwarf-column-info
 
-// RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
-// RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
+// RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE %s
+// RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-INSTR-GENERATE-FILE %s
+// CHECK-PROFILE-INSTR-GENERATE: "-fprofile-instrument=clang" "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
+// CHECK-PROFILE-INSTR-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
+
+// RUN: %clang_cl -### /FA -fprofile-generate -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE %s
+// CHECK-PROFILE-GENERATE: "-fprofile-instrument=llvm" "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
+
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
 // RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file -- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
-// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang" "--dependent-lib={{[^"]*}}clang_rt.profile-{{[^"]*}}.lib"
-// CHECK-PROFILE-GENERATE-FILE: "-fprofile-instrument-path=/tmp/somefile.profraw"
 // CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
 
 // RUN: %clang_cl -### /FA -fprofile-instr-use -- %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-USE %s
Index: clang/lib/Driv

Re: r361152 - [LibTooling] Add RangeSelector library for defining source ranges based on bound AST nodes.

2019-05-21 Thread Yitzhak Mandelbaum via cfe-commits
https://reviews.llvm.org/D62201

On Tue, May 21, 2019 at 10:15 AM Nico Weber  wrote:

> I'm suggesting you make the below change. For testing, I'd just try
> building locally.
>
> $ git diff
> diff --git a/clang/unittests/Tooling/CMakeLists.txt
> b/clang/unittests/Tooling/CMakeLists.txt
> index 8c383be2d74..af8a35d9251 100644
> --- a/clang/unittests/Tooling/CMakeLists.txt
> +++ b/clang/unittests/Tooling/CMakeLists.txt
> @@ -1,6 +1,7 @@
>  set(LLVM_LINK_COMPONENTS
>${LLVM_TARGETS_TO_BUILD}
>Support
> +  TestingSupport
>)
>
>  # By default MSVC has a 2^16 limit on the number of sections in an object
> file,
> @@ -70,8 +71,6 @@ target_link_libraries(ToolingTests
>clangToolingCore
>clangToolingInclusions
>clangToolingRefactor
> -  LLVMSupport
> -  LLVMTestingSupport
>)
>
> On Mon, May 20, 2019 at 9:49 PM Yitzhak Mandelbaum 
> wrote:
>
>> Nice, thanks for r361208.  As for support -- no, I didn't try that. I
>> was following a pattern I saw elsewhere.  Do you suggest that I make that
>> change? If so, any particular way to test it?
>>
>> thanks
>>
>> On Mon, May 20, 2019 at 8:26 PM Nico Weber  wrote:
>>
>>> +  LLVMSupport
>>> +  LLVMTestingSupport
>>>
>>> clang/unittests/Tooling/CMakeLists already has this at the top:
>>> set(LLVM_LINK_COMPONENTS
>>>   ${LLVM_TARGETS_TO_BUILD}
>>>   Support
>>>   )
>>>
>>> I think we link Support twice now. Did adding TestingSupport up there
>>> not work? I'd expect that your addition would break shared library builds,
>>> or something like that.
>>>
>>> (Also, I tried to fix a build error that old gcc versions had with this
>>> change in r361208.)
>>>
>>> *From: *Yitzhak Mandelbaum via cfe-commits 
>>> *Date: *Mon, May 20, 2019 at 9:12 AM
>>> *To: * 
>>>
>>> Author: ymandel
 Date: Mon May 20 06:15:14 2019
 New Revision: 361152

 URL: http://llvm.org/viewvc/llvm-project?rev=361152&view=rev
 Log:
 [LibTooling] Add RangeSelector library for defining source ranges based
 on bound AST nodes.

 Summary:

 The RangeSelector library defines a combinator language for specifying
 source
 ranges based on bound ids for AST nodes.  The combinator approach
 follows the
 design of the AST matchers.  The RangeSelectors defined here will be
 used in
 both RewriteRule, for specifying source affected by edit, and in
 Stencil for
 specifying source to use constructively in a replacement.

 Reviewers: ilya-biryukov

 Subscribers: mgorny, cfe-commits

 Tags: #clang

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

 Added:
 cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h
 cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
 cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp
 Modified:
 cfe/trunk/lib/Tooling/Refactoring/CMakeLists.txt
 cfe/trunk/unittests/Tooling/CMakeLists.txt

 Added: cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h?rev=361152&view=auto

 ==
 --- cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h (added)
 +++ cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h Mon May
 20 06:15:14 2019
 @@ -0,0 +1,80 @@
 +//===--- RangeSelector.h - Source-selection library -*- 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
 +//

 +//===--===//
 +///
 +///  \file
 +///  Defines a combinator library supporting the definition of
 _selectors_,
 +///  which select source ranges based on (bound) AST nodes.
 +///

 +//===--===//
 +
 +#ifndef LLVM_CLANG_TOOLING_REFACTOR_RANGE_SELECTOR_H_
 +#define LLVM_CLANG_TOOLING_REFACTOR_RANGE_SELECTOR_H_
 +
 +#include "clang/ASTMatchers/ASTMatchFinder.h"
 +#include "clang/Basic/SourceLocation.h"
 +#include "llvm/ADT/StringRef.h"
 +#include "llvm/Support/Error.h"
 +#include 
 +
 +namespace clang {
 +namespace tooling {
 +using RangeSelector = std::function(
 +const ast_matchers::MatchFinder::MatchResult &)>;
 +
 +inline RangeSelector charRange(CharSourceRange R) {
 +  return [R](const ast_matchers::MatchFinder::MatchResult &)
 + -> Expected { return R; };
 +}
 +
 +/// Selects from the start of \p Begin and to the end of \p End.
 +RangeSelector range(RangeSelector Begin, RangeSelector End);
 +
 +/// Convenience version of \c ra

[PATCH] D62201: [LibTooling] Adjust dependencies for unittests.

2019-05-21 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: thakis.
Herald added a subscriber: mgorny.
Herald added a project: clang.

Fix a redundant dependency and move another to its proper place.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62201

Files:
  clang/unittests/Tooling/CMakeLists.txt


Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Support
+  TestingSupport
   )
 
 # By default MSVC has a 2^16 limit on the number of sections in an object file,
@@ -70,8 +71,6 @@
   clangToolingCore
   clangToolingInclusions
   clangToolingRefactor
-  LLVMSupport
-  LLVMTestingSupport
   )
 
 


Index: clang/unittests/Tooling/CMakeLists.txt
===
--- clang/unittests/Tooling/CMakeLists.txt
+++ clang/unittests/Tooling/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   ${LLVM_TARGETS_TO_BUILD}
   Support
+  TestingSupport
   )
 
 # By default MSVC has a 2^16 limit on the number of sections in an object file,
@@ -70,8 +71,6 @@
   clangToolingCore
   clangToolingInclusions
   clangToolingRefactor
-  LLVMSupport
-  LLVMTestingSupport
   )
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r361269 - [OPENMP][NVPTX]Mark more functions as always_inline for better

2019-05-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Tue May 21 08:11:58 2019
New Revision: 361269

URL: http://llvm.org/viewvc/llvm-project?rev=361269&view=rev
Log:
[OPENMP][NVPTX]Mark more functions as always_inline for better
performance.

Internally generated functions must be marked as always_inlines in most
cases. Patch marks some extra reduction function + outlined parallel
functions as always_inline for better performance, but only if the
optimization is requested.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/declare_target_codegen_globalization.cpp
cfe/trunk/test/OpenMP/for_reduction_codegen_UDR.cpp
cfe/trunk/test/OpenMP/nvptx_allocate_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_data_sharing.cpp
cfe/trunk/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_lambda_capturing.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_parallel_for_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_parallel_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp

cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_teams_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_teams_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_reduction_codegen.cpp
cfe/trunk/test/OpenMP/taskloop_simd_reduction_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=361269&r1=361268&r2=361269&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Tue May 21 08:11:58 2019
@@ -1274,9 +1274,11 @@ emitCombinerOrInitializer(CodeGenModule
   auto *Fn = llvm::Function::Create(FnTy, llvm::GlobalValue::InternalLinkage,
 Name, &CGM.getModule());
   CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FnInfo);
-  Fn->removeFnAttr(llvm::Attribute::NoInline);
-  Fn->removeFnAttr(llvm::Attribute::OptimizeNone);
-  Fn->addFnAttr(llvm::Attribute::AlwaysInline);
+  if (CGM.getLangOpts().Optimize) {
+Fn->removeFnAttr(llvm::Attribute::NoInline);
+Fn->removeFnAttr(llvm::Attribute::OptimizeNone);
+Fn->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
   CodeGenFunction CGF(CGM);
   // Map "T omp_in;" variable to "*omp_in_parm" value in all expressions.
   // Map "T omp_out;" variable to "*omp_out_parm" value in all expressions.
@@ -4671,9 +4673,11 @@ emitTaskPrivateMappingFunction(CodeGenMo
   &CGM.getModule());
   CGM.SetInternalFunctionAttributes(GlobalDecl(), TaskPrivatesMap,
 TaskPrivatesMapFnInfo);
-  TaskPrivatesMap->removeFnAttr(llvm::Attribute::NoInline);
-  TaskPrivatesMap->removeFnAttr(llvm::Attribute::OptimizeNone);
-  TaskPrivatesMap->addFnAttr(llvm::Attribute::AlwaysInline);
+  if (CGM.getLangOpts().Optimize) {
+TaskPrivatesMap->removeFnAttr(llvm::Attribute::NoInline);
+TaskPrivatesMap->removeFnAttr(llvm::Attribute::OptimizeNone);
+TaskPrivatesMap->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
   CodeGenFunction CGF(CGM);
   CGF.StartFunction(GlobalDecl(), C.VoidTy, TaskPrivatesMap,
 TaskPrivatesMapFnInfo, Args, Loc, Loc);

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=361269&r1=361268&r2=361269&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Tue May 21 08:11:58 2019
@@ -1929,6 +1929,11 @@ llvm::Function *CGOpenMPRuntimeNVPTX::em
   auto *OutlinedFun =
   cast(CGOpenMPRuntime::emitParallelOutlinedFunction(
   D, ThreadIDVar, InnermostKind, CodeGen));
+  if (CGM.getLangOpts().Optimize) {
+OutlinedFun->removeFnAttr(llvm::Attribute::NoInline);
+OutlinedFun->removeFnAttr(llvm::Attribute::OptimizeNone);
+OutlinedFun->addFnAttr(llvm::Attribute::AlwaysInline);
+  }
   IsInTargetMasterThreadRegion = PrevIsInTargetMasterThreadRegion;
   IsInTTDRegion = PrevIsInTTDRegion;
   if (getExecutionMode() != CGOpenMPRuntimeNVPTX::EM_SPMD &&
@@ -2045,9 +2050,11 @@ llvm::Function *CGOpenMPRuntimeNVPTX::em
   CodeGen.setAction(Action);
   llvm::Function *OutlinedFun = CGOpenMP

[PATCH] D61643: [PragmaHandler][NFC] Expose `#pragma` location

2019-05-21 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri accepted this revision.
lebedev.ri added a comment.

No one raised any concerns, so let's do **this**.




Comment at: clang/docs/ClangPlugins.rst:58
 ExamplePragmaHandler() : PragmaHandler("example_pragma") { }
-void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
   Token &PragmaTok) {

aaron.ballman wrote:
> jdenny wrote:
> > jdenny wrote:
> > > lebedev.ri wrote:
> > > > jdenny wrote:
> > > > > lebedev.ri wrote:
> > > > > > Hmm.
> > > > > > This will have effects on out-of-tree plugins that define pragmas.
> > > > > > I'm not sure how to proceed here, just notify cfe-dev and move on?
> > > > > We could do something like this in `PragmaHandler`:
> > > > > 
> > > > > ```
> > > > >   virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind 
> > > > > Introducer,
> > > > > Token &FirstToken) {
> > > > > llvm_unreachable("deprecated HandlePragma unexpectedly called");
> > > > >   }
> > > > >   virtual void HandlePragma(Preprocessor &PP, PragmaIntroducer 
> > > > > Introducer,
> > > > > Token &FirstToken) {
> > > > > HandlePragma(PP, Introducer.Kind, FirstToken);
> > > > >   }
> > > > > ```
> > > > > 
> > > > > The derived class could override either one.  Unfortunately, if it 
> > > > > didn't override either, the error is then at run time instead of 
> > > > > compile time as it is now.
> > > > > 
> > > > > Whether this is worth it, I don't know.  Who's the right person to 
> > > > > answer this question?
> > > > I think mailing cfe-dev will get this question the most visibility.
> > > > Though i //think// the solution will be to go with the current patch.
> > > I tried that at
> > > 
> > > http://lists.llvm.org/pipermail/cfe-dev/2019-May/062297.htm
> > > 
> > > but it's been a week without a response.  I'm happy to try again, perhaps 
> > > with a shorter more general email about `PragmaHandler` backward 
> > > compatibility that might catch a different set of eyes.  Is it worth it, 
> > > or should we just assume no response so far means no one thinks it's an 
> > > issue?  Thanks.
> > Sorry, copy and paste error.  The URL is:
> > 
> > http://lists.llvm.org/pipermail/cfe-dev/2019-May/062297.html
> I don't think we make guarantees about the stability of these APIs and this 
> is a loud break for out-of-tree users rather than a silent behavioral change. 
> I think the approach taken in this patch is fine.
Indeed, i was waiting a bit of time since that post.
Since there has been no response..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61643



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


[PATCH] D62202: Work around a Visual C++ bug

2019-05-21 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added reviewers: aaron.ballman, rnk.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Put up for review because I'm not clear whether this should be considered a 
permanent fix, or if I should put some sort of comment here indicating it's a 
workaround.


Repository:
  rC Clang

https://reviews.llvm.org/D62202

Files:
  clang/lib/Tooling/Refactoring/RangeSelector.cpp


Index: clang/lib/Tooling/Refactoring/RangeSelector.cpp
===
--- clang/lib/Tooling/Refactoring/RangeSelector.cpp
+++ clang/lib/Tooling/Refactoring/RangeSelector.cpp
@@ -218,37 +218,43 @@
 };
 } // namespace
 
+namespace {
 // Returns the range of the statements (all source between the braces).
-static CharSourceRange getStatementsRange(const MatchResult &,
-  const CompoundStmt &CS) {
+CharSourceRange getStatementsRange(const MatchResult &,
+   const CompoundStmt &CS) {
   return CharSourceRange::getCharRange(CS.getLBracLoc().getLocWithOffset(1),
CS.getRBracLoc());
 }
+} // namespace
 
 RangeSelector tooling::statements(StringRef ID) {
   return RelativeSelector(ID);
 }
 
+namespace {
 // Returns the range of the source between the call's parentheses.
-static CharSourceRange getCallArgumentsRange(const MatchResult &Result,
- const CallExpr &CE) {
+CharSourceRange getCallArgumentsRange(const MatchResult &Result,
+  const CallExpr &CE) {
   return CharSourceRange::getCharRange(
   findOpenParen(CE, *Result.SourceManager, Result.Context->getLangOpts())
   .getLocWithOffset(1),
   CE.getRParenLoc());
 }
+} // namespace
 
 RangeSelector tooling::callArgs(StringRef ID) {
   return RelativeSelector(ID);
 }
 
+namespace {
 // Returns the range of the elements of the initializer list. Includes all
 // source between the braces.
-static CharSourceRange getElementsRange(const MatchResult &,
-const InitListExpr &E) {
+CharSourceRange getElementsRange(const MatchResult &,
+ const InitListExpr &E) {
   return CharSourceRange::getCharRange(E.getLBraceLoc().getLocWithOffset(1),
E.getRBraceLoc());
 }
+} // namespace
 
 RangeSelector tooling::initListElements(StringRef ID) {
   return RelativeSelector(ID);


Index: clang/lib/Tooling/Refactoring/RangeSelector.cpp
===
--- clang/lib/Tooling/Refactoring/RangeSelector.cpp
+++ clang/lib/Tooling/Refactoring/RangeSelector.cpp
@@ -218,37 +218,43 @@
 };
 } // namespace
 
+namespace {
 // Returns the range of the statements (all source between the braces).
-static CharSourceRange getStatementsRange(const MatchResult &,
-  const CompoundStmt &CS) {
+CharSourceRange getStatementsRange(const MatchResult &,
+   const CompoundStmt &CS) {
   return CharSourceRange::getCharRange(CS.getLBracLoc().getLocWithOffset(1),
CS.getRBracLoc());
 }
+} // namespace
 
 RangeSelector tooling::statements(StringRef ID) {
   return RelativeSelector(ID);
 }
 
+namespace {
 // Returns the range of the source between the call's parentheses.
-static CharSourceRange getCallArgumentsRange(const MatchResult &Result,
- const CallExpr &CE) {
+CharSourceRange getCallArgumentsRange(const MatchResult &Result,
+  const CallExpr &CE) {
   return CharSourceRange::getCharRange(
   findOpenParen(CE, *Result.SourceManager, Result.Context->getLangOpts())
   .getLocWithOffset(1),
   CE.getRParenLoc());
 }
+} // namespace
 
 RangeSelector tooling::callArgs(StringRef ID) {
   return RelativeSelector(ID);
 }
 
+namespace {
 // Returns the range of the elements of the initializer list. Includes all
 // source between the braces.
-static CharSourceRange getElementsRange(const MatchResult &,
-const InitListExpr &E) {
+CharSourceRange getElementsRange(const MatchResult &,
+ const InitListExpr &E) {
   return CharSourceRange::getCharRange(E.getLBraceLoc().getLocWithOffset(1),
E.getRBraceLoc());
 }
+} // namespace
 
 RangeSelector tooling::initListElements(StringRef ID) {
   return RelativeSelector(ID);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58920: [Modules][PR39287] Consolidate multiple std's

2019-05-21 Thread Brian Gesiak via Phabricator via cfe-commits
modocache updated this revision to Diff 200518.
modocache added a comment.

Hmm... alright, I'm not really sure how I could implement a test that fails 
without this, but I added a check in the FindExistingResult destructor.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58920

Files:
  lib/Serialization/ASTReaderDecl.cpp
  test/Modules/Inputs/mod-virtual-destructor-bug-two/a.h
  test/Modules/Inputs/mod-virtual-destructor-bug-two/module.modulemap
  test/Modules/Inputs/mod-virtual-destructor-bug/a.h
  test/Modules/Inputs/mod-virtual-destructor-bug/module.modulemap
  test/Modules/mod-virtual-destructor-bug-two.cpp
  test/Modules/mod-virtual-destructor-bug.cpp

Index: test/Modules/mod-virtual-destructor-bug.cpp
===
--- /dev/null
+++ test/Modules/mod-virtual-destructor-bug.cpp
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++17 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/mod-virtual-destructor-bug %s -verify
+
+class A {
+  virtual ~A() {}
+};
+
+#include "a.h"
+
+namespace std { class type_info; }
+
+void foo() {
+  typeid(foo); // expected-warning {{expression result unused}}
+}
Index: test/Modules/mod-virtual-destructor-bug-two.cpp
===
--- /dev/null
+++ test/Modules/mod-virtual-destructor-bug-two.cpp
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++17 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/mod-virtual-destructor-bug-two %s -verify
+
+class A {
+  virtual ~A() {}
+};
+
+#include "a.h"
+
+void foo() {
+  typeid(foo); // expected-warning {{expression result unused}}
+}
Index: test/Modules/Inputs/mod-virtual-destructor-bug/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/mod-virtual-destructor-bug/module.modulemap
@@ -0,0 +1,3 @@
+module "a.h" {
+  header "a.h"
+}
Index: test/Modules/Inputs/mod-virtual-destructor-bug/a.h
===
--- /dev/null
+++ test/Modules/Inputs/mod-virtual-destructor-bug/a.h
@@ -0,0 +1 @@
+namespace std {}
Index: test/Modules/Inputs/mod-virtual-destructor-bug-two/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/mod-virtual-destructor-bug-two/module.modulemap
@@ -0,0 +1,3 @@
+module "a.h" {
+  header "a.h"
+}
Index: test/Modules/Inputs/mod-virtual-destructor-bug-two/a.h
===
--- /dev/null
+++ test/Modules/Inputs/mod-virtual-destructor-bug-two/a.h
@@ -0,0 +1 @@
+namespace std { class type_info; }
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -47,6 +47,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Sema/IdentifierResolver.h"
+#include "clang/Sema/Sema.h"
 #include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Serialization/ContinuousRangeMap.h"
@@ -3252,6 +3253,9 @@
 // Add the declaration to its redeclaration context so later merging
 // lookups will find it.
 MergeDC->makeDeclVisibleInContextImpl(New, /*Internal*/true);
+if (isa(New) && Name.getAsString() == "std")
+  if (!Reader.getSema()->StdNamespace)
+Reader.getSema()->StdNamespace = New;
   }
 }
 
@@ -3415,6 +3419,14 @@
   return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
 TypedefNameForLinkage);
 }
+if (isa(D) && D->getName() == "std") {
+  auto StdPtr = Reader.getSema()->StdNamespace;
+  if (StdPtr.isValid() && !StdPtr.isOffset())
+if (auto *Std = cast_or_null(StdPtr.get(nullptr)))
+  if (isSameEntity(Std, D))
+return FindExistingResult(Reader, D, Std, AnonymousDeclNumber,
+  TypedefNameForLinkage);
+}
   } else {
 // Not in a mergeable context.
 return FindExistingResult(Reader);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61643: [PragmaHandler][NFC] Expose `#pragma` location

2019-05-21 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny marked an inline comment as done.
jdenny added inline comments.



Comment at: clang/docs/ClangPlugins.rst:58
 ExamplePragmaHandler() : PragmaHandler("example_pragma") { }
-void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
+void HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer,
   Token &PragmaTok) {

lebedev.ri wrote:
> aaron.ballman wrote:
> > jdenny wrote:
> > > jdenny wrote:
> > > > lebedev.ri wrote:
> > > > > jdenny wrote:
> > > > > > lebedev.ri wrote:
> > > > > > > Hmm.
> > > > > > > This will have effects on out-of-tree plugins that define pragmas.
> > > > > > > I'm not sure how to proceed here, just notify cfe-dev and move on?
> > > > > > We could do something like this in `PragmaHandler`:
> > > > > > 
> > > > > > ```
> > > > > >   virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind 
> > > > > > Introducer,
> > > > > > Token &FirstToken) {
> > > > > > llvm_unreachable("deprecated HandlePragma unexpectedly called");
> > > > > >   }
> > > > > >   virtual void HandlePragma(Preprocessor &PP, PragmaIntroducer 
> > > > > > Introducer,
> > > > > > Token &FirstToken) {
> > > > > > HandlePragma(PP, Introducer.Kind, FirstToken);
> > > > > >   }
> > > > > > ```
> > > > > > 
> > > > > > The derived class could override either one.  Unfortunately, if it 
> > > > > > didn't override either, the error is then at run time instead of 
> > > > > > compile time as it is now.
> > > > > > 
> > > > > > Whether this is worth it, I don't know.  Who's the right person to 
> > > > > > answer this question?
> > > > > I think mailing cfe-dev will get this question the most visibility.
> > > > > Though i //think// the solution will be to go with the current patch.
> > > > I tried that at
> > > > 
> > > > http://lists.llvm.org/pipermail/cfe-dev/2019-May/062297.htm
> > > > 
> > > > but it's been a week without a response.  I'm happy to try again, 
> > > > perhaps with a shorter more general email about `PragmaHandler` 
> > > > backward compatibility that might catch a different set of eyes.  Is it 
> > > > worth it, or should we just assume no response so far means no one 
> > > > thinks it's an issue?  Thanks.
> > > Sorry, copy and paste error.  The URL is:
> > > 
> > > http://lists.llvm.org/pipermail/cfe-dev/2019-May/062297.html
> > I don't think we make guarantees about the stability of these APIs and this 
> > is a loud break for out-of-tree users rather than a silent behavioral 
> > change. I think the approach taken in this patch is fine.
> Indeed, i was waiting a bit of time since that post.
> Since there has been no response..
Thanks, guys!  I'll work on pushing soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61643



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


[PATCH] D62202: Work around a Visual C++ bug

2019-05-21 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

To provide some missing details:
The original source gets a bogus compile-time error with Visual Studio 2017, 
prior to version 15.8.  I have 15.2, so I need this patch to build Clang.
Our current minimum-version requirement (per CheckCompilerVersion.cmake) is 
Visual Studio 2015 (some specific update), which assumes all Visual Studio 2017 
versions are usable.  So by that criterion, we need this patch for all Visual 
Studio 2017 versions to be usable.
Arguably the anonymous-namespace version is the "more modern" tactic anyway, so 
as a long-term fix this is actually fine anyway.

My hesitation is... it *is* a compiler bug, and I'm working around it... 
wondered what y'all think about it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62202



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-21 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

@E5ten, I see what is going on. Give me 30 minutes and I’ll have a fix pushed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61909



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


[PATCH] D62192: [clang-tidy]: Add cert-oop54-cpp alias for bugprone-unhandled-self-assignment

2019-05-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mention alias (in aliases list) in Release Notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62192



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


r361271 - Fix BUILD_SHARED_LIBS for clang which broke in D61909

2019-05-21 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue May 21 08:56:17 2019
New Revision: 361271

URL: http://llvm.org/viewvc/llvm-project?rev=361271&view=rev
Log:
Fix BUILD_SHARED_LIBS for clang which broke in D61909

llvm_add_library ignores `BUILD_SHARED_LIBS` `STATIC` is explicitly specified. 
This restores the `BUILD_SHARED_LIBS` behavior to the clang build.

Modified:
cfe/trunk/cmake/modules/AddClang.cmake

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=361271&r1=361270&r2=361271&view=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Tue May 21 08:56:17 2019
@@ -83,7 +83,13 @@ macro(add_clang_library name)
   if(ARG_SHARED)
 set(LIBTYPE SHARED)
   else()
-set(LIBTYPE STATIC OBJECT)
+# llvm_add_library ignores BUILD_SHARED_LIBS if STATIC is explicitly set,
+# so we need to handle it here.
+if(BUILD_SHARED_LIBS)
+  set(LIBTYPE SHARED OBJECT)
+else()
+  set(LIBTYPE STATIC OBJECT)
+endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_STATIC_LIBS ${name})
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})


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


[PATCH] D62202: Work around a Visual C++ bug

2019-05-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D62202#1510394 , @probinson wrote:

> To provide some missing details:
>  The original source gets a bogus compile-time error with Visual Studio 2017, 
> prior to version 15.8.  I have 15.2, so I need this patch to build Clang.
>  Our current minimum-version requirement (per CheckCompilerVersion.cmake) is 
> Visual Studio 2015 (some specific update), which assumes all Visual Studio 
> 2017 versions are usable.  So by that criterion, we need this patch for all 
> Visual Studio 2017 versions to be usable.
>  Arguably the anonymous-namespace version is the "more modern" tactic anyway, 
> so as a long-term fix this is actually fine anyway.


Technically this violates the LLVM style guide which says "make anonymous 
namespaces as small as possible, and only use them for class declarations." 
(preferring static for functions) - 
https://llvm.org/docs/CodingStandards.html#anonymous-namespaces

But making code work for the compilers we say we support seems reasonable to me.

What's the compiler bug - can't handle static functions as non-type template 
parameters in general? Are there other workarounds to consider?

> My hesitation is... it *is* a compiler bug, and I'm working around it... 
> wondered what y'all think about it.




Repository:
  rC Clang

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

https://reviews.llvm.org/D62202



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


[PATCH] D61909: Add Clang shared library with C++ exports

2019-05-21 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

@E5ten, I just pushed r361271, which should resolve your issue.

I have a better longer-term fix in mind that I'll put up for review this week.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61909



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


[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-21 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr accepted this revision.
gribozavr added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clang-tidy/utils/TransformerTidy.h:32
+// };
+class TransformerTidy : public ClangTidyCheck {
+public:

I'd prefer a name like "TransformerClangTidyCheck", it will only appear in a 
few places, but is much more clear.



Comment at: clang-tools-extra/clang-tidy/utils/TransformerTidy.h:38
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;

I'd suggest to add comments telling users to not override these methods in 
subclasses.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386



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


[PATCH] D62202: Work around a Visual C++ bug

2019-05-21 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In D62202#1510414 , @dblaikie wrote:

> Technically this violates the LLVM style guide which says "make anonymous 
> namespaces as small as possible, and only use them for class declarations." 
> (preferring static for functions) - 
> https://llvm.org/docs/CodingStandards.html#anonymous-namespaces


Which argues for flagging it somehow.

> But making code work for the compilers we say we support seems reasonable to 
> me.
> 
> What's the compiler bug - can't handle static functions as non-type template 
> parameters in general? Are there other workarounds to consider?

Correct, static function was not permitted as a non-type template parameter.
https://developercommunity.visualstudio.com/content/problem/25334/error-code-c2971-when-specifying-a-function-as-the.html
I'm not aware of other workarounds, but I don't claim to be deeply familiar 
with the darker corners of C++.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62202



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


[PATCH] D58418: [clang][DirectoryWatcher] Upstream DirectoryWatcher

2019-05-21 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp:136
+
+const int PollResult = poll(&PollReq, 1, TimeoutMs);
+// There are inotify events waiting to be read!

jkorous wrote:
> gribozavr wrote:
> > What is the role of the timeout and why does it need to be so small?
> The whole idea is that we can't block on `read()` if we ever want to stop 
> watching the directory, release resources (file descriptors, threads) and 
> correctly destruct the DirectoryWatcher instance either
> - because of a bug in some other thread in the implementation
> - or asynchronous client action (e. g. destructor being called) in main 
> application thread
> 
> The timeout adds latency in those scenarios.
Waking up 1000 times a second is not great -- it will lead to battery drain on 
laptops etc.

Please see 
https://stackoverflow.com/questions/8593004/waiting-on-a-condition-pthread-cond-wait-and-a-socket-change-select-simultan
 for non-busy-wait options.



Comment at: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp:111
+
+  std::unique_ptr>

"alignof()" expression is standard C++ since C++11. (No need for underscores.)



Comment at: clang/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp:114
+  ManagedBuffer = llvm::make_unique>();
+  char *const Buf = ManagedBuffer->buffer;

use 'auto' to store the return value of make_unique?


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

https://reviews.llvm.org/D58418



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


[PATCH] D62202: Work around a Visual C++ bug

2019-05-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D62202#1510449 , @probinson wrote:

> In D62202#1510414 , @dblaikie wrote:
>
> > Technically this violates the LLVM style guide which says "make anonymous 
> > namespaces as small as possible, and only use them for class declarations." 
> > (preferring static for functions) - 
> > https://llvm.org/docs/CodingStandards.html#anonymous-namespaces
>
>
> Which argues for flagging it somehow.


Yeah, if we're going this way I'd certainly advocate having a comment of some 
kind explaining why it's this way so it doesn't regress.

>> But making code work for the compilers we say we support seems reasonable to 
>> me.
>> 
>> What's the compiler bug - can't handle static functions as non-type template 
>> parameters in general? Are there other workarounds to consider?
> 
> Correct, static function was not permitted as a non-type template parameter.
>  
> https://developercommunity.visualstudio.com/content/problem/25334/error-code-c2971-when-specifying-a-function-as-the.html
>  I'm not aware of other workarounds, but I don't claim to be deeply familiar 
> with the darker corners of C++.

I'm wondering if the code itself could be changed somewhat. Non-type template 
parameters, especially pointer typed ones (especially especially function 
pointer typed ones), are pretty rare/unusual. It'd be nice, for instance, to be 
able to pass a(n ideally stateless) lambda but there's no way to default 
construct them, or get a constexpr function pointer for them until C++17, 
unfortunately. (& even then you can't use lambdas directly in a template 
parameter expression, which is unfortunate... probably because mangling?)

Another possibility to keep these helper functions close to their use would be 
to put them in local classes inside the functions they're helping - and make 
the utility function a static member of that class? (it's awkward, but it's no 
more lines than wrapping each one in an anonymous namespace, etc)


Repository:
  rC Clang

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

https://reviews.llvm.org/D62202



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


[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

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



Comment at: clang-tools-extra/clang-tidy/utils/TransformerTidy.h:32
+// };
+class TransformerTidy : public ClangTidyCheck {
+public:

gribozavr wrote:
> I'd prefer a name like "TransformerClangTidyCheck", it will only appear in a 
> few places, but is much more clear.
will do, but should I also rename the files correspondingly?



Comment at: clang-tools-extra/clang-tidy/utils/TransformerTidy.h:38
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;

gribozavr wrote:
> I'd suggest to add comments telling users to not override these methods in 
> subclasses.
sure. would marking them as `final` make sense, then?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386



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


[PATCH] D62208: [OpenCL] Enable queue_t and clk_event_t comparisons in C++ mode

2019-05-21 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
Herald added subscribers: cfe-commits, yaxunl.
Herald added a project: clang.

Support queue_t and clk_event_t comparisons in C++ for OpenCL mode, to
preserve backwards compatibility with OpenCL C.


Repository:
  rC Clang

https://reviews.llvm.org/D62208

Files:
  lib/Sema/SemaExpr.cpp
  test/SemaOpenCL/clk_event_t.cl


Index: test/SemaOpenCL/clk_event_t.cl
===
--- test/SemaOpenCL/clk_event_t.cl
+++ test/SemaOpenCL/clk_event_t.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
 
 // Taken from opencl-c.h
 #define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -10808,7 +10808,7 @@
 return computeResultTy();
   }
 
-  if (getLangOpts().OpenCLVersion >= 200) {
+  if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
 if (LHSType->isClkEventT() && RHSType->isClkEventT()) {
   return computeResultTy();
 }


Index: test/SemaOpenCL/clk_event_t.cl
===
--- test/SemaOpenCL/clk_event_t.cl
+++ test/SemaOpenCL/clk_event_t.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL2.0
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=c++
 
 // Taken from opencl-c.h
 #define CLK_NULL_EVENT (__builtin_astype(((void*)(__SIZE_MAX__)), clk_event_t))
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -10808,7 +10808,7 @@
 return computeResultTy();
   }
 
-  if (getLangOpts().OpenCLVersion >= 200) {
+  if (getLangOpts().OpenCLVersion >= 200 || getLangOpts().OpenCLCPlusPlus) {
 if (LHSType->isClkEventT() && RHSType->isClkEventT()) {
   return computeResultTy();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-21 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/TransformerTidy.h:32
+// };
+class TransformerTidy : public ClangTidyCheck {
+public:

ymandel wrote:
> gribozavr wrote:
> > I'd prefer a name like "TransformerClangTidyCheck", it will only appear in 
> > a few places, but is much more clear.
> will do, but should I also rename the files correspondingly?
Yes please.



Comment at: clang-tools-extra/clang-tidy/utils/TransformerTidy.h:38
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;

ymandel wrote:
> gribozavr wrote:
> > I'd suggest to add comments telling users to not override these methods in 
> > subclasses.
> sure. would marking them as `final` make sense, then?
Right, that's the perfect tool for the job.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386



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


r361274 - Do not use the incorrect attribute spelling list index when translating a no_sanitize_foo attribute into a no_sanitize("foo") attribute.

2019-05-21 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Tue May 21 10:24:49 2019
New Revision: 361274

URL: http://llvm.org/viewvc/llvm-project?rev=361274&view=rev
Log:
Do not use the incorrect attribute spelling list index when translating a 
no_sanitize_foo attribute into a no_sanitize("foo") attribute.

This fixes a crash when AST pretty printing declarations marked with 
no_sanitize_memory.

Added:
cfe/trunk/test/AST/ast-print-no-sanitize.cpp
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=361274&r1=361273&r2=361274&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Tue May 21 10:24:49 2019
@@ -6329,9 +6329,21 @@ static void handleNoSanitizeSpecificAttr
   if (isGlobalVar(D) && SanitizerName != "address")
 S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
 << AL << ExpectedFunction;
-  D->addAttr(::new (S.Context)
- NoSanitizeAttr(AL.getRange(), S.Context, &SanitizerName, 1,
-AL.getAttributeSpellingListIndex()));
+
+  // FIXME: Rather than create a NoSanitizeSpecificAttr, this creates a
+  // NoSanitizeAttr object; but we need to calculate the correct spelling list
+  // index rather than incorrectly assume the index for NoSanitizeSpecificAttr
+  // has the same spellings as the index for NoSanitizeAttr. We don't have a
+  // general way to "translate" between the two, so this hack attempts to work
+  // around the issue with hard-coded indicies. This is critical for calling
+  // getSpelling() or prettyPrint() on the resulting semantic attribute object
+  // without failing assertions.
+  unsigned TranslatedSpellingIndex = 0;
+  if (AL.isC2xAttribute() || AL.isCXX11Attribute())
+TranslatedSpellingIndex = 1;
+
+  D->addAttr(::new (S.Context) NoSanitizeAttr(
+  AL.getRange(), S.Context, &SanitizerName, 1, TranslatedSpellingIndex));
 }
 
 static void handleInternalLinkageAttr(Sema &S, Decl *D, const ParsedAttr &AL) {

Added: cfe/trunk/test/AST/ast-print-no-sanitize.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-print-no-sanitize.cpp?rev=361274&view=auto
==
--- cfe/trunk/test/AST/ast-print-no-sanitize.cpp (added)
+++ cfe/trunk/test/AST/ast-print-no-sanitize.cpp Tue May 21 10:24:49 2019
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -std=c++11 -ast-print %s -o - | FileCheck %s
+
+void should_not_crash_1() __attribute__((no_sanitize_memory));
+[[clang::no_sanitize_memory]] void should_not_crash_2();
+
+// CHECK: void should_not_crash_1() __attribute__((no_sanitize("memory")));
+// CHECK: void should_not_crash_2() 
{{\[\[}}clang::no_sanitize("memory"){{\]\]}};


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


r361275 - [CMake] One more stab at fixing BUILD_SHARED_LIBS

2019-05-21 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue May 21 10:30:59 2019
New Revision: 361275

URL: http://llvm.org/viewvc/llvm-project?rev=361275&view=rev
Log:
[CMake] One more stab at fixing BUILD_SHARED_LIBS

If clang's libraries are build SHARED, we need to grab their 
`PRIVATE_LINK_LIBRARIES` properties and add those to clang_shared's interface.

Modified:
cfe/trunk/tools/clang-shlib/CMakeLists.txt

Modified: cfe/trunk/tools/clang-shlib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-shlib/CMakeLists.txt?rev=361275&r1=361274&r2=361275&view=diff
==
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt Tue May 21 10:30:59 2019
@@ -8,6 +8,7 @@ get_property(clang_libs GLOBAL PROPERTY
 foreach (lib ${clang_libs})
   list(APPEND _OBJECTS $)
   list(APPEND _DEPS $)
+  list(APPEND _DEPS $)
 endforeach ()
 
 add_clang_library(clang_shared


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


[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-21 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 200536.
ymandel added a comment.

Renamed TransformerTidy to TransformerClangTidyCheck; classes and files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386

Files:
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -0,0 +1,63 @@
+//=== TransformerClangTidyCheckTest.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 "../clang-tidy/utils/TransformerClangTidyCheck.h"
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Refactoring/Stencil.h"
+#include "clang/Tooling/Refactoring/Transformer.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace {
+// Invert the code of an if-statement, while maintaining its semantics.
+tooling::RewriteRule invertIf() {
+  using namespace ::clang::ast_matchers;
+  using tooling::change;
+  using tooling::stencil::cat;
+  using tooling::stencil::node;
+  using tooling::stencil::sNode;
+
+  StringRef C = "C", T = "T", E = "E";
+  return tooling::makeRule(
+  ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+ hasElse(stmt().bind(E))),
+  change(cat("if(!(", node(C), ")) ", sNode(E), " else ", sNode(T;
+}
+
+class IfInverterCheck : public TransformerClangTidyCheck {
+public:
+  IfInverterCheck(StringRef Name, ClangTidyContext *Context)
+  : TransformerClangTidyCheck(invertIf(), Name, Context) {}
+};
+
+// Basic test of using a rewrite rule as a ClangTidy.
+TEST(TransformerClangTidyCheckTest, Basic) {
+  const std::string Input = R"cc(
+void log(const char* msg);
+void foo() {
+  if (10 > 1.0)
+log("oh no!");
+  else
+log("ok");
+}
+  )cc";
+  const std::string Expected = R"(
+void log(const char* msg);
+void foo() {
+  if(!(10 > 1.0)) log("ok"); else log("oh no!");
+}
+  )";
+  EXPECT_EQ(Expected, test::runCheckOnCode(Input));
+}
+} // namespace
+} // namespace utils
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -17,6 +17,7 @@
   OverlappingReplacementsTest.cpp
   UsingInserterTest.cpp
   ReadabilityModuleTest.cpp
+  TransformerClangTidyCheckTest.cpp
   )
 
 target_link_libraries(ClangTidyTests
@@ -36,4 +37,5 @@
   clangTidyUtils
   clangTooling
   clangToolingCore
+  clangToolingRefactor
   )
Index: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.h
@@ -0,0 +1,49 @@
+//===-- TransformerClangTidyCheck.h - 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_CLANG_TIDY_CHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_CLANG_TIDY_CHECK_H
+
+#include "../ClangTidy.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Refactoring/Transformer.h"
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+// A base class for defining a ClangTidy check based on a `RewriteRule`.
+//
+// For example, given a rule `MyCheckAsRewriteRule`, one can define a tidy check
+// as follows:
+//
+// class MyCheck : public TransformerClangTidyCheck {
+//  public:
+//   MyCheck(StringRef Name, ClangTidyContext *Context)
+//   : TransformerClangTidyCheck(MyCheckAsRewriteRule, Name, Context) {}
+// };
+class TransformerClangTidyCheck : public ClangTidyCheck {
+public:
+  TransformerClangTidyCheck(tooling::RewriteRule R, StringRef Name,
+ClangTidyContext *Context)
+  : ClangTidyCheck(Name, 

[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-21 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 4 inline comments as done.
ymandel added a comment.

Thanks for the review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386



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


r361278 - [clang][Darwin] Refactor header search path logic into the driver

2019-05-21 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Tue May 21 10:48:04 2019
New Revision: 361278

URL: http://llvm.org/viewvc/llvm-project?rev=361278&view=rev
Log:
[clang][Darwin] Refactor header search path logic into the driver

Summary:
This commit moves the logic for determining system, resource and C++
header search paths from CC1 to the driver. This refactor has already
been made for several platforms, but Darwin had been left behind.

This refactor tries to implement the previous search path logic with
perfect accuracy. In particular, the order of all include paths inside
CC1 and all paths that were skipped because nonexistent are conserved
after the refactor. This change was also tested against a code base
of significant size and revealed no problems.

Reviewers: jfb, arphaman

Subscribers: nemanjai, javed.absar, kbarton, christof, jkorous, dexonsmith, 
jsji, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/include/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/include/c++/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/include/c++/4.2.1/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/include/c++/4.2.1/arm64-apple-darwin10/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/include/c++/4.2.1/arm64-apple-darwin10/.keep
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/lib/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_aarch64/usr/lib/.keep
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/4.2.1/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/4.2.1/arm-apple-darwin10/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/4.2.1/arm-apple-darwin10/v6/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/4.2.1/arm-apple-darwin10/v6/.keep

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/4.2.1/arm-apple-darwin10/v7/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/include/c++/4.2.1/arm-apple-darwin10/v7/.keep
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/lib/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_arm/usr/lib/.keep
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.0.0/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.0.0/powerpc-apple-darwin10/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.0.0/powerpc-apple-darwin10/ppc64/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.0.0/powerpc-apple-darwin10/ppc64/.keep

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.2.1/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.2.1/powerpc-apple-darwin10/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.2.1/powerpc-apple-darwin10/ppc64/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/include/c++/4.2.1/powerpc-apple-darwin10/ppc64/.keep
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/lib/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_ppc/usr/lib/.keep
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/
cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/c++/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/c++/4.0.0/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/c++/4.0.0/i686-apple-darwin8/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/c++/4.0.0/i686-apple-darwin8/.keep

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/c++/4.2.1/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86/usr/include/c++/4.2.1/i686-apple-darwin10/

cfe/trunk/test/Driver/Inputs/basic_darwin_sdk_libstdcxx_x86

  1   2   3   >