[PATCH] D91590: [NVPTX] Efficently support dynamic index on CUDA kernel aggregate parameters.

2020-11-18 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

As mentioned earlier, that's very experimental support. Even though the SASS 
looks reasonable, it still needs verifying on real systems. For non-kernel 
functions, it seems we share the path. So that we should do a similar thing. 
The current approach fixes that in the codegen phase by adding back the 
`alloca` to match the parameter space semantic. Once that alloca is dynamically 
indexed, it won't be promoted in SROA. Only `instcomb` eliminates that `alloca` 
when it is only modified once by copying from a constant memory. As `instcomb` 
won't break certain patterns prepared in the codegen preparation, it won't run 
in the backend. That dynamically indexed `alloca` won't be removed.




Comment at: clang/test/CodeGenCUDA/kernel-args.cu:13-14
 // AMDGCN: define amdgpu_kernel void @_Z6kernel1A(%struct.A addrspace(4)* 
byref(%struct.A) align 8 %{{.+}})
-// NVPTX: define void @_Z6kernel1A(%struct.A* byval(%struct.A) align 8 %x)
+// NVPTX: define void @_Z6kernel1A(%struct.A addrspace(101)* byref(%struct.A) 
align 8 %0)
 __global__ void kernel(A x) {
 }

tra wrote:
> Is the idea here to rely on PTX to store the value in param space (so we do 
> actually pass the parameter by value)  and represent it on IR level as a 
> reference to an an externally-provided storage with the value.
> So:
> - C++ passes argument by value
> - IR knows that PTX will store it somewhere in param space and uses `byref`
> - we still generate PTX which has parameter passed by value, but now we can 
> access it directly via a reference to param-space value.
> 
> Presumably for parameters we do want to modify, we'll need to fall back to 
> having a local copy.
> 
> So far so good. However, now we may have a problem distinguishing between 
> C++-level arguments passed by value vs by reference -- they all will look 
> like `byref` on IR level. That is, unless you rely on `addrspace(101)` to 
> indicate that it's actually a `byval` in disguise. 
> 
> It looks plausible as long as we can guarantee that we never modify it. 
> Neither in the current function nor in any of the callees, if we pass it by 
> reference. 
> 
> I'm not particularly familiar with AA machinery. I'd appreciate if you could 
> elaborate on how you see it all work end-to-end.
> 
It does the same thing as `nvptx-lower-args` does but applies that earlier in 
the frontend. The upside is that IR is optimized by all the middle-end opts. 
`instcomb` will remove that dynamically indexed `alloca` if it's only modified 
by copying from constant memory. AA teaches the compiler that parameter space 
has the property of constantness. Even though we run SROA after 
`nvptx-lower-args`, but we general won't run `instcomb` in the backend as it 
potentially breaks certain patterns prepared in the codegen preparation phase.

`byref` (newly added) in LLVM IR is different from by-reference in C++. The 
later is translated into a pointer. `byref` in LLVM IR says that content of 
that pointer should not be modified in the function body. It won't be ambiguous 
from the IR side.

It's still possible for the backend to do similar stuff. Once that `byval` 
argument has `readonly`, that `alloca` could be skipped.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91590

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


[clang] 955341a - test commit

2020-11-18 Thread Thorsten Schütt via cfe-commits

Author: Thorsten Schütt
Date: 2020-11-18T09:20:37+01:00
New Revision: 955341a722a0a204c79f6b948e4fe0f23bb56e30

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

LOG: test commit

add whitespace

Added: 


Modified: 
clang/lib/Tooling/Tooling.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index 063f4df2da5f..79851ac723da 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -645,7 +645,7 @@ std::unique_ptr buildASTFromCodeWithArgs(
 
   if (!Invocation.run())
 return nullptr;
-
+ 
   assert(ASTs.size() == 1);
   return std::move(ASTs[0]);
 }



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


[PATCH] D91626: [clangd] Implement textDocument/implementation.

2020-11-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

thanks, just reviewed at the xrefs code.  I think we can narrow the scope of 
the patch by splitting it into two patches

- find-implementation in xrefs.cpp
- LSP & clangd server layer (needs a smoke lit test)




Comment at: clang-tools-extra/clangd/XRefs.cpp:1147
+  for (const NamedDecl *ND : getDeclAtPosition(AST, *CurLoc, Relations))
+if (llvm::isa(ND))
+  Req.Subjects.insert(getSymbolID(ND));

I think we should restrict to `virtual`  method only.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1153
+  Index->relations(Req, [&](const SymbolID &Subject, const Symbol &Object) {
+if (auto Loc = symbolToLocation(Object, *MainFilePath))
+  Results.References.push_back(*Loc);

`symbolToLocation` will prefer definition location over declaration location.

there are a few options:

1) just return declaration location
2) just return definition location
3) return both

in the find-implementaiton case, I think the declaration location is more? 
interesting than the definition location, I would slightly prefer 1), what do 
you think?



Comment at: clang-tools-extra/clangd/XRefs.h:87
+/// Returns implementations of the virtual function at a specified \p Pos.
+ReferencesResult findImplementations(ParsedAST &AST, Position Pos,
+ const SymbolIndex *Index);

not sure ReferenceResult is the best fit -- we never set the `HasMore` field. 

I'd use `std::vector`, this returns richer information, and the 
client (LSPServer can choose which location they want to return).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91626

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


[PATCH] D91605: [sanitizers] Implement GetTls on Solaris

2020-11-18 Thread Rainer Orth via Phabricator via cfe-commits
ro added inline comments.



