[PATCH] D96719: [clang-tidy] Add new check 'bugprone-thread-canceltype-asynchronous' and alias 'cert-pos47-c'.

2021-02-16 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 323896.
balazske marked 3 inline comments as done.
balazske added a comment.

Fixed problems with documentation and improved test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96719

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/ThreadCanceltypeAsynchronousCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ThreadCanceltypeAsynchronousCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-thread-canceltype-asynchronous.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-pos47-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-thread-canceltype-asynchronous.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-thread-canceltype-asynchronous.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-thread-canceltype-asynchronous.cpp
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s bugprone-thread-canceltype-asynchronous %t
+
+#define PTHREAD_CANCEL_DEFERRED 0
+#define PTHREAD_CANCEL_ASYNCHRONOUS 1
+
+int pthread_setcanceltype(int type, int *oldtype);
+
+int main() {
+  int result, oldtype;
+
+  if ((result = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype)) != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: asynchronous cancelability type should not be used [bugprone-thread-canceltype-asynchronous]
+return 1;
+  }
+
+  if ((result = pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype)) != 0) {
+return 1;
+  }
+
+  return 0;
+}
+
+int f() {
+  int result, oldtype;
+
+  if ((result = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype)) != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: asynchronous cancelability type should not be used [bugprone-thread-canceltype-asynchronous]
+return 1;
+  }
+
+  return 0;
+}
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
@@ -95,6 +95,7 @@
`bugprone-suspicious-string-compare `_, "Yes"
`bugprone-swapped-arguments `_, "Yes"
`bugprone-terminating-continue `_, "Yes"
+   `bugprone-thread-canceltype-asynchronous `_, "No"
`bugprone-throw-keyword-missing `_,
`bugprone-too-small-loop-variable `_,
`bugprone-undefined-memory-manipulation `_,
@@ -334,6 +335,7 @@
`cert-oop11-cpp `_, `performance-move-constructor-init `_, "Yes"
`cert-oop54-cpp `_, `bugprone-unhandled-self-assignment `_,
`cert-pos44-c `_, `bugprone-bad-signal-to-kill-thread `_,
+   `cert-pos47-c `_, `bugprone-thread-canceltype-asynchronous `_,
`cert-str34-c `_, `bugprone-signed-char-misuse `_,
`clang-analyzer-core.CallAndMessage `_, `Clang Static Analyzer `_,
`clang-analyzer-core.DivideZero `_, `Clang Static Analyzer `_,
Index: clang-tools-extra/docs/clang-tidy/checks/cert-pos47-c.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cert-pos47-c.rst
@@ -0,0 +1,9 @@
+.. title:: clang-tidy - cert-pos47-c
+.. meta::
+   :http-equiv=refresh: 5;URL=bugprone-thread-canceltype-asynchronous.html
+
+cert-pos47-c
+
+
+The cert-pos47-c check is an alias, please see
+`bugprone-thread-canceltype-asynchronous `_ for more information.
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-thread-canceltype-asynchronous.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-thread-canceltype-asynchronous.rst
@@ -0,0 +1,19 @@
+.. title:: clang-tidy - bugprone-thread-canceltype-asynchronous
+
+bugprone-thread-canceltype-asynchronous
+===
+
+Finds ``pthread_setcanceltype`` function calls where a thread's cancellation
+type is set to asynchronous. Asynchronous cancellation type
+(``PTHREAD_CANCEL_ASYNCHRONOUS``) is generally unsafe, use type
+``PTHREAD_CANCEL_DEFERRED`` instead which is the default. Even with deferred
+cancellation, a cancellation point in an asynchronous signal handler may still
+be acted upon and the effect is as if it was an asynchronous cancellation.
+
+.. code-block: c++
+
+  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+
+This check corresponds to the CERT C Coding Standard rule
+`POS47-C. Do not use threads that can be canceled asynchronously
+`_.
Index: clang-tools-

[PATCH] D96744: clang-format IncludeBlocks: Regroup determination of "main" for framework-style includes fix

2021-02-16 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Tooling/HeaderIncludesTest.cpp:106
+<< "for source file " << FileName;
+EXPECT_EQ(Manager.getIncludePriority("", true), 0)
+<< "for source file " << FileName;

I would also add `"baz.h"`, since the test is named `IsMainHeader`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96744

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


[PATCH] D96717: [clangd] Bind outgoing calls through LSPBinder too. NFC

2021-02-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

mostly LG. some comments around the way we set up outgoinmethod stubs though.




Comment at: clang-tools-extra/clangd/LSPBinder.h:88
+  template 
+  void outgoingMethod(llvm::StringLiteral Method,
+  OutgoingMethod &Handler) {

well this one filling an out-parameter definitely tripped me over while reading 
the code a couple times, and once more on the tests.

what about making this return the handler instead? E.g. `Edit = 
Bind.outgoingMethod("edit")`, I know it is ugly that we 
duplicate template params on declaration + here now. Maybe we can get away by 
making `OutgoingMethod` a class with a call operator and a `RawOutgoing *Out` 
member that can be bound later on ? e.g:

```
template 
class OutgoingMethod {
  RawOutgoing *Out = nullptr;
public:
  void operator()(const P& Params, Callback CB) {
assert(Out && "Method haven't bound");
Out->callMethod(Method, JSON(Params), );
  }
};
```

then we either make LSPBinder a friend of OutgoingMethod and set Out through 
it, or the other way around and have a `OutgoingMethod::bindOut(LSPBinder&)` ?

not sure if it is any better though, as we still construct a somewhat invalid 
object :/



Comment at: clang-tools-extra/clangd/LSPBinder.h:90
+  OutgoingMethod &Handler) {
+Handler = [Method, Out(&Out)](Request R, Callback Reply) {
+  Out->callMethod(

nit: maybe move bodies for these functions out-of-line too?



Comment at: clang-tools-extra/clangd/LSPBinder.h:93
+  Method, JSON(R),
+  // FIXME: why keep ctx alive but not restore it for the callback?
+  [Reply(std::move(Reply)), Ctx(Context::current().clone()),

haha feels like confusing `Context` and `WithContext` issue i talked about 
yesterday :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96717

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


[PATCH] D96730: [clangd] Modules can have a public API. NFC

2021-02-16 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.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/ClangdServer.h:349
 
+  ModuleSet *Modules;
   const GlobalCompilationDatabase &CDB;

nit: ` = nullptr`



Comment at: clang-tools-extra/clangd/Module.cpp:7
+bool ModuleSet::addImpl(void *Key, std::unique_ptr M) {
+  if (!Map.try_emplace(Key, M.get()).second)
+return false;

should we log/assert?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96730

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


[PATCH] D96755: [clangd] Shutdown sequence for modules, and doc threading requirements

2021-02-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

This allows modules to do work on non-TUScheduler background threads.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96755

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Module.h
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -16,6 +16,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Testing/Support/Error.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -23,6 +24,8 @@
 namespace clang {
 namespace clangd {
 namespace {
+using llvm::HasValue;
+using llvm::Succeeded;
 
 MATCHER_P(DiagMessage, M, "") {
   if (const auto *O = arg.getAsObject()) {
@@ -39,6 +42,7 @@
 Base = ClangdServer::optsForTest();
 // This is needed to we can test index-based operations like call hierarchy.
 Base.BuildDynamicSymbolIndex = true;
+Base.Modules = &Modules;
   }
 
   LSPClient &start() {
@@ -66,6 +70,7 @@
 
   MockFS FS;
   ClangdLSPServer::Options Opts;
+  ModuleSet Modules;
 
 private:
   // Color logs so we can distinguish them from test output.
@@ -233,10 +238,7 @@
 void get(const std::nullptr_t &, Callback Reply) { Reply(Value); }
 int Value = 0;
   };
-  std::vector> Mods;
-  Mods.push_back(std::make_unique());
-  ModuleSet ModSet(std::move(Mods));
-  Opts.Modules = &ModSet;
+  Modules.add(std::make_unique());
 
   auto &Client = start();
   Client.notify("add", 2);
@@ -244,6 +246,118 @@
   EXPECT_EQ(10, Client.call("get", nullptr).takeValue());
 }
 
+// Creates a Callback that writes its received value into an Optional.
+template 
+llvm::unique_function)>
+capture(llvm::Optional> &Out) {
+  Out.reset();
+  return [&Out](llvm::Expected V) { Out.emplace(std::move(V)); };
+}
+
+TEST_F(LSPTest, ModulesThreadingTest) {
+  // A module that does its work on a background thread, and so exercises the
+  // block/shutdown protocol.
+  class AsyncCounter : public Module {
+bool ShouldStop;
+int State = 0;
+std::deque> Queue; // null = increment, non-null = read.
+std::condition_variable CV;
+std::mutex Mu;
+std::thread Thread;
+
+void run() {
+  std::unique_lock Lock(Mu);
+  while (true) {
+CV.wait(Lock, [&] { return ShouldStop || !Queue.empty(); });
+if (ShouldStop) {
+  Queue.clear();
+  CV.notify_all();
+  return;
+}
+Callback &Task = Queue.front();
+if (Task)
+  Task(State);
+else
+  ++State;
+Queue.pop_front();
+CV.notify_all();
+  }
+}
+
+bool blockUntilIdle(Deadline D) override {
+  std::unique_lock Lock(Mu);
+  return clangd::wait(Lock, CV, D, [this] { return Queue.empty(); });
+}
+
+void stop() override {
+  {
+std::lock_guard Lock(Mu);
+ShouldStop = true;
+  }
+  CV.notify_all();
+}
+
+  public:
+AsyncCounter() : Thread([this] { run(); }) {}
+~AsyncCounter() {
+  // Verify shutdown sequence was performed.
+  // Real modules would not do this, to be robust to no ClangdServer.
+  EXPECT_TRUE(ShouldStop) << "ClangdServer should request shutdown";
+  EXPECT_EQ(Queue.size(), 0u) << "ClangdServer should block until idle";
+  Thread.join();
+}
+
+// Get the current value, bypassing the queue.
+// Used to verify that sync->blockUntilIdle avoids races in tests.
+int getSync() {
+  std::lock_guard Lock(Mu);
+  return State;
+}
+
+// Get the current value asynchronously.
+void get(Callback Reply) {
+  {
+std::lock_guard Lock(Mu);
+Queue.push_back(std::move(Reply));
+  }
+  CV.notify_all();
+}
+
+// Increment the current value asynchronously.
+void increment() {
+  {
+std::lock_guard Lock(Mu);
+Queue.push_back(nullptr);
+  }
+  CV.notify_all();
+}
+  };
+
+  auto *Counter = new AsyncCounter();
+  Modules.add(std::unique_ptr(Counter));
+  auto &Client = start();
+
+  llvm::Optional> One, Two, Three;
+  Counter->increment();
+  Counter->get(capture(One));
+  Counter->increment();
+  Counter->get(capture(Two));
+  Counter->increment();
+  Counter->get(capture(Three));
+  EXPECT_THAT_EXPECTED(Client.call("sync", nullptr).take(), Succeeded());
+  ASSERT_TRUE(One && Two && Three) << "sync should wait for pending requests";
+  EXPECT_EQ(3,

[PATCH] D96726: [clangd] Give modules access to filesystem, scheduler, and index.

2021-02-16 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.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/Module.h:1
+//===--- Module.h - Plugging features into clangd 
-*-C++-*-===//
+//

oops, sorry for forgetting that..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96726

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


[PATCH] D92290: [clangd] Factor out the heuristic resolver code into its own class

2021-02-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks so much for pushing this through, it looks great.

In D92290#2564656 , @nridge wrote:

> I haven't refactored the tests to pass in a null resolver / annotate the ones 
> that do or don't need one. Would you like that done in this patch, or a 
> follow-up?

Let's go ahead and land this, I'm happy to make the test changes.
(Not worried about regressions, as clearly we're never passing null in 
production)




Comment at: clang-tools-extra/clangd/HeuristicResolver.h:65
+  // Try to heuristically resolve the type of a dependent nested name
+  // specifier.
+  const Type *

nit: maybe just me, but "type of a NNS" is confusing because my brain thinks 
it's something like "type of an expr".

Maybe "type denoted by a NNS"?

Maybe also "Note that *dependent* name specifiers always name types, not e.g. 
namespaces".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92290

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


[PATCH] D96755: [clangd] Shutdown sequence for modules, and doc threading requirements

2021-02-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:180
+for (auto &Mod : *Modules)
+  Mod.blockUntilIdle(Deadline::infinity());
+  }

why is our contract saying that just calling `stop` is not enough?
i think clangdserver should just signal shutdown to modules, and our contract 
should say that server facilities will be undefined from this point forward.
that way modules accessing the facilities, could block stop until they are 
done, and never make use of it afterwards? it'll make modules a little more 
complicated, at the very least they would need some stricter control whenever 
they are accessing facilities, but I think it is worth for keeping clangdserver 
shutdown cleaner. wdyt?



Comment at: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp:261
+  class AsyncCounter : public Module {
+bool ShouldStop;
+int State = 0;

` = false;`



Comment at: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp:349
+  ASSERT_TRUE(One && Two && Three) << "sync should wait for pending requests";
+  EXPECT_EQ(3, Counter->getSync()) << "sync avoids flaky tests";
+  // Sanity check: reads and writes are sequenced on the worker thread.

not sure what this is testing in addition to final callback receiving 3 as a 
value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96755

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


[PATCH] D96744: clang-format IncludeBlocks: Regroup determination of "main" for framework-style includes fix

2021-02-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I think I'd be concern about the `` case (lets ignore the fact that I 
should be including 

so imagine I'm writing a string class and I have

string.cpp including "string.h"

but as part of my string class because I'm somehow extending std::string

  #include "string.h"
  #include 
  
  class mystring : public std::string
  {
  }

Which file wins?

I think lots of people will always consider `<>` to mean system paths, I think 
if there is any chance that `<>` could change the order then I think it needs 
to be an option that is off by default.

I don't think this is a bug, I think you are asking for an enhancement.




Comment at: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp:237
-  if (!IncludeName.startswith("\""))
-return false;
-

Does this need to be an option?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96744

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


[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-02-16 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: clang/include/clang/Driver/Options.td:4231
+def flarge_sizes : Flag<["-"],"flarge-sizes">, Group, 
+  HelpText<"Set the default KIND for INTEGER to 8.">;
 }

tskeith wrote:
> That's not what -flarge-sizes does. Here is the description from 
> flang/docs/Extensions.md:
> 
> > The default `INTEGER` type is required by the standard to occupy
> > the same amount of storage as the default `REAL` type.  Default
> > `REAL` is of course 32-bit IEEE-754 floating-point today.  This legacy
> > rule imposes an artificially small constraint in some cases
> > where Fortran mandates that something have the default `INTEGER`
> > type: specifically, the results of references to the intrinsic functions
> > `SIZE`, `STORAGE_SIZE`,`LBOUND`, `UBOUND`, `SHAPE`, and the location 
> > reductions
> > `FINDLOC`, `MAXLOC`, and `MINLOC` in the absence of an explicit
> > `KIND=` actual argument.  We return `INTEGER(KIND=8)` by default in
> > these cases when the `-flarge-sizes` option is enabled.
> > `SIZEOF` and `C_SIZEOF` always return `INTEGER(KIND=8)`.
It will be tricky to capture all that in a short help text. Would this work:
```
Use INTEGER(KIND=8) for the result type in size-related intrinsics.
```
?


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

https://reviews.llvm.org/D96344

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


[PATCH] D92290: [clangd] Factor out the heuristic resolver code into its own class

2021-02-16 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 323906.
nridge added a comment.

address nit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92290

Files:
  clang-tools-extra/clangd/ASTSignals.cpp
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/HeuristicResolver.cpp
  clang-tools-extra/clangd/HeuristicResolver.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -86,7 +86,8 @@
 EXPECT_EQ(N->kind(), NodeType) << Selection;
 
 std::vector ActualDecls;
-for (const auto &Entry : allTargetDecls(N->ASTNode))
+for (const auto &Entry :
+ allTargetDecls(N->ASTNode, AST.getHeuristicResolver()))
   ActualDecls.emplace_back(Entry.first, Entry.second);
 return ActualDecls;
   }
@@ -978,16 +979,20 @@
 
 std::vector Refs;
 if (const auto *Func = llvm::dyn_cast(TestDecl))
-  findExplicitReferences(Func->getBody(), [&Refs](ReferenceLoc R) {
-Refs.push_back(std::move(R));
-  });
+  findExplicitReferences(
+  Func->getBody(),
+  [&Refs](ReferenceLoc R) { Refs.push_back(std::move(R)); },
+  AST.getHeuristicResolver());
 else if (const auto *NS = llvm::dyn_cast(TestDecl))
-  findExplicitReferences(NS, [&Refs, &NS](ReferenceLoc R) {
-// Avoid adding the namespace foo decl to the results.
-if (R.Targets.size() == 1 && R.Targets.front() == NS)
-  return;
-Refs.push_back(std::move(R));
-  });
+  findExplicitReferences(
+  NS,
+  [&Refs, &NS](ReferenceLoc R) {
+// Avoid adding the namespace foo decl to the results.
+if (R.Targets.size() == 1 && R.Targets.front() == NS)
+  return;
+Refs.push_back(std::move(R));
+  },
+  AST.getHeuristicResolver());
 else
   ADD_FAILURE() << "Failed to find ::foo decl for test";
 
Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -148,34 +148,37 @@
   // removing the directive.
   std::vector IdentsToQualify;
   for (auto &D : Inputs.AST->getLocalTopLevelDecls()) {
-findExplicitReferences(D, [&](ReferenceLoc Ref) {
-  if (Ref.Qualifier)
-return; // This reference is already qualified.
-
-  for (auto *T : Ref.Targets) {
-if (!visibleContext(T->getDeclContext())
- ->Equals(TargetDirective->getNominatedNamespace()))
-  return;
-  }
-  SourceLocation Loc = Ref.NameLoc;
-  if (Loc.isMacroID()) {
-// Avoid adding qualifiers before macro expansions, it's probably
-// incorrect, e.g.
-//   namespace std { int foo(); }
-//   #define FOO 1 + foo()
-//   using namespace foo; // provides matrix
-//   auto x = FOO; // Must not changed to auto x = std::FOO
-if (!SM.isMacroArgExpansion(Loc))
-  return; // FIXME: report a warning to the users.
-Loc = SM.getFileLoc(Ref.NameLoc);
-  }
-  assert(Loc.isFileID());
-  if (SM.getFileID(Loc) != SM.getMainFileID())
-return; // FIXME: report these to the user as warnings?
-  if (SM.isBeforeInTranslationUnit(Loc, FirstUsingDirectiveLoc))
-return; // Directive was not visible before this point.
-  IdentsToQualify.push_back(Loc);
-});
+findExplicitReferences(
+D,
+[&](ReferenceLoc Ref) {
+  if (Ref.Qualifier)
+return; // This reference is already qualified.
+
+  for (auto *T : Ref.Targets) {
+if (!visibleContext(T->getDeclContext())
+ ->Equals(TargetDirective->getNominatedNamespace()))
+  return;
+  }
+  SourceLocation Loc = Ref.NameLoc;
+  if (Loc.isMacroID()) {
+// Avoid adding qualifiers before macro expansions, it's probably
+// incorrect, e.g.
+//   namespace std { int foo(); }
+  

[PATCH] D92290: [clangd] Factor out the heuristic resolver code into its own class

2021-02-16 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9510b0940265: [clangd] Factor out the heuristic resolver 
code into its own class (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92290

Files:
  clang-tools-extra/clangd/ASTSignals.cpp
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/HeuristicResolver.cpp
  clang-tools-extra/clangd/HeuristicResolver.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -86,7 +86,8 @@
 EXPECT_EQ(N->kind(), NodeType) << Selection;
 
 std::vector ActualDecls;
-for (const auto &Entry : allTargetDecls(N->ASTNode))
+for (const auto &Entry :
+ allTargetDecls(N->ASTNode, AST.getHeuristicResolver()))
   ActualDecls.emplace_back(Entry.first, Entry.second);
 return ActualDecls;
   }
@@ -978,16 +979,20 @@
 
 std::vector Refs;
 if (const auto *Func = llvm::dyn_cast(TestDecl))
-  findExplicitReferences(Func->getBody(), [&Refs](ReferenceLoc R) {
-Refs.push_back(std::move(R));
-  });
+  findExplicitReferences(
+  Func->getBody(),
+  [&Refs](ReferenceLoc R) { Refs.push_back(std::move(R)); },
+  AST.getHeuristicResolver());
 else if (const auto *NS = llvm::dyn_cast(TestDecl))
-  findExplicitReferences(NS, [&Refs, &NS](ReferenceLoc R) {
-// Avoid adding the namespace foo decl to the results.
-if (R.Targets.size() == 1 && R.Targets.front() == NS)
-  return;
-Refs.push_back(std::move(R));
-  });
+  findExplicitReferences(
+  NS,
+  [&Refs, &NS](ReferenceLoc R) {
+// Avoid adding the namespace foo decl to the results.
+if (R.Targets.size() == 1 && R.Targets.front() == NS)
+  return;
+Refs.push_back(std::move(R));
+  },
+  AST.getHeuristicResolver());
 else
   ADD_FAILURE() << "Failed to find ::foo decl for test";
 
Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -148,34 +148,37 @@
   // removing the directive.
   std::vector IdentsToQualify;
   for (auto &D : Inputs.AST->getLocalTopLevelDecls()) {
-findExplicitReferences(D, [&](ReferenceLoc Ref) {
-  if (Ref.Qualifier)
-return; // This reference is already qualified.
-
-  for (auto *T : Ref.Targets) {
-if (!visibleContext(T->getDeclContext())
- ->Equals(TargetDirective->getNominatedNamespace()))
-  return;
-  }
-  SourceLocation Loc = Ref.NameLoc;
-  if (Loc.isMacroID()) {
-// Avoid adding qualifiers before macro expansions, it's probably
-// incorrect, e.g.
-//   namespace std { int foo(); }
-//   #define FOO 1 + foo()
-//   using namespace foo; // provides matrix
-//   auto x = FOO; // Must not changed to auto x = std::FOO
-if (!SM.isMacroArgExpansion(Loc))
-  return; // FIXME: report a warning to the users.
-Loc = SM.getFileLoc(Ref.NameLoc);
-  }
-  assert(Loc.isFileID());
-  if (SM.getFileID(Loc) != SM.getMainFileID())
-return; // FIXME: report these to the user as warnings?
-  if (SM.isBeforeInTranslationUnit(Loc, FirstUsingDirectiveLoc))
-return; // Directive was not visible before this point.
-  IdentsToQualify.push_back(Loc);
-});
+findExplicitReferences(
+D,
+[&](ReferenceLoc Ref) {
+  if (Ref.Qualifier)
+return; // This reference is already qualified.
+
+  for (auto *T : Ref.Targets) {
+if (!visibleContext(T->getDeclContext())
+ ->Equals(TargetDirective->getNominatedNamespace()))
+  return;
+  }
+  SourceLocation Loc = Ref.NameLoc;
+  if (Loc.isMacroID(

[clang-tools-extra] 9510b09 - [clangd] Factor out the heuristic resolver code into its own class

2021-02-16 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2021-02-16T04:10:52-05:00
New Revision: 9510b09402659e6ba6e29b9caf0504c89bc72871

URL: 
https://github.com/llvm/llvm-project/commit/9510b09402659e6ba6e29b9caf0504c89bc72871
DIFF: 
https://github.com/llvm/llvm-project/commit/9510b09402659e6ba6e29b9caf0504c89bc72871.diff

LOG: [clangd] Factor out the heuristic resolver code into its own class

The patch also does some cleanup on the interface of the entry
points from TargetFinder into the heuristic resolution code.

Since the heuristic resolver is created in a place where the
ASTContext is available, it can store the ASTContext and the
NameFactory hack can be removed.

Differential revision: https://reviews.llvm.org/D92290

Added: 
clang-tools-extra/clangd/HeuristicResolver.cpp
clang-tools-extra/clangd/HeuristicResolver.h

Modified: 
clang-tools-extra/clangd/ASTSignals.cpp
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/FindTarget.h
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/ParsedAST.h
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ASTSignals.cpp 
b/clang-tools-extra/clangd/ASTSignals.cpp
index b8cc7f05927a..58c57e147d41 100644
--- a/clang-tools-extra/clangd/ASTSignals.cpp
+++ b/clang-tools-extra/clangd/ASTSignals.cpp
@@ -15,27 +15,30 @@ namespace clangd {
 ASTSignals ASTSignals::derive(const ParsedAST &AST) {
   ASTSignals Signals;
   const SourceManager &SM = AST.getSourceManager();
-  findExplicitReferences(AST.getASTContext(), [&](ReferenceLoc Ref) {
-for (const NamedDecl *ND : Ref.Targets) {
-  if (!isInsideMainFile(Ref.NameLoc, SM))
-continue;
-  SymbolID ID = getSymbolID(ND);
-  if (!ID)
-continue;
-  unsigned &SymbolCount = Signals.ReferencedSymbols[ID];
-  SymbolCount++;
-  // Process namespace only when we see the symbol for the first time.
-  if (SymbolCount != 1)
-continue;
-  if (const auto *NSD = dyn_cast(ND->getDeclContext())) {
-if (NSD->isAnonymousNamespace())
-  continue;
-std::string NS = printNamespaceScope(*NSD);
-if (!NS.empty())
-  Signals.RelatedNamespaces[NS]++;
-  }
-}
-  });
+  findExplicitReferences(
+  AST.getASTContext(),
+  [&](ReferenceLoc Ref) {
+for (const NamedDecl *ND : Ref.Targets) {
+  if (!isInsideMainFile(Ref.NameLoc, SM))
+continue;
+  SymbolID ID = getSymbolID(ND);
+  if (!ID)
+continue;
+  unsigned &SymbolCount = Signals.ReferencedSymbols[ID];
+  SymbolCount++;
+  // Process namespace only when we see the symbol for the first time.
+  if (SymbolCount != 1)
+continue;
+  if (const auto *NSD = dyn_cast(ND->getDeclContext())) 
{
+if (NSD->isAnonymousNamespace())
+  continue;
+std::string NS = printNamespaceScope(*NSD);
+if (!NS.empty())
+  Signals.RelatedNamespaces[NS]++;
+  }
+}
+  },
+  AST.getHeuristicResolver());
   return Signals;
 }
 } // namespace clangd

diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 1d12e7e2355d..3de510665723 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -71,6 +71,7 @@ add_clang_library(clangDaemon
   GlobalCompilationDatabase.cpp
   Headers.cpp
   HeaderSourceSwitch.cpp
+  HeuristicResolver.cpp
   Hover.cpp
   IncludeFixer.cpp
   JSONTransport.cpp

diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index 46c98685dabb..2dabae47b519 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -8,6 +8,7 @@
 
 #include "FindTarget.h"
 #include "AST.h"
+#include "HeuristicResolver.h"
 #include "support/Logger.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Decl.h"
@@ -56,210 +57,6 @@ LLVM_ATTRIBUTE_UNUSED std::string nodeToString(const 
DynTypedNode &N) {
   return S;
 }
 
-// Helper function for getMembersReferencedViaDependentName()
-// which takes a possibly-dependent type `T` and heuristically
-// resolves it to a CXXRecordDecl in which we can try name lookup.
-CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) {
-  assert(T);
-
-  if (const auto *RT = T->getAs())

[PATCH] D96760: [clang-format] Suppress diagnostics on second parse

2021-02-16 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: njames93, MyDeveloperDay, curdeius.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is the follow up to D93844 .

Suppress the diagnostics when applying the child configurations, since they 
were printed on the first parse.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96760

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


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1394,8 +1394,8 @@
 }
 
 std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
-   FormatStyle *Style,
-   bool AllowUnknownOptions) {
+   FormatStyle *Style, bool 
AllowUnknownOptions,
+   llvm::SourceMgr::DiagHandlerTy DiagHandler) 
{
   assert(Style);
   FormatStyle::LanguageKind Language = Style->Language;
   assert(Language != FormatStyle::LK_None);
@@ -1403,7 +1403,8 @@
 return make_error_code(ParseError::Error);
   Style->StyleSet.Clear();
   std::vector Styles;
-  llvm::yaml::Input Input(Config);
+  llvm::yaml::Input Input(Config, /*Ctxt=*/nullptr, DiagHandler,
+  /*DiagHandlerCtxt=*/nullptr);
   // DocumentListTraits> uses the context to get default
   // values for the fields, keys for which are missing from the configuration.
   // Mapping also uses the context to get the language to find the correct
@@ -2990,6 +2991,8 @@
   FilesToLookFor.push_back(".clang-format");
   FilesToLookFor.push_back("_clang-format");
 
+  auto dropDiagnosticHandler = [](const llvm::SMDiagnostic &, void *) {};
+
   for (StringRef Directory = Path; !Directory.empty();
Directory = llvm::sys::path::parent_path(Directory)) {
 
@@ -3034,7 +3037,8 @@
   LLVM_DEBUG(llvm::dbgs() << "Applying child configurations\n");
 
   for (const auto& MemBuf : llvm::reverse(ChildFormatTextToApply)){
-auto Ec = parseConfiguration(*MemBuf, &Style, AllowUnknownOptions);
+auto Ec = parseConfiguration(*MemBuf, &Style, AllowUnknownOptions,
+ dropDiagnosticHandler);
 // It was already correctly parsed.
 assert(!Ec);
 static_cast(Ec);
@@ -3069,8 +3073,9 @@
 LLVM_DEBUG(llvm::dbgs()
<< "Applying child configuration on fallback style\n");
 
-auto Ec = parseConfiguration(*ChildFormatTextToApply.front(),
- &FallbackStyle, AllowUnknownOptions);
+auto Ec =
+parseConfiguration(*ChildFormatTextToApply.front(), &FallbackStyle,
+   AllowUnknownOptions, dropDiagnosticHandler);
 // It was already correctly parsed.
 assert(!Ec);
 static_cast(Ec);
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -19,6 +19,7 @@
 #include "clang/Tooling/Inclusions/IncludeStyle.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/Regex.h"
+#include "llvm/Support/SourceMgr.h"
 #include 
 
 namespace llvm {
@@ -3269,9 +3270,10 @@
 private:
   FormatStyleSet StyleSet;
 
-  friend std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
-FormatStyle *Style,
-bool AllowUnknownOptions);
+  friend std::error_code
+  parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
+ bool AllowUnknownOptions,
+ llvm::SourceMgr::DiagHandlerTy DiagHandler);
 };
 
 /// Returns a format style complying with the LLVM coding standards:
@@ -3329,9 +3331,12 @@
 ///
 /// If AllowUnknownOptions is true, no errors are emitted if unknown
 /// format options are occured.
-std::error_code parseConfiguration(llvm::MemoryBufferRef Config,
-   FormatStyle *Style,
-   bool AllowUnknownOptions = false);
+///
+/// If set all diagnostics are emitted through the DiagHandler.
+std::error_code
+parseConfiguration(llvm::MemoryBufferRef Config, FormatStyle *Style,
+   bool AllowUnknownOptions = false,
+   llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr);
 
 /// Like above but accepts an unnamed buffer.
 inline std::error_code parseConfiguration(StringRef Config, FormatStyle *Style,


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1394,8 +1394,8 @@

[PATCH] D96761: [clang][cli] Generate -f[no-]finite-loops arguments

2021-02-16 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, fhahn.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch generates the `-f[no-]finite-loops` arguments from 
`CompilerInvocation` (added in D96419 ), 
fixing test failures of Clang built with `-DCLANG_ROUND_TRIP_CC1_ARGS=ON`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96761

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/attr-mustprogress.cpp


Index: clang/test/CodeGenCXX/attr-mustprogress.cpp
===
--- clang/test/CodeGenCXX/attr-mustprogress.cpp
+++ clang/test/CodeGenCXX/attr-mustprogress.cpp
@@ -7,7 +7,7 @@
 // Make sure -ffinite-loops overrides -std=c++98 for loops.
 // RUN: %clang_cc1 -std=c++98 -ffinite-loops -triple=x86_64-unknown-linux-gnu 
-S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s
 
-// Make sure -fno_finite-loops overrides -std=c++11
+// Make sure -fno-finite-loops overrides -std=c++11
 // RUN: %clang_cc1 -std=c++11 -fno-finite-loops 
-triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck 
--check-prefix=CHECK --check-prefix=CXX98 %s
 
 int a = 0;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1509,6 +1509,17 @@
 
   if (!Opts.EmitVersionIdentMetadata)
 GenerateArg(Args, OPT_Qn, SA);
+
+  switch (Opts.FiniteLoops) {
+  case CodeGenOptions::FiniteLoopsKind::Language:
+break;
+  case CodeGenOptions::FiniteLoopsKind::Always:
+GenerateArg(Args, OPT_ffinite_loops, SA);
+break;
+  case CodeGenOptions::FiniteLoopsKind::Never:
+GenerateArg(Args, OPT_fno_finite_loops, SA);
+break;
+  }
 }
 
 bool CompilerInvocation::ParseCodeGenArgsImpl(CodeGenOptions &Opts,


Index: clang/test/CodeGenCXX/attr-mustprogress.cpp
===
--- clang/test/CodeGenCXX/attr-mustprogress.cpp
+++ clang/test/CodeGenCXX/attr-mustprogress.cpp
@@ -7,7 +7,7 @@
 // Make sure -ffinite-loops overrides -std=c++98 for loops.
 // RUN: %clang_cc1 -std=c++98 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s
 
-// Make sure -fno_finite-loops overrides -std=c++11
+// Make sure -fno-finite-loops overrides -std=c++11
 // RUN: %clang_cc1 -std=c++11 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX98 %s
 
 int a = 0;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1509,6 +1509,17 @@
 
   if (!Opts.EmitVersionIdentMetadata)
 GenerateArg(Args, OPT_Qn, SA);
+
+  switch (Opts.FiniteLoops) {
+  case CodeGenOptions::FiniteLoopsKind::Language:
+break;
+  case CodeGenOptions::FiniteLoopsKind::Always:
+GenerateArg(Args, OPT_ffinite_loops, SA);
+break;
+  case CodeGenOptions::FiniteLoopsKind::Never:
+GenerateArg(Args, OPT_fno_finite_loops, SA);
+break;
+  }
 }
 
 bool CompilerInvocation::ParseCodeGenArgsImpl(CodeGenOptions &Opts,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96760: [clang-format] Suppress diagnostics on second parse

2021-02-16 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/include/clang/Format/Format.h:3342-3346
 inline std::error_code parseConfiguration(StringRef Config, FormatStyle *Style,
   bool AllowUnknownOptions = false) {
   return parseConfiguration(llvm::MemoryBufferRef(Config, "YAML"), Style,
 AllowUnknownOptions);
 }

On my code I would do that change too.

This way we would get all the changes to the signature without manual work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96760

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


[clang] 96d229c - [flang][driver] Add options for unparsing

2021-02-16 Thread Andrzej Warzynski via cfe-commits

Author: Andrzej Warzynski
Date: 2021-02-16T09:32:51Z
New Revision: 96d229c9abdfb2836e18a554bfb63b5d52aeebfa

URL: 
https://github.com/llvm/llvm-project/commit/96d229c9abdfb2836e18a554bfb63b5d52aeebfa
DIFF: 
https://github.com/llvm/llvm-project/commit/96d229c9abdfb2836e18a554bfb63b5d52aeebfa.diff

LOG: [flang][driver] Add options for unparsing

This patch adds the following compiler frontend driver options:
  * -fdebug-unparse (f18 spelling: -funparse)
  * -fdebug-unparse-with-symbols (f18 spelling: -funparse-with-symbols)
The new driver will only accept the new spelling. `f18` will accept both
the original and the new spelling.

A new base class for frontend actions is added: `PrescanAndSemaAction`.
This is added to reduce code duplication that otherwise these new
options would lead to. Implementation from
  * `ParseSyntaxOnlyAction::ExecutionAction`
is moved to:
  * `PrescanAndSemaAction::BeginSourceFileAction`
This implementation is now shared between:
  * PrescanAndSemaAction
  * ParseSyntaxOnlyAction
  * DebugUnparseAction
  * DebugUnparseWithSymbolsAction

All tests that don't require other yet unimplemented options are
updated. This way `flang-new -fc1` is used instead of `f18` when
`FLANG_BUILD_NEW_DRIVER` is set to `On`. In order to facilitate this,
`%flang_fc1` is added in the LIT configuration (lit.cfg.py).

`asFortran` from f18.cpp is duplicated as `getBasicAsFortran` in
FrontendOptions.cpp. At this stage it's hard to find a good place to
share this method. I suggest that we revisit this once a switch from
`f18` to `flang-new` is complete.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
flang/include/flang/Frontend/FrontendActions.h
flang/include/flang/Frontend/FrontendOptions.h
flang/lib/Frontend/CMakeLists.txt
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendActions.cpp
flang/lib/Frontend/FrontendOptions.cpp
flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
flang/lib/Parser/CMakeLists.txt
flang/test/Flang-Driver/driver-help.f90
flang/test/Parser/continuation-in-if.f
flang/test/Parser/pp-dir-comments.f90
flang/test/Semantics/canondo01.f90
flang/test/Semantics/canondo02.f90
flang/test/Semantics/canondo03.f90
flang/test/Semantics/canondo04.f90
flang/test/Semantics/canondo05.f90
flang/test/Semantics/critical04.f90
flang/test/Semantics/defined-ops.f90
flang/test/Semantics/doconcurrent02.f90
flang/test/Semantics/doconcurrent03.f90
flang/test/Semantics/doconcurrent04.f90
flang/test/Semantics/doconcurrent07.f90
flang/test/Semantics/label02.f90
flang/test/Semantics/label03.f90
flang/test/Semantics/label04.f90
flang/test/Semantics/label05.f90
flang/test/Semantics/label06.f90
flang/test/Semantics/label07.f90
flang/test/Semantics/label08.f90
flang/test/Semantics/label09.f90
flang/test/Semantics/label10.f90
flang/test/Semantics/label12.f90
flang/test/Semantics/label13.f90
flang/test/Semantics/label15.f90
flang/test/lit.cfg.py
flang/tools/f18/f18.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d22956b86c4a..04a23c59e264 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4244,6 +4244,18 @@ def fopenacc : Flag<["-"], "fopenacc">, Group,
 
 }
 
+//===--===//
+// FC1 Options
+//===--===//
+let Flags = [FC1Option, FlangOnlyOption] in {
+
+def fdebug_unparse : Flag<["-"], "fdebug-unparse">, Group,
+  HelpText<"Unparse and stop.">;
+def fdebug_unparse_with_symbols : Flag<["-"], "fdebug-unparse-with-symbols">, 
Group,
+  HelpText<"Unparse and stop.">;
+
+}
+
 
//===--===//
 // CC1 Options
 
//===--===//

diff  --git a/flang/include/flang/Frontend/FrontendActions.h 
b/flang/include/flang/Frontend/FrontendActions.h
index f28e3c2bc552..4c29d0d5a641 100644
--- a/flang/include/flang/Frontend/FrontendActions.h
+++ b/flang/include/flang/Frontend/FrontendActions.h
@@ -37,7 +37,23 @@ class PrintPreprocessedAction : public PrescanAction {
   void ExecuteAction() override;
 };
 
-class ParseSyntaxOnlyAction : public PrescanAction {
+//===--===//
+// PrescanAndSema Actions
+//===--===//
+class PrescanAndSemaAction : public FrontendAction {
+  void ExecuteAction() override = 0;
+  bool BeginSourceFileAction(CompilerInstance &ci) override;
+};
+
+class DebugUnparseWithSymbolsAction : public 

[PATCH] D96483: [flang][driver] Add options for unparsing

2021-02-16 Thread Andrzej Warzynski via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG96d229c9abdf: [flang][driver] Add options for unparsing 
(authored by awarzynski).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96483

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CMakeLists.txt
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/Frontend/FrontendOptions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/lib/Parser/CMakeLists.txt
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Parser/continuation-in-if.f
  flang/test/Parser/pp-dir-comments.f90
  flang/test/Semantics/canondo01.f90
  flang/test/Semantics/canondo02.f90
  flang/test/Semantics/canondo03.f90
  flang/test/Semantics/canondo04.f90
  flang/test/Semantics/canondo05.f90
  flang/test/Semantics/critical04.f90
  flang/test/Semantics/defined-ops.f90
  flang/test/Semantics/doconcurrent02.f90
  flang/test/Semantics/doconcurrent03.f90
  flang/test/Semantics/doconcurrent04.f90
  flang/test/Semantics/doconcurrent07.f90
  flang/test/Semantics/label02.f90
  flang/test/Semantics/label03.f90
  flang/test/Semantics/label04.f90
  flang/test/Semantics/label05.f90
  flang/test/Semantics/label06.f90
  flang/test/Semantics/label07.f90
  flang/test/Semantics/label08.f90
  flang/test/Semantics/label09.f90
  flang/test/Semantics/label10.f90
  flang/test/Semantics/label12.f90
  flang/test/Semantics/label13.f90
  flang/test/Semantics/label15.f90
  flang/test/lit.cfg.py
  flang/tools/f18/f18.cpp

Index: flang/tools/f18/f18.cpp
===
--- flang/tools/f18/f18.cpp
+++ flang/tools/f18/f18.cpp
@@ -540,9 +540,10 @@
   options.instrumentedParse = true;
 } else if (arg == "-fdebug-no-semantics") {
   driver.debugNoSemantics = true;
-} else if (arg == "-funparse") {
+} else if (arg == "-funparse" || arg == "-fdebug-unparse") {
   driver.dumpUnparse = true;
-} else if (arg == "-funparse-with-symbols") {
+} else if (arg == "-funparse-with-symbols" ||
+arg == "-fdebug-unparse-with-symbols") {
   driver.dumpUnparseWithSymbols = true;
 } else if (arg == "-funparse-typed-exprs-to-f18-fc") {
   driver.unparseTypedExprsToF18_FC = true;
Index: flang/test/lit.cfg.py
===
--- flang/test/lit.cfg.py
+++ flang/test/lit.cfg.py
@@ -74,10 +74,15 @@
 if config.include_flang_new_driver_test:
tools.append(ToolSubst('%flang-new', command=FindTool('flang-new'), unresolved='fatal'))
tools.append(ToolSubst('%flang', command=FindTool('flang-new'), unresolved='fatal'))
+   tools.append(ToolSubst('%flang_fc1', command=FindTool('flang-new'),
+extra_args=['-fc1'], unresolved='fatal'))
 else:
tools.append(ToolSubst('%flang', command=FindTool('f18'),
 extra_args=["-intrinsic-module-directory "+config.flang_intrinsic_modules_dir],
 unresolved='fatal'))
+   tools.append(ToolSubst('%flang_fc1', command=FindTool('f18'),
+extra_args=["-intrinsic-module-directory "+config.flang_intrinsic_modules_dir],
+unresolved='fatal'))
 
 if config.flang_standalone_build:
 llvm_config.add_tool_substitutions(tools, [config.flang_llvm_tools_dir])
Index: flang/test/Semantics/label15.f90
===
--- flang/test/Semantics/label15.f90
+++ flang/test/Semantics/label15.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
 
 !CHECK-NOT: error:
 module mm
Index: flang/test/Semantics/label13.f90
===
--- flang/test/Semantics/label13.f90
+++ flang/test/Semantics/label13.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
 ! CHECK: branch into loop body from outside
 ! CHECK: the loop branched into
 
Index: flang/test/Semantics/label12.f90
===
--- flang/test/Semantics/label12.f90
+++ flang/test/Semantics/label12.f90
@@ -1,4 +1,4 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
 ! CHECK: expected end of statement
 
 subroutine s
Index: flang/test/Semantics/label10.f90
===
--- flang/test/Semantics/label10.f90
+++ flang/test/Semantics/label10.f90
@@ -1,4 +1,4 @@
-! RUN: not %f18 -funparse-with-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang_fc1 -fdebug-unparse-with-symbols %s 2>&1 | FileCheck %s
 ! CHECK:

[PATCH] D96744: clang-format IncludeBlocks: Regroup determination of "main" for framework-style includes fix

2021-02-16 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc added a comment.

Thanks for the speedy reply and the great tool. With appropriate Regex and 
Priority settings, `IncludeCategories` worked flawlessly for me aside from not 
identifying the main header. Treating `#include "foo/bar/baz.h"` as the main 
header in file `bar/random/baz.h` seems like a bug, but I certainly see the 
dangers of changing current `<>` behavior. I also considered treating `<>` 
includes as main headers only if they also contain a forward-slash, e.g.:

  if (!IncludeName.startswith("\"") && !IncludeName.contains("/"))
return false;

That would resolve the `` case, although `#include ` in 
a file `anything/sys/types.h` would be identified as the main header. So making 
an option seems like the cleanest solution. Say, `bool 
IncludeIsMainAllowBraces`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96744

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


[PATCH] D89870: [clangd] Drop template argument lists from completions followed by

2021-02-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

(sorry for forgetting about this)




Comment at: clang-tools-extra/clangd/CodeComplete.cpp:450
+if (Snippet->front() == '<')
+  return Snippet->substr(0, Snippet->find('('));
+return "";

what if we have `(` in the template parameter list ? i think we need to 
literally find the matching `>` and include all the text in between instead.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:456
+  // template argument list but it would be complicated.
+  if (NextTokenKind == tok::less && Snippet->front() == '<')
+return "";

nit: again might be worth putting the easy-to-reason case above to reduce 
mental load when reading.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:459
+}
 if (!Snippet)
   // All bundles are function calls.

nit: move this case above and get rid of `if(Snippet` part of the check?



Comment at: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp:2982
   )cpp";
+  // FIXME(kirillbobyrev): Also strip prefix of identifier token before the
+  // cursor from completion item ("fo" in this case).

umm, where did this fixme come from exactly? don't we emit these as 
replacements for the `fo` part of the text anyway ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89870

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


[PATCH] D96716: [flang][driver] Add debug dump options

2021-02-16 Thread Faris Rehman via Phabricator via cfe-commits
FarisRehman updated this revision to Diff 323929.
FarisRehman added a comment.

Rebase off main

Rebase off main and update some comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96716

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/debug-provenance.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Semantics/data05.f90
  flang/test/Semantics/data08.f90
  flang/test/Semantics/data09.f90
  flang/test/Semantics/offsets01.f90
  flang/test/Semantics/offsets02.f90
  flang/test/Semantics/offsets03.f90
  flang/test/Semantics/resolve100.f90
  flang/test/Semantics/rewrite01.f90

Index: flang/test/Semantics/rewrite01.f90
===
--- flang/test/Semantics/rewrite01.f90
+++ flang/test/Semantics/rewrite01.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fdebug-dump-parse-tree %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-dump-parse-tree %s 2>&1 | FileCheck %s
 ! Ensure that READ(CVAR) [, item-list] is corrected when CVAR is a
 ! character variable so as to be a formatted read from the default
 ! unit, not an unformatted read from an internal unit (which is not
Index: flang/test/Semantics/resolve100.f90
===
--- flang/test/Semantics/resolve100.f90
+++ flang/test/Semantics/resolve100.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
+!RUN: %flang_fc1 -fdebug-dump-symbols %s | FileCheck %s
 
 program p
   ! CHECK: a size=4 offset=0: ObjectEntity type: LOGICAL(4)
Index: flang/test/Semantics/offsets03.f90
===
--- flang/test/Semantics/offsets03.f90
+++ flang/test/Semantics/offsets03.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
+!RUN: %flang_fc1 -fdebug-dump-symbols %s | FileCheck %s
 
 ! Size and alignment with EQUIVALENCE and COMMON
 
Index: flang/test/Semantics/offsets02.f90
===
--- flang/test/Semantics/offsets02.f90
+++ flang/test/Semantics/offsets02.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
+!RUN: %flang_fc1 -fdebug-dump-symbols %s | FileCheck %s
 
 ! Size and alignment of derived types
 
Index: flang/test/Semantics/offsets01.f90
===
--- flang/test/Semantics/offsets01.f90
+++ flang/test/Semantics/offsets01.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
+!RUN: %flang_fc1 -fdebug-dump-symbols %s | FileCheck %s
 
 ! Size and alignment of intrinsic types
 subroutine s1
Index: flang/test/Semantics/data09.f90
===
--- flang/test/Semantics/data09.f90
+++ flang/test/Semantics/data09.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fsyntax-only -fdebug-dump-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-dump-symbols %s 2>&1 | FileCheck %s
 ! CHECK: init:[INTEGER(4)::1065353216_4,1073741824_4,1077936128_4,1082130432_4]
 ! Verify that the closure of EQUIVALENCE'd symbols with any DATA
 ! initialization produces a combined initializer.
Index: flang/test/Semantics/data08.f90
===
--- flang/test/Semantics/data08.f90
+++ flang/test/Semantics/data08.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fdebug-dump-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fdebug-dump-symbols %s 2>&1 | FileCheck %s
 ! CHECK: DATA statement value initializes 'jx' of type 'INTEGER(4)' with CHARACTER
 ! CHECK: DATA statement value initializes 'jy' of type 'INTEGER(4)' with CHARACTER
 ! CHECK: DATA statement value initializes 'jz' of type 'INTEGER(4)' with CHARACTER
Index: flang/test/Semantics/data05.f90
===
--- flang/test/Semantics/data05.f90
+++ flang/test/Semantics/data05.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
+!RUN: %flang_fc1 -fdebug-dump-symbols %s | FileCheck %s
 module m
   interface
 integer function ifunc(n)
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -46,6 +46,9 @@
 ! HELP-FC1-NEXT: -D = Define  to  (or 1 if  omitted)
 ! HELP-FC1-NEXT: -emit-obj Emit native object files
 ! HELP-FC1-NEXT: -E Only run the preprocessor
+! HELP-FC1-NEXT: -fdebug-dump-parse-tree Dump the parse tree
+! HELP-FC1-NEXT: -fdebug-dump-provenance Dump provenance
+! HELP-FC1-NEXT: -fdebug-dump-symbolsDump symbols after the semanti

[PATCH] D96761: [clang][cli] Generate -f[no-]finite-loops arguments

2021-02-16 Thread Florian Hahn via Phabricator via cfe-commits
fhahn accepted this revision.
fhahn added a comment.
This revision is now accepted and ready to land.

LGTM thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96761

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


[PATCH] D96407: [flang][driver] Add extension options and -finput-charset

2021-02-16 Thread Faris Rehman via Phabricator via cfe-commits
FarisRehman updated this revision to Diff 323938.
FarisRehman added a comment.

Rebase off main

Rebase off main and remove dependency on patch D96344 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96407

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/FrontendOptions.h
  flang/include/flang/Parser/parsing.h
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/escaped-backslash.f90
  flang/test/Flang-Driver/frontend-forwarding.f90
  flang/test/Flang-Driver/implicit-none.f90
  flang/test/Semantics/oldparam02.f90
  flang/test/Semantics/resolve64.f90

Index: flang/test/Semantics/resolve64.f90
===
--- flang/test/Semantics/resolve64.f90
+++ flang/test/Semantics/resolve64.f90
@@ -1,4 +1,4 @@
-! RUN: %S/test_errors.sh %s %t %f18 -flogical-abbreviations -fxor-operator
+! RUN: %S/test_errors.sh %s %t %flang -flogical-abbreviations -fxor-operator
 
 ! Like m4 in resolve63 but compiled with different options.
 ! Alternate operators are enabled so treat these as intrinsic.
Index: flang/test/Semantics/oldparam02.f90
===
--- flang/test/Semantics/oldparam02.f90
+++ flang/test/Semantics/oldparam02.f90
@@ -1,4 +1,4 @@
-! RUN: not %f18 -falternative-parameter-statement -fdebug-dump-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang -falternative-parameter-statement -fsyntax-only %s 2>&1 | FileCheck %s
 
 ! Error tests for "old style" PARAMETER statements
 subroutine subr(x1,x2,x3,x4,x5)
Index: flang/test/Flang-Driver/implicit-none.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/implicit-none.f90
@@ -0,0 +1,32 @@
+! Ensure argument -fimplicit-none works as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=DEFAULT
+! RUN: %flang-new -fsyntax-only -fimplicit-none -fno-implicit-none %s  2>&1 | FileCheck %s --allow-empty --check-prefix=DEFAULT
+! RUN: not %flang-new -fsyntax-only -fimplicit-none %s  2>&1 | FileCheck %s --check-prefix=WITH_IMPL_NONE
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=DEFAULT
+! RUN: %flang-new -fc1 -fsyntax-only -fimplicit-none -fno-implicit-none %s  2>&1 | FileCheck %s --allow-empty --check-prefix=DEFAULT
+! RUN: not %flang-new -fc1 -fsyntax-only -fimplicit-none %s  2>&1 | FileCheck %s --check-prefix=WITH_IMPL_NONE
+
+!--
+! EXPECTED OUTPUT FOR NO IMPLICIT NONE
+!--
+! DEFAULT-NOT:error
+
+!--
+! EXPECTED OUTPUT FOR IMPLICIT NONE ALWAYS
+!--
+! WITH_IMPL_NONE:No explicit type declared for 'a'
+! WITH_IMPL_NONE:No explicit type declared for 'b'
+
+function a()
+  a = b
+end
Index: flang/test/Flang-Driver/frontend-forwarding.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/frontend-forwarding.f90
@@ -0,0 +1,10 @@
+! Test that flang-new forwards Flang frontend 
+! options to flang-new -fc1 as expected.
+
+! REQUIRES: new-flang-driver
+
+! RUN: %flang-new -fsyntax-only -### %s -o %t 2>&1 \
+! RUN: -finput-charset=utf-8 \
+! RUN:   | FileCheck %s
+
+! CHECK: "-finput-charset=utf-8"
Index: flang/test/Flang-Driver/escaped-backslash.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/escaped-backslash.f90
@@ -0,0 +1,35 @@
+! Ensure argument -fbackslash works as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -E %s  2>&1 | FileCheck %s --check-prefix=ESCAPED
+! RUN: %flang-new -E -fbackslash -fno-backslash %s  2>&1 | FileCheck %s --check-prefix=ESCAPED
+! RUN: %flang-new -E -fbackslash %s  2>&1 | FileCheck %s --check-prefix=UNESCAPED
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 -E %s  2>&1 | FileCheck %s --check-prefix=ESCAPED
+! RUN: %flang-new -fc1 -E -fbackslash -fno-backslash %s  2>&1 | FileCheck %s --check-prefix=ESCAPED
+! RUN: %flang-new -fc1 -E -fbackslash %s  2>&1 | FileCheck %s --check-prefix=UNESCAPED
+
+!-
+! EXP

[clang] 10826ea - [flang][driver] Add extension options and -finput-charset

2021-02-16 Thread Faris Rehman via cfe-commits

Author: Faris Rehman
Date: 2021-02-16T11:27:06Z
New Revision: 10826ea7b1c12c2afe421448996f98ed66869020

URL: 
https://github.com/llvm/llvm-project/commit/10826ea7b1c12c2afe421448996f98ed66869020
DIFF: 
https://github.com/llvm/llvm-project/commit/10826ea7b1c12c2afe421448996f98ed66869020.diff

LOG: [flang][driver] Add extension options and -finput-charset

Add the following options:
* -fimplicit-none and -fno-implicit-none
* -fbackslash and -fno-backslash
* -flogical-abbreviations and -fno-logical-abbreviations
* -fxor-operator and -fno-xor-operator
* -falternative-parameter-statement
* -finput-charset=

Summary of changes:
- Enable extensions in CompilerInvocation#ParseFrontendArgs
- Add encoding_ to Fortran::frontend::FrontendOptions
- Add encoding to Fortran::parser::Options

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

Added: 
flang/test/Flang-Driver/escaped-backslash.f90
flang/test/Flang-Driver/frontend-forwarding.f90
flang/test/Flang-Driver/implicit-none.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/FrontendOptions.h
flang/include/flang/Parser/parsing.h
flang/lib/Frontend/CompilerInstance.cpp
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Flang-Driver/driver-help-hidden.f90
flang/test/Flang-Driver/driver-help.f90
flang/test/Semantics/oldparam02.f90
flang/test/Semantics/resolve64.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 04a23c59e264..b3e17e1bfe27 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1714,7 +1714,8 @@ def fexperimental_strict_floating_point : Flag<["-"], 
"fexperimental-strict-floa
   Group, Flags<[CC1Option]>,
   HelpText<"Enables experimental strict floating point in LLVM.">,
   MarshallingInfoFlag>;
-def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group;
+def finput_charset_EQ : Joined<["-"], "finput-charset=">, Flags<[FlangOption, 
FC1Option]>, Group,
+  HelpText<"Specify the default character set for source files">;
 def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group;
 def finstrument_functions : Flag<["-"], "finstrument-functions">, 
Group, Flags<[CC1Option]>,
   HelpText<"Generate calls to instrument function entry and exit">,
@@ -4170,7 +4171,6 @@ defm aggressive_function_elimination : 
BooleanFFlag<"aggressive-function-elimina
 defm align_commons : BooleanFFlag<"align-commons">, Group;
 defm all_intrinsics : BooleanFFlag<"all-intrinsics">, Group;
 defm automatic : BooleanFFlag<"automatic">, Group;
-defm backslash : BooleanFFlag<"backslash">, Group;
 defm backtrace : BooleanFFlag<"backtrace">, Group;
 defm bounds_check : BooleanFFlag<"bounds-check">, Group;
 defm check_array_temporaries : BooleanFFlag<"check-array-temporaries">, 
Group;
@@ -4187,7 +4187,6 @@ defm dump_parse_tree : BooleanFFlag<"dump-parse-tree">, 
Group;
 defm external_blas : BooleanFFlag<"external-blas">, Group;
 defm f2c : BooleanFFlag<"f2c">, Group;
 defm frontend_optimize : BooleanFFlag<"frontend-optimize">, 
Group;
-defm implicit_none : BooleanFFlag<"implicit-none">, Group;
 defm init_local_zero : BooleanFFlag<"init-local-zero">, Group;
 defm integer_4_integer_8 : BooleanFFlag<"integer-4-integer-8">, 
Group;
 defm intrinsic_modules_path : BooleanFFlag<"intrinsic-modules-path">, 
Group;
@@ -4241,6 +4240,22 @@ file}]>;
 def ffixed_line_length_VALUE : Joined<["-"], "ffixed-line-length-">, 
Group, Alias;
 def fopenacc : Flag<["-"], "fopenacc">, Group,
   HelpText<"Enable OpenACC">;
+def fbackslash : Flag<["-"], "fbackslash">, Group,
+  HelpText<"Specify that backslash in string introduces an escape character">,
+  DocBrief<[{Change the interpretation of backslashes in string literals from
+a single backslash character to "C-style" escape characters.}]>;
+def fno_backslash : Flag<["-"], "fno-backslash">, Group;
+def fxor_operator : Flag<["-"], "fxor-operator">, Group,
+  HelpText<"Enable .XOR. as a synonym of .NEQV.">;
+def fno_xor_operator : Flag<["-"], "fno-xor-operator">, Group;
+def flogical_abbreviations : Flag<["-"], "flogical-abbreviations">, 
Group,
+  HelpText<"Enable logical abbreviations">;
+def fno_logical_abbreviations : Flag<["-"], "fno-logical-abbreviations">, 
Group;
+def fimplicit_none : Flag<["-"], "fimplicit-none">, Group,
+  HelpText<"No implicit typing allowed unless overridden by IMPLICIT 
statements">;
+def fno_implicit_none : Flag<["-"], "fno-implicit-none">, Group;
+def falternative_parameter_statement : Flag<["-"], 
"falternative-parameter-statement">, Group,
+  HelpText<"Enable the old style PARAMETER statement">;
 
 }
 

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index c96b33ba1696..98d37eb7e692 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/Too

[PATCH] D96407: [flang][driver] Add extension options and -finput-charset

2021-02-16 Thread Faris Rehman via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG10826ea7b1c1: [flang][driver] Add extension options and 
-finput-charset (authored by FarisRehman).

Changed prior to commit:
  https://reviews.llvm.org/D96407?vs=323938&id=323950#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96407

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/FrontendOptions.h
  flang/include/flang/Parser/parsing.h
  flang/lib/Frontend/CompilerInstance.cpp
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Flang-Driver/escaped-backslash.f90
  flang/test/Flang-Driver/frontend-forwarding.f90
  flang/test/Flang-Driver/implicit-none.f90
  flang/test/Semantics/oldparam02.f90
  flang/test/Semantics/resolve64.f90

Index: flang/test/Semantics/resolve64.f90
===
--- flang/test/Semantics/resolve64.f90
+++ flang/test/Semantics/resolve64.f90
@@ -1,4 +1,4 @@
-! RUN: %S/test_errors.sh %s %t %f18 -flogical-abbreviations -fxor-operator
+! RUN: %S/test_errors.sh %s %t %flang -flogical-abbreviations -fxor-operator
 
 ! Like m4 in resolve63 but compiled with different options.
 ! Alternate operators are enabled so treat these as intrinsic.
Index: flang/test/Semantics/oldparam02.f90
===
--- flang/test/Semantics/oldparam02.f90
+++ flang/test/Semantics/oldparam02.f90
@@ -1,4 +1,4 @@
-! RUN: not %f18 -falternative-parameter-statement -fdebug-dump-symbols %s 2>&1 | FileCheck %s
+! RUN: not %flang -falternative-parameter-statement -fsyntax-only %s 2>&1 | FileCheck %s
 
 ! Error tests for "old style" PARAMETER statements
 subroutine subr(x1,x2,x3,x4,x5)
Index: flang/test/Flang-Driver/implicit-none.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/implicit-none.f90
@@ -0,0 +1,32 @@
+! Ensure argument -fimplicit-none works as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=DEFAULT
+! RUN: %flang-new -fsyntax-only -fimplicit-none -fno-implicit-none %s  2>&1 | FileCheck %s --allow-empty --check-prefix=DEFAULT
+! RUN: not %flang-new -fsyntax-only -fimplicit-none %s  2>&1 | FileCheck %s --check-prefix=WITH_IMPL_NONE
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=DEFAULT
+! RUN: %flang-new -fc1 -fsyntax-only -fimplicit-none -fno-implicit-none %s  2>&1 | FileCheck %s --allow-empty --check-prefix=DEFAULT
+! RUN: not %flang-new -fc1 -fsyntax-only -fimplicit-none %s  2>&1 | FileCheck %s --check-prefix=WITH_IMPL_NONE
+
+!--
+! EXPECTED OUTPUT FOR NO IMPLICIT NONE
+!--
+! DEFAULT-NOT:error
+
+!--
+! EXPECTED OUTPUT FOR IMPLICIT NONE ALWAYS
+!--
+! WITH_IMPL_NONE:No explicit type declared for 'a'
+! WITH_IMPL_NONE:No explicit type declared for 'b'
+
+function a()
+  a = b
+end
Index: flang/test/Flang-Driver/frontend-forwarding.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/frontend-forwarding.f90
@@ -0,0 +1,10 @@
+! Test that flang-new forwards Flang frontend
+! options to flang-new -fc1 as expected.
+
+! REQUIRES: new-flang-driver
+
+! RUN: %flang-new -fsyntax-only -### %s -o %t 2>&1 \
+! RUN: -finput-charset=utf-8 \
+! RUN:   | FileCheck %s
+
+! CHECK: "-finput-charset=utf-8"
Index: flang/test/Flang-Driver/escaped-backslash.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/escaped-backslash.f90
@@ -0,0 +1,35 @@
+! Ensure argument -fbackslash works as expected.
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -E %s  2>&1 | FileCheck %s --check-prefix=ESCAPED
+! RUN: %flang-new -E -fbackslash -fno-backslash %s  2>&1 | FileCheck %s --check-prefix=ESCAPED
+! RUN: %flang-new -E -fbackslash %s  2>&1 | FileCheck %s --check-prefix=UNESCAPED
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 -E %s  2>&1 | FileCheck %s --check-prefix=ESCAPED
+! RUN: %flang-new -fc1 -E -fbackslash -fno-backslash %s  2>&1 | FileCheck %s --check-prefix=ESCA

[PATCH] D96690: [clangd] Treat paths case-insensitively depending on the platform

2021-02-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 323951.
kadircet added a comment.
Herald added subscribers: ormris, mgorny.

- Don't case fold stored strings, or the ones passing interface boundaries
- Define a `pathIsAncestor` helper instead and use that for comparison of 
MountPoint
- Expose a CLANGD_PATH_CASE_INSENSITIVE macro, which is defined whenever the 
platform treats paths case-insensitively


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96690

Files:
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/support/Path.cpp
  clang-tools-extra/clangd/support/Path.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/support/PathTests.cpp

Index: clang-tools-extra/clangd/unittests/support/PathTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/support/PathTests.cpp
@@ -0,0 +1,36 @@
+//===-- PathTests.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 "support/Path.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+TEST(PathTests, IsAncestor) {
+  EXPECT_TRUE(pathIsAncestor("/foo", "/foo"));
+  EXPECT_TRUE(pathIsAncestor("/foo/", "/foo"));
+
+  EXPECT_FALSE(pathIsAncestor("/foo", "/fooz"));
+  EXPECT_FALSE(pathIsAncestor("/foo/", "/fooz"));
+
+  EXPECT_TRUE(pathIsAncestor("/foo", "/foo/bar"));
+  EXPECT_TRUE(pathIsAncestor("/foo/", "/foo/bar"));
+
+#ifdef CLANGD_PATH_CASE_INSENSITIVE
+  EXPECT_TRUE(pathIsAncestor("/fOo", "/foo/bar"));
+  EXPECT_TRUE(pathIsAncestor("/foo", "/fOo/bar"));
+#else
+  EXPECT_FALSE(pathIsAncestor("/fOo", "/foo/bar"));
+  EXPECT_FALSE(pathIsAncestor("/foo", "/fOo/bar"));
+#endif
+}
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1125,7 +1125,7 @@
   EXPECT_THAT(Results.GlobalChanges.keys(),
   UnorderedElementsAre(Main, testPath("other.cc")));
 
-#if defined(_WIN32) || defined(__APPLE__)
+#ifdef CLANGD_PATH_CASE_INSENSITIVE
   // On case-insensitive systems, no duplicates if AST vs index case differs.
   // https://github.com/clangd/clangd/issues/665
   TU.Filename = "MAIN.CC";
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -99,6 +99,25 @@
   Frag.If.PathMatch.emplace_back("ba*r");
   EXPECT_FALSE(compileAndApply());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+
+  // Only matches case-insensitively.
+  Frag = {};
+  Frag.If.PathMatch.emplace_back("B*R");
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+#ifdef CLANGD_PATH_CASE_INSENSITIVE
+  EXPECT_TRUE(compileAndApply());
+#else
+  EXPECT_FALSE(compileAndApply());
+#endif
+
+  Frag = {};
+  Frag.If.PathExclude.emplace_back("B*R");
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+#ifdef CLANGD_PATH_CASE_INSENSITIVE
+  EXPECT_FALSE(compileAndApply());
+#else
+  EXPECT_TRUE(compileAndApply());
+#endif
 }
 
 TEST_F(ConfigCompileTests, CompileCommands) {
@@ -406,6 +425,22 @@
   ASSERT_THAT(Diags.Diagnostics, IsEmpty());
   ASSERT_TRUE(Conf.Index.External);
   EXPECT_THAT(Conf.Index.External->MountPoint, FooPath);
+
+  // Only matches case-insensitively.
+  BazPath = testPath("fOo/baz.h", llvm::sys::path::Style::posix);
+  BazPath = llvm::sys::path::convert_to_slash(BazPath);
+  Parm.Path = BazPath;
+
+  FooPath = testPath("FOO/", llvm::sys::path::Style::posix);
+  Frag = GetFrag("", FooPath.c_str());
+  compileAndApply();
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+#ifdef CLANGD_PATH_CASE_INSENSITIVE
+  ASSERT_TRUE(Conf.Index.External);
+  EXPECT_THAT(Conf.Index.External->MountPoint, FooPath);
+#else
+  ASSERT_FALSE(Conf.Index.External);
+#endif
 }
 } // namespace
 } // namespace config
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -104,6 +104,7 @@
   support/FunctionTests.cpp
   support/MarkupTests.cpp
   support/MemoryTreeTests.cpp
+  support/PathTests.cpp
   support/ThreadingTests.cp

[PATCH] D94627: [PowerPC][PC Rel] Implement option to omit Power10 instructions from stubs

2021-02-16 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp accepted this revision as: stefanp.
stefanp added a comment.
This revision is now accepted and ready to land.

I just have one final nit otherwise LGTM. Feel free to fix that on commit.
Please wait a couple of days and see if @MaskRay has any further comments.




Comment at: lld/test/ELF/ppc64-pcrel-call-to-extern.s:135
+
+## .plt[3] - 0x10020010 = 0x10030160 - 0x10020010 = 0x10150 = 65888
 # CHECK-LABEL: <__plt_pcrel_callee_global_stother1>:

stefanp wrote:
> nit:
> Please fix these comments.
> `0x10150` does not equal `65888`.
nit:
I think these numbers are still wrong.
```
0x10030160 - 0x10020010 = 0x10150 not 0x10160
```
I think it should be: `0x10030170`


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

https://reviews.llvm.org/D94627

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


[PATCH] D81678: Introduce noundef attribute at call sites for stricter poison analysis

2021-02-16 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678

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


[PATCH] D96760: [clang-format] Suppress diagnostics on second parse

2021-02-16 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I did have another plan for a different way to go about this, not sure if its 
really any better though.
It involved building a vector of the edits the config would apply to its 
parent. Then after the parent is parsed just applying those edits.
It results in only 1 pass over the config file however it's a little more 
involved to get it to work.




Comment at: clang/include/clang/Format/Format.h:3339
+   bool AllowUnknownOptions = false,
+   llvm::SourceMgr::DiagHandlerTy DiagHandler = nullptr);
 

I know this is sufficient for the purpose of this patch, however it doesn't 
make sense to accept take the handler parameter without also taking a void* for 
its context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96760

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


[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-16 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal created this revision.
pdhaliwal added reviewers: jdoerfert, JonChesterfield, ronlieb.
Herald added subscribers: kerbowa, guansong, t-tye, tpr, dstuttard, yaxunl, 
nhaehnle, jvesely, kzhuravl.
pdhaliwal requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, wdng.
Herald added a project: clang.

AMDGCN does not support linking of object files, hence
backend and assemble actions are skipped to produce LLVM IR.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96769

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/test/Driver/amdgpu-openmp-toolchain.c


Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===
--- clang/test/Driver/amdgpu-openmp-toolchain.c
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
 // RUN:   env LIBRARY_PATH=%S/Inputs/hip_dev_lib %clang -### 
--target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa 
-Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s 2>&1 \
 // RUN:   | FileCheck %s
@@ -5,7 +6,7 @@
 // verify the tools invocations
 // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" 
"c"{{.*}}
 // CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-unknown-linux-gnu"{{.*}}"-x" 
"ir"{{.*}}
-// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" 
"amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" 
"-emit-llvm-bc" 
"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}}
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" 
"amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx906" "-fcuda-is-device" 
"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx906.bc"{{.*}}
 // CHECK: llvm-link{{.*}}"-o" 
"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc"
 // CHECK: llc{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-linked-{{.*}}.bc" 
"-mtriple=amdgcn-amd-amdhsa" "-mcpu=gfx906" "-filetype=obj" 
"-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o"
 // CHECK: lld{{.*}}"-flavor" "gnu" "--no-undefined" "-shared" 
"-o"{{.*}}amdgpu-openmp-toolchain-{{.*}}.out" 
"{{.*}}amdgpu-openmp-toolchain-{{.*}}-gfx906-{{.*}}.o"
@@ -25,18 +26,29 @@
 // CHECK-PHASES: 6: preprocessor, {5}, cpp-output, (device-openmp)
 // CHECK-PHASES: 7: compiler, {6}, ir, (device-openmp)
 // CHECK-PHASES: 8: offload, "host-openmp (x86_64-unknown-linux-gnu)" {2}, 
"device-openmp (amdgcn-amd-amdhsa)" {7}, ir
-// CHECK-PHASES: 9: backend, {8}, assembler, (device-openmp)
-// CHECK-PHASES: 10: assembler, {9}, object, (device-openmp)
-// CHECK-PHASES: 11: linker, {10}, image, (device-openmp)
-// CHECK-PHASES: 12: offload, "device-openmp (amdgcn-amd-amdhsa)" {11}, image
-// CHECK-PHASES: 13: clang-offload-wrapper, {12}, ir, (host-openmp)
-// CHECK-PHASES: 14: backend, {13}, assembler, (host-openmp)
-// CHECK-PHASES: 15: assembler, {14}, object, (host-openmp)
-// CHECK-PHASES: 16: linker, {4, 15}, image, (host-openmp)
+// CHECK-PHASES: 9: linker, {8}, image, (device-openmp)
+// CHECK-PHASES: 10: offload, "device-openmp (amdgcn-amd-amdhsa)" {9}, image
+// CHECK-PHASES: 11: clang-offload-wrapper, {10}, ir, (host-openmp)
+// CHECK-PHASES: 12: backend, {11}, assembler, (host-openmp)
+// CHECK-PHASES: 13: assembler, {12}, object, (host-openmp)
+// CHECK-PHASES: 14: linker, {4, 13}, image, (host-openmp)
 
 // handling of --libomptarget-amdgcn-bc-path
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx803 
--libomptarget-amdgcn-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc
 %s 2>&1 | FileCheck %s --check-prefix=CHECK-LIBOMPTARGET
-// CHECK-LIBOMPTARGET: clang{{.*}}"-cc1"{{.*}}"-triple" 
"amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" 
"-emit-llvm-bc" 
"-mlink-builtin-bitcode"{{.*}}Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc"{{.*}}
+// CHECK-LIBOMPTARGET: clang{{.*}}"-cc1"{{.*}}"-triple" 
"amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" 
"-mlink-builtin-bitcode"{{.*}}Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc"{{.*}}
 
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx803 -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-NOGPULIB
-// CHECK-NOGPULIB-NOT: clang{{.*}}"-cc1"{{.*}}"-triple" 
"amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" 
"-emit-llvm-bc" 
"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx803.bc"{{.*}}
+// CHECK-NOGPULIB-NOT: clang{{.*}}"-cc1"{{.*}}"-triple" 
"amdgcn-amd-amdhsa"{{.*}}"-target-cpu" "gfx803" "-fcuda-is-device" 
"-mlink-builtin-bitcode"{{.*}}libomptarget-amdgcn-gfx803.bc"{{.*}}
+
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings 
-save-temps -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa 
-Xopenmp-target=amdgcn-amd-amdhsa -march=gfx803 -

[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-16 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:3057
+  for (unsigned I = 0; I < ToolChains.size(); ++I) {
+Action *&A = OpenMPDeviceActions[I];
+// AMDGPU does not support linking of object files, so we skip

This logic is based on the assumption that the ith item in OpenMPDeviceActions 
corresponds to ith item in ToolChains array. Size of both lists is guaranteed 
to be same from assert on #3035.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[clang] 13f4448 - [analyzer] Rework SValBuilder::evalCast function into maintainable and clear way

2021-02-16 Thread Denys Petrov via cfe-commits

Author: Denys Petrov
Date: 2021-02-16T14:30:51+02:00
New Revision: 13f4448ae7db1a477ec2d48776e46415a3401314

URL: 
https://github.com/llvm/llvm-project/commit/13f4448ae7db1a477ec2d48776e46415a3401314
DIFF: 
https://github.com/llvm/llvm-project/commit/13f4448ae7db1a477ec2d48776e46415a3401314.diff

LOG: [analyzer] Rework SValBuilder::evalCast function into maintainable and 
clear way

Summary: Refactor SValBuilder::evalCast function. Make the function clear and 
get rid of redundant and repetitive code. Unite SValBuilder::evalCast, 
SimpleSValBuilder::dispatchCast, SimpleSValBuilder::evalCastFromNonLoc and 
SimpleSValBuilder::evalCastFromLoc functions into single SValBuilder::evalCast.
This patch shall not change any previous behavior.

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
index 4ea85f9730bb..2358d2d66b30 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
@@ -75,6 +75,28 @@ class SValBuilder {
   virtual SVal evalCastFromNonLoc(NonLoc val, QualType castTy) = 0;
   virtual SVal evalCastFromLoc(Loc val, QualType castTy) = 0;
 
+  SVal evalCastKind(UndefinedVal V, QualType CastTy, QualType OriginalTy);
+  SVal evalCastKind(UnknownVal V, QualType CastTy, QualType OriginalTy);
+  SVal evalCastKind(Loc V, QualType CastTy, QualType OriginalTy);
+  SVal evalCastKind(NonLoc V, QualType CastTy, QualType OriginalTy);
+  SVal evalCastSubKind(loc::ConcreteInt V, QualType CastTy,
+   QualType OriginalTy);
+  SVal evalCastSubKind(loc::GotoLabel V, QualType CastTy, QualType OriginalTy);
+  SVal evalCastSubKind(loc::MemRegionVal V, QualType CastTy,
+   QualType OriginalTy);
+  SVal evalCastSubKind(nonloc::CompoundVal V, QualType CastTy,
+   QualType OriginalTy);
+  SVal evalCastSubKind(nonloc::ConcreteInt V, QualType CastTy,
+   QualType OriginalTy);
+  SVal evalCastSubKind(nonloc::LazyCompoundVal V, QualType CastTy,
+   QualType OriginalTy);
+  SVal evalCastSubKind(nonloc::LocAsInteger V, QualType CastTy,
+   QualType OriginalTy);
+  SVal evalCastSubKind(nonloc::SymbolVal V, QualType CastTy,
+   QualType OriginalTy);
+  SVal evalCastSubKind(nonloc::PointerToMember V, QualType CastTy,
+   QualType OriginalTy);
+
 public:
   // FIXME: Make these protected again once RegionStoreManager correctly
   // handles loads from 
diff erent bound value types.
@@ -102,7 +124,7 @@ class SValBuilder {
  Ty2->isIntegralOrEnumerationType()));
   }
 
-  SVal evalCast(SVal val, QualType castTy, QualType originalType);
+  SVal evalCast(SVal V, QualType CastTy, QualType OriginalTy);
 
   // Handles casts of type CK_IntegralCast.
   SVal evalIntegralCast(ProgramStateRef state, SVal val, QualType castTy,

diff  --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp 
b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
index 72b8ada1dfab..4b146d83c194 100644
--- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -530,108 +530,197 @@ SVal SValBuilder::evalIntegralCast(ProgramStateRef 
state, SVal val,
   return evalCast(val, castTy, originalTy);
 }
 
-// FIXME: should rewrite according to the cast kind.
-SVal SValBuilder::evalCast(SVal val, QualType castTy, QualType originalTy) {
-  castTy = Context.getCanonicalType(castTy);
-  originalTy = Context.getCanonicalType(originalTy);
-  if (val.isUnknownOrUndef() || castTy == originalTy)
-return val;
+//===--===//
+// Cast methods.
+// `evalCast` is the main method
+// `evalCastKind` and `evalCastSubKind` are helpers
+//===--===//
 
-  if (castTy->isBooleanType()) {
-if (val.isUnknownOrUndef())
-  return val;
-if (val.isConstant())
-  return makeTruthVal(!val.isZeroConstant(), castTy);
-if (!Loc::isLocType(originalTy) &&
-!originalTy->isIntegralOrEnumerationType() &&
-!originalTy->isMemberPointerType())
-  return UnknownVal();
-if (SymbolRef Sym = val.getAsSymbol(true)) {
-  BasicValueFactory &BVF = getBasicValueFactory();
-  // FIXME: If we had a state here, we could see if the symbol is known to
-  // be zero, but we don't.
-  return makeNonLoc(Sym, BO_NE, BVF.getValue(0, Sym->getType()), castTy);
-}
-// Loc values are not always true, they could be weakly linked functio

[PATCH] D90157: [analyzer] Rework SValBuilder::evalCast function into maintainable and clear way

2021-02-16 Thread Denys Petrov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG13f4448ae7db: [analyzer] Rework SValBuilder::evalCast 
function into maintainable and clear way (authored by ASDenysPetrov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90157

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
  clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

Index: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -530,108 +530,197 @@
   return evalCast(val, castTy, originalTy);
 }
 
-// FIXME: should rewrite according to the cast kind.
-SVal SValBuilder::evalCast(SVal val, QualType castTy, QualType originalTy) {
-  castTy = Context.getCanonicalType(castTy);
-  originalTy = Context.getCanonicalType(originalTy);
-  if (val.isUnknownOrUndef() || castTy == originalTy)
-return val;
+//===--===//
+// Cast methods.
+// `evalCast` is the main method
+// `evalCastKind` and `evalCastSubKind` are helpers
+//===--===//
 
-  if (castTy->isBooleanType()) {
-if (val.isUnknownOrUndef())
-  return val;
-if (val.isConstant())
-  return makeTruthVal(!val.isZeroConstant(), castTy);
-if (!Loc::isLocType(originalTy) &&
-!originalTy->isIntegralOrEnumerationType() &&
-!originalTy->isMemberPointerType())
-  return UnknownVal();
-if (SymbolRef Sym = val.getAsSymbol(true)) {
-  BasicValueFactory &BVF = getBasicValueFactory();
-  // FIXME: If we had a state here, we could see if the symbol is known to
-  // be zero, but we don't.
-  return makeNonLoc(Sym, BO_NE, BVF.getValue(0, Sym->getType()), castTy);
-}
-// Loc values are not always true, they could be weakly linked functions.
-if (Optional L = val.getAs())
-  return evalCastFromLoc(*L, castTy);
+SVal SValBuilder::evalCast(SVal V, QualType CastTy, QualType OriginalTy) {
+  CastTy = Context.getCanonicalType(CastTy);
+  OriginalTy = Context.getCanonicalType(OriginalTy);
+  if (CastTy == OriginalTy)
+return V;
 
-Loc L = val.castAs().getLoc();
-return evalCastFromLoc(L, castTy);
+  // FIXME: Move this check to the most appropriate evalCastKind/evalCastSubKind
+  // function.
+  // For const casts, casts to void, just propagate the value.
+  if (!CastTy->isVariableArrayType() && !OriginalTy->isVariableArrayType())
+if (shouldBeModeledWithNoOp(Context, Context.getPointerType(CastTy),
+Context.getPointerType(OriginalTy)))
+  return V;
+
+  // Cast SVal according to kinds.
+  switch (V.getBaseKind()) {
+  case SVal::UndefinedValKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  case SVal::UnknownValKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  case SVal::LocKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  case SVal::NonLocKind:
+return evalCastKind(V.castAs(), CastTy, OriginalTy);
+  default:
+llvm_unreachable("Unknown SVal kind");
   }
+}
 
-  // For const casts, casts to void, just propagate the value.
-  if (!castTy->isVariableArrayType() && !originalTy->isVariableArrayType())
-if (shouldBeModeledWithNoOp(Context, Context.getPointerType(castTy),
- Context.getPointerType(originalTy)))
-  return val;
+SVal SValBuilder::evalCastKind(UndefinedVal V, QualType CastTy,
+   QualType OriginalTy) {
+  return V;
+}
 
-  // Check for casts from pointers to integers.
-  if (castTy->isIntegralOrEnumerationType() && Loc::isLocType(originalTy))
-return evalCastFromLoc(val.castAs(), castTy);
-
-  // Check for casts from integers to pointers.
-  if (Loc::isLocType(castTy) && originalTy->isIntegralOrEnumerationType()) {
-if (Optional LV = val.getAs()) {
-  if (const MemRegion *R = LV->getLoc().getAsRegion()) {
-StoreManager &storeMgr = StateMgr.getStoreManager();
-R = storeMgr.castRegion(R, castTy);
-return R ? SVal(loc::MemRegionVal(R)) : UnknownVal();
-  }
-  return LV->getLoc();
-}
-return dispatchCast(val, castTy);
+SVal SValBuilder::evalCastKind(UnknownVal V, QualType CastTy,
+   QualType OriginalTy) {
+  return V;
+}
+
+SVal SValBuilder::evalCastKind(Loc V, QualType CastTy, QualType OriginalTy) {
+  switch (V.getSubKind()) {
+  case loc::ConcreteIntKind:
+return evalCastSubKind(V.castAs(), CastTy, OriginalTy);
+  case loc::GotoLabelKind:
+return evalCastSubKind(V.castAs(), CastTy, OriginalTy);
+  case loc::MemRegionValKind:
+return evalCastSubKind(V.castAs(), CastTy, OriginalTy);
+  default:
+llvm_unreachable("Unknown S

[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Change looks reasonable. Does this fix save-temps as intended?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D96725: [clang-tidy] Fix modernize-use-using in extern C code

2021-02-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp:305
 };
+
+extern "C" {

steveire wrote:
> njames93 wrote:
> > steveire wrote:
> > > Can you add tests for typedefs in other scopes like
> > > 
> > > ```
> > > 
> > > extern "C" {
> > > typedef int CType;
> > > 
> > > struct CAnother {
> > > };
> > > 
> > > typedef struct {
> > >   int b;
> > >   typedef struct CAnother AStruct;
> > > } CStruct;
> > > 
> > > void foo()
> > > {
> > >   typedef struct CAnother AStruct;
> > > }
> > > }
> > > 
> > > ```
> > I'm not sure those tests add any value. For the struct, you can't have a 
> > typedef in a struct in c. The function typedef is valid in c, but I still 
> > can't see a reason to use extern C when defining a function in c++
> Fair enough - Clang accepts the typedef in the struct with a warning, but it 
> doesn't get transformed by the check anyway. The one in the function doesn't 
> get transformed either, and if functions are so unlikely to appear in extern 
> C, that it doesn't need to be covered, that's fine with me.
> I still can't see a reason to use extern C when defining a function in c++

There are a few reasons.

1) You're defining an extern linkage function with C language linkage and not 
providing the declaration or you're being consistent between the declaration 
and the definition.

2) You have an `extern "C"` block that contains function definitions.

3) Pedantically, if the function declaration is `extern "C"`, the function 
definition must be as well (http://eel.is/c++draft/dcl.link#1.sentence-5, 
http://eel.is/c++draft/dcl.link#6), however, many compilers ignore these 
requirements because otherwise the STL has issues.

So it definitely does happen in the wild. As some examples:

https://codesearch.isocpp.org/actcd19/main/b/bali-phy/bali-phy_3.4+dfsg-1/src/builtins/SModel.cc
https://codesearch.isocpp.org/actcd19/main/o/openjdk-11/openjdk-11_11.0.3+1-1/test/hotspot/jtreg/vmTestbase/nsk/jvmti/AttachOnDemand/attach015/attach015Agent00.c
https://codesearch.isocpp.org/actcd19/main/m/mp3fs/mp3fs_0.91-1/src/transcode.cc
https://codesearch.isocpp.org/actcd19/main/t/theano/theano_0.8.2-6/theano/sandbox/cuda/cnmem.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96725

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


[PATCH] D96051: [OpenCL] Support enum and typedef args in TableGen BIFs

2021-02-16 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!




Comment at: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl:27
+  // expected-error@-3 0+{{no matching function for call to 'barrier'}}
+  // expected-error@* {{typedef type cl_mem_fence_flags not found; include the 
base header with -finclude-default-header}}
+}

svenvh wrote:
> Anastasia wrote:
> > Actually, could we remove the `typedef` from the diagnostic because it 
> > exposes the implementation details unnecessarily? I believe the spec 
> > doesn't say what the type is aside from enums?  As a matter of fact, we 
> > have some types implemented as typedefs that should have been a native 
> > types e.g. vector types that we might change one day.
> I agree it's an implementation detail, but I can see reasons for keeping it: 
> when there is an enum type with the same name available in the translation 
> unit, then the message "type X not found" is not completely correct, because 
> a type X exists, but it is of the wrong type. By prefixing "enum" or 
> "typedef", the diagnostic is more accurate.  This diagnostic is mainly 
> targeted at Clang developers actually, because a user shouldn't see this 
> diagnostic in any normal use case (with the driver setting both 
> -fdeclare-opencl-builtins and -finclude-default-header).
Ah, I see.  Since the diagnostics are not going to be exposed during normal 
compilation it is less critical indeed... I guess the only issue is when we 
update the type implementation we might need more tests to change.


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

https://reviews.llvm.org/D96051

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


[PATCH] D95409: [clang] implicitly delete space ship operator with function pointers

2021-02-16 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

Ping.

By the way I realize I may not have put the new tests in the appropriate place. 
Any guidance there welcome.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95409

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


[PATCH] D96771: [OpenCL] Add distinct file extension for C++ for OpenCL

2021-02-16 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: svenvh, mantognini.
Herald added subscribers: dexonsmith, ebevhan, yaxunl.
Herald added a reviewer: jansvoboda11.
Anastasia requested review of this revision.

Files compiled with C++ for OpenCL can have a distinct file extension - 
`clcpp`, then clang driver will pick the compilation mode automatically without 
the use of `-cl-std=clc++`


https://reviews.llvm.org/D96771

Files:
  clang/include/clang/Basic/LangStandard.h
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Types.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/test/Driver/cxx_for_opencl.clcpp
  clang/test/Driver/lit.local.cfg
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -26,7 +26,7 @@
 
 # suffixes: A list of file extensions to treat as test files.
 config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu',
-   '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs']
+   '.ll', '.cl', '.clcpp', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent
Index: clang/test/Driver/lit.local.cfg
===
--- clang/test/Driver/lit.local.cfg
+++ clang/test/Driver/lit.local.cfg
@@ -1,5 +1,5 @@
 config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', '.F90', '.f95',
-   '.cu', '.rs', '.cl', '.hip']
+   '.cu', '.rs', '.cl', '.clcpp', '.hip']
 config.substitutions = list(config.substitutions)
 config.substitutions.insert(0,
 ('%clang_cc1',
Index: clang/test/Driver/cxx_for_opencl.clcpp
===
--- /dev/null
+++ clang/test/Driver/cxx_for_opencl.clcpp
@@ -0,0 +1,14 @@
+// RUN: %clang %s -Xclang -verify -fsyntax-only
+// RUN: %clang %s -cl-std=cl2.0 -Xclang -verify -fsyntax-only
+
+#ifdef __OPENCL_CPP_VERSION__
+//expected-no-diagnostics
+#endif
+
+kernel void k(){
+  auto a = get_local_id(1);
+#ifndef __OPENCL_CPP_VERSION__
+//expected-error@-2{{OpenCL C version 2.0 does not support the 'auto' storage class specifier}}
+//expected-warning@-3{{type specifier missing, defaults to 'int'}}
+#endif
+}
Index: clang/lib/Frontend/FrontendActions.cpp
===
--- clang/lib/Frontend/FrontendActions.cpp
+++ clang/lib/Frontend/FrontendActions.cpp
@@ -862,6 +862,7 @@
   case Language::ObjC:
   case Language::ObjCXX:
   case Language::OpenCL:
+  case Language::OpenCLCXX:
   case Language::CUDA:
   case Language::HIP:
 break;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -511,7 +511,9 @@
 static unsigned getOptimizationLevel(ArgList &Args, InputKind IK,
  DiagnosticsEngine &Diags) {
   unsigned DefaultOpt = llvm::CodeGenOpt::None;
-  if (IK.getLanguage() == Language::OpenCL && !Args.hasArg(OPT_cl_opt_disable))
+  if ((IK.getLanguage() == Language::OpenCL ||
+   IK.getLanguage() == Language::OpenCLCXX) &&
+  !Args.hasArg(OPT_cl_opt_disable))
 DefaultOpt = llvm::CodeGenOpt::Default;
 
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
@@ -2355,6 +2357,7 @@
 DashX = llvm::StringSwitch(XValue)
 .Case("c", Language::C)
 .Case("cl", Language::OpenCL)
+.Case("clcpp", Language::OpenCLCXX)
 .Case("cuda", Language::CUDA)
 .Case("hip", Language::HIP)
 .Case("c++", Language::CXX)
@@ -2743,6 +2746,9 @@
 case Language::OpenCL:
   LangStd = LangStandard::lang_opencl10;
   break;
+case Language::OpenCLCXX:
+  LangStd = LangStandard::lang_openclcpp;
+  break;
 case Language::CUDA:
   LangStd = LangStandard::lang_cuda;
   break;
@@ -2878,7 +2884,11 @@
 return S.getLanguage() == Language::C;
 
   case Language::OpenCL:
-return S.getLanguage() == Language::OpenCL;
+return S.getLanguage() == Language::OpenCL ||
+   S.getLanguage() == Language::OpenCLCXX;
+
+  case Language::OpenCLCXX:
+return S.getLanguage() == Language::OpenCLCXX;
 
   case Language::CXX:
   case Language::ObjCXX:
@@ -2915,6 +2925,8 @@
 return "Objective-C++";
   case Language::OpenCL:
 return "OpenCL";
+  case Language::OpenCLCXX:
+return "C++ for OpenCL";
   case Language::CUDA:
 return "CUDA";
   case Language::RenderScript:
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/

[PATCH] D96281: [clang-tidy] Add options to flag individual core increments and to ignore macros to readability-function-cognitive-complexity check.

2021-02-16 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 323962.
massberg added a comment.

Change option name, improve description and minor fixes.

- Change name FlagBasicIncrements to DescribeBasicIncrements.
- Improve description of this option and added an example.
- Minor code fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

Files:
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.cpp
  clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-function-cognitive-complexity-flags.cpp
@@ -0,0 +1,94 @@
+// RUN: %check_clang_tidy %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=THRESHOLD5 %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 5}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
+// RUN: %check_clang_tidy -check-suffix=IGNORE-MACROS %s readability-function-cognitive-complexity %t -- \
+// RUN:   -config='{CheckOptions: \
+// RUN: [{key: readability-function-cognitive-complexity.Threshold, \
+// RUN:   value: 0}, \
+// RUN:  {key: readability-function-cognitive-complexity.IgnoreMacros, \
+// RUN:   value: "true"}, \
+// RUN:  {key: readability-function-cognitive-complexity.DescribeBasicIncrements, \
+// RUN:   value: "false"} ]}'
+
+void func_of_complexity_4() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_of_complexity_4' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  if (1) {
+if (1) {
+}
+  }
+  if (1) {
+  }
+}
+
+#define MacroOfComplexity10 \
+  if (1) {  \
+if (1) {\
+  if (1) {  \
+if (1) {\
+}   \
+  } \
+}   \
+  }
+
+void function_with_macro() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-THRESHOLD5: :[[@LINE-2]]:6: warning: function 'function_with_macro' has cognitive complexity of 11 (threshold 5) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-3]]:6: warning: function 'function_with_macro' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+
+  MacroOfComplexity10
+
+  if (1) {
+  }
+}
+
+#define uglyfunctionmacro(name) \
+  void name() { \
+if (true) { \
+  try { \
+  } catch (...) {   \
+  } \
+}   \
+  }
+
+uglyfunctionmacro(MacroFunction)
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: function 'MacroFunction' has cognitive complexity of 3 (threshold 0) [readability-function-cognitive-complexity]
+
+#define noop
+
+#define SomeMacro(x) \
+  if (1) {   \
+x\
+  }
+
+void func_macro_1() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_macro_1' has cognitive complexity of 2 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_macro_1' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+
+  if (1) {
+  }
+  SomeMacro(noop;)
+}
+
+void func_macro_2() {
+  // CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'func_macro_2' has cognitive complexity of 4 (threshold 0) [readability-function-cognitive-complexity]
+  // CHECK-NOTES-IGNORE-MACROS: :[[@LINE-2]]:6: warning: function 'func_macro_2' has cognitive complexity of 1 (threshold 0) [readability-function-cognitive-complexity]
+
+  if (1) {
+  }
+  // Note that if the IgnoreMa

[PATCH] D86119: [OPENMP50]Allow overlapping mapping in target constrcuts.

2021-02-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked 2 inline comments as done.
ABataev added a comment.

In D86119#2562187 , @grokos wrote:

> In D86119#2561163 , @abhinavgaba 
> wrote:
>
>> Thanks for the changes, Alexey! I tried the patch locally, and it looks 
>> stable. It handled several tests I tried, including the following case 
>> involving array section on a pointer to pointer base, and nested mappers 
>> with `PTR_AND_OBJ` maps successfully:
>>
>>   #include 
>>   
>>   typedef struct { int a; double *b; } C;
>>   #pragma omp declare mapper(id1: C s) map(to:s.a) map(from:s.b[0:2])
>>   
>>   typedef struct { int e; C f; int h; short *g; } D;
>>   #pragma omp declare mapper(default: D r) map(from:r.e) map(mapper(id1), 
>> tofrom:r.f) map(tofrom: r.g[0:r.h])
>>   
>>   int main() {
>> constexpr int N = 10;
>> D s;
>> s.e = 111;
>> s.f.a = 222;
>> double x[2]; x[1] = 20;
>> short y[N]; y[1] = 30;
>> s.f.b = &x[0];
>> s.g = &y[0];
>> s.h = N;
>>   
>> D* sp = &s;
>> D** spp = &sp;
>>   
>> printf("%d %d %lf %p %d %p\n", spp[0][0].e, spp[0][0].f.a, 
>> spp[0][0].f.b[1], spp[0][0].f.b, spp[0][0].g[1], spp[0][0].g);
>> // Expected: 111 222 20.0  30 
>>   
>> #pragma omp target map(tofrom:spp[0][0])
>> {
>>   printf("%d %d %lf %p %d %p\n", spp[0][0].e, spp[0][0].f.a, 
>> spp[0][0].f.b[1], spp[0][0].f.b, spp[0][0].g[1], spp[0][0].g);
>>   // Expected:  222   30 
>>   spp[0][0].e = 333;
>>   spp[0][0].f.a = 444;
>>   spp[0][0].f.b[1] = 40;
>>   spp[0][0].g[1] = 50;
>> }
>> printf("%d %d %lf %p %d %p\n", spp[0][0].e, spp[0][0].f.a, 
>> spp[0][0].f.b[1], spp[0][0].f.b, spp[0][0].g[1], spp[0][0].g);
>> // Expected: 333 222 40.0  50 
>>   }
>
> @ABataev This is a nice complex example, I think it's worth including it in 
> the runtime tests (under libomptarget).
>
> @abhinavgaba Thanks for providing it!

Ok, will add it as a part of the patch




Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:8483-8484
+  for (const auto &M : Data.second) {
+for (const MapInfo &L : M) {
+  assert(!L.Components.empty() &&
+ "Not expecting declaration with no component lists.");

abhinavgaba wrote:
> Tabs should probably be spaces. Same for a few other places in the changeset.
These are not tabs. Looks like this is how Phabricators shows some format 
changes.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9726
 llvm::Value *OriMapType = MapperCGF.Builder.getInt64(Info.Types[I]);
-llvm::Value *Member = MapperCGF.Builder.CreateAnd(
-OriMapType,
-MapperCGF.Builder.getInt64(MappableExprsHandler::OMP_MAP_MEMBER_OF));
-llvm::BasicBlock *MemberCombineBB =
-MapperCGF.createBasicBlock("omp.member.combine");
-llvm::BasicBlock *TypeBB = MapperCGF.createBasicBlock("omp.type");
-llvm::Value *IsMember = MapperCGF.Builder.CreateIsNull(Member);
-MapperCGF.Builder.CreateCondBr(IsMember, TypeBB, MemberCombineBB);
-// Add the number of pre-existing components to the MEMBER_OF field if it
-// is valid.
-MapperCGF.EmitBlock(MemberCombineBB);
-llvm::Value *CombinedMember =
-MapperCGF.Builder.CreateNUWAdd(OriMapType, ShiftedPreviousSize);
+// llvm::Value *Member = MapperCGF.Builder.CreateAnd(
+// OriMapType,

abhinavgaba wrote:
> Commented-out code intentionally left in?
Yeah, forgot to remove it, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86119

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


[PATCH] D96281: [clang-tidy] Add options to flag individual core increments and to ignore macros to readability-function-cognitive-complexity check.

2021-02-16 Thread Jens Massberg via Phabricator via cfe-commits
massberg marked 4 inline comments as done.
massberg added a comment.

Thanks for the comments!




Comment at: 
clang-tools-extra/clang-tidy/readability/FunctionCognitiveComplexityCheck.h:24-26
+///   * `FlagBasicIncrements`- if set to `true`, additional to flagging
+//  functions exceeding the threshold also every piece of code (loops, if
+//  statements, ...) which contributes to that complexity is flagged.

alexfh wrote:
> Thanks! Now the description contains enough information, but it was hard for 
> me to understand it. I'd suggest to reword this a bit, for example: "if set 
> to `true`, then for each function exceeding the complexity threshold the 
> check will issue additional diagnostics on every piece of code (loop, `if` 
> statement, etc.) which contributes to that complexity."
> 
> As mentioned earlier, an example may help understand the purpose of this 
> option even better.
Thanks for the suggested rewording!
I took you suggestion and added a comment to the existing examples below which 
hopefully explains the option now.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability-function-cognitive-complexity.rst:20
 
+.. option:: FlagBasicIncrements
+

lebedev.ri wrote:
> `FlagBasicIncrements` is misleading, this should be `DescribeBasicIncrements`.
Thanks, I renamed it as proposed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96281

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


[clang] 3238934 - [clang][cli] Generate -f[no-]finite-loops arguments

2021-02-16 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-02-16T14:39:20+01:00
New Revision: 32389346ed83e14b7a9bd3a31a96181c6a1cdb5e

URL: 
https://github.com/llvm/llvm-project/commit/32389346ed83e14b7a9bd3a31a96181c6a1cdb5e
DIFF: 
https://github.com/llvm/llvm-project/commit/32389346ed83e14b7a9bd3a31a96181c6a1cdb5e.diff

LOG: [clang][cli] Generate -f[no-]finite-loops arguments

This patch generates the `-f[no-]finite-loops` arguments from 
`CompilerInvocation` (added in D96419), fixing test failures of Clang built 
with `-DCLANG_ROUND_TRIP_CC1_ARGS=ON`.

Reviewed By: fhahn

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGenCXX/attr-mustprogress.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index b2ee11a42f57..f92964732688 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1509,6 +1509,17 @@ void CompilerInvocation::GenerateCodeGenArgs(
 
   if (!Opts.EmitVersionIdentMetadata)
 GenerateArg(Args, OPT_Qn, SA);
+
+  switch (Opts.FiniteLoops) {
+  case CodeGenOptions::FiniteLoopsKind::Language:
+break;
+  case CodeGenOptions::FiniteLoopsKind::Always:
+GenerateArg(Args, OPT_ffinite_loops, SA);
+break;
+  case CodeGenOptions::FiniteLoopsKind::Never:
+GenerateArg(Args, OPT_fno_finite_loops, SA);
+break;
+  }
 }
 
 bool CompilerInvocation::ParseCodeGenArgsImpl(CodeGenOptions &Opts,

diff  --git a/clang/test/CodeGenCXX/attr-mustprogress.cpp 
b/clang/test/CodeGenCXX/attr-mustprogress.cpp
index 93e366b4ca7f..48ac7ad938ba 100644
--- a/clang/test/CodeGenCXX/attr-mustprogress.cpp
+++ b/clang/test/CodeGenCXX/attr-mustprogress.cpp
@@ -7,7 +7,7 @@
 // Make sure -ffinite-loops overrides -std=c++98 for loops.
 // RUN: %clang_cc1 -std=c++98 -ffinite-loops -triple=x86_64-unknown-linux-gnu 
-S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s
 
-// Make sure -fno_finite-loops overrides -std=c++11
+// Make sure -fno-finite-loops overrides -std=c++11
 // RUN: %clang_cc1 -std=c++11 -fno-finite-loops 
-triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck 
--check-prefix=CHECK --check-prefix=CXX98 %s
 
 int a = 0;



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


[PATCH] D96761: [clang][cli] Generate -f[no-]finite-loops arguments

2021-02-16 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32389346ed83: [clang][cli] Generate -f[no-]finite-loops 
arguments (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96761

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/attr-mustprogress.cpp


Index: clang/test/CodeGenCXX/attr-mustprogress.cpp
===
--- clang/test/CodeGenCXX/attr-mustprogress.cpp
+++ clang/test/CodeGenCXX/attr-mustprogress.cpp
@@ -7,7 +7,7 @@
 // Make sure -ffinite-loops overrides -std=c++98 for loops.
 // RUN: %clang_cc1 -std=c++98 -ffinite-loops -triple=x86_64-unknown-linux-gnu 
-S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s
 
-// Make sure -fno_finite-loops overrides -std=c++11
+// Make sure -fno-finite-loops overrides -std=c++11
 // RUN: %clang_cc1 -std=c++11 -fno-finite-loops 
-triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck 
--check-prefix=CHECK --check-prefix=CXX98 %s
 
 int a = 0;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1509,6 +1509,17 @@
 
   if (!Opts.EmitVersionIdentMetadata)
 GenerateArg(Args, OPT_Qn, SA);
+
+  switch (Opts.FiniteLoops) {
+  case CodeGenOptions::FiniteLoopsKind::Language:
+break;
+  case CodeGenOptions::FiniteLoopsKind::Always:
+GenerateArg(Args, OPT_ffinite_loops, SA);
+break;
+  case CodeGenOptions::FiniteLoopsKind::Never:
+GenerateArg(Args, OPT_fno_finite_loops, SA);
+break;
+  }
 }
 
 bool CompilerInvocation::ParseCodeGenArgsImpl(CodeGenOptions &Opts,


Index: clang/test/CodeGenCXX/attr-mustprogress.cpp
===
--- clang/test/CodeGenCXX/attr-mustprogress.cpp
+++ clang/test/CodeGenCXX/attr-mustprogress.cpp
@@ -7,7 +7,7 @@
 // Make sure -ffinite-loops overrides -std=c++98 for loops.
 // RUN: %clang_cc1 -std=c++98 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s
 
-// Make sure -fno_finite-loops overrides -std=c++11
+// Make sure -fno-finite-loops overrides -std=c++11
 // RUN: %clang_cc1 -std=c++11 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX98 %s
 
 int a = 0;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1509,6 +1509,17 @@
 
   if (!Opts.EmitVersionIdentMetadata)
 GenerateArg(Args, OPT_Qn, SA);
+
+  switch (Opts.FiniteLoops) {
+  case CodeGenOptions::FiniteLoopsKind::Language:
+break;
+  case CodeGenOptions::FiniteLoopsKind::Always:
+GenerateArg(Args, OPT_ffinite_loops, SA);
+break;
+  case CodeGenOptions::FiniteLoopsKind::Never:
+GenerateArg(Args, OPT_fno_finite_loops, SA);
+break;
+  }
 }
 
 bool CompilerInvocation::ParseCodeGenArgsImpl(CodeGenOptions &Opts,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96777: [clang][driver] Set the input type to Fortran when reading from stdin

2021-02-16 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski created this revision.
Herald added subscribers: usaxena95, kadircet.
Herald added a reviewer: sscalpone.
awarzynski requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.

This patch makes sure that for the following invocation of the new Flang
driver, clangDriver sets the input type to Fortran:

  flang-new -E -

This change does not affect `clang`, i.e. for the following invocation
the input type is set to C:

  clang -E -

This change leverages the fact that for `flang-new` the driver is in
Flang mode.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96777

Files:
  clang/lib/Driver/Driver.cpp
  flang/test/Flang-Driver/input-from-stdin.f90


Index: flang/test/Flang-Driver/input-from-stdin.f90
===
--- flang/test/Flang-Driver/input-from-stdin.f90
+++ flang/test/Flang-Driver/input-from-stdin.f90
@@ -5,19 +5,22 @@
 !--
 ! FLANG DRIVER (flang-new)
 !--
-! TODO: Add support for `flang-new -`
-! Currently `bin/flang-new  -E -` defaults to `-x c` and e.g. F90 is not 
allowed
-! in `-x ` (see `clang::driver::types::canTypeBeUserSpecified` in
-! Types.cpp)
+! Input type is implicit
+! RUN: cat %s | flang-new -E - | FileCheck %s --check-prefix=PP-NOT-DEFINED
+! RUN: cat %s | flang-new -DNEW -E - | FileCheck %s --check-prefix=PP-DEFINED
+
+! Input type is explicit
+! RUN: cat %s | flang-new -E -x f95-cpp-input - | FileCheck %s 
--check-prefix=PP-NOT-DEFINED
+! RUN: cat %s | flang-new -DNEW -E -x f95-cpp-input - | FileCheck %s 
--check-prefix=PP-DEFINED
 
 !---
 ! FLANG FRONTEND DRIVER (flang-new -fc1)
 !---
-! Test `-E` - for the corresponding frontend actions the driver relies on the 
prescanner API to handle file I/O
+! Test `-E`: for the corresponding frontend actions the driver relies on the 
prescanner API to handle file I/O
 ! RUN: cat %s | flang-new -fc1 -E | FileCheck %s --check-prefix=PP-NOT-DEFINED
 ! RUN: cat %s | flang-new -fc1 -DNEW -E | FileCheck %s 
--check-prefix=PP-DEFINED
 
-! Test `-test-io` - for the corresponding frontend action 
(`InputOutputTestAction`) the driver handles the file I/O on its own
+! Test `-test-io`: for the corresponding frontend action 
(`InputOutputTestAction`) the driver handles the file I/O on its own
 ! the corresponding action (`PrintPreprocessedAction`)
 ! RUN: cat %s | flang-new -fc1 -test-io | FileCheck %s --check-prefix=IO 
--match-full-lines
 ! RUN: cat %s | flang-new -fc1 -DNEW -test-io | FileCheck %s --check-prefix=IO 
--match-full-lines
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2192,15 +2192,20 @@
 
 // stdin must be handled specially.
 if (memcmp(Value, "-", 2) == 0) {
-  // If running with -E, treat as a C input (this changes the builtin
-  // macros, for example). This may be overridden by -ObjC below.
-  //
-  // Otherwise emit an error but still use a valid type to avoid
-  // spurious errors (e.g., no inputs).
-  if (!Args.hasArgNoClaim(options::OPT_E) && !CCCIsCPP())
-Diag(IsCLMode() ? clang::diag::err_drv_unknown_stdin_type_clang_cl
-: clang::diag::err_drv_unknown_stdin_type);
-  Ty = types::TY_C;
+  if (IsFlangMode()) {
+Ty = types::TY_Fortran;
+  } else {
+// If running with -E, treat as a C input (this changes the
+// builtin macros, for example). This may be overridden by -ObjC
+// below.
+//
+// Otherwise emit an error but still use a valid type to avoid
+// spurious errors (e.g., no inputs).
+if (!Args.hasArgNoClaim(options::OPT_E) && !CCCIsCPP())
+  Diag(IsCLMode() ? 
clang::diag::err_drv_unknown_stdin_type_clang_cl
+  : clang::diag::err_drv_unknown_stdin_type);
+Ty = types::TY_C;
+  }
 } else {
   // Otherwise lookup by extension.
   // Fallback is C if invoked as C preprocessor, C++ if invoked with


Index: flang/test/Flang-Driver/input-from-stdin.f90
===
--- flang/test/Flang-Driver/input-from-stdin.f90
+++ flang/test/Flang-Driver/input-from-stdin.f90
@@ -5,19 +5,22 @@
 !--
 ! FLANG DRIVER (flang-new)
 !--
-! TODO: Add support for `flang-new -`
-! Currently `bin/flang-new  -E -` defaults to `-x c` and e.g. F90 is not allowed
-! in `-x ` (see `clang::driver::types::canTypeBeUserSpecified` in
-! Types.cpp)
+! Input type is implicit
+! RUN: cat %s | flang-new -E - | FileCheck %s --check-prefix=PP-NOT-DEFINED
+! RUN: cat %s | flang-new -D

[PATCH] D96082: [clang-tidy] Add 'readability-useless-return-value' check

2021-02-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D96082#2561806 , @steveire wrote:

> In D96082#2550468 , @LukasHanel 
> wrote:
>
>> In D96082#2549943 , @steveire wrote:
>>
>>> In D96082#2545807 , @LukasHanel 
>>> wrote:
>>>
 Hi, thanks for discussing my proposal!

 - Usefulness of the fix-it's
>>>
>>> I agree with @njames93 that this check is dangerous. Even if you extended 
>>> it to port callExprs, that would only work in translation units which can 
>>> see the definition.
>>
>> Are you saying I should just remove the fix-its altogether?
>> Or, put them under some option that is off by default?
>
> I'm not sure this check meets the general applicability and usefulness 
> threshold to be part of clang-tidy. The warning alone isn't actionable. 
> Someone wanting to take action on the warning would have to write their own 
> clang tidy check to make the change across their codebase. Add that to the 
> false-positive issues I mentioned before.
>
> Does anyone have any other thoughts?

I agree. I'm not certain such a check could ever be generally applicable. For 
example, some functions return zero always because it's part of the API design. 
e.g.,

  struct Base {
virtual int foo() { return 0; /* Degenerate case */ }
  };
  
  struct Derived : Base {
int foo() override; // More useful implementation
  };
  
  // Or
  namespace std {
  template <>
  class numeric_limits {
  public:
...
static constexpr MyAwesomeType lowest() noexcept { return 0; /* implicit 
conversion to the return type */ }
...
  };

Also, there's nothing particularly interesting about `0` as opposed to any 
other constant return value.

A somewhat similar check that would be interesting is a function that returns 
the same value on all control paths, as that may signify a logical error on the 
part of the programmer. e.g.,

  int foo() {
if (whatever)
  return 0;
   ... code without return statements ...
return 0;
  }
  
  // Or
  int bar() {
if (whatever)
  return foo();
else
  ...
...
return foo();
  }

but I'd want this check to ignore functions that only have a single `return` 
statement in them in order to reduce noise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96082

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


[PATCH] D88220: [C++20] P1825R0: More implicit moves

2021-02-16 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88220

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-16 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D95246#2564137 , @ASDenysPetrov 
wrote:

> This patch causes fails in a bunch of test files. When I roll it back, it 
> passes.
> Below you can see fail output of `ubsan-blacklist-vfs.c` and 
> `basic-block-sections.c`.
> F15539561: fail_output.txt 
>
> Please, pay attention to this. 
> I'm using build on Win10 + GCC config.
>
> P.S. The similar trouble is in D95808 . I've 
> commented there as well.

Hi Denys, thanks for bringing this to my attention, I'll look into this 
failure. I do know that the CI test for this patch and the other patch ran on 
Windows and did not report any errors. 
https://buildkite.com/llvm-project/premerge-checks/builds/23727#63570ad0-0e74-4825-b1dc-8f53a4d4dad0
Do you know what is different between your environments which is causing the 
spelling to be capitalized? This might help me determine how to fix the current 
host platform check in llvm/utils/lit/lit/llvm/config.py.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-16 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D95246#2565351 , 
@abhina.sreeskantharajan wrote:

> Do you know what is different between your environments which is causing the 
> spelling to be capitalized? This might help me determine how to fix the 
> current host platform check in llvm/utils/lit/lit/llvm/config.py.

Could it be something to do with a different standard library being used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[clang] ed86328 - [clang][cli] Add explicit round-trip test

2021-02-16 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-02-16T14:56:26+01:00
New Revision: ed86328515888b762277a118773b2f41b106d016

URL: 
https://github.com/llvm/llvm-project/commit/ed86328515888b762277a118773b2f41b106d016
DIFF: 
https://github.com/llvm/llvm-project/commit/ed86328515888b762277a118773b2f41b106d016.diff

LOG: [clang][cli] Add explicit round-trip test

This patch adds a test that verifies all `CompilerInvocation` members are 
filled correctly during command line round-trip.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/unittests/Frontend/CompilerInvocationTest.cpp

Removed: 




diff  --git a/clang/unittests/Frontend/CompilerInvocationTest.cpp 
b/clang/unittests/Frontend/CompilerInvocationTest.cpp
index 268f0d0dca45..b7f9cedc9cb3 100644
--- a/clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ b/clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -7,8 +7,10 @@
 
//===--===//
 
 #include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Basic/TargetOptions.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticBuffer.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/Support/Host.h"
 
 #include "gmock/gmock.h"
@@ -740,4 +742,85 @@ TEST_F(CommandLineTest, DigraphsEnabled) {
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fdigraphs")));
 }
+
+TEST_F(CommandLineTest, RoundTrip) {
+  // Testing one marshalled and one manually generated option from each
+  // CompilerInvocation member.
+  const char *Args[] = {
+  "-round-trip-args",
+  // LanguageOptions
+  "-std=c17",
+  "-fmax-tokens=10",
+  // TargetOptions
+  "-target-sdk-version=1.2.3",
+  "-meabi",
+  "4",
+  // DiagnosticOptions
+  "-Wundef-prefix=XY",
+  "-fdiagnostics-format",
+  "clang",
+  // HeaderSearchOptions
+  "-stdlib=libc++",
+  "-fimplicit-module-maps",
+  // PreprocessorOptions
+  "-DXY=AB",
+  "-include-pch",
+  "a.pch",
+  // AnalyzerOptions
+  "-analyzer-config",
+  "ctu-import-threshold=42",
+  "-unoptimized-cfg",
+  // MigratorOptions (no manually handled arguments)
+  "-no-ns-alloc-error",
+  // CodeGenOptions
+  "-debug-info-kind=limited",
+  "-debug-info-macro",
+  // DependencyOutputOptions
+  "--show-includes",
+  "-H",
+  // FileSystemOptions (no manually handled arguments)
+  "-working-directory",
+  "folder",
+  // FrontendOptions
+  "-load",
+  "plugin",
+  "-ast-merge",
+  // PreprocessorOutputOptions
+  "-dD",
+  "-CC",
+  };
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+
+  ASSERT_TRUE(Invocation.getLangOpts()->C17);
+  ASSERT_EQ(Invocation.getLangOpts()->MaxTokens, 10u);
+
+  ASSERT_EQ(Invocation.getTargetOpts().SDKVersion, llvm::VersionTuple(1, 2, 
3));
+  ASSERT_EQ(Invocation.getTargetOpts().EABIVersion, EABI::EABI4);
+
+  ASSERT_THAT(Invocation.getDiagnosticOpts().UndefPrefixes,
+  Contains(StrEq("XY")));
+  ASSERT_EQ(Invocation.getDiagnosticOpts().getFormat(),
+TextDiagnosticFormat::Clang);
+
+  ASSERT_TRUE(Invocation.getHeaderSearchOpts().UseLibcxx);
+  ASSERT_TRUE(Invocation.getHeaderSearchOpts().ImplicitModuleMaps);
+
+  ASSERT_THAT(Invocation.getPreprocessorOpts().Macros,
+  Contains(std::make_pair(std::string("XY=AB"), false)));
+  ASSERT_EQ(Invocation.getPreprocessorOpts().ImplicitPCHInclude, "a.pch");
+
+  ASSERT_EQ(Invocation.getAnalyzerOpts()->Config["ctu-import-threshold"], 
"42");
+  ASSERT_TRUE(Invocation.getAnalyzerOpts()->UnoptimizedCFG);
+
+  ASSERT_TRUE(Invocation.getMigratorOpts().NoNSAllocReallocError);
+
+  ASSERT_EQ(Invocation.getCodeGenOpts().getDebugInfo(),
+codegenoptions::DebugInfoKind::LimitedDebugInfo);
+  ASSERT_TRUE(Invocation.getCodeGenOpts().MacroDebugInfo);
+
+  ASSERT_EQ(Invocation.getDependencyOutputOpts().ShowIncludesDest,
+ShowIncludesDestination::Stdout);
+  ASSERT_TRUE(Invocation.getDependencyOutputOpts().ShowHeaderIncludes);
+}
 } // anonymous namespace



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


[PATCH] D96705: [clang][cli] Add explicit round-trip test

2021-02-16 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGed8632851588: [clang][cli] Add explicit round-trip test 
(authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96705

Files:
  clang/unittests/Frontend/CompilerInvocationTest.cpp

Index: clang/unittests/Frontend/CompilerInvocationTest.cpp
===
--- clang/unittests/Frontend/CompilerInvocationTest.cpp
+++ clang/unittests/Frontend/CompilerInvocationTest.cpp
@@ -7,8 +7,10 @@
 //===--===//
 
 #include "clang/Frontend/CompilerInvocation.h"
+#include "clang/Basic/TargetOptions.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/TextDiagnosticBuffer.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/Support/Host.h"
 
 #include "gmock/gmock.h"
@@ -740,4 +742,85 @@
   Invocation.generateCC1CommandLine(GeneratedArgs, *this);
   ASSERT_THAT(GeneratedArgs, Contains(StrEq("-fdigraphs")));
 }
+
+TEST_F(CommandLineTest, RoundTrip) {
+  // Testing one marshalled and one manually generated option from each
+  // CompilerInvocation member.
+  const char *Args[] = {
+  "-round-trip-args",
+  // LanguageOptions
+  "-std=c17",
+  "-fmax-tokens=10",
+  // TargetOptions
+  "-target-sdk-version=1.2.3",
+  "-meabi",
+  "4",
+  // DiagnosticOptions
+  "-Wundef-prefix=XY",
+  "-fdiagnostics-format",
+  "clang",
+  // HeaderSearchOptions
+  "-stdlib=libc++",
+  "-fimplicit-module-maps",
+  // PreprocessorOptions
+  "-DXY=AB",
+  "-include-pch",
+  "a.pch",
+  // AnalyzerOptions
+  "-analyzer-config",
+  "ctu-import-threshold=42",
+  "-unoptimized-cfg",
+  // MigratorOptions (no manually handled arguments)
+  "-no-ns-alloc-error",
+  // CodeGenOptions
+  "-debug-info-kind=limited",
+  "-debug-info-macro",
+  // DependencyOutputOptions
+  "--show-includes",
+  "-H",
+  // FileSystemOptions (no manually handled arguments)
+  "-working-directory",
+  "folder",
+  // FrontendOptions
+  "-load",
+  "plugin",
+  "-ast-merge",
+  // PreprocessorOutputOptions
+  "-dD",
+  "-CC",
+  };
+
+  ASSERT_TRUE(CompilerInvocation::CreateFromArgs(Invocation, Args, *Diags));
+
+  ASSERT_TRUE(Invocation.getLangOpts()->C17);
+  ASSERT_EQ(Invocation.getLangOpts()->MaxTokens, 10u);
+
+  ASSERT_EQ(Invocation.getTargetOpts().SDKVersion, llvm::VersionTuple(1, 2, 3));
+  ASSERT_EQ(Invocation.getTargetOpts().EABIVersion, EABI::EABI4);
+
+  ASSERT_THAT(Invocation.getDiagnosticOpts().UndefPrefixes,
+  Contains(StrEq("XY")));
+  ASSERT_EQ(Invocation.getDiagnosticOpts().getFormat(),
+TextDiagnosticFormat::Clang);
+
+  ASSERT_TRUE(Invocation.getHeaderSearchOpts().UseLibcxx);
+  ASSERT_TRUE(Invocation.getHeaderSearchOpts().ImplicitModuleMaps);
+
+  ASSERT_THAT(Invocation.getPreprocessorOpts().Macros,
+  Contains(std::make_pair(std::string("XY=AB"), false)));
+  ASSERT_EQ(Invocation.getPreprocessorOpts().ImplicitPCHInclude, "a.pch");
+
+  ASSERT_EQ(Invocation.getAnalyzerOpts()->Config["ctu-import-threshold"], "42");
+  ASSERT_TRUE(Invocation.getAnalyzerOpts()->UnoptimizedCFG);
+
+  ASSERT_TRUE(Invocation.getMigratorOpts().NoNSAllocReallocError);
+
+  ASSERT_EQ(Invocation.getCodeGenOpts().getDebugInfo(),
+codegenoptions::DebugInfoKind::LimitedDebugInfo);
+  ASSERT_TRUE(Invocation.getCodeGenOpts().MacroDebugInfo);
+
+  ASSERT_EQ(Invocation.getDependencyOutputOpts().ShowIncludesDest,
+ShowIncludesDestination::Stdout);
+  ASSERT_TRUE(Invocation.getDependencyOutputOpts().ShowHeaderIncludes);
+}
 } // anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96690: [clangd] Treat paths case-insensitively depending on the platform

2021-02-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Nice, thank you!




Comment at: clang-tools-extra/clangd/support/Path.cpp:22
 
-bool pathEqual(PathRef A, PathRef B) {
-#if defined(_WIN32) || defined(__APPLE__)
-  return A.equals_lower(B);
-#else
-  return A == B;
-#endif
+bool pathIsAncestor(PathRef Ancestor, PathRef Path,
+llvm::sys::path::Style Style) {

we should decide what the preconditions are here

Could assert both are absolute paths, this places a burden on callers.

I do like the idea this is "just" a smarter lexical startswith. (I'd consider 
pathStartsWith rather than pathIsAncestor for this reason)
In this case we should doc it (e.g. foo/./bar is not an ancestor of 
foo/bar/baz) and return false when Ancestor is empty (rather than crash)



Comment at: clang-tools-extra/clangd/support/Path.h:18
+#if defined(_WIN32) || defined(__APPLE__)
+#define CLANGD_PATH_CASE_INSENSITIVE
+#endif

(we could conditionally define this as either 0 or 1 and then use it for regex 
flags without ifdef, up to you)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96690

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


[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-16 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added a comment.

This does fixes the save-temps but only when -o is not specified. If -o is 
specified the name of host object file and host-wrapper object file (second 
last phase) is same, which fails the linker. This does not seem to be related 
to this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[clang-tools-extra] 40cc63e - [clangd] Modules can have a public API. NFC

2021-02-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-02-16T15:22:57+01:00
New Revision: 40cc63ea6eec7874d3a358f9fa549ef2f6543512

URL: 
https://github.com/llvm/llvm-project/commit/40cc63ea6eec7874d3a358f9fa549ef2f6543512
DIFF: 
https://github.com/llvm/llvm-project/commit/40cc63ea6eec7874d3a358f9fa549ef2f6543512.diff

LOG: [clangd] Modules can have a public API. NFC

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

Added: 
clang-tools-extra/clangd/Module.cpp

Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Module.h
clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index 3de510665723..bf654a23e00c 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -75,6 +75,7 @@ add_clang_library(clangDaemon
   Hover.cpp
   IncludeFixer.cpp
   JSONTransport.cpp
+  Module.cpp
   PathMapping.cpp
   Protocol.cpp
   Quality.cpp

diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index b39e582d84a1..49f01cd0b59a 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -127,7 +127,7 @@ ClangdServer::Options::operator TUScheduler::Options() 
const {
 ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
const ThreadsafeFS &TFS, const Options &Opts,
Callbacks *Callbacks)
-: CDB(CDB), TFS(TFS),
+: Modules(Opts.Modules), CDB(CDB), TFS(TFS),
   DynamicIdx(Opts.BuildDynamicSymbolIndex ? new FileIndex() : nullptr),
   ClangTidyProvider(Opts.ClangTidyProvider),
   WorkspaceRoot(Opts.WorkspaceRoot),

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 83c8567461ec..9581a558ea31 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -161,6 +161,15 @@ class ClangdServer {
   ClangdServer(const GlobalCompilationDatabase &CDB, const ThreadsafeFS &TFS,
const Options &Opts, Callbacks *Callbacks = nullptr);
 
+  /// Gets the installed module of a given type, if any.
+  /// This exposes access the public interface of modules that have one.
+  template  Mod *getModule() {
+return Modules ? Modules->get() : nullptr;
+  }
+  template  const Mod *getModule() const {
+return Modules ? Modules->get() : nullptr;
+  }
+
   /// Add a \p File to the list of tracked C++ files or update the contents if
   /// \p File is already tracked. Also schedules parsing of the AST for it on a
   /// separate thread. When the parsing is complete, DiagConsumer passed in
@@ -337,6 +346,7 @@ class ClangdServer {
   ArrayRef Ranges,
   Callback CB);
 
+  ModuleSet *Modules;
   const GlobalCompilationDatabase &CDB;
   const ThreadsafeFS &TFS;
 

diff  --git a/clang-tools-extra/clangd/Module.cpp 
b/clang-tools-extra/clangd/Module.cpp
new file mode 100644
index ..1152ae4e7fb2
--- /dev/null
+++ b/clang-tools-extra/clangd/Module.cpp
@@ -0,0 +1,18 @@
+#include "Module.h"
+
+namespace clang {
+namespace clangd {
+
+bool ModuleSet::addImpl(void *Key, std::unique_ptr M,
+const char *Source) {
+  if (!Map.try_emplace(Key, M.get()).second) {
+// Source should (usually) include the name of the concrete module type.
+elog("Tried to register duplicate modules via {0}", Source);
+return false;
+  }
+  Modules.push_back(std::move(M));
+  return true;
+}
+
+} // namespace clangd
+} // namespace clang

diff  --git a/clang-tools-extra/clangd/Module.h 
b/clang-tools-extra/clangd/Module.h
index a99b78d51c44..1db228000a6e 100644
--- a/clang-tools-extra/clangd/Module.h
+++ b/clang-tools-extra/clangd/Module.h
@@ -3,8 +3,10 @@
 
 #include "LSPBinder.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/JSON.h"
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -41,12 +43,28 @@ class Module {
  llvm::json::Object &ServerCaps) {}
 };
 
+/// A ModuleSet is a collection of modules installed in clangd.
+///
+/// Modules can be looked up by type, or used through the Module interface.
+/// This allows individual modules to expose a public API.
+/// For this reason, there can be only one module of each type.
+///
+/// ModuleSet owns the modules. It is itself owned by main, not ClangdServer.
 class ModuleSet {
   std::vector> Modules;
+  llvm::DenseMap Map;
+
+  template  struct ID {
+static_assert(std::is_base_of::value &&
+  std::is_final::value,
+  "Modules must be final classes derived from clangd::Module");
+static int Key;
+  };
+
+  b

[PATCH] D96730: [clangd] Modules can have a public API. NFC

2021-02-16 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rG40cc63ea6eec: [clangd] Modules can have a public API. NFC 
(authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D96730?vs=323822&id=323985#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96730

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Module.cpp
  clang-tools-extra/clangd/Module.h
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -222,25 +222,26 @@
 }
 
 TEST_F(LSPTest, ModulesTest) {
-  class MathModule : public Module {
+  class MathModule final : public Module {
 void initializeLSP(LSPBinder &Bind, const llvm::json::Object &ClientCaps,
llvm::json::Object &ServerCaps) override {
   Bind.notification("add", this, &MathModule::add);
   Bind.method("get", this, &MathModule::get);
 }
 
+int Value = 0;
+
+  public:
 void add(const int &X) { Value += X; }
 void get(const std::nullptr_t &, Callback Reply) { Reply(Value); }
-int Value = 0;
   };
-  std::vector> Mods;
-  Mods.push_back(std::make_unique());
-  ModuleSet ModSet(std::move(Mods));
-  Opts.Modules = &ModSet;
+  ModuleSet Mods;
+  Mods.add(std::make_unique());
+  Opts.Modules = &Mods;
 
   auto &Client = start();
   Client.notify("add", 2);
-  Client.notify("add", 8);
+  Mods.get()->add(8);
   EXPECT_EQ(10, Client.call("get", nullptr).takeValue());
 }
 
Index: clang-tools-extra/clangd/Module.h
===
--- clang-tools-extra/clangd/Module.h
+++ clang-tools-extra/clangd/Module.h
@@ -3,8 +3,10 @@
 
 #include "LSPBinder.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/JSON.h"
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -41,12 +43,28 @@
  llvm::json::Object &ServerCaps) {}
 };
 
+/// A ModuleSet is a collection of modules installed in clangd.
+///
+/// Modules can be looked up by type, or used through the Module interface.
+/// This allows individual modules to expose a public API.
+/// For this reason, there can be only one module of each type.
+///
+/// ModuleSet owns the modules. It is itself owned by main, not ClangdServer.
 class ModuleSet {
   std::vector> Modules;
+  llvm::DenseMap Map;
+
+  template  struct ID {
+static_assert(std::is_base_of::value &&
+  std::is_final::value,
+  "Modules must be final classes derived from clangd::Module");
+static int Key;
+  };
+
+  bool addImpl(void *Key, std::unique_ptr, const char *Source);
 
 public:
-  explicit ModuleSet(std::vector> Modules)
-  : Modules(std::move(Modules)) {}
+  ModuleSet() = default;
 
   using iterator = llvm::pointee_iterator;
   using const_iterator =
@@ -55,7 +73,20 @@
   iterator end() { return iterator(Modules.end()); }
   const_iterator begin() const { return const_iterator(Modules.begin()); }
   const_iterator end() const { return const_iterator(Modules.end()); }
+
+  template  bool add(std::unique_ptr M) {
+return addImpl(&ID::Key, std::move(M), LLVM_PRETTY_FUNCTION);
+  }
+  template  Mod *get() {
+return static_cast(Map.lookup(&ID::Key));
+  }
+  template  const Mod *get() const {
+return const_cast(this)->get();
+  }
 };
+
+template  int ModuleSet::ID::Key;
+
 } // namespace clangd
 } // namespace clang
 #endif
Index: clang-tools-extra/clangd/Module.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/Module.cpp
@@ -0,0 +1,18 @@
+#include "Module.h"
+
+namespace clang {
+namespace clangd {
+
+bool ModuleSet::addImpl(void *Key, std::unique_ptr M,
+const char *Source) {
+  if (!Map.try_emplace(Key, M.get()).second) {
+// Source should (usually) include the name of the concrete module type.
+elog("Tried to register duplicate modules via {0}", Source);
+return false;
+  }
+  Modules.push_back(std::move(M));
+  return true;
+}
+
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -161,6 +161,15 @@
   ClangdServer(const GlobalCompilationDatabase &CDB, const ThreadsafeFS &TFS,
const Options &Opts, Callbacks *Callbacks = nullptr);
 
+  /// Gets the installed module of a given type, i

[PATCH] D96616: [OpenCL][Docs] Change decription for the OpenCL standard headers

2021-02-16 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added inline comments.



Comment at: clang/docs/OpenCLSupport.rst:67
+All the options in this section are frontend-only and therefore if used
+with regular clang driver they require frontend forwarding e.g. ``-cc1``
+or ``-Xclang``.





Comment at: clang/docs/OpenCLSupport.rst:123
+Because the header is very large and long to parse, PCH (:doc:`PCHInternals`)
+and modules (:doc:`Modules`) are used internally to improve the compilation
+speed.

"are" or "can be"?



Comment at: clang/docs/UsersManual.rst:2942
+Allows to disable all extra types and functions that are not native to the 
compiler.
+This might reduce the compilation speed marginally but many declaration from 
the
+OpenCL standard won't be accessible i.e. the following example will fail to 
compile.





Comment at: clang/docs/UsersManual.rst:2943
+This might reduce the compilation speed marginally but many declaration from 
the
+OpenCL standard won't be accessible i.e. the following example will fail to 
compile.
 





Comment at: clang/docs/UsersManual.rst:2948
+ $ echo "bool is_wg_uniform(int i){return 
get_enqueued_local_size(i)==get_local_size(i);}" > test.cl
+ $ clang -cl-std=CL2.0 -cl-no-stdinc test.cl
 

Maybe include the error output from running this as well, because otherwise a 
hasty reader might assume this command should work?



Comment at: clang/docs/UsersManual.rst:3016
 
.. code-block:: console
 

I wonder if we need to keep this example?  You're not referring to it from the 
text and it's not demonstrating any special flags anymore.


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

https://reviews.llvm.org/D96616

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


[PATCH] D96716: [flang][driver] Add debug dump options

2021-02-16 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

I think that this patch does a great job demonstrating the use of frontend 
actions and how _action_ compiler flags map to them. Given how 
`Fortran::semantics::Semantics` are defined and created, I think that adding 
_semantics_ as a member variable to `PrescanAndSemaAction` makes a lot of sense.

Btw, I also think that it would be worth exploring what Clang does. Ideally 
we'd have some `Sema` API that would be a member of `CompilerInstance`. 
However, that's outside the scope of this patch :)

Apart from one comment this looks good to me. Thank you for submitting this 
@FarisRehman !




Comment at: flang/include/flang/Frontend/FrontendActions.h:54
+public:
+  std::unique_ptr semantics_;
 };

Do we need to expose it? Shouldn't this be private?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96716

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


[clang-tools-extra] b6e52d8 - [clangd] Give modules access to filesystem, scheduler, and index.

2021-02-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-02-16T15:30:08+01:00
New Revision: b6e52d8fa7217db319e240854a9d8ff3133d02b6

URL: 
https://github.com/llvm/llvm-project/commit/b6e52d8fa7217db319e240854a9d8ff3133d02b6
DIFF: 
https://github.com/llvm/llvm-project/commit/b6e52d8fa7217db319e240854a9d8ff3133d02b6.diff

LOG: [clangd] Give modules access to filesystem, scheduler, and index.

This finally makes it possible to implement useful modules.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/Module.cpp
clang-tools-extra/clangd/Module.h
clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 49f01cd0b59ae..67aba1c3d92ea 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -167,6 +167,16 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase 
&CDB,
   }
   if (DynamicIdx)
 AddIndex(DynamicIdx.get());
+
+  if (Opts.Modules) {
+Module::Facilities F{
+this->WorkScheduler,
+this->Index,
+this->TFS,
+};
+for (auto &Mod : *Opts.Modules)
+  Mod.initialize(F);
+  }
 }
 
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,

diff  --git a/clang-tools-extra/clangd/Module.cpp 
b/clang-tools-extra/clangd/Module.cpp
index 1152ae4e7fb22..051f1b45c8375 100644
--- a/clang-tools-extra/clangd/Module.cpp
+++ b/clang-tools-extra/clangd/Module.cpp
@@ -1,8 +1,27 @@
+//===--- Module.cpp - Plugging features into clangd 
---===//
+//
+// 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 "Module.h"
+#include "support/Logger.h"
 
 namespace clang {
 namespace clangd {
 
+void Module::initialize(const Facilities &F) {
+  assert(!Fac.hasValue() && "Initialized twice");
+  Fac.emplace(F);
+}
+
+Module::Facilities &Module::facilities() {
+  assert(Fac.hasValue() && "Not initialized yet");
+  return *Fac;
+}
+
 bool ModuleSet::addImpl(void *Key, std::unique_ptr M,
 const char *Source) {
   if (!Map.try_emplace(Key, M.get()).second) {

diff  --git a/clang-tools-extra/clangd/Module.h 
b/clang-tools-extra/clangd/Module.h
index 1db228000a6ed..4b184b19dcb3b 100644
--- a/clang-tools-extra/clangd/Module.h
+++ b/clang-tools-extra/clangd/Module.h
@@ -1,7 +1,14 @@
+//===--- Module.h - Plugging features into clangd 
-*-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
+//
+//===--===//
+
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_MODULE_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_MODULE_H
 
-#include "LSPBinder.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/JSON.h"
@@ -11,6 +18,10 @@
 
 namespace clang {
 namespace clangd {
+class LSPBinder;
+class SymbolIndex;
+class ThreadsafeFS;
+class TUScheduler;
 
 /// A Module contributes a vertical feature to clangd.
 ///
@@ -18,10 +29,11 @@ namespace clangd {
 ///
 /// The lifetime of a module is roughly:
 ///  - modules are created before the LSP server, in ClangdMain.cpp
-///  - these modules are then passed to ClangdLSPServer and ClangdServer
-///  - module hooks can be called at this point.
-///FIXME: We should make some server facilities like TUScheduler and index
-///available to those modules after ClangdServer is initalized.
+///  - these modules are then passed to ClangdLSPServer in a ModuleSet
+///  - initializeLSP() is called when the editor calls initialize.
+//   - initialize() is then called by ClangdServer as it is constructed.
+///  - module hooks can be called by the server at this point.
+///Server facilities (scheduler etc) are available.
 ///  - ClangdServer will not be destroyed until all the requests are done.
 ///FIXME: Block server shutdown until all the modules are idle.
 ///  - modules will be destroyed after ClangdLSPServer is destroyed.
@@ -41,6 +53,28 @@ class Module {
   virtual void initializeLSP(LSPBinder &Bind,
  const llvm::json::Object &ClientCaps,
  llvm::json::Object &ServerCaps) {}
+
+  /// Shared server facilities needed by the module to get its work done.
+  struct Facilities {
+TUScheduler &Scheduler;
+const SymbolIndex *Index;
+const ThreadsafeFS &FS;
+  };
+  /// Called by the server 

[PATCH] D96726: [clangd] Give modules access to filesystem, scheduler, and index.

2021-02-16 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb6e52d8fa721: [clangd] Give modules access to filesystem, 
scheduler, and index. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D96726?vs=323809&id=323992#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96726

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/Module.cpp
  clang-tools-extra/clangd/Module.h
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -233,7 +233,11 @@
 
   public:
 void add(const int &X) { Value += X; }
-void get(const std::nullptr_t &, Callback Reply) { Reply(Value); }
+void get(const std::nullptr_t &, Callback Reply) {
+  scheduler().runQuick(
+  "get", "",
+  [Reply(std::move(Reply)), Value(Value)]() mutable { Reply(Value); });
+}
   };
   ModuleSet Mods;
   Mods.add(std::make_unique());
Index: clang-tools-extra/clangd/Module.h
===
--- clang-tools-extra/clangd/Module.h
+++ clang-tools-extra/clangd/Module.h
@@ -1,7 +1,14 @@
+//===--- Module.h - Plugging features into clangd -*-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
+//
+//===--===//
+
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_MODULE_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_MODULE_H
 
-#include "LSPBinder.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/JSON.h"
@@ -11,6 +18,10 @@
 
 namespace clang {
 namespace clangd {
+class LSPBinder;
+class SymbolIndex;
+class ThreadsafeFS;
+class TUScheduler;
 
 /// A Module contributes a vertical feature to clangd.
 ///
@@ -18,10 +29,11 @@
 ///
 /// The lifetime of a module is roughly:
 ///  - modules are created before the LSP server, in ClangdMain.cpp
-///  - these modules are then passed to ClangdLSPServer and ClangdServer
-///  - module hooks can be called at this point.
-///FIXME: We should make some server facilities like TUScheduler and index
-///available to those modules after ClangdServer is initalized.
+///  - these modules are then passed to ClangdLSPServer in a ModuleSet
+///  - initializeLSP() is called when the editor calls initialize.
+//   - initialize() is then called by ClangdServer as it is constructed.
+///  - module hooks can be called by the server at this point.
+///Server facilities (scheduler etc) are available.
 ///  - ClangdServer will not be destroyed until all the requests are done.
 ///FIXME: Block server shutdown until all the modules are idle.
 ///  - modules will be destroyed after ClangdLSPServer is destroyed.
@@ -41,6 +53,28 @@
   virtual void initializeLSP(LSPBinder &Bind,
  const llvm::json::Object &ClientCaps,
  llvm::json::Object &ServerCaps) {}
+
+  /// Shared server facilities needed by the module to get its work done.
+  struct Facilities {
+TUScheduler &Scheduler;
+const SymbolIndex *Index;
+const ThreadsafeFS &FS;
+  };
+  /// Called by the server to prepare this module for use.
+  void initialize(const Facilities &F);
+
+protected:
+  /// Accessors for modules to access shared server facilities they depend on.
+  Facilities &facilities();
+  /// The scheduler is used to run tasks on worker threads and access ASTs.
+  TUScheduler &scheduler() { return facilities().Scheduler; }
+  /// The index is used to get information about the whole codebase.
+  const SymbolIndex *index() { return facilities().Index; }
+  /// The filesystem is used to read source files on disk.
+  const ThreadsafeFS &fs() { return facilities().FS; }
+
+private:
+  llvm::Optional Fac;
 };
 
 /// A ModuleSet is a collection of modules installed in clangd.
Index: clang-tools-extra/clangd/Module.cpp
===
--- clang-tools-extra/clangd/Module.cpp
+++ clang-tools-extra/clangd/Module.cpp
@@ -1,8 +1,27 @@
+//===--- Module.cpp - Plugging features into clangd ---===//
+//
+// 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 "Module.h"
+#include "support/Logger.h"
 
 namespace

[PATCH] D96783: [Driver] Support -gdwarf64 for assembly files

2021-02-16 Thread Igor Kudrin via Phabricator via cfe-commits
ikudrin created this revision.
ikudrin added reviewers: ayermolo, dblaikie, aprantl, MaskRay.
ikudrin added projects: LLVM, clang, debug-info.
Herald added subscribers: jansvoboda11, dang.
ikudrin requested review of this revision.

The option was added in D90507  for C/C++ 
source files. This patch adds support for assembly files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96783

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/debug-options-as.c
  clang/test/Misc/cc1as-debug-format.s
  clang/tools/driver/cc1as_main.cpp

Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -91,6 +91,7 @@
   unsigned SaveTemporaryLabels : 1;
   unsigned GenDwarfForAssembly : 1;
   unsigned RelaxELFRelocations : 1;
+  unsigned Dwarf64 : 1;
   unsigned DwarfVersion;
   std::string DwarfDebugFlags;
   std::string DwarfDebugProducer;
@@ -160,6 +161,7 @@
 FatalWarnings = 0;
 NoWarn = 0;
 IncrementalLinkerCompatible = 0;
+Dwarf64 = 0;
 DwarfVersion = 0;
 EmbedBitcode = 0;
   }
@@ -231,6 +233,8 @@
   }
 
   Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
+  if (auto *DwarfFormatArg = Args.getLastArg(OPT_gdwarf64, OPT_gdwarf32))
+Opts.Dwarf64 = DwarfFormatArg->getOption().matches(OPT_gdwarf64) ? 1 : 0;
   Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
   Opts.DwarfDebugFlags =
   std::string(Args.getLastArgValue(OPT_dwarf_debug_flags));
@@ -417,6 +421,7 @@
   Ctx.addDebugPrefixMapEntry(KV.first, KV.second);
   if (!Opts.MainFileName.empty())
 Ctx.setMainFileName(StringRef(Opts.MainFileName));
+  Ctx.setDwarfFormat(Opts.Dwarf64 ? dwarf::DWARF64 : dwarf::DWARF32);
   Ctx.setDwarfVersion(Opts.DwarfVersion);
   if (Opts.GenDwarfForAssembly)
 Ctx.setGenDwarfRootFile(Opts.InputFile,
Index: clang/test/Misc/cc1as-debug-format.s
===
--- /dev/null
+++ clang/test/Misc/cc1as-debug-format.s
@@ -0,0 +1,24 @@
+// REQUIRES: x86-registered-target
+/// DWARF32 debug info is produced by default, when neither -gdwarf32 nor -gdwarf64 is given.
+// RUN: %clang -cc1as -triple x86_64-pc-linux-gnu -filetype obj -debug-info-kind=limited -dwarf-version=4 %s -o %t
+// RUN: llvm-dwarfdump -all %t | FileCheck %s --check-prefixes=CHECK,DWARF32
+/// -gdwarf64 causes generating DWARF64 debug info.
+// RUN: %clang -cc1as -triple x86_64-pc-linux-gnu -filetype obj -gdwarf64 -debug-info-kind=limited -dwarf-version=4 %s -o %t
+// RUN: llvm-dwarfdump -all %t | FileCheck %s --check-prefixes=CHECK,DWARF64
+/// -gdwarf32 is also handled and produces DWARF32 debug info.
+// RUN: %clang -cc1as -triple x86_64-pc-linux-gnu -filetype obj -gdwarf32 -debug-info-kind=limited -dwarf-version=4 %s -o %t
+// RUN: llvm-dwarfdump -all %t | FileCheck %s --check-prefixes=CHECK,DWARF32
+
+// CHECK:.debug_info contents:
+// DWARF32-NEXT: format = DWARF32
+// DWARF64-NEXT: format = DWARF64
+
+// CHECK:.debug_line contents:
+// CHECK-NEXT:   debug_line[
+// CHECK-NEXT:   Line table prologue:
+// CHECK-NEXT: total_length:
+// DWARF32-NEXT: format: DWARF32
+// DWARF64-NEXT: format: DWARF64
+
+.text
+  nop
Index: clang/test/Driver/debug-options-as.c
===
--- clang/test/Driver/debug-options-as.c
+++ clang/test/Driver/debug-options-as.c
@@ -32,3 +32,31 @@
 //
 // P: "-cc1as"
 // P: "-dwarf-debug-producer"
+
+// Check that -gdwarf64 is passed to cc1as.
+// RUN: %clang -### -c -gdwarf64 -gdwarf-5 -target x86_64 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -c -gdwarf64 -gdwarf-4 -target x86_64 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -c -gdwarf64 -gdwarf-3 -target x86_64 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_ON %s
+// GDWARF64_ON: "-cc1as"
+// GDWARF64_ON: "-gdwarf64"
+
+// Check that -gdwarf64 can be reverted with -gdwarf32.
+// RUN: %clang -### -c -gdwarf64 -gdwarf32 -gdwarf-4 -target x86_64 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_OFF %s
+// GDWARF64_OFF: "-cc1as"
+// GDWARF64_OFF-NOT: "-gdwarf64"
+
+// Check that an error is reported if -gdwarf64 cannot be used.
+// RUN: %clang -### -c -gdwarf64 -gdwarf-2 -target x86_64 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_VER %s
+// RUN: %clang -### -c -gdwarf64 -gdwarf-4 -target i386-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_32ARCH %s
+// RUN: %clang -### -c -gdwarf64 -gdwarf-4 -target x86_64-apple-darwin %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_ELF %s
+//
+// 

[PATCH] D96561: [clang-tidy] add -use-color option to clang-tidy-diff.py

2021-02-16 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96561

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


[PATCH] D90851: [clang-tidy] Extending bugprone-signal-handler with POSIX functions.

2021-02-16 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90851

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


[PATCH] D96784: Pass the cmdline aapcs bitfield options to cc1

2021-02-16 Thread Ties Stuij via Phabricator via cfe-commits
stuij created this revision.
Herald added a subscriber: kristof.beyls.
stuij requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The following commits added commandline arguments to control following the Arm
Procedure Call Standard for certain volatile bitfield operations:

- https://reviews.llvm.org/D67399
- https://reviews.llvm.org/D72932

This commit fixes the oversight that these args weren't passed from the driver
to cc1 if appropriate.

Where *appropriate* means:

- `-faapcs-bitfield-width`: is the default, so won't be passed
- `-fno-aapcs-bitfield-width`: should be passed
- `-faapcs-bitfield-load`: should be passed


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96784

Files:
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1522,6 +1522,15 @@
   }
 }
 
+void AddAAPCSVolatileBitfieldArgs(const ArgList &Args, ArgStringList &CmdArgs) 
{
+  if (!Args.hasFlag(options::OPT_faapcs_bitfield_width,
+options::OPT_fno_aapcs_bitfield_width, true))
+CmdArgs.push_back("-fno-aapcs-bitfield-width");
+
+  if (Args.getLastArg(options::OPT_ForceAAPCSBitfieldLoad))
+CmdArgs.push_back("-faapcs-bitfield-load");
+}
+
 namespace {
 void RenderARMABI(const llvm::Triple &Triple, const ArgList &Args,
   ArgStringList &CmdArgs) {
@@ -1580,6 +1589,8 @@
 
   if (Args.getLastArg(options::OPT_mcmse))
 CmdArgs.push_back("-mcmse");
+
+  AddAAPCSVolatileBitfieldArgs(Args, CmdArgs);
 }
 
 void Clang::RenderTargetOptions(const llvm::Triple &EffectiveTriple,
@@ -1768,6 +1779,8 @@
   D.Diag(diag::err_drv_unsupported_option_argument)
   << A->getOption().getName() << Val;
   }
+
+  AddAAPCSVolatileBitfieldArgs(Args, CmdArgs);
 }
 
 void Clang::AddMIPSTargetArgs(const ArgList &Args,


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1522,6 +1522,15 @@
   }
 }
 
+void AddAAPCSVolatileBitfieldArgs(const ArgList &Args, ArgStringList &CmdArgs) {
+  if (!Args.hasFlag(options::OPT_faapcs_bitfield_width,
+options::OPT_fno_aapcs_bitfield_width, true))
+CmdArgs.push_back("-fno-aapcs-bitfield-width");
+
+  if (Args.getLastArg(options::OPT_ForceAAPCSBitfieldLoad))
+CmdArgs.push_back("-faapcs-bitfield-load");
+}
+
 namespace {
 void RenderARMABI(const llvm::Triple &Triple, const ArgList &Args,
   ArgStringList &CmdArgs) {
@@ -1580,6 +1589,8 @@
 
   if (Args.getLastArg(options::OPT_mcmse))
 CmdArgs.push_back("-mcmse");
+
+  AddAAPCSVolatileBitfieldArgs(Args, CmdArgs);
 }
 
 void Clang::RenderTargetOptions(const llvm::Triple &EffectiveTriple,
@@ -1768,6 +1779,8 @@
   D.Diag(diag::err_drv_unsupported_option_argument)
   << A->getOption().getName() << Val;
   }
+
+  AddAAPCSVolatileBitfieldArgs(Args, CmdArgs);
 }
 
 void Clang::AddMIPSTargetArgs(const ArgList &Args,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96690: [clangd] Treat paths case-insensitively depending on the platform

2021-02-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 323997.
kadircet marked an inline comment as done.
kadircet added a comment.

- s/pathIsAncestor/pathStartsWith
- Fix tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96690

Files:
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/support/Path.cpp
  clang-tools-extra/clangd/support/Path.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp
  clang-tools-extra/clangd/unittests/support/PathTests.cpp

Index: clang-tools-extra/clangd/unittests/support/PathTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/support/PathTests.cpp
@@ -0,0 +1,36 @@
+//===-- PathTests.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 "support/Path.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+TEST(PathTests, IsAncestor) {
+  EXPECT_TRUE(pathStartsWith("/foo", "/foo"));
+  EXPECT_TRUE(pathStartsWith("/foo/", "/foo"));
+
+  EXPECT_FALSE(pathStartsWith("/foo", "/fooz"));
+  EXPECT_FALSE(pathStartsWith("/foo/", "/fooz"));
+
+  EXPECT_TRUE(pathStartsWith("/foo", "/foo/bar"));
+  EXPECT_TRUE(pathStartsWith("/foo/", "/foo/bar"));
+
+#ifdef CLANGD_PATH_CASE_INSENSITIVE
+  EXPECT_TRUE(pathStartsWith("/fOo", "/foo/bar"));
+  EXPECT_TRUE(pathStartsWith("/foo", "/fOo/bar"));
+#else
+  EXPECT_FALSE(pathStartsWith("/fOo", "/foo/bar"));
+  EXPECT_FALSE(pathStartsWith("/foo", "/fOo/bar"));
+#endif
+}
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1125,7 +1125,7 @@
   EXPECT_THAT(Results.GlobalChanges.keys(),
   UnorderedElementsAre(Main, testPath("other.cc")));
 
-#if defined(_WIN32) || defined(__APPLE__)
+#ifdef CLANGD_PATH_CASE_INSENSITIVE
   // On case-insensitive systems, no duplicates if AST vs index case differs.
   // https://github.com/clangd/clangd/issues/665
   TU.Filename = "MAIN.CC";
Index: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
===
--- clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
+++ clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
@@ -99,6 +99,25 @@
   Frag.If.PathMatch.emplace_back("ba*r");
   EXPECT_FALSE(compileAndApply());
   EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+
+  // Only matches case-insensitively.
+  Frag = {};
+  Frag.If.PathMatch.emplace_back("B.*R");
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+#ifdef CLANGD_PATH_CASE_INSENSITIVE
+  EXPECT_TRUE(compileAndApply());
+#else
+  EXPECT_FALSE(compileAndApply());
+#endif
+
+  Frag = {};
+  Frag.If.PathExclude.emplace_back("B.*R");
+  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
+#ifdef CLANGD_PATH_CASE_INSENSITIVE
+  EXPECT_FALSE(compileAndApply());
+#else
+  EXPECT_TRUE(compileAndApply());
+#endif
 }
 
 TEST_F(ConfigCompileTests, CompileCommands) {
@@ -406,6 +425,23 @@
   ASSERT_THAT(Diags.Diagnostics, IsEmpty());
   ASSERT_TRUE(Conf.Index.External);
   EXPECT_THAT(Conf.Index.External->MountPoint, FooPath);
+
+  // Only matches case-insensitively.
+  BazPath = testPath("fOo/baz.h", llvm::sys::path::Style::posix);
+  BazPath = llvm::sys::path::convert_to_slash(BazPath);
+  Parm.Path = BazPath;
+
+  FooPath = testPath("FOO/", llvm::sys::path::Style::posix);
+  FooPath = llvm::sys::path::convert_to_slash(FooPath);
+  Frag = GetFrag("", FooPath.c_str());
+  compileAndApply();
+  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
+#ifdef CLANGD_PATH_CASE_INSENSITIVE
+  ASSERT_TRUE(Conf.Index.External);
+  EXPECT_THAT(Conf.Index.External->MountPoint, FooPath);
+#else
+  ASSERT_FALSE(Conf.Index.External);
+#endif
 }
 } // namespace
 } // namespace config
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -104,6 +104,7 @@
   support/FunctionTests.cpp
   support/MarkupTests.cpp
   support/MemoryTreeTests.cpp
+  support/PathTests.cpp
   support/ThreadingTests.cpp
   support/TestTracer.cpp
   support/TraceTests.cpp
Index: clang-tools-extra/clangd/support/Path.h
===
--- c

[PATCH] D96690: [clangd] Treat paths case-insensitively depending on the platform

2021-02-16 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/support/Path.cpp:22
 
-bool pathEqual(PathRef A, PathRef B) {
-#if defined(_WIN32) || defined(__APPLE__)
-  return A.equals_lower(B);
-#else
-  return A == B;
-#endif
+bool pathIsAncestor(PathRef Ancestor, PathRef Path,
+llvm::sys::path::Style Style) {

sammccall wrote:
> we should decide what the preconditions are here
> 
> Could assert both are absolute paths, this places a burden on callers.
> 
> I do like the idea this is "just" a smarter lexical startswith. (I'd consider 
> pathStartsWith rather than pathIsAncestor for this reason)
> In this case we should doc it (e.g. foo/./bar is not an ancestor of 
> foo/bar/baz) and return false when Ancestor is empty (rather than crash)
oops nice catch. going with the latter option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96690

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2021-02-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping


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

https://reviews.llvm.org/D71726

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


[PATCH] D96195: [HIP] Fix managed variable linkage

2021-02-16 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping


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

https://reviews.llvm.org/D96195

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


[PATCH] D96178: [OpenCL] Create VoidPtrTy with generic AS in C++ for OpenCL mode

2021-02-16 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov updated this revision to Diff 324004.
azabaznov added a comment.

Fix clang-tidy warnings


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96178

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl


Index: clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -triple spir -cl-std=clc++ -emit-llvm -O0 -o - | 
FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+
+class A {
+public:
+  void* operator new(size_t);
+  void operator delete(void *ptr);
+};
+
+void test_new_delete(A **a) {
+// CHECK: %{{.*}} = call spir_func i8 addrspace(4)* @_ZNU3AS41AnwEj(i32 {{.*}})
+*a = new A;
+// CHECK: call spir_func void @_ZNU3AS41AdlEPU3AS4v(i8 addrspace(4)* {{.*}})
+delete *a;
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15261,11 +15261,13 @@
   return false;
 }
 
-static QualType
-RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy) {
-  QualType QTy = PtrTy->getPointeeType();
-  QTy = SemaRef.Context.removeAddrSpaceQualType(QTy);
-  return SemaRef.Context.getPointerType(QTy);
+static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef,
+ const PointerType *PtrTy) {
+  auto &Ctx = SemaRef.Context;
+  Qualifiers PtrQuals = PtrTy->getPointeeType().getQualifiers();
+  PtrQuals.removeAddressSpace();
+  return Ctx.getPointerType(Ctx.getCanonicalType(Ctx.getQualifiedType(
+  PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals)));
 }
 
 static inline bool
@@ -15277,11 +15279,14 @@
   QualType ResultType =
   FnDecl->getType()->castAs()->getReturnType();
 
-  // The operator is valid on any address space for OpenCL.
   if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
-if (auto *PtrTy = ResultType->getAs()) {
+// The operator is valid on any address space for OpenCL.
+// Drop address space from actual and expected result types.
+if (const auto *PtrTy = ResultType->getAs())
   ResultType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
-}
+
+if (auto ExpectedPtrTy = ExpectedResultType->getAs())
+  ExpectedResultType = RemoveAddressSpaceFromPtr(SemaRef, ExpectedPtrTy);
   }
 
   // Check that the result type is what we expect.
@@ -15311,10 +15316,14 @@
   QualType FirstParamType = FnDecl->getParamDecl(0)->getType();
   if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
 // The operator is valid on any address space for OpenCL.
-if (auto *PtrTy =
-FnDecl->getParamDecl(0)->getType()->getAs()) {
+// Drop address space from actual and expected first parameter types.
+if (const auto *PtrTy =
+FnDecl->getParamDecl(0)->getType()->getAs())
   FirstParamType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
-}
+
+if (auto ExpectedPtrTy = ExpectedFirstParamType->getAs())
+  ExpectedFirstParamType =
+  RemoveAddressSpaceFromPtr(SemaRef, ExpectedPtrTy);
   }
 
   // Check that the first parameter type is what we expect.
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -1445,7 +1445,7 @@
   ObjCSuperType = QualType();
 
   // void * type
-  if (LangOpts.OpenCLVersion >= 200) {
+  if (LangOpts.OpenCLGenericAddressSpace) {
 auto Q = VoidTy.getQualifiers();
 Q.setAddressSpace(LangAS::opencl_generic);
 VoidPtrTy = getPointerType(getCanonicalType(


Index: clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -triple spir -cl-std=clc++ -emit-llvm -O0 -o - | FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+
+class A {
+public:
+  void* operator new(size_t);
+  void operator delete(void *ptr);
+};
+
+void test_new_delete(A **a) {
+// CHECK: %{{.*}} = call spir_func i8 addrspace(4)* @_ZNU3AS41AnwEj(i32 {{.*}})
+*a = new A;
+// CHECK: call spir_func void @_ZNU3AS41AdlEPU3AS4v(i8 addrspace(4)* {{.*}})
+delete *a;
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15261,11 +15261,13 @@
   return false;
 }
 
-static QualType
-RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy) {
-  QualType QTy = PtrTy->getPointeeType();
-  QTy = SemaRef.Context.removeAddrSpaceQualType(QTy);
-  return SemaRef.Context.getPointerType(QTy);
+static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef,

[PATCH] D96178: [OpenCL] Create VoidPtrTy with generic AS in C++ for OpenCL mode

2021-02-16 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

Thanks for review. Last change is a small fix for if clang-tidy warnings


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96178

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


[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Could you somewhere explain why emit-llvm-bc is not enough? This simply reverts 
its introduction without saying why.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D96789: [OpenCL] Move printf declaration to opencl-c-base.h

2021-02-16 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
svenvh added a project: clang.
Herald added a subscriber: yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

Supporting `printf` with `-fdeclare-opencl-builtins` would require
special handling (for e.g. varargs and format attributes) for just
this one function.  Instead, move the `printf` declaration to the
shared base header.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96789

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Headers/opencl-c.h


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -14176,12 +14176,6 @@
 half16 __ovld __cnfn shuffle2(half16 x, half16 y, ushort16 mask);
 #endif //cl_khr_fp16
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
-// OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf
-
-int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 
2)));
-#endif
-
 // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write 
Functions
 
 #ifdef cl_khr_gl_msaa_sharing
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -460,6 +460,12 @@
 
 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0)
 
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
+// OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf
+
+int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 
2)));
+#endif
+
 #ifdef cl_intel_device_side_avc_motion_estimation
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : begin
 


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -14176,12 +14176,6 @@
 half16 __ovld __cnfn shuffle2(half16 x, half16 y, ushort16 mask);
 #endif //cl_khr_fp16
 
-#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
-// OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf
-
-int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));
-#endif
-
 // OpenCL v1.1 s6.11.3, v1.2 s6.12.14, v2.0 s6.13.14 - Image Read and Write Functions
 
 #ifdef cl_khr_gl_msaa_sharing
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -460,6 +460,12 @@
 
 #endif // defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 
+#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
+// OpenCL v1.2 s6.12.13, v2.0 s6.13.13 - printf
+
+int printf(__constant const char* st, ...) __attribute__((format(printf, 1, 2)));
+#endif
+
 #ifdef cl_intel_device_side_avc_motion_estimation
 #pragma OPENCL EXTENSION cl_intel_device_side_avc_motion_estimation : begin
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87146: [analyzer] Implement shared semantics checks for XNU functions in PthreadLockChecker

2021-02-16 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

Could you please give a few links to some documentation about the functions you 
are trying to model?
Is 
https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/synchronization/synchronization.html
 a legitimate resource for this?

It's really important to bake the proper semantic rules into the modeling.


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

https://reviews.llvm.org/D87146

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


[clang] 3c8bf29 - Reduce the number of attributes attached to each function

2021-02-16 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-02-16T16:19:54+01:00
New Revision: 3c8bf29f14e45cdf4c5dc5edcb3bb2f02cc9f394

URL: 
https://github.com/llvm/llvm-project/commit/3c8bf29f14e45cdf4c5dc5edcb3bb2f02cc9f394
DIFF: 
https://github.com/llvm/llvm-project/commit/3c8bf29f14e45cdf4c5dc5edcb3bb2f02cc9f394.diff

LOG: Reduce the number of attributes attached to each function

This takes advantage of the implicit default behavior to reduce the number of
attributes, which in turns reduces compilation time. I've observed -3% in
instruction count when compiling sqlite3 amalgamation with -O0

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/attr-target-x87-softfp.c
clang/test/CodeGenOpenCL/no-signed-zeros.cl
clang/test/CodeGenOpenCL/relaxed-fpmath.cl

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 42801372189b..405b4d2e1980 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1773,8 +1773,8 @@ void 
CodeGenModule::getDefaultFunctionAttributes(StringRef Name,
 }
 FuncAttrs.addAttribute("frame-pointer", FpKind);
 
-FuncAttrs.addAttribute("less-precise-fpmad",
-   llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));
+if (CodeGenOpts.LessPreciseFPMAD)
+  FuncAttrs.addAttribute("less-precise-fpmad", "true");
 
 if (CodeGenOpts.NullPointerIsValid)
   FuncAttrs.addAttribute(llvm::Attribute::NullPointerIsValid);
@@ -1788,9 +1788,8 @@ void 
CodeGenModule::getDefaultFunctionAttributes(StringRef Name,
   CodeGenOpts.FP32DenormalMode.str());
 }
 
-FuncAttrs.addAttribute("no-trapping-math",
-   llvm::toStringRef(LangOpts.getFPExceptionMode() ==
- LangOptions::FPE_Ignore));
+if (LangOpts.getFPExceptionMode() == LangOptions::FPE_Ignore)
+  FuncAttrs.addAttribute("no-trapping-math", "true");
 
 // Strict (compliant) code is the default, so only add this attribute to
 // indicate that we are trying to workaround a problem case.
@@ -1799,18 +1798,18 @@ void 
CodeGenModule::getDefaultFunctionAttributes(StringRef Name,
 
 // TODO: Are these all needed?
 // unsafe/inf/nan/nsz are handled by instruction-level FastMathFlags.
-FuncAttrs.addAttribute("no-infs-fp-math",
-   llvm::toStringRef(LangOpts.NoHonorInfs));
-FuncAttrs.addAttribute("no-nans-fp-math",
-   llvm::toStringRef(LangOpts.NoHonorNaNs));
-FuncAttrs.addAttribute("unsafe-fp-math",
-   llvm::toStringRef(LangOpts.UnsafeFPMath));
-FuncAttrs.addAttribute("use-soft-float",
-   llvm::toStringRef(CodeGenOpts.SoftFloat));
+if (LangOpts.NoHonorInfs)
+  FuncAttrs.addAttribute("no-infs-fp-math", "true");
+if (LangOpts.NoHonorNaNs)
+  FuncAttrs.addAttribute("no-nans-fp-math", "true");
+if (LangOpts.UnsafeFPMath)
+  FuncAttrs.addAttribute("unsafe-fp-math", "true");
+if (CodeGenOpts.SoftFloat)
+  FuncAttrs.addAttribute("use-soft-float", "true");
 FuncAttrs.addAttribute("stack-protector-buffer-size",
llvm::utostr(CodeGenOpts.SSPBufferSize));
-FuncAttrs.addAttribute("no-signed-zeros-fp-math",
-   llvm::toStringRef(LangOpts.NoSignedZero));
+if (LangOpts.NoSignedZero)
+  FuncAttrs.addAttribute("no-signed-zeros-fp-math", "true");
 
 // TODO: Reciprocal estimate codegen options should apply to instructions?
 const std::vector &Recips = CodeGenOpts.Reciprocals;

diff  --git a/clang/test/CodeGen/attr-target-x87-softfp.c 
b/clang/test/CodeGen/attr-target-x87-softfp.c
index 0d26dab74ec0..445e31280f84 100644
--- a/clang/test/CodeGen/attr-target-x87-softfp.c
+++ b/clang/test/CodeGen/attr-target-x87-softfp.c
@@ -8,9 +8,9 @@ int __attribute__((target("no-x87"))) bar(int a) { return 4; }
 // CHECK: bar{{.*}} #1
 
 // CHECK: #0 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87"
-// HARD: "use-soft-float"="false"
+// HARD-NOT: "use-soft-float"
 // SOFT: "use-soft-float"="true"
 
 // CHECK: #1 = {{.*}}"target-cpu"="x86-64" 
"target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,-x87"
-// HARD: "use-soft-float"="false"
+// HARD-NOT: "use-soft-float"
 // SOFT: "use-soft-float"="true"

diff  --git a/clang/test/CodeGenOpenCL/no-signed-zeros.cl 
b/clang/test/CodeGenOpenCL/no-signed-zeros.cl
index 5cbff4dd9e0c..13ce480ebe6e 100644
--- a/clang/test/CodeGenOpenCL/no-signed-zeros.cl
+++ b/clang/test/CodeGenOpenCL/no-signed-zeros.cl
@@ -6,5 +6,5 @@ float signedzeros(float a) {
 }
 
 // CHECK: attributes
-// NORMAL: "no-signed-zeros-fp-math"="false"
+// NORMAL-NOT: "no-signed-zeros-fp-math"
 // NO-SIGNED-ZEROS: "no-signed-zeros-fp-math"="true"

diff  --git a/clang/test/CodeGenOpenCL/r

[PATCH] D96400: Reduce the number of attributes attached to each function

2021-02-16 Thread serge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c8bf29f14e4: Reduce the number of attributes attached to 
each function (authored by serge-sans-paille).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96400

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/attr-target-x87-softfp.c
  clang/test/CodeGenOpenCL/no-signed-zeros.cl
  clang/test/CodeGenOpenCL/relaxed-fpmath.cl

Index: clang/test/CodeGenOpenCL/relaxed-fpmath.cl
===
--- clang/test/CodeGenOpenCL/relaxed-fpmath.cl
+++ clang/test/CodeGenOpenCL/relaxed-fpmath.cl
@@ -29,11 +29,11 @@
 }
 // CHECK: attributes
 
-// NORMAL: "less-precise-fpmad"="false"
-// NORMAL: "no-infs-fp-math"="false"
-// NORMAL: "no-nans-fp-math"="false"
-// NORMAL: "no-signed-zeros-fp-math"="false"
-// NORMAL: "unsafe-fp-math"="false"
+// NORMAL-NOT: "less-precise-fpmad"
+// NORMAL-NOT: "no-infs-fp-math"
+// NORMAL-NOT: "no-nans-fp-math"
+// NORMAL-NOT: "no-signed-zeros-fp-math"
+// NORMAL-NOT: "unsafe-fp-math"
 
 // FAST: "less-precise-fpmad"="true"
 // FAST: "no-infs-fp-math"="true"
@@ -41,29 +41,29 @@
 // FAST: "no-signed-zeros-fp-math"="true"
 // FAST: "unsafe-fp-math"="true"
 
-// FINITE: "less-precise-fpmad"="false"
+// FINITE-NOT: "less-precise-fpmad"
 // FINITE: "no-infs-fp-math"="true"
 // FINITE: "no-nans-fp-math"="true"
-// FINITE: "no-signed-zeros-fp-math"="false"
-// FINITE: "unsafe-fp-math"="false"
+// FINITE-NOT: "no-signed-zeros-fp-math"
+// FINITE-NOT: "unsafe-fp-math"
 
 // UNSAFE: "less-precise-fpmad"="true"
-// UNSAFE: "no-infs-fp-math"="false"
-// UNSAFE: "no-nans-fp-math"="false"
+// UNSAFE-NOT: "no-infs-fp-math"
+// UNSAFE-NOT: "no-nans-fp-math"
 // UNSAFE: "no-signed-zeros-fp-math"="true"
 // UNSAFE: "unsafe-fp-math"="true"
 
 // MAD: "less-precise-fpmad"="true"
-// MAD: "no-infs-fp-math"="false"
-// MAD: "no-nans-fp-math"="false"
-// MAD: "no-signed-zeros-fp-math"="false"
-// MAD: "unsafe-fp-math"="false"
+// MAD-NOT: "no-infs-fp-math"
+// MAD-NOT: "no-nans-fp-math"
+// MAD-NOT: "no-signed-zeros-fp-math"
+// MAD-NOT: "unsafe-fp-math"
 
-// NOSIGNED: "less-precise-fpmad"="false"
-// NOSIGNED: "no-infs-fp-math"="false"
-// NOSIGNED: "no-nans-fp-math"="false"
+// NOSIGNED-NOT: "less-precise-fpmad"
+// NOSIGNED-NOT: "no-infs-fp-math"
+// NOSIGNED-NOT: "no-nans-fp-math"
 // NOSIGNED: "no-signed-zeros-fp-math"="true"
-// NOSIGNED: "unsafe-fp-math"="false"
+// NOSIGNED-NOT: "unsafe-fp-math"
 
 #else
 // Undefine this to avoid putting it in the PCH.
Index: clang/test/CodeGenOpenCL/no-signed-zeros.cl
===
--- clang/test/CodeGenOpenCL/no-signed-zeros.cl
+++ clang/test/CodeGenOpenCL/no-signed-zeros.cl
@@ -6,5 +6,5 @@
 }
 
 // CHECK: attributes
-// NORMAL: "no-signed-zeros-fp-math"="false"
+// NORMAL-NOT: "no-signed-zeros-fp-math"
 // NO-SIGNED-ZEROS: "no-signed-zeros-fp-math"="true"
Index: clang/test/CodeGen/attr-target-x87-softfp.c
===
--- clang/test/CodeGen/attr-target-x87-softfp.c
+++ clang/test/CodeGen/attr-target-x87-softfp.c
@@ -8,9 +8,9 @@
 // CHECK: bar{{.*}} #1
 
 // CHECK: #0 = {{.*}}"target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87"
-// HARD: "use-soft-float"="false"
+// HARD-NOT: "use-soft-float"
 // SOFT: "use-soft-float"="true"
 
 // CHECK: #1 = {{.*}}"target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,-x87"
-// HARD: "use-soft-float"="false"
+// HARD-NOT: "use-soft-float"
 // SOFT: "use-soft-float"="true"
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1773,8 +1773,8 @@
 }
 FuncAttrs.addAttribute("frame-pointer", FpKind);
 
-FuncAttrs.addAttribute("less-precise-fpmad",
-   llvm::toStringRef(CodeGenOpts.LessPreciseFPMAD));
+if (CodeGenOpts.LessPreciseFPMAD)
+  FuncAttrs.addAttribute("less-precise-fpmad", "true");
 
 if (CodeGenOpts.NullPointerIsValid)
   FuncAttrs.addAttribute(llvm::Attribute::NullPointerIsValid);
@@ -1788,9 +1788,8 @@
   CodeGenOpts.FP32DenormalMode.str());
 }
 
-FuncAttrs.addAttribute("no-trapping-math",
-   llvm::toStringRef(LangOpts.getFPExceptionMode() ==
- LangOptions::FPE_Ignore));
+if (LangOpts.getFPExceptionMode() == LangOptions::FPE_Ignore)
+  FuncAttrs.addAttribute("no-trapping-math", "true");
 
 // Strict (compliant) code is the default, so only add this attribute to
 // indicate that we are trying to workaround a problem case.
@@ -1799,18 +1798,18 @@
 
 // TODO: Are these all needed?
 // unsafe/inf/nan/nsz are ha

[PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

2021-02-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D76342#2562097 , @Meinersbur wrote:

> Who is going to commit?

I can commit it as soon as you accepted it if you don't mind of course.




Comment at: clang/include/clang/AST/StmtOpenMP.h:651-677
+  static bool
+  doForAllLoops(Stmt *CurStmt, bool TryImperfectlyNestedLoops,
+unsigned NumLoops,
+llvm::function_ref Callback);
+  static bool
+  doForAllLoops(const Stmt *CurStmt, bool TryImperfectlyNestedLoops,
+unsigned NumLoops,

Meinersbur wrote:
> ABataev wrote:
> > Meinersbur wrote:
> > > ABataev wrote:
> > > > Meinersbur wrote:
> > > > > Please add doxygen comments.
> > > > > 
> > > > > IMHO, using callbacks makes the callers significantly more 
> > > > > complicated. Why not fill a SmallVectorImpl with the result?
> > > > It just hides all internal representation in the class and the 
> > > > user/caller should not worry about proper implementation of the loops 
> > > > processing. Consider it as a way to encapsulate representation details.
> > > That could also be done by returning and iterator/filling an array with 
> > > the requested data. The latter is one of the primary uses of 
> > > `SmallVectorImpl`.
> > > 
> > > coroutines should make returning an iterator much simpler, eventually 
> > > when we are allowed to use C++20.
> > I just prefer not to expose internals if they could be processed within the 
> > class instance.
> Using SmallVectorImpl for this is still the dominant style in clang. For 
> instance:
>  * Sema::getUndefinedButUsed
>  * Sema::FindHiddenVirtualMethods
>  * Sema::CollectMultipleMethodsInGlobalPool
>  * Sema::SelectBestMethod
>  * Sema::CollectIvarsToConstructOrDestruct
>  * Sema::collectUnexpandedParameterPacks
>  * Sema::FindProtocolDeclaration
>  * Sema::GatherArgumentsForCall
>  * Sema::GatherGlobalCodeCompletions
>  * Sema::getUndefinedButUsed
>  * ASTContext::getOverriddenMethods
>  * ASTContext::DeepCollectObjCIvars
>  * ASTContext::getInjectedTemplateArgs
> 
>  ...
> 
There is also another motivation behind this solution: to reuse the code as 
much as possible and avoid code duplication (loops to process inner 
loops/bodies) and focus just on loops/bodies processing.



Comment at: clang/include/clang/AST/StmtOpenMP.h:659
+llvm::function_ref Callback) {
+auto &&NewCallback = [Callback](unsigned Cnt, Stmt *CurStmt) {
+  return Callback(Cnt, CurStmt);

Meinersbur wrote:
> ABataev wrote:
> > Meinersbur wrote:
> > > ABataev wrote:
> > > > Meinersbur wrote:
> > > > > I do not see why making this a forwarding reference.
> > > > There is a type mismatch in callback types, `Stmt *` and `const Stmt *`
> > > I understand why the additional lambda is needed, but wondered about why 
> > > the declaration is not
> > > ```
> > > auto NewCallback = [Callback](unsigned Cnt, Stmt *CurStmt) { 
> > > ```
> > > 
> > I believe it just saves us from the extra constructor call.
> It does not: https://godbolt.org/z/81ac7o
Yes, currently it is not, it was before. But even now there is a difference in 
AST:
  `-CompoundStmt 
|-DeclStmt 
| `-VarDecl  line:4:17 used Lambda '(lambda at 
line:4:26)':'(lambda at line:4:26)' cinit
|   `-ExprWithCleanups  '(lambda at line:4:26)':'(lambda 
at line:4:26)'
| `-CXXConstructExpr  '(lambda at 
line:4:26)':'(lambda at line:4:26)' 'void ((lambda at line:4:26) &&) noexcept' 
elidable
|   `-MaterializeTemporaryExpr  '(lambda at 
line:4:26)' xvalue



With `&&`:
  `-CompoundStmt 
|-DeclStmt 
| `-VarDecl  line:4:17 used Lambda '(lambda at 
line:4:26) &&' cinit
|   `-ExprWithCleanups  '(lambda at line:4:26)' xvalue
| `-MaterializeTemporaryExpr  '(lambda at 
line:4:26)' xvalue extended by Var 0x562226678ad8 'Lambda' '(lambda at 
line:4:26) &&'

Just the constructor call is marked as elidable and is not emitted anymore, but 
it still saves some memory/time because we don't need to emit an extra AST node.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76342

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


[PATCH] D96719: [clang-tidy] Add new check 'bugprone-thread-canceltype-asynchronous' and alias 'cert-pos47-c'.

2021-02-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp:169
 "bugprone-terminating-continue");
+CheckFactories.registerCheck(
+"bugprone-thread-canceltype-asynchronous");

I think this check is likely better surfaced in the `concurrency` module. WDYT?



Comment at: 
clang-tools-extra/clang-tidy/bugprone/ThreadCanceltypeAsynchronousCheck.cpp:29
+
+static Preprocessor *PP;
+

Any particular reason to use a global variable here rather than making it a 
member of `ThreadCanceltypeAsynchronousCheck`?



Comment at: 
clang-tools-extra/clang-tidy/bugprone/ThreadCanceltypeAsynchronousCheck.cpp:34
+  if (!PthreadCancelAsynchronousValue) {
+const auto IsAsynchronous = [](const auto &KeyValue) -> bool {
+  return KeyValue.first->getName() == "PTHREAD_CANCEL_ASYNCHRONOUS" &&

We don't use top-level `const` on local value types (here and elsewhere in the 
patch).



Comment at: 
clang-tools-extra/clang-tidy/bugprone/ThreadCanceltypeAsynchronousCheck.cpp:38
+};
+const auto TryExpandAsInteger =
+[](Preprocessor::macro_iterator It) -> Optional {

Do we know that POSIX implementations always use a simple integer here, or do 
we have to worry about code like:
```
#define PTHREAD_CANCEL_ASYNCHRONOUS (1 << 0)
```
or
```
#define PTHREAD_CANCEL_ASYNCHRONOUS SOME_OTHER_MACRO
```



Comment at: 
clang-tools-extra/clang-tidy/bugprone/ThreadCanceltypeAsynchronousCheck.cpp:68
+diag(MatchedExpr->getBeginLoc(),
+ "asynchronous cancelability type should not be used");
+  }

How about: `the cancel type for a pthread should not be 
'PTHREAD_CANCEL_ASYNCHRONOUS'`?



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-thread-canceltype-asynchronous.rst:9
+(``PTHREAD_CANCEL_ASYNCHRONOUS``) is generally unsafe, use type
+``PTHREAD_CANCEL_DEFERRED`` instead which is the default. Even with deferred
+cancellation, a cancellation point in an asynchronous signal handler may still




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96719

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-02-16 Thread Stefan Gränitz via Phabricator via cfe-commits
sgraenitz added a subscriber: anarazel.
sgraenitz added a comment.

Hi Vassil, thanks for upstreaming this! I think it goes into a good direction.

The last time I looked at the Cling sources downstream, it was based on LLVM 
release 5.0. The IncrementalJIT class was based on what we call OrcV1 today. 
OrcV1 is long deprecated and even though it's still in tree today, it will very 
likely be removed in the upcoming release cycle. So I guess, one of the 
challenges will be porting the Cling internals to OrcV2 -- a lot has changed, 
mostly to the better :) Not all of this is relevant for this patch, but maybe 
it's worth mentioning for upcoming additions.

OrcV2 works with Dylibs, basically symbol namespaces. When you add a module to 
a Dylib, all its symbols will be added. Respectively, if you want to remove 
something from a Dylib, you have to remove the symbols (for fine-tuning it you 
can reach for a Dylib's ResourceTracker). Symbols won't be materialized until 
you look them up. I guess for incremental compilation you would keep on adding 
symbols, one increment at a time.

  int var1 = 42; int f() { return var1; }
  int var2 = f();

Let's say these are two inputs. The first line only adds definitions for 
symbols `var1` and `f()` but won't materialize anything. The second line would 
have to lookup `f()`, execute it and emit a new definition for `var2`. I never 
got into Cling deep enough to find out how it works, but I assume it's 
high-level enough that it won't require large changes. One thing I'd recommend 
to double-check: if there is a third line that adds a static constructor, will 
LLJIT only run this one or will it run all previous static ctors again when 
calling `initialize()`? I assume the former but I wouldn't bet on it.

Another aspect is that downstream Cling is based on RuntimeDyld for linking 
Orc's output object files. I remember RemovableObjectLinkingLayer adding some 
object file removal code. Upstream OrcV2 grew it's own linker in the meantime. 
It's called JITLink and gets pulled into LLJIT via `ObjectLinkingLayer`. 
RuntimeDyld-based linking is still supported with the 
`RTDyldObjectLinkingLayer`. JITLink is not complete for all platforms yet. 
Thus, LLJITBuilder defaults to JITLink on macOS and RuntimeDyld otherwise. 
Chances are that JITLink gets good enough for ELF to enable it by default on 
Linux (at least x86-64). I guess that's your platform of concern? The related 
question is whether you are aiming for JITLink straight away or staying with 
RuntimeDyld for now.

For the moment, I added a few pointers inline. Some are referring to my general 
comments above.




Comment at: clang/lib/CodeGen/CodeGenAction.cpp:908
 
+CodeGenerator *CodeGenAction::getCodeGenerator() const {
+  return BEConsumer->getCodeGenerator();

v.g.vassilev wrote:
> @rjmccall, we were wondering if there is a better way to ask CodeGen to start 
> a new module. The current approach seems to be drilling hole in a number of 
> abstraction layers.
> 
> In the past we have touched that area a little in 
> https://reviews.llvm.org/D3 and the answer may be already there but I 
> fail to connect the dots.
> 
> Recently, we thought about having a new FrontendAction callback for beginning 
> a new phase when compiling incremental input. We need to keep track of the 
> created objects (needed for error recovery) in our Transaction. We can have a 
> map of `Transaction*` to `llvm::Module*` in CodeGen. The issue is that new 
> JITs take ownership of the `llvm::Module*` which seems to make it impossible 
> to support jitted code removal with that model (cc: @lhames, @rsmith).
When compiling incrementally, doeas a "new phase" mean that all subsequent code 
will go into a new module from then on? How will dependencies to previous 
symbols be handled? Are all symbols external?

> The issue is that new JITs take ownership of the llvm::Module*

That's true, but you can still keep a raw pointer to it, which will be valid at 
least as long as the module wasn't linked. Afterwards it depends on the linker:
* RuntimeDyld can return ownership of the object's memory range via 
`NotifyEmittedFunction`
* JITLink provides the `ReturnObjectBufferFunction` for the same purpose

> seems to make it impossible to support jitted code removal with that model

Can you figure out what symbols are affected and remove these? A la: 
https://github.com/llvm/llvm-project/blob/13f4448ae7db1a47/llvm/include/llvm/ExecutionEngine/Orc/Core.h#L1020

I think @anarazel has ported a client with code removal to OrcV2 successfully 
in the past. Maybe there's something we can learn from it.



Comment at: clang/lib/Interpreter/IncrementalExecutor.h:36
+  llvm::Error addModule(std::unique_ptr M);
+  llvm::Error runCtors() const;
+};

v.g.vassilev wrote:
> teemperor wrote:
> > Should we maybe merge `runCtors` and `addModule`? Not sure if there is a 
> > use case for adding a Module but not ru

[PATCH] D96784: Pass the cmdline aapcs bitfield options to cc1

2021-02-16 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

Looks ok but needs tests. See clang/test/Driver for examples of checking -### 
output.




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1525
 
+void AddAAPCSVolatileBitfieldArgs(const ArgList &Args, ArgStringList &CmdArgs) 
{
+  if (!Args.hasFlag(options::OPT_faapcs_bitfield_width,

Name this AddARMAAPCSVolatileBitfieldArgs to match the other helpers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96784

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


[PATCH] D96717: [clangd] Bind outgoing calls through LSPBinder too. NFC

2021-02-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 2 inline comments as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/LSPBinder.h:88
+  template 
+  void outgoingMethod(llvm::StringLiteral Method,
+  OutgoingMethod &Handler) {

kadircet wrote:
> well this one filling an out-parameter definitely tripped me over while 
> reading the code a couple times, and once more on the tests.
> 
> what about making this return the handler instead? E.g. `Edit = 
> Bind.outgoingMethod("edit")`, I know it is ugly that 
> we duplicate template params on declaration + here now. Maybe we can get away 
> by making `OutgoingMethod` a class with a call operator and a `RawOutgoing 
> *Out` member that can be bound later on ? e.g:
> 
> ```
> template 
> class OutgoingMethod {
>   RawOutgoing *Out = nullptr;
> public:
>   void operator()(const P& Params, Callback CB) {
> assert(Out && "Method haven't bound");
> Out->callMethod(Method, JSON(Params), );
>   }
> };
> ```
> 
> then we either make LSPBinder a friend of OutgoingMethod and set Out through 
> it, or the other way around and have a `OutgoingMethod::bindOut(LSPBinder&)` ?
> 
> not sure if it is any better though, as we still construct a somewhat invalid 
> object :/
> well this one filling an out-parameter definitely tripped me over while 
> reading the code a couple times, and once more on the tests.

Yup. My feeling is the wins are:
 - avoid writing the types over and over (we can't really avoid it on the 
instance variable)
 - resembles syntax for binding incoming things

And the main loss is definitely that we're not using assignment syntax for 
assignment.

> what about making this return the handler instead? E.g. Edit = 
> Bind.outgoingMethod("edit")

This is a reasonable alternative, as you say the duplication is the downside.

> Maybe we can get away by making OutgoingMethod a class with a call operator

Yeah, I don't really understand what this achieves - the usage looks the same, 
just now the logical assignment doesn't use assignment syntax *or* assignment 
semantics :-)

Other ideas I had:
 - the object is untyped, and the call operator is templated/typed - no 
type-safety at callsite, yuck
 - `outgoingMethod` returns an untyped proxy object with a template conversion 
operator to unique_function. This gives us assignment syntax... and 
horrible compiler errors on mismatch.

I'm going to try the latter out to see how bad it is.



Comment at: clang-tools-extra/clangd/LSPBinder.h:93
+  Method, JSON(R),
+  // FIXME: why keep ctx alive but not restore it for the callback?
+  [Reply(std::move(Reply)), Ctx(Context::current().clone()),

kadircet wrote:
> haha feels like confusing `Context` and `WithContext` issue i talked about 
> yesterday :D
Exactly. I'm fairly sure we need a WithContext here but don't want to risk 
changing it at the same time.



Comment at: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp:237
+  Value += X;
+  Changed(Value);
+}

whoops, after rebasing against 40cc63ea6eec7874d3a358f9fa549ef2f6543512 this 
uncovered a bug - we're testing the public API from the wrong thread (server 
thread != main thread).

So I've had to remove that test in this patch. We can test public APIs again in 
D96755.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96717

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


[PATCH] D96717: [clangd] Bind outgoing calls through LSPBinder too. NFC

2021-02-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 324012.
sammccall marked an inline comment as done.
sammccall added a comment.

rebase & address comments (except bind out API, still to come)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96717

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/LSPBinder.h
  clang-tools-extra/clangd/Module.h
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
  clang-tools-extra/clangd/unittests/LSPBinderTests.cpp

Index: clang-tools-extra/clangd/unittests/LSPBinderTests.cpp
===
--- clang-tools-extra/clangd/unittests/LSPBinderTests.cpp
+++ clang-tools-extra/clangd/unittests/LSPBinderTests.cpp
@@ -15,12 +15,15 @@
 namespace clangd {
 namespace {
 
+using testing::ElementsAre;
 using testing::HasSubstr;
+using testing::IsEmpty;
 using testing::UnorderedElementsAre;
 
 // JSON-serializable type for testing.
 struct Foo {
   int X;
+  friend bool operator==(Foo A, Foo B) { return A.X == B.X; }
 };
 bool fromJSON(const llvm::json::Value &V, Foo &F, llvm::json::Path P) {
   return fromJSON(V, F.X, P.field("X"));
@@ -35,9 +38,31 @@
   return [&Out](llvm::Expected V) { Out.emplace(std::move(V)); };
 }
 
+struct OutgoingRecorder : public LSPBinder::RawOutgoing {
+  llvm::StringMap> Received;
+
+  void callMethod(llvm::StringRef Method, llvm::json::Value Params,
+  Callback Reply) override {
+Received[Method].push_back(Params);
+if (Method == "fail")
+  return Reply(error("Params={0}", Params));
+Reply(Params); // echo back the request
+  }
+  void notify(llvm::StringRef Method, llvm::json::Value Params) override {
+Received[Method].push_back(std::move(Params));
+  }
+
+  std::vector take(llvm::StringRef Method) {
+std::vector Result = Received.lookup(Method);
+Received.erase(Method);
+return Result;
+  }
+};
+
 TEST(LSPBinderTest, IncomingCalls) {
   LSPBinder::RawHandlers RawHandlers;
-  LSPBinder Binder{RawHandlers};
+  OutgoingRecorder RawOutgoing;
+  LSPBinder Binder{RawHandlers, RawOutgoing};
   struct Handler {
 void plusOne(const Foo &Params, Callback Reply) {
   Reply(Foo{Params.X + 1});
@@ -94,7 +119,45 @@
   RawCmdPlusOne(1, capture(Reply));
   ASSERT_TRUE(Reply.hasValue());
   EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(2));
+
+  // None of this generated any outgoing traffic.
+  EXPECT_THAT(RawOutgoing.Received, IsEmpty());
+}
+
+TEST(LSPBinderTest, OutgoingCalls) {
+  LSPBinder::RawHandlers RawHandlers;
+  OutgoingRecorder RawOutgoing;
+  LSPBinder Binder{RawHandlers, RawOutgoing};
+
+  LSPBinder::OutgoingMethod Echo;
+  Binder.outgoingMethod("echo", Echo);
+  LSPBinder::OutgoingMethod WrongSignature;
+  Binder.outgoingMethod("wrongSignature", WrongSignature);
+  LSPBinder::OutgoingMethod Fail;
+  Binder.outgoingMethod("fail", Fail);
+
+  llvm::Optional> Reply;
+  Echo(Foo{2}, capture(Reply));
+  EXPECT_THAT(RawOutgoing.take("echo"), ElementsAre(llvm::json::Value(2)));
+  ASSERT_TRUE(Reply.hasValue());
+  EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(Foo{2}));
+
+  // JSON response is integer, can't be parsed as string.
+  llvm::Optional> WrongTypeReply;
+  WrongSignature(Foo{2}, capture(WrongTypeReply));
+  EXPECT_THAT(RawOutgoing.take("wrongSignature"),
+  ElementsAre(llvm::json::Value(2)));
+  ASSERT_TRUE(Reply.hasValue());
+  EXPECT_THAT_EXPECTED(WrongTypeReply.getValue(),
+   llvm::FailedWithMessage(
+   HasSubstr("failed to decode wrongSignature reply")));
+
+  Fail(Foo{2}, capture(Reply));
+  EXPECT_THAT(RawOutgoing.take("fail"), ElementsAre(llvm::json::Value(2)));
+  ASSERT_TRUE(Reply.hasValue());
+  EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::FailedWithMessage("Params=2"));
 }
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -23,6 +23,7 @@
 namespace clang {
 namespace clangd {
 namespace {
+using testing::ElementsAre;
 
 MATCHER_P(DiagMessage, M, "") {
   if (const auto *O = arg.getAsObject()) {
@@ -223,16 +224,20 @@
 
 TEST_F(LSPTest, ModulesTest) {
   class MathModule final : public Module {
+OutgoingNotification Changed;
 void initializeLSP(LSPBinder &Bind, const llvm::json::Object &ClientCaps,
llvm::json::Object &ServerCaps) override {
   Bind.notification("add", this, &MathModule::add);
   Bind.method("get", this, &MathModule::get);
+  Bind.outgoingNotification("changed", Changed);
 }
 
 int Value = 0;
 
-  public:
-void add(const int &X) { Value += X; }
+void add(const

[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-16 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added a comment.

emit-llvm-bc does not correctly solve the problem. It works because [input, 
compile, assemble, backend] actions collapse to a single action by driver. This 
single command handles emit-llvm-bc properly. But when save-temps is specified, 
this collapsing does not happen which messes up command line flags of the jobs 
and hence the output, for e.g., preprocessor command also has -emit-llvm-bc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-16 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Perhaps paraphrase that and add it to the commit message (which is derived from 
the text at the top of this page)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D96719: [clang-tidy] Add new check 'bugprone-thread-canceltype-asynchronous' and alias 'cert-pos47-c'.

2021-02-16 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 324013.
balazske added a comment.

Adding missed alias to CERT module.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96719

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/ThreadCanceltypeAsynchronousCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ThreadCanceltypeAsynchronousCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-thread-canceltype-asynchronous.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-pos47-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-thread-canceltype-asynchronous.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-thread-canceltype-asynchronous.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-thread-canceltype-asynchronous.cpp
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s bugprone-thread-canceltype-asynchronous %t
+
+#define PTHREAD_CANCEL_DEFERRED 0
+#define PTHREAD_CANCEL_ASYNCHRONOUS 1
+
+int pthread_setcanceltype(int type, int *oldtype);
+
+int main() {
+  int result, oldtype;
+
+  if ((result = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype)) != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: asynchronous cancelability type should not be used [bugprone-thread-canceltype-asynchronous]
+return 1;
+  }
+
+  if ((result = pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype)) != 0) {
+return 1;
+  }
+
+  return 0;
+}
+
+int f() {
+  int result, oldtype;
+
+  if ((result = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype)) != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: asynchronous cancelability type should not be used [bugprone-thread-canceltype-asynchronous]
+return 1;
+  }
+
+  return 0;
+}
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
@@ -95,6 +95,7 @@
`bugprone-suspicious-string-compare `_, "Yes"
`bugprone-swapped-arguments `_, "Yes"
`bugprone-terminating-continue `_, "Yes"
+   `bugprone-thread-canceltype-asynchronous `_, "No"
`bugprone-throw-keyword-missing `_,
`bugprone-too-small-loop-variable `_,
`bugprone-undefined-memory-manipulation `_,
@@ -334,6 +335,7 @@
`cert-oop11-cpp `_, `performance-move-constructor-init `_, "Yes"
`cert-oop54-cpp `_, `bugprone-unhandled-self-assignment `_,
`cert-pos44-c `_, `bugprone-bad-signal-to-kill-thread `_,
+   `cert-pos47-c `_, `bugprone-thread-canceltype-asynchronous `_,
`cert-str34-c `_, `bugprone-signed-char-misuse `_,
`clang-analyzer-core.CallAndMessage `_, `Clang Static Analyzer `_,
`clang-analyzer-core.DivideZero `_, `Clang Static Analyzer `_,
Index: clang-tools-extra/docs/clang-tidy/checks/cert-pos47-c.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cert-pos47-c.rst
@@ -0,0 +1,9 @@
+.. title:: clang-tidy - cert-pos47-c
+.. meta::
+   :http-equiv=refresh: 5;URL=bugprone-thread-canceltype-asynchronous.html
+
+cert-pos47-c
+
+
+The cert-pos47-c check is an alias, please see
+`bugprone-thread-canceltype-asynchronous `_ for more information.
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-thread-canceltype-asynchronous.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-thread-canceltype-asynchronous.rst
@@ -0,0 +1,19 @@
+.. title:: clang-tidy - bugprone-thread-canceltype-asynchronous
+
+bugprone-thread-canceltype-asynchronous
+===
+
+Finds ``pthread_setcanceltype`` function calls where a thread's cancellation
+type is set to asynchronous. Asynchronous cancellation type
+(``PTHREAD_CANCEL_ASYNCHRONOUS``) is generally unsafe, use type
+``PTHREAD_CANCEL_DEFERRED`` instead which is the default. Even with deferred
+cancellation, a cancellation point in an asynchronous signal handler may still
+be acted upon and the effect is as if it was an asynchronous cancellation.
+
+.. code-block: c++
+
+  pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldtype);
+
+This check corresponds to the CERT C Coding Standard rule
+`POS47-C. Do not use threads that can be canceled asynchronously
+`_.
Index: clang-tools-extra

[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D96769#2565751 , @pdhaliwal wrote:

> emit-llvm-bc does not correctly solve the problem. It works because [input, 
> compile, assemble, backend] actions collapse to a single action by driver. 
> This single command handles emit-llvm-bc properly. But when save-temps is 
> specified, this collapsing does not happen which messes up command line flags 
> of the jobs and hence the output, for e.g., preprocessor command also has 
> -emit-llvm-bc.

Is this the intended behavior of -save-temps + -emit-llvm-bc or an accident? 
What exactly happens when both are specified and what is the problem. Maybe we 
should fix that instead of working around it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D88220: [C++20] P1825R0: More implicit moves

2021-02-16 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone accepted this revision.
Quuxplusone added a comment.
This revision is now accepted and ready to land.

> either way I'm a dead end — I don't consider myself authorized to "accept" 
> Clang changes.
> You're still going to have to attract the attention of someone with the 
> authority and/or force-of-will to say "okay ship it."

Well, it's been a month since I said that. I'll land this tonight, unless 
someone yells "stop" before then. If it causes any problems, we can revert it 
easy enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88220

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


[PATCH] D96716: [flang][driver] Add debug dump options

2021-02-16 Thread Faris Rehman via Phabricator via cfe-commits
FarisRehman added inline comments.



Comment at: flang/include/flang/Frontend/FrontendActions.h:54
+public:
+  std::unique_ptr semantics_;
 };

awarzynski wrote:
> Do we need to expose it? Shouldn't this be private?
It will not compile if the variable is private as it needs to be referenced in 
the implementation of ExecuteAction, e.g. 
`DebugDumpParseTreeAction::ExecuteAction()`
It will compile if set to `protected` or `public`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96716

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


[PATCH] D96771: [OpenCL] Add distinct file extension for C++ for OpenCL

2021-02-16 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added a comment.

I feel this would be a valuable addition, indeed. Only a minor question from me.




Comment at: clang/lib/Driver/Types.cpp:265
.Case("cl", TY_CL)
+   .Case("clcpp", TY_CLCXX)
.Case("cp", TY_CXX)

I'm not sure we want that -- I'm actually fine if we don't -- but I see below 
`c++` and `cxx` are supported in addition to `cpp`. Should we therefore also 
have `clc++` and `clcxx` as file valid extensions for consistency? I wonder 
what the general opinion is.


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

https://reviews.llvm.org/D96771

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


[PATCH] D94673: [analyzer][CTU] API for CTU macro expansions

2021-02-16 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

LGTM! You may wanna wait for someone more knowledgeable about CTU to give it 
another accept.


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

https://reviews.llvm.org/D94673

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


[PATCH] D96769: [OpenMP][AMDGPU] Skip backend and assemble phases for amdgcn

2021-02-16 Thread Pushpinder Singh via Phabricator via cfe-commits
pdhaliwal added a comment.

It is because of how addClangTargetOptions is invoked. In case of save-temps, 
it is being invoked for all the actions resulting in target cc1 call. That's 
why all these invocations have -emit-llvm-bc. I guess we need Action as an 
argument to addClangTargetOptions.

Also, it does not make sense for having assemble and backend action for amdgcn 
as linker is dependent directly on llvm IR. They will also come up redundantly 
in the -ccc-print-phases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D95790: [clang][cli] Documentation of CompilerInvocation parsing/generation

2021-02-16 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

Needs an example in the "Creating new Command Line Option" section, but with 
that it looks good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95790

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


[PATCH] D96771: [OpenCL] Add distinct file extension for C++ for OpenCL

2021-02-16 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added inline comments.



Comment at: clang/lib/Driver/Types.cpp:265
.Case("cl", TY_CL)
+   .Case("clcpp", TY_CLCXX)
.Case("cp", TY_CXX)

mantognini wrote:
> I'm not sure we want that -- I'm actually fine if we don't -- but I see below 
> `c++` and `cxx` are supported in addition to `cpp`. Should we therefore also 
> have `clc++` and `clcxx` as file valid extensions for consistency? I wonder 
> what the general opinion is.
And there is also `.cc` above.  Since you're asking for opinions, my personal 
opinion is that one extension should be enough, and providing a CL counterpart 
for all existing C++ file extensions does not bring more value.


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

https://reviews.llvm.org/D96771

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


[PATCH] D96717: [clangd] Bind outgoing calls through LSPBinder too. NFC

2021-02-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 324025.
sammccall added a comment.

OK, the awful proxy object thing works :-)
It requires a SFINAE fix to unique_function though, which i'll send separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96717

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/LSPBinder.h
  clang-tools-extra/clangd/Module.h
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
  clang-tools-extra/clangd/unittests/LSPBinderTests.cpp

Index: clang-tools-extra/clangd/unittests/LSPBinderTests.cpp
===
--- clang-tools-extra/clangd/unittests/LSPBinderTests.cpp
+++ clang-tools-extra/clangd/unittests/LSPBinderTests.cpp
@@ -15,12 +15,15 @@
 namespace clangd {
 namespace {
 
+using testing::ElementsAre;
 using testing::HasSubstr;
+using testing::IsEmpty;
 using testing::UnorderedElementsAre;
 
 // JSON-serializable type for testing.
 struct Foo {
   int X;
+  friend bool operator==(Foo A, Foo B) { return A.X == B.X; }
 };
 bool fromJSON(const llvm::json::Value &V, Foo &F, llvm::json::Path P) {
   return fromJSON(V, F.X, P.field("X"));
@@ -35,9 +38,31 @@
   return [&Out](llvm::Expected V) { Out.emplace(std::move(V)); };
 }
 
+struct OutgoingRecorder : public LSPBinder::RawOutgoing {
+  llvm::StringMap> Received;
+
+  void callMethod(llvm::StringRef Method, llvm::json::Value Params,
+  Callback Reply) override {
+Received[Method].push_back(Params);
+if (Method == "fail")
+  return Reply(error("Params={0}", Params));
+Reply(Params); // echo back the request
+  }
+  void notify(llvm::StringRef Method, llvm::json::Value Params) override {
+Received[Method].push_back(std::move(Params));
+  }
+
+  std::vector take(llvm::StringRef Method) {
+std::vector Result = Received.lookup(Method);
+Received.erase(Method);
+return Result;
+  }
+};
+
 TEST(LSPBinderTest, IncomingCalls) {
   LSPBinder::RawHandlers RawHandlers;
-  LSPBinder Binder{RawHandlers};
+  OutgoingRecorder RawOutgoing;
+  LSPBinder Binder{RawHandlers, RawOutgoing};
   struct Handler {
 void plusOne(const Foo &Params, Callback Reply) {
   Reply(Foo{Params.X + 1});
@@ -94,7 +119,45 @@
   RawCmdPlusOne(1, capture(Reply));
   ASSERT_TRUE(Reply.hasValue());
   EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(2));
+
+  // None of this generated any outgoing traffic.
+  EXPECT_THAT(RawOutgoing.Received, IsEmpty());
+}
+
+TEST(LSPBinderTest, OutgoingCalls) {
+  LSPBinder::RawHandlers RawHandlers;
+  OutgoingRecorder RawOutgoing;
+  LSPBinder Binder{RawHandlers, RawOutgoing};
+
+  LSPBinder::OutgoingMethod Echo;
+  Echo = Binder.outgoingMethod("echo");
+  LSPBinder::OutgoingMethod WrongSignature;
+  WrongSignature = Binder.outgoingMethod("wrongSignature");
+  LSPBinder::OutgoingMethod Fail;
+  Fail = Binder.outgoingMethod("fail");
+
+  llvm::Optional> Reply;
+  Echo(Foo{2}, capture(Reply));
+  EXPECT_THAT(RawOutgoing.take("echo"), ElementsAre(llvm::json::Value(2)));
+  ASSERT_TRUE(Reply.hasValue());
+  EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(Foo{2}));
+
+  // JSON response is integer, can't be parsed as string.
+  llvm::Optional> WrongTypeReply;
+  WrongSignature(Foo{2}, capture(WrongTypeReply));
+  EXPECT_THAT(RawOutgoing.take("wrongSignature"),
+  ElementsAre(llvm::json::Value(2)));
+  ASSERT_TRUE(Reply.hasValue());
+  EXPECT_THAT_EXPECTED(WrongTypeReply.getValue(),
+   llvm::FailedWithMessage(
+   HasSubstr("failed to decode wrongSignature reply")));
+
+  Fail(Foo{2}, capture(Reply));
+  EXPECT_THAT(RawOutgoing.take("fail"), ElementsAre(llvm::json::Value(2)));
+  ASSERT_TRUE(Reply.hasValue());
+  EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::FailedWithMessage("Params=2"));
 }
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -23,6 +23,7 @@
 namespace clang {
 namespace clangd {
 namespace {
+using testing::ElementsAre;
 
 MATCHER_P(DiagMessage, M, "") {
   if (const auto *O = arg.getAsObject()) {
@@ -223,16 +224,20 @@
 
 TEST_F(LSPTest, ModulesTest) {
   class MathModule final : public Module {
+OutgoingNotification Changed;
 void initializeLSP(LSPBinder &Bind, const llvm::json::Object &ClientCaps,
llvm::json::Object &ServerCaps) override {
   Bind.notification("add", this, &MathModule::add);
   Bind.method("get", this, &MathModule::get);
+  Changed = Bind.outgoingNotification("changed");
 }
 
 int Value = 0;
 
-  public:
-void add(const int &X) { Value += X; }

[PATCH] D87519: [analyzer][Liveness][NFC] Enqueue the CFGBlocks post-order

2021-02-16 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

What about analyzing a Sema translation unit? That should be beefy enough to 
have a longer runtime.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87519

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


[PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

2021-02-16 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D76342#2565686 , @ABataev wrote:

> I can commit it as soon as you accepted it if you don't mind of course.

I do not mind


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76342

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


[PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

2021-02-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D76342#2565945 , @Meinersbur wrote:

> In D76342#2565686 , @ABataev wrote:
>
>> I can commit it as soon as you accepted it if you don't mind of course.
>
> I do not mind

Ok, will commit it in a few minutes, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76342

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


[clang] 1a323c8 - [analyzer] Fix a warning

2021-02-16 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-02-16T09:12:07-08:00
New Revision: 1a323c8a96afc53ef965a4268cd419cfde2f1890

URL: 
https://github.com/llvm/llvm-project/commit/1a323c8a96afc53ef965a4268cd419cfde2f1890
DIFF: 
https://github.com/llvm/llvm-project/commit/1a323c8a96afc53ef965a4268cd419cfde2f1890.diff

LOG: [analyzer] Fix a warning

This patch fixes a warning from -Wcovered-switch-default.  The switch
statement in question handles all the enum values.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/SValBuilder.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp 
b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
index 4b146d83c194..a47a28e1e866 100644
--- a/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -560,9 +560,9 @@ SVal SValBuilder::evalCast(SVal V, QualType CastTy, 
QualType OriginalTy) {
 return evalCastKind(V.castAs(), CastTy, OriginalTy);
   case SVal::NonLocKind:
 return evalCastKind(V.castAs(), CastTy, OriginalTy);
-  default:
-llvm_unreachable("Unknown SVal kind");
   }
+
+  llvm_unreachable("Unknown SVal kind");
 }
 
 SVal SValBuilder::evalCastKind(UndefinedVal V, QualType CastTy,



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


[PATCH] D96717: [clangd] Bind outgoing calls through LSPBinder too. NFC

2021-02-16 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.

thanks! can't wait for the unique_function sfinae fix :)




Comment at: clang-tools-extra/clangd/LSPBinder.h:185
+
+LSPBinder::UntypedOutgoingNotification inline LSPBinder::outgoingNotification(
+llvm::StringLiteral Method) {

maybe put `inline` at the start of the declaration ? :D



Comment at: clang-tools-extra/clangd/LSPBinder.h:88
+  template 
+  void outgoingMethod(llvm::StringLiteral Method,
+  OutgoingMethod &Handler) {

sammccall wrote:
> kadircet wrote:
> > well this one filling an out-parameter definitely tripped me over while 
> > reading the code a couple times, and once more on the tests.
> > 
> > what about making this return the handler instead? E.g. `Edit = 
> > Bind.outgoingMethod("edit")`, I know it is ugly 
> > that we duplicate template params on declaration + here now. Maybe we can 
> > get away by making `OutgoingMethod` a class with a call operator and a 
> > `RawOutgoing *Out` member that can be bound later on ? e.g:
> > 
> > ```
> > template 
> > class OutgoingMethod {
> >   RawOutgoing *Out = nullptr;
> > public:
> >   void operator()(const P& Params, Callback CB) {
> > assert(Out && "Method haven't bound");
> > Out->callMethod(Method, JSON(Params), );
> >   }
> > };
> > ```
> > 
> > then we either make LSPBinder a friend of OutgoingMethod and set Out 
> > through it, or the other way around and have a 
> > `OutgoingMethod::bindOut(LSPBinder&)` ?
> > 
> > not sure if it is any better though, as we still construct a somewhat 
> > invalid object :/
> > well this one filling an out-parameter definitely tripped me over while 
> > reading the code a couple times, and once more on the tests.
> 
> Yup. My feeling is the wins are:
>  - avoid writing the types over and over (we can't really avoid it on the 
> instance variable)
>  - resembles syntax for binding incoming things
> 
> And the main loss is definitely that we're not using assignment syntax for 
> assignment.
> 
> > what about making this return the handler instead? E.g. Edit = 
> > Bind.outgoingMethod("edit")
> 
> This is a reasonable alternative, as you say the duplication is the downside.
> 
> > Maybe we can get away by making OutgoingMethod a class with a call operator
> 
> Yeah, I don't really understand what this achieves - the usage looks the 
> same, just now the logical assignment doesn't use assignment syntax *or* 
> assignment semantics :-)
> 
> Other ideas I had:
>  - the object is untyped, and the call operator is templated/typed - no 
> type-safety at callsite, yuck
>  - `outgoingMethod` returns an untyped proxy object with a template 
> conversion operator to unique_function. This gives us assignment 
> syntax... and horrible compiler errors on mismatch.
> 
> I'm going to try the latter out to see how bad it is.
thanks! this looks a whole lot better!



Comment at: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp:237
+  Value += X;
+  Changed(Value);
+}

sammccall wrote:
> whoops, after rebasing against 40cc63ea6eec7874d3a358f9fa549ef2f6543512 this 
> uncovered a bug - we're testing the public API from the wrong thread (server 
> thread != main thread).
> 
> So I've had to remove that test in this patch. We can test public APIs again 
> in D96755.
yikes, i see what you mean now.. (i was searching for the failure in the 
previous commit you mentioned)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96717

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-02-16 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D95246#2565351 , 
@abhina.sreeskantharajan wrote:

> 



> Do you know what is different between your environments which is causing the 
> spelling to be capitalized? This might help me determine how to fix the 
> current host platform check in llvm/utils/lit/lit/llvm/config.py.

I'd love to help you. I'm using ordinary Win10. Here is my python output:

  >>> os.name
  'nt'
  >>> sys.platform
  'win32'
  >>> platform.system()
  'Windows'
  >>> platform.release()
  '10'
  >>>

If you would say what exact info you need I would execute and send you.
BTW my python3 uses //Sentence case capitalization// in errors as you can see:

  >>> open('some')
  Traceback (most recent call last):
File "", line 1, in 
  FileNotFoundError: [Errno 2] No such file or directory: 'some'
  >>>




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D92024: [clang] Implement P0692R1 from C++20 (access checking on specializations and instantiations)

2021-02-16 Thread Alex Orlov via Phabricator via cfe-commits
aorlov added a comment.

Ping! Please, don't pass by this patch. I need your competent evaluation to 
load it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92024

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


[PATCH] D67429: Improve code generation for thread_local variables:

2021-02-16 Thread Wolfgang Pieb via Phabricator via cfe-commits
wolfgangp added a comment.

Ping. Just wondering if there are any new insights on the issue reported in 
PR48030 .


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67429

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


[PATCH] D88631: [X86] Support customizing stack protector guard

2021-02-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.
Herald added a subscriber: jansvoboda11.

Looks like there's also a `-mstack-protector-guard-symbol=` which Linux kernel 
developers are looking to use for 32b X86 kernels: 
https://bugs.llvm.org/show_bug.cgi?id=49209.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88631

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


  1   2   >