Comment at: compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:455-520
+#if SANITIZER_SOLARIS
+// dlpi_tls_modid is only available since Solaris 11.4 SRU 10.  Use
+// dlinfo(RTLD_DI_LINKMAP) instead which works on both Solaris 11.3 and 
Illumos.
+
+// Beginning of declaration from OpenSolaris/Illumos
+// $SRC/cmd/sgs/include/rtld.h.
+typedef struct {

vitalybuka wrote:
> can this go into sanitizer_platform_limits_solaris.h ?
> 
I don't think it belongs there: AFAICS that header is for types used by the 
interceptors.

I've been following what other targets do here, like declaring internal types 
and functions, and adding helpers like `GetSizeFromHdr`.  It would only be 
confusing if Solaris were treated differently.  It certainly helped me a lot 
being able to see what other targets do in once place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91605

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


[clang-tools-extra] 9d77584 - [clangd] Call hierarchy (Protocol layer)

2020-11-18 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2020-11-18T03:41:31-05:00
New Revision: 9d77584fe04010a2aa536308d4032bf5677d7000

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

LOG: [clangd] Call hierarchy (Protocol layer)

The protocol is based on the spec found here:
https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#textDocument_prepareCallHierarchy

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

Added: 


Modified: 
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h

Removed: 




diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 2a457420ff21..7464485e7058 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -1209,6 +1209,58 @@ bool fromJSON(const llvm::json::Value &Params, 
ReferenceParams &R,
   return fromJSON(Params, Base, P);
 }
 
+llvm::json::Value toJSON(SymbolTag Tag) {
+  return llvm::json::Value{static_cast(Tag)};
+}
+
+llvm::json::Value toJSON(const CallHierarchyItem &I) {
+  llvm::json::Object Result{{"name", I.name},
+{"kind", static_cast(I.kind)},
+{"range", I.range},
+{"selectionRange", I.selectionRange},
+{"uri", I.uri}};
+  if (!I.tags.empty())
+Result["tags"] = I.tags;
+  if (!I.detail.empty())
+Result["detail"] = I.detail;
+  if (!I.data.empty())
+Result["data"] = I.data;
+  return std::move(Result);
+}
+
+bool fromJSON(const llvm::json::Value &Params, CallHierarchyItem &I,
+  llvm::json::Path P) {
+  llvm::json::ObjectMapper O(Params, P);
+
+  // Populate the required fields only. We don't care about the
+  // optional fields `Tags` and `Detail` for the purpose of
+  // client --> server communication.
+  return O && O.map("name", I.name) && O.map("kind", I.kind) &&
+ O.map("uri", I.uri) && O.map("range", I.range) &&
+ O.map("selectionRange", I.selectionRange) &&
+ O.mapOptional("data", I.data);
+}
+
+bool fromJSON(const llvm::json::Value &Params,
+  CallHierarchyIncomingCallsParams &C, llvm::json::Path P) {
+  llvm::json::ObjectMapper O(Params, P);
+  return O.map("item", C.item);
+}
+
+llvm::json::Value toJSON(const CallHierarchyIncomingCall &C) {
+  return llvm::json::Object{{"from", C.from}, {"fromRanges", C.fromRanges}};
+}
+
+bool fromJSON(const llvm::json::Value &Params,
+  CallHierarchyOutgoingCallsParams &C, llvm::json::Path P) {
+  llvm::json::ObjectMapper O(Params, P);
+  return O.map("item", C.item);
+}
+
+llvm::json::Value toJSON(const CallHierarchyOutgoingCall &C) {
+  return llvm::json::Object{{"to", C.to}, {"fromRanges", C.fromRanges}};
+}
+
 static const char *toString(OffsetEncoding OE) {
   switch (OE) {
   case OffsetEncoding::UTF8:

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index d0c4c6bbd4b4..8d2f5d2e15b0 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -1375,7 +1375,7 @@ struct TypeHierarchyItem {
   /// descendants. If not defined, the children have not been resolved.
   llvm::Optional> children;
 
-  /// An optional 'data' filed, which can be used to identify a type hierarchy
+  /// An optional 'data' field, which can be used to identify a type hierarchy
   /// item in a resolve request.
   llvm::Optional data;
 };
@@ -1397,6 +1397,83 @@ struct ResolveTypeHierarchyItemParams {
 bool fromJSON(const llvm::json::Value &, ResolveTypeHierarchyItemParams &,
   llvm::json::Path);
 
+enum class SymbolTag { Deprecated = 1 };
+llvm::json::Value toJSON(SymbolTag);
+
+/// The parameter of a `textDocument/prepareCallHierarchy` request.
+struct CallHierarchyPrepareParams : public TextDocumentPositionParams {};
+
+/// Represents programming constructs like functions or constructors
+/// in the context of call hierarchy.
+struct CallHierarchyItem {
+  /// The name of this item.
+  std::string name;
+
+  /// The kind of this item.
+  SymbolKind kind;
+
+  /// Tags for this item.
+  std::vector tags;
+
+  /// More detaill for this item, e.g. the signature of a function.
+  std::string detail;
+
+  /// The resource identifier of this item.
+  URIForFile uri;
+
+  /// The range enclosing this symbol not including leading / trailing
+  /// whitespace but everything else, e.g. comments and code.
+  Range range;
+
+  /// The range that should be selected and revealed when this symbol
+  /// is being picked, e.g. the name of a function.
+  /// Must be contained by `Rng`.
+  Range selectionRange;
+
+  /// An optional 'data' field, which can be used to identify a call
+  /// hierarchy item in an incomingCalls or outgoingCalls r

[PATCH] D89296: [clangd] Call hierarchy (Protocol layer)

2020-11-18 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 rG9d77584fe040: [clangd] Call hierarchy (Protocol layer) 
(authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89296

Files:
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h

Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -1375,7 +1375,7 @@
   /// descendants. If not defined, the children have not been resolved.
   llvm::Optional> children;
 
-  /// An optional 'data' filed, which can be used to identify a type hierarchy
+  /// An optional 'data' field, which can be used to identify a type hierarchy
   /// item in a resolve request.
   llvm::Optional data;
 };
@@ -1397,6 +1397,83 @@
 bool fromJSON(const llvm::json::Value &, ResolveTypeHierarchyItemParams &,
   llvm::json::Path);
 
+enum class SymbolTag { Deprecated = 1 };
+llvm::json::Value toJSON(SymbolTag);
+
+/// The parameter of a `textDocument/prepareCallHierarchy` request.
+struct CallHierarchyPrepareParams : public TextDocumentPositionParams {};
+
+/// Represents programming constructs like functions or constructors
+/// in the context of call hierarchy.
+struct CallHierarchyItem {
+  /// The name of this item.
+  std::string name;
+
+  /// The kind of this item.
+  SymbolKind kind;
+
+  /// Tags for this item.
+  std::vector tags;
+
+  /// More detaill for this item, e.g. the signature of a function.
+  std::string detail;
+
+  /// The resource identifier of this item.
+  URIForFile uri;
+
+  /// The range enclosing this symbol not including leading / trailing
+  /// whitespace but everything else, e.g. comments and code.
+  Range range;
+
+  /// The range that should be selected and revealed when this symbol
+  /// is being picked, e.g. the name of a function.
+  /// Must be contained by `Rng`.
+  Range selectionRange;
+
+  /// An optional 'data' field, which can be used to identify a call
+  /// hierarchy item in an incomingCalls or outgoingCalls request.
+  std::string data;
+};
+llvm::json::Value toJSON(const CallHierarchyItem &);
+bool fromJSON(const llvm::json::Value &, CallHierarchyItem &, llvm::json::Path);
+
+/// The parameter of a `callHierarchy/incomingCalls` request.
+struct CallHierarchyIncomingCallsParams {
+  CallHierarchyItem item;
+};
+bool fromJSON(const llvm::json::Value &, CallHierarchyIncomingCallsParams &,
+  llvm::json::Path);
+
+/// Represents an incoming call, e.g. a caller of a method or constructor.
+struct CallHierarchyIncomingCall {
+  /// The item that makes the call.
+  CallHierarchyItem from;
+
+  /// The range at which the calls appear.
+  /// This is relative to the caller denoted by `From`.
+  std::vector fromRanges;
+};
+llvm::json::Value toJSON(const CallHierarchyIncomingCall &);
+
+/// The parameter of a `callHierarchy/outgoingCalls` request.
+struct CallHierarchyOutgoingCallsParams {
+  CallHierarchyItem item;
+};
+bool fromJSON(const llvm::json::Value &, CallHierarchyOutgoingCallsParams &,
+  llvm::json::Path);
+
+/// Represents an outgoing call, e.g. calling a getter from a method or
+/// a method from a constructor etc.
+struct CallHierarchyOutgoingCall {
+  /// The item that is called.
+  CallHierarchyItem to;
+
+  /// The range at which this item is called.
+  /// This is the range relative to the caller, and not `To`.
+  std::vector fromRanges;
+};
+llvm::json::Value toJSON(const CallHierarchyOutgoingCall &);
+
 struct ReferenceParams : public TextDocumentPositionParams {
   // For now, no options like context.includeDeclaration are supported.
 };
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -1209,6 +1209,58 @@
   return fromJSON(Params, Base, P);
 }
 
+llvm::json::Value toJSON(SymbolTag Tag) {
+  return llvm::json::Value{static_cast(Tag)};
+}
+
+llvm::json::Value toJSON(const CallHierarchyItem &I) {
+  llvm::json::Object Result{{"name", I.name},
+{"kind", static_cast(I.kind)},
+{"range", I.range},
+{"selectionRange", I.selectionRange},
+{"uri", I.uri}};
+  if (!I.tags.empty())
+Result["tags"] = I.tags;
+  if (!I.detail.empty())
+Result["detail"] = I.detail;
+  if (!I.data.empty())
+Result["data"] = I.data;
+  return std::move(Result);
+}
+
+bool fromJSON(const llvm::json::Value &Params, CallHierarchyItem &I,
+  llvm::json::Path P) {
+  llvm::json::ObjectMapper O(Params, P);
+
+  // Populate the required fields only. We don't care about the
+  // optional fields `Tags

[PATCH] D91122: [clangd] Call hierarchy (XRefs layer, incoming calls)

2020-11-18 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.h:109
+/// Get call hierarchy information at \p Pos.
+llvm::Optional>
+prepareCallHierarchy(ParsedAST &AST, Position Pos, const SymbolIndex *Index,

kadircet wrote:
> nridge wrote:
> > kadircet wrote:
> > > what's the distinction between empty and none return values ? (same for 
> > > others)
> > Generally speaking, a `None` result means "the input was not recognized in 
> > some way", while an empty vector result means "there are no results for 
> > this input".
> > 
> > For `prepareCallHierarchy`, the inputs encode a source location, and the 
> > operation asks "give me `CallHierarchyItem`s for suitable declarations 
> > (i.e. functions) at this location. So, `None` means "the source location 
> > could not be recognized" (`sourceLocationInMainFile` failed), while an 
> > empty result means "there are no declarations of functions at this 
> > location".
> > 
> > For `incomingCalls` and `outgoingCalls`, the inputs encode a declaration of 
> > a function, and the operation asks "give me its callers / callees". So, a 
> > `None` means "could not locate the function (i.e. symbol)", while an empty 
> > result means "this function has no callers / callees".
> > Generally speaking, a None result means "the input was not recognized in 
> > some way", while an empty vector result means "there are no results for 
> > this input".
> 
> Makes sense, but that sounds like an implementation detail. I don't see any 
> difference between the two from caller's point of view. Even the logging 
> happens inside the implementation. As for interpreting llvm::None by the 
> caller, i believe it is subject to change, so unless we return an Expected, 
> there's not much value in returning an Optional, and even in such a case, 
> caller probably can't do much but propagate the error (maybe also try with 
> Pos+/-1, but usually that's handled within the XRefs as well).
> 
> Returning an empty container is also coherent with rest of the APIs we have 
> in XRefs.h.
> 
> So I believe we should drop the optionals here.
The protocol 
[specifies](https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#textDocument_prepareCallHierarchy)
 return types of `CallHierarchyItem[] | null` for `prepareCallHierarchy` and 
`CallHierarchyIncomingCall[] | null` for `incomingCalls`.

The `| null` in there suggests that the protocol intends for there to be a 
semantic difference  between an empty array and null, and that clients may want 
to do things differently in the two caes (e.g. show an "unable to compute call 
hierarchy" error dialog vs. show an emty tree).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91122

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


[PATCH] D85600: [clang-format] use spaces for alignment of binary/ternary expressions with UT_AlignWithSpaces

2020-11-18 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

I am not 100% that it is thanks to this patch but reformatting Firefox code 
with clang-format 11 significantly improves the readability of the usage 
of ternary operators. See: https://phabricator.services.mozilla.com/D90795

Thanks for the change!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85600

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


[PATCH] D83298: Add ability to make fixups to CompilerInvocation after option parsing

2020-11-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a comment.

Taking over the revision, as Daniel is no longer involved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83298

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


[clang] 2be5698 - [clang][cli] Add ability to make fixups to CompilerInvocation after option parsing

2020-11-18 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-11-18T10:35:38+01:00
New Revision: 2be569870486a2068667f4625723c0a7409f4c97

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

LOG: [clang][cli] Add ability to make fixups to CompilerInvocation after option 
parsing

Depends on D83211

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index feae81317047..b850f6466a34 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1347,7 +1347,7 @@ def fcf_protection : Flag<["-"], "fcf-protection">, 
Group, Flags<[CoreO
   Alias, AliasArgs<["full"]>,
   HelpText<"Enable cf-protection in 'full' mode">;
 
-defm xray_instrument : OptInFFlag<"xray-instrument", "Generate XRay 
instrumentation sleds on function entry and exit">;
+defm xray_instrument : OptInFFlag<"xray-instrument", "Generate XRay 
instrumentation sleds on function entry and exit", "", "", [], 
"LangOpts->XRayInstrument">;
 
 def fxray_instruction_threshold_EQ :
   JoinedOrSeparate<["-"], "fxray-instruction-threshold=">,
@@ -1375,15 +1375,15 @@ def fxray_modes :
   HelpText<"List of modes to link in by default into XRay instrumented 
binaries.">;
 
 defm xray_always_emit_customevents : 
OptInFFlag<"xray-always-emit-customevents",
-  "Always emit __xray_customevent(...) calls even if the containing function 
is not always instrumented">;
+  "Always emit __xray_customevent(...) calls even if the containing function 
is not always instrumented", "", "", [], 
"LangOpts->XRayAlwaysEmitCustomEvents">;
 
 defm xray_always_emit_typedevents : OptInFFlag<"xray-always-emit-typedevents",
-  "Always emit __xray_typedevent(...) calls even if the containing function is 
not always instrumented">;
+  "Always emit __xray_typedevent(...) calls even if the containing function is 
not always instrumented", "", "", [], "LangOpts->XRayAlwaysEmitTypedEvents">;
 
 defm xray_ignore_loops : OptInFFlag<"xray-ignore-loops",
-  "Don't instrument functions with loops unless they also meet the minimum 
function size">;
+  "Don't instrument functions with loops unless they also meet the minimum 
function size", "", "", [], "CodeGenOpts.XRayIgnoreLoops">;
 defm xray_function_index : OptOutFFlag<"xray-function-index", "",
-  "Omit function index section at the expense of single-function patching 
performance">;
+  "Omit function index section at the expense of single-function patching 
performance", "", [], "CodeGenOpts.XRayOmitFunctionIndex">;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
   Flags<[CC1Option]>,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index a9bc48fd23a5..2ea1027e125d 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -245,6 +245,17 @@ static T extractMaskValue(T KeyPath) {
   return KeyPath & Value;
 }
 
+static void FixupInvocation(CompilerInvocation &Invocation) {
+  LangOptions &LangOpts = *Invocation.getLangOpts();
+  DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
+  CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
+  CodeGenOpts.XRayInstrumentFunctions = LangOpts.XRayInstrument;
+  CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents;
+  CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents;
+
+  llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
+}
+
 
//===--===//
 // Deserialization (from args)
 
//===--===//
@@ -1189,16 +1200,8 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, 
ArgList &Args, InputKind IK,
   Opts.InstrumentFunctionEntryBare =
   Args.hasArg(OPT_finstrument_function_entry_bare);
 
-  Opts.XRayInstrumentFunctions =
-  Args.hasArg(OPT_fxray_instrument);
-  Opts.XRayAlwaysEmitCustomEvents =
-  Args.hasArg(OPT_fxray_always_emit_customevents);
-  Opts.XRayAlwaysEmitTypedEvents =
-  Args.hasArg(OPT_fxray_always_emit_typedevents);
   Opts.XRayInstructionThreshold =
   getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
-  Opts.XRayIgnoreLoops = Args.hasArg(OPT_fxray_ignore_loops);
-  Opts.XRayOmitFunctionIndex = Args.hasArg(OPT_fno_xray_function_index);
   Opts.XRayTotalFunctionGroups =
   getLastArgIntValue(Args, OPT_fxray_function_groups, 1, Diags);
   Opts.XRaySelectedFunctionGroup =
@@ -3447,13 +3450,6 @@ static void ParseLa

[PATCH] D83298: Add ability to make fixups to CompilerInvocation after option parsing

2020-11-18 Thread Jan Svoboda 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 rG2be569870486: [clang][cli] Add ability to make fixups to 
CompilerInvocation after option… (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D83298?vs=280946&id=306004#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83298

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -245,6 +245,17 @@
   return KeyPath & Value;
 }
 
+static void FixupInvocation(CompilerInvocation &Invocation) {
+  LangOptions &LangOpts = *Invocation.getLangOpts();
+  DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
+  CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
+  CodeGenOpts.XRayInstrumentFunctions = LangOpts.XRayInstrument;
+  CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents;
+  CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents;
+
+  llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
+}
+
 
//===--===//
 // Deserialization (from args)
 
//===--===//
@@ -1189,16 +1200,8 @@
   Opts.InstrumentFunctionEntryBare =
   Args.hasArg(OPT_finstrument_function_entry_bare);
 
-  Opts.XRayInstrumentFunctions =
-  Args.hasArg(OPT_fxray_instrument);
-  Opts.XRayAlwaysEmitCustomEvents =
-  Args.hasArg(OPT_fxray_always_emit_customevents);
-  Opts.XRayAlwaysEmitTypedEvents =
-  Args.hasArg(OPT_fxray_always_emit_typedevents);
   Opts.XRayInstructionThreshold =
   getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
-  Opts.XRayIgnoreLoops = Args.hasArg(OPT_fxray_ignore_loops);
-  Opts.XRayOmitFunctionIndex = Args.hasArg(OPT_fno_xray_function_index);
   Opts.XRayTotalFunctionGroups =
   getLastArgIntValue(Args, OPT_fxray_function_groups, 1, Diags);
   Opts.XRaySelectedFunctionGroup =
@@ -3447,13 +3450,6 @@
   systemBlacklists.begin(),
   systemBlacklists.end());
 
-  // -fxray-instrument
-  Opts.XRayInstrument = Args.hasArg(OPT_fxray_instrument);
-  Opts.XRayAlwaysEmitCustomEvents =
-  Args.hasArg(OPT_fxray_always_emit_customevents);
-  Opts.XRayAlwaysEmitTypedEvents =
-  Args.hasArg(OPT_fxray_always_emit_typedevents);
-
   // -fxray-{always,never}-instrument= filenames.
   Opts.XRayAlwaysInstrumentFiles =
   Args.getAllArgValues(OPT_fxray_always_instrument);
@@ -3827,9 +3823,7 @@
   }
 
   Success &= Res.parseSimpleArgs(Args, Diags);
-
-  llvm::sys::Process::UseANSIEscapeCodes(
-  Res.DiagnosticOpts->UseANSIEscapeCodes);
+  FixupInvocation(Res);
 
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
   Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1347,7 +1347,7 @@
   Alias, AliasArgs<["full"]>,
   HelpText<"Enable cf-protection in 'full' mode">;
 
-defm xray_instrument : OptInFFlag<"xray-instrument", "Generate XRay 
instrumentation sleds on function entry and exit">;
+defm xray_instrument : OptInFFlag<"xray-instrument", "Generate XRay 
instrumentation sleds on function entry and exit", "", "", [], 
"LangOpts->XRayInstrument">;
 
 def fxray_instruction_threshold_EQ :
   JoinedOrSeparate<["-"], "fxray-instruction-threshold=">,
@@ -1375,15 +1375,15 @@
   HelpText<"List of modes to link in by default into XRay instrumented 
binaries.">;
 
 defm xray_always_emit_customevents : 
OptInFFlag<"xray-always-emit-customevents",
-  "Always emit __xray_customevent(...) calls even if the containing function 
is not always instrumented">;
+  "Always emit __xray_customevent(...) calls even if the containing function 
is not always instrumented", "", "", [], 
"LangOpts->XRayAlwaysEmitCustomEvents">;
 
 defm xray_always_emit_typedevents : OptInFFlag<"xray-always-emit-typedevents",
-  "Always emit __xray_typedevent(...) calls even if the containing function is 
not always instrumented">;
+  "Always emit __xray_typedevent(...) calls even if the containing function is 
not always instrumented", "", "", [], "LangOpts->XRayAlwaysEmitTypedEvents">;
 
 defm xray_ignore_loops : OptInFFlag<"xray-ignore-loops",
-  "Don't instrument functions with loops unless they also meet the minimum 
function size">;
+  "Don't instrument functions with loops unless they also meet the minimum 

[PATCH] D83315: Turn arcmt-* options into a single option

2020-11-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a comment.

Taking over this patch, as Daniel is no longer involved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83315

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


[PATCH] D83315: Turn arcmt-* options into a single option

2020-11-18 Thread Jan Svoboda 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 rG05eeda9752b3: [clang][cli] Turn arcmt-* options into a 
single option (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83315

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/ARCMT/GC-check-warn-nsalloc.m
  clang/test/ARCMT/GC-check.m
  clang/test/ARCMT/atautorelease-check.m
  clang/test/ARCMT/check-api.m
  clang/test/ARCMT/check-with-pch.m
  clang/test/ARCMT/check-with-serialized-diag.m
  clang/test/ARCMT/checking-in-arc.m
  clang/test/ARCMT/checking.m
  clang/test/ARCMT/cxx-checking.mm
  clang/test/ARCMT/driver-migrate.m
  clang/test/ARCMT/migrate-emit-errors.m
  clang/test/ARCMT/migrate-plist-output.m
  clang/test/ARCMT/migrate-space-in-path.m
  clang/test/ARCMT/migrate-with-pch.m
  clang/test/ARCMT/migrate.m
  clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
  clang/test/ARCMT/nonobjc-to-objc-cast-2.m
  clang/test/ARCMT/releases-driver.m
  clang/test/ARCMT/releases-driver.m.result
  clang/test/ARCMT/verify.m
  clang/test/ARCMT/with-arc-mode-modify.m
  clang/test/ARCMT/with-arc-mode-modify.m.result
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -114,7 +114,7 @@
 OS << ", ";
 emitScopedNormalizedValue(OS, DefaultValue);
 OS << ", ";
-emitScopedNormalizedValue(OS, NormalizerRetTy);
+OS << NormalizerRetTy;
 OS << ", ";
 OS << Normalizer;
 OS << ", ";
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -199,6 +199,9 @@
   code Normalizer = "normalizeSimpleEnum";
   code Denormalizer = "denormalizeSimpleEnum";
 }
+class AutoNormalizeEnumJoined : AutoNormalizeEnum {
+  code Denormalizer = "denormalizeSimpleEnumJoined";
+}
 class ValueMerger { code ValueMerger = merger; }
 class ValueExtractor { code ValueExtractor = extractor; }
 
Index: clang/test/ARCMT/with-arc-mode-modify.m.result
===
--- clang/test/ARCMT/with-arc-mode-modify.m.result
+++ clang/test/ARCMT/with-arc-mode-modify.m.result
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
 // RUN: cat %s > %t
-// RUN: %clang_cc1 -arcmt-modify -fsyntax-only -fobjc-arc -x objective-c %t
+// RUN: %clang_cc1 -arcmt-action=modify -fsyntax-only -fobjc-arc -x objective-c %t
 // RUN: diff %t %s.result
 // RUN: rm %t
 
Index: clang/test/ARCMT/with-arc-mode-modify.m
===
--- clang/test/ARCMT/with-arc-mode-modify.m
+++ clang/test/ARCMT/with-arc-mode-modify.m
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -x objective-c %s.result
 // RUN: cat %s > %t
-// RUN: %clang_cc1 -arcmt-modify -fsyntax-only -fobjc-arc -x objective-c %t
+// RUN: %clang_cc1 -arcmt-action=modify -fsyntax-only -fobjc-arc -x objective-c %t
 // RUN: diff %t %s.result
 // RUN: rm %t
 
Index: clang/test/ARCMT/verify.m
===
--- clang/test/ARCMT/verify.m
+++ clang/test/ARCMT/verify.m
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -arcmt-check -verify %s
-// RUN: not %clang_cc1 -arcmt-check -verify %t.invalid 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -arcmt-action=check -verify %s
+// RUN: not %clang_cc1 -arcmt-action=check -verify %t.invalid 2>&1 | FileCheck %s
 
 #if 0
 // expected-error {{should be ignored}}
Index: clang/test/ARCMT/releases-driver.m.result
===
--- clang/test/ARCMT/releases-driver.m.result
+++ clang/test/ARCMT/releases-driver.m.result
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
 // RUN: cat %s > %t
-// RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x objective-c %t
+// RUN: %clang_cc1 -arcmt-action=modify -triple x86_64-apple-macosx10.6 -x objective-c %t
 // RUN: diff %t %s.result
 // RUN: rm %t
 
Index: clang/test/ARCMT/releases-driver.m
===
--- clang/test/ARCMT/releases-driver.m
+++ clang/test/ARCMT/releases-driver.m
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fblocks -fsyntax-only -fobjc-arc -x objective-c %s.result
 // RUN: cat %s > %t
-// RUN: %clang_cc1 -arcmt-modify -triple x86_64-apple-macosx10.6 -x objective-c %t
+// RUN: %clang_cc1 -arcmt-action=modify -triple x86_64-apple-macosx10.6 -x objective-c %t
 /

[clang] 05eeda9 - [clang][cli] Turn arcmt-* options into a single option

2020-11-18 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-11-18T10:53:41+01:00
New Revision: 05eeda9752b393c074dd22716670bc3b9671270d

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

LOG: [clang][cli] Turn arcmt-* options into a single option

- The new option, -arcmt-action, is a simple enum based option.
- The driver is modified to translate the existing -ccc-acmt-* options 
accordingly
Depends on D83298

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/ARCMT/GC-check-warn-nsalloc.m
clang/test/ARCMT/GC-check.m
clang/test/ARCMT/atautorelease-check.m
clang/test/ARCMT/check-api.m
clang/test/ARCMT/check-with-pch.m
clang/test/ARCMT/check-with-serialized-diag.m
clang/test/ARCMT/checking-in-arc.m
clang/test/ARCMT/checking.m
clang/test/ARCMT/cxx-checking.mm
clang/test/ARCMT/driver-migrate.m
clang/test/ARCMT/migrate-emit-errors.m
clang/test/ARCMT/migrate-plist-output.m
clang/test/ARCMT/migrate-space-in-path.m
clang/test/ARCMT/migrate-with-pch.m
clang/test/ARCMT/migrate.m
clang/test/ARCMT/no-canceling-bridge-to-bridge-cast.m
clang/test/ARCMT/nonobjc-to-objc-cast-2.m
clang/test/ARCMT/releases-driver.m
clang/test/ARCMT/releases-driver.m.result
clang/test/ARCMT/verify.m
clang/test/ARCMT/with-arc-mode-modify.m
clang/test/ARCMT/with-arc-mode-modify.m.result
llvm/include/llvm/Option/OptParser.td
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index b850f6466a34..cd5cb37c93cd 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3832,7 +3832,7 @@ def mrelocation_model : Separate<["-"], 
"mrelocation-model">,
   HelpText<"The relocation model to use">, 
Values<"static,pic,ropi,rwpi,ropi-rwpi,dynamic-no-pic">,
   NormalizedValuesScope<"llvm::Reloc">,
   NormalizedValues<["Static", "PIC_", "ROPI", "RWPI", "ROPI_RWPI", 
"DynamicNoPIC"]>,
-  MarshallingInfoString<"CodeGenOpts.RelocationModel", "PIC_", "Model">,
+  MarshallingInfoString<"CodeGenOpts.RelocationModel", "PIC_", 
"llvm::Reloc::Model">,
   AutoNormalizeEnum;
 def fno_math_builtin : Flag<["-"], "fno-math-builtin">,
   HelpText<"Disable implicit builtin knowledge of math functions">;
@@ -4262,12 +4262,13 @@ def no_emit_llvm_uselists : Flag<["-"], 
"no-emit-llvm-uselists">,
 
 def mt_migrate_directory : Separate<["-"], "mt-migrate-directory">,
   HelpText<"Directory for temporary files produced during ARC or ObjC 
migration">;
-def arcmt_check : Flag<["-"], "arcmt-check">,
-  HelpText<"Check for ARC migration issues that need manual handling">;
-def arcmt_modify : Flag<["-"], "arcmt-modify">,
-  HelpText<"Apply modifications to files to conform to ARC">;
-def arcmt_migrate : Flag<["-"], "arcmt-migrate">,
-  HelpText<"Apply modifications and produces temporary files that conform to 
ARC">;
+
+def arcmt_action_EQ : Joined<["-"], "arcmt-action=">, Flags<[CC1Option, 
NoDriverOption]>,
+  HelpText<"The ARC migration action to take">, Values<"check,modify,migrate">,
+  NormalizedValuesScope<"FrontendOptions">,
+  NormalizedValues<["ARCMT_Check", "ARCMT_Modify", "ARCMT_Migrate"]>,
+  MarshallingInfoString<"FrontendOpts.ARCMTAction", "ARCMT_None", "unsigned">,
+  AutoNormalizeEnumJoined;
 
 def opt_record_file : Separate<["-"], "opt-record-file">,
   HelpText<"File name to use for YAML optimization record output">;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index ae9e1ce61d11..ad242d24e5c9 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3190,13 +3190,13 @@ static void RenderARCMigrateToolOptions(const Driver 
&D, const ArgList &Args,
   switch (A->getOption().getID()) {
   default: llvm_unreachable("missed a case");
   case options::OPT_ccc_arcmt_check:
-CmdArgs.push_back("-arcmt-check");
+CmdArgs.push_back("-arcmt-action=check");
 break;
   case options::OPT_ccc_arcmt_modify:
-CmdArgs.push_back("-arcmt-modify");
+CmdArgs.push_back("-arcmt-action=modify");
 break;
   case options::OPT_ccc_arcmt_migrate:
-CmdArgs.push_back("-arcmt-migrate");
+CmdArgs.push_back("-arcmt-action=migrate");
 CmdArgs.push_back("-mt-migrate-directory");
 CmdArgs.push_back(A->getValue());
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 2ea1027e125d..8916fe6a4756 100644
--- a/clang/

[PATCH] D84637: [AST] Enhance the const expression evaluator to support error-dependent exprs.

2020-11-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 306015.
hokein marked 9 inline comments as done.
hokein added a comment.

rebase and address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84637

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
  clang/test/SemaCXX/enable_if.cpp
  clang/test/SemaCXX/invalid-constructor-init.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp

Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -53,14 +53,12 @@
 return 2;
   }
   static constexpr int foo2() {
-return AA::getB(); // expected-error{{no matching function for call to 'getB'}} \
-  // expected-note {{subexpression not valid in a constant expression}}
+return AA::getB(); // expected-error{{no matching function for call to 'getB'}}
   }
 };
 // FIXME: should we suppress the "be initialized by a constant expression" diagnostic?
 constexpr auto x2 = AA::foo2(); // expected-error {{be initialized by a constant expression}} \
- // expected-note {{in instantiation of member function}} \
- // expected-note {{in call to}}
+ // expected-note {{in instantiation of member function}}
 }
 
 // verify no assertion failure on violating value category.
Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- clang/test/SemaCXX/invalid-constructor-init.cpp
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -2,7 +2,7 @@
 
 struct X {
   int Y;
-  constexpr X() // expected-error {{constexpr constructor never produces}}
+  constexpr X()
   : Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}}
 };
 // no crash on evaluating the constexpr ctor.
@@ -10,12 +10,12 @@
 
 struct X2 {
   int Y = foo();// expected-error {{use of undeclared identifier 'foo'}}
-  constexpr X2() {} // expected-error {{constexpr constructor never produces a constant expression}}
+  constexpr X2() {}
 };
 
 struct X3 {
   int Y;
-  constexpr X3() // expected-error {{constexpr constructor never produces}}
+  constexpr X3()
   : Y(({foo();})) {} // expected-error {{use of undeclared identifier 'foo'}}
 };
 
Index: clang/test/SemaCXX/enable_if.cpp
===
--- clang/test/SemaCXX/enable_if.cpp
+++ clang/test/SemaCXX/enable_if.cpp
@@ -414,8 +414,8 @@
 
 template  constexpr int callTemplated() { return templated(); }
 
-constexpr int B = 10 + // expected-error {{initialized by a constant expression}}
-callTemplated<0>(); // expected-error@-3{{no matching function for call to 'templated'}} expected-note{{in instantiation of function template}} expected-note@-10{{candidate disabled}} expected-note {{in call to 'callTemplated()'}} expected-note@-3 {{subexpression not valid in a constant expression}}
+constexpr int B = 10 +// expected-error {{initialized by a constant expression}}
+  callTemplated<0>(); // expected-error@-3{{no matching function for call to 'templated'}} expected-note{{in instantiation of function template}} expected-note@-10{{candidate disabled}}
 static_assert(callTemplated<1>() == 1, "");
 }
 
Index: clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 %s -std=c++20 -fsyntax-only -fcxx-exceptions -verify
+
+// verify no value-dependent-assertion crash in constexpr function body and no
+// bogus diagnostics.
+class Foo {
+  constexpr Foo() {
+while (invalid()) {} // expected-error {{use of undeclared identifier}}
+if (invalid()) {} // expected-error {{use of undeclared identifier}}
+  }
+};
+
+constexpr void test1() {
+  while (invalid()) {} // expected-error {{use of undeclared identifier}}
+  if (invalid()) {} // expected-error {{use of undeclared identifier}}
+}
+
+struct A {
+  int *p = new int(invalid()); // expected-error {{use of undeclared identifier}}
+  constexpr ~A() { delete p; }
+};
+constexpr int test2() {
+  A a;
+  return 1;
+}
+
+constexpr int test3() {
+  return invalid(); // expected-error {{use of undeclared identifier}}
+}
+
+constexpr int test4() {
+  if (invalid()) // expected-error {{use of undeclared identifier}}
+return 1;
+  else
+return 0;
+}
+
+constexpr int test5() { // expected-error {{constexpr function never produce}}
+  for (;; a++); // expected-error {{use of undeclared identifier}}  \
+   expected-note {{constexpr evaluation hit maximum step limit; possible infinite loop?}}
+  ret

[PATCH] D84637: [AST] Enhance the const expression evaluator to support error-dependent exprs.

2020-11-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D84637#2345353 , @rsmith wrote:

> There are a couple of cases where you're returning `EvalStmtResult` from a 
> function with a `bool` return type, that I'd like to see fixed before this 
> lands.
>
> All the other comments are directed towards producing more precise behavior 
> when evaluating a function containing errors / value-dependent constructs. I 
> don't think there's any need to block fixing the crasher here on improving 
> the diagnostics, so I'm happy if you ignore these and commit as-is (other 
> than fixing the return type issue), but I think we'll want to look at these 
> diagnostic improvements at some point.

thanks for the useful comments, I think I have addressed most of them and added 
more tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84637

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


[PATCH] D91162: Give up on evaluating value-dependent potential constexpr before hitting the assertion.

2020-11-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D91162#2400723 , @hokein wrote:

> oops, this reminds me of the patch https://reviews.llvm.org/D84637 (I should 
> have landed it, sorry), that patch should fix a general recovery-expr crash 
> inside constexpr function body. I think the crash test should be fixed by 
> that (let me check tomorrow).

yeah, confirmed that D84637  will fix the 
crash, I also added the crash case there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91162

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


[PATCH] D83406: Remove NormalizerRetTy and use the decltype of the KeyPath instead

2020-11-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a comment.

Taking over this patch, as Daniel is no longer involved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83406

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


[PATCH] D83406: Remove NormalizerRetTy and use the decltype of the KeyPath instead

2020-11-18 Thread Jan Svoboda 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 rG5e696d895bde: [clang][cli] Remove NormalizerRetTy and use 
the decltype of the KeyPath instead (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D83406?vs=276467&id=306017#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83406

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -71,7 +71,6 @@
   StringRef KeyPath;
   StringRef DefaultValue;
   StringRef NormalizedValuesScope;
-  StringRef NormalizerRetTy;
   StringRef Normalizer;
   StringRef Denormalizer;
   StringRef ValueMerger;
@@ -114,8 +113,6 @@
 OS << ", ";
 emitScopedNormalizedValue(OS, DefaultValue);
 OS << ", ";
-OS << NormalizerRetTy;
-OS << ", ";
 OS << Normalizer;
 OS << ", ";
 OS << Denormalizer;
@@ -174,9 +171,9 @@
 static MarshallingInfo::Ptr createMarshallingInfo(const Record &R) {
   assert(!isa(R.getValueInit("KeyPath")) &&
  !isa(R.getValueInit("DefaultValue")) &&
- !isa(R.getValueInit("NormalizerRetTy")) &&
  !isa(R.getValueInit("ValueMerger")) &&
- "MarshallingInfo must have a type");
+ "MarshallingInfo must have a provide a keypath, default value and a "
+ "value merger");
 
   MarshallingInfo::Ptr Ret;
   StringRef KindString = R.getValueAsString("MarshallingInfoKind");
@@ -191,7 +188,6 @@
   Ret->KeyPath = R.getValueAsString("KeyPath");
   Ret->DefaultValue = R.getValueAsString("DefaultValue");
   Ret->NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
-  Ret->NormalizerRetTy = R.getValueAsString("NormalizerRetTy");
 
   Ret->Normalizer = R.getValueAsString("Normalizer");
   Ret->Denormalizer = R.getValueAsString("Denormalizer");
Index: llvm/unittests/Option/OptionMarshallingTest.cpp
===
--- llvm/unittests/Option/OptionMarshallingTest.cpp
+++ llvm/unittests/Option/OptionMarshallingTest.cpp
@@ -18,7 +18,7 @@
 #define OPTION_WITH_MARSHALLING(   \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
-TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)\
+NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  \
   {NAME, #KEYPATH, #DEFAULT_VALUE},
 #include "Opts.inc"
 #undef OPTION_WITH_MARSHALLING
Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -156,20 +156,17 @@
   code DefaultValue = defaultvalue;
 }
 
-class MarshallingInfoString
-  : MarshallingInfo {
-  code NormalizerRetTy = normalizerretty;
-}
+class MarshallingInfoString
+  : MarshallingInfo {}
 
-class MarshallingInfoFlag, code ty="unsigned">
+class MarshallingInfoFlag>
   : MarshallingInfo {
-  code NormalizerRetTy = ty;
   code Normalizer = "normalizeSimpleFlag";
   code Denormalizer = "denormalizeSimpleFlag";
 }
 
 class MarshallingInfoBitfieldFlag
-  : MarshallingInfoFlag, "unsigned"> {
+  : MarshallingInfoFlag> {
   code Normalizer = "(normalizeFlagToValue)";
   code ValueMerger = "mergeMaskValue";
   code ValueExtractor = "(extractMaskValue)";
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -256,7 +256,7 @@
 
 template 
 static T mergeForwardValue(T KeyPath, U Value) {
-  return static_cast(Value);
+  return Value;
 }
 
 template  static T mergeMaskValue(T KeyPath, U Value) {
@@ -3773,22 +3773,24 @@
 #define OPTION_WITH_MARSHALLING(   \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
-TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)\
+NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  \
   {\
 this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  \
 if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))  \
-  this->KEYPA

[clang] 5e696d8 - [clang][cli] Remove NormalizerRetTy and use the decltype of the KeyPath instead

2020-11-18 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-11-18T11:31:13+01:00
New Revision: 5e696d895bde1eb584a9de5c9feba1a98c6bb487

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

LOG: [clang][cli] Remove NormalizerRetTy and use the decltype of the KeyPath 
instead

Depends on D83315

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/Option/OptParser.td
llvm/unittests/Option/OptionMarshallingTest.cpp
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index cd5cb37c93cd..01d90a47101b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3639,7 +3639,7 @@ def target_feature : Separate<["-"], "target-feature">,
   HelpText<"Target specific attributes">;
 def triple : Separate<["-"], "triple">,
   HelpText<"Specify target triple (e.g. i686-apple-darwin9)">,
-  MarshallingInfoString<"TargetOpts->Triple", 
"llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())", "std::string">,
+  MarshallingInfoString<"TargetOpts->Triple", 
"llvm::Triple::normalize(llvm::sys::getDefaultTargetTriple())">,
   AlwaysEmit, Normalizer<"normalizeTriple">, DenormalizeString;
 def target_abi : Separate<["-"], "target-abi">,
   HelpText<"Target a particular ABI type">;
@@ -3832,7 +3832,7 @@ def mrelocation_model : Separate<["-"], 
"mrelocation-model">,
   HelpText<"The relocation model to use">, 
Values<"static,pic,ropi,rwpi,ropi-rwpi,dynamic-no-pic">,
   NormalizedValuesScope<"llvm::Reloc">,
   NormalizedValues<["Static", "PIC_", "ROPI", "RWPI", "ROPI_RWPI", 
"DynamicNoPIC"]>,
-  MarshallingInfoString<"CodeGenOpts.RelocationModel", "PIC_", 
"llvm::Reloc::Model">,
+  MarshallingInfoString<"CodeGenOpts.RelocationModel", "PIC_">,
   AutoNormalizeEnum;
 def fno_math_builtin : Flag<["-"], "fno-math-builtin">,
   HelpText<"Disable implicit builtin knowledge of math functions">;
@@ -4267,7 +4267,7 @@ def arcmt_action_EQ : Joined<["-"], "arcmt-action=">, 
Flags<[CC1Option, NoDriver
   HelpText<"The ARC migration action to take">, Values<"check,modify,migrate">,
   NormalizedValuesScope<"FrontendOptions">,
   NormalizedValues<["ARCMT_Check", "ARCMT_Modify", "ARCMT_Migrate"]>,
-  MarshallingInfoString<"FrontendOpts.ARCMTAction", "ARCMT_None", "unsigned">,
+  MarshallingInfoString<"FrontendOpts.ARCMTAction", "ARCMT_None">,
   AutoNormalizeEnumJoined;
 
 def opt_record_file : Separate<["-"], "opt-record-file">,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 8916fe6a4756..2c54611e4912 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -256,7 +256,7 @@ static Optional normalizeTriple(OptSpecifier 
Opt, int TableIndex,
 
 template 
 static T mergeForwardValue(T KeyPath, U Value) {
-  return static_cast(Value);
+  return Value;
 }
 
 template  static T mergeMaskValue(T KeyPath, U Value) {
@@ -3773,22 +3773,24 @@ bool CompilerInvocation::parseSimpleArgs(const ArgList 
&Args,
 #define OPTION_WITH_MARSHALLING(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
-TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)
\
+NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  
\
   {
\
 this->KEYPATH = MERGER(this->KEYPATH, DEFAULT_VALUE);  
\
 if (auto MaybeValue = NORMALIZER(OPT_##ID, TABLE_INDEX, Args, Diags))  
\
-  this->KEYPATH = MERGER(this->KEYPATH, static_cast(*MaybeValue));   
\
+  this->KEYPATH = MERGER(  
\
+  this->KEYPATH, static_castKEYPATH)>(*MaybeValue));   
\
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(   
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
-TYPE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,
\
+NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,  
\
 NEG_SPELLING)  
\
   {
\
 if (auto MaybeValue =  

[PATCH] D83690: Port Migator option flags to new option parsing system

2020-11-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a comment.

Taking over this patch, as Daniel is no longer involved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83690

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


[PATCH] D90944: [clang-tidy] implement concurrency-mt-unsafe

2020-11-18 Thread Vasily Kulikov via Phabricator via cfe-commits
segoon updated this revision to Diff 306020.
segoon retitled this revision from "[clang-tidy] implement 
concurrent-mt-unsafe" to "[clang-tidy] implement concurrency-mt-unsafe".
segoon added a comment.

- concurrent -> concurrency
- split the patch apart


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

https://reviews.llvm.org/D90944

Files:
  clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
  clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
  clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
  clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-any.cpp
  clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-glibc.cpp
  clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-posix.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-posix.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-posix.cpp
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy %s concurrency-mt-unsafe %t -- -config='{CheckOptions: [{key: "concurrency-mt-unsafe.FunctionSet", value: "posix"}]}'
+
+extern unsigned int sleep (unsigned int __seconds);
+extern int *gmtime (const int *__timer);
+extern int *gmtime_r (const int *__timer, char*);
+extern char *dirname (char *__path);
+
+void foo() {
+  sleep(2);
+  ::sleep(2);
+
+  auto tm = gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function is not thread safe [concurrency-mt-unsafe]
+  tm = ::gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  tm = gmtime_r(nullptr, nullptr);
+  tm = ::gmtime_r(nullptr, nullptr);
+
+  dirname(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+}
Index: clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-glibc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-glibc.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s concurrency-mt-unsafe %t -- -config='{CheckOptions: [{key: "concurrency-mt-unsafe.FunctionSet", value: "glibc"}]}'
+
+extern unsigned int sleep (unsigned int __seconds);
+extern int *gmtime (const int *__timer);
+extern char *dirname (char *__path);
+
+void foo() {
+  sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  ::sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  dirname(nullptr);
+}
Index: clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-any.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-any.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s concurrency-mt-unsafe %t
+
+extern unsigned int sleep (unsigned int __seconds);
+extern int *gmtime (const int *__timer);
+extern int *gmtime_r (const int *__timer, char*);
+extern char *dirname (char *__path);
+
+void foo() {
+  sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+  ::sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  auto tm = gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function is not thread safe [concurrency-mt-unsafe]
+  tm = ::gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  tm = gmtime_r(nullptr, nullptr);
+  tm = ::gmtime_r(nullptr, nullptr);
+
+  dirname(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+}
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
@@ -138,6 +138,7 @@
`clang-analyzer-valist.CopyToSelf `_,
`clang-analyzer-valist.Uninitialized `_,
`clang-analyzer-valist.Unterminated `_,
+   `concurrency-mt-unsafe `_,
`cppcoreguidelines-avoid-goto `_,
`cppcoreguidelines-avoid-non-const-global-variables `_,
`cppcoreguidelines-init-variables `_, "Yes"
Index: clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
@@ -0,0 +1,52 @@
+.. title:: clang-tidy - concurrency-mt-unsafe
+
+concurrency-mt-unsafe
+

[PATCH] D91694: [clangd] Remove the trailing "." in add-using message.

2020-11-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: adamcz.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: clang.
hokein requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

to be consistent witih other code actions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91694

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp


Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -52,7 +52,7 @@
 
 std::string AddUsing::title() const {
   return std::string(llvm::formatv(
-  "Add using-declaration for {0} and remove qualifier.", Name));
+  "Add using-declaration for {0} and remove qualifier", Name));
 }
 
 // Locates all "using" statements relevant to SelectionDeclContext.


Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -52,7 +52,7 @@
 
 std::string AddUsing::title() const {
   return std::string(llvm::formatv(
-  "Add using-declaration for {0} and remove qualifier.", Name));
+  "Add using-declaration for {0} and remove qualifier", Name));
 }
 
 // Locates all "using" statements relevant to SelectionDeclContext.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91656: [clang-tidy] add concurrency module

2020-11-18 Thread Vasily Kulikov via Phabricator via cfe-commits
segoon updated this revision to Diff 306022.
segoon retitled this revision from "[clang-tidy] add concurrent module" to 
"[clang-tidy] add concurrency module".
segoon added a comment.

- concurrent -> concurrency


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

https://reviews.llvm.org/D91656

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
  clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
  clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.cpp
  clang-tools-extra/clang-tidy/concurrency/MtUnsafeCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/concurrency-mt-unsafe.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-any.cpp
  clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-glibc.cpp
  clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-posix.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-posix.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-posix.cpp
@@ -0,0 +1,22 @@
+// RUN: %check_clang_tidy %s concurrency-mt-unsafe %t -- -config='{CheckOptions: [{key: "concurrency-mt-unsafe.FunctionSet", value: "posix"}]}'
+
+extern unsigned int sleep (unsigned int __seconds);
+extern int *gmtime (const int *__timer);
+extern int *gmtime_r (const int *__timer, char*);
+extern char *dirname (char *__path);
+
+void foo() {
+  sleep(2);
+  ::sleep(2);
+
+  auto tm = gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function is not thread safe [concurrency-mt-unsafe]
+  tm = ::gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  tm = gmtime_r(nullptr, nullptr);
+  tm = ::gmtime_r(nullptr, nullptr);
+
+  dirname(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+}
Index: clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-glibc.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-glibc.cpp
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s concurrency-mt-unsafe %t -- -config='{CheckOptions: [{key: "concurrency-mt-unsafe.FunctionSet", value: "glibc"}]}'
+
+extern unsigned int sleep (unsigned int __seconds);
+extern int *gmtime (const int *__timer);
+extern char *dirname (char *__path);
+
+void foo() {
+  sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  ::sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  dirname(nullptr);
+}
Index: clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-any.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/concurrency-mt-unsafe-any.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s concurrency-mt-unsafe %t
+
+extern unsigned int sleep (unsigned int __seconds);
+extern int *gmtime (const int *__timer);
+extern int *gmtime_r (const int *__timer, char*);
+extern char *dirname (char *__path);
+
+void foo() {
+  sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+  ::sleep(2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  auto tm = gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: function is not thread safe [concurrency-mt-unsafe]
+  tm = ::gmtime(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: function is not thread safe [concurrency-mt-unsafe]
+
+  tm = gmtime_r(nullptr, nullptr);
+  tm = ::gmtime_r(nullptr, nullptr);
+
+  dirname(nullptr);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: function is not thread safe [concurrency-mt-unsafe]
+}
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -64,6 +64,8 @@
 ``bugprone-``  Checks that target bugprone code constructs.
 ``cert-``  Checks related to CERT Secure Coding Guidelines.
 ``clang-analyzer-``Clang Static Analyzer checks.
+``concurrency-``   Checks related to concurrent programming (including
+   threads, fibers, coroutines, etc.).
 ``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
 ``darwin-``Checks related to Darwin coding conventions.
 ``fuchsia-``   Checks related to Fuchsia coding conventions.
Index: clang-tools-extr

[PATCH] D91695: [ARM][AArch64] Adding Neoverse N2 CPU support

2020-11-18 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM created this revision.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, hiraditya, 
kristof.beyls.
Herald added projects: clang, LLVM.
MarkMurrayARM requested review of this revision.

Add support for the Neoverse N2 CPU to the ARM and AArch64 backends.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91695

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/neon-dot-product.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.3a-rcpc.s
  llvm/test/MC/AArch64/armv8.5a-ssbs.s
  llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
  llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -328,7 +328,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 90;
+static constexpr unsigned NumARMCPUArchs = 91;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -1048,7 +1048,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 44;
+static constexpr unsigned NumAArch64CPUArchs = 45;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -9,6 +9,7 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-x1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n2 --disassemble < %s | FileCheck %s
 
 # CHECK: ldaprb w0, [x0]
 # CHECK: ldaprh w0, [x0]
Index: llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
+++ llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
@@ -6,6 +6,7 @@
 // RUN: llvm-mc -triple thumb -mcpu=cortex-a78 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=cortex-x1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=neoverse-n1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
+// RUN: llvm-mc -triple thumb -mcpu=neoverse-n2 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 
 // RUN: not llvm-mc -triple thumb -mattr=-dotprod -show-encoding < %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ERROR < %t %s
Index: llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
+++ llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
@@ -3,6 +3,7 @@
 // RUN: llvm-mc -triple arm -mcpu=cortex-a75 -show-encoding < %s | FileCheck %s  --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=cortex-a76 -show-encoding < %s | FileCheck %s  --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=neoverse-n1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
+// RUN: llvm-mc -triple arm -mcpu=neoverse-n2 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=cortex-a77 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=cortex-a78 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=cortex-x1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
Index: llvm/test/MC/AArch64/armv8.5a-ssbs.s
===
--- llvm/test/MC/AArch64/armv8.5a-ssbs.s
+++ llvm/test/MC/AArch64/armv8.5a-ssbs.s
@@ -6,6 +6,7 @@
 // RUN: llvm-mc -triple aarch64 -show-encoding -mcpu=cortex-a76ae < %s | FileCheck %s
 // RUN: llvm-mc -triple aarch64 -show-encoding -mcpu=neoverse-e1 < %s  | FileCheck %s
 // RUN: llvm-mc -triple aarch64 -show-encoding -mcpu=neoverse-n1 < %s  | FileCheck %s
+// RUN: llvm-mc -triple aarch64 -show-encoding -mcpu=neoverse-n2 < %s  | FileCheck %s
 // RUN: not llvm-mc -triple aarch64 -show-encoding -mattr=-ssbs  < %s 2>&1 | FileCheck %s --check-prefix=NOSPECID
 
 mrs x2, SSBS
Index: llvm/test/MC/AArch6

[PATCH] D91694: [clangd] Remove the trailing "." in add-using message.

2020-11-18 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

If you are doing this may as well cover `DefineOutline` and 
`RemoveUsingNamespace` - that one can do away with formatv too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91694

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


[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-18 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 306026.
kbobyrev marked 2 inline comments as done.
kbobyrev added a comment.

Resolve some comments, simplify the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -94,6 +94,15 @@
   // For each "^" this test moves cursor to its location and applies renaming
   // while checking that all identifiers in [[]] ranges are also renamed.
   llvm::StringRef Tests[] = {
+  // Example.
+  R"cpp(
+template
+void [[f^oo]]();
+
+template<>
+void [[f^oo]]();
+  )cpp",
+
   // Function.
   R"cpp(
 void [[foo^]]() {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,7 +18,6 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
@@ -76,6 +75,8 @@
   return OtherFile;
 }
 
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D);
+
 llvm::DenseSet locateDeclAt(ParsedAST &AST,
SourceLocation TokenStartLoc) {
   unsigned Offset =
@@ -91,9 +92,7 @@
   for (const NamedDecl *D :
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
-// Get to CXXRecordDecl from constructor or destructor.
-D = tooling::getCanonicalSymbolDeclaration(D);
-Result.insert(D);
+Result.insert(canonicalRenameDecl(D));
   }
   return Result;
 }
@@ -222,23 +221,65 @@
   return error("Cannot rename symbol: {0}", Message(Reason));
 }
 
+const NamedDecl *canonicalRenameDecl(const TemplateDecl *D) {
+  return D->getTemplatedDecl();
+}
+
+const NamedDecl *canonicalRenameDecl(const CXXMethodDecl *D) {
+  const CXXMethodDecl *Result = D;
+  if (const FunctionDecl *InstantiatedMethod =
+  D->getInstantiatedFromMemberFunction())
+Result = cast(InstantiatedMethod);
+  while (Result->isVirtual() && Result->size_overridden_methods())
+Result = *Result->overridden_methods().begin();
+  return Result;
+}
+
+const NamedDecl *canonicalRenameDecl(const FunctionDecl *D) {
+  if (const FunctionTemplateDecl *Template = D->getPrimaryTemplate())
+return canonicalRenameDecl(Template);
+  return D;
+}
+
+const NamedDecl *canonicalRenameDecl(const VarTemplateSpecializationDecl *D) {
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}
+
+const NamedDecl *canonicalRenameDecl(const ClassTemplateSpecializationDecl *D) {
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}
+
+// Canonical declarations help simplify the process of renaming. Examples:
+// - Given a constructor/destructor, canonical declaration is the parent
+//   CXXRecordDecl
+// - Specializations should point to the specialized declaration.
+// - Instantiations should point to instantiated declaration.
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D) {
+  D = dyn_cast(D->getCanonicalDecl());
+  if (const auto *Constructor = dyn_cast(D))
+return canonicalRenameDecl(Constructor->getParent());
+  if (const auto *Destructor = dyn_cast(D))
+return canonicalRenameDecl(Destructor->getParent());
+  if (const auto *VarTemplate = dyn_cast(D))
+return canonicalRenameDecl(VarTemplate);
+  if (const auto *Template = dyn_cast(D))
+return canonicalRenameDecl(Template);
+  if (const auto *ClassTemplateSpecialization =
+  dyn_cast(D))
+return canonicalRenameDecl(ClassTemplateSpecialization);
+  if (const auto *Method = dyn_cast(D))
+return canonicalRenameDecl(Method);
+  if (const auto *Function = dyn_cast(D))
+return canonicalRenameDecl(Function);
+  return D;
+}
+
 // Return all rename occurrences in the main file.
 std::vector findOccurrencesWithinFile(ParsedAST &AST,
   const NamedDecl &ND) {
   trace::Span Tracer("FindOccurrencesWithinFile");
-  // If the cursor is at the underlying CXXRecordDecl of the
-  // ClassTemplateDecl, ND will be the CXXRecordDecl. In this case, we need to
-  // get the primary template manually.
-  // getUSRsForDeclaration will find other related symbols, e.g. virtual and its
-  // overriddens, primary template and all explicit specializations.
-  // FIXME: Get rid of the remaining tooling APIs.
-  const auto *RenameDecl 

[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-18 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:239
+  if (const auto *Template = D->getPrimaryTemplate())
+return canonicalRenameDecl(Template);
+  return D;

hokein wrote:
> the `auto` + varies `canonicalRenameDecl` overrides make the code hard to 
> follow.
> 
> since these functions are small, I think we can inline them into the main 
> `canonicalRenameDecl(const NamedDecl *D)`
I removed `auto`s but I believe merging them into a single function would not 
be great for two reasons:

* Some classes are already handled by the same function outside of the main 
one: ctor/dtor's parent `CXXRecordDecl`, etc: in the main function we'd have to 
have a weird logic behind extracting those and this is likely to result in more 
code
* Some functions call other ones (e.g. here we have 
`canonicalRenameDecl(Template)` - sure, right now it's just 
`D->getTemplatedDecl()` but if we decide to change something and when we 
introduce more code it'd be easy to forget and code duplication is not really a 
good idea).

WDYT?



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:246
+  if (const auto *Primary = TemplatedDecl->getPrimaryTemplate())
+return Primary;
+  return TemplatedDecl;

hokein wrote:
> didn't quite follow the code here, the code looks like we get the 
> FunctionTemplateDecl back via the code path (FunctionTemplateDecl -> 
> FunctionDecl -> FunctionTemplateDecl), and it looks like we're not using the 
> specialized declaration as the canonical decl.
Uh, good catch, thanks. This one is simply not needed because we handle 
`TemplateDecl` which does the right thing for `FunctionTemplateDecl`.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:255
+const NamedDecl *canonicalRenameDecl(const ClassTemplateSpecializationDecl *D) 
{
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}

hokein wrote:
> want to confirm my understanding:
> 
> given the example below:
> 
> ```
> template
> class Foo {};
> 
> template<>
> class Foo {};
> ```
> 
> the AST is like:
> 
> ```
> ClassTemplateDecl
>   |-CXXRecordDecl (Foo definition) -> (1)
>   |-ClassTemplateSpecialization. 
> 
> ClassTemplateSpecializationDecl -> call canonicalRenameDecl on it.
>   |-Template Argument int
>   |-CXXRecordDecl -> (2)
> ```
> 
> if we pass `ClassTemplateSpecializationDecl` to this function, this function 
> will return (2)?
No, this will return (1): `getSpecializedTemplate()` returns 
`ClassTemplateDecl` and then `getTemplatedDecl()` gets to `CXXRecordDecl` in it.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:261
+//   CXXRecordDecl
+// - Specializations should point to the specialized declaration.
+// - Instantiations should point to instantiated declaration.

hokein wrote:
> I think the motivation is for merely renaming the explicit template 
> specialization, but not the primary template?
How come? The specialized template is the primary template, am I missing 
something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

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


[PATCH] D71880: [clangd] Implement Decl canonicalization rules for rename

2020-11-18 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 306027.
kbobyrev added a comment.

Remove leftover test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71880

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp

Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -18,7 +18,6 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
-#include "clang/Tooling/Refactoring/Rename/USRFindingAction.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
@@ -76,6 +75,8 @@
   return OtherFile;
 }
 
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D);
+
 llvm::DenseSet locateDeclAt(ParsedAST &AST,
SourceLocation TokenStartLoc) {
   unsigned Offset =
@@ -91,9 +92,7 @@
   for (const NamedDecl *D :
targetDecl(SelectedNode->ASTNode,
   DeclRelation::Alias | DeclRelation::TemplatePattern)) {
-// Get to CXXRecordDecl from constructor or destructor.
-D = tooling::getCanonicalSymbolDeclaration(D);
-Result.insert(D);
+Result.insert(canonicalRenameDecl(D));
   }
   return Result;
 }
@@ -222,23 +221,65 @@
   return error("Cannot rename symbol: {0}", Message(Reason));
 }
 
+const NamedDecl *canonicalRenameDecl(const TemplateDecl *D) {
+  return D->getTemplatedDecl();
+}
+
+const NamedDecl *canonicalRenameDecl(const CXXMethodDecl *D) {
+  const CXXMethodDecl *Result = D;
+  if (const FunctionDecl *InstantiatedMethod =
+  D->getInstantiatedFromMemberFunction())
+Result = cast(InstantiatedMethod);
+  while (Result->isVirtual() && Result->size_overridden_methods())
+Result = *Result->overridden_methods().begin();
+  return Result;
+}
+
+const NamedDecl *canonicalRenameDecl(const FunctionDecl *D) {
+  if (const FunctionTemplateDecl *Template = D->getPrimaryTemplate())
+return canonicalRenameDecl(Template);
+  return D;
+}
+
+const NamedDecl *canonicalRenameDecl(const VarTemplateSpecializationDecl *D) {
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}
+
+const NamedDecl *canonicalRenameDecl(const ClassTemplateSpecializationDecl *D) {
+  return D->getSpecializedTemplate()->getTemplatedDecl();
+}
+
+// Canonical declarations help simplify the process of renaming. Examples:
+// - Given a constructor/destructor, canonical declaration is the parent
+//   CXXRecordDecl
+// - Specializations should point to the specialized declaration.
+// - Instantiations should point to instantiated declaration.
+const NamedDecl *canonicalRenameDecl(const NamedDecl *D) {
+  D = dyn_cast(D->getCanonicalDecl());
+  if (const auto *Constructor = dyn_cast(D))
+return canonicalRenameDecl(Constructor->getParent());
+  if (const auto *Destructor = dyn_cast(D))
+return canonicalRenameDecl(Destructor->getParent());
+  if (const auto *VarTemplate = dyn_cast(D))
+return canonicalRenameDecl(VarTemplate);
+  if (const auto *Template = dyn_cast(D))
+return canonicalRenameDecl(Template);
+  if (const auto *ClassTemplateSpecialization =
+  dyn_cast(D))
+return canonicalRenameDecl(ClassTemplateSpecialization);
+  if (const auto *Method = dyn_cast(D))
+return canonicalRenameDecl(Method);
+  if (const auto *Function = dyn_cast(D))
+return canonicalRenameDecl(Function);
+  return D;
+}
+
 // Return all rename occurrences in the main file.
 std::vector findOccurrencesWithinFile(ParsedAST &AST,
   const NamedDecl &ND) {
   trace::Span Tracer("FindOccurrencesWithinFile");
-  // If the cursor is at the underlying CXXRecordDecl of the
-  // ClassTemplateDecl, ND will be the CXXRecordDecl. In this case, we need to
-  // get the primary template manually.
-  // getUSRsForDeclaration will find other related symbols, e.g. virtual and its
-  // overriddens, primary template and all explicit specializations.
-  // FIXME: Get rid of the remaining tooling APIs.
-  const auto *RenameDecl =
-  ND.getDescribedTemplate() ? ND.getDescribedTemplate() : &ND;
-  std::vector RenameUSRs =
-  tooling::getUSRsForDeclaration(RenameDecl, AST.getASTContext());
-  llvm::DenseSet TargetIDs;
-  for (auto &USR : RenameUSRs)
-TargetIDs.insert(SymbolID(USR));
+  assert(canonicalRenameDecl(&ND) == &ND &&
+ "ND should be already canonicalized.");
 
   std::vector Results;
   for (Decl *TopLevelDecl : AST.getLocalTopLevelDecls()) {
@@ -246,11 +287,11 @@
   if (Ref.Targets.empty())
 return;
   for (const auto *Target : Ref.Targets) {
-auto ID = getSymbolID(Target);
-if (!ID || TargetIDs.find(ID) == TargetIDs.end())
+if (canonicalRenameDecl(Target) == &ND) {
+  Results.push_back(Ref.NameLo

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

2020-11-18 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

If data mappings can overlap, then it follows that copies to/from the target 
must be done sequentially by the runtime, unless additional information on 
their independence exists. Alias analysis style.

I see the programmer convenience angle, but it is a shame to no longer be able 
to perform the to: mappings simultaneously.


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


[clang] 1e6fc2f - [clang][cli] Port Migrator option flags to new option parsing system

2020-11-18 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2020-11-18T12:18:27+01:00
New Revision: 1e6fc2fa532c280abec04f83410dfdb3760dfc0f

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

LOG: [clang][cli] Port Migrator option flags to new option parsing system

Depends on D83406

Reviewed By: Bigcheese

Original patch by Daniel Grumberg.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 01d90a47101b..7a75eb683249 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3791,10 +3791,12 @@ def analyzer_werror : Flag<["-"], "analyzer-werror">,
 // Migrator Options
 
//===--===//
 def migrator_no_nsalloc_error : Flag<["-"], "no-ns-alloc-error">,
-  HelpText<"Do not error on use of 
NSAllocateCollectable/NSReallocateCollectable">;
+  HelpText<"Do not error on use of 
NSAllocateCollectable/NSReallocateCollectable">,
+  MarshallingInfoFlag<"MigratorOpts.NoNSAllocReallocError">;
 
 def migrator_no_finalize_removal : Flag<["-"], "no-finalize-removal">,
-  HelpText<"Do not remove finalize method in gc mode">;
+  HelpText<"Do not remove finalize method in gc mode">,
+  MarshallingInfoFlag<"MigratorOpts.NoFinalizeRemoval">;
 
 
//===--===//
 // CodeGen Options

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 2c54611e4912..a0ed8178b9df 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -683,12 +683,6 @@ static void parseAnalyzerConfigs(AnalyzerOptions &AnOpts,
<< "a filename";
 }
 
-static bool ParseMigratorArgs(MigratorOptions &Opts, ArgList &Args) {
-  Opts.NoNSAllocReallocError = Args.hasArg(OPT_migrator_no_nsalloc_error);
-  Opts.NoFinalizeRemoval = Args.hasArg(OPT_migrator_no_finalize_removal);
-  return true;
-}
-
 static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args) {
   Opts.BlockCommandNames = Args.getAllArgValues(OPT_fcomment_block_commands);
   Opts.ParseAllComments = Args.hasArg(OPT_fparse_all_comments);
@@ -3838,7 +3832,6 @@ bool 
CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
   FixupInvocation(Res);
 
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
-  Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
   if (!Res.getDependencyOutputOpts().OutputFile.empty() &&
   Res.getDependencyOutputOpts().Targets.empty()) {



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


[PATCH] D83690: Port Migator option flags to new option parsing system

2020-11-18 Thread Jan Svoboda 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 rG1e6fc2fa532c: [clang][cli] Port Migrator option flags to new 
option parsing system (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D83690?vs=277473&id=306033#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83690

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -683,12 +683,6 @@
<< "a filename";
 }
 
-static bool ParseMigratorArgs(MigratorOptions &Opts, ArgList &Args) {
-  Opts.NoNSAllocReallocError = Args.hasArg(OPT_migrator_no_nsalloc_error);
-  Opts.NoFinalizeRemoval = Args.hasArg(OPT_migrator_no_finalize_removal);
-  return true;
-}
-
 static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args) {
   Opts.BlockCommandNames = Args.getAllArgValues(OPT_fcomment_block_commands);
   Opts.ParseAllComments = Args.hasArg(OPT_fparse_all_comments);
@@ -3838,7 +3832,6 @@
   FixupInvocation(Res);
 
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
-  Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
   if (!Res.getDependencyOutputOpts().OutputFile.empty() &&
   Res.getDependencyOutputOpts().Targets.empty()) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3791,10 +3791,12 @@
 // Migrator Options
 
//===--===//
 def migrator_no_nsalloc_error : Flag<["-"], "no-ns-alloc-error">,
-  HelpText<"Do not error on use of 
NSAllocateCollectable/NSReallocateCollectable">;
+  HelpText<"Do not error on use of 
NSAllocateCollectable/NSReallocateCollectable">,
+  MarshallingInfoFlag<"MigratorOpts.NoNSAllocReallocError">;
 
 def migrator_no_finalize_removal : Flag<["-"], "no-finalize-removal">,
-  HelpText<"Do not remove finalize method in gc mode">;
+  HelpText<"Do not remove finalize method in gc mode">,
+  MarshallingInfoFlag<"MigratorOpts.NoFinalizeRemoval">;
 
 
//===--===//
 // CodeGen Options


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -683,12 +683,6 @@
<< "a filename";
 }
 
-static bool ParseMigratorArgs(MigratorOptions &Opts, ArgList &Args) {
-  Opts.NoNSAllocReallocError = Args.hasArg(OPT_migrator_no_nsalloc_error);
-  Opts.NoFinalizeRemoval = Args.hasArg(OPT_migrator_no_finalize_removal);
-  return true;
-}
-
 static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args) {
   Opts.BlockCommandNames = Args.getAllArgValues(OPT_fcomment_block_commands);
   Opts.ParseAllComments = Args.hasArg(OPT_fparse_all_comments);
@@ -3838,7 +3832,6 @@
   FixupInvocation(Res);
 
   Success &= ParseAnalyzerArgs(*Res.getAnalyzerOpts(), Args, Diags);
-  Success &= ParseMigratorArgs(Res.getMigratorOpts(), Args);
   ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), Args);
   if (!Res.getDependencyOutputOpts().OutputFile.empty() &&
   Res.getDependencyOutputOpts().Targets.empty()) {
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3791,10 +3791,12 @@
 // Migrator Options
 //===--===//
 def migrator_no_nsalloc_error : Flag<["-"], "no-ns-alloc-error">,
-  HelpText<"Do not error on use of NSAllocateCollectable/NSReallocateCollectable">;
+  HelpText<"Do not error on use of NSAllocateCollectable/NSReallocateCollectable">,
+  MarshallingInfoFlag<"MigratorOpts.NoNSAllocReallocError">;
 
 def migrator_no_finalize_removal : Flag<["-"], "no-finalize-removal">,
-  HelpText<"Do not remove finalize method in gc mode">;
+  HelpText<"Do not remove finalize method in gc mode">,
+  MarshallingInfoFlag<"MigratorOpts.NoFinalizeRemoval">;
 
 //===--===//
 // CodeGen Options
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91656: [clang-tidy] add concurrency module

2020-11-18 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Now that you have added the concurrency module as a new patch, all that code 
needs removing from this diff. If you generate the diff from that patch it 
should work. You should only be left with the code needed to add this check to 
that module.


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

https://reviews.llvm.org/D91656

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


[PATCH] D91656: [clang-tidy] add concurrency module

2020-11-18 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Can you remove the code related to adding the mt-unsafe-posix check.


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

https://reviews.llvm.org/D91656

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


[PATCH] D83211: Factor out call to EXTRACTOR in generateCC1CommandLine

2020-11-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 306035.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83211

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -263,6 +263,9 @@
   return KeyPath | Value;
 }
 
+// The value returned by an extractor is stored as a constant reference.
+// Watch out for missed reference lifetime extension.
+
 template  static T extractForwardValue(T KeyPath) {
   return KeyPath;
 }
@@ -4044,9 +4047,10 @@
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  
\
-  if (((FLAGS) & options::CC1Option) &&
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != (DEFAULT_VALUE))) {  
\
-DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   
\
+  if ((FLAGS)&options::CC1Option) {
\
+const auto &Extracted = EXTRACTOR(this->KEYPATH);  
\
+if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE))   
\
+  DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);
\
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(   
\
@@ -4054,10 +4058,10 @@
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  
\
 NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,  
\
 NEG_SPELLING)  
\
-  if (((FLAGS)&options::CC1Option) &&  
\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {
\
-DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX,
\
- EXTRACTOR(this->KEYPATH));
\
+  if ((FLAGS)&options::CC1Option) {
\
+const auto &Extracted = EXTRACTOR(this->KEYPATH);  
\
+if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE))   
\
+  DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX, Extracted);  
\
   }
 
 #include "clang/Driver/Options.inc"


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -263,6 +263,9 @@
   return KeyPath | Value;
 }
 
+// The value returned by an extractor is stored as a constant reference.
+// Watch out for missed reference lifetime extension.
+
 template  static T extractForwardValue(T KeyPath) {
   return KeyPath;
 }
@@ -4044,9 +4047,10 @@
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
 NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  \
-  if (((FLAGS) & options::CC1Option) &&\
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != (DEFAULT_VALUE))) {  \
-DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, EXTRACTOR(this->KEYPATH));   \
+  if ((FLAGS)&options::CC1Option) {\
+const auto &Extracted = EXTRACTOR(this->KEYPATH);  \
+if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE))   \
+  DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);\
   }
 
 #define OPTION_WITH_MARSHALLING_BOOLEAN(   \
@@ -4054,10 +4058,10 @@
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
 NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX, NEG_ID,  \
 NEG_SPELLING)  \
-  if (((FLAGS)&options::CC1Option) &&  \
-  (ALWAYS_EMIT || EXTRACTOR(this->KEYPATH) != DEFAULT_VALUE)) {\
-DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX,\
- EXTRACTOR(this->KEYPATH));\
+  if ((FLAGS)&options::CC1Option) {\
+const auto &Extracted = EXTRACTOR(this->KEYPATH);  \
+if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE))   \
+  DENORMALIZER(Args, SPELLING, NEG_SPELLING, SA, TABLE_INDEX, Extracted);  \

[PATCH] D91559: Add sysroot/lib to library search path of baremetal toolchain.

2020-11-18 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh updated this revision to Diff 306036.
abidh added a comment.

Handle review comment.


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

https://reviews.llvm.org/D91559

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
@@ -34,6 +35,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
@@ -47,6 +49,7 @@
 // CHECK-V6M-LIBCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
@@ -60,6 +63,7 @@
 // CHECK-V6M-LIBSTDCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}6.0.0"
 // CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
@@ -70,7 +74,8 @@
 // RUN: -nodefaultlibs \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-NDL %s
 // CHECK-V6M-NDL: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" 
"-Bstatic"
-// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 "-o" "{{.*}}.o"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib" "-o" 
"{{.*}}.o"
 
 // RUN: %clangxx -target arm-none-eabi -v 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -33,6 +33,11 @@
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
+  SmallString<128> SysRoot(getDriver().SysRoot);
+  if (!SysRoot.empty()) {
+llvm::sys::path::append(SysRoot, "lib");
+getFilePaths().push_back(std::string(SysRoot));
+  }
 }
 
 /// Is the triple {arm,thumb}-none-none-{eabi,eabihf} ?
@@ -189,6 +194,7 @@
 
   CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
 
+  TC.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" "-Lsome{{[/\\

[PATCH] D91559: Add sysroot/lib to library search path of baremetal toolchain.

2020-11-18 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
abidh marked an inline comment as done.
abidh added inline comments.



Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:39
+llvm::sys::path::append(SysRoot, "lib");
+getFilePaths().push_back(std::string(SysRoot.str()));
+  }

jroelofs wrote:
> Is the explicit `std::string` ctor call necessary here? Since `SmallString` 
> has an `operator std::string() const`, I think this can just be:
> 
> ```
> getFilePaths().push_back(SysRoot);
> ```
That operator is explicit. Although I noticed that I did not need the str() 
call.


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

https://reviews.llvm.org/D91559

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


[clang] 680931a - [Matrix] Adjust matrix pointer type for inline asm arguments.

2020-11-18 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2020-11-18T11:44:11Z
New Revision: 680931af2757fb495c5727d335ffa580fb3dbe98

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

LOG: [Matrix] Adjust matrix pointer type for inline asm arguments.

Matrix types in memory are represented as arrays, but accessed through
vector pointers, with the alignment specified on the access operation.

For inline assembly, update pointer arguments to use vector pointers.
Otherwise there will be a mis-match if the matrix is also an
input-argument which is represented as vector.

Reviewed By: nickdesaulniers

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmt.cpp
clang/test/CodeGen/matrix-type.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index d8be0ef4e525..d67e73a2ec3b 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -2306,8 +2306,21 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
 std::max((uint64_t)LargestVectorWidth,
  VT->getPrimitiveSizeInBits().getKnownMinSize());
 } else {
-  ArgTypes.push_back(Dest.getAddress(*this).getType());
-  Args.push_back(Dest.getPointer(*this));
+  llvm::Type *DestAddrTy = Dest.getAddress(*this).getType();
+  llvm::Value *DestPtr = Dest.getPointer(*this);
+  // Matrix types in memory are represented by arrays, but accessed through
+  // vector pointers, with the alignment specified on the access operation.
+  // For inline assembly, update pointer arguments to use vector pointers.
+  // Otherwise there will be a mis-match if the matrix is also an
+  // input-argument which is represented as vector.
+  if (isa(OutExpr->getType().getCanonicalType())) {
+DestAddrTy = llvm::PointerType::get(
+ConvertType(OutExpr->getType()),
+cast(DestAddrTy)->getAddressSpace());
+DestPtr = Builder.CreateBitCast(DestPtr, DestAddrTy);
+  }
+  ArgTypes.push_back(DestAddrTy);
+  Args.push_back(DestPtr);
   Constraints += "=*";
   Constraints += OutputConstraint;
   ReadOnly = ReadNone = false;

diff  --git a/clang/test/CodeGen/matrix-type.c 
b/clang/test/CodeGen/matrix-type.c
index 399984b50c69..ab239a247b1d 100644
--- a/clang/test/CodeGen/matrix-type.c
+++ b/clang/test/CodeGen/matrix-type.c
@@ -162,10 +162,10 @@ void matrix_inline_asm_memory_readwrite() {
   // CHECK-LABEL: define void @matrix_inline_asm_memory_readwrite()
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:[[ALLOCA:%.+]] = alloca [16 x double], align 8
-  // CHECK-NEXT:[[PTR:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x 
double>*
-  // CHECK-NEXT:[[VAL:%.+]] = load <16 x double>, <16 x double>* [[PTR]], 
align 8
-  // FIXME: Pointer element type does not match the vector type.
-  // CHECK-NEXT:call void asm sideeffect "", 
"=*r|m,0,~{memory},~{dirflag},~{fpsr},~{flags}"([16 x double]* [[ALLOCA]], <16 
x double> [[VAL]])
+  // CHECK-NEXT:[[PTR1:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x 
double>*
+  // CHECK-NEXT:[[PTR2:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x 
double>*
+  // CHECK-NEXT:[[VAL:%.+]] = load <16 x double>, <16 x double>* [[PTR2]], 
align 8
+  // CHECK-NEXT:call void asm sideeffect "", 
"=*r|m,0,~{memory},~{dirflag},~{fpsr},~{flags}"(<16 x double>* [[PTR1]], <16 x 
double> [[VAL]])
   // CHECK-NEXT:ret void
 
   dx4x4_t m;



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


[PATCH] D91631: [Matrix] Adjust matrix pointer type for inline asm arguments.

2020-11-18 Thread Florian Hahn 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 rG680931af2757: [Matrix] Adjust matrix pointer type for inline 
asm arguments. (authored by fhahn).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91631

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/matrix-type.c


Index: clang/test/CodeGen/matrix-type.c
===
--- clang/test/CodeGen/matrix-type.c
+++ clang/test/CodeGen/matrix-type.c
@@ -162,10 +162,10 @@
   // CHECK-LABEL: define void @matrix_inline_asm_memory_readwrite()
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:[[ALLOCA:%.+]] = alloca [16 x double], align 8
-  // CHECK-NEXT:[[PTR:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x 
double>*
-  // CHECK-NEXT:[[VAL:%.+]] = load <16 x double>, <16 x double>* [[PTR]], 
align 8
-  // FIXME: Pointer element type does not match the vector type.
-  // CHECK-NEXT:call void asm sideeffect "", 
"=*r|m,0,~{memory},~{dirflag},~{fpsr},~{flags}"([16 x double]* [[ALLOCA]], <16 
x double> [[VAL]])
+  // CHECK-NEXT:[[PTR1:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x 
double>*
+  // CHECK-NEXT:[[PTR2:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x 
double>*
+  // CHECK-NEXT:[[VAL:%.+]] = load <16 x double>, <16 x double>* [[PTR2]], 
align 8
+  // CHECK-NEXT:call void asm sideeffect "", 
"=*r|m,0,~{memory},~{dirflag},~{fpsr},~{flags}"(<16 x double>* [[PTR1]], <16 x 
double> [[VAL]])
   // CHECK-NEXT:ret void
 
   dx4x4_t m;
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2306,8 +2306,21 @@
 std::max((uint64_t)LargestVectorWidth,
  VT->getPrimitiveSizeInBits().getKnownMinSize());
 } else {
-  ArgTypes.push_back(Dest.getAddress(*this).getType());
-  Args.push_back(Dest.getPointer(*this));
+  llvm::Type *DestAddrTy = Dest.getAddress(*this).getType();
+  llvm::Value *DestPtr = Dest.getPointer(*this);
+  // Matrix types in memory are represented by arrays, but accessed through
+  // vector pointers, with the alignment specified on the access operation.
+  // For inline assembly, update pointer arguments to use vector pointers.
+  // Otherwise there will be a mis-match if the matrix is also an
+  // input-argument which is represented as vector.
+  if (isa(OutExpr->getType().getCanonicalType())) {
+DestAddrTy = llvm::PointerType::get(
+ConvertType(OutExpr->getType()),
+cast(DestAddrTy)->getAddressSpace());
+DestPtr = Builder.CreateBitCast(DestPtr, DestAddrTy);
+  }
+  ArgTypes.push_back(DestAddrTy);
+  Args.push_back(DestPtr);
   Constraints += "=*";
   Constraints += OutputConstraint;
   ReadOnly = ReadNone = false;


Index: clang/test/CodeGen/matrix-type.c
===
--- clang/test/CodeGen/matrix-type.c
+++ clang/test/CodeGen/matrix-type.c
@@ -162,10 +162,10 @@
   // CHECK-LABEL: define void @matrix_inline_asm_memory_readwrite()
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:[[ALLOCA:%.+]] = alloca [16 x double], align 8
-  // CHECK-NEXT:[[PTR:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x double>*
-  // CHECK-NEXT:[[VAL:%.+]] = load <16 x double>, <16 x double>* [[PTR]], align 8
-  // FIXME: Pointer element type does not match the vector type.
-  // CHECK-NEXT:call void asm sideeffect "", "=*r|m,0,~{memory},~{dirflag},~{fpsr},~{flags}"([16 x double]* [[ALLOCA]], <16 x double> [[VAL]])
+  // CHECK-NEXT:[[PTR1:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x double>*
+  // CHECK-NEXT:[[PTR2:%.+]] = bitcast [16 x double]* [[ALLOCA]] to <16 x double>*
+  // CHECK-NEXT:[[VAL:%.+]] = load <16 x double>, <16 x double>* [[PTR2]], align 8
+  // CHECK-NEXT:call void asm sideeffect "", "=*r|m,0,~{memory},~{dirflag},~{fpsr},~{flags}"(<16 x double>* [[PTR1]], <16 x double> [[VAL]])
   // CHECK-NEXT:ret void
 
   dx4x4_t m;
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -2306,8 +2306,21 @@
 std::max((uint64_t)LargestVectorWidth,
  VT->getPrimitiveSizeInBits().getKnownMinSize());
 } else {
-  ArgTypes.push_back(Dest.getAddress(*this).getType());
-  Args.push_back(Dest.getPointer(*this));
+  llvm::Type *DestAddrTy = Dest.getAddress(*this).getType();
+  llvm::Value *DestPtr = Dest.getPointer(*this);
+  // Matrix types in memory are represented by arrays, but accessed through
+  // vector pointers, with the alignment specified on the access operation.
+  // 

[PATCH] D91696: [AArch64][SVE] Allow lax conversion between VLATs and GNU vectors

2020-11-18 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis created this revision.
joechrisellis added reviewers: fpetrogalli, peterwaller-arm.
Herald added subscribers: cfe-commits, psnobl, kristof.beyls, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: clang.
joechrisellis requested review of this revision.

Previously, lax conversions were only allowed between SVE vector-length
agnostic types and vector-length specific types. This meant that code
such as the following:

  #include 
  #define N __ARM_FEATURE_SVE_BITS
  #define FIXED_ATTR __attribute__ ((vector_size (N/8)))
  typedef float fixed_float32_t FIXED_ATTR;
  
  void foo() {
  fixed_float32_t fs32;
  svfloat64_t s64;
  fs32 = s64;
  }

was not allowed.

This patch makes a minor change to areLaxCompatibleSveTypes to allow for
lax conversions to be performed between SVE vector-length agnostic types
and GNU vectors.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91696

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Sema/aarch64-sve-lax-vector-conversions.c
  clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp

Index: clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
===
--- clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
+++ clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
@@ -7,32 +7,61 @@
 #include 
 
 #define N __ARM_FEATURE_SVE_BITS
-#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+#define SVE_FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+#define GNU_FIXED_ATTR __attribute__((vector_size(N / 8)))
 
-typedef svfloat32_t fixed_float32_t FIXED_ATTR;
-typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svfloat32_t sve_fixed_float32_t SVE_FIXED_ATTR;
+typedef svint32_t sve_fixed_int32_t SVE_FIXED_ATTR;
+typedef float gnu_fixed_float32_t GNU_FIXED_ATTR;
+typedef int gnu_fixed_int32_t GNU_FIXED_ATTR;
 
-void allowed_with_integer_lax_conversions() {
-  fixed_int32_t fi32;
+void sve_allowed_with_integer_lax_conversions() {
+  sve_fixed_int32_t fi32;
   svint64_t si64;
 
   // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
   // -flax-vector-conversions={integer,all}.
   fi32 = si64;
-  // lax-vector-none-error@-1 {{assigning to 'fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+  // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
   si64 = fi32;
   // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
 }
 
-void allowed_with_all_lax_conversions() {
-  fixed_float32_t ff32;
+void sve_allowed_with_all_lax_conversions() {
+  sve_fixed_float32_t ff32;
   svfloat64_t sf64;
 
   // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
   // -flax-vector-conversions=all.
   ff32 = sf64;
-  // lax-vector-none-error@-1 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
-  // lax-vector-integer-error@-2 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-none-error@-1 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  sf64 = ff32;
+  // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
+}
+
+void gnu_allowed_with_integer_lax_conversions() {
+  gnu_fixed_int32_t fi32;
+  svint64_t si64;
+
+  // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
+  // -flax-vector-conversions={integer,all}.
+  fi32 = si64;
+  // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+  si64 = fi32;
+  // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+}
+
+void gnu_allowed_with_all_lax_conversions() {
+  gnu_fixed_float32_t ff32;
+  svfloat64_t sf64;
+
+  // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
+  // -flax-vector-conversions=all.
+  ff32 = sf64;
+  // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
   sf64 = ff32;
   // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
   // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
Index: clang/test/Sema/aarch64-sve-lax-vector-conversions.c
===
--- clang/test/Se

[PATCH] D90982: Ignore implicit nodes in IgnoreUnlessSpelledInSource mode

2020-11-18 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added subscribers: stephenkelly, RKSimon.
RKSimon added a comment.

@stephenkelly This is breaking a large number of bots - please can you revert 
your patch series to get things green again?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90982

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


[PATCH] D91696: [AArch64][SVE] Allow lax conversion between VLATs and GNU vectors

2020-11-18 Thread Will Lovett via Phabricator via cfe-commits
willlovett added a comment.

I found this one.  The fix looks sensible, and I believe the test is correct 
and consistent with the spec.  I'll leave it to someone else to accept.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91696

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


[PATCH] D83691: Port Comment option flags to new parsing system

2020-11-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a comment.

Taking over this patch, as Daniel is no longer involved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83691

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


[PATCH] D83691: Port Comment option flags to new parsing system

2020-11-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 306042.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83691

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -685,7 +685,6 @@
 
 static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args) {
   Opts.BlockCommandNames = Args.getAllArgValues(OPT_fcomment_block_commands);
-  Opts.ParseAllComments = Args.hasArg(OPT_fparse_all_comments);
 }
 
 /// Create a new Regex instance out of the string value in \p RpassArg.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -402,6 +402,11 @@
 // Make sure all other -ccc- options are rejected.
 def ccc_ : Joined<["-"], "ccc-">, Group, Flags<[Unsupported]>;
 
+// Comment Options
+
+def fparse_all_comments : Flag<["-"], "fparse-all-comments">, 
Group, Flags<[CC1Option]>,
+  MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments">;
+
 // Standard Options
 
 def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[NoXarchOption, CoreOption, 
FlangOption]>,
@@ -930,7 +935,6 @@
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, 
Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation 
comment block command">,
   MetaVarName<"">;
-def fparse_all_comments : Flag<["-"], "fparse-all-comments">, 
Group, Flags<[CC1Option]>;
 def frecord_command_line : Flag<["-"], "frecord-command-line">,
   Group;
 def fno_record_command_line : Flag<["-"], "fno-record-command-line">,


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -685,7 +685,6 @@
 
 static void ParseCommentArgs(CommentOptions &Opts, ArgList &Args) {
   Opts.BlockCommandNames = Args.getAllArgValues(OPT_fcomment_block_commands);
-  Opts.ParseAllComments = Args.hasArg(OPT_fparse_all_comments);
 }
 
 /// Create a new Regex instance out of the string value in \p RpassArg.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -402,6 +402,11 @@
 // Make sure all other -ccc- options are rejected.
 def ccc_ : Joined<["-"], "ccc-">, Group, Flags<[Unsupported]>;
 
+// Comment Options
+
+def fparse_all_comments : Flag<["-"], "fparse-all-comments">, Group, Flags<[CC1Option]>,
+  MarshallingInfoFlag<"LangOpts->CommentOpts.ParseAllComments">;
+
 // Standard Options
 
 def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[NoXarchOption, CoreOption, FlangOption]>,
@@ -930,7 +935,6 @@
 def fcomment_block_commands : CommaJoined<["-"], "fcomment-block-commands=">, Group, Flags<[CC1Option]>,
   HelpText<"Treat each comma separated argument in  as a documentation comment block command">,
   MetaVarName<"">;
-def fparse_all_comments : Flag<["-"], "fparse-all-comments">, Group, Flags<[CC1Option]>;
 def frecord_command_line : Flag<["-"], "frecord-command-line">,
   Group;
 def fno_record_command_line : Flag<["-"], "fno-record-command-line">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83691: Port Comment option flags to new parsing system

2020-11-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

WDYT @Bigcheese?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83691

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


[PATCH] D91696: [AArch64][SVE] Allow lax conversion between VLATs and GNU vectors

2020-11-18 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 306043.
joechrisellis added a comment.

Remove redundant tests from clang/test/Sema/attr-arm-sve-vector-bits.c.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91696

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Sema/aarch64-sve-lax-vector-conversions.c
  clang/test/Sema/attr-arm-sve-vector-bits.c
  clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp

Index: clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
===
--- clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
+++ clang/test/SemaCXX/aarch64-sve-lax-vector-conversions.cpp
@@ -7,32 +7,61 @@
 #include 
 
 #define N __ARM_FEATURE_SVE_BITS
-#define FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+#define SVE_FIXED_ATTR __attribute__((arm_sve_vector_bits(N)))
+#define GNU_FIXED_ATTR __attribute__((vector_size(N / 8)))
 
-typedef svfloat32_t fixed_float32_t FIXED_ATTR;
-typedef svint32_t fixed_int32_t FIXED_ATTR;
+typedef svfloat32_t sve_fixed_float32_t SVE_FIXED_ATTR;
+typedef svint32_t sve_fixed_int32_t SVE_FIXED_ATTR;
+typedef float gnu_fixed_float32_t GNU_FIXED_ATTR;
+typedef int gnu_fixed_int32_t GNU_FIXED_ATTR;
 
-void allowed_with_integer_lax_conversions() {
-  fixed_int32_t fi32;
+void sve_allowed_with_integer_lax_conversions() {
+  sve_fixed_int32_t fi32;
   svint64_t si64;
 
   // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
   // -flax-vector-conversions={integer,all}.
   fi32 = si64;
-  // lax-vector-none-error@-1 {{assigning to 'fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+  // lax-vector-none-error@-1 {{assigning to 'sve_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
   si64 = fi32;
   // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
 }
 
-void allowed_with_all_lax_conversions() {
-  fixed_float32_t ff32;
+void sve_allowed_with_all_lax_conversions() {
+  sve_fixed_float32_t ff32;
   svfloat64_t sf64;
 
   // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
   // -flax-vector-conversions=all.
   ff32 = sf64;
-  // lax-vector-none-error@-1 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
-  // lax-vector-integer-error@-2 {{assigning to 'fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-none-error@-1 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'sve_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  sf64 = ff32;
+  // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
+}
+
+void gnu_allowed_with_integer_lax_conversions() {
+  gnu_fixed_int32_t fi32;
+  svint64_t si64;
+
+  // The implicit cast here should fail if -flax-vector-conversions=none, but pass if
+  // -flax-vector-conversions={integer,all}.
+  fi32 = si64;
+  // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_int32_t' (vector of 16 'int' values) from incompatible type}}
+  si64 = fi32;
+  // lax-vector-none-error@-1 {{assigning to 'svint64_t' (aka '__SVInt64_t') from incompatible type}}
+}
+
+void gnu_allowed_with_all_lax_conversions() {
+  gnu_fixed_float32_t ff32;
+  svfloat64_t sf64;
+
+  // The implicit cast here should fail if -flax-vector-conversions={none,integer}, but pass if
+  // -flax-vector-conversions=all.
+  ff32 = sf64;
+  // lax-vector-none-error@-1 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
+  // lax-vector-integer-error@-2 {{assigning to 'gnu_fixed_float32_t' (vector of 16 'float' values) from incompatible type}}
   sf64 = ff32;
   // lax-vector-none-error@-1 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
   // lax-vector-integer-error@-2 {{assigning to 'svfloat64_t' (aka '__SVFloat64_t') from incompatible type}}
Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -272,16 +272,6 @@
 // Test the implicit conversion only applies to valid types
 fixed_bool_t to_fixed_bool_t__from_svint32_t(svint32_t x) { return x; } // expected-error-re {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'fixed_bool_t' (vector of {{[0-9]+}} 'unsigned char' values)}}
 
-svint64_t to_svint64_t__from_gnu_int32_t(gnu_int32_t x) { return x; } // expected-error-re {{returning 'gnu_int32_t' (vector of {{[0-9]+}} 'int32_t' values) from a function with incompatible result type 'svi

[PATCH] D91656: [clang-tidy] add concurrency module

2020-11-18 Thread Vasily Kulikov via Phabricator via cfe-commits
segoon updated this revision to Diff 306044.
segoon added a comment.

- remove garbage files


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

https://reviews.llvm.org/D91656

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
  clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/index.rst

Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -64,6 +64,8 @@
 ``bugprone-``  Checks that target bugprone code constructs.
 ``cert-``  Checks related to CERT Secure Coding Guidelines.
 ``clang-analyzer-``Clang Static Analyzer checks.
+``concurrency-``   Checks related to concurrent programming (including
+   threads, fibers, coroutines, etc.).
 ``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
 ``darwin-``Checks related to Darwin coding conventions.
 ``fuchsia-``   Checks related to Fuchsia coding conventions.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -82,6 +82,11 @@
   `Altera SDK for OpenCL: Best Practices Guide
   `_.
 
+- New ``concurrency`` module.
+
+  Includes checks related to concurrent programming (e.g. threads, fibers,
+  coroutines, etc.).
+
 New checks
 ^^
 
Index: clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/concurrency/ConcurrencyTidyModule.cpp
@@ -0,0 +1,33 @@
+//===--- ConcurrencyTidyModule.cpp - clang-tidy ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "../ClangTidy.h"
+#include "../ClangTidyModule.h"
+#include "../ClangTidyModuleRegistry.h"
+
+namespace clang {
+namespace tidy {
+namespace concurrency {
+
+class ConcurrencyModule : public ClangTidyModule {
+public:
+  void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {}
+};
+
+} // namespace concurrency
+
+// Register the ConcurrencyTidyModule using this statically initialized variable.
+static ClangTidyModuleRegistry::Add
+X("concurrency-module", "Adds concurrency checks.");
+
+// This anchor is used to force the linker to link in the generated object file
+// and thus register the ConcurrencyModule.
+volatile int ConcurrencyModuleAnchorSource = 0;
+
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/concurrency/CMakeLists.txt
@@ -0,0 +1,23 @@
+set(LLVM_LINK_COMPONENTS
+  FrontendOpenMP
+  Support
+  )
+
+add_clang_library(clangTidyConcurrencyModule
+  ConcurrencyTidyModule.cpp
+
+  LINK_LIBS
+  clangTidy
+  clangTidyUtils
+  )
+
+clang_target_link_libraries(clangTidyConcurrencyModule
+  PRIVATE
+  clangAnalysis
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangLex
+  clangSerialization
+  clangTooling
+  )
Index: clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
===
--- clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
+++ clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
@@ -45,6 +45,11 @@
 static int LLVM_ATTRIBUTE_UNUSED CERTModuleAnchorDestination =
 CERTModuleAnchorSource;
 
+// This anchor is used to force the linker to link the ConcurrencyModule.
+extern volatile int ConcurrencyModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED ConcurrencyModuleAnchorDestination =
+ConcurrencyModuleAnchorSource;
+
 // This anchor is used to force the linker to link the CppCoreGuidelinesModule.
 extern volatile int CppCoreGuidelinesModuleAnchorSource;
 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
Index: clang-tools-extra/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/CMakeLists.txt
@@ -73,6 +73,7 @@
 add_subdirectory(performance)
 add_subdirectory(portability)
 add_subdirectory(readability)
+add_subdirectory(concurrency)
 add_subdirectory(zircon)
 set(ALL_CLANG_TIDY_CHECKS
   clangTidy

[PATCH] D91656: [clang-tidy] add concurrency module

2020-11-18 Thread Vasily Kulikov via Phabricator via cfe-commits
segoon added a comment.

In D91656#2402245 , @njames93 wrote:

> Can you remove the code related to adding the mt-unsafe-posix check.

Sorry, I've added unnecessary files. Removed now.


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

https://reviews.llvm.org/D91656

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


[PATCH] D17993: [CodeGen] Apply 'nonnull' and 'dereferenceable(N)' to 'this' pointer arguments.

2020-11-18 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2169
+if (!CodeGenOpts.NullPointerIsValid &&
+getContext().getTargetAddressSpace(FI.arg_begin()->type) == 0) {
+  Attrs.addAttribute(llvm::Attribute::NonNull);

rjmccall wrote:
> rsmith wrote:
> > jdoerfert wrote:
> > > rjmccall wrote:
> > > > rsmith wrote:
> > > > > jdoerfert wrote:
> > > > > > arichardson wrote:
> > > > > > > Isn't the `this` pointer also nonnull in other address spaces?
> > > > > > > 
> > > > > > > In our CHERI fork we use AS200 for the this pointer and would 
> > > > > > > quite like to have the nonnull attribute.
> > > > > > > I can obviously change this line locally when I next merge from 
> > > > > > > upstream, but I would like to avoid diffs and it seems to me like 
> > > > > > > this restriction is unnecessary.
> > > > > > I also think `NullPointerIsValid` is sufficient. 
> > > > > It's my understanding that:
> > > > > * The LLVM `null` value in any address space is the all-zero-bits 
> > > > > value.
> > > > > * In address space zero, the `null` value does not correspond to 
> > > > > addressable memory, but this is not assumed to hold in other address 
> > > > > spaces.
> > > > > * An address-space-zero `null` value that is addressspacecast to a 
> > > > > different address space might not be the `null` in the target address 
> > > > > space.
> > > > > * The `nonnull` attribute implies that the pointer value is not the 
> > > > > `null` value.
> > > > > * A null pointer in the frontend in a non-zero address space 
> > > > > corresponds to the value produced by an addressspacecast of an 
> > > > > address-space-zero `null` value to the target address space.
> > > > > 
> > > > > That being the case, there is simply no connection between the C and 
> > > > > C++ notion of a null pointer and a `null` LLVM pointer value in a 
> > > > > non-zero address space in general, so it is not correct to use the 
> > > > > `nonnull` attribute in a non-zero address space in general. Only if 
> > > > > we know that a C++ null pointer is actually represented by the LLVM 
> > > > > `null` value in the corresponding address space can we use the 
> > > > > `nonnull` attribute to expose that fact to LLVM. And we do not know 
> > > > > that in general.
> > > > I think all of this is correct except that the frontend does know what 
> > > > the bit-pattern of the null pointer is in any particular language-level 
> > > > address space, and it knows what the language-level address space of 
> > > > `this` is.  So we should be able to ask whether the null value in the 
> > > > `this` address space is the all-zero value and use that to decide 
> > > > whether to apply `nonnull`.
> > > Hm, I think the problem is that we don't couple `NullPointerIsValid` with 
> > > the address space. As I said before. In LLVM-IR, if we don't have the 
> > > `null-pointer-is-valid` property, then "memory access" implies 
> > > `dereferenceable` implies `nonnull`. Now, we usually assume non-0 address 
> > > spaces to have the above property, but that should be decoupled. The 
> > > query if "null is valid" should take the function and the AS, as it does 
> > > conceptually in LLVM-core, and then decide if `null-pointer-is-valid` or 
> > > not. If we had that, @arichardson could define that AS200 does not have 
> > > valid null pointers. If you do that right now the IR passes will at least 
> > > deduce `nonnull` based on `derferenceable`.
> > > I think all of this is correct except that the frontend does know what 
> > > the bit-pattern of the null pointer is in any particular language-level 
> > > address space
> > 
> > Interesting. How do we get at that? Do we ask the middle-end to 
> > constant-fold `addrspacecast i8* null to i8* addrspace(N)` and see if we 
> > get a `null` back, or is there a better way?
> > 
> > In any case, this patch follows the same pattern we use for return values 
> > of reference type, parameters of reference type, and decayed array function 
> > parameters with static array bounds, all of which apply `nonnull` only in 
> > address space 0. If we want to use a different pattern, to consider whether 
> > LLVM's `nonnull` means "not a null pointer" rather than assuming that holds 
> > only in address space 0, we should make a holistic change for that 
> > throughout CGCall.cpp, rather than touching only the handling of the `this` 
> > pointer.
> > 
> > It'd also be interesting to consider what we want 
> > `__attribute__((nonnull))` to mean in address spaces where the null pointer 
> > isn't the zero pointer: should it mean non-zero at the source level / 
> > non-null in LLVM IR, or should it mean non-null at the source level (which 
> > might be unrepresentable in LLVM IR, but static analysis etc. could still 
> > detect it)? We're currently inconsistent on this: static analysis, constant 
> > evaluation, and sanitizers treat the attribute as meaning non-null, but IR 
> > ge

[PATCH] D91694: [clangd] Remove the trailing "." in add-using message.

2020-11-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 306045.
hokein added a comment.

Fix other code actions as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91694

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp


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
@@ -38,7 +38,9 @@
 
   bool prepare(const Selection &Inputs) override;
   Expected apply(const Selection &Inputs) override;
-  std::string title() const override;
+  std::string title() const override {
+return "Remove using namespace, re-qualify names instead";
+  }
   llvm::StringLiteral kind() const override {
 return CodeAction::REFACTOR_KIND;
   }
@@ -200,10 +202,6 @@
   return Effect::mainFileEdit(SM, std::move(R));
 }
 
-std::string RemoveUsingNamespace::title() const {
-  return std::string(
-  llvm::formatv("Remove using namespace, re-qualify names instead."));
-}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -360,7 +360,7 @@
 return CodeAction::REFACTOR_KIND;
   }
   std::string title() const override {
-return "Move function body to out-of-line.";
+return "Move function body to out-of-line";
   }
 
   bool prepare(const Selection &Sel) override {
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -52,7 +52,7 @@
 
 std::string AddUsing::title() const {
   return std::string(llvm::formatv(
-  "Add using-declaration for {0} and remove qualifier.", Name));
+  "Add using-declaration for {0} and remove qualifier", Name));
 }
 
 // Locates all "using" statements relevant to SelectionDeclContext.


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
@@ -38,7 +38,9 @@
 
   bool prepare(const Selection &Inputs) override;
   Expected apply(const Selection &Inputs) override;
-  std::string title() const override;
+  std::string title() const override {
+return "Remove using namespace, re-qualify names instead";
+  }
   llvm::StringLiteral kind() const override {
 return CodeAction::REFACTOR_KIND;
   }
@@ -200,10 +202,6 @@
   return Effect::mainFileEdit(SM, std::move(R));
 }
 
-std::string RemoveUsingNamespace::title() const {
-  return std::string(
-  llvm::formatv("Remove using namespace, re-qualify names instead."));
-}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -360,7 +360,7 @@
 return CodeAction::REFACTOR_KIND;
   }
   std::string title() const override {
-return "Move function body to out-of-line.";
+return "Move function body to out-of-line";
   }
 
   bool prepare(const Selection &Sel) override {
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -52,7 +52,7 @@
 
 std::string AddUsing::title() const {
   return std::string(llvm::formatv(
-  "Add using-declaration for {0} and remove qualifier.", Name));
+  "Add using-declaration for {0} and remove qualifier", Name));
 }
 
 // Locates all "using" statements relevant to SelectionDeclContext.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91694: [clangd] Remove the trailing "." in add-using message.

2020-11-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D91694#2402203 , @njames93 wrote:

> If you are doing this may as well cover `DefineOutline` and 
> `RemoveUsingNamespace` - that one can do away with formatv too.

good catch, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91694

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


[PATCH] D90835: [RFC][clang-tidy] Ignore diagnostics due to macro expansion from not-interested headers

2020-11-18 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 306046.
DmitryPolukhin marked 2 inline comments as done.
DmitryPolukhin added a comment.

- addressed comments in the diff
- stop ignoring system macro


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90835

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/test/clang-tidy/infrastructure/macros.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/macros.h
  clang-tools-extra/test/clang-tidy/infrastructure/macros_filter.h

Index: clang-tools-extra/test/clang-tidy/infrastructure/macros_filter.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/macros_filter.h
@@ -0,0 +1,3 @@
+#define HEADER_FILTER_MACRO_DIAG_IN_ARG(a) a
+#define HEADER_FILTER_MACRO_DIAG_IN_BODY int var_B1[10]
+#define HEADER_FILTER_MACRO_DIAG_IN_BODY2 int var_B2[10]
Index: clang-tools-extra/test/clang-tidy/infrastructure/macros.h
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/macros.h
@@ -0,0 +1,9 @@
+#define HEADER_MACRO_DIAG_IN_ARG(a) a
+#define HEADER_MACRO_DIAG_IN_BODY int var_C1[10]
+#define HEADER_MACRO_DIAG_IN_BODY2 int var_C2[10]
+
+#define DEFINE_bool(name, val)\
+  namespace fLB { \
+  typedef char FLAG_##name##_value_is_not_a_bool[(sizeof(val) != sizeof(bool)) ? -1 : 1]; \
+  }   \
+  bool FLAG_##name = val
Index: clang-tools-extra/test/clang-tidy/infrastructure/macros.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/macros.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/macros.cpp
@@ -1,7 +1,41 @@
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' %s -- | FileCheck %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor,modernize-avoid-c-arrays' --header-filter='macros_filter.h' %s -- | FileCheck %s
+
+#include "macros.h"
+#include "macros_filter.h"
 
 #define Q(name) class name { name(int i); }
 
 Q(A);
 // CHECK: :[[@LINE-1]]:3: warning: single-argument constructors must be marked explicit
-// CHECK: :3:30: note: expanded from macro 'Q'
+// CHECK: :[[@LINE-4]]:30: note: expanded from macro 'Q'
+
+#define MAIN_MACRO_DIAG_IN_ARG(a) a
+MAIN_MACRO_DIAG_IN_ARG(int var_A[10]);
+// CHECK: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use std::array<> instead
+
+#define MAIN_MACRO_DIAG_IN_BODY int var_A1[10]
+MAIN_MACRO_DIAG_IN_BODY;
+// CHECK: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK: :[[@LINE-3]]:33: note: expanded from macro 'MAIN_MACRO_DIAG_IN_BODY'
+
+HEADER_FILTER_MACRO_DIAG_IN_ARG(int var_B[10]);
+// CHECK: :[[@LINE-1]]:33: warning: do not declare C-style arrays, use std::array<> instead
+
+HEADER_FILTER_MACRO_DIAG_IN_BODY;
+// CHECK: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK: note: expanded from macro 'HEADER_FILTER_MACRO_DIAG_IN_BODY'
+
+#define MAIN_MACRO_WRAPPER HEADER_FILTER_MACRO_DIAG_IN_BODY2
+MAIN_MACRO_WRAPPER;
+// CHECK: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
+// CHECK: note: expanded from macro 'MAIN_MACRO_WRAPPER'
+// CHECK: note: expanded from macro 'HEADER_FILTER_MACRO_DIAG_IN_BODY2'
+
+HEADER_MACRO_DIAG_IN_ARG(int var_C[10]);
+HEADER_MACRO_DIAG_IN_BODY;
+
+#define MAIN_MACRO_WRAPPER2 HEADER_MACRO_DIAG_IN_BODY2
+MAIN_MACRO_WRAPPER2;
+
+DEFINE_bool(test, false);
+// CHECK-NOT: warning:
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -177,6 +177,10 @@
 DiagEngine->getDiagnosticIDs()->getDescription(DiagnosticID)));
   }
 
+  /// Returns the \c HeaderFilter constructed for the options set in the
+  /// context.
+  llvm::Regex *getHeaderFilter() const;
+
 private:
   // Writes to Stats.
   friend class ClangTidyDiagnosticConsumer;
@@ -189,6 +193,8 @@
   class CachedGlobList;
   std::unique_ptr CheckFilter;
   std::unique_ptr WarningAsErrorFilter;
+  // Cache for compiled regex with HeaderFilter.
+  mutable std::unique_ptr HeaderFilter;
 
   LangOptions LangOpts;
 
@@ -243,10 +249,6 @@
   void removeIncompatibleErrors();
   void removeDuplicatedDiagnosticsOfAliasCheckers();
 
-  /// Returns the \c HeaderFilter constructed for the options set in the
-  /// context.
-  llvm::Regex *getHeaderFilter();
-
   /// Updates \c LastErrorRelatesToUse

[PATCH] D83693: Port analyzer flags to new option parsing system

2020-11-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a comment.
Herald added a subscriber: steakhal.

Taking over this patch, as Daniel is no longer involved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83693

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


[PATCH] D83693: Port analyzer flags to new option parsing system

2020-11-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 306047.
jansvoboda11 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83693

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -454,44 +454,19 @@
 }
   }
 
-  Opts.ShowCheckerHelp = Args.hasArg(OPT_analyzer_checker_help);
-  Opts.ShowCheckerHelpAlpha = Args.hasArg(OPT_analyzer_checker_help_alpha);
-  Opts.ShowCheckerHelpDeveloper =
-  Args.hasArg(OPT_analyzer_checker_help_developer);
-
-  Opts.ShowCheckerOptionList = Args.hasArg(OPT_analyzer_checker_option_help);
-  Opts.ShowCheckerOptionAlphaList =
-  Args.hasArg(OPT_analyzer_checker_option_help_alpha);
-  Opts.ShowCheckerOptionDeveloperList =
-  Args.hasArg(OPT_analyzer_checker_option_help_developer);
-
-  Opts.ShowConfigOptionsList = Args.hasArg(OPT_analyzer_config_help);
-  Opts.ShowEnabledCheckerList = Args.hasArg(OPT_analyzer_list_enabled_checkers);
   Opts.ShouldEmitErrorsOnInvalidConfigValue =
   /* negated */!llvm::StringSwitch(
Args.getLastArgValue(OPT_analyzer_config_compatibility_mode))
 .Case("true", true)
 .Case("false", false)
 .Default(false);
-  Opts.DisableAllCheckers = Args.hasArg(OPT_analyzer_disable_all_checks);
 
-  Opts.visualizeExplodedGraphWithGraphViz =
-Args.hasArg(OPT_analyzer_viz_egraph_graphviz);
   Opts.DumpExplodedGraphTo =
   std::string(Args.getLastArgValue(OPT_analyzer_dump_egraph));
-  Opts.NoRetryExhausted = Args.hasArg(OPT_analyzer_disable_retry_exhausted);
-  Opts.AnalyzerWerror = Args.hasArg(OPT_analyzer_werror);
-  Opts.AnalyzeAll = Args.hasArg(OPT_analyzer_opt_analyze_headers);
-  Opts.AnalyzerDisplayProgress = Args.hasArg(OPT_analyzer_display_progress);
-  Opts.AnalyzeNestedBlocks =
-Args.hasArg(OPT_analyzer_opt_analyze_nested_blocks);
   Opts.AnalyzeSpecificFunction =
   std::string(Args.getLastArgValue(OPT_analyze_function));
-  Opts.UnoptimizedCFG = Args.hasArg(OPT_analysis_UnoptimizedCFG);
-  Opts.TrimGraph = Args.hasArg(OPT_trim_egraph);
   Opts.maxBlockVisitOnPath =
   getLastArgIntValue(Args, OPT_analyzer_max_loop, 4, Diags);
-  Opts.PrintStats = Args.hasArg(OPT_analyzer_stats);
   Opts.InlineMaxStackDepth =
   getLastArgIntValue(Args, OPT_analyzer_inline_max_stack_depth,
  Opts.InlineMaxStackDepth, Diags);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3663,7 +3663,8 @@
 //===--===//
 
 def analysis_UnoptimizedCFG : Flag<["-"], "unoptimized-cfg">,
-  HelpText<"Generate unoptimized CFGs for all analyses">;
+  HelpText<"Generate unoptimized CFGs for all analyses">,
+  MarshallingInfoFlag<"AnalyzerOpts->UnoptimizedCFG">;
 def analysis_CFGAddImplicitDtors : Flag<["-"], "cfg-add-implicit-dtors">,
   HelpText<"Add C++ implicit destructors to CFGs for all analyses">;
 
@@ -3686,18 +3687,23 @@
 def analyzer_purge_EQ : Joined<["-"], "analyzer-purge=">, Alias;
 
 def analyzer_opt_analyze_headers : Flag<["-"], "analyzer-opt-analyze-headers">,
-  HelpText<"Force the static analyzer to analyze functions defined in header files">;
+  HelpText<"Force the static analyzer to analyze functions defined in header files">,
+  MarshallingInfoFlag<"AnalyzerOpts->AnalyzeAll">;
 def analyzer_opt_analyze_nested_blocks : Flag<["-"], "analyzer-opt-analyze-nested-blocks">,
-  HelpText<"Analyze the definitions of blocks in addition to functions">;
+  HelpText<"Analyze the definitions of blocks in addition to functions">,
+  MarshallingInfoFlag<"AnalyzerOpts->AnalyzeNestedBlocks">;
 def analyzer_display_progress : Flag<["-"], "analyzer-display-progress">,
-  HelpText<"Emit verbose output about the analyzer's progress">;
+  HelpText<"Emit verbose output about the analyzer's progress">,
+  MarshallingInfoFlag<"AnalyzerOpts->AnalyzerDisplayProgress">;
 def analyze_function : Separate<["-"], "analyze-function">,
   HelpText<"Run analysis on specific function (for C++ include parameters in name)">;
 def analyze_function_EQ : Joined<["-"], "analyze-function=">, Alias;
 def trim_egraph : Flag<["-"], "trim-egraph">,
-  HelpText<"Only show error-related paths in the analysis graph">;
+  HelpText<"Only show error-related paths in the analysis graph">,
+  MarshallingInfoFlag<"AnalyzerOpts->TrimGraph">;
 def analyzer_viz_egraph_graphviz : Flag<["-"], "analyzer-viz-egraph-graphviz">,
-  HelpText<"Display exploded graph using GraphViz">;
+  HelpText<"Display exploded graph using GraphViz">,
+  MarshallingInfoFlag<"AnalyzerOp

[PATCH] D83693: Port analyzer flags to new option parsing system

2020-11-18 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

WDYT @Bigcheese?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83693

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


[PATCH] D90835: [RFC][clang-tidy] Ignore diagnostics due to macro expansion from not-interested headers

2020-11-18 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@njames93 thank you for the feedback!

Still waiting for more feedback and especially high level one about this 
feature in general. Does it look useful? Should it be behind a flag i.e. 
changing default behaviour is too dangerous?




Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:249-251
+  if (!HeaderFilter)
+HeaderFilter =
+std::make_unique(*getOptions().HeaderFilterRegex);

njames93 wrote:
> This should also check if the Optional has a value
This code was moved from `ClangTidyDiagnosticConsumer::getHeaderFilter` but you 
are right, it makes sense to add support for missing value.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:349-351
+  // Skip macro from system headers.
+  if (!*Context.getOptions().SystemHeaders && SM.isInSystemHeader(SpellingLoc))
+return true;

njames93 wrote:
> This looks suspicious, in clang-tidy land `SystemHeaders` is always set, 
> however outside clang-tidy it may not be.
> Perhaps `getValueOr(false)` should be used to prevent any asserts.
> 
> Also can a test be added to show this respecting the SystemHeaders setting.
Running this code on bigger codebase I found undesired side-effect that it is 
better to report issues on system macro like NULL such issues usually from 
external code, not from macro itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90835

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


[PATCH] D91695: [ARM][AArch64] Adding Neoverse N2 CPU support

2020-11-18 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Can you add the cpuid to host.cpp too?




Comment at: llvm/include/llvm/Support/AArch64TargetParser.def:154
+AARCH64_CPU_NAME("neoverse-n2", ARMV8_5A, FK_CRYPTO_NEON_FP_ARMV8, false,
+ (AArch64::AEK_BF16 | AArch64::AEK_DOTPROD | AArch64::AEK_I8MM 
| AArch64::AEK_MTE | AArch64::AEK_RAS |
+  AArch64::AEK_RCPC | AArch64::AEK_SB | AArch64::AEK_SSBS | 
AArch64::AEK_SVE2))

The lines are getting a little long here.

Does it need things like DOTPROD, if it's already 8.5?



Comment at: llvm/include/llvm/Support/ARMTargetParser.def:304
+ARM_CPU_NAME("neoverse-n2", ARMV8_5A, FK_CRYPTO_NEON_FP_ARMV8, false,
+ (ARM::AEK_BF16 | ARM::AEK_DOTPROD | ARM::AEK_I8MM | ARM::AEK_RAS 
| ARM::AEK_SB))
 ARM_CPU_NAME("neoverse-v1", ARMV8_4A, FK_CRYPTO_NEON_FP_ARMV8, false,

Formatting



Comment at: llvm/unittests/Support/TargetParserTest.cpp:993
   EXPECT_TRUE(testAArch64CPU(
  "neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_DOTPROD |

There should be tests like this, I think. Same for ARM below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91695

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


[clang] 8cdc538 - Add sysroot/lib to library search path of baremetal toolchain.

2020-11-18 Thread Hafiz Abid Qadeer via cfe-commits

Author: Hafiz Abid Qadeer
Date: 2020-11-18T12:38:52Z
New Revision: 8cdc538873879bd57c3ba71956d68b49a2973a45

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

LOG: Add sysroot/lib to library search path of baremetal toolchain.

Baremetal toolchain is not adding sysroot/lib to the library
search path. This is forcing the user to do it manually. This commit
fixes this shortcoming by adding the sysroot/lib to library search path
if sysroot is not empty.

Reviewed By: jroelofs

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 9df42061e12c..91e2715404fe 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -33,6 +33,11 @@ BareMetal::BareMetal(const Driver &D, const llvm::Triple 
&Triple,
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
+  SmallString<128> SysRoot(getDriver().SysRoot);
+  if (!SysRoot.empty()) {
+llvm::sys::path::append(SysRoot, "lib");
+getFilePaths().push_back(std::string(SysRoot));
+  }
 }
 
 /// Is the triple {arm,thumb}-none-none-{eabi,eabihf} ?
@@ -189,6 +194,7 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 
   CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
 
+  TC.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});

diff  --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index 3a5c1555dc2c..f9d48e46e639 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
@@ -34,6 +35,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
@@ -47,6 +49,7 @@
 // CHECK-V6M-LIBCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
@@ -60,6 +63,7 @@
 // CHECK-V6M-LIBSTDCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}6.0.0"
 // CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
@@ -70,7 +74,8 @@
 // RUN: -nodefaultlibs \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-NDL %s
 // CHECK-V6M-NDL: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" 
"-Bstatic"
-// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 "-o" "{{.*}}.o"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\

[PATCH] D91559: Add sysroot/lib to library search path of baremetal toolchain.

2020-11-18 Thread Hafiz Abid Qadeer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
abidh marked an inline comment as done.
Closed by commit rG8cdc53887387: Add sysroot/lib to library search path of 
baremetal toolchain. (authored by abidh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91559

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/test/Driver/baremetal.cpp


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-C-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-V6M-C-SAME: "-T" "semihosted.lds" 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
@@ -34,6 +35,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-DEFAULTCXX %s
 // CHECK-V6M-DEFAULTCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-DEFAULTCXX-SAME: "-o" "{{.*}}.o"
@@ -47,6 +49,7 @@
 // CHECK-V6M-LIBCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}v1"
 // CHECK-V6M-LIBCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
 // CHECK-V6M-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBCXX-SAME: "-o" "{{.*}}.o"
@@ -60,6 +63,7 @@
 // CHECK-V6M-LIBSTDCXX: "-internal-isystem" 
"{{[^"]+}}{{[/\\]+}}include{{[/\\]+}}c++{{[/\\]+}}6.0.0"
 // CHECK-V6M-LIBSTDCXX: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" 
"{{.*}}.o" "-Bstatic"
 // CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
 // CHECK-V6M-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
 // CHECK-V6M-LIBSTDCXX-SAME: "-o" "{{.*}}.o"
@@ -70,7 +74,8 @@
 // RUN: -nodefaultlibs \
 // RUN:   | FileCheck --check-prefix=CHECK-V6M-NDL %s
 // CHECK-V6M-NDL: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" 
"-Bstatic"
-// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 "-o" "{{.*}}.o"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}lib{{(64)?}}{{[/\\]+}}clang{{[/\\]+}}{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
+// CHECK-V6M-NDL-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}baremetal_arm{{[/\\]+}}lib" "-o" 
"{{.*}}.o"
 
 // RUN: %clangxx -target arm-none-eabi -v 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-THREAD-MODEL
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -33,6 +33,11 @@
   getProgramPaths().push_back(getDriver().getInstalledDir());
   if (getDriver().getInstalledDir() != getDriver().Dir)
 getProgramPaths().push_back(getDriver().Dir);
+  SmallString<128> SysRoot(getDriver().SysRoot);
+  if (!SysRoot.empty()) {
+llvm::sys::path::append(SysRoot, "lib");
+getFilePaths().push_back(std::string(SysRoot));
+  }
 }
 
 /// Is the triple {arm,thumb}-none-none-{eabi,eabihf} ?
@@ -189,6 +194,7 @@
 
   CmdArgs.push_back(Args.MakeArgString("-L" + TC.getRuntimesDir()));
 
+  TC.AddFilePathLibArgs(Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
 options::OPT_e, options::OPT_s, options::OPT_t,
 options::OPT_Z_Flag, options::OPT_r});


Index: clang/test/Driver/baremetal.cpp
===
--- clang/test/Driver/baremetal.cpp
+++ clang/test/Driver/baremetal.cpp
@@ -12,6 +12,7 @@
 // CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal.cpp"
 // CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
 // CHECK-V6M-C-

[clang] bcaa198 - Remove unportable test

2020-11-18 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-11-18T12:42:07Z
New Revision: bcaa19894994f1363a10c082541efb67435399d1

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

LOG: Remove unportable test

The default content of translation unit varies too much between
platforms.

Added: 


Modified: 
clang/unittests/AST/ASTTraverserTest.cpp

Removed: 




diff  --git a/clang/unittests/AST/ASTTraverserTest.cpp 
b/clang/unittests/AST/ASTTraverserTest.cpp
index e61069ae61d6..184bddce7f2e 100644
--- a/clang/unittests/AST/ASTTraverserTest.cpp
+++ b/clang/unittests/AST/ASTTraverserTest.cpp
@@ -1068,52 +1068,6 @@ int i = 0;
 )cpp");
 const auto *TUDecl = AST->getASTContext().getTranslationUnitDecl();
 
-#if _WIN32
-EXPECT_EQ(dumpASTString(TK_AsIs, TUDecl),
-  R"cpp(
-TranslationUnitDecl
-|-CXXRecordDecl '_GUID'
-| `-TypeVisibilityAttr
-|-TypedefDecl '__int128_t'
-| `-BuiltinType
-|-TypedefDecl '__uint128_t'
-| `-BuiltinType
-|-TypedefDecl '__NSConstantString'
-| `-RecordType
-|-CXXRecordDecl 'type_info'
-| `-TypeVisibilityAttr
-|-TypedefDecl 'size_t'
-| `-BuiltinType
-|-TypedefDecl '__builtin_ms_va_list'
-| `-PointerType
-|   `-BuiltinType
-|-TypedefDecl '__builtin_va_list'
-| `-PointerType
-|   `-BuiltinType
-`-VarDecl 'i'
-  `-IntegerLiteral
-)cpp");
-#else
-EXPECT_EQ(dumpASTString(TK_AsIs, TUDecl),
-  R"cpp(
-TranslationUnitDecl
-|-TypedefDecl '__int128_t'
-| `-BuiltinType
-|-TypedefDecl '__uint128_t'
-| `-BuiltinType
-|-TypedefDecl '__NSConstantString'
-| `-RecordType
-|-TypedefDecl '__builtin_ms_va_list'
-| `-PointerType
-|   `-BuiltinType
-|-TypedefDecl '__builtin_va_list'
-| `-ConstantArrayType
-|   `-RecordType
-`-VarDecl 'i'
-  `-IntegerLiteral
-)cpp");
-#endif
-
 EXPECT_EQ(dumpASTString(TK_IgnoreUnlessSpelledInSource, TUDecl),
   R"cpp(
 TranslationUnitDecl



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


[PATCH] D91410: [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref

2020-11-18 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added a comment.

In D91410#2400018 , @tejohnson wrote:

> 



> ... the new checking is a mix of assert and fatal errors. Is that intended?

No. The added checks are based on the checks on other calls to the 
`Target::createXXX` functions in this file or other related files. If there are 
any fatal errors nearby (e.g. llvm/lib/LTO/ThinLTOCodeGenerator.cpp:581 vs 
569), the check will be a  fatal error; and if there are any assertions (e.g. 
llvm/lib/CodeGen/LLVMTargetMachine.cpp:43,45,52 vs 60) or the calls are never 
checked (e.g. llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:300), the added check 
will be an assertion.

> If these are not likely due to user input issues, then perhaps they should 
> all be assert so that they are compiled out in release compilers?

Since all these problems are reported by my static analyzer, I do not really 
know whether these checked pointers will actually be null when the code is 
executed. And I did not try to dynamically execute the program to check the 
problems either. But chances are that if the creator callbacks are not properly 
set or the called creator functions returns nullptr, the problem will happen. 
In my opinion, these problems may only happen during development. Therefore, I 
believe asserts can be sufficient to diagnose the problems.

If you think it would be better to use assertions instead of fatal errors, I 
will make an update on all `llvm/lib/xxx` files (or maybe all files). But 
before that, I'd prefer waiting for the replies from other reviewers on the 
remaining parts of the patch and making an update for all the suggestions.

Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91410

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


[PATCH] D90982: Ignore implicit nodes in IgnoreUnlessSpelledInSource mode

2020-11-18 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

I've removed the offending test (which in this case is the correct fix - it is 
not a temporary fix).

@RKSimon  Is there some way I can see what is causing the failures on the other 
platforms? Was it because of this test? How can I monitor this? I knew how to 
see it in lab.llvm.org, but it seems things are missing or moved in the new 
buildbot interface. I otherwise have no way of knowing what problems were 
caused by this, and whether a new version of this patch fixes the problems?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90982

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


[PATCH] D91696: [AArch64][SVE] Allow lax conversion between VLATs and GNU vectors

2020-11-18 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli accepted this revision.
fpetrogalli added a comment.
This revision is now accepted and ready to land.

This LGTM. May I ask to extend the commit message to add a reference to the 
paragraph in section "3.7.3.3", item 2 on page 23 of the specs version 00bet6?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91696

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


[PATCH] D89031: [SVE] Add support to vectorize_width loop pragma for scalable vectors

2020-11-18 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added a comment.

As I see it there are a bunch of pragmas that all enable vectorisation, with 
each pragma providing a unit of information.  One component of this information 
is the vectorisation factor hint provided by vectorize_width.

With the introduction of scalable vectors this hint is using the wrong datatype 
and thus needs to be updated to allow `vectorize_width(#num,[fixed|scalable])` 
and `vectorize_width([fixed|scalable])` along side the existing 
`vectorize_width(#num)` representation that effectively becomes an alias to 
`vectorize_width(#num, fixed)`.

Doing this means all existing usages work as expected and there's now extra 
power to better guide the chosen vectorisation factor.


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

https://reviews.llvm.org/D89031

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


[clang] 871fe71 - Fix typo for hasAnyOverloadedOperatorName; NFC

2020-11-18 Thread Aaron Ballman via cfe-commits

Author: Keishi Hattori
Date: 2020-11-18T07:48:59-05:00
New Revision: 871fe71f2951cb19421a2b47ddb54ed6b3c8cba2

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

LOG: Fix typo for hasAnyOverloadedOperatorName; NFC

Added: 


Modified: 
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index d348bc80e792..d9fa3c2830fb 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -2779,7 +2779,7 @@ Narrowing Matchers
 Matches overloaded operator names specified in strings without the
 "operator" prefix: e.g. "<<".
 
-  hasAnyOverloadesOperatorName("+", "-")
+  hasAnyOverloadedOperatorName("+", "-")
 Is equivalent to
   anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
 
@@ -3400,7 +3400,7 @@ Narrowing Matchers
 Matches overloaded operator names specified in strings without the
 "operator" prefix: e.g. "<<".
 
-  hasAnyOverloadesOperatorName("+", "-")
+  hasAnyOverloadedOperatorName("+", "-")
 Is equivalent to
   anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
 

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 39274331a12e..d8b049f45341 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2825,7 +2825,7 @@ hasOverloadedOperatorName(StringRef Name) {
 /// Matches overloaded operator names specified in strings without the
 /// "operator" prefix: e.g. "<<".
 ///
-///   hasAnyOverloadesOperatorName("+", "-")
+///   hasAnyOverloadedOperatorName("+", "-")
 /// Is equivalent to
 ///   anyOf(hasOverloadedOperatorName("+"), hasOverloadedOperatorName("-"))
 extern const internal::VariadicFunction<



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


[PATCH] D91592: [ASTMatchers] Fix typo for hasAnyOverloadedOperatorName

2020-11-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Thank you for the fix, I've commit on your behalf in 
871fe71f2951cb19421a2b47ddb54ed6b3c8cba2 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91592

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


[PATCH] D77598: Integral template argument suffix and cast printing

2020-11-18 Thread Pratyush Das via Phabricator via cfe-commits
reikdas updated this revision to Diff 306059.
reikdas added a comment.

Addresses @rsmith 's comments.

> On that basis, I think it would be preferable to change 
> TemplateArgument::print to accept not a bool indicating whether the type was 
> known, but instead a const NamedDecl * for the corresponding template 
> parameter. Then the logic is: include the type if we don't know the 
> corresponding parameter or if its type is deduced.

I decided to continue passing a bool and move the logic for checking if the 
corresponding parameter's type is deduced to the caller. This is to handle the 
case where we need to let the template argument printing routine know not to 
print the cast when we get a parameter list whose size is lesser than the 
length of the list of arguments.

Unfortunately, there are still some cases where there are explicit casts when 
we don't want them to be.


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

https://reviews.llvm.org/D77598

Files:
  clang/include/clang/AST/StmtDataCollectors.td
  clang/include/clang/AST/TemplateBase.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/NestedNameSpecifier.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Analysis/PathDiagnostic.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/Analysis/eval-predefined-exprs.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p12.cpp
  clang/test/CXX/temp/temp.param/p10-2a.cpp
  clang/test/SemaCXX/builtin-align-cxx.cpp
  clang/test/SemaCXX/cxx11-ast-print.cpp
  clang/test/SemaCXX/matrix-type-builtins.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/test/SemaTemplate/delegating-constructors.cpp
  clang/test/SemaTemplate/matrix-type.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/tools/libclang/CIndex.cpp
  
clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
@@ -20,7 +20,7 @@
 llvm::raw_string_ostream Stream(ArgStr);
 const TemplateArgument &Arg = ArgLoc.getArgument();
 
-Arg.print(Context->getPrintingPolicy(), Stream);
+Arg.print(Context->getPrintingPolicy(), Stream, /*IncludeType*/ true);
 Match(Stream.str(), ArgLoc.getLocation());
 return ExpectedLocationVisitor::
   TraverseTemplateArgumentLoc(ArgLoc);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5144,8 +5144,9 @@
 SmallString<128> Str;
 llvm::raw_svector_ostream OS(Str);
 OS << *ClassSpec;
-printTemplateArgumentList(OS, ClassSpec->getTemplateArgs().asArray(),
-  Policy);
+printTemplateArgumentList(
+OS, ClassSpec->getTemplateArgs().asArray(), Policy,
+ClassSpec->getSpecializedTemplate()->getTemplateParameters());
 return cxstring::createDup(OS.str());
   }
 
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -457,3 +457,13 @@
   X y;
   int n = y.call(); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}
 }
+
+namespace PR9227 {
+template  struct S {};
+template <> struct S<1> { using type = int; }; // expected-note {{'S<1>::type' declared here}}
+S<1L>::type t; // expected-error {{no type named 'type' in 'PR9227::S<1L>'; did you mean 'S<1>::type'?}}
+
+template  struct A {};
+template <> struct A<1> { using type = int; }; // expected-note {{'A<1>::type' declared here}}
+A<2>::type x;  // expected-error {{no type named 'type' in 'PR9227::A<2>'; did you mean 'A<1>::type'?}}
+} // namespace PR9227
Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -270,6 +270,23 @@
   void test_char_possibly_negative() { enable_if_char<'\x02'>::type i; } // expected-error{{enable_if_char<'\x02'>'; did you mean 'enable_if_char<'a'>::typ

[PATCH] D91695: [ARM][AArch64] Adding Neoverse N2 CPU support

2020-11-18 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 306062.
MarkMurrayARM added a comment.
Herald added a subscriber: dexonsmith.

Address reviewer comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91695

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/neon-dot-product.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.3a-rcpc.s
  llvm/test/MC/AArch64/armv8.5a-ssbs.s
  llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
  llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -328,7 +328,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 90;
+static constexpr unsigned NumARMCPUArchs = 91;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -1048,7 +1048,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 44;
+static constexpr unsigned NumAArch64CPUArchs = 45;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -9,6 +9,7 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-x1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n2 --disassemble < %s | FileCheck %s
 
 # CHECK: ldaprb w0, [x0]
 # CHECK: ldaprh w0, [x0]
Index: llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
+++ llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
@@ -6,6 +6,7 @@
 // RUN: llvm-mc -triple thumb -mcpu=cortex-a78 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=cortex-x1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=neoverse-n1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
+// RUN: llvm-mc -triple thumb -mcpu=neoverse-n2 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 
 // RUN: not llvm-mc -triple thumb -mattr=-dotprod -show-encoding < %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ERROR < %t %s
Index: llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
+++ llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
@@ -3,6 +3,7 @@
 // RUN: llvm-mc -triple arm -mcpu=cortex-a75 -show-encoding < %s | FileCheck %s  --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=cortex-a76 -show-encoding < %s | FileCheck %s  --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=neoverse-n1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
+// RUN: llvm-mc -triple arm -mcpu=neoverse-n2 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=cortex-a77 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=cortex-a78 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=cortex-x1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
Index: llvm/test/MC/AArch64/armv8.5a-ssbs.s
===
--- llvm/test/MC/AArch64/armv8.5a-ssbs.s
+++ llvm/test/MC/AArch64/armv8.5a-ssbs.s
@@ -6,6 +6,7 @@
 // RUN: llvm-mc -triple aarch64 -show-encoding -mcpu=cortex-a76ae < %s | FileCheck %s
 // RUN: llvm-mc -triple aarch64 -show-encoding -mcpu=neoverse-e1 < %s  | FileCheck %s
 // RUN: llvm-mc -triple aarch64 -show-encoding -mcpu=neoverse-n1 < %s  | FileCheck %s
+// RUN: llvm-mc -triple aarch64 -show-encoding -mcpu=neoverse-n2 < %s  | FileCheck %s
 // RUN: not llvm-mc -triple aarch64 -show-encoding -mattr=-ssbs  < %s 2>&1 | FileCheck %s --check-prefix=NOSPECID
 
 mrs x2, SSBS
Index: llvm/test/MC/AArch64/armv8.3a-rcpc.s
==

[PATCH] D91695: [ARM][AArch64] Adding Neoverse N2 CPU support

2020-11-18 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 306063.
MarkMurrayARM added a comment.

Address review comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91695

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/neon-dot-product.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/AArch64/armv8.3a-rcpc.s
  llvm/test/MC/AArch64/armv8.5a-ssbs.s
  llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
  llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -328,7 +328,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 90;
+static constexpr unsigned NumARMCPUArchs = 91;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -1048,7 +1048,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 44;
+static constexpr unsigned NumAArch64CPUArchs = 45;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -9,6 +9,7 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-x1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n2 --disassemble < %s | FileCheck %s
 
 # CHECK: ldaprb w0, [x0]
 # CHECK: ldaprh w0, [x0]
Index: llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
+++ llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
@@ -6,6 +6,7 @@
 // RUN: llvm-mc -triple thumb -mcpu=cortex-a78 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=cortex-x1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=neoverse-n1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
+// RUN: llvm-mc -triple thumb -mcpu=neoverse-n2 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 
 // RUN: not llvm-mc -triple thumb -mattr=-dotprod -show-encoding < %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ERROR < %t %s
Index: llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
+++ llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
@@ -3,6 +3,7 @@
 // RUN: llvm-mc -triple arm -mcpu=cortex-a75 -show-encoding < %s | FileCheck %s  --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=cortex-a76 -show-encoding < %s | FileCheck %s  --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=neoverse-n1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
+// RUN: llvm-mc -triple arm -mcpu=neoverse-n2 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=cortex-a77 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=cortex-a78 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple arm -mcpu=cortex-x1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
Index: llvm/test/MC/AArch64/armv8.5a-ssbs.s
===
--- llvm/test/MC/AArch64/armv8.5a-ssbs.s
+++ llvm/test/MC/AArch64/armv8.5a-ssbs.s
@@ -6,6 +6,7 @@
 // RUN: llvm-mc -triple aarch64 -show-encoding -mcpu=cortex-a76ae < %s | FileCheck %s
 // RUN: llvm-mc -triple aarch64 -show-encoding -mcpu=neoverse-e1 < %s  | FileCheck %s
 // RUN: llvm-mc -triple aarch64 -show-encoding -mcpu=neoverse-n1 < %s  | FileCheck %s
+// RUN: llvm-mc -triple aarch64 -show-encoding -mcpu=neoverse-n2 < %s  | FileCheck %s
 // RUN: not llvm-mc -triple aarch64 -show-encoding -mattr=-ssbs  < %s 2>&1 | FileCheck %s --check-prefix=NOSPECID
 
 mrs x2, SSBS
Index: llvm/test/MC/AArch64/armv8.3a-rcpc.s

[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2020-11-18 Thread Alexey Bader via Phabricator via cfe-commits
bader added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:4554
+
+  // Language rules define if it is legal to cast from one address space
+  // to another, and which address space we should use as a "common

asavonic wrote:
> bader wrote:
> > asavonic wrote:
> > > sdmitriev wrote:
> > > > bader wrote:
> > > > > Anastasia wrote:
> > > > > > What language rules?
> > > > > I suppose it's a generic note and author didn't meant some particular 
> > > > > language here. This change was contributed by @sdmitriev. 
> > > > > @sdmitriev, could you clarify, please?
> > > > This comment was originally added by @asavonic to 
> > > > clang/lib/CodeGen/CGExprScalar.cpp (lines 2962-2965 in this patch), and 
> > > > later I reused his code along with the comment in this file while 
> > > > fixing a very similar issue. So, I guess it would be more correct to 
> > > > ask Andrew to clarify. @asavonic, can you please comment on this?
> > > > This comment was originally added by @asavonic to 
> > > > clang/lib/CodeGen/CGExprScalar.cpp (lines 2962-2965 in this patch), and 
> > > > later I reused his code along with the comment in this file while 
> > > > fixing a very similar issue.
> > > 
> > > There is `if (Opts.SYCLIsDevice)` In CGExprScalar.cpp, so we handle SYCL 
> > > language rules.
> > > In SYCL, (almost) all pointers have default address space in AST, but in 
> > > CG some pointers become private/local/global, and some are lowered as 
> > > generic pointers. We need to add an implicit addrspacecast in CG to emit 
> > > an expression that expects the same type for its operands.
> > > 
> > > For example:
> > > const char *str = ... ;
> > > const char *phi_str = i > 2 ? str : "hello world!";
> > > 
> > > In AST types of `str` and `"hello world"` are the same (`const char *`). 
> > > In CG we emit `str` as `i8 addrspace(4)*` and `"hello world"` as `i8*`. 
> > > At this point we have to decide what type `phi_str` should have, and 
> > > addrspacecast the operands accordingly.
> > Is it possible to avoid fixing address space mismatch at this point by 
> > adjusting AST as suggested by John in this comment: 
> > https://reviews.llvm.org/D89909#inline-837495?
> > 
> > I wonder if it can be done w/o impacting C++ template metaprogramming as 
> > noted in this thread: 
> > http://clang-developers.42468.n3.nabble.com/RFC-Re-use-OpenCL-address-space-attributes-for-SYCL-td4068754.html.
> > Is it possible to avoid fixing address space mismatch at this point by 
> > adjusting AST
> 
> Some address space mismatches are present in CG already, see 
> CodeGenModule::getStringLiteralAddressSpace and 
> CodeGenModule::GetGlobalVarAddressSpace. This should be moved to AST (or 
> replaced) as well, right?
> Some address space mismatches are present in CG already, see 
> CodeGenModule::getStringLiteralAddressSpace and 
> CodeGenModule::GetGlobalVarAddressSpace. This should be moved to AST (or 
> replaced) as well, right?

Kind of. If I'm not mistaken the idea is to redefine some TargetInfo hooks for 
SPIR target (similar to AMDGPU target) and IRGen should be able to align 
address spaces without additional customization like this. John provided a 
little bit more details in the RFC thread: 
http://clang-developers.42468.n3.nabble.com/RFC-Re-use-OpenCL-address-space-attributes-for-SYCL-td4068754.html#a4069039.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D91695: [ARM][AArch64] Adding Neoverse N2 CPU support

2020-11-18 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

In the first version N2 had FeatureTME. Did you remove that on purpose?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91695

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


[clang-tools-extra] aad3ea8 - [clangd] Remove the trailing "." in add-using message.

2020-11-18 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-11-18T14:46:26+01:00
New Revision: aad3ea8983a84827f8d4bc81d76b2a5fe218430e

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

LOG: [clangd] Remove the trailing "." in add-using message.

to be consistent witih other code actions.

Reviewed By: adamcz

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
index fe01894b6386..cf8347f312a3 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -52,7 +52,7 @@ REGISTER_TWEAK(AddUsing)
 
 std::string AddUsing::title() const {
   return std::string(llvm::formatv(
-  "Add using-declaration for {0} and remove qualifier.", Name));
+  "Add using-declaration for {0} and remove qualifier", Name));
 }
 
 // Locates all "using" statements relevant to SelectionDeclContext.

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
index 0462090ee25a..23b0e00d9aa5 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -360,7 +360,7 @@ class DefineOutline : public Tweak {
 return CodeAction::REFACTOR_KIND;
   }
   std::string title() const override {
-return "Move function body to out-of-line.";
+return "Move function body to out-of-line";
   }
 
   bool prepare(const Selection &Sel) override {

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
index 8bd9703397b6..25fab244e30c 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -38,7 +38,9 @@ class RemoveUsingNamespace : public Tweak {
 
   bool prepare(const Selection &Inputs) override;
   Expected apply(const Selection &Inputs) override;
-  std::string title() const override;
+  std::string title() const override {
+return "Remove using namespace, re-qualify names instead";
+  }
   llvm::StringLiteral kind() const override {
 return CodeAction::REFACTOR_KIND;
   }
@@ -200,10 +202,6 @@ Expected RemoveUsingNamespace::apply(const 
Selection &Inputs) {
   return Effect::mainFileEdit(SM, std::move(R));
 }
 
-std::string RemoveUsingNamespace::title() const {
-  return std::string(
-  llvm::formatv("Remove using namespace, re-qualify names instead."));
-}
 } // namespace
 } // namespace clangd
 } // namespace clang



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


[PATCH] D91694: [clangd] Remove the trailing "." in add-using message.

2020-11-18 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaad3ea8983a8: [clangd] Remove the trailing "." in 
add-using message. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91694

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp


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
@@ -38,7 +38,9 @@
 
   bool prepare(const Selection &Inputs) override;
   Expected apply(const Selection &Inputs) override;
-  std::string title() const override;
+  std::string title() const override {
+return "Remove using namespace, re-qualify names instead";
+  }
   llvm::StringLiteral kind() const override {
 return CodeAction::REFACTOR_KIND;
   }
@@ -200,10 +202,6 @@
   return Effect::mainFileEdit(SM, std::move(R));
 }
 
-std::string RemoveUsingNamespace::title() const {
-  return std::string(
-  llvm::formatv("Remove using namespace, re-qualify names instead."));
-}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -360,7 +360,7 @@
 return CodeAction::REFACTOR_KIND;
   }
   std::string title() const override {
-return "Move function body to out-of-line.";
+return "Move function body to out-of-line";
   }
 
   bool prepare(const Selection &Sel) override {
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -52,7 +52,7 @@
 
 std::string AddUsing::title() const {
   return std::string(llvm::formatv(
-  "Add using-declaration for {0} and remove qualifier.", Name));
+  "Add using-declaration for {0} and remove qualifier", Name));
 }
 
 // Locates all "using" statements relevant to SelectionDeclContext.


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
@@ -38,7 +38,9 @@
 
   bool prepare(const Selection &Inputs) override;
   Expected apply(const Selection &Inputs) override;
-  std::string title() const override;
+  std::string title() const override {
+return "Remove using namespace, re-qualify names instead";
+  }
   llvm::StringLiteral kind() const override {
 return CodeAction::REFACTOR_KIND;
   }
@@ -200,10 +202,6 @@
   return Effect::mainFileEdit(SM, std::move(R));
 }
 
-std::string RemoveUsingNamespace::title() const {
-  return std::string(
-  llvm::formatv("Remove using namespace, re-qualify names instead."));
-}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -360,7 +360,7 @@
 return CodeAction::REFACTOR_KIND;
   }
   std::string title() const override {
-return "Move function body to out-of-line.";
+return "Move function body to out-of-line";
   }
 
   bool prepare(const Selection &Sel) override {
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -52,7 +52,7 @@
 
 std::string AddUsing::title() const {
   return std::string(llvm::formatv(
-  "Add using-declaration for {0} and remove qualifier.", Name));
+  "Add using-declaration for {0} and remove qualifier", Name));
 }
 
 // Locates all "using" statements relevant to SelectionDeclContext.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91702: [clangd] Implement textDocument/implementation (Xref layer)

2020-11-18 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman.
Herald added a project: clang.
usaxena95 requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Implements textdocument/implementation 
(https://microsoft.github.io/language-server-protocol/specification#textDocument_implementation)

There is no clear semantic in LSP, but VSCode has some documentation about the 
behaviour: "For an interface, this shows all the implementors of that interface 
and for abstract methods, this shows all concrete implementations of that 
method."

This currently shows all concrete methods that overrides a virtual function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91702

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -43,6 +43,7 @@
 using ::testing::Matcher;
 using ::testing::UnorderedElementsAre;
 using ::testing::UnorderedElementsAreArray;
+using ::testing::UnorderedPointwise;
 
 MATCHER_P2(FileRange, File, Range, "") {
   return Location{URIForFile::canonicalize(File, testRoot()), Range} == arg;
@@ -1161,12 +1162,12 @@
 )cpp",
   };
 
-  for (const auto* Case : Tests) {
+  for (const auto *Case : Tests) {
 SCOPED_TRACE(Case);
 auto T = Annotations(Case);
 auto AST = TestTU::withCode(T.code()).build();
 EXPECT_THAT(locateSymbolAt(AST, T.point()),
-::testing::UnorderedPointwise(DeclRange(), T.ranges()));
+UnorderedPointwise(DeclRange(), T.ranges()));
   }
 }
 
@@ -1464,6 +1465,64 @@
   }
 }
 
+TEST(FindImplementations, Inheritance) {
+  llvm::StringRef Test = R"cpp(
+struct Base {
+  virtual void F$1^oo();
+};
+struct Child1 : Base {
+  void $1[[Fo$3^o]]() override;
+  virtual void B$2^ar();
+};
+struct Child2 : Child1 {
+  void $3[[Foo]]() override;
+  void $2[[Bar]]() override;
+};
+void FromReference() {
+  Base* B;
+  B->Fo$1^o();
+  &Base::Fo$1^o;
+  Child1 * C1;
+  C1->B$2^ar();
+  C1->Fo$3^o();
+}
+  )cpp";
+
+  Annotations Code(Test);
+  auto TU = TestTU::withCode(Code.code());
+  auto AST = TU.build();
+  for (const std::string &Label : {"1", "2", "3"}) {
+for (const auto &Point : Code.points(Label)) {
+  EXPECT_THAT(findImplementations(AST, Point, TU.index().get()),
+  UnorderedPointwise(DeclRange(), Code.ranges(Label)))
+  << Code.code() << " at " << Point << " for Label " << Label;
+}
+  }
+}
+
+TEST(FindImplementations, CaptureDefintion) {
+  llvm::StringRef Test = R"cpp(
+struct Base {
+  virtual void F^oo();
+};
+struct Child1 : Base {
+  void $Decl[[Foo]]() override;
+};
+struct Child2 : Base {
+  void $Child2[[Foo]]() override;
+};
+void Child1::$Def[[Foo]]() { /* Definition */ }
+  )cpp";
+  Annotations Code(Test);
+  auto TU = TestTU::withCode(Code.code());
+  auto AST = TU.build();
+  EXPECT_THAT(findImplementations(AST, Code.point(), TU.index().get()),
+  UnorderedElementsAre(
+  Sym("Foo", Code.range("Decl"), Code.range("Def")),
+  Sym("Foo", Code.range("Child2"), Code.range("Child2"
+  << Test;
+}
+
 TEST(FindReferences, WithinAST) {
   const char *Tests[] = {
   R"cpp(// Local variable
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -82,6 +82,11 @@
   std::vector References;
   bool HasMore = false;
 };
+
+/// Returns implementations of the virtual function at a specified \p Pos.
+std::vector findImplementations(ParsedAST &AST, Position Pos,
+   const SymbolIndex *Index);
+
 /// Returns references of the symbol at a specified \p Pos.
 /// \p Limit limits the number of results returned (0 means no limit).
 ReferencesResult findReferences(ParsedAST &AST, Position Pos, uint32_t Limit,
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1124,6 +1124,46 @@
   return Result;
 }
 
+std::vector findImplementations(ParsedAST &AST, Position Pos,
+   const SymbolIndex *Index) {
+  std::vector Results;
+  // We rely on index to find the implementations in subclasses.
+  if (!Index)
+return Results;
+  const SourceManager &SM = AST.getSourceManager();
+  auto MainFilePath =
+  getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
+  if (!MainFilePath) {
+elog("Failed t

[PATCH] D91626: [clangd] Implement textDocument/implementation.

2020-11-18 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 306076.
usaxena95 marked 3 inline comments as done.
usaxena95 added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91626

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -43,6 +43,7 @@
 using ::testing::Matcher;
 using ::testing::UnorderedElementsAre;
 using ::testing::UnorderedElementsAreArray;
+using ::testing::UnorderedPointwise;
 
 MATCHER_P2(FileRange, File, Range, "") {
   return Location{URIForFile::canonicalize(File, testRoot()), Range} == arg;
@@ -1161,12 +1162,12 @@
 )cpp",
   };
 
-  for (const auto* Case : Tests) {
+  for (const auto *Case : Tests) {
 SCOPED_TRACE(Case);
 auto T = Annotations(Case);
 auto AST = TestTU::withCode(T.code()).build();
 EXPECT_THAT(locateSymbolAt(AST, T.point()),
-::testing::UnorderedPointwise(DeclRange(), T.ranges()));
+UnorderedPointwise(DeclRange(), T.ranges()));
   }
 }
 
@@ -1464,6 +1465,64 @@
   }
 }
 
+TEST(FindImplementations, Inheritance) {
+  llvm::StringRef Test = R"cpp(
+struct Base {
+  virtual void F$1^oo();
+};
+struct Child1 : Base {
+  void $1[[Fo$3^o]]() override;
+  virtual void B$2^ar();
+};
+struct Child2 : Child1 {
+  void $3[[Foo]]() override;
+  void $2[[Bar]]() override;
+};
+void FromReference() {
+  Base* B;
+  B->Fo$1^o();
+  &Base::Fo$1^o;
+  Child1 * C1;
+  C1->B$2^ar();
+  C1->Fo$3^o();
+}
+  )cpp";
+
+  Annotations Code(Test);
+  auto TU = TestTU::withCode(Code.code());
+  auto AST = TU.build();
+  for (const std::string &Label : {"1", "2", "3"}) {
+for (const auto &Point : Code.points(Label)) {
+  EXPECT_THAT(findImplementations(AST, Point, TU.index().get()),
+  UnorderedPointwise(DeclRange(), Code.ranges(Label)))
+  << Code.code() << " at " << Point << " for Label " << Label;
+}
+  }
+}
+
+TEST(FindImplementations, CaptureDefintion) {
+  llvm::StringRef Test = R"cpp(
+struct Base {
+  virtual void F^oo();
+};
+struct Child1 : Base {
+  void $Decl[[Foo]]() override;
+};
+struct Child2 : Base {
+  void $Child2[[Foo]]() override;
+};
+void Child1::$Def[[Foo]]() { /* Definition */ }
+  )cpp";
+  Annotations Code(Test);
+  auto TU = TestTU::withCode(Code.code());
+  auto AST = TU.build();
+  EXPECT_THAT(findImplementations(AST, Code.point(), TU.index().get()),
+  UnorderedElementsAre(
+  Sym("Foo", Code.range("Decl"), Code.range("Def")),
+  Sym("Foo", Code.range("Child2"), Code.range("Child2"
+  << Test;
+}
+
 TEST(FindReferences, WithinAST) {
   const char *Tests[] = {
   R"cpp(// Local variable
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -82,6 +82,11 @@
   std::vector References;
   bool HasMore = false;
 };
+
+/// Returns implementations of the virtual function at a specified \p Pos.
+std::vector findImplementations(ParsedAST &AST, Position Pos,
+   const SymbolIndex *Index);
+
 /// Returns references of the symbol at a specified \p Pos.
 /// \p Limit limits the number of results returned (0 means no limit).
 ReferencesResult findReferences(ParsedAST &AST, Position Pos, uint32_t Limit,
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1124,6 +1124,46 @@
   return Result;
 }
 
+std::vector findImplementations(ParsedAST &AST, Position Pos,
+   const SymbolIndex *Index) {
+  std::vector Results;
+  // We rely on index to find the implementations in subclasses.
+  if (!Index)
+return Results;
+  const SourceManager &SM = AST.getSourceManager();
+  auto MainFilePath =
+  getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
+  if (!MainFilePath) {
+elog("Failed to get a path for the main file, so no implementations.");
+return Results;
+  }
+  auto CurLoc = sourceLocationInMainFile(SM, Pos);
+
+  DeclRelationSet Relations =
+  DeclRelation::TemplatePattern | DeclRelation::Alias;
+  RelationsRequest Req;
+  Req.Predicate = RelationKind::OverriddenBy;
+  for (const NamedDecl *ND : getDeclAtPosition(AST, *CurLoc, Relations))
+if (const CXXMethodDecl *CXXMD = llvm::dyn_cast(ND))
+  if (CXXMD->isVirtual())
+R

[PATCH] D91626: [clangd] Implement textDocument/implementation.

2020-11-18 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1153
+  Index->relations(Req, [&](const SymbolID &Subject, const Symbol &Object) {
+if (auto Loc = symbolToLocation(Object, *MainFilePath))
+  Results.References.push_back(*Loc);

hokein wrote:
> `symbolToLocation` will prefer definition location over declaration location.
> 
> there are a few options:
> 
> 1) just return declaration location
> 2) just return definition location
> 3) return both
> 
> in the find-implementaiton case, I think the declaration location is more? 
> interesting than the definition location, I would slightly prefer 1), what do 
> you think?
You are right. I experienced this while playing with it in VSCode. Sorry to not 
explicitly mention this.
I too prefer declaration in such case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91626

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


[PATCH] D91015: [clang-tidy] Extend bugprone-string-constructor-check to std::string_view.

2020-11-18 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

LGTM. I'll leave it to Aaron, though, to accept.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91015

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


[PATCH] D91626: [clangd] Implement textDocument/implementation.

2020-11-18 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 306079.
usaxena95 added a comment.

Added test for no implementation for concrete methods.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91626

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -43,6 +43,7 @@
 using ::testing::Matcher;
 using ::testing::UnorderedElementsAre;
 using ::testing::UnorderedElementsAreArray;
+using ::testing::UnorderedPointwise;
 
 MATCHER_P2(FileRange, File, Range, "") {
   return Location{URIForFile::canonicalize(File, testRoot()), Range} == arg;
@@ -1161,12 +1162,12 @@
 )cpp",
   };
 
-  for (const auto* Case : Tests) {
+  for (const auto *Case : Tests) {
 SCOPED_TRACE(Case);
 auto T = Annotations(Case);
 auto AST = TestTU::withCode(T.code()).build();
 EXPECT_THAT(locateSymbolAt(AST, T.point()),
-::testing::UnorderedPointwise(DeclRange(), T.ranges()));
+UnorderedPointwise(DeclRange(), T.ranges()));
   }
 }
 
@@ -1464,6 +1465,67 @@
   }
 }
 
+TEST(FindImplementations, Inheritance) {
+  llvm::StringRef Test = R"cpp(
+struct Base {
+  virtual void F$1^oo();
+  void C$4^oncrete();
+};
+struct Child1 : Base {
+  void $1[[Fo$3^o]]() override;
+  virtual void B$2^ar();
+  void Concrete();  // No implementations for concrete methods.
+};
+struct Child2 : Child1 {
+  void $3[[Foo]]() override;
+  void $2[[Bar]]() override;
+};
+void FromReference() {
+  Base* B;
+  B->Fo$1^o();
+  B->C$4^oncrete();
+  &Base::Fo$1^o;
+  Child1 * C1;
+  C1->B$2^ar();
+  C1->Fo$3^o();
+}
+  )cpp";
+
+  Annotations Code(Test);
+  auto TU = TestTU::withCode(Code.code());
+  auto AST = TU.build();
+  for (const std::string &Label : {"1", "2", "3", "4"}) {
+for (const auto &Point : Code.points(Label)) {
+  EXPECT_THAT(findImplementations(AST, Point, TU.index().get()),
+  UnorderedPointwise(DeclRange(), Code.ranges(Label)))
+  << Code.code() << " at " << Point << " for Label " << Label;
+}
+  }
+}
+
+TEST(FindImplementations, CaptureDefintion) {
+  llvm::StringRef Test = R"cpp(
+struct Base {
+  virtual void F^oo();
+};
+struct Child1 : Base {
+  void $Decl[[Foo]]() override;
+};
+struct Child2 : Base {
+  void $Child2[[Foo]]() override;
+};
+void Child1::$Def[[Foo]]() { /* Definition */ }
+  )cpp";
+  Annotations Code(Test);
+  auto TU = TestTU::withCode(Code.code());
+  auto AST = TU.build();
+  EXPECT_THAT(findImplementations(AST, Code.point(), TU.index().get()),
+  UnorderedElementsAre(
+  Sym("Foo", Code.range("Decl"), Code.range("Def")),
+  Sym("Foo", Code.range("Child2"), Code.range("Child2"
+  << Test;
+}
+
 TEST(FindReferences, WithinAST) {
   const char *Tests[] = {
   R"cpp(// Local variable
Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -82,6 +82,11 @@
   std::vector References;
   bool HasMore = false;
 };
+
+/// Returns implementations of the virtual function at a specified \p Pos.
+std::vector findImplementations(ParsedAST &AST, Position Pos,
+   const SymbolIndex *Index);
+
 /// Returns references of the symbol at a specified \p Pos.
 /// \p Limit limits the number of results returned (0 means no limit).
 ReferencesResult findReferences(ParsedAST &AST, Position Pos, uint32_t Limit,
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1124,6 +1124,46 @@
   return Result;
 }
 
+std::vector findImplementations(ParsedAST &AST, Position Pos,
+   const SymbolIndex *Index) {
+  std::vector Results;
+  // We rely on index to find the implementations in subclasses.
+  if (!Index)
+return Results;
+  const SourceManager &SM = AST.getSourceManager();
+  auto MainFilePath =
+  getCanonicalPath(SM.getFileEntryForID(SM.getMainFileID()), SM);
+  if (!MainFilePath) {
+elog("Failed to get a path for the main file, so no implementations.");
+return Results;
+  }
+  auto CurLoc = sourceLocationInMainFile(SM, Pos);
+
+  DeclRelationSet Relations =
+  DeclRelation::TemplatePattern | DeclRelation::Alias;
+  RelationsRequest Req;
+  Req.Predicate = RelationKind::OverriddenBy;
+  for (const NamedDecl *ND : getDeclAtPosition(AST, *Cu

[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2020-11-18 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[PATCH] D77493: [clang-tidy] Add do-not-refer-atomic-twice check

2020-11-18 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis updated this revision to Diff 306080.
abelkocsis added a comment.

Fixes, `std::atomic` variables add


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D77493

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/DoNotReferAtomicTwiceCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/DoNotReferAtomicTwiceCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-do-not-refer-atomic-twice.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con40-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-do-not-refer-atomic-twice.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-do-not-refer-atomic-twice.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-do-not-refer-atomic-twice.cpp
@@ -0,0 +1,129 @@
+// RUN: %check_clang_tidy %s bugprone-do-not-refer-atomic-twice %t
+#define _Bool bool
+typedef _Atomic _Bool atomic_bool;
+typedef _Atomic int atomic_int;
+#define offsetof(type, member) 0
+
+namespace std {
+template 
+struct atomic {
+  atomic(T t) {}
+  T operator=(const T t) { return t; }
+  T operator+(const T t) { return t; }
+  T operator*(const T t) { return t; }
+  void operator+=(const T t) {}
+  T operator++(const T t) { return t; }
+  operator T() const { return 0; }
+};
+} // namespace std
+
+atomic_bool b = false;
+atomic_int n = 0;
+_Atomic int n2 = 0;
+_Atomic(int) n3 = 0;
+std::atomic n4(0);
+
+struct S {
+  atomic_bool b;
+  atomic_int n;
+  _Atomic int n2;
+  _Atomic(int) n3;
+  std::atomic n4();
+};
+
+void warn1() {
+  n = (n + 1) / 2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Do not refer to atomic variable 'n' twice in an expression [bugprone-do-not-refer-atomic-twice]
+  n2 = (n2 + 1) / 2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: Do not refer to atomic variable 'n2' twice in an expression [bugprone-do-not-refer-atomic-twice]
+  n3 = (n3 + 1) / 2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: Do not refer to atomic variable 'n3' twice in an expression [bugprone-do-not-refer-atomic-twice]
+  n4 = (n4 + 1) / 2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: Do not refer to atomic variable 'n4' twice in an expression [bugprone-do-not-refer-atomic-twice]
+  b = b && true;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Do not refer to atomic variable 'b' twice in an expression [bugprone-do-not-refer-atomic-twice]
+}
+
+int warn2_1() {
+  return n * (n + 1) / 2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: Do not refer to atomic variable 'n' twice in an expression [bugprone-do-not-refer-atomic-twice]
+}
+
+int warn2_2() {
+  return n2 * (n2 + 1) / 2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Do not refer to atomic variable 'n2' twice in an expression [bugprone-do-not-refer-atomic-twice]
+}
+
+int warn2_3() {
+  return n3 * (n3 + 1) / 2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Do not refer to atomic variable 'n3' twice in an expression [bugprone-do-not-refer-atomic-twice]
+}
+
+int warn2_4() {
+  return n4 * (n4 + 1) / 2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Do not refer to atomic variable 'n4' twice in an expression [bugprone-do-not-refer-atomic-twice]
+}
+
+int warn2_5() {
+  return (b && true) || b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: Do not refer to atomic variable 'b' twice in an expression [bugprone-do-not-refer-atomic-twice]
+}
+
+void good1() {
+  n = 12;
+  n2 = 12;
+  n3 = 12;
+  n4 = 12;
+  b = true;
+}
+
+int good2_1() {
+  return n;
+}
+
+int good2_2() {
+  return n2;
+}
+
+int good2_3() {
+  return n3;
+}
+
+int good2_4() {
+  return n4;
+}
+
+bool good2_5() {
+  return b;
+}
+
+void good3() {
+  n += 12;
+  n2 += 12;
+  n3 += 12;
+  n4 += 12;
+  b ^= 1;
+}
+
+void good4() {
+  n++;
+  n2++;
+  n3++;
+  n4++;
+}
+
+void good5() {
+  int a = sizeof(atomic_int);
+  int a2 = sizeof(_Atomic int);
+  int a3 = sizeof(_Atomic(int));
+  int a4 = sizeof(std::atomic);
+  int a5 = sizeof(atomic_bool);
+}
+
+void good6() {
+  int a = offsetof(S, b);
+  int a2 = offsetof(S, n);
+  int a3 = offsetof(S, n2);
+  int a4 = offsetof(S, n3);
+  int a5 = offsetof(S, n4);
+}
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
@@ -55,6 +55,7 @@
`bugprone-branch-clone `_,
`bugprone-copy-constructor-init `_, "Yes"
`bugprone-dangling-handle `_,
+   `bugprone-do-not-refer-atomic-twice `_,
`bugprone-dynamic-static-initializers `_,
`bugprone-exception-escape `_,
`bugprone-fold-init-type `_,
@@ -103,6 +10

[PATCH] D91695: [ARM][AArch64] Adding Neoverse N2 CPU support

2020-11-18 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM added a comment.

In D91695#2402495 , @tschuett wrote:

> In the first version N2 had FeatureTME. Did you remove that on purpose?

Yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91695

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


[PATCH] D91695: [ARM][AArch64] Adding Neoverse N2 CPU support

2020-11-18 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

The features still differ from gcc.
https://github.com/gcc-mirror/gcc/blob/cb1a4876a0e724ca3962ec14dce9e7819fa72ea5/gcc/config/aarch64/aarch64-cores.def#L146
It has SVE2_Bitperm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91695

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


[PATCH] D91695: [ARM][AArch64] Adding Neoverse N2 CPU support

2020-11-18 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM added a comment.

In D91695#2402616 , @tschuett wrote:

> The features still differ from gcc.
> https://github.com/gcc-mirror/gcc/blob/cb1a4876a0e724ca3962ec14dce9e7819fa72ea5/gcc/config/aarch64/aarch64-cores.def#L146
> It has SVE2_Bitperm.

I'm still testing some fixes. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91695

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


[PATCH] D43002: Emit S_OBJNAME symbol in CodeView

2020-11-18 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D43002

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


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

2020-11-18 Thread Ye Luo via Phabricator via cfe-commits
ye-luo added a comment.

1. Could you separate the reordering related changes to separate patch?
2. Could you mention which line in spec 4.5 was the restriction? Even 5.0/5.1 
has some restrictions. Need to be clear which one you refer to.


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] D91626: [clangd] Implement textDocument/implementation.

2020-11-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

The patch description is a bit stale now.




Comment at: clang-tools-extra/clangd/XRefs.cpp:1130
+  std::vector Results;
+  // We rely on index to find the implementations in subclasses.
+  if (!Index)

The current way is probably ok -- the index may be stale (if the index is not 
finished yet by the time we call find-implementation), so we might loose some 
latest results for the current main file. I think we need some comments 
describing the behavior. Maybe in future, we'll reconsider it



Comment at: clang-tools-extra/clangd/XRefs.cpp:1140
+  }
+  auto CurLoc = sourceLocationInMainFile(SM, Pos);
+

nit: we need to verify `CurLoc` is available. 



Comment at: clang-tools-extra/clangd/XRefs.cpp:1160
+  auto DefLoc = indexToLSPLocation(Object.Definition, *MainFilePath);
+  Loc.Definition = DefLoc ? *DefLoc : *DeclLoc;
+  Results.push_back(Loc);

I think we can leave the Definition if `!DefLoc`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91626

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


[PATCH] D72184: [BPF] support atomic instructions

2020-11-18 Thread Brendan Jackman via Phabricator via cfe-commits
jackmanb added inline comments.



Comment at: llvm/lib/Target/BPF/BPFInstrInfo.td:699
+  let Inst{51-48} = addr{19-16}; // base reg
+  let Inst{55-52} = dst;
+  let Inst{47-32} = addr{15-0}; // offset

There is another mismatch between what I implemented in the kernel and what 
you've implemented here, which is that I used `dst` as the pointer base and 
`src` as the writeback register but you did the opposite.

IIUC what we have here at the moment is `dst = sync_fetch_and_add(*(src + off), 
dst);`. The advantage is that `dst` makes more intuitive sense as a writeback 
register. 

If we instead had `src = sync_fetch_and_add(*(dst + off), src)` we have the 
unintuitive writeback to `src`, but now a) the 2nd argument (the addend) makes 
more intuitive sense, and b) `dst` being the pointer base is consistent with 
the rest of `BPF_STX`.



Comment at: llvm/lib/Target/BPF/BPFInstrInfo.td:783
+  let Inst{47-32} = addr{15-0}; // offset
+  let Inst{11-8} = new;
+  let Inst{7-4} = BPF_CMPXCHG.Value;

If we go down the route of matching operands with x86 as you have done for 
`XFALU64` and `XCHG`, I think  we should also do it for cmpxchg.

IIUC this is `dst = atomic_cmpxchg(*(src + off), r0, new);` 

But to do it in a single x86 instruction we need to have only 2 operands + the 
hard-coded r0. `r0 = atomic_xmpxchg(*(dst + off), r0, src);` would seem most 
natural to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72184

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


[clang] bd4662c - [AST] Enhance the const expression evaluator to support error-dependent exprs.

2020-11-18 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-11-18T15:48:06+01:00
New Revision: bd4662cd3f3743e08699e6bab976d9e7b163ece0

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

LOG: [AST] Enhance the const expression evaluator to support error-dependent 
exprs.

Fix a crash when evaluating a constexpr function which contains
recovery-exprs. https://bugs.llvm.org/show_bug.cgi?id=46837

Would be nice to have constant expression evaluator support general template
value-dependent expressions, but it requires more work.

This patch is a good start I think, to handle the error-only
value-dependent expressions.

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

Added: 
clang/test/SemaCXX/constexpr-function-recovery-crash.cpp

Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/SemaCXX/enable_if.cpp
clang/test/SemaCXX/invalid-constructor-init.cpp
clang/test/SemaCXX/recovery-expr-type.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 44560c6fd84f..fc1d2cd7757e 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -1942,6 +1942,7 @@ void CallStackFrame::describe(raw_ostream &Out) {
 /// result.
 /// \return \c true if the caller should keep evaluating.
 static bool EvaluateIgnoredValue(EvalInfo &Info, const Expr *E) {
+  assert(!E->isValueDependent());
   APValue Scratch;
   if (!Evaluate(Scratch, Info, E))
 // We don't need the value, but we might have skipped a side effect here.
@@ -2497,6 +2498,7 @@ static bool HandleConversionToBool(const APValue &Val, 
bool &Result) {
 
 static bool EvaluateAsBooleanCondition(const Expr *E, bool &Result,
EvalInfo &Info) {
+  assert(!E->isValueDependent());
   assert(E->isRValue() && "missing lvalue-to-rvalue conv in bool condition");
   APValue Val;
   if (!Evaluate(Val, Info, E))
@@ -4795,9 +4797,11 @@ static bool EvaluateVarDecl(EvalInfo &Info, const 
VarDecl *VD) {
ScopeKind::Block, Result);
 
   const Expr *InitE = VD->getInit();
-  if (!InitE)
+  if (!InitE) {
+if (VD->getType()->isDependentType())
+  return Info.noteSideEffect();
 return getDefaultInitValue(VD->getType(), Val);
-
+  }
   if (InitE->isValueDependent())
 return false;
 
@@ -4825,10 +4829,20 @@ static bool EvaluateDecl(EvalInfo &Info, const Decl *D) 
{
   return OK;
 }
 
+static bool EvaluateDependentExpr(const Expr *E, EvalInfo &Info) {
+  assert(E->isValueDependent());
+  if (Info.noteSideEffect())
+return true;
+  assert(E->containsErrors() && "valid value-dependent expression should never 
"
+"reach invalid code path.");
+  return false;
+}
 
 /// Evaluate a condition (either a variable declaration or an expression).
 static bool EvaluateCond(EvalInfo &Info, const VarDecl *CondDecl,
  const Expr *Cond, bool &Result) {
+  if (Cond->isValueDependent())
+return false;
   FullExpressionRAII Scope(Info);
   if (CondDecl && !EvaluateDecl(Info, CondDecl))
 return false;
@@ -5053,10 +5067,15 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, 
EvalInfo &Info,
   EvaluateLoopBody(Result, Info, FS->getBody(), Case);
   if (ESR != ESR_Continue)
 return ESR;
-  if (FS->getInc()) {
-FullExpressionRAII IncScope(Info);
-if (!EvaluateIgnoredValue(Info, FS->getInc()) || !IncScope.destroy())
-  return ESR_Failed;
+  if (const auto *Inc = FS->getInc()) {
+if (Inc->isValueDependent()) {
+  if (!EvaluateDependentExpr(Inc, Info))
+return ESR_Failed;
+} else {
+  FullExpressionRAII IncScope(Info);
+  if (!EvaluateIgnoredValue(Info, Inc) || !IncScope.destroy())
+return ESR_Failed;
+}
   }
   break;
 }
@@ -5086,13 +5105,18 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, 
EvalInfo &Info,
   switch (S->getStmtClass()) {
   default:
 if (const Expr *E = dyn_cast(S)) {
-  // Don't bother evaluating beyond an expression-statement which couldn't
-  // be evaluated.
-  // FIXME: Do we need the FullExpressionRAII object here?
-  // VisitExprWithCleanups should create one when necessary.
-  FullExpressionRAII Scope(Info);
-  if (!EvaluateIgnoredValue(Info, E) || !Scope.destroy())
-return ESR_Failed;
+  if (E->isValueDependent()) {
+if (!EvaluateDependentExpr(E, Info))
+  return ESR_Failed;
+  } else {
+// Don't bother evaluating beyond an expression-statement which 
couldn't
+// be evaluated.
+// FIXME: Do we need the FullExpressionRAII object here?
+// VisitExprWithCleanups should create one when necessary.
+

[PATCH] D84637: [AST] Enhance the const expression evaluator to support error-dependent exprs.

2020-11-18 Thread Haojian Wu 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 rGbd4662cd3f37: [AST] Enhance the const expression evaluator 
to support error-dependent exprs. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84637

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
  clang/test/SemaCXX/enable_if.cpp
  clang/test/SemaCXX/invalid-constructor-init.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp

Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -53,14 +53,12 @@
 return 2;
   }
   static constexpr int foo2() {
-return AA::getB(); // expected-error{{no matching function for call to 'getB'}} \
-  // expected-note {{subexpression not valid in a constant expression}}
+return AA::getB(); // expected-error{{no matching function for call to 'getB'}}
   }
 };
 // FIXME: should we suppress the "be initialized by a constant expression" diagnostic?
 constexpr auto x2 = AA::foo2(); // expected-error {{be initialized by a constant expression}} \
- // expected-note {{in instantiation of member function}} \
- // expected-note {{in call to}}
+ // expected-note {{in instantiation of member function}}
 }
 
 // verify no assertion failure on violating value category.
Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- clang/test/SemaCXX/invalid-constructor-init.cpp
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -2,7 +2,7 @@
 
 struct X {
   int Y;
-  constexpr X() // expected-error {{constexpr constructor never produces}}
+  constexpr X()
   : Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}}
 };
 // no crash on evaluating the constexpr ctor.
@@ -10,12 +10,12 @@
 
 struct X2 {
   int Y = foo();// expected-error {{use of undeclared identifier 'foo'}}
-  constexpr X2() {} // expected-error {{constexpr constructor never produces a constant expression}}
+  constexpr X2() {}
 };
 
 struct X3 {
   int Y;
-  constexpr X3() // expected-error {{constexpr constructor never produces}}
+  constexpr X3()
   : Y(({foo();})) {} // expected-error {{use of undeclared identifier 'foo'}}
 };
 
Index: clang/test/SemaCXX/enable_if.cpp
===
--- clang/test/SemaCXX/enable_if.cpp
+++ clang/test/SemaCXX/enable_if.cpp
@@ -414,8 +414,8 @@
 
 template  constexpr int callTemplated() { return templated(); }
 
-constexpr int B = 10 + // expected-error {{initialized by a constant expression}}
-callTemplated<0>(); // expected-error@-3{{no matching function for call to 'templated'}} expected-note{{in instantiation of function template}} expected-note@-10{{candidate disabled}} expected-note {{in call to 'callTemplated()'}} expected-note@-3 {{subexpression not valid in a constant expression}}
+constexpr int B = 10 +// expected-error {{initialized by a constant expression}}
+  callTemplated<0>(); // expected-error@-3{{no matching function for call to 'templated'}} expected-note{{in instantiation of function template}} expected-note@-10{{candidate disabled}}
 static_assert(callTemplated<1>() == 1, "");
 }
 
Index: clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 %s -std=c++20 -fsyntax-only -fcxx-exceptions -verify
+
+// verify no value-dependent-assertion crash in constexpr function body and no
+// bogus diagnostics.
+class Foo {
+  constexpr Foo() {
+while (invalid()) {} // expected-error {{use of undeclared identifier}}
+if (invalid()) {} // expected-error {{use of undeclared identifier}}
+  }
+};
+
+constexpr void test1() {
+  while (invalid()) {} // expected-error {{use of undeclared identifier}}
+  if (invalid()) {} // expected-error {{use of undeclared identifier}}
+}
+
+struct A {
+  int *p = new int(invalid()); // expected-error {{use of undeclared identifier}}
+  constexpr ~A() { delete p; }
+};
+constexpr int test2() {
+  A a;
+  return 1;
+}
+
+constexpr int test3() {
+  return invalid(); // expected-error {{use of undeclared identifier}}
+}
+
+constexpr int test4() {
+  if (invalid()) // expected-error {{use of undeclared identifier}}
+return 1;
+  else
+return 0;
+}
+
+constexpr int test5() { // expected-error {{constexpr function never produce}}
+  for (;; a++); // expected-error {{use of undeclared identifier}}

[PATCH] D90928: [OpenCL] Add assertions to extension lookup

2020-11-18 Thread Erik Tomusk via Phabricator via cfe-commits
erik2020 updated this revision to Diff 306094.
erik2020 added a comment.

Changed asserting code to return `false` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90928

Files:
  clang/include/clang/Basic/OpenCLOptions.h


Index: clang/include/clang/Basic/OpenCLOptions.h
===
--- clang/include/clang/Basic/OpenCLOptions.h
+++ clang/include/clang/Basic/OpenCLOptions.h
@@ -37,33 +37,46 @@
   }
 
   bool isEnabled(llvm::StringRef Ext) const {
-return OptMap.find(Ext)->second.Enabled;
+auto E = OptMap.find(Ext);
+return E != OptMap.end() && E->second.Enabled;
   }
 
   // Is supported as either an extension or an (optional) core feature for
   // OpenCL version \p CLVer.
   bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const {
+auto E = OptMap.find(Ext);
+if (E == OptMap.end()) {
+  return false;
+}
 // In C++ mode all extensions should work at least as in v2.0.
 auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
-auto I = OptMap.find(Ext)->getValue();
+auto I = E->getValue();
 return I.Supported && I.Avail <= CLVer;
   }
 
   // Is supported (optional) OpenCL core features for OpenCL version \p CLVer.
   // For supported extension, return false.
   bool isSupportedCore(llvm::StringRef Ext, const LangOptions &LO) const {
+auto E = OptMap.find(Ext);
+if (E == OptMap.end()) {
+  return false;
+}
 // In C++ mode all extensions should work at least as in v2.0.
 auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
-auto I = OptMap.find(Ext)->getValue();
+auto I = E->getValue();
 return I.Supported && I.Avail <= CLVer && I.Core != ~0U && CLVer >= I.Core;
   }
 
   // Is supported OpenCL extension for OpenCL version \p CLVer.
   // For supported (optional) core feature, return false.
   bool isSupportedExtension(llvm::StringRef Ext, const LangOptions &LO) const {
+auto E = OptMap.find(Ext);
+if (E == OptMap.end()) {
+  return false;
+}
 // In C++ mode all extensions should work at least as in v2.0.
 auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
-auto I = OptMap.find(Ext)->getValue();
+auto I = E->getValue();
 return I.Supported && I.Avail <= CLVer && (I.Core == ~0U || CLVer < 
I.Core);
   }
 


Index: clang/include/clang/Basic/OpenCLOptions.h
===
--- clang/include/clang/Basic/OpenCLOptions.h
+++ clang/include/clang/Basic/OpenCLOptions.h
@@ -37,33 +37,46 @@
   }
 
   bool isEnabled(llvm::StringRef Ext) const {
-return OptMap.find(Ext)->second.Enabled;
+auto E = OptMap.find(Ext);
+return E != OptMap.end() && E->second.Enabled;
   }
 
   // Is supported as either an extension or an (optional) core feature for
   // OpenCL version \p CLVer.
   bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const {
+auto E = OptMap.find(Ext);
+if (E == OptMap.end()) {
+  return false;
+}
 // In C++ mode all extensions should work at least as in v2.0.
 auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
-auto I = OptMap.find(Ext)->getValue();
+auto I = E->getValue();
 return I.Supported && I.Avail <= CLVer;
   }
 
   // Is supported (optional) OpenCL core features for OpenCL version \p CLVer.
   // For supported extension, return false.
   bool isSupportedCore(llvm::StringRef Ext, const LangOptions &LO) const {
+auto E = OptMap.find(Ext);
+if (E == OptMap.end()) {
+  return false;
+}
 // In C++ mode all extensions should work at least as in v2.0.
 auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
-auto I = OptMap.find(Ext)->getValue();
+auto I = E->getValue();
 return I.Supported && I.Avail <= CLVer && I.Core != ~0U && CLVer >= I.Core;
   }
 
   // Is supported OpenCL extension for OpenCL version \p CLVer.
   // For supported (optional) core feature, return false.
   bool isSupportedExtension(llvm::StringRef Ext, const LangOptions &LO) const {
+auto E = OptMap.find(Ext);
+if (E == OptMap.end()) {
+  return false;
+}
 // In C++ mode all extensions should work at least as in v2.0.
 auto CLVer = LO.OpenCLCPlusPlus ? 200 : LO.OpenCLVersion;
-auto I = OptMap.find(Ext)->getValue();
+auto I = E->getValue();
 return I.Supported && I.Avail <= CLVer && (I.Core == ~0U || CLVer < I.Core);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77598: Integral template argument suffix and cast printing

2020-11-18 Thread Pratyush Das via Phabricator via cfe-commits
reikdas updated this revision to Diff 306097.

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

https://reviews.llvm.org/D77598

Files:
  clang/include/clang/AST/StmtDataCollectors.td
  clang/include/clang/AST/TemplateBase.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/NestedNameSpecifier.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Analysis/PathDiagnostic.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/Analysis/eval-predefined-exprs.cpp
  clang/test/CXX/lex/lex.literal/lex.ext/p12.cpp
  clang/test/CXX/temp/temp.param/p10-2a.cpp
  clang/test/SemaCXX/builtin-align-cxx.cpp
  clang/test/SemaCXX/cxx11-ast-print.cpp
  clang/test/SemaCXX/matrix-type-builtins.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/test/SemaTemplate/delegating-constructors.cpp
  clang/test/SemaTemplate/matrix-type.cpp
  clang/test/SemaTemplate/temp_arg_nontype.cpp
  clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
  clang/tools/libclang/CIndex.cpp
  
clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
@@ -20,7 +20,7 @@
 llvm::raw_string_ostream Stream(ArgStr);
 const TemplateArgument &Arg = ArgLoc.getArgument();
 
-Arg.print(Context->getPrintingPolicy(), Stream);
+Arg.print(Context->getPrintingPolicy(), Stream, /*IncludeType*/ true);
 Match(Stream.str(), ArgLoc.getLocation());
 return ExpectedLocationVisitor::
   TraverseTemplateArgumentLoc(ArgLoc);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -5144,8 +5144,9 @@
 SmallString<128> Str;
 llvm::raw_svector_ostream OS(Str);
 OS << *ClassSpec;
-printTemplateArgumentList(OS, ClassSpec->getTemplateArgs().asArray(),
-  Policy);
+printTemplateArgumentList(
+OS, ClassSpec->getTemplateArgs().asArray(), Policy,
+ClassSpec->getSpecializedTemplate()->getTemplateParameters());
 return cxstring::createDup(OS.str());
   }
 
Index: clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype_cxx1z.cpp
@@ -457,3 +457,13 @@
   X y;
   int n = y.call(); // expected-error {{cannot initialize a variable of type 'int' with an rvalue of type 'void *'}}
 }
+
+namespace PR9227 {
+template  struct S {};
+template <> struct S<1> { using type = int; }; // expected-note {{'S<1>::type' declared here}}
+S<1L>::type t; // expected-error {{no type named 'type' in 'PR9227::S<1L>'; did you mean 'S<1>::type'?}}
+
+template  struct A {};
+template <> struct A<1> { using type = int; }; // expected-note {{'A<1>::type' declared here}}
+A<2>::type x;  // expected-error {{no type named 'type' in 'PR9227::A<2>'; did you mean 'A<1>::type'?}}
+} // namespace PR9227
Index: clang/test/SemaTemplate/temp_arg_nontype.cpp
===
--- clang/test/SemaTemplate/temp_arg_nontype.cpp
+++ clang/test/SemaTemplate/temp_arg_nontype.cpp
@@ -270,6 +270,23 @@
   void test_char_possibly_negative() { enable_if_char<'\x02'>::type i; } // expected-error{{enable_if_char<'\x02'>'; did you mean 'enable_if_char<'a'>::type'?}}
   void test_char_single_quote() { enable_if_char<'\''>::type i; } // expected-error{{enable_if_char<'\''>'; did you mean 'enable_if_char<'a'>::type'?}}
   void test_char_backslash() { enable_if_char<'\\'>::type i; } // expected-error{{enable_if_char<'\\'>'; did you mean 'enable_if_char<'a'>::type'?}}
+
+  template  struct enable_if_int {};
+  template <> struct enable_if_int<1> { typedef int type; }; // expected-note{{'enable_if_int<1>::type' declared here}}
+  void test_int() { enable_if_int<2>::type i; } // expected-error{{enable_if_int<2>'; did you mean 'enable_if_int<1>::type'?}}
+
+  template  struct enable_if_unsigned_int {};
+  template <> struct enable_if_unsigned_int<1> { typedef int type; }; // expected-note{{'enable_if_unsigned_int<1>::type' declared here}}
+  void test_unsigned_int() { enable_if_unsigned_int<2>::ty

[PATCH] D89869: [OpenCL] Define OpenCL feature macros for all versions

2020-11-18 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/include/clang/Basic/OpenCLOptions.h:51
+  // check specific version of feature)
+  void supportFeatureForPreOCL30(StringRef Feat, bool On = true) {
+assert(CLVer < 300 && "Can'be called for OpenCL C higher 3.0");

Anastasia wrote:
> azabaznov wrote:
> > Anastasia wrote:
> > > I find the name of this function very confusing but I can't think of any 
> > > better one. Also the flow is becoming harder to understand to be honest. 
> > > This function is not as straight forward as `support` because it might 
> > > not actually do what is expected from it. I wonder if the name with 
> > > something like `adjust` would be more appropriate. At the same time 
> > > `adjustFeatures` is the only place where we need to check for the 
> > > version. Perhaps you can just do the language version check straight in 
> > > `adjustFeatures`?
> > > 
> > > Overall, let's just get clear about the flow of setting the features and 
> > > extensions. If in `adjustFeatures` we set default features supported in a 
> > > certain language version then targets can set the other features. Now 
> > > let's examine what should happen with the features and extensions on the 
> > > following use cases:
> > > - Do we always set the equivalent extension when the feature is being set 
> > > by the target?
> > > - Do we always set the equivalent feature when the extension is being set 
> > > by the target?
> > > - What happens when equivalent features and extensions are set but to 
> > > different values?
> > > - What if targets set core feature/extension to unsupported?
> > > - How does `-cl-ext` modify core features/extensions and equivalent 
> > > features+extensions?
> > > 
> > > I am a bit worried about the fact that we have different items for the 
> > > same optional functionality in `OpenCLOptions` as it might be a nightmare 
> > > to keep them consistent. We can however also choose a path of not keeping 
> > > them consistent in the common code and rely on targets to set them up 
> > > correctly.
> > > 
> > > Initially, when we discussed adding feature macros to earlier standards I 
> > > was thinking of simplifying the design. For example instead of checking 
> > > for extension macros and feature macros in the header when declaring 
> > > certain functions we could only check for one of those. The question 
> > > whether we can really achieve the simplifications and at what cost.
> > Ok.
> > 
> > Now I think that defining features for pre-OpenCL C 3.0 if they have 
> > equivalent extension indeed brings up some complexities. The check for the 
> > support of features in header will still look like follows:
> > 
> > ```
> > #if defined(cl_khr_fp64) || defined(__opencl_c_fp64)
> > ...
> > #endif
> > ```
> > 
> > so there is no need to add a feature macro for pre-OpenCL C 3.0 if there is 
> > a same extension to check. Are you agree with that?
> > 
> > However, I still see a reason for defining  equivalent extension for OpenCL 
> > C 3.0 if feature is supported (backward compatibility with earlier OpenCL C 
> > kernels).
> > 
> > > Overall, let's just get clear about the flow of setting the features and 
> > > extensions
> > IMO the main thing which we need to try to follow here is that features are 
> > stronger concept than extensions in OpenCL C 3.0. The reason for this is 
> > that API won't report extension support if the feature is not supported ([[ 
> > https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_API.html#_3d_image_writes
> >  | 3d image writes example]]. To be clear, if users need to support 
> > functionality in OpenCL C 3.0 they should use features, for earlier 
> > versions they should use extensions.
> > 
> > Answering your questions:
> > 
> > > Do we always set the equivalent extension when the feature is being set 
> > > by the target?
> > I think we should do it for OpenCL C 3.0 only to maintain backward 
> > compatibility with OpenCL C 1.2 applications.
> > 
> > > Do we always set the equivalent feature when the extension is being set 
> > > by the target
> > I think we shouldn't set equivalent feature for pre-OpenCL C 3.0 since 
> > there is no need in that. This brings up some complexities, and we can 
> > check an extension presence.
> > 
> > > What happens when equivalent features and extensions are set but to 
> > > different values
> > We need to avoid that case for OpenCL C 3.0 since implementation could not 
> > report extension support if equivalent feature is not supported.
> > 
> > > How does -cl-ext modify core features/extensions and equivalent 
> > > features+extensions
> > '-сl-ext' should not affect feature support in pre-OpenCL 3.0. In OpenCL C 
> > 3.0 it's more likely to use features instead of extensions since it's a 
> > stronger concept; and equivalent feature+extension will be supported 
> > simultaneously if feature is turned on.
> > 
> > And a question:
> > 
> > > What if targets se

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

2020-11-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D86119#2402661 , @ye-luo wrote:

> 1. Could you separate the reordering related changes to separate patch?

It is impossible. There is a separate patch for removing extra TGT_TARGET_PARAM 
but it cannot be separated from this patch.

> 2. Could you mention which line in spec 4.5 was the restriction? Even 5.0/5.1 
> has some restrictions. Need to be clear which one you refer to.

Yes, you right, I'm trying to support something like `map(alloc: S) map(tofrom: 
S.f)` or `map(S, S.ptr[0])` which was not previously allowed and is a feature 
of OpenMP 5.0.


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] D91485: [clang-tidy] ElseAfterReturn check wont suggest fixes if preprocessor branches are involved

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

LGTM aside from the testing request.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability-else-after-return.cpp:313
+#endif
+}

njames93 wrote:
> aaron.ballman wrote:
> > We should probably add some tests for more pathological cases, like:
> > ```
> > #if 1
> > if (true) {
> >   return;
> > #else
> > {
> > #endif
> > } else {
> >   return;
> > }
> > ```
> I'm don't even think its worth adding tests for that kind of code. Its 
> impossible to reason about at the AST level(we dont get any AST for discarded 
> pp conditional branches). So for these or cases like :
> ```lang=c++
> if (true) {
> #if 1
>   return;
> } else {
> #endif
>   return;
> }
> ```
> Its just simpler to leave the behaviour as is and hope that a user sees the 
> change and addresses (or suppresses) it manually.
I was not suggesting that we add the tests because we want to elegantly handle 
such eldritch horrors, but because I want to be sure we're not going to 
crash/assert/etc if we encounter them. My suggestion is to add the test cases 
and if you think the behavior isn't ideal, just stick a FIXME comment on the 
test case to show that we don't like the behavior but aren't dealing with it 
right now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91485

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


[PATCH] D91485: [clang-tidy] ElseAfterReturn check wont suggest fixes if preprocessor branches are involved

2020-11-18 Thread Stephen Kelly via Phabricator via cfe-commits
steveire requested changes to this revision.
steveire added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:34
+  return;
+auto &Collection = Collections[SM.getFileID(Loc)];
+assert(Collection.empty() || Collection.back().getEnd() < Loc);

`auto` needs to be replaced/expanded.



Comment at: 
clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp:208
+
+  const auto &ConditionalBranches = Iter->getSecond();
+

`auto` needs to be replaced/expanded.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91485

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


[PATCH] D91410: [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref

2020-11-18 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D91410#2401751 , @OikawaKirie wrote:

> In D91410#2400018 , @tejohnson wrote:
>
>> 
>
>
>
>> ... the new checking is a mix of assert and fatal errors. Is that intended?
>
> No. The added checks are based on the checks on other calls to the 
> `Target::createXXX` functions in this file or other related files. If there 
> are any fatal errors nearby (e.g. llvm/lib/LTO/ThinLTOCodeGenerator.cpp:581 
> vs 569), the check will be a  fatal error; and if there are any assertions 
> (e.g. llvm/lib/CodeGen/LLVMTargetMachine.cpp:43,45,52 vs 60) or the calls are 
> never checked (e.g. llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:300), the 
> added check will be an assertion.
>
>> If these are not likely due to user input issues, then perhaps they should 
>> all be assert so that they are compiled out in release compilers?
>
> Since all these problems are reported by my static analyzer, I do not really 
> know whether these checked pointers will actually be null when the code is 
> executed. And I did not try to dynamically execute the program to check the 
> problems either. But chances are that if the creator callbacks are not 
> properly set or the called creator functions returns nullptr, the problem 
> will happen. In my opinion, these problems may only happen during 
> development. Therefore, I believe asserts can be sufficient to diagnose the 
> problems.
>
> If you think it would be better to use assertions instead of fatal errors, I 
> will make an update on all `llvm/lib/xxx` files (or maybe all files). But 
> before that, I'd prefer waiting for the replies from other reviewers on the 
> remaining parts of the patch and making an update for all the suggestions.

Sure that sounds good. (Otherwise the llvm/lib parts LGTM)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91410

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


[clang] 5ba324c - [OPENMP]Fix PR48174: compile-time crash with target enter data on a global struct.

2020-11-18 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-11-18T07:48:58-08:00
New Revision: 5ba324ccadce35a146b0c04e90d6414c3dc42546

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

LOG: [OPENMP]Fix PR48174:  compile-time crash with target enter data on a 
global struct.

The compiler should treat array subscript with base pointer as a first
pointer in complex data, it is used only for member expression with base
pointer.

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

Added: 
clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index c20094f5bc99..88be8b9da36d 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7870,6 +7870,10 @@ class MappableExprsHandler {
 IsExpressionFirstInfo = false;
 IsCaptureFirstInfo = false;
 FirstPointerInComplexData = false;
+  } else if (FirstPointerInComplexData) {
+BP = CGF.EmitOMPSharedLValue(I->getAssociatedExpression())
+ .getAddress(CGF);
+FirstPointerInComplexData = false;
   }
 }
 

diff  --git 
a/clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp 
b/clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
new file mode 100644
index ..1132b0194e14
--- /dev/null
+++ b/clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
@@ -0,0 +1,48 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+#pragma omp declare target
+typedef struc

[PATCH] D91660: [OPENMP]Fix PR48174: compile-time crash with target enter data on a global struct.

2020-11-18 Thread Alexey Bataev 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 rG5ba324ccadce: [OPENMP]Fix PR48174:  compile-time crash with 
target enter data on a global… (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91660

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp


Index: clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
@@ -0,0 +1,48 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
--check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+#pragma omp declare target
+typedef struct {
+  int *arr;
+} MyObject;
+
+MyObject *objects;
+#pragma omp end declare target
+
+// CHECK-DAG: [[SIZES0:@.+]] = private unnamed_addr constant [1 x i64] [i64 
{{8|4}}]
+// CHECK-DAG: [[MAPS0:@.+]] = private unnamed_addr constant [1 x i64] [i64 49]
+// CHECK-DAG: [[MAPS1:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, 
i64 281474976710673]
+// CHECK: @main
+int main(void) {
+// CHECK: call void @__tgt_target_data_begin_mapper(i64 -1, i32 1, i8** 
%{{.+}}, i8** %{{.+}}, i64* getelementptr inbounds ([1 x i64], [1 x i64]* 
[[SIZES0]], i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* 
[[MAPS0]], i32 0, i32 0), i8** null)
+#pragma omp target enter data map(to : objects [0:1])
+// CHECK: call void @__tgt_target_data_begin_mapper(i64 -1, i32 2, i8** 
%{{.+}}, i8** %{{.+}}, i64* %{{.+}}, i64* getelementptr inbounds ([2 x i64], [2 
x i64]* [[MAPS1]], i32 0, i32 0), i8** null)
+#pragma omp target enter data map(to : objects[0].arr [0:1])
+
+  return 0;
+}

[PATCH] D91625: [clang] Do not crash on pointer wchar_t pointer assignment.

2020-11-18 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 306108.
adamcz added a comment.

addressed review comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91625

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/SemaCXX/wchar_t.cpp


Index: clang/test/SemaCXX/wchar_t.cpp
===
--- clang/test/SemaCXX/wchar_t.cpp
+++ clang/test/SemaCXX/wchar_t.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar 
-verify=allow-signed %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar 
-verify=allow-signed -DSKIP_ERROR_TESTS %s
 // allow-signed-no-diagnostics
 wchar_t x;
 
@@ -32,3 +32,10 @@
 // rdar://8040728
 wchar_t in[] = L"\x434" "\x434";  // No warning
 
+#ifndef SKIP_ERROR_TESTS
+// Verify that we do not crash when assigning wchar_t* to another pointer type.
+void assignment(wchar_t *x) {
+  char *y;
+  y = x; // expected-error {{incompatible pointer types assigning to 'char *' 
from 'wchar_t *'}}
+}
+#endif
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9972,6 +9972,11 @@
 return UnsignedLongLongTy;
   case BuiltinType::Int128:
 return UnsignedInt128Ty;
+  // wchar_t is special. It is either signed or not, but when it's signed,
+  // there's no matching "unsigned wchar_t". Therefore we return the unsigned
+  // version of it's underlying type instead.
+  case BuiltinType::WChar_S:
+return getUnsignedWCharType();
 
   case BuiltinType::ShortAccum:
 return UnsignedShortAccumTy;


Index: clang/test/SemaCXX/wchar_t.cpp
===
--- clang/test/SemaCXX/wchar_t.cpp
+++ clang/test/SemaCXX/wchar_t.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar -verify=allow-signed %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar -verify=allow-signed -DSKIP_ERROR_TESTS %s
 // allow-signed-no-diagnostics
 wchar_t x;
 
@@ -32,3 +32,10 @@
 // rdar://8040728
 wchar_t in[] = L"\x434" "\x434";  // No warning
 
+#ifndef SKIP_ERROR_TESTS
+// Verify that we do not crash when assigning wchar_t* to another pointer type.
+void assignment(wchar_t *x) {
+  char *y;
+  y = x; // expected-error {{incompatible pointer types assigning to 'char *' from 'wchar_t *'}}
+}
+#endif
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9972,6 +9972,11 @@
 return UnsignedLongLongTy;
   case BuiltinType::Int128:
 return UnsignedInt128Ty;
+  // wchar_t is special. It is either signed or not, but when it's signed,
+  // there's no matching "unsigned wchar_t". Therefore we return the unsigned
+  // version of it's underlying type instead.
+  case BuiltinType::WChar_S:
+return getUnsignedWCharType();
 
   case BuiltinType::ShortAccum:
 return UnsignedShortAccumTy;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91625: [clang] Do not crash on pointer wchar_t pointer assignment.

2020-11-18 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:8726
+else if (!lhptee->isWideCharType() &&
+ lhptee->hasSignedIntegerRepresentation())
   ltrans = S.Context.getCorrespondingUnsignedType(ltrans);

hokein wrote:
> I'm wondering whether the fix is in 
> `ASTContext::getCorrespondingUnsignedType()` 
> 
> if my reading of the standard is right:
> 
> - there exists a corresponding standard (or extended) unsigned integer type 
> for each of standard (or extended) signed integer types, 
> http://eel.is/c++draft/basic.fundamental#2
> - wchar_t is an integer type, http://eel.is/c++draft/basic.fundamental#11, 
> and has an implementation-defined signed or unsigned integer type as its 
> underlying type, http://eel.is/c++draft/basic.fundamental#8
> 
> I think the rule also applies on `wchar_t`, the fix seems to handle `WChar_S` 
> case (return `ASTContext::getUnsignedWCharType()`) in 
> `ASTContext::getCorrespondingUnsignedType()`. What do you think?
http://eel.is/c++draft/basic.fundamental#11 - wchar_t is not a signed or 
unsigned integer type. It is an integer type, but not signed integer type. 
Therefore it's underlying type might have an matching signed/unsigned version, 
but wchar_t does not.

I initially wanted to fix ASTContext::getCorrespondingUnsignedType(), but 
switched to this version with the idea that calling 
getCorrespondingUnsignedType() on wchar_t is most likely a bug in the first 
place and returning something there might just hide the issue.

However, based on your comment and the fact that, for char, we already return 
underlying type too, I think maybe this is a better approach after all. 
Updated. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91625

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


  1   2   3   >