[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-15 Thread Ally Tiritoglu via Phabricator via cfe-commits
atirit updated this revision to Diff 330568.
atirit added a comment.

Added comments for the previous commit's changes and cleaned up those changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

Files:
  clang/lib/Format/TokenAnnotator.cpp


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3663,8 +3663,11 @@
   }
 
   if (isAllmanBrace(Left) || isAllmanBrace(Right)) {
+// The tokens that could force an enum to not be on a single line are a
+// trailing comment and a trailing comma on the last case. This checks for
+// those.
 bool lineContainsBreakingTokens = false;
-FormatToken *breakingSearchToken = Right.Previous;
+const FormatToken *breakingSearchToken = &Right;
 while ((breakingSearchToken = breakingSearchToken->Next)) {
   bool hasBreakingComma = breakingSearchToken->is(tok::comma) &&
   breakingSearchToken->Next->is(tok::r_brace);
@@ -3674,15 +3677,16 @@
   }
 }
 bool isAllowedByAfterEnum =
-(Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) ||
-(Line.startsWith(tok::kw_typedef, tok::kw_enum) &&
- Style.BraceWrapping.AfterEnum);
+(Line.startsWith(tok::kw_enum) ||
+ Line.startsWith(tok::kw_typedef, tok::kw_enum)) &&
+Style.BraceWrapping.AfterEnum;
 bool isLineTooBig = (strlen(Right.TokenText.data()) +
  Right.OriginalColumn) > Style.ColumnLimit;
-bool isAllowedByShortEnums = !Style.AllowShortEnumsOnASingleLine ||
- isLineTooBig || lineContainsBreakingTokens;
-return (isAllowedByAfterEnum &&
-(isAllowedByShortEnums || lineContainsBreakingTokens)) ||
+// AllowShortEnumsOnASingleLine is ignored if the line is too long or
+// contains breaking tokens.
+bool isAllowedByShortEnums = isLineTooBig || lineContainsBreakingTokens ||
+ !Style.AllowShortEnumsOnASingleLine;
+return (isAllowedByAfterEnum && isAllowedByShortEnums) ||
(Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) 
||
(Line.startsWith(tok::kw_struct) && 
Style.BraceWrapping.AfterStruct);
   }


Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3663,8 +3663,11 @@
   }
 
   if (isAllmanBrace(Left) || isAllmanBrace(Right)) {
+// The tokens that could force an enum to not be on a single line are a
+// trailing comment and a trailing comma on the last case. This checks for
+// those.
 bool lineContainsBreakingTokens = false;
-FormatToken *breakingSearchToken = Right.Previous;
+const FormatToken *breakingSearchToken = &Right;
 while ((breakingSearchToken = breakingSearchToken->Next)) {
   bool hasBreakingComma = breakingSearchToken->is(tok::comma) &&
   breakingSearchToken->Next->is(tok::r_brace);
@@ -3674,15 +3677,16 @@
   }
 }
 bool isAllowedByAfterEnum =
-(Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) ||
-(Line.startsWith(tok::kw_typedef, tok::kw_enum) &&
- Style.BraceWrapping.AfterEnum);
+(Line.startsWith(tok::kw_enum) ||
+ Line.startsWith(tok::kw_typedef, tok::kw_enum)) &&
+Style.BraceWrapping.AfterEnum;
 bool isLineTooBig = (strlen(Right.TokenText.data()) +
  Right.OriginalColumn) > Style.ColumnLimit;
-bool isAllowedByShortEnums = !Style.AllowShortEnumsOnASingleLine ||
- isLineTooBig || lineContainsBreakingTokens;
-return (isAllowedByAfterEnum &&
-(isAllowedByShortEnums || lineContainsBreakingTokens)) ||
+// AllowShortEnumsOnASingleLine is ignored if the line is too long or
+// contains breaking tokens.
+bool isAllowedByShortEnums = isLineTooBig || lineContainsBreakingTokens ||
+ !Style.AllowShortEnumsOnASingleLine;
+return (isAllowedByAfterEnum && isAllowedByShortEnums) ||
(Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) ||
(Line.startsWith(tok::kw_struct) && Style.BraceWrapping.AfterStruct);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-15 Thread Ally Tiritoglu via Phabricator via cfe-commits
atirit added a comment.

I would like to request that this commit be considered for merging.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

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


[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-15 Thread Ally Tiritoglu via Phabricator via cfe-commits
atirit updated this revision to Diff 330570.
atirit added a comment.

Attempting to fix build


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1344,12 +1344,52 @@
   Style.AllowShortEnumsOnASingleLine = true;
   verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
   Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+}
+
+TEST_F(FormatTest, AfterEnum) {
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+
+  Style.AllowShortEnumsOnASingleLine = true;
+  Style.BraceWrapping.AfterEnum = true;
+  verifyFormat("enum { A, B, C } Test1;", Style);
+  verifyFormat("enum\n"
+   "{\n"
+   "  A,\n"
+   "  B, // foo\n"
+   "  C\n"
+   "} Test2;",
+   Style);
+  Style.BraceWrapping.AfterEnum = false;
+  verifyFormat("enum { A, B, C } Test3;", Style);
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "  B, // foo\n"
+   "  C\n"
+   "} Test4;",
+   Style);
+
+  Style.AllowShortEnumsOnASingleLine = false;
+  Style.BraceWrapping.AfterEnum = true;
   verifyFormat("enum\n"
"{\n"
"  A,\n"
"  B,\n"
"  C\n"
-   "} ShortEnum1, ShortEnum2;",
+   "} Test5;",
+   Style);
+  Style.BraceWrapping.AfterEnum = false;
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} Test6;",
Style);
 }
 
@@ -13276,6 +13316,7 @@
 TEST_F(FormatTest, AllmanBraceBreaking) {
   FormatStyle AllmanBraceStyle = getLLVMStyle();
   AllmanBraceStyle.BreakBeforeBraces = FormatStyle::BS_Allman;
+  AllmanBraceStyle.AllowShortEnumsOnASingleLine = false;
 
   EXPECT_EQ("namespace a\n"
 "{\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -694,6 +694,8 @@
 return Style.BraceWrapping.AfterUnion;
   if (InitialToken.is(tok::kw_struct))
 return Style.BraceWrapping.AfterStruct;
+  if (InitialToken.is(tok::kw_enum))
+return Style.BraceWrapping.AfterEnum;
   return false;
 }
 
@@ -2482,8 +2484,9 @@
 return true;
   }
 
-  if (!Style.AllowShortEnumsOnASingleLine)
+  if (!Style.AllowShortEnumsOnASingleLine && Style.BraceWrapping.AfterEnum)
 addUnwrappedLine();
+
   // Parse enum body.
   nextToken();
   if (!Style.AllowShortEnumsOnASingleLine) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3662,12 +3662,35 @@
 return true;
   }
 
-  if (isAllmanBrace(Left) || isAllmanBrace(Right))
-return (Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) ||
-   (Line.startsWith(tok::kw_typedef, tok::kw_enum) &&
-Style.BraceWrapping.AfterEnum) ||
+  if (isAllmanBrace(Left) || isAllmanBrace(Right)) {
+// The tokens that could force an enum to not be on a single line are a
+// trailing comment and a trailing comma on the last case. This checks for
+// those.
+bool lineContainsBreakingTokens = false;
+const FormatToken *breakingSearchToken = &Right;
+while ((breakingSearchToken = breakingSearchToken->Next)) {
+  bool hasBreakingComma = breakingSearchToken->is(tok::comma) &&
+  breakingSearchToken->Next->is(tok::r_brace);
+  if (breakingSearchToken->isTrailingComment() || hasBreakingComma) {
+lineContainsBreakingTokens = true;
+break;
+  }
+}
+bool isAllowedByAfterEnum =
+(Line.startsWith(tok::kw_enum) ||
+ Line.startsWith(tok::kw_typedef, tok::kw_enum)) &&
+Style.BraceWrapping.AfterEnum;
+bool isLineTooBig = (strlen(Right.TokenText.data()) +
+ Right.OriginalColumn) > Style.ColumnLimit;
+// AllowShortEnumsOnASingleLine is ignored if the line is too long or
+// contains breaking tokens.
+bool isAllowedByShortEnums = isLineTooBig || lineContainsBreakingTokens ||
+ !Style.AllowShortEnumsOnASingleLine;
+return (isAllowedByAfterEnum && isAllowedByShortEnums) ||
(Line.startsWith(tok::kw_class) && S

[PATCH] D98622: [-Wcalled-once-parameter] Let escapes overwrite MaybeCalled states

2021-03-15 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added a reviewer: NoQ.
Herald added a subscriber: Charusso.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This commit makes escapes symmetrical, meaning that having escape
before and after the branching, where parameter is not called on
one of the paths, will have the same effect.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98622

Files:
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/test/SemaObjC/warn-called-once.m


Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -1130,4 +1130,32 @@
   }
 }
 
+- (void)test_escape_before_branch:(int)cond
+   withCompletion:(void (^)(void))handler {
+  if (cond) {
+filler();
+  }
+
+  void (^copiedHandler)(void) = ^{
+handler();
+  };
+
+  if (cond) {
+// no-warning
+handler();
+  } else {
+copiedHandler();
+  }
+}
+
+- (void)test_escape_after_branch:(int)cond
+   withCompletion:(void (^)(void))handler {
+  if (cond) {
+// no-warning
+handler();
+  }
+
+  escape(handler);
+}
+
 @end
Index: clang/lib/Analysis/CalledOnceCheck.cpp
===
--- clang/lib/Analysis/CalledOnceCheck.cpp
+++ clang/lib/Analysis/CalledOnceCheck.cpp
@@ -1367,7 +1367,7 @@
 if (auto Index = getIndex(Parameter)) {
   ParameterStatus &CurrentParamStatus = CurrentState.getStatusFor(*Index);
 
-  if (CurrentParamStatus.getKind() == ParameterStatus::NotCalled) {
+  if (CurrentParamStatus.isErrorStatus()) {
 CurrentParamStatus = ParameterStatus::Escaped;
   }
 }


Index: clang/test/SemaObjC/warn-called-once.m
===
--- clang/test/SemaObjC/warn-called-once.m
+++ clang/test/SemaObjC/warn-called-once.m
@@ -1130,4 +1130,32 @@
   }
 }
 
+- (void)test_escape_before_branch:(int)cond
+   withCompletion:(void (^)(void))handler {
+  if (cond) {
+filler();
+  }
+
+  void (^copiedHandler)(void) = ^{
+handler();
+  };
+
+  if (cond) {
+// no-warning
+handler();
+  } else {
+copiedHandler();
+  }
+}
+
+- (void)test_escape_after_branch:(int)cond
+   withCompletion:(void (^)(void))handler {
+  if (cond) {
+// no-warning
+handler();
+  }
+
+  escape(handler);
+}
+
 @end
Index: clang/lib/Analysis/CalledOnceCheck.cpp
===
--- clang/lib/Analysis/CalledOnceCheck.cpp
+++ clang/lib/Analysis/CalledOnceCheck.cpp
@@ -1367,7 +1367,7 @@
 if (auto Index = getIndex(Parameter)) {
   ParameterStatus &CurrentParamStatus = CurrentState.getStatusFor(*Index);
 
-  if (CurrentParamStatus.getKind() == ParameterStatus::NotCalled) {
+  if (CurrentParamStatus.isErrorStatus()) {
 CurrentParamStatus = ParameterStatus::Escaped;
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98404: [clangd] Optionally add reflection for clangd-index-server

2021-03-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 330573.
kbobyrev marked an inline comment as done.
kbobyrev added a comment.
Herald added a project: clang-tools-extra.

Add the variable to Features.inc.in and canonicalize.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98404

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Features.inc.in
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -22,6 +22,10 @@
   add_library(protobuf ALIAS protobuf::libprotobuf)
   set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
   add_library(grpc++ ALIAS gRPC::grpc++)
+  if (ENABLE_GRPC_REFLECTION)
+set_target_properties(gRPC::grpc++_reflection PROPERTIES IMPORTED_GLOBAL TRUE)
+add_library(grpc++_reflection ALIAS gRPC::grpc++_reflection)
+  endif()
 
   set(GRPC_CPP_PLUGIN $)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
@@ -71,12 +75,21 @@
   add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
   message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
   set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
+  if (ENABLE_GRPC_REFLECTION)
+find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection $GRPC_OPTS REQUIRED)
+add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
+set_target_properties(grpc++_reflection PROPERTIES IMPORTED_LOCATION ${GRPC_REFLECTION_LIBRARY})
+  endif()
   find_library(PROTOBUF_LIBRARY protobuf $PROTOBUF_OPTS REQUIRED)
   message(STATUS "Using protobuf: " ${PROTOBUF_LIBRARY})
   add_library(protobuf UNKNOWN IMPORTED GLOBAL)
   set_target_properties(protobuf PROPERTIES IMPORTED_LOCATION ${PROTOBUF_LIBRARY})
 endif()
 
+if (ENABLE_GRPC_REFLECTION)
+  set(REFLECTION_LIBRARY grpc++_reflection)
+endif()
+
 # Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.
 # Libraries that use these headers should adjust the include path.
 # If the "GRPC" argument is given, services are also generated.
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -35,6 +35,10 @@
 #include 
 #include 
 
+#ifdef ENABLE_GRPC_REFLECTION
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace remote {
@@ -313,6 +317,9 @@
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
+#ifdef ENABLE_GRPC_REFLECTION
+  grpc::reflection::InitProtoReflectionServerBuilderPlugin();
+#endif
   grpc::ServerBuilder Builder;
   Builder.AddListeningPort(ServerAddress.str(),
grpc::InsecureServerCredentials());
Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -9,6 +9,10 @@
   RemoteIndexServiceProto
   )
 
+if (ENABLE_GRPC_REFLECTION)
+  add_definitions(-DENABLE_GRPC_REFLECTION)
+endif()
+
 target_link_libraries(clangd-index-server
   PRIVATE
   clangDaemon
@@ -17,4 +21,6 @@
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
+
+  ${REFLECTION_LIBRARY}
   )
Index: clang-tools-extra/clangd/Features.inc.in
===
--- clang-tools-extra/clangd/Features.inc.in
+++ clang-tools-extra/clangd/Features.inc.in
@@ -1,3 +1,4 @@
 #define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@
 #define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMOTE@
+#define ENABLE_GRPC_REFLECTION @ENABLE_GRPC_REFLECTION@
 #define CLANGD_MALLOC_TRIM @CLANGD_MALLOC_TRIM@
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -19,6 +19,7 @@
 llvm_canonicalize_cmake_booleans(
   CLANGD_BUILD_XPC
   CLANGD_ENABLE_REMOTE
+  ENABLE_GRPC_REFLECTION
   CLANGD_MALLOC_TRIM
   LLVM_ENABLE_ZLIB
 )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98429: [clang-format] Add new option to clang-format: SpaceBeforeForLoopSemiColon

2021-03-15 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Please add a note to the release notes and also a test for a range based for 
with initializer (c++20).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98429

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


[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-15 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3669-3688
+bool lineContainsBreakingTokens = false;
+const FormatToken *breakingSearchToken = &Right;
+while ((breakingSearchToken = breakingSearchToken->Next)) {
+  bool hasBreakingComma = breakingSearchToken->is(tok::comma) &&
+  breakingSearchToken->Next->is(tok::r_brace);
+  if (breakingSearchToken->isTrailingComment() || hasBreakingComma) {
+lineContainsBreakingTokens = true;

Please refactor this part so that the conditions can short-circuit, and start 
with checking for `!Style.AllowShortEnumsOnASingleLine` (the cheapest check) 
and end with the `while` loop (the apparently most expensive check).
You can do this by putting these conditions in a lambda.
Something like:

```
auto isAllowedByShortEnums = [&] () {
  if (!Style.AllowShortEnumsOnASingleLine) return false;

  // check isLineTooBig etc.

const FormatToken *breakingSearchToken = &Right;
while ((breakingSearchToken = breakingSearchToken->Next)) {
  bool hasBreakingComma = breakingSearchToken->is(tok::comma) &&
  breakingSearchToken->Next->is(tok::r_brace);
  if (breakingSearchToken->isTrailingComment() || hasBreakingComma) {
return true;
  }
}

  return false;
};
return (isAllowedByAfterEnum && isAllowedByShortEnums()) || // ...
```



Comment at: clang/lib/Format/TokenAnnotator.cpp:3683
+Style.BraceWrapping.AfterEnum;
+bool isLineTooBig = (strlen(Right.TokenText.data()) +
+ Right.OriginalColumn) > Style.ColumnLimit;

strlen? Please use `StringRef::size()`.



Comment at: clang/unittests/Format/FormatTest.cpp:13319
   AllmanBraceStyle.BreakBeforeBraces = FormatStyle::BS_Allman;
+  AllmanBraceStyle.AllowShortEnumsOnASingleLine = false;
 

That shouldn't be necessary here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

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


[PATCH] D93938: [clang-format] Fixed AfterEnum handling

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



Comment at: clang/lib/Format/TokenAnnotator.cpp:3690-3691
+return (isAllowedByAfterEnum && isAllowedByShortEnums) ||
(Line.startsWith(tok::kw_class) && Style.BraceWrapping.AfterClass) 
||
(Line.startsWith(tok::kw_struct) && 
Style.BraceWrapping.AfterStruct);
+  }

Maybe move that check to the top and return early (without running through the 
loop and strlen).



Comment at: clang/unittests/Format/FormatTest.cpp:13319
   AllmanBraceStyle.BreakBeforeBraces = FormatStyle::BS_Allman;
+  AllmanBraceStyle.AllowShortEnumsOnASingleLine = false;
 

curdeius wrote:
> That shouldn't be necessary here.
Is it useful to test once with false and once with true?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

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


[PATCH] D98214: [clang-format] Fix aligning with linebreaks

2021-03-15 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM. Let some time to others to have a look before landing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98214

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


[PATCH] D97058: [OpenCL] Refactor diagnostic for OpenCL extension/feature

2021-03-15 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

> Do you also get fatal error: 'opencl-c-base.h' file not found? If so, we 
> might need at least to file a clang bug that we should look at before the 
> next release.

I'm able to reproduce it when not setting `-target` option explicitly:

  $ ./build_release/bin/c-index-test -test-print-type 
./llvm-project/clang/test/Index/opencl-types.cl -cl-std=CL2.0 | 
./build_release/bin/FileCheck ./llvm-project/clang/test/Index/opencl-types.cl
  fatal error: 'opencl-c-base.h' file not found
  fatal error: 'opencl-c-base.h' file not found
  
  $ ./build_release/bin/c-index-test -test-print-type 
./llvm-project/clang/test/Index/opencl-types.cl -cl-std=CL2.0 -target x86_64 | 
./build_release/bin/FileCheck ./llvm-project/clang/test/Index/opencl-types.cl
  $


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97058

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


[PATCH] D98539: [OpenCL] Set target as spir for c-index-test for OpenCL

2021-03-15 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

@Anastasia, thanks for landing this! Sorry for delay, I though that this can 
wait until Monday


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98539

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


[PATCH] D97563: [clang-tidy] Enable modernize-concat-nested-namespaces also on headers

2021-03-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 330578.
DmitryPolukhin added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97563

Files:
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
  
clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
@@ -1,4 +1,13 @@
-// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-concat-nested-namespaces %t
+// RUN: cp %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
+// RUN: %check_clang_tidy -std=c++17 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
+// Restore header file and re-run with c++20:
+// RUN: cp %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
+// RUN: %check_clang_tidy -std=c++20 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
+
+#include "modernize-concat-nested-namespaces.h"
+// CHECK-MESSAGES-DAG: modernize-concat-nested-namespaces.h:1:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 
 namespace n1 {}
 
@@ -27,7 +36,7 @@
 
 namespace n9 {
 namespace n10 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n9::n10
 void t();
 } // namespace n10
@@ -36,7 +45,7 @@
 
 namespace n11 {
 namespace n12 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n11::n12
 namespace n13 {
 void t();
@@ -60,7 +69,7 @@
 namespace n18 {
 namespace n19 {
 namespace n20 {
-// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n18::n19::n20
 void t();
 } // namespace n20
@@ -83,7 +92,7 @@
 namespace {
 namespace n24 {
 namespace n25 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n24::n25
 void t();
 } // namespace n25
@@ -95,7 +104,7 @@
 namespace n26::n27 {
 namespace n28 {
 namespace n29::n30 {
-// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n26::n27::n28::n29::n30
 void t() {}
 } // namespace n29::n30
@@ -105,14 +114,14 @@
 
 namespace n31 {
 namespace n32 {}
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 } // namespace n31
 // CHECK-FIXES-EMPTY
 
 namespace n33 {
 namespace n34 {
 namespace n35 {}
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 } // namespace n34
 // CHECK-FIXES-EMPTY
 namespace n36 {
@@ -127,7 +136,7 @@
 #define IEXIST
 namespace n39 {
 namespace n40 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK

[PATCH] D98487: [AArch64][SVE/NEON] Add support for FROUNDEVEN for both NEON and fixed length SVE

2021-03-15 Thread Caroline via Phabricator via cfe-commits
CarolineConcatto added a comment.

Hi @ bsmith,

Thank you for adding me as a reviewer, although I don't think I am the more 
qualified to approve or not this patch.
But I have a question: 
Why is this patch only changing int_aarch64_neon_frintn and not 
int_aarch64_sve_frintn?
Is there a particular reason to do so? 
As you said in the commit message the ISD node for FROUNDEVEN exists now.
If so it would be too much to explain that in the commit message?
Thank you,
Carol


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98487

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


[PATCH] D97563: [clang-tidy] Enable modernize-concat-nested-namespaces also on headers

2021-03-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I think the implicit question is: won't this regress headers that are meant to 
be compatible with earlier standards?
Did the original review mention anything about this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97563

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


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-15 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/test/CodeGen/arm_acle.c:908
+#if __ARM_64BIT_STATE && defined(__ARM_FEATURE_RNG)
+// AArch64-v8_3-LABEL: @test_rndr(
+// AArch64-v8_3-NEXT:  entry:

stelios-arm wrote:
> SjoerdMeijer wrote:
> > Not sure if I am surprised that this works This is (re)using tag 
> > `AArch64-v8_3` and for the other tests that use this and don't have RNG 
> > set, I was expecting FileCheck to complain about this, not sure if I am 
> > missing something though.
> It turns out that this test is disabled 
> (https://github.com/llvm/llvm-project/commit/6fcd4e080f09c9765d6e0ea03b1da91669c8509a).
>  I am going to remove the changes in this file. 
But this seems to be a useful test to have. Are we testing this elsewhere now?


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

https://reviews.llvm.org/D98264

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


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-15 Thread Stelios Ioannou via Phabricator via cfe-commits
stelios-arm added inline comments.



Comment at: clang/test/CodeGen/arm_acle.c:908
+#if __ARM_64BIT_STATE && defined(__ARM_FEATURE_RNG)
+// AArch64-v8_3-LABEL: @test_rndr(
+// AArch64-v8_3-NEXT:  entry:

SjoerdMeijer wrote:
> stelios-arm wrote:
> > SjoerdMeijer wrote:
> > > Not sure if I am surprised that this works This is (re)using tag 
> > > `AArch64-v8_3` and for the other tests that use this and don't have RNG 
> > > set, I was expecting FileCheck to complain about this, not sure if I am 
> > > missing something though.
> > It turns out that this test is disabled 
> > (https://github.com/llvm/llvm-project/commit/6fcd4e080f09c9765d6e0ea03b1da91669c8509a).
> >  I am going to remove the changes in this file. 
> But this seems to be a useful test to have. Are we testing this elsewhere now?
@dmgreen created a patch to re-enable this test 
(https://reviews.llvm.org/D98510). I am going to add the tests again. 


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

https://reviews.llvm.org/D98264

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


[PATCH] D98404: [clangd] Optionally add reflection for clangd-index-server

2021-03-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt:12
 
+if (ENABLE_GRPC_REFLECTION)
+  set(REFLECTION_LIBRARY grpc++_reflection)

kadircet wrote:
> kbobyrev wrote:
> > kadircet wrote:
> > > can we move this piece into FindGRPC.cmake instead?
> > Yes, but I think only the `set(REFLECTION_LIBRARY grpc++_reflection)` part? 
> > Having the `-DENABLE_GRPC_REFLECTION` definition globally is probably not 
> > very nice and as with the other target under `clangd/index/remote`, 
> > `add_target_definition` doesn't work because of `add_clan_executable` :(
> ah i forgot about that one, can we have this in 
> `clang-tools-extra/clangd/Features.inc.in` then, with rest of our definitions?
> 
> you might also want to canonicalize the option via 
> `llvm_canonicalize_cmake_booleans`
this is not needed anymore right ?



Comment at: clang-tools-extra/clangd/index/remote/server/Server.cpp:38
 
+#ifdef ENABLE_GRPC_REFLECTION
+#include 

this should be `#if` rather than an `#ifdef`, same below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98404

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


[PATCH] D98548: [clang][Sema] Don't try to initialize implicit variable of invalid anonymous union/struct

2021-03-15 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a comment.

This seems quite an early point to bail out, so it will prevent some 
errors/warnings associated with initialization from being emitted. For example, 
this warning is currently emitted but would be suppressed by this patch:

  union {
virtual int a();
int b = 'c'; // expected-warning {{in-class initialization of non-static 
data member is a C++11 extension [-Wc++11-extensions]}}
  }

I don't know how much that matters seeing as the union is invalid by this point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98548

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


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-03-15 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S updated this revision to Diff 330588.
Max_S added a comment.

Changed the option to EmptyLineAfterAccessModifier and allowed the options 
Never, Leave and Always. Updated the tests accordingly and also added an entry 
in the changelog.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9179,6 +9179,128 @@
Style);
 }
 
+TEST_F(FormatTest, FormatsAfterAccessModifiers) {
+  char const *const NL_After_Never = "struct foo {\n"
+ "private:\n"
+ "  void f() {}\n"
+ "\n"
+ "private:\n"
+ "  int i;\n"
+ "\n"
+ "protected:\n"
+ "  int j;\n"
+ "};\n";
+  char const *const NL_After_Always = "struct foo {\n"
+  "private:\n"
+  "\n"
+  "  void f() {}\n"
+  "\n"
+  "private:\n"
+  "\n"
+  "  int i;\n"
+  "\n"
+  "protected:\n"
+  "\n"
+  "  int j;\n"
+  "};\n";
+
+  char const *const NL_After_Always3Times = "struct foo {\n"
+"private:\n"
+"\n\n\n"
+"  void f() {}\n"
+"\n"
+"private:\n"
+"\n\n\n"
+"  int i;\n"
+"\n"
+"protected:\n"
+"\n\n\n"
+"  int j;\n"
+"};\n";
+
+  char const *const NL_After_Never_Before_Never = "struct foo {\n"
+  "private:\n"
+  "  void f() {}\n"
+  "private:\n"
+  "  int i;\n"
+  "protected:\n"
+  "  int j;\n"
+  "};\n";
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_EQ(Style.EmptyLineAfterAccessModifier, FormatStyle::ELAAMS_Never);
+  EXPECT_EQ(NL_After_Never, format(NL_After_Never, Style));
+  EXPECT_EQ(NL_After_Never, format(NL_After_Always, Style));
+
+  Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
+  EXPECT_EQ(NL_After_Always, format(NL_After_Never, Style));
+  EXPECT_EQ(NL_After_Always, format(NL_After_Always, Style));
+
+  Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Leave;
+  Style.MaxEmptyLinesToKeep = 0u;
+  EXPECT_EQ(NL_After_Never_Before_Never, format(NL_After_Never, Style));
+  EXPECT_EQ(NL_After_Never_Before_Never, format(NL_After_Always, Style));
+  EXPECT_EQ(NL_After_Never_Before_Never, format(NL_After_Always3Times, Style));
+
+  Style.MaxEmptyLinesToKeep = 1u;
+  EXPECT_EQ(NL_After_Never, format(NL_After_Never, Style));
+  EXPECT_EQ(NL_After_Always, format(NL_After_Always, Style));
+  EXPECT_EQ(NL_After_Always, format(NL_After_Always3Times, Style));
+
+  Style.MaxEmptyLinesToKeep = 10u;
+  EXPECT_EQ(NL_After_Never, format(NL_After_Never, Style));
+  EXPECT_EQ(NL_After_Always, format(NL_After_Always, Style));
+  EXPECT_EQ(NL_After_Always3Times, format(NL_After_Always3Times, Style));
+
+  // Test with comments
+  char const *const NL_Com_After_Never = "struct foo {\n"
+ "private:\n"
+ "  // comment\n"
+ "  void f() {}\n"
+ "\n"
+ "private: /* comment */\n"
+ "  int i;\n"
+

[PATCH] D98404: [clangd] Optionally add reflection for clangd-index-server

2021-03-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 330589.
kbobyrev marked 2 inline comments as done.
kbobyrev added a comment.

Resolve review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98404

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Features.inc.in
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  llvm/cmake/modules/FindGRPC.cmake


Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -22,6 +22,10 @@
   add_library(protobuf ALIAS protobuf::libprotobuf)
   set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
   add_library(grpc++ ALIAS gRPC::grpc++)
+  if (ENABLE_GRPC_REFLECTION)
+set_target_properties(gRPC::grpc++_reflection PROPERTIES IMPORTED_GLOBAL 
TRUE)
+add_library(grpc++_reflection ALIAS gRPC::grpc++_reflection)
+  endif()
 
   set(GRPC_CPP_PLUGIN $)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
@@ -71,12 +75,21 @@
   add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
   message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
   set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
+  if (ENABLE_GRPC_REFLECTION)
+find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection $GRPC_OPTS REQUIRED)
+add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
+set_target_properties(grpc++_reflection PROPERTIES IMPORTED_LOCATION 
${GRPC_REFLECTION_LIBRARY})
+  endif()
   find_library(PROTOBUF_LIBRARY protobuf $PROTOBUF_OPTS REQUIRED)
   message(STATUS "Using protobuf: " ${PROTOBUF_LIBRARY})
   add_library(protobuf UNKNOWN IMPORTED GLOBAL)
   set_target_properties(protobuf PROPERTIES IMPORTED_LOCATION 
${PROTOBUF_LIBRARY})
 endif()
 
+if (ENABLE_GRPC_REFLECTION)
+  set(REFLECTION_LIBRARY grpc++_reflection)
+endif()
+
 # Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.
 # Libraries that use these headers should adjust the include path.
 # If the "GRPC" argument is given, services are also generated.
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -35,6 +35,10 @@
 #include 
 #include 
 
+#if ENABLE_GRPC_REFLECTION
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace remote {
@@ -313,6 +317,9 @@
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
+#if ENABLE_GRPC_REFLECTION
+  grpc::reflection::InitProtoReflectionServerBuilderPlugin();
+#endif
   grpc::ServerBuilder Builder;
   Builder.AddListeningPort(ServerAddress.str(),
grpc::InsecureServerCredentials());
Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -17,4 +17,6 @@
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
+
+  ${REFLECTION_LIBRARY}
   )
Index: clang-tools-extra/clangd/Features.inc.in
===
--- clang-tools-extra/clangd/Features.inc.in
+++ clang-tools-extra/clangd/Features.inc.in
@@ -1,3 +1,4 @@
 #define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@
 #define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMOTE@
+#define ENABLE_GRPC_REFLECTION @ENABLE_GRPC_REFLECTION@
 #define CLANGD_MALLOC_TRIM @CLANGD_MALLOC_TRIM@
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -19,6 +19,7 @@
 llvm_canonicalize_cmake_booleans(
   CLANGD_BUILD_XPC
   CLANGD_ENABLE_REMOTE
+  ENABLE_GRPC_REFLECTION
   CLANGD_MALLOC_TRIM
   LLVM_ENABLE_ZLIB
 )


Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -22,6 +22,10 @@
   add_library(protobuf ALIAS protobuf::libprotobuf)
   set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
   add_library(grpc++ ALIAS gRPC::grpc++)
+  if (ENABLE_GRPC_REFLECTION)
+set_target_properties(gRPC::grpc++_reflection PROPERTIES IMPORTED_GLOBAL TRUE)
+add_library(grpc++_reflection ALIAS gRPC::grpc++_reflection)
+  endif()
 
   set(GRPC_CPP_PLUGIN $)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
@@ -71,12 +75,21 @@
   add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
   message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
   set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
+  if (ENABLE_G

[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-03-15 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S added a comment.

As already described in the update I changed the option name and how it 
behaves. It is now more in line with EmptyLineBeforeAccessModifier.

I hope this was the correct way to push the rewrite, since all line remarks are 
now off.




Comment at: clang/include/clang/Format/Format.h:1957
+  /// Defines how many lines are put after access modifiers.
+  unsigned EmptyLinesAfterAccessModifier;
+

curdeius wrote:
> This option seems to be very different from `EmptyLineBeforeAccessModifier`. 
> I don't mean in what it does, because this is analogical, but in the possible 
> options.
> Wouldn't it be less surprising to have (at least some) similar options here 
> and there?
> Is there any value in having more than one line after access modifiers? 
> Couldn't that be achieved with Leave option?
> How do the two options work together?
> 
> Also, the difference in singular vs. plural form of "Line(s)" in these two 
> options is disconcerting.
> From the user perspective, it's error-prone to have two options that are at 
> the same time so similar and so different.
I agree with you and changed it accordingly. I left out the option 
`LogicalBlock`.

The interaction between the two options is quite minimal. I can add extra 
tests, that would demonstrate this but I do not think that this is necessary.

The leave option would now applies MaxEmptyLinesToKeep in a correct way. See 
also my remarks in >>! In D98237#2616621.



Comment at: clang/unittests/Format/FormatTest.cpp:9212
+  StyleWithLine.EmptyLinesAfterAccessModifier = 1u;
+  EXPECT_EQ(test2NL, format(test0NL, StyleWithLine));
+  EXPECT_EQ(test2NL, format(test1NL, StyleWithLine));

HazardyKnusperkeks wrote:
> Max_S wrote:
> > MyDeveloperDay wrote:
> > > yeah I'm not a fan of this like this... sorry... just write the test out 
> > > in long form, when it goes wrong I don't have to be a compiler to 
> > > understand what is going wrong I can just see it.
> > I can change this, but the current output of the tests is (I forced the 
> > error):
> > ```
> > //llvm-project/clang/unittests/Format/FormatTest.cpp:72: Failure
> >   Expected: Expected.str()
> >   Which is: "class Foo {\nprivate:\n\n  int i;\n};"
> > To be equal to: format(Expected, Style)
> >   Which is: "class Foo {\nprivate:\n  int i;\n};"
> > With diff:
> > @@ -1,5 @@
> >  class Foo {
> >  private:
> > -
> >int i;
> >  };
> > ```
> > 
> > Which is actually human readable in this case. Shall I still change it?
> I'm a fan of it. :)
> Especially with the demonstration that the string is still expanded.
I changed all to EXPECT_EQ since the failer output there is better. It shows 
the variables names and not the arbitrary code in verfyFormat. Hope this is ok.
```
/home/msagebaum/Kaiserslautern/Programms/temp/llvm-project/clang/unittests/Format/FormatTest.cpp:9202:
 Failure
  Expected: test2NL
  Which is: "class Foo {\nprivate:\n\n  int i;\n};"
To be equal to: format(test1NL)
  Which is: "class Foo {\nprivate:\n  int i;\n};"
With diff:
@@ -1,5 @@
 class Foo {
 private:
-
   int i;
 };




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

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


[PATCH] D97563: [clang-tidy] Enable modernize-concat-nested-namespaces also on headers

2021-03-15 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D97563#2625513 , @lebedev.ri wrote:

> I think the implicit question is: won't this regress headers that are meant 
> to be compatible with earlier standards?
> Did the original review mention anything about this?

Clang-tidy already deals with that using the `--header-filter` option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97563

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


[PATCH] D98404: [clangd] Optionally add reflection for clangd-index-server

2021-03-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 330592.
kbobyrev added a comment.

Include Features.inc in Server.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98404

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Features.inc.in
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -22,6 +22,10 @@
   add_library(protobuf ALIAS protobuf::libprotobuf)
   set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
   add_library(grpc++ ALIAS gRPC::grpc++)
+  if (ENABLE_GRPC_REFLECTION)
+set_target_properties(gRPC::grpc++_reflection PROPERTIES IMPORTED_GLOBAL TRUE)
+add_library(grpc++_reflection ALIAS gRPC::grpc++_reflection)
+  endif()
 
   set(GRPC_CPP_PLUGIN $)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
@@ -71,12 +75,21 @@
   add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
   message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
   set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
+  if (ENABLE_GRPC_REFLECTION)
+find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection $GRPC_OPTS REQUIRED)
+add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
+set_target_properties(grpc++_reflection PROPERTIES IMPORTED_LOCATION ${GRPC_REFLECTION_LIBRARY})
+  endif()
   find_library(PROTOBUF_LIBRARY protobuf $PROTOBUF_OPTS REQUIRED)
   message(STATUS "Using protobuf: " ${PROTOBUF_LIBRARY})
   add_library(protobuf UNKNOWN IMPORTED GLOBAL)
   set_target_properties(protobuf PROPERTIES IMPORTED_LOCATION ${PROTOBUF_LIBRARY})
 endif()
 
+if (ENABLE_GRPC_REFLECTION)
+  set(REFLECTION_LIBRARY grpc++_reflection)
+endif()
+
 # Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.
 # Libraries that use these headers should adjust the include path.
 # If the "GRPC" argument is given, services are also generated.
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "Features.inc"
 #include "Index.pb.h"
 #include "Service.grpc.pb.h"
 #include "index/Index.h"
@@ -35,6 +36,10 @@
 #include 
 #include 
 
+#if ENABLE_GRPC_REFLECTION
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace remote {
@@ -313,6 +318,9 @@
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
+#if ENABLE_GRPC_REFLECTION
+  grpc::reflection::InitProtoReflectionServerBuilderPlugin();
+#endif
   grpc::ServerBuilder Builder;
   Builder.AddListeningPort(ServerAddress.str(),
grpc::InsecureServerCredentials());
Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -17,4 +17,6 @@
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
+
+  ${REFLECTION_LIBRARY}
   )
Index: clang-tools-extra/clangd/Features.inc.in
===
--- clang-tools-extra/clangd/Features.inc.in
+++ clang-tools-extra/clangd/Features.inc.in
@@ -1,3 +1,4 @@
 #define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@
 #define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMOTE@
+#define ENABLE_GRPC_REFLECTION @ENABLE_GRPC_REFLECTION@
 #define CLANGD_MALLOC_TRIM @CLANGD_MALLOC_TRIM@
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -19,6 +19,7 @@
 llvm_canonicalize_cmake_booleans(
   CLANGD_BUILD_XPC
   CLANGD_ENABLE_REMOTE
+  ENABLE_GRPC_REFLECTION
   CLANGD_MALLOC_TRIM
   LLVM_ENABLE_ZLIB
 )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97563: [clang-tidy] Enable modernize-concat-nested-namespaces also on headers

2021-03-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

In D97563#2624680 , @njames93 wrote:

> Is DAG required because the header file warnings are printed in a different 
> order depending on things like platform?

@njames93 Thank you for review! Yes, on Windows build bot showed different 
order of the messages so I added `-DAG` to don't depend on any particular order.

In D97563#2625513 , @lebedev.ri wrote:

> I think the implicit question is: won't this regress headers that are meant 
> to be compatible with earlier standards?
> Did the original review mention anything about this?

In the original code review it was not discussed. Moreover it is more or less 
applicable to all modernize-* checks and they work in headers selected with 
`--header-filter` so I think these is no reason to invent special mechanism 
only for this check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97563

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


[PATCH] D98487: [AArch64][SVE/NEON] Add support for FROUNDEVEN for both NEON and fixed length SVE

2021-03-15 Thread Bradley Smith via Phabricator via cfe-commits
bsmith added a comment.

> Why is this patch only changing int_aarch64_neon_frintn and not 
> int_aarch64_sve_frintn?
> Is there a particular reason to do so?

Things are done slightly differently for SVE in this regard, in principal yes, 
we could emit roundeven instead of frintn from the ACLE intrinsic, however all 
of the other ACLE intrinsics also emit SVE specific LLVM intrinsics rather than 
the arch-indep nodes. This patch doesn't change that in order to stay 
consistent, if we did want to change that it should be done as a separate patch 
that changes all of them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98487

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


[PATCH] D97563: [clang-tidy] Enable modernize-concat-nested-namespaces also on headers

2021-03-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 330596.
DmitryPolukhin added a comment.

Rebase again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97563

Files:
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
  
clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
@@ -1,4 +1,13 @@
-// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-concat-nested-namespaces %t
+// RUN: cp %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
+// RUN: %check_clang_tidy -std=c++17 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
+// Restore header file and re-run with c++20:
+// RUN: cp %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
+// RUN: %check_clang_tidy -std=c++20 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
+
+#include "modernize-concat-nested-namespaces.h"
+// CHECK-MESSAGES-DAG: modernize-concat-nested-namespaces.h:1:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 
 namespace n1 {}
 
@@ -27,7 +36,7 @@
 
 namespace n9 {
 namespace n10 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n9::n10
 void t();
 } // namespace n10
@@ -36,7 +45,7 @@
 
 namespace n11 {
 namespace n12 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n11::n12
 namespace n13 {
 void t();
@@ -60,7 +69,7 @@
 namespace n18 {
 namespace n19 {
 namespace n20 {
-// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n18::n19::n20
 void t();
 } // namespace n20
@@ -83,7 +92,7 @@
 namespace {
 namespace n24 {
 namespace n25 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n24::n25
 void t();
 } // namespace n25
@@ -95,7 +104,7 @@
 namespace n26::n27 {
 namespace n28 {
 namespace n29::n30 {
-// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n26::n27::n28::n29::n30
 void t() {}
 } // namespace n29::n30
@@ -105,14 +114,14 @@
 
 namespace n31 {
 namespace n32 {}
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 } // namespace n31
 // CHECK-FIXES-EMPTY
 
 namespace n33 {
 namespace n34 {
 namespace n35 {}
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 } // namespace n34
 // CHECK-FIXES-EMPTY
 namespace n36 {
@@ -127,7 +136,7 @@
 #define IEXIST
 namespace n39 {
 namespace n40 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 //

[clang] 1974065 - [AST] Add generator for source location introspection

2021-03-15 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-03-15T10:52:44Z
New Revision: 19740652c4c4329e2b9e77f96e5e31c360b4e8bb

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

LOG: [AST] Add generator for source location introspection

Generate a json file containing descriptions of AST classes and their
public accessors which return SourceLocation or SourceRange.

Use the JSON file to generate a C++ API and implementation for accessing
the source locations and method names for accessing them for a given AST
node.

This new API can be used to implement 'srcloc' output in clang-query:

  http://ce.steveire.com/z/m_kTIo

The JSON file can also be used to generate bindings for other languages,
such as Python and Javascript:

  https://steveire.wordpress.com/2019/04/30/the-future-of-ast-matching

In this first version of this feature, only the accessors for Stmt
classes are generated, not Decls, TypeLocs etc.  Those can be added
after this change is reviewed, as this change is mostly about
infrastructure of these code generators.

Also in this version, the platforms/cmake configurations are excluded as
much as possible so that support can be added iteratively.  Currently a
break on any platform causes a revert of the entire feature.  This way,
the `OR WIN32` can be removed in a future commit and if it breaks the
buildbots, only that commit gets reverted, making the entire process
easier to manage.

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

Added: 
clang/include/clang/Tooling/NodeIntrospection.h
clang/lib/Tooling/DumpTool/APIData.h
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.h
clang/lib/Tooling/DumpTool/CMakeLists.txt
clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
clang/lib/Tooling/NodeIntrospection.cpp
clang/unittests/Introspection/CMakeLists.txt
clang/unittests/Introspection/IntrospectionTest.cpp
llvm/utils/gn/secondary/clang/lib/Tooling/DumpTool/BUILD.gn
llvm/utils/gn/secondary/clang/unittests/Introspection/BUILD.gn

Modified: 
clang/lib/Tooling/CMakeLists.txt
clang/unittests/CMakeLists.txt
llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
llvm/utils/gn/secondary/clang/unittests/BUILD.gn

Removed: 




diff  --git a/clang/include/clang/Tooling/NodeIntrospection.h 
b/clang/include/clang/Tooling/NodeIntrospection.h
new file mode 100644
index ..abaa58b674a1
--- /dev/null
+++ b/clang/include/clang/Tooling/NodeIntrospection.h
@@ -0,0 +1,85 @@
+//===- NodeIntrospection.h *- C++ 
-*---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file contains the implementation of the NodeIntrospection.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
+#define LLVM_CLANG_TOOLING_NODEINTROSPECTION_H
+
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/DeclarationName.h"
+
+#include 
+#include 
+
+namespace clang {
+
+class Stmt;
+
+namespace tooling {
+
+class LocationCall {
+public:
+  enum LocationCallFlags { NoFlags, ReturnsPointer, IsCast };
+  LocationCall(std::shared_ptr on, std::string name,
+   LocationCallFlags flags = NoFlags)
+  : m_on(on), m_name(name), m_flags(flags) {}
+  LocationCall(std::shared_ptr on, std::string name,
+   std::vector const &args,
+   LocationCallFlags flags = NoFlags)
+  : m_on(on), m_name(name), m_flags(flags) {}
+
+  LocationCall *on() const { return m_on.get(); }
+  StringRef name() const { return m_name; }
+  std::vector const &args() const { return m_args; }
+  bool returnsPointer() const { return m_flags & ReturnsPointer; }
+  bool isCast() const { return m_flags & IsCast; }
+
+private:
+  std::shared_ptr m_on;
+  std::string m_name;
+  std::vector m_args;
+  LocationCallFlags m_flags;
+};
+
+class LocationCallFormatterCpp {
+public:
+  static std::string format(LocationCall *Call);
+};
+
+namespace internal {
+struct RangeLessThan {
+  bool operator()(
+  std::pair> const &LHS,
+  std::pair> const &RHS) const;
+};
+} // namespace internal
+
+template >>
+using UniqueMultiMap = std::set, Comp>;
+
+using SourceLocationMap =
+UniqueMultiMap>;
+using SourceRangeMap =
+UniqueMultiMap,
+   internal::RangeLessThan>;
+
+struct NodeLocationAccessors {
+  SourceLocationMap LocationAccessors;
+  SourceRangeMap RangeAccessors;
+};
+
+namespace N

[PATCH] D98113: [Driver] Also search FilePaths for compiler-rt before falling back

2021-03-15 Thread Luís Marques via Phabricator via cfe-commits
luismarques added a comment.

This makes sense to me but I'm not quite sure about the implications, 
especially when we consider compatibility. I think we need more eyes on this 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98113

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


[PATCH] D98487: [AArch64][SVE/NEON] Add support for FROUNDEVEN for both NEON and fixed length SVE

2021-03-15 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added a comment.

In D98487#2625673 , @bsmith wrote:

>> Why is this patch only changing int_aarch64_neon_frintn and not 
>> int_aarch64_sve_frintn?
>> Is there a particular reason to do so?
>
> Things are done slightly differently for SVE in this regard, in principal 
> yes, we could emit roundeven instead of frintn from the ACLE intrinsic, 
> however all of the other ACLE intrinsics also emit SVE specific LLVM 
> intrinsics rather than the arch-indep nodes. This patch doesn't change that 
> in order to stay consistent, if we did want to change that it should be done 
> as a separate patch that changes all of them.

@CarolineConcatto There are two levels at play here.  At the top level 
(C->LLVM) the SVE ACLE cannot use the roundeven intrinsic because that 
operation takes a single data operand whereas for SVE the operation is 
predicated and thus also requires predicate and passthru operands (i.e. the two 
intrinsics are doing different things).  At the bottom level (CodeGen) we 
already lower scalable vector variants of both intrinsics to 
ISD::FROUNDEVEN_MERGE_PASSTHRU which is the "masked" version of ISD::FROUNDEVEN.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98487

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-15 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

I tried reproducing the CI failures reported at the top (in particular 
`intrinsic_module_path.f90`), but haven't had much luck. @arnamoy10 - how about 
you?

Could you `clang-format` this patch when uploading the next diff? Thank you!




Comment at: flang/lib/Frontend/CompilerInvocation.cpp:319
+  // to the default location to search (currently hardcoded).
+  // TODO: identify a value for this default search directory
+  for (const auto *currentArg :

This `TODO` has been addressed, right?



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:323
+opts.searchDirectoriesFromIntrModPath.emplace_back(currentArg->getValue());
+  opts.searchDirectoriesFromIntrModPath.emplace_back(getIntrinsicDir());
 }

This method is meant for parsing input parameters, but the default directory 
for intrinsic modules is not a parameter. I think that `setFortranOpts` would 
be a better place for adding the default directory for 
`fortranOptions.searchDirectories`.


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

https://reviews.llvm.org/D97080

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


[PATCH] D97125: Stop traping on sNaN in __builtin_isinf

2021-03-15 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added a comment.

In D97125#2603832 , @thopre wrote:

> Requesting review since the logic has changed. This time I've also tested 
> isfinite against glibc's result. All looks good.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97125

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


[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

The attribute bits look fine to me aside from the documentation request.




Comment at: clang/include/clang/Basic/Attr.td:738
   let Args = [UnsignedArgument<"Count">, DefaultIntArgument<"Offset", 0>];
   let Documentation = [PatchableFunctionEntryDocs];
 }

We should probably add some documentation about what targets this attribute is 
supported on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

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


[PATCH] D98487: [AArch64][SVE/NEON] Add support for FROUNDEVEN for both NEON and fixed length SVE

2021-03-15 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:476
-  // intrinsic.
-  def int_aarch64_neon_frintn : AdvSIMD_1FloatArg_Intrinsic;
-

If you are removing the old intrinsic (which is great), then it will need some 
AutoUpgrade code from the old to the new. Hopefully in this case that's pretty 
simple. Look for how aarch64.rbit is done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98487

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


[PATCH] D97119: [flang][driver] Add options for -std=f2018

2021-03-15 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: clang/include/clang/Driver/Options.td:3535-3536
   MarshallingInfoFlag>;
-def pedantic : Flag<["-", "--"], "pedantic">, Group, 
Flags<[CC1Option]>,
-  MarshallingInfoFlag>;
+def pedantic : Flag<["-", "--"], "pedantic">, Group, 
Flags<[CC1Option,FlangOption,FC1Option]>,
+  HelpText<"Issue warnings for uses of extensions to Fortran">, 
MarshallingInfoFlag>;
 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,

As this options is shared with Clang, the description should be generic enough 
so that it works for both `clang` and `flang`. Some sources for inspiration 
below:

**gfortran 1**
```
 gfortran --help=common | grep "\-\-pedantic"
  --pedantic  Same as -Wpedantic.  Use the latter option 
instead.
  --pedantic-errors   Same as -pedantic-errors.  Use the latter option 
instead.
```
**gfortran 2**
```
$ gfortran --help=common | grep "\-Wpedantic "
  -Wpedantic  Issue warnings needed for strict compliance to 
the standard.
```
**clang** 
(from https://clang.llvm.org/docs/UsersManual.html):
```
-pedantic
Warn on language extensions.

-pedantic-errors
Error on language extensions.
```



Comment at: clang/lib/Driver/ToolChains/Flang.cpp:43
+options::OPT_flarge_sizes,
+options::OPT_pedantic,
+options::OPT_std_EQ});

`-pedantic` controls errors and warning messages. It's not really a dialect 
option.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:371-374
+  if (args.hasArg(clang::driver::options::OPT_fopenmp)) {
+res.frontendOpts().features_.Enable(
+Fortran::common::LanguageFeature::OpenMP);
+  }

DELETEME?



Comment at: flang/test/Driver/std2018.f90:6-11
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty 
--check-prefix=WITHOUT
+! RUN: %flang-new -fsyntax-only -std=f2018 %s  2>&1 | FileCheck %s 
--check-prefix=GIVEN
+! RUN: %flang-new -fsyntax-only -pedantic %s  2>&1 | FileCheck %s 
--check-prefix=GIVEN
+! RUN: %f18 -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty 
--check-prefix=WITHOUT
+! RUN: %f18 -fsyntax-only -Mstandard %s  2>&1 | FileCheck %s 
--check-prefix=GIVEN
+! RUN: not %flang-new -fsyntax-only -std=90 %s  2>&1 | FileCheck %s 
--check-prefix=WRONG

We are moving towards sharing all of the tests between the new and the old 
drivers (more context: https://reviews.llvm.org/D98257). We should avoid:
* `%f18`, which is meant for `f18` only,
* `%flang-new`, which is meant for `flang-new` only.

So this whole section is a bit problematic. As these options don't require any 
particular logic in the compiler driver (i.e. `flang-new`), I suggest deleting 
it. It is sufficient to test with the frontend driver `%flang_fc1` (i.e. 
`flang-new -fc1`).


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

https://reviews.llvm.org/D97119

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


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-15 Thread Stelios Ioannou via Phabricator via cfe-commits
stelios-arm updated this revision to Diff 330616.
stelios-arm added a comment.

Added tests in `arm_acle.c`.


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

https://reviews.llvm.org/D98264

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/builtins-arm64.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/rand.ll
  llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir

Index: llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
===
--- llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
+++ llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
@@ -100,11 +100,11 @@
   bb.0:
 liveins: $x0
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 renamable $x8 = MOVZXi 15309, 0
 renamable $x8 = MOVKXi renamable $x8, 26239, 16
 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store 8)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRXui killed renamable  $x8, renamable killed $x0, 1, implicit killed $x8 :: (store 8)
 RET undef $lr
 
@@ -134,9 +134,9 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRXui killed renamable  $x8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
@@ -166,9 +166,9 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
@@ -275,10 +275,10 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 renamable $w8 = ORRWrs $wzr, killed renamable $w8, 0, implicit-def $x8
 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
Index: llvm/test/CodeGen/AArch64/rand.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/rand.ll
@@ -0,0 +1,38 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64 -mcpu=neoverse-v1 -mattr=+rand %s -o - | FileCheck %s
+
+define  i32 @rndr(i64* %__addr) {
+; CHECK-LABEL: rndr:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x8, RNDR
+; CHECK-NEXT:cset w9, eq
+; CHECK-NEXT:str x8, [x0]
+; CHECK-NEXT:and w0, w9, #0x1
+; CHECK-NEXT:ret
+  %1 = tail call { i64, i1 } @llvm.aarch64.rndr()
+  %2 = extractvalue { i64, i1 } %1, 0
+  %3 = extractvalue { i64, i1 } %1, 1
+  store i64 %2, i64* %__addr, align 8
+  %4 = zext i1 %3 to i32
+  ret i32 %4
+}
+
+
+define  i32 @rndrrs(i64*  %__addr) {
+; CHECK-LABEL: rndrrs:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x8, RNDRRS
+; CHECK-NEXT:cset w9, eq
+; CHECK-NEXT:str x8, [x0]
+; CHECK-NEXT:and w0, w9, #0x1
+; CHECK-NEXT:ret
+  %1 = tail call { i64, i1 } @llvm.aarch64.rndrrs()
+  %2 = extractvalue { i64, i1 } %1, 0
+  %3 = extractvalue { i64, i1 } %1, 1
+  store i64 %2, i64* %__addr, align 8
+  %4 = zext i1 %3 to i32
+  ret i32 %4
+}
+
+declare { i64, i1 } @llvm.aarch64.rndr()
+declare { i64, i1 } @llvm.aarch64.rndrrs()
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -607,7 +607,9 @@
 def AArch64stnp : SDNode<"AArch64ISD::STNP", SDT_AArch64stnp, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
 
 def AArch64tbl : SDNode<"AArch64ISD::TBL", SDT_AArch64TBL>;
-
+def AArch64mrs : SDNode<"AArch64ISD::MRS",
+SDTypeProfile<1, 1, [SDTCisVT<0, i64>, SDTCisVT<1, i32>]>,
+[SDNPHasChain, SDNPOutGlue]>;
 //===--===//
 
 //===--===//
@@ -1266,6 +126

[PATCH] D98134: [RFC][POC] Introduce callback argument encoding mode into callback metadata

2021-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:432
 If a statement is marked ``nomerge`` and contains call expressions, those call
-expressions inside the statement will not be merged during optimization. This 
+expressions inside the statement will not be merged during optimization. This
 attribute can be used to prevent the optimizer from obscuring the source

It looks like a bunch of unrelated whitespace changes snuck in.



Comment at: clang/include/clang/Basic/AttrDocs.td:5221
+The first position in the attribute identifies the callback argument encoding
+mode, ``0`` for flat mode, and ``1`` for stacked mode. The following example
+shows the difference between the two modes:

Rather than use `0` and `1` directly, any reason not to use a named enumerator 
so that the user can write: `__attribute__((callback(stacked, 3, 4)))`?

Also, should this attribute argument be the last argument in the list and made 
optional so that existing code will continue to work?



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2940
+def err_callback_attribute_no_encoding_mode : Error<
+  "'callback' attribute specifies no parameter encoding mode">;
 def err_callback_attribute_invalid_callee : Error<

I'm not certain it's reasonable to turn this into an error given that this 
attribute already exists in the wild. This basically breaks all users of the 
attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98134

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


[PATCH] D98521: [clang-tidy] Fix readability-identifer-naming duplicating prefix or suffix for replacements.

2021-03-15 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.

Good catch, LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98521

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


[PATCH] D93164: [AST] Add generator for source location introspection

2021-03-15 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

ast-dump-tool is still somewhere in lib/ instead of in tools/ in the reland as 
far as I can tell.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93164

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


[clang] c0cd527 - [ast-dump-tool] fix regression if --empty-implementation but --json-input-path is not

2021-03-15 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-03-15T08:48:26-04:00
New Revision: c0cd5274ccdbe57edb20b0375b73a75c70a48882

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

LOG: [ast-dump-tool] fix regression if --empty-implementation but 
--json-input-path is not

Looks like this broke in one of the relands of
https://reviews.llvm.org/D93164

Added: 


Modified: 
clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py

Removed: 




diff  --git a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py 
b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
index 054cae6e78f2..b4d31d3e49a9 100755
--- a/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
+++ b/clang/lib/Tooling/DumpTool/generate_cxx_src_locs.py
@@ -156,14 +156,16 @@ def main():
 
 use_empty_implementation = options.empty_implementation
 
-if not os.path.exists(options.json_input_path):
-  use_empty_implementation = True
+if (not use_empty_implementation
+and not os.path.exists(options.json_input_path)):
+use_empty_implementation = True
 
-with open(options.json_input_path) as f:
-jsonData = json.load(f)
+if not use_empty_implementation:
+with open(options.json_input_path) as f:
+jsonData = json.load(f)
 
-if not 'classesInClade' in jsonData or not jsonData["classesInClade"]:
-  use_empty_implementation = True
+if not 'classesInClade' in jsonData or not jsonData["classesInClade"]:
+use_empty_implementation = True
 
 if use_empty_implementation:
 with open(os.path.join(os.getcwd(),



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


[PATCH] D98295: [Clang] Add addrsig attribute to mark global functions/variables as address significant.

2021-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm not opposed to the attribute per se, but I'd like to understand the 
motivation behind it a bit more. It seems like it solves a special edge case 
for a specific linker and I'm wondering if that's sufficient motivation for the 
community to support the attribute or not.




Comment at: clang/test/Sema/attr-addrsig.c:8
+
+struct __attribute__((addrsig)) A {}; // expected-warning {{'addrsig' 
attribute only applies to functions and variables}}

You should also have a test that the attribute does not accept any arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98295

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


[PATCH] D97717: [SYCL] Rework the SYCL driver options

2021-03-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 requested changes to this revision.
jansvoboda11 added a comment.
This revision now requires changes to proceed.

I like the simplification of the command line interface. I have concerns about 
changing the tests just to make them pass though.




Comment at: clang/unittests/Frontend/CompilerInvocationTest.cpp:547
+  // there is no syntax I could find that would allow it). However, the option
+  // is handled properly on a real invocation. See: Clang::ConstructJob().
+  ASSERT_THAT(GeneratedArgs, Contains(HasSubstr("-sycl-std=")));

The `generateCC1CommandLine` function is used when CC1 gets invoked with 
`-round-trip-args`. It is also going to be used in `clang-scan-deps`.

Instead of putting a fixme here, I think it would make more sense to decide how 
to handle the option properly. There are a couple of approaches:
* Instead of removing `ShouldParseIf` from `sycl_std_EQ`, it 
could be replaced with `ShouldParseIf`.
* Remove `ShouldParseIf` from `sycl_std_EQ`, but issue 
warning/error in `CompilerInvocation::fixupInvocation` whenever `SYCLVersion != 
LangOptions::SYCL_None && !(SYCLIsDevice || SYCLIsHost)`.
* Remove the marshalling annotation from `sycl_std_EQ` and handle its 
parsing/generation including the device/host checks manually in 
`CompilerInvocation`. (I'm personally not fan of moving simple logic like this 
from tablegen marshalling annotations to `CompilerInvocation` though.)

See 
https://clang.llvm.org/docs/InternalsManual.html#adding-new-command-line-option 
for more information.


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

https://reviews.llvm.org/D97717

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


[PATCH] D98487: [AArch64][SVE/NEON] Add support for FROUNDEVEN for both NEON and fixed length SVE

2021-03-15 Thread Bradley Smith via Phabricator via cfe-commits
bsmith updated this revision to Diff 330629.
bsmith added a comment.
Herald added a subscriber: dexonsmith.

- Add AutoUpgrade code to convert aarch64.neon.frintn to roundeven
- Add test for above AutoUpgrade


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98487

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-intrinsics.c
  clang/test/CodeGen/aarch64-neon-misc.c
  clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm64-vrnd.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/include/llvm/Target/TargetSelectionDAG.td
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/arm64-vcvt.ll
  llvm/test/CodeGen/AArch64/arm64-vfloatintrinsics.ll
  llvm/test/CodeGen/AArch64/f16-instructions.ll
  llvm/test/CodeGen/AArch64/fp-intrinsics.ll
  llvm/test/CodeGen/AArch64/frintn.ll
  llvm/test/CodeGen/AArch64/sve-fixed-length-fp-rounding.ll
  llvm/test/CodeGen/AArch64/vec-libcalls.ll

Index: llvm/test/CodeGen/AArch64/vec-libcalls.ll
===
--- llvm/test/CodeGen/AArch64/vec-libcalls.ll
+++ llvm/test/CodeGen/AArch64/vec-libcalls.ll
@@ -29,6 +29,7 @@
 declare <3 x float> @llvm.nearbyint.v3f32(<3 x float>)
 declare <3 x float> @llvm.rint.v3f32(<3 x float>)
 declare <3 x float> @llvm.round.v3f32(<3 x float>)
+declare <3 x float> @llvm.roundeven.v3f32(<3 x float>)
 declare <3 x float> @llvm.sqrt.v3f32(<3 x float>)
 declare <3 x float> @llvm.trunc.v3f32(<3 x float>)
 
@@ -478,6 +479,15 @@
   ret <3 x float> %r
 }
 
+define <3 x float> @roundeven_v3f32(<3 x float> %x) nounwind {
+; CHECK-LABEL: roundeven_v3f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:frintn v0.4s, v0.4s
+; CHECK-NEXT:ret
+  %r = call <3 x float> @llvm.roundeven.v3f32(<3 x float> %x)
+  ret <3 x float> %r
+}
+
 define <3 x float> @sqrt_v3f32(<3 x float> %x) nounwind {
 ; CHECK-LABEL: sqrt_v3f32:
 ; CHECK:   // %bb.0:
Index: llvm/test/CodeGen/AArch64/sve-fixed-length-fp-rounding.ll
===
--- llvm/test/CodeGen/AArch64/sve-fixed-length-fp-rounding.ll
+++ llvm/test/CodeGen/AArch64/sve-fixed-length-fp-rounding.ll
@@ -1255,6 +1255,253 @@
   ret void
 }
 
+;
+; ROUNDEVEN -> FRINTN
+;
+
+; Don't use SVE for 64-bit vectors.
+define <4 x half> @frintn_v4f16(<4 x half> %op) #0 {
+; CHECK-LABEL: frintn_v4f16:
+; CHECK: frintn v0.4h, v0.4h
+; CHECK-NEXT: ret
+  %res = call <4 x half> @llvm.roundeven.v4f16(<4 x half> %op)
+  ret <4 x half> %res
+}
+
+; Don't use SVE for 128-bit vectors.
+define <8 x half> @frintn_v8f16(<8 x half> %op) #0 {
+; CHECK-LABEL: frintn_v8f16:
+; CHECK: frintn v0.8h, v0.8h
+; CHECK-NEXT: ret
+  %res = call <8 x half> @llvm.roundeven.v8f16(<8 x half> %op)
+  ret <8 x half> %res
+}
+
+define void @frintn_v16f16(<16 x half>* %a) #0 {
+; CHECK-LABEL: frintn_v16f16:
+; CHECK: ptrue [[PG:p[0-9]+]].h, vl16
+; CHECK-DAG: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
+; CHECK-NEXT: frintn [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
+; CHECK-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
+; CHECK-NEXT: ret
+  %op = load <16 x half>, <16 x half>* %a
+  %res = call <16 x half> @llvm.roundeven.v16f16(<16 x half> %op)
+  store <16 x half> %res, <16 x half>* %a
+  ret void
+}
+
+define void @frintn_v32f16(<32 x half>* %a) #0 {
+; CHECK-LABEL: frintn_v32f16:
+; VBITS_GE_512: ptrue [[PG:p[0-9]+]].h, vl32
+; VBITS_GE_512-DAG: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
+; VBITS_GE_512-NEXT: frintn [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
+; VBITS_GE_512-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
+; VBITS_GE_512-NEXT: ret
+
+; Ensure sensible type legalisation.
+; VBITS_EQ_256-DAG: ptrue [[PG:p[0-9]+]].h, vl16
+; VBITS_EQ_256-DAG: add x[[A_HI:[0-9]+]], x0, #32
+; VBITS_EQ_256-DAG: ld1h { [[OP_LO:z[0-9]+]].h }, [[PG]]/z, [x0]
+; VBITS_EQ_256-DAG: ld1h { [[OP_HI:z[0-9]+]].h }, [[PG]]/z, [x[[A_HI]]]
+; VBITS_EQ_256-DAG: frintn [[RES_LO:z[0-9]+]].h, [[PG]]/m, [[OP_LO]].h
+; VBITS_EQ_256-DAG: frintn [[RES_HI:z[0-9]+]].h, [[PG]]/m, [[OP_HI]].h
+; VBITS_EQ_256-DAG: st1h { [[RES_LO]].h }, [[PG]], [x0]
+; VBITS_EQ_256-DAG: st1h { [[RES_HI]].h }, [[PG]], [x[[A_HI]]
+; VBITS_EQ_256-NEXT: ret
+  %op = load <32 x half>, <32 x half>* %a
+  %res = call <32 x half> @llvm.roundeven.v32f16(<32 x half> %op)
+  store <32 x half> %res, <32 x half>* %a
+  ret void
+}
+
+define void @frintn_v64f16(<64 x half>* %a) #0 {
+; CHECK-LABEL: frintn_v64f16:
+; VBITS_GE_1024: ptrue [[PG:p[0-9]+]].h, vl64
+; VBITS_GE_1024-DAG: ld1h { [[OP:z[0-9]+]].h }, [[PG]]/z, [x0]
+; VBITS_GE_1024-NEXT: frintn [[RES:z[0-9]+]].h, [[PG]]/m, [[OP]].h
+; VBITS_GE_1024-NEXT: st1h { [[RES]].h }, [[PG]], [x0]
+; VBITS_GE_1024-NEXT: ret
+  %op = load <64 x half>, <64 x half>* %a
+  %res 

[PATCH] D98416: [clang-tidy] Fix cppcoreguidelines-narrowing-conversions false positive

2021-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.
Herald added a project: clang-tools-extra.

> However this has opened a can of worms. Currenty float a = 
> std::numeric_limits::infinity(); is marked as narrowing.

I think this is technically not narrowing, per 
http://eel.is/c++draft/dcl.init.list#7.2, because the source is a constant 
expression (at least, after C++11) and the value can be represented after 
conversion. However, I wonder if the same is true for the various NaNs as it is 
for infinity?

> Whats more suspicious is double a = std::numeric_limits::infinity(); 
> is also marked as narrowing.

This is definitely not narrowing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98416

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


[clang] 6badd3c - [ASTMatchers] Fix documentation for hasAnyBody matcher

2021-03-15 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-15T13:06:49Z
New Revision: 6badd3c52dc8a9c0a253a48722c569bfea4f

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

LOG: [ASTMatchers] Fix documentation for hasAnyBody matcher

Looks like a oversight when the matcher was added.

Reviewed By: steveire

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

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 0becf5ebfb8c..0d2570bcd58f 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -7509,7 +7509,7 @@ AST Traversal Matchers
   void f();
   void f() {}
   void g();
-hasAnyBody(functionDecl())
+functionDecl(hasAnyBody(compoundStmt()))
   matches both 'void f();'
   and 'void f() {}'
 with compoundStmt()

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 885bc74ad3ea..64e8cecf4822 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -5217,7 +5217,7 @@ AST_POLYMORPHIC_MATCHER_P(hasBody,
 ///   void f() {}
 ///   void g();
 /// \endcode
-/// hasAnyBody(functionDecl())
+/// functionDecl(hasAnyBody(compoundStmt()))
 ///   matches both 'void f();'
 ///   and 'void f() {}'
 /// with compoundStmt()



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


[PATCH] D98583: [ASTMatchers] Fix documentation for hasAnyBody matcher

2021-03-15 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6badd3c52dc8: [ASTMatchers] Fix documentation for hasAnyBody 
matcher (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98583

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


Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -5217,7 +5217,7 @@
 ///   void f() {}
 ///   void g();
 /// \endcode
-/// hasAnyBody(functionDecl())
+/// functionDecl(hasAnyBody(compoundStmt()))
 ///   matches both 'void f();'
 ///   and 'void f() {}'
 /// with compoundStmt()
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -7509,7 +7509,7 @@
   void f();
   void f() {}
   void g();
-hasAnyBody(functionDecl())
+functionDecl(hasAnyBody(compoundStmt()))
   matches both 'void f();'
   and 'void f() {}'
 with compoundStmt()


Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -5217,7 +5217,7 @@
 ///   void f() {}
 ///   void g();
 /// \endcode
-/// hasAnyBody(functionDecl())
+/// functionDecl(hasAnyBody(compoundStmt()))
 ///   matches both 'void f();'
 ///   and 'void f() {}'
 /// with compoundStmt()
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -7509,7 +7509,7 @@
   void f();
   void f() {}
   void g();
-hasAnyBody(functionDecl())
+functionDecl(hasAnyBody(compoundStmt()))
   matches both 'void f();'
   and 'void f() {}'
 with compoundStmt()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ff91206 - [ASTMatchers][Dynamic] Add missing matchers from Registry

2021-03-15 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-15T13:07:39Z
New Revision: ff9120636e9c890b4db735d252d16b92091dde55

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

LOG: [ASTMatchers][Dynamic] Add missing matchers from Registry

Add the `fixedPointLiteral`, `hasAnyBody` and `templateArgumentLoc` to the 
dynamic matcher registry.

Reviewed By: steveire

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

Added: 


Modified: 
clang/lib/ASTMatchers/Dynamic/Registry.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 4300eb8d8b98..bfc46b7742d6 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -229,6 +229,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(expr);
   REGISTER_MATCHER(exprWithCleanups);
   REGISTER_MATCHER(fieldDecl);
+  REGISTER_MATCHER(fixedPointLiteral);
   REGISTER_MATCHER(floatLiteral);
   REGISTER_MATCHER(forDecomposition);
   REGISTER_MATCHER(forEach);
@@ -254,6 +255,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(hasAnyArgument);
   REGISTER_MATCHER(hasAnyBase);
   REGISTER_MATCHER(hasAnyBinding);
+  REGISTER_MATCHER(hasAnyBody);
   REGISTER_MATCHER(hasAnyClause);
   REGISTER_MATCHER(hasAnyConstructorInitializer);
   REGISTER_MATCHER(hasAnyDeclaration);
@@ -526,6 +528,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(tagType);
   REGISTER_MATCHER(templateArgument);
   REGISTER_MATCHER(templateArgumentCountIs);
+  REGISTER_MATCHER(templateArgumentLoc);
   REGISTER_MATCHER(templateName);
   REGISTER_MATCHER(templateSpecializationType);
   REGISTER_MATCHER(templateTemplateParmDecl);



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


[PATCH] D98556: [ASTMatchers][Dynamic] Add missing matchers from Registry

2021-03-15 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGff9120636e9c: [ASTMatchers][Dynamic] Add missing matchers 
from Registry (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98556

Files:
  clang/lib/ASTMatchers/Dynamic/Registry.cpp


Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -229,6 +229,7 @@
   REGISTER_MATCHER(expr);
   REGISTER_MATCHER(exprWithCleanups);
   REGISTER_MATCHER(fieldDecl);
+  REGISTER_MATCHER(fixedPointLiteral);
   REGISTER_MATCHER(floatLiteral);
   REGISTER_MATCHER(forDecomposition);
   REGISTER_MATCHER(forEach);
@@ -254,6 +255,7 @@
   REGISTER_MATCHER(hasAnyArgument);
   REGISTER_MATCHER(hasAnyBase);
   REGISTER_MATCHER(hasAnyBinding);
+  REGISTER_MATCHER(hasAnyBody);
   REGISTER_MATCHER(hasAnyClause);
   REGISTER_MATCHER(hasAnyConstructorInitializer);
   REGISTER_MATCHER(hasAnyDeclaration);
@@ -526,6 +528,7 @@
   REGISTER_MATCHER(tagType);
   REGISTER_MATCHER(templateArgument);
   REGISTER_MATCHER(templateArgumentCountIs);
+  REGISTER_MATCHER(templateArgumentLoc);
   REGISTER_MATCHER(templateName);
   REGISTER_MATCHER(templateSpecializationType);
   REGISTER_MATCHER(templateTemplateParmDecl);


Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -229,6 +229,7 @@
   REGISTER_MATCHER(expr);
   REGISTER_MATCHER(exprWithCleanups);
   REGISTER_MATCHER(fieldDecl);
+  REGISTER_MATCHER(fixedPointLiteral);
   REGISTER_MATCHER(floatLiteral);
   REGISTER_MATCHER(forDecomposition);
   REGISTER_MATCHER(forEach);
@@ -254,6 +255,7 @@
   REGISTER_MATCHER(hasAnyArgument);
   REGISTER_MATCHER(hasAnyBase);
   REGISTER_MATCHER(hasAnyBinding);
+  REGISTER_MATCHER(hasAnyBody);
   REGISTER_MATCHER(hasAnyClause);
   REGISTER_MATCHER(hasAnyConstructorInitializer);
   REGISTER_MATCHER(hasAnyDeclaration);
@@ -526,6 +528,7 @@
   REGISTER_MATCHER(tagType);
   REGISTER_MATCHER(templateArgument);
   REGISTER_MATCHER(templateArgumentCountIs);
+  REGISTER_MATCHER(templateArgumentLoc);
   REGISTER_MATCHER(templateName);
   REGISTER_MATCHER(templateSpecializationType);
   REGISTER_MATCHER(templateTemplateParmDecl);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98030: [IR] Add vscale_range IR function attribute

2021-03-15 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added inline comments.



Comment at: clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c:10-14
+// CHECK-128: attributes #0 = { {{.*}} vscale_range(1,1) {{.*}} }
+// CHECK-256: attributes #0 = { {{.*}} vscale_range(2,2) {{.*}} }
+// CHECK-512: attributes #0 = { {{.*}} vscale_range(4,4) {{.*}} }
+// CHECK-1024: attributes #0 = { {{.*}} vscale_range(8,8) {{.*}} }
+// CHECK-2048: attributes #0 = { {{.*}} vscale_range(16,16) {{.*}} }

I'm happy with this but for information you could use the same trick as for the 
`llvm/test/Analysis/CostModel/AArch64/sve-fixed-length.ll` so that only a 
single CHECK, and CHECK-NOT line is required.



Comment at: llvm/include/llvm/IR/Attributes.h:944
 
+  /// Add an vscale_range attribute, using the representation returned by
+  /// Attribute.getIntValue().

a



Comment at: llvm/test/Verifier/vscale_range.ll:3-4
+
+; CHECK-NOT: 'vscale_range' minimum cannot be greater than maximum
+declare i8* @a(i32) vscale_range(1, 0)
+

I think attributes.ll is a better place for this test, along with a CHECK for 
it's expected output.

Kind of related, what is expected for `vscale_range(0,0)` and does that need a 
test (positive or negative)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98030

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


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-15 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Thanks, nice one, LGTM.




Comment at: llvm/test/CodeGen/AArch64/rand.ll:2
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64 -mcpu=neoverse-v1 -mattr=+rand %s -o - | FileCheck 
%s
+

Nit: we don't need `-mcpu=neoverse-v1`, so just remove it?


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

https://reviews.llvm.org/D98264

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


[PATCH] D98616: [RISCV] Add inline asm constraint 'v' in Clang for RISC-V 'V'.

2021-03-15 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

GCC use `vr` for vector register and `vm` for vector mask register.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98616

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


[PATCH] D98616: [RISCV] Add inline asm constraint 'v' in Clang for RISC-V 'V'.

2021-03-15 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D98616#2626093 , @kito-cheng wrote:

> GCC use `vr` for vector register and `vm` for vector mask register.

How does that even work? Aren't multi character strings a set of options?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98616

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


[PATCH] D98487: [AArch64][SVE/NEON] Add support for FROUNDEVEN for both NEON and fixed length SVE

2021-03-15 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Thanks. This looks sensible, from what I can tell.




Comment at: llvm/include/llvm/Target/TargetSelectionDAG.td:158
 ]>;
+def SDTFPRoundEvenOp  : SDTypeProfile<1, 1, [   // froundeven
+  SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<0, 1>, 
SDTCisSameNumEltsAs<0, 1>

Is this used? The one above should maybe say `// fpround`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98487

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


[PATCH] D98616: [RISCV] Add inline asm constraint 'v' in Clang for RISC-V 'V'.

2021-03-15 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D98616#2626094 , @jrtc27 wrote:

> In D98616#2626093 , @kito-cheng 
> wrote:
>
>> GCC use `vr` for vector register and `vm` for vector mask register.
>
> How does that even work? Aren't multi character strings a set of options?

Hm, apparently multi-character constraints already exist. Not a fan of it as it 
parses like "vector or register/memory" to me but if that's how GCC needs to 
internally model its instructions then we have to copy that...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98616

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


[PATCH] D94950: [clang][lex] Speculative fix for buffer overrun on raw string parse

2021-03-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1639
   const char *Prefix = ThisTokBuf;
-  while (ThisTokBuf[0] != '(')
+  while (ThisTokBuf - Prefix < 16 && ThisTokBuf[0] != '(')
 ++ThisTokBuf;

beccadax wrote:
> Nit: "16" is a magic number; it might be better to use a constant or comment 
> to document its significance (raw strings can only have 16-character 
> delimiters).
> 
> (I believe this is C++11 [lex.string]p2, but I've never written one of the 
> citation comments you see in clang, so I'm not sure if you should cite a 
> later standard.)
Good point on the magic number, I'm going to extract that.

I'll check how the citations are written and add one here.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1647
   ThisTokEnd -= ThisTokBuf - Prefix;
   assert(ThisTokEnd >= ThisTokBuf && "malformed raw string literal");
 

beccadax wrote:
> In your shoes, I would also have promoted this to a real check, but if you 
> think that's overkill I'm fine with leaving it as it is.
I think that's sensible, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94950

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


[PATCH] D94950: [clang][lex] Speculative fix for buffer overrun on raw string parse

2021-03-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 330647.
jansvoboda11 added a comment.

Implement suggested improvements


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94950

Files:
  clang/lib/Lex/LiteralSupport.cpp


Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -1628,16 +1628,28 @@
 
 // Check for raw string
 if (ThisTokBuf[0] == 'R') {
+  if (ThisTokBuf[1] != '"') {
+// The file may have come from PCH and then changed after loading the
+// PCH; Fail gracefully.
+return DiagnoseLexingError(StringToks[i].getLocation());
+  }
   ThisTokBuf += 2; // skip R"
 
+  // C++11 [lex.string]p2: A `d-char-sequence` shall consist of at most 16
+  // characters.
+  constexpr unsigned RawStrDelimiterLen = 16;
+
   const char *Prefix = ThisTokBuf;
-  while (ThisTokBuf[0] != '(')
+  while (ThisTokBuf - Prefix < RawStrDelimiterLen && ThisTokBuf[0] != '(')
 ++ThisTokBuf;
+  if (ThisTokBuf[0] != '(')
+return DiagnoseLexingError(StringToks[i].getLocation());
   ++ThisTokBuf; // skip '('
 
   // Remove same number of characters from the end
   ThisTokEnd -= ThisTokBuf - Prefix;
-  assert(ThisTokEnd >= ThisTokBuf && "malformed raw string literal");
+  if (ThisTokEnd < ThisTokBuf)
+return DiagnoseLexingError(StringToks[i].getLocation());
 
   // C++14 [lex.string]p4: A source-file new-line in a raw string literal
   // results in a new-line in the resulting execution string-literal.


Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -1628,16 +1628,28 @@
 
 // Check for raw string
 if (ThisTokBuf[0] == 'R') {
+  if (ThisTokBuf[1] != '"') {
+// The file may have come from PCH and then changed after loading the
+// PCH; Fail gracefully.
+return DiagnoseLexingError(StringToks[i].getLocation());
+  }
   ThisTokBuf += 2; // skip R"
 
+  // C++11 [lex.string]p2: A `d-char-sequence` shall consist of at most 16
+  // characters.
+  constexpr unsigned RawStrDelimiterLen = 16;
+
   const char *Prefix = ThisTokBuf;
-  while (ThisTokBuf[0] != '(')
+  while (ThisTokBuf - Prefix < RawStrDelimiterLen && ThisTokBuf[0] != '(')
 ++ThisTokBuf;
+  if (ThisTokBuf[0] != '(')
+return DiagnoseLexingError(StringToks[i].getLocation());
   ++ThisTokBuf; // skip '('
 
   // Remove same number of characters from the end
   ThisTokEnd -= ThisTokBuf - Prefix;
-  assert(ThisTokEnd >= ThisTokBuf && "malformed raw string literal");
+  if (ThisTokEnd < ThisTokBuf)
+return DiagnoseLexingError(StringToks[i].getLocation());
 
   // C++14 [lex.string]p4: A source-file new-line in a raw string literal
   // results in a new-line in the resulting execution string-literal.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D94950: [clang][lex] Speculative fix for buffer overrun on raw string parse

2021-03-15 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 rG23cc8ebf59c6: [clang][lex] Speculative fix for buffer 
overrun on raw string parse (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D94950?vs=330647&id=330650#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94950

Files:
  clang/lib/Lex/LiteralSupport.cpp


Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -1628,16 +1628,28 @@
 
 // Check for raw string
 if (ThisTokBuf[0] == 'R') {
+  if (ThisTokBuf[1] != '"') {
+// The file may have come from PCH and then changed after loading the
+// PCH; Fail gracefully.
+return DiagnoseLexingError(StringToks[i].getLocation());
+  }
   ThisTokBuf += 2; // skip R"
 
+  // C++11 [lex.string]p2: A `d-char-sequence` shall consist of at most 16
+  // characters.
+  constexpr unsigned MaxRawStrDelimLen = 16;
+
   const char *Prefix = ThisTokBuf;
-  while (ThisTokBuf[0] != '(')
+  while (ThisTokBuf - Prefix < MaxRawStrDelimLen && ThisTokBuf[0] != '(')
 ++ThisTokBuf;
+  if (ThisTokBuf[0] != '(')
+return DiagnoseLexingError(StringToks[i].getLocation());
   ++ThisTokBuf; // skip '('
 
   // Remove same number of characters from the end
   ThisTokEnd -= ThisTokBuf - Prefix;
-  assert(ThisTokEnd >= ThisTokBuf && "malformed raw string literal");
+  if (ThisTokEnd < ThisTokBuf)
+return DiagnoseLexingError(StringToks[i].getLocation());
 
   // C++14 [lex.string]p4: A source-file new-line in a raw string literal
   // results in a new-line in the resulting execution string-literal.


Index: clang/lib/Lex/LiteralSupport.cpp
===
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -1628,16 +1628,28 @@
 
 // Check for raw string
 if (ThisTokBuf[0] == 'R') {
+  if (ThisTokBuf[1] != '"') {
+// The file may have come from PCH and then changed after loading the
+// PCH; Fail gracefully.
+return DiagnoseLexingError(StringToks[i].getLocation());
+  }
   ThisTokBuf += 2; // skip R"
 
+  // C++11 [lex.string]p2: A `d-char-sequence` shall consist of at most 16
+  // characters.
+  constexpr unsigned MaxRawStrDelimLen = 16;
+
   const char *Prefix = ThisTokBuf;
-  while (ThisTokBuf[0] != '(')
+  while (ThisTokBuf - Prefix < MaxRawStrDelimLen && ThisTokBuf[0] != '(')
 ++ThisTokBuf;
+  if (ThisTokBuf[0] != '(')
+return DiagnoseLexingError(StringToks[i].getLocation());
   ++ThisTokBuf; // skip '('
 
   // Remove same number of characters from the end
   ThisTokEnd -= ThisTokBuf - Prefix;
-  assert(ThisTokEnd >= ThisTokBuf && "malformed raw string literal");
+  if (ThisTokEnd < ThisTokBuf)
+return DiagnoseLexingError(StringToks[i].getLocation());
 
   // C++14 [lex.string]p4: A source-file new-line in a raw string literal
   // results in a new-line in the resulting execution string-literal.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 23cc8eb - [clang][lex] Speculative fix for buffer overrun on raw string parse

2021-03-15 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-03-15T15:13:47+01:00
New Revision: 23cc8ebf59c661ebb988370a0edbcda37b61080a

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

LOG: [clang][lex] Speculative fix for buffer overrun on raw string parse

This attempts to fix a (non-deterministic) buffer overrun when parsing raw 
string literals during modular build.

Similar fix to 4e5b5c36f47c9a406ea7f6b4f89fae477693973a.

Reviewed By: beccadax

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

Added: 


Modified: 
clang/lib/Lex/LiteralSupport.cpp

Removed: 




diff  --git a/clang/lib/Lex/LiteralSupport.cpp 
b/clang/lib/Lex/LiteralSupport.cpp
index 6c3cdbdf6492..df98516ee61d 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -1628,16 +1628,28 @@ void StringLiteralParser::init(ArrayRef 
StringToks){
 
 // Check for raw string
 if (ThisTokBuf[0] == 'R') {
+  if (ThisTokBuf[1] != '"') {
+// The file may have come from PCH and then changed after loading the
+// PCH; Fail gracefully.
+return DiagnoseLexingError(StringToks[i].getLocation());
+  }
   ThisTokBuf += 2; // skip R"
 
+  // C++11 [lex.string]p2: A `d-char-sequence` shall consist of at most 16
+  // characters.
+  constexpr unsigned MaxRawStrDelimLen = 16;
+
   const char *Prefix = ThisTokBuf;
-  while (ThisTokBuf[0] != '(')
+  while (ThisTokBuf - Prefix < MaxRawStrDelimLen && ThisTokBuf[0] != '(')
 ++ThisTokBuf;
+  if (ThisTokBuf[0] != '(')
+return DiagnoseLexingError(StringToks[i].getLocation());
   ++ThisTokBuf; // skip '('
 
   // Remove same number of characters from the end
   ThisTokEnd -= ThisTokBuf - Prefix;
-  assert(ThisTokEnd >= ThisTokBuf && "malformed raw string literal");
+  if (ThisTokEnd < ThisTokBuf)
+return DiagnoseLexingError(StringToks[i].getLocation());
 
   // C++14 [lex.string]p4: A source-file new-line in a raw string literal
   // results in a new-line in the resulting execution string-literal.



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


[clang] 74c270f - [ASTMatchers] Don't forward matchers in MapAnyOf

2021-03-15 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-15T14:16:52Z
New Revision: 74c270f33eb16d336b4ab834e18b27f8efcbabe8

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

LOG: [ASTMatchers] Don't forward matchers in MapAnyOf

Forwarding these means that if an r-value reference is passed, the matcher will 
be moved. However it appears this happens for each mapped node matcher, 
resulting in use-after-move issues.

Reviewed By: steveire

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

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchersInternal.h

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 19b8941746dd..53b37b338a55 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1386,8 +1386,7 @@ struct MapAnyOfMatcherImpl {
 internal::DynTypedMatcher::VO_AnyOf},
 applyMatcher(
 [&](auto... Matcher) {
-  return std::make_tuple(Matcher(
-  std::forward(InnerMatcher)...)...);
+  return std::make_tuple(Matcher(InnerMatcher...)...);
 },
 std::tuple<
 VariadicDynCastAllOfMatcher...>(;



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


[PATCH] D98497: [ASTMatchers] Don't forward matchers in MapAnyOf

2021-03-15 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG74c270f33eb1: [ASTMatchers] Don't forward matchers in 
MapAnyOf (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98497

Files:
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h


Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1386,8 +1386,7 @@
 internal::DynTypedMatcher::VO_AnyOf},
 applyMatcher(
 [&](auto... Matcher) {
-  return std::make_tuple(Matcher(
-  std::forward(InnerMatcher)...)...);
+  return std::make_tuple(Matcher(InnerMatcher...)...);
 },
 std::tuple<
 VariadicDynCastAllOfMatcher...>(;


Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1386,8 +1386,7 @@
 internal::DynTypedMatcher::VO_AnyOf},
 applyMatcher(
 [&](auto... Matcher) {
-  return std::make_tuple(Matcher(
-  std::forward(InnerMatcher)...)...);
+  return std::make_tuple(Matcher(InnerMatcher...)...);
 },
 std::tuple<
 VariadicDynCastAllOfMatcher...>(;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 0333dde - [clang-tidy] Fix readability-identifer-naming duplicating prefix or suffix for replacements.

2021-03-15 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-15T14:20:48Z
New Revision: 0333dde923c42219863f314d6c9fc0dcd352ef02

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

LOG: [clang-tidy] Fix readability-identifer-naming duplicating prefix or suffix 
for replacements.

If a identifier has a correct prefix/suffix but a bad case, the fix won't strip 
them when computing the correct case, leading to duplication when the are added 
back.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 09b3cc25678c..12853fa14823 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -407,6 +407,8 @@ static bool isParamInMainLikeFunction(const ParmVarDecl 
&ParmDecl,
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
+  Name.consume_front(Style.Prefix);
+  Name.consume_back(Style.Suffix);
   const std::string Fixed = fixupWithCase(
   Name, 
Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
   StringRef Mid = StringRef(Fixed).trim("_");

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
index f66202ecd11b..11ffc6c16615 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -148,6 +148,10 @@ int global3;
 int g_twice_global3 = ADD_TO_SELF(global3);
 // CHECK-FIXES: {{^}}int g_twice_global3 = ADD_TO_SELF(g_global3);{{$}}
 
+int g_Global4;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global 
variable 'g_Global4'
+// CHECK-FIXES: {{^}}int g_global4;{{$}}
+
 enum my_enumeration {
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for enum 
'my_enumeration'
 // CHECK-FIXES: {{^}}enum EMyEnumeration {{{$}}
@@ -544,6 +548,9 @@ unsigned const MyConstGlobal_array[] = {1,2,3};
 // CHECK-FIXES: {{^}}unsigned const MY_CONST_GLOBAL_ARRAY[] = {1,2,3};{{$}}
 
 int * MyGlobal_Ptr;// -> ok
+int * my_second_global_Ptr;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global 
pointer 'my_second_global_Ptr'
+// CHECK-FIXES: {{^}}int * MySecondGlobal_Ptr;{{$}}
 int * const MyConstantGlobalPointer = nullptr;
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global 
constant pointer 'MyConstantGlobalPointer'
 // CHECK-FIXES: {{^}}int * const MY_CONSTANT_GLOBAL_POINTER_Ptr = nullptr;{{$}}



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


[PATCH] D98521: [clang-tidy] Fix readability-identifer-naming duplicating prefix or suffix for replacements.

2021-03-15 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0333dde923c4: [clang-tidy] Fix readability-identifer-naming 
duplicating prefix or suffix for… (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98521

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -148,6 +148,10 @@
 int g_twice_global3 = ADD_TO_SELF(global3);
 // CHECK-FIXES: {{^}}int g_twice_global3 = ADD_TO_SELF(g_global3);{{$}}
 
+int g_Global4;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global 
variable 'g_Global4'
+// CHECK-FIXES: {{^}}int g_global4;{{$}}
+
 enum my_enumeration {
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for enum 
'my_enumeration'
 // CHECK-FIXES: {{^}}enum EMyEnumeration {{{$}}
@@ -544,6 +548,9 @@
 // CHECK-FIXES: {{^}}unsigned const MY_CONST_GLOBAL_ARRAY[] = {1,2,3};{{$}}
 
 int * MyGlobal_Ptr;// -> ok
+int * my_second_global_Ptr;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global 
pointer 'my_second_global_Ptr'
+// CHECK-FIXES: {{^}}int * MySecondGlobal_Ptr;{{$}}
 int * const MyConstantGlobalPointer = nullptr;
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global 
constant pointer 'MyConstantGlobalPointer'
 // CHECK-FIXES: {{^}}int * const MY_CONSTANT_GLOBAL_POINTER_Ptr = nullptr;{{$}}
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -407,6 +407,8 @@
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
+  Name.consume_front(Style.Prefix);
+  Name.consume_back(Style.Suffix);
   const std::string Fixed = fixupWithCase(
   Name, 
Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
   StringRef Mid = StringRef(Fixed).trim("_");


Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -148,6 +148,10 @@
 int g_twice_global3 = ADD_TO_SELF(global3);
 // CHECK-FIXES: {{^}}int g_twice_global3 = ADD_TO_SELF(g_global3);{{$}}
 
+int g_Global4;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for global variable 'g_Global4'
+// CHECK-FIXES: {{^}}int g_global4;{{$}}
+
 enum my_enumeration {
 // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for enum 'my_enumeration'
 // CHECK-FIXES: {{^}}enum EMyEnumeration {{{$}}
@@ -544,6 +548,9 @@
 // CHECK-FIXES: {{^}}unsigned const MY_CONST_GLOBAL_ARRAY[] = {1,2,3};{{$}}
 
 int * MyGlobal_Ptr;// -> ok
+int * my_second_global_Ptr;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for global pointer 'my_second_global_Ptr'
+// CHECK-FIXES: {{^}}int * MySecondGlobal_Ptr;{{$}}
 int * const MyConstantGlobalPointer = nullptr;
 // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for global constant pointer 'MyConstantGlobalPointer'
 // CHECK-FIXES: {{^}}int * const MY_CONSTANT_GLOBAL_POINTER_Ptr = nullptr;{{$}}
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -407,6 +407,8 @@
 static std::string
 fixupWithStyle(StringRef Name,
const IdentifierNamingCheck::NamingStyle &Style) {
+  Name.consume_front(Style.Prefix);
+  Name.consume_back(Style.Suffix);
   const std::string Fixed = fixupWithCase(
   Name, Style.Case.getValueOr(IdentifierNamingCheck::CaseType::CT_AnyCase));
   StringRef Mid = StringRef(Fixed).trim("_");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] da55af7 - [clang-tidy] Enable modernize-concat-nested-namespaces also on headers

2021-03-15 Thread Dmitry Polukhin via cfe-commits

Author: Dmitry Polukhin
Date: 2021-03-15T07:32:45-07:00
New Revision: da55af7f1d348c133774d8e8117d60462363fef5

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

LOG: [clang-tidy] Enable modernize-concat-nested-namespaces also on headers

For some reason the initial implementation of the check had an explicit check
for the main file to avoid being applied in headers. This diff removes this
check and add a test for the check on a header.

Similar approach was proposed in D61989 but review there got stuck.

Test Plan: added new test case

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h

Modified: 
clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
index 83c3fac949ba..e55b260060ce 100644
--- a/clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
@@ -82,9 +82,6 @@ void ConcatNestedNamespacesCheck::check(
   if (!locationsInSameFile(Sources, ND.getBeginLoc(), ND.getRBraceLoc()))
 return;
 
-  if (!Sources.isInMainFile(ND.getBeginLoc()))
-return;
-
   if (anonymousOrInlineNamespace(ND))
 return;
 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
new file mode 100644
index ..752b33718dca
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
@@ -0,0 +1,8 @@
+namespace nn1 {
+namespace nn2 {
+// CHECK-FIXES: namespace nn1::nn2
+void t();
+} // namespace nn2
+} // namespace nn1
+// CHECK-FIXES: void t();
+// CHECK-FIXES-NEXT: } // namespace nn1

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
index dcde32d0f069..7c13c1c61cf2 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
@@ -1,4 +1,13 @@
-// RUN: %check_clang_tidy -std=c++17-or-later %s 
modernize-concat-nested-namespaces %t
+// RUN: cp 
%S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
 %T/modernize-concat-nested-namespaces.h
+// RUN: %check_clang_tidy -std=c++17 %s modernize-concat-nested-namespaces %t 
-- -header-filter=".*" -- -I %T
+// RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h 
%S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
 -check-prefix=CHECK-FIXES
+// Restore header file and re-run with c++20:
+// RUN: cp 
%S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
 %T/modernize-concat-nested-namespaces.h
+// RUN: %check_clang_tidy -std=c++20 %s modernize-concat-nested-namespaces %t 
-- -header-filter=".*" -- -I %T
+// RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h 
%S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
 -check-prefix=CHECK-FIXES
+
+#include "modernize-concat-nested-namespaces.h"
+// CHECK-MESSAGES-DAG: modernize-concat-nested-namespaces.h:1:1: warning: 
nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 
 namespace n1 {}
 
@@ -27,7 +36,7 @@ void t();
 
 namespace n9 {
 namespace n10 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be 
concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be 
concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n9::n10
 void t();
 } // namespace n10
@@ -36,7 +45,7 @@ void t();
 
 namespace n11 {
 namespace n12 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be 
concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be 
concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n11::n12
 namespace n13 {
 void t();
@@ -60,7 +69,7 @@ void t();
 namespace n18 {
 namespace n19 {
 namespace n20 {
-// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: nested namespaces can be 
concatenated [modernize-concat-

[PATCH] D97563: [clang-tidy] Enable modernize-concat-nested-namespaces also on headers

2021-03-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGda55af7f1d34: [clang-tidy] Enable 
modernize-concat-nested-namespaces also on headers (authored by DmitryPolukhin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97563

Files:
  clang-tools-extra/clang-tidy/modernize/ConcatNestedNamespacesCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h
  
clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-concat-nested-namespaces.cpp
@@ -1,4 +1,13 @@
-// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-concat-nested-namespaces %t
+// RUN: cp %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
+// RUN: %check_clang_tidy -std=c++17 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
+// Restore header file and re-run with c++20:
+// RUN: cp %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h %T/modernize-concat-nested-namespaces.h
+// RUN: %check_clang_tidy -std=c++20 %s modernize-concat-nested-namespaces %t -- -header-filter=".*" -- -I %T
+// RUN: FileCheck -input-file=%T/modernize-concat-nested-namespaces.h %S/Inputs/modernize-concat-nested-namespaces/modernize-concat-nested-namespaces.h -check-prefix=CHECK-FIXES
+
+#include "modernize-concat-nested-namespaces.h"
+// CHECK-MESSAGES-DAG: modernize-concat-nested-namespaces.h:1:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 
 namespace n1 {}
 
@@ -27,7 +36,7 @@
 
 namespace n9 {
 namespace n10 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n9::n10
 void t();
 } // namespace n10
@@ -36,7 +45,7 @@
 
 namespace n11 {
 namespace n12 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n11::n12
 namespace n13 {
 void t();
@@ -60,7 +69,7 @@
 namespace n18 {
 namespace n19 {
 namespace n20 {
-// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n18::n19::n20
 void t();
 } // namespace n20
@@ -83,7 +92,7 @@
 namespace {
 namespace n24 {
 namespace n25 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n24::n25
 void t();
 } // namespace n25
@@ -95,7 +104,7 @@
 namespace n26::n27 {
 namespace n28 {
 namespace n29::n30 {
-// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 // CHECK-FIXES: namespace n26::n27::n28::n29::n30
 void t() {}
 } // namespace n29::n30
@@ -105,14 +114,14 @@
 
 namespace n31 {
 namespace n32 {}
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 } // namespace n31
 // CHECK-FIXES-EMPTY
 
 namespace n33 {
 namespace n34 {
 namespace n35 {}
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES-DAG: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
 } // namespace n34
 // CHECK-FIXES-EMPTY
 namespace n36 {
@@ -127,7 +136,7 @@
 #define IEXIST
 namespace n39 {
 namespace n40 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
+// CHECK-MESSAGES

[PATCH] D98616: [RISCV] Add inline asm constraint 'v' in Clang for RISC-V 'V'.

2021-03-15 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

Provide more implementation detail on GCC,

- if a letter are used as a prefix of multi-char constraint, then it can't be 
used as a single letter constraint
  - e.g. If we defined `vr` and `vm` then we can't define `v` as constraint
- constraint with same prefix should have same length
  - e.g. If we defined `vr` and `vm` then we can't define `vrr` since has 
different length.

And in fact we have defined bunch of predicate prefixed with `v`[1], but I am 
open mind to change if needed that since GCC didn't upstream that yet.

[1] 
https://github.com/riscv/riscv-gcc/blob/riscv-gcc-10.1-rvv-dev/gcc/config/riscv/constraints.md#L117


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98616

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


[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-15 Thread Ally Tiritoglu via Phabricator via cfe-commits
atirit added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3683
+Style.BraceWrapping.AfterEnum;
+bool isLineTooBig = (strlen(Right.TokenText.data()) +
+ Right.OriginalColumn) > Style.ColumnLimit;

curdeius wrote:
> strlen? Please use `StringRef::size()`.
For `FormatToken.TokenText`, `StringRef::size()` is set to the length of the 
token, not of the stored text. Please see 
`clang/lib/Format/FormatTokenLexer.cpp:1047`. Changing that line breaks nearly 
every format test so I'm assuming that it is correct. A `strlen` or equivalent 
is necessary here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

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


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-15 Thread Stelios Ioannou via Phabricator via cfe-commits
stelios-arm updated this revision to Diff 330670.
stelios-arm added a comment.

Change the  `rand.ll` llc arguments to the ones that are only relevant.


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

https://reviews.llvm.org/D98264

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/builtins-arm64.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/rand.ll
  llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir

Index: llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
===
--- llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
+++ llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
@@ -100,11 +100,11 @@
   bb.0:
 liveins: $x0
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 renamable $x8 = MOVZXi 15309, 0
 renamable $x8 = MOVKXi renamable $x8, 26239, 16
 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store 8)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRXui killed renamable  $x8, renamable killed $x0, 1, implicit killed $x8 :: (store 8)
 RET undef $lr
 
@@ -134,9 +134,9 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRXui killed renamable  $x8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
@@ -166,9 +166,9 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
@@ -275,10 +275,10 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 renamable $w8 = ORRWrs $wzr, killed renamable $w8, 0, implicit-def $x8
 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
Index: llvm/test/CodeGen/AArch64/rand.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/rand.ll
@@ -0,0 +1,40 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64 -mattr=+v8.5a,+rand %s -o - | FileCheck %s
+
+define  i32 @rndr(i64* %__addr) {
+; CHECK-LABEL: rndr:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x9, RNDR
+; CHECK-NEXT:cset w8, eq
+; CHECK-NEXT:and w8, w8, #0x1
+; CHECK-NEXT:str x9, [x0]
+; CHECK-NEXT:mov w0, w8
+; CHECK-NEXT:ret
+  %1 = tail call { i64, i1 } @llvm.aarch64.rndr()
+  %2 = extractvalue { i64, i1 } %1, 0
+  %3 = extractvalue { i64, i1 } %1, 1
+  store i64 %2, i64* %__addr, align 8
+  %4 = zext i1 %3 to i32
+  ret i32 %4
+}
+
+
+define  i32 @rndrrs(i64*  %__addr) {
+; CHECK-LABEL: rndrrs:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x9, RNDRRS
+; CHECK-NEXT:cset w8, eq
+; CHECK-NEXT:and w8, w8, #0x1
+; CHECK-NEXT:str x9, [x0]
+; CHECK-NEXT:mov w0, w8
+; CHECK-NEXT:ret
+  %1 = tail call { i64, i1 } @llvm.aarch64.rndrrs()
+  %2 = extractvalue { i64, i1 } %1, 0
+  %3 = extractvalue { i64, i1 } %1, 1
+  store i64 %2, i64* %__addr, align 8
+  %4 = zext i1 %3 to i32
+  ret i32 %4
+}
+
+declare { i64, i1 } @llvm.aarch64.rndr()
+declare { i64, i1 } @llvm.aarch64.rndrrs()
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -607,7 +607,9 @@
 def AArch64stnp : SDNode<"AArch64ISD::STNP", SDT_AArch64stnp, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
 
 def AArch64tbl : SDNode<"AArch64ISD::TBL", SDT_AArch64TBL>;
-
+def AArch64mrs : SDNode<"AArch64ISD::MRS",
+SDTypeProfile<1, 1, [SDTCisVT<0, i64>, SDTCisVT<1, i32>]>,
+[SDNPHasChain, SDNPOutGlue]>;
 //===--===//
 
 //===-

[PATCH] D98404: [clangd] Optionally add reflection for clangd-index-server

2021-03-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 330675.
kbobyrev added a comment.

Add explicit CMake option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98404

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Features.inc.in
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -22,6 +22,10 @@
   add_library(protobuf ALIAS protobuf::libprotobuf)
   set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
   add_library(grpc++ ALIAS gRPC::grpc++)
+  if (ENABLE_GRPC_REFLECTION)
+set_target_properties(gRPC::grpc++_reflection PROPERTIES IMPORTED_GLOBAL TRUE)
+add_library(grpc++_reflection ALIAS gRPC::grpc++_reflection)
+  endif()
 
   set(GRPC_CPP_PLUGIN $)
   set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
@@ -71,12 +75,21 @@
   add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
   message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
   set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
+  if (ENABLE_GRPC_REFLECTION)
+find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection $GRPC_OPTS REQUIRED)
+add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
+set_target_properties(grpc++_reflection PROPERTIES IMPORTED_LOCATION ${GRPC_REFLECTION_LIBRARY})
+  endif()
   find_library(PROTOBUF_LIBRARY protobuf $PROTOBUF_OPTS REQUIRED)
   message(STATUS "Using protobuf: " ${PROTOBUF_LIBRARY})
   add_library(protobuf UNKNOWN IMPORTED GLOBAL)
   set_target_properties(protobuf PROPERTIES IMPORTED_LOCATION ${PROTOBUF_LIBRARY})
 endif()
 
+if (ENABLE_GRPC_REFLECTION)
+  set(REFLECTION_LIBRARY grpc++_reflection)
+endif()
+
 # Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.
 # Libraries that use these headers should adjust the include path.
 # If the "GRPC" argument is given, services are also generated.
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "Features.inc"
 #include "Index.pb.h"
 #include "Service.grpc.pb.h"
 #include "index/Index.h"
@@ -35,6 +36,10 @@
 #include 
 #include 
 
+#if ENABLE_GRPC_REFLECTION
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace remote {
@@ -313,6 +318,9 @@
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
+#if ENABLE_GRPC_REFLECTION
+  grpc::reflection::InitProtoReflectionServerBuilderPlugin();
+#endif
   grpc::ServerBuilder Builder;
   Builder.AddListeningPort(ServerAddress.str(),
grpc::InsecureServerCredentials());
Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -17,4 +17,6 @@
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
+
+  ${REFLECTION_LIBRARY}
   )
Index: clang-tools-extra/clangd/Features.inc.in
===
--- clang-tools-extra/clangd/Features.inc.in
+++ clang-tools-extra/clangd/Features.inc.in
@@ -1,3 +1,4 @@
 #define CLANGD_BUILD_XPC @CLANGD_BUILD_XPC@
 #define CLANGD_ENABLE_REMOTE @CLANGD_ENABLE_REMOTE@
+#define ENABLE_GRPC_REFLECTION @ENABLE_GRPC_REFLECTION@
 #define CLANGD_MALLOC_TRIM @CLANGD_MALLOC_TRIM@
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -19,6 +19,7 @@
 llvm_canonicalize_cmake_booleans(
   CLANGD_BUILD_XPC
   CLANGD_ENABLE_REMOTE
+  ENABLE_GRPC_REFLECTION
   CLANGD_MALLOC_TRIM
   LLVM_ENABLE_ZLIB
 )
@@ -186,6 +187,7 @@
 
 # FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
 option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
+option(ENABLE_GRPC_REFLECTION "Link clangd-index-server to gRPC Reflection library" OFF)
 set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
 
 add_subdirectory(index/remote)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98487: [AArch64][SVE/NEON] Add support for FROUNDEVEN for both NEON and fixed length SVE

2021-03-15 Thread Bradley Smith via Phabricator via cfe-commits
bsmith added inline comments.



Comment at: llvm/include/llvm/Target/TargetSelectionDAG.td:158
 ]>;
+def SDTFPRoundEvenOp  : SDTypeProfile<1, 1, [   // froundeven
+  SDTCisFP<0>, SDTCisFP<1>, SDTCisOpSmallerThanOp<0, 1>, 
SDTCisSameNumEltsAs<0, 1>

dmgreen wrote:
> Is this used? The one above should maybe say `// fpround`?
No it's not, I added it for consistency, but perhaps I shouldn't? I think 
fround is correct for the one above, or at least is consistent with the others 
in this file, for example fextend below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98487

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


[clang] f60b353 - Stop traping on sNaN in __builtin_isinf

2021-03-15 Thread Thomas Preud'homme via cfe-commits

Author: Thomas Preud'homme
Date: 2021-03-15T15:38:08Z
New Revision: f60b35340fd70acb3c8003349931f085305886ad

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

LOG: Stop traping on sNaN in __builtin_isinf

__builtin_isinf currently generates a floating-point compare operation
which triggers a trap when faced with a signaling NaN in StrictFP mode.
This commit uses integer operations instead to not generate any trap in
such a case.

Reviewed By: mibintc

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/X86/strictfp_builtins.c
clang/test/CodeGen/aarch64-strictfp-builtins.c
clang/test/CodeGen/builtin_float_strictfp.c
clang/test/CodeGen/strictfp_builtins.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ed43e5fd091f4..29886b57a81f9 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3078,15 +3078,38 @@ RValue CodeGenFunction::EmitBuiltinExpr(const 
GlobalDecl GD, unsigned BuiltinID,
 // isfinite(x) --> fabs(x) != infinity
 // x != NaN via the ordered compare in either case.
 CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
-// FIXME: for strictfp/IEEE-754 we need to not trap on SNaN here.
 Value *V = EmitScalarExpr(E->getArg(0));
-Value *Fabs = EmitFAbs(*this, V);
-Constant *Infinity = ConstantFP::getInfinity(V->getType());
-CmpInst::Predicate Pred = (BuiltinID == Builtin::BI__builtin_isinf)
-  ? CmpInst::FCMP_OEQ
-  : CmpInst::FCMP_ONE;
-Value *FCmp = Builder.CreateFCmp(Pred, Fabs, Infinity, "cmpinf");
-return RValue::get(Builder.CreateZExt(FCmp, ConvertType(E->getType(;
+llvm::Type *Ty = V->getType();
+if (!Builder.getIsFPConstrained() ||
+Builder.getDefaultConstrainedExcept() == fp::ebIgnore ||
+!Ty->isIEEE()) {
+  Value *Fabs = EmitFAbs(*this, V);
+  Constant *Infinity = ConstantFP::getInfinity(V->getType());
+  CmpInst::Predicate Pred = (BuiltinID == Builtin::BI__builtin_isinf)
+? CmpInst::FCMP_OEQ
+: CmpInst::FCMP_ONE;
+  Value *FCmp = Builder.CreateFCmp(Pred, Fabs, Infinity, "cmpinf");
+  return RValue::get(Builder.CreateZExt(FCmp, ConvertType(E->getType(;
+}
+
+if (Value *Result = getTargetHooks().testFPKind(V, BuiltinID, Builder, 
CGM))
+  return RValue::get(Result);
+
+// Inf values have all exp bits set and a zero significand. Therefore:
+// isinf(V) == ((V << 1) == ((exp mask) << 1))
+// isfinite(V) == ((V << 1) < ((exp mask) << 1)) using unsigned comparison
+unsigned bitsize = Ty->getScalarSizeInBits();
+llvm::IntegerType *IntTy = Builder.getIntNTy(bitsize);
+Value *IntV = Builder.CreateBitCast(V, IntTy);
+Value *Shl1 = Builder.CreateShl(IntV, 1);
+const llvm::fltSemantics &Semantics = Ty->getFltSemantics();
+APInt ExpMask = APFloat::getInf(Semantics).bitcastToAPInt();
+Value *ExpMaskShl1 = llvm::ConstantInt::get(IntTy, ExpMask.shl(1));
+if (BuiltinID == Builtin::BI__builtin_isinf)
+  V = Builder.CreateICmpEQ(Shl1, ExpMaskShl1);
+else
+  V = Builder.CreateICmpULT(Shl1, ExpMaskShl1);
+return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
   }
 
   case Builtin::BI__builtin_isinf_sign: {

diff  --git a/clang/test/CodeGen/X86/strictfp_builtins.c 
b/clang/test/CodeGen/X86/strictfp_builtins.c
index d7eda34fb45ef..c3c94164e04f9 100644
--- a/clang/test/CodeGen/X86/strictfp_builtins.c
+++ b/clang/test/CodeGen/X86/strictfp_builtins.c
@@ -26,6 +26,42 @@ void p(char *str, int x) {
 
 #define P(n,args) p(#n #args, __builtin_##n args)
 
+// CHECK-LABEL: @test_long_double_isinf(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca x86_fp80, align 16
+// CHECK-NEXT:store x86_fp80 [[D:%.*]], x86_fp80* [[LD_ADDR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load x86_fp80, x86_fp80* [[LD_ADDR]], align 16
+// CHECK-NEXT:[[BITCAST:%.*]] = bitcast x86_fp80 [[TMP0]] to i80
+// CHECK-NEXT:[[SHL1:%.*]] = shl i80 [[BITCAST]], 1
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq i80 [[SHL1]], -18446744073709551616
+// CHECK-NEXT:[[RES:%.*]] = zext i1 [[CMP]] to i32
+// CHECK-NEXT:call void @p(i8* getelementptr inbounds ([10 x i8], [10 x 
i8]* @.str.[[#STRID:1]], i64 0, i64 0), i32 [[RES]]) [[ATTR4]]
+// CHECK-NEXT:ret void
+//
+void test_long_double_isinf(long double ld) {
+  P(isinf, (ld));
+
+  return;
+}
+
+// CHECK-LABEL: @test_long_double_isfinite(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca x86_fp80, align 16
+// CHECK-NEXT:store x86_fp80 

[PATCH] D97125: Stop traping on sNaN in __builtin_isinf

2021-03-15 Thread Thomas Preud'homme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf60b35340fd7: Stop traping on sNaN in __builtin_isinf 
(authored by thopre).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97125

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/X86/strictfp_builtins.c
  clang/test/CodeGen/aarch64-strictfp-builtins.c
  clang/test/CodeGen/builtin_float_strictfp.c
  clang/test/CodeGen/strictfp_builtins.c

Index: clang/test/CodeGen/strictfp_builtins.c
===
--- clang/test/CodeGen/strictfp_builtins.c
+++ clang/test/CodeGen/strictfp_builtins.c
@@ -55,23 +55,114 @@
   return;
 }
 
-// CHECK-LABEL: @test_isinf(
+// CHECK-LABEL: @test_fp16_isinf(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
-// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
-// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.fabs.f64(double [[TMP0]]) [[ATTR5]]
-// CHECK-NEXT:[[CMPINF:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x7FF0, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
-// CHECK-NEXT:[[TMP2:%.*]] = zext i1 [[CMPINF]] to i32
-// CHECK-NEXT:call void @p(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 [[TMP2]]) [[ATTR4]]
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca half, align 2
+// CHECK-NEXT:store half [[H:%.*]], half* [[LD_ADDR]], align 2
+// CHECK-NEXT:[[TMP0:%.*]] = load half, half* [[LD_ADDR]], align 2
+// CHECK-NEXT:[[BITCAST:%.*]] = bitcast half [[TMP0]] to i16
+// CHECK-NEXT:[[SHL1:%.*]] = shl i16 [[BITCAST]], 1
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq i16 [[SHL1]], -2048
+// CHECK-NEXT:[[RES:%.*]] = zext i1 [[CMP]] to i32
+// CHECK-NEXT:call void @p(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.[[#STRID:2]], i64 0, i64 0), i32 [[RES]]) [[ATTR4]]
 // CHECK-NEXT:ret void
 //
-void test_isinf(double d) {
+void test_fp16_isinf(__fp16 h) {
+  P(isinf, (h));
+
+  return;
+}
+
+// CHECK-LABEL: @test_float_isinf(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca float, align 4
+// CHECK-NEXT:store float [[F:%.*]], float* [[LD_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[LD_ADDR]], align 4
+// CHECK-NEXT:[[BITCAST:%.*]] = bitcast float [[TMP0]] to i32
+// CHECK-NEXT:[[SHL1:%.*]] = shl i32 [[BITCAST]], 1
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq i32 [[SHL1]], -16777216
+// CHECK-NEXT:[[RES:%.*]] = zext i1 [[CMP]] to i32
+// CHECK-NEXT:call void @p(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.[[#STRID:STRID+1]], i64 0, i64 0), i32 [[RES]]) [[ATTR4]]
+// CHECK-NEXT:ret void
+//
+void test_float_isinf(float f) {
+  P(isinf, (f));
+
+  return;
+}
+
+// CHECK-LABEL: @test_double_isinf(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[LD_ADDR]], align 8
+// CHECK-NEXT:[[BITCAST:%.*]] = bitcast double [[TMP0]] to i64
+// CHECK-NEXT:[[SHL1:%.*]] = shl i64 [[BITCAST]], 1
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq i64 [[SHL1]], -9007199254740992
+// CHECK-NEXT:[[RES:%.*]] = zext i1 [[CMP]] to i32
+// CHECK-NEXT:call void @p(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.[[#STRID:STRID+1]], i64 0, i64 0), i32 [[RES]]) [[ATTR4]]
+// CHECK-NEXT:ret void
+//
+void test_double_isinf(double d) {
   P(isinf, (d));
 
   return;
 }
 
+// CHECK-LABEL: @test_fp16_isfinite(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca half, align 2
+// CHECK-NEXT:store half [[H:%.*]], half* [[LD_ADDR]], align 2
+// CHECK-NEXT:[[TMP0:%.*]] = load half, half* [[LD_ADDR]], align 2
+// CHECK-NEXT:[[BITCAST:%.*]] = bitcast half [[TMP0]] to i16
+// CHECK-NEXT:[[SHL1:%.*]] = shl i16 [[BITCAST]], 1
+// CHECK-NEXT:[[CMP:%.*]] = icmp ult i16 [[SHL1]], -2048
+// CHECK-NEXT:[[RES:%.*]] = zext i1 [[CMP]] to i32
+// CHECK-NEXT:call void @p(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.[[#STRID:STRID+1]], i64 0, i64 0), i32 [[RES]]) [[ATTR4]]
+// CHECK-NEXT:ret void
+//
+void test_fp16_isfinite(__fp16 h) {
+  P(isfinite, (h));
+
+  return;
+}
+
+// CHECK-LABEL: @test_float_isfinite(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca float, align 4
+// CHECK-NEXT:store float [[F:%.*]], float* [[LD_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load float, float* [[LD_ADDR]], align 4
+// CHECK-NEXT:[[BITCAST:%.*]] = bitcast float [[TMP0]] to i32
+// CHECK-NEXT:[[SHL1:%.*]] = shl i32 [[BITCAST]], 1
+// CHECK-NEXT:[[CMP:%.*]] = icmp ult i32 [[SHL1]], -16777216
+// CHECK-NEXT:[[RES:%.*]] = 

[PATCH] D98246: [clangd] Add basic monitoring info request for remote index server

2021-03-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 330681.
kbobyrev marked 6 inline comments as done.
kbobyrev added a comment.
Herald added a project: clang-tools-extra.

Resolve review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98246

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/MonitoringService.proto
  clang-tools-extra/clangd/index/remote/Service.proto
  clang-tools-extra/clangd/index/remote/server/Server.cpp

Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- clang-tools-extra/clangd/index/remote/server/Server.cpp
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -7,7 +7,10 @@
 //===--===//
 
 #include "Index.pb.h"
+#include "MonitoringService.grpc.pb.h"
+#include "MonitoringService.pb.h"
 #include "Service.grpc.pb.h"
+#include "Service.pb.h"
 #include "index/Index.h"
 #include "index/Serialization.h"
 #include "index/Symbol.h"
@@ -283,11 +286,43 @@
   clangd::SymbolIndex &Index;
 };
 
+class Monitor final : public v1::Monitor::Service {
+public:
+  Monitor(llvm::sys::TimePoint<> StartTime)
+  : StartTime(StartTime), IndexLastReload(StartTime) {}
+
+  void updateIndex(const llvm::sys::TimePoint<> UpdateTime) {
+IndexLastReload = UpdateTime;
+  }
+
+private:
+  // FIXME(kirillbobyrev): Most fields should be populated when the index
+  // reloads (probably in adjacent metadata.txt file next to loaded .idx) but
+  // they aren't right now.
+  grpc::Status MonitoringInfo(grpc::ServerContext *Context,
+  const v1::MonitoringInfoRequest *Request,
+  v1::MonitoringInfoReply *Reply) override {
+Reply->set_uptime(std::chrono::duration_cast(
+  std::chrono::system_clock::now() - StartTime)
+  .count());
+// FIXME(kirillbobyrev): This is not really "freshness", this is just the
+// time since last index reload.
+Reply->set_freshness(std::chrono::duration_cast(
+ std::chrono::system_clock::now() - IndexLastReload)
+ .count());
+return grpc::Status::OK;
+  }
+
+  const llvm::sys::TimePoint<> StartTime;
+  llvm::sys::TimePoint<> IndexLastReload;
+};
+
 // Detect changes in \p IndexPath file and load new versions of the index
 // whenever they become available.
 void hotReload(clangd::SwapIndex &Index, llvm::StringRef IndexPath,
llvm::vfs::Status &LastStatus,
-   llvm::IntrusiveRefCntPtr &FS) {
+   llvm::IntrusiveRefCntPtr &FS,
+   Monitor &Monitor) {
   auto Status = FS->status(IndexPath);
   // Requested file is same as loaded index: no reload is needed.
   if (!Status || (Status->getLastModificationTime() ==
@@ -306,10 +341,11 @@
   Index.reset(std::move(NewIndex));
   log("New index version loaded. Last modification time: {0}, size: {1} bytes.",
   Status->getLastModificationTime(), Status->getSize());
+  Monitor.updateIndex(Status->getLastModificationTime());
 }
 
 void runServerAndWait(clangd::SymbolIndex &Index, llvm::StringRef ServerAddress,
-  llvm::StringRef IndexPath) {
+  llvm::StringRef IndexPath, Monitor &Monitor) {
   RemoteIndexServer Service(Index, IndexRoot);
 
   grpc::EnableDefaultHealthCheckService(true);
@@ -319,6 +355,7 @@
   Builder.AddChannelArgument(GRPC_ARG_MAX_CONNECTION_IDLE_MS,
  IdleTimeoutSeconds * 1000);
   Builder.RegisterService(&Service);
+  Builder.RegisterService(&Monitor);
   std::unique_ptr Server(Builder.BuildAndStart());
   log("Server listening on {0}", ServerAddress);
 
@@ -417,16 +454,18 @@
   }
   clang::clangd::SwapIndex Index(std::move(SymIndex));
 
-  std::thread HotReloadThread([&Index, &Status, &FS]() {
+  Monitor Monitor(std::chrono::system_clock::now());
+
+  std::thread HotReloadThread([&Index, &Status, &FS, &Monitor]() {
 llvm::vfs::Status LastStatus = *Status;
 static constexpr auto RefreshFrequency = std::chrono::seconds(30);
 while (!clang::clangd::shutdownRequested()) {
-  hotReload(Index, llvm::StringRef(IndexPath), LastStatus, FS);
+  hotReload(Index, llvm::StringRef(IndexPath), LastStatus, FS, Monitor);
   std::this_thread::sleep_for(RefreshFrequency);
 }
   });
 
-  runServerAndWait(Index, ServerAddress, IndexPath);
+  runServerAndWait(Index, ServerAddress, IndexPath, Monitor);
 
   HotReloadThread.join();
 }
Index: clang-tools-extra/clangd/index/remote/Service.proto
===
--- clang-tools-extra/clangd/index/remote/Service.proto
+++ clang-tools-extra/clangd/index/remote/Service.proto
@@ -23,4 +23,3 @@
 
   rpc Relations(RelationsRequest) returns (stream Re

[PATCH] D98635: [libtooling][clang-tidy] Fix diagnostics not handlings SourceRange highlights

2021-03-15 Thread Whisperity via Phabricator via cfe-commits
whisperity created this revision.
whisperity added reviewers: aaron.ballman, njames93.
whisperity added projects: clang, clang-tools-extra.
Herald added subscribers: martong, gamesh411, Szelethus, dkrupp, rnkovacs, 
xazax.hun.
whisperity requested review of this revision.
Herald added a subscriber: cfe-commits.

> Fixes bug #49000 .

Currently, when a diagnostic in Clang-Tidy is produced as 
`diag(Var->getLocation(), "foo %0") << "bar" << Var->getSourceRange();`, the 
source range specified to be highlighted is discarded, i.e.

  x.cpp:21:18: warning: foo bar [blah-blah-checker]
  void fun(int I, int J, int K) {}
   ^

is created instead of producing a full highlight:

  x.cpp:21:18: warning: foo bar [blah-blah-checker]
  void fun(int I, int J, int K) {}
   ^

This creates a discrepancy between warnings generated in `Clang::Sema` which 
work properly, and in Tidy.
This patch fixes the issue by making sure Clang-Tidy's logic of decoupling 
ranges from the `SourceManager` and rendering them later respects custom ranges 
that are fed into a diagnostic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98635

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
  clang-tools-extra/unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
  clang/include/clang/Tooling/Core/Diagnostic.h
  clang/include/clang/Tooling/DiagnosticsYaml.h
  clang/lib/Tooling/Core/Diagnostic.cpp
  clang/unittests/Tooling/DiagnosticsYamlTest.cpp

Index: clang/unittests/Tooling/DiagnosticsYamlTest.cpp
===
--- clang/unittests/Tooling/DiagnosticsYamlTest.cpp
+++ clang/unittests/Tooling/DiagnosticsYamlTest.cpp
@@ -20,14 +20,16 @@
 using namespace clang::tooling;
 using clang::tooling::Diagnostic;
 
-static DiagnosticMessage makeMessage(const std::string &Message, int FileOffset,
- const std::string &FilePath,
- const StringMap &Fix) {
+static DiagnosticMessage
+makeMessage(const std::string &Message, int FileOffset,
+const std::string &FilePath, const StringMap &Fix,
+const SmallVector &Ranges) {
   DiagnosticMessage DiagMessage;
   DiagMessage.Message = Message;
   DiagMessage.FileOffset = FileOffset;
   DiagMessage.FilePath = FilePath;
   DiagMessage.Fix = Fix;
+  DiagMessage.Ranges = Ranges;
   return DiagMessage;
 }
 
@@ -47,8 +49,8 @@
  const StringMap &Fix,
  const SmallVector &Ranges) {
   return Diagnostic(DiagnosticName,
-makeMessage(Message, FileOffset, FilePath, Fix), {},
-Diagnostic::Warning, "path/to/build/directory", Ranges);
+makeMessage(Message, FileOffset, FilePath, Fix, Ranges), {},
+Diagnostic::Warning, "path/to/build/directory");
 }
 
 static const char *YAMLContent =
@@ -77,12 +79,12 @@
 "  Offset:  62\n"
 "  Length:  2\n"
 "  ReplacementText: 'replacement #2'\n"
+"  Ranges:\n"
+"- FilePath:'path/to/source.cpp'\n"
+"  FileOffset:  10\n"
+"  Length:  10\n"
 "Level:   Warning\n"
 "BuildDirectory:  'path/to/build/directory'\n"
-"Ranges:\n"
-"  - FilePath:'path/to/source.cpp'\n"
-"FileOffset:  10\n"
-"Length:  10\n"
 "  - DiagnosticName:  'diagnostic#3'\n"
 "DiagnosticMessage:\n"
 "  Message: 'message #3'\n"
@@ -123,9 +125,9 @@
   TUD.Diagnostics.push_back(makeDiagnostic("diagnostic#3", "message #3", 72,
"path/to/source2.cpp", {}, {}));
   TUD.Diagnostics.back().Notes.push_back(
-  makeMessage("Note1", 88, "path/to/note1.cpp", {}));
+  makeMessage("Note1", 88, "path/to/note1.cpp", {}, {}));
   TUD.Diagnostics.back().Notes.push_back(
-  makeMessage("Note2", 99, "path/to/note2.cpp", {}));
+  makeMessage("Note2", 99, "path/to/note2.cpp", {}, {}));
 
   std::string YamlContent;
   raw_string_ostream YamlContentStream(YamlContent);
@@ -166,7 +168,7 @@
   EXPECT_EQ(100u, Fixes1[0].getOffset());
   EXPECT_EQ(12u, Fixes1[0].getLength());
   EXPECT_EQ("replacement #1", Fixes1[0].getReplacementText());
-  EXPECT_TRUE(D1.Ranges.empty());
+  EXPECT_TRUE(D1.Message.Ranges.empty());
 
   Diagnostic D2 = TUDActual.Diagnostics[1];
   EXPECT_EQ("diagnostic#2", D2.DiagnosticName);
@@ -179,10 +181,10 @@
   EXPECT_EQ(62u, Fixes2[0].getOffset());
   EXPECT_EQ(2u, Fixes2[0].getLength());
   EXPECT_EQ("replacement #2", Fixes2[0].getReplacementText());
-  EXPECT_EQ(1u, D2.Ranges.size());
-  EXPECT_EQ("path/to/source.cpp", D2.Ranges[0].FilePath);

[clang] 33b1f3f - [clang][patch] Solve PR49479, File scope fp pragma should propagate to functions nested in struct, and initialization expressions

2021-03-15 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-03-15T12:15:20-04:00
New Revision: 33b1f3f42cb9fc4fed9501ed49e4805f134e7a1b

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

LOG: [clang][patch] Solve PR49479, File scope fp pragma should propagate to 
functions nested in struct, and initialization expressions

Previously, the CurFPFeatures state was set to command line settings before
semantic analysis of the nested member functions and initialization
expressions, that's not correct, it should use the pragma state which
is in effect at the lexical position.

Reviewed By: Erich Keane, Aaron Ballman

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

Added: 


Modified: 
clang/lib/Parse/ParseDeclCXX.cpp
clang/test/CodeGen/fp-floatcontrol-stack.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index df71ba34cdd9..dd1cccf72668 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -3417,15 +3417,6 @@ void Parser::ParseCXXMemberSpecification(SourceLocation 
RecordLoc,
 // declarations and the lexed inline method definitions, along with any
 // delayed attributes.
 
-// Save the state of Sema.FPFeatures, and change the setting
-// to the levels specified on the command line.  Previous level
-// will be restored when the RAII object is destroyed.
-Sema::FPFeaturesStateRAII SaveFPFeaturesState(Actions);
-FPOptionsOverride NewOverrides;
-Actions.CurFPFeatures = NewOverrides.applyOverrides(getLangOpts());
-Actions.FpPragmaStack.Act(Tok.getLocation(), Sema::PSK_Reset, StringRef(),
-  {} /*unused*/);
-
 SourceLocation SavedPrevTokLocation = PrevTokLocation;
 ParseLexedPragmas(getCurrentClass());
 ParseLexedAttributes(getCurrentClass());

diff  --git a/clang/test/CodeGen/fp-floatcontrol-stack.cpp 
b/clang/test/CodeGen/fp-floatcontrol-stack.cpp
index f49b5088641c..122c621b4cbc 100644
--- a/clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -212,8 +212,7 @@ float fun_default FUN(1)
 #endif
 float y();
 class ON {
-  // Settings for top level class initializer revert to command line
-  // source pragma's do not pertain.
+  // Settings for top level class initializer use program source setting.
   float z = 2 + y() * 7;
 //CHECK-LABEL: define {{.*}} void @_ZN2ONC2Ev{{.*}}
 #if DEFAULT
@@ -224,11 +223,10 @@ class ON {
 //CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
 #endif
 #if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
+//CHECK-NOHONOR: call float {{.*}}llvm.fmuladd
 #endif
 #if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
+//CHECK-FAST: float {{.*}}llvm.fmuladd{{.*}}
 #endif
 };
 ON on;
@@ -236,18 +234,28 @@ ON on;
 class OFF {
   float w = 2 + y() * 7;
 //CHECK-LABEL: define {{.*}} void @_ZN3OFFC2Ev{{.*}}
-#if DEFAULT
-//CHECK-DDEFAULT: call float {{.*}}llvm.fmuladd
-#endif
-#if EBSTRICT
-//CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
-#endif
-#if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
-#endif
-#if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
-#endif
+//CHECK: call float {{.*}}llvm.fmuladd
 };
 OFF off;
+
+#pragma clang fp reassociate(on)
+struct MyComplex {
+  float xx;
+  float yy;
+  MyComplex(float x, float y) {
+xx = x;
+yy = y;
+  }
+  MyComplex() {}
+  const MyComplex operator+(const MyComplex other) const {
+//CHECK-LABEL: define {{.*}} @_ZNK9MyComplexplES_
+//CHECK: fadd reassoc float
+//CHECK: fadd reassoc float
+return MyComplex(xx + other.xx, yy + other.yy);
+  }
+};
+MyComplex useAdd() {
+  MyComplex a (1, 3);
+  MyComplex b (2, 4);
+   return a + b;
+}



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


[PATCH] D98635: [libtooling][clang-tidy] Fix diagnostics not handlings SourceRange highlights

2021-03-15 Thread Whisperity via Phabricator via cfe-commits
whisperity updated this revision to Diff 330687.
whisperity added a comment.

**NFC** I originally wrote a Release Notes entry about this, which I forgot to 
commit before I generated the patch file I uploaded, this is fixed now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98635

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/infrastructure/export-diagnostics.cpp
  clang-tools-extra/unittests/clang-apply-replacements/ApplyReplacementsTest.cpp
  clang/include/clang/Tooling/Core/Diagnostic.h
  clang/include/clang/Tooling/DiagnosticsYaml.h
  clang/lib/Tooling/Core/Diagnostic.cpp
  clang/unittests/Tooling/DiagnosticsYamlTest.cpp

Index: clang/unittests/Tooling/DiagnosticsYamlTest.cpp
===
--- clang/unittests/Tooling/DiagnosticsYamlTest.cpp
+++ clang/unittests/Tooling/DiagnosticsYamlTest.cpp
@@ -20,14 +20,16 @@
 using namespace clang::tooling;
 using clang::tooling::Diagnostic;
 
-static DiagnosticMessage makeMessage(const std::string &Message, int FileOffset,
- const std::string &FilePath,
- const StringMap &Fix) {
+static DiagnosticMessage
+makeMessage(const std::string &Message, int FileOffset,
+const std::string &FilePath, const StringMap &Fix,
+const SmallVector &Ranges) {
   DiagnosticMessage DiagMessage;
   DiagMessage.Message = Message;
   DiagMessage.FileOffset = FileOffset;
   DiagMessage.FilePath = FilePath;
   DiagMessage.Fix = Fix;
+  DiagMessage.Ranges = Ranges;
   return DiagMessage;
 }
 
@@ -47,8 +49,8 @@
  const StringMap &Fix,
  const SmallVector &Ranges) {
   return Diagnostic(DiagnosticName,
-makeMessage(Message, FileOffset, FilePath, Fix), {},
-Diagnostic::Warning, "path/to/build/directory", Ranges);
+makeMessage(Message, FileOffset, FilePath, Fix, Ranges), {},
+Diagnostic::Warning, "path/to/build/directory");
 }
 
 static const char *YAMLContent =
@@ -77,12 +79,12 @@
 "  Offset:  62\n"
 "  Length:  2\n"
 "  ReplacementText: 'replacement #2'\n"
+"  Ranges:\n"
+"- FilePath:'path/to/source.cpp'\n"
+"  FileOffset:  10\n"
+"  Length:  10\n"
 "Level:   Warning\n"
 "BuildDirectory:  'path/to/build/directory'\n"
-"Ranges:\n"
-"  - FilePath:'path/to/source.cpp'\n"
-"FileOffset:  10\n"
-"Length:  10\n"
 "  - DiagnosticName:  'diagnostic#3'\n"
 "DiagnosticMessage:\n"
 "  Message: 'message #3'\n"
@@ -123,9 +125,9 @@
   TUD.Diagnostics.push_back(makeDiagnostic("diagnostic#3", "message #3", 72,
"path/to/source2.cpp", {}, {}));
   TUD.Diagnostics.back().Notes.push_back(
-  makeMessage("Note1", 88, "path/to/note1.cpp", {}));
+  makeMessage("Note1", 88, "path/to/note1.cpp", {}, {}));
   TUD.Diagnostics.back().Notes.push_back(
-  makeMessage("Note2", 99, "path/to/note2.cpp", {}));
+  makeMessage("Note2", 99, "path/to/note2.cpp", {}, {}));
 
   std::string YamlContent;
   raw_string_ostream YamlContentStream(YamlContent);
@@ -166,7 +168,7 @@
   EXPECT_EQ(100u, Fixes1[0].getOffset());
   EXPECT_EQ(12u, Fixes1[0].getLength());
   EXPECT_EQ("replacement #1", Fixes1[0].getReplacementText());
-  EXPECT_TRUE(D1.Ranges.empty());
+  EXPECT_TRUE(D1.Message.Ranges.empty());
 
   Diagnostic D2 = TUDActual.Diagnostics[1];
   EXPECT_EQ("diagnostic#2", D2.DiagnosticName);
@@ -179,10 +181,10 @@
   EXPECT_EQ(62u, Fixes2[0].getOffset());
   EXPECT_EQ(2u, Fixes2[0].getLength());
   EXPECT_EQ("replacement #2", Fixes2[0].getReplacementText());
-  EXPECT_EQ(1u, D2.Ranges.size());
-  EXPECT_EQ("path/to/source.cpp", D2.Ranges[0].FilePath);
-  EXPECT_EQ(10u, D2.Ranges[0].FileOffset);
-  EXPECT_EQ(10u, D2.Ranges[0].Length);
+  EXPECT_EQ(1u, D2.Message.Ranges.size());
+  EXPECT_EQ("path/to/source.cpp", D2.Message.Ranges[0].FilePath);
+  EXPECT_EQ(10u, D2.Message.Ranges[0].FileOffset);
+  EXPECT_EQ(10u, D2.Message.Ranges[0].Length);
 
   Diagnostic D3 = TUDActual.Diagnostics[2];
   EXPECT_EQ("diagnostic#3", D3.DiagnosticName);
@@ -198,5 +200,5 @@
   EXPECT_EQ("path/to/note2.cpp", D3.Notes[1].FilePath);
   std::vector Fixes3 = getFixes(D3.Message.Fix);
   EXPECT_TRUE(Fixes3.empty());
-  EXPECT_TRUE(D3.Ranges.empty());
+  EXPECT_TRUE(D3.Message.Ranges.empty());
 }
Index: clang/lib/Tooling/Core/Diagnostic.cpp
===
--- clang/lib/Tooling/Core/Diagnostic.cpp
+++ clang/

[PATCH] D98211: Solve PR49479, File scope fp pragma should propagate to functions nested in struct, and initialization expressions

2021-03-15 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG33b1f3f42cb9: [clang][patch] Solve PR49479, File scope fp 
pragma should propagate to… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98211

Files:
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/CodeGen/fp-floatcontrol-stack.cpp


Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -212,8 +212,7 @@
 #endif
 float y();
 class ON {
-  // Settings for top level class initializer revert to command line
-  // source pragma's do not pertain.
+  // Settings for top level class initializer use program source setting.
   float z = 2 + y() * 7;
 //CHECK-LABEL: define {{.*}} void @_ZN2ONC2Ev{{.*}}
 #if DEFAULT
@@ -224,11 +223,10 @@
 //CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
 #endif
 #if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
+//CHECK-NOHONOR: call float {{.*}}llvm.fmuladd
 #endif
 #if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
+//CHECK-FAST: float {{.*}}llvm.fmuladd{{.*}}
 #endif
 };
 ON on;
@@ -236,18 +234,28 @@
 class OFF {
   float w = 2 + y() * 7;
 //CHECK-LABEL: define {{.*}} void @_ZN3OFFC2Ev{{.*}}
-#if DEFAULT
-//CHECK-DDEFAULT: call float {{.*}}llvm.fmuladd
-#endif
-#if EBSTRICT
-//CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
-#endif
-#if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
-#endif
-#if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
-#endif
+//CHECK: call float {{.*}}llvm.fmuladd
 };
 OFF off;
+
+#pragma clang fp reassociate(on)
+struct MyComplex {
+  float xx;
+  float yy;
+  MyComplex(float x, float y) {
+xx = x;
+yy = y;
+  }
+  MyComplex() {}
+  const MyComplex operator+(const MyComplex other) const {
+//CHECK-LABEL: define {{.*}} @_ZNK9MyComplexplES_
+//CHECK: fadd reassoc float
+//CHECK: fadd reassoc float
+return MyComplex(xx + other.xx, yy + other.yy);
+  }
+};
+MyComplex useAdd() {
+  MyComplex a (1, 3);
+  MyComplex b (2, 4);
+   return a + b;
+}
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -3417,15 +3417,6 @@
 // declarations and the lexed inline method definitions, along with any
 // delayed attributes.
 
-// Save the state of Sema.FPFeatures, and change the setting
-// to the levels specified on the command line.  Previous level
-// will be restored when the RAII object is destroyed.
-Sema::FPFeaturesStateRAII SaveFPFeaturesState(Actions);
-FPOptionsOverride NewOverrides;
-Actions.CurFPFeatures = NewOverrides.applyOverrides(getLangOpts());
-Actions.FpPragmaStack.Act(Tok.getLocation(), Sema::PSK_Reset, StringRef(),
-  {} /*unused*/);
-
 SourceLocation SavedPrevTokLocation = PrevTokLocation;
 ParseLexedPragmas(getCurrentClass());
 ParseLexedAttributes(getCurrentClass());


Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -212,8 +212,7 @@
 #endif
 float y();
 class ON {
-  // Settings for top level class initializer revert to command line
-  // source pragma's do not pertain.
+  // Settings for top level class initializer use program source setting.
   float z = 2 + y() * 7;
 //CHECK-LABEL: define {{.*}} void @_ZN2ONC2Ev{{.*}}
 #if DEFAULT
@@ -224,11 +223,10 @@
 //CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
 #endif
 #if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
+//CHECK-NOHONOR: call float {{.*}}llvm.fmuladd
 #endif
 #if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
+//CHECK-FAST: float {{.*}}llvm.fmuladd{{.*}}
 #endif
 };
 ON on;
@@ -236,18 +234,28 @@
 class OFF {
   float w = 2 + y() * 7;
 //CHECK-LABEL: define {{.*}} void @_ZN3OFFC2Ev{{.*}}
-#if DEFAULT
-//CHECK-DDEFAULT: call float {{.*}}llvm.fmuladd
-#endif
-#if EBSTRICT
-//CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
-#endif
-#if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
-#endif
-#if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
-#endif
+//CHECK: call float {{.*}}llvm.fmuladd
 };
 OFF off;
+
+#pragma clang fp reassociate(on)
+struct MyComplex {
+  float xx;
+  float yy;
+  MyComplex(float x, float y) {
+xx = x;
+yy = y;
+  }
+  MyComplex() {}
+  const MyComplex operator+(const MyComplex other) const {
+//CHECK-LABEL: define {{.*}} @_ZNK9MyComplexplES_
+//CHECK: fadd reassoc float
+//CHECK

[PATCH] D97785: [SystemZ][z/OS] Distinguish between text and binary files on z/OS

2021-03-15 Thread Zibi Sarbino via Phabricator via cfe-commits
zibi added a comment.

LGTM, I just wonder if we can make an extra parameter to be default. I notice 
some places that is a default parameter but not in all instances. With default 
parameter some of the calls might be simplified if there is no need to override 
it.




Comment at: clang/lib/Frontend/FrontendActions.cpp:812
+  bool BinaryMode = false;
+  llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
+  if (HostTriple.isOSWindows()) {

If we don't need Triple anywhere else except here we can remove the new for 
local variable and do crate it as part of the test.

```
if (HostTriple(LLVM_HOST_TRIPLE).isOSWindows()) {
...
```
or even

```
bool BinaryMode = (HostTriple(LLVM_HOST_TRIPLE).isOSWindows())  ? true : false;

```



Comment at: llvm/lib/Support/ToolOutputFile.cpp:50
+
+  llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
+  // On Windows, we set the OF_None flag even for text files to avoid

Can we avoid creating  `HostTriple` here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97785

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


[PATCH] D98030: [IR] Add vscale_range IR function attribute

2021-03-15 Thread Bradley Smith via Phabricator via cfe-commits
bsmith updated this revision to Diff 330691.
bsmith marked 3 inline comments as done.
bsmith added a comment.

- Prevent vscale_range(0,0) from crashing and instead don't add the attribute
- Improve CHECK lines in arm-sve-vector-bits-vscale-range.c test
- Test vscale_range(0,0) case and move some tests around


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98030

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c
  llvm/docs/BitCodeFormat.rst
  llvm/docs/LangRef.rst
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLParser.h
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/AttributeImpl.h
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Bitcode/attributes.ll
  llvm/test/Verifier/vscale_range.ll

Index: llvm/test/Verifier/vscale_range.ll
===
--- /dev/null
+++ llvm/test/Verifier/vscale_range.ll
@@ -0,0 +1,4 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+; CHECK: 'vscale_range' minimum cannot be greater than maximum
+declare i8* @b(i32*) vscale_range(8, 1)
Index: llvm/test/Bitcode/attributes.ll
===
--- llvm/test/Bitcode/attributes.ll
+++ llvm/test/Bitcode/attributes.ll
@@ -422,6 +422,31 @@
   ret void
 }
 
+; CHECK: define void @f72() #45
+define void @f72() vscale_range(8)
+{
+  ret void
+}
+
+; CHECK: define void @f73() #46
+define void @f73() vscale_range(1,8)
+{
+  ret void
+}
+
+; CHECK: define void @f74() #47
+define void @f74() vscale_range(1,0)
+{
+  ret void
+}
+
+; CHECK: define void @f75()
+; CHECK-NOT: define void @f75() #
+define void @f75() vscale_range(0,0)
+{
+  ret void
+}
+
 ; CHECK: attributes #0 = { noreturn }
 ; CHECK: attributes #1 = { nounwind }
 ; CHECK: attributes #2 = { readnone }
@@ -467,4 +492,7 @@
 ; CHECK: attributes #42 = { nocallback }
 ; CHECK: attributes #43 = { cold }
 ; CHECK: attributes #44 = { hot }
+; CHECK: attributes #45 = { vscale_range(8,8) }
+; CHECK: attributes #46 = { vscale_range(1,8) }
+; CHECK: attributes #47 = { vscale_range(1,0) }
 ; CHECK: attributes #[[NOBUILTIN]] = { nobuiltin }
Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -970,6 +970,7 @@
   case Attribute::StackProtectStrong:
   case Attribute::StrictFP:
   case Attribute::UWTable:
+  case Attribute::VScaleRange:
   case Attribute::NoCfCheck:
   case Attribute::MustProgress:
   case Attribute::NoProfile:
Index: llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
===
--- llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
+++ llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
@@ -73,6 +73,7 @@
   .Case("sspstrong", Attribute::StackProtectStrong)
   .Case("strictfp", Attribute::StrictFP)
   .Case("uwtable", Attribute::UWTable)
+  .Case("vscale_range", Attribute::VScaleRange)
   .Default(Attribute::None);
 }
 
Index: llvm/lib/IR/Verifier.cpp
===
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -1629,6 +1629,7 @@
   case Attribute::InlineHint:
   case Attribute::StackAlignment:
   case Attribute::UWTable:
+  case Attribute::VScaleRange:
   case Attribute::NonLazyBind:
   case Attribute::ReturnsTwice:
   case Attribute::SanitizeAddress:
@@ -1987,6 +1988,14 @@
   return;
   }
 
+  if (Attrs.hasFnAttribute(Attribute::VScaleRange)) {
+std::pair Args =
+Attrs.getVScaleRangeArgs(AttributeList::FunctionIndex);
+
+if (Args.first > Args.second && Args.second != 0)
+  CheckFailed("'vscale_range' minimum cannot be greater than maximum", V);
+  }
+
   if (Attrs.hasFnAttribute("frame-pointer")) {
 StringRef FP = Attrs.getAttribute(AttributeList::FunctionIndex,
   "frame-pointer").getValueAsString();
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -78,6 +78,17 @@
   return std::make_pair(ElemSizeArg, NumElemsArg);
 }
 
+static uint64_t packVScaleRangeArgs(unsigned MinValue, unsigned MaxValue) {
+  return uint64_t(MinValue) << 32 | MaxValue;
+}
+
+static std::pair unpackVScaleRangeArgs(uint64_t Value) {
+  unsigned MaxValue = Value & std::numeric_limits::max();
+  unsigned MinValue 

[PATCH] D98433: [clang] [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:1438
 
-// Parse trailing-return-type[opt].
-if (Tok.is(tok::arrow)) {
-  FunLocalRangeEnd = Tok.getLocation();
-  SourceRange Range;
-  TrailingReturnType =
-  ParseTrailingReturnType(Range, /*MayBeFollowedByDirectInit*/ false);
-  TrailingReturnTypeLoc = Range.getBegin();
-  if (Range.getEnd().isValid())
-DeclEndLoc = Range.getEnd();
-}
+PrototypeScope.Exit();
+  } else if (getLangOpts().CPlusPlus2b) {

No need to call this here, it happens from the destructor of `ParseScope`.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:1440
+  } else if (getLangOpts().CPlusPlus2b) {
+ParseScope PrototypeScope(this, Scope::FunctionPrototypeScope |
+Scope::FunctionDeclarationScope |

I don't know the answer to this, but... do we need a prototype scope at all 
when there's no parameter list? The old code was doing this, so I don't think 
this is an issue with your patch per se, more just curiosity whether this is 
necessary in this case.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:1447
+std::vector EmptyParamInfo;
+ParseLambdaSpecifiers(/*LParenLoc=*/NoLoc, /*RParenLoc=*/NoLoc,
+  EmptyParamInfo, /*EllipsisLoc=*/NoLoc);

curdeius wrote:
> I'm not sure what I should do with `LParenLoc` and `RParenLoc`. Any idea?
What you've done here seems reasonable to me. The `SourceLocation` for the 
parens will be invalid, which is the behavior I'd expect when the parens are 
missing.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:1450
 
 PrototypeScope.Exit();
   } else if (Tok.isOneOf(tok::kw_mutable, tok::arrow, tok::kw___attribute,

No need to call this here, it happens from the destructor of `ParseScope`.



Comment at: clang/test/Parser/cxx2b-lambdas.cpp:22
+auto XL1 = [] constexpr mutable constexpr {};  // expected-error{{cannot 
appear multiple times}}
+auto XL2 = []) constexpr mutable constexpr {}; // expected-error{{expected 
body}}

It'd be handy to test: `auto XL3 = []( constexpr mutable constexpr {}; ` where 
the parameter list is missing the closing right paren.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

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


[PATCH] D98264: [AArch64] Implement __rndr, __rndrrs intrinsics

2021-03-15 Thread Stelios Ioannou via Phabricator via cfe-commits
stelios-arm updated this revision to Diff 330694.
stelios-arm added a comment.

Typo fix for `__ARM_FEATURE_RNG` macro check in `aarch64-target-features.c`.


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

https://reviews.llvm.org/D98264

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/builtins-arm64.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/rand.ll
  llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir

Index: llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
===
--- llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
+++ llvm/test/CodeGen/AArch64/stp-opt-with-renaming.mir
@@ -100,11 +100,11 @@
   bb.0:
 liveins: $x0
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 renamable $x8 = MOVZXi 15309, 0
 renamable $x8 = MOVKXi renamable $x8, 26239, 16
 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store 8)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRXui killed renamable  $x8, renamable killed $x0, 1, implicit killed $x8 :: (store 8)
 RET undef $lr
 
@@ -134,9 +134,9 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 STRXui renamable $x8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRXui killed renamable  $x8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
@@ -166,9 +166,9 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
@@ -275,10 +275,10 @@
   bb.0:
 liveins: $x0, $x1
 
-renamable $x8 = MRS 58880
+renamable $x8 = MRS 58880, implicit-def $nzcv
 renamable $w8 = ORRWrs $wzr, killed renamable $w8, 0, implicit-def $x8
 STRWui renamable $w8, renamable $x0, 0, implicit killed $x8 :: (store 4)
-renamable $x8 = MRS 55840
+renamable $x8 = MRS 55840, implicit-def $nzcv
 STRWui killed renamable $w8, renamable killed $x0, 1, implicit killed $x8 :: (store 4)
 RET undef $lr
 
Index: llvm/test/CodeGen/AArch64/rand.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/rand.ll
@@ -0,0 +1,40 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64 -mattr=+v8.5a,+rand %s -o - | FileCheck %s
+
+define  i32 @rndr(i64* %__addr) {
+; CHECK-LABEL: rndr:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x9, RNDR
+; CHECK-NEXT:cset w8, eq
+; CHECK-NEXT:and w8, w8, #0x1
+; CHECK-NEXT:str x9, [x0]
+; CHECK-NEXT:mov w0, w8
+; CHECK-NEXT:ret
+  %1 = tail call { i64, i1 } @llvm.aarch64.rndr()
+  %2 = extractvalue { i64, i1 } %1, 0
+  %3 = extractvalue { i64, i1 } %1, 1
+  store i64 %2, i64* %__addr, align 8
+  %4 = zext i1 %3 to i32
+  ret i32 %4
+}
+
+
+define  i32 @rndrrs(i64*  %__addr) {
+; CHECK-LABEL: rndrrs:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mrs x9, RNDRRS
+; CHECK-NEXT:cset w8, eq
+; CHECK-NEXT:and w8, w8, #0x1
+; CHECK-NEXT:str x9, [x0]
+; CHECK-NEXT:mov w0, w8
+; CHECK-NEXT:ret
+  %1 = tail call { i64, i1 } @llvm.aarch64.rndrrs()
+  %2 = extractvalue { i64, i1 } %1, 0
+  %3 = extractvalue { i64, i1 } %1, 1
+  store i64 %2, i64* %__addr, align 8
+  %4 = zext i1 %3 to i32
+  ret i32 %4
+}
+
+declare { i64, i1 } @llvm.aarch64.rndr()
+declare { i64, i1 } @llvm.aarch64.rndrrs()
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -607,7 +607,9 @@
 def AArch64stnp : SDNode<"AArch64ISD::STNP", SDT_AArch64stnp, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
 
 def AArch64tbl : SDNode<"AArch64ISD::TBL", SDT_AArch64TBL>;
-
+def AArch64mrs : SDNode<"AArch64ISD::MRS",
+SDTypeProfile<1, 1, [SDTCisVT<0, i64>, SDTCisVT<1, i32>]>,
+[SDNPHasChain, SDNPOutGlue]>;
 //===--===//
 
 /

[PATCH] D98635: [libtooling][clang-tidy] Fix diagnostics not respecting and highlighting fed SourceRanges

2021-03-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for looking into this!

It looks like there are some unit test failures from the change: 
https://buildkite.com/llvm-project/premerge-checks/builds/29754#a9b04ab5-e326-4ff1-beea-773f21a33349


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98635

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


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

2021-03-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert resigned from this revision.
jdoerfert added a comment.

I see the need for this to work, unsure if this is the right way, we need to 
make progress though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D98635: [libtooling][clang-tidy] Fix diagnostics not respecting and highlighting fed SourceRanges

2021-03-15 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In D98635#2626455 , @aaron.ballman 
wrote:

> It looks like there are some unit test failures from the change: 
> https://buildkite.com/llvm-project/premerge-checks/builds/29754#a9b04ab5-e326-4ff1-beea-773f21a33349

Strange because I specifically ran both `check-clang` **and** 
`check-clang-tools` locally, but will look into this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98635

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


[PATCH] D98610: [RISCV] Support clang -fpatchable-function-entry && GNU function attribute 'patchable_function_entry'

2021-03-15 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: llvm/test/CodeGen/RISCV/patchable-function-entry.ll:1-3
+;; Test the function attribute "patchable-function-entry".
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s --check-prefixes=CHECK,32
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s --check-prefixes=CHECK,64

luismarques wrote:
> jrtc27 wrote:
> > Please match the style of the other tests: 
> > - update_llc_test_checks.py
> > - RV32I/RV32IC/RV64I/RV64IC
> > Please match the style of the other tests: 
> > - update_llc_test_checks.py
> 
> I was going to comment on that but I was unsure it applied here, given that 
> this test was running more than just `llc`. The other RISC-V CodeGen tests we 
> have with objdump don't use the update script IIRC. (And these manual tests 
> were neatly written and much more condensed that the sprawling output of the 
> auto updated checks). But I agree that in general using the script is the way 
> to go for the RISC-V tests.
Yeah, though as you'll see in my comment below I don't think using llvm-objdump 
adds any value, at which point UTC works just fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98610

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


[PATCH] D91054: [Clang][OpenMP] Frontend work for sections - D89671

2021-03-15 Thread Chirag Khandelwal via Phabricator via cfe-commits
AMDChirag added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:3579
+SectionCBVector.push_back(SectionCB);
+  }
+} else {

jdoerfert wrote:
> Why do we unpack the children here instead of making a single call back for 
> the CapturedStmt?
Because there is a bunch of additional IR (creation of switch statement and its 
cases/blocks, loop counter based on count of children) that is generated by 
`createSections`. If the children are not unpacked and `CapturedStmt` is 
directly passed to `EmitOMPRegionBody` in the callback, `createSections` will 
not be able to generate the required IR to encase the `section` constructs with.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91054

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


[clang] 3997076 - [CMake] Require python 3.6 if enabling LLVM test targets

2021-03-15 Thread Christopher Tetreault via cfe-commits

Author: Christopher Tetreault
Date: 2021-03-15T09:50:39-07:00
New Revision: 39970764af39415ad62136ff75b0f89577c18037

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

LOG: [CMake] Require python 3.6 if enabling LLVM test targets

The lit test suite uses python 3.6 features. Rather than a strange
python syntax error upon running the lit tests, we will require the
correct version in CMake.

Reviewed By: serge-sans-paille, yln

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

Added: 


Modified: 
clang/CMakeLists.txt
lld/CMakeLists.txt
llvm/CMakeLists.txt
llvm/cmake/modules/HandleLLVMOptions.cmake
mlir/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 4695dc8a46fff..9ecf4b9d2de86 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -131,7 +131,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+  COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}

diff  --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt
index d4e561b50d8f8..cbca979aaeb11 100644
--- a/lld/CMakeLists.txt
+++ b/lld/CMakeLists.txt
@@ -57,7 +57,8 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+  COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index f5298de9f7ca6..22c1a130f4a56 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -693,7 +693,8 @@ set(ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER TRUE CACHE BOOL
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+COMPONENTS Interpreter)
 
 ##
 

diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake 
b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 32fb4e10e31e9..2e088bd6e9168 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1176,3 +1176,11 @@ if(LLVM_USE_RELATIVE_PATHS_IN_FILES)
   append_if(SUPPORTS_FFILE_PREFIX_MAP 
"-ffile-prefix-map=${source_root}/=${LLVM_SOURCE_PREFIX}" CMAKE_C_FLAGS 
CMAKE_CXX_FLAGS)
   add_flag_if_supported("-no-canonical-prefixes" NO_CANONICAL_PREFIXES)
 endif()
+
+if(LLVM_INCLUDE_TESTS)
+  # Lit test suite requires at least python 3.6
+  set(LLVM_MINIMUM_PYTHON_VERSION 3.6)
+else()
+  # FIXME: it is unknown if this is the actual minimum bound
+  set(LLVM_MINIMUM_PYTHON_VERSION 3.0)
+endif()

diff  --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 7385e6b172226..79ef5510ad2d3 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -106,7 +106,8 @@ set(MLIR_PYTHON_BINDINGS_VERSION_LOCKED 1 CACHE BOOL
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION}
+COMPONENTS Interpreter Development NumPy REQUIRED)
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: 
${Python3_NumPy_INCLUDE_DIRS}")



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


[PATCH] D95635: [CMake] Require python 3.6 if enabling LLVM test targets

2021-03-15 Thread Christopher Tetreault 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 rG39970764af39: [CMake] Require python 3.6 if enabling LLVM 
test targets (authored by ctetreau).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95635

Files:
  clang/CMakeLists.txt
  lld/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/HandleLLVMOptions.cmake
  mlir/CMakeLists.txt


Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -106,7 +106,8 @@
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION}
+COMPONENTS Interpreter Development NumPy REQUIRED)
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: 
${Python3_NumPy_INCLUDE_DIRS}")
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1176,3 +1176,11 @@
   append_if(SUPPORTS_FFILE_PREFIX_MAP 
"-ffile-prefix-map=${source_root}/=${LLVM_SOURCE_PREFIX}" CMAKE_C_FLAGS 
CMAKE_CXX_FLAGS)
   add_flag_if_supported("-no-canonical-prefixes" NO_CANONICAL_PREFIXES)
 endif()
+
+if(LLVM_INCLUDE_TESTS)
+  # Lit test suite requires at least python 3.6
+  set(LLVM_MINIMUM_PYTHON_VERSION 3.6)
+else()
+  # FIXME: it is unknown if this is the actual minimum bound
+  set(LLVM_MINIMUM_PYTHON_VERSION 3.0)
+endif()
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -693,7 +693,8 @@
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+COMPONENTS Interpreter)
 
 ##
 
Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -57,7 +57,8 @@
   include(CheckAtomic)
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+  COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -131,7 +131,8 @@
   set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY 
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
 
   if(LLVM_INCLUDE_TESTS)
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+  COMPONENTS Interpreter)
 
 # Check prebuilt llvm/utils.
 if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX}


Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -106,7 +106,8 @@
 
 if(MLIR_BINDINGS_PYTHON_ENABLED)
   include(MLIRDetectPythonEnv)
-  find_package(Python3 COMPONENTS Interpreter Development NumPy REQUIRED)
+  find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION}
+COMPONENTS Interpreter Development NumPy REQUIRED)
   message(STATUS "Found python include dirs: ${Python3_INCLUDE_DIRS}")
   message(STATUS "Found python libraries: ${Python3_LIBRARIES}")
   message(STATUS "Found numpy v${Python3_NumPy_VERSION}: ${Python3_NumPy_INCLUDE_DIRS}")
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1176,3 +1176,11 @@
   append_if(SUPPORTS_FFILE_PREFIX_MAP "-ffile-prefix-map=${source_root}/=${LLVM_SOURCE_PREFIX}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
   add_flag_if_supported("-no-canonical-prefixes" NO_CANONICAL_PREFIXES)
 endif()
+
+if(LLVM_INCLUDE_TESTS)
+  # Lit test suite requires at least python 3.6
+  set(LLVM_MINIMUM_PYTHON_VERSION 3.6)
+else()
+  # FIXME: it is unknown if this is the actual minimum bound
+  set(LLVM_MINIMUM_PYTHON_VERSION 3.0)
+endif()
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -693,7 +693,8 @@
 
 include(HandleLLVMOptions)
 
-find_package(Python3 REQUIRED COMPONENTS Interpreter)
+find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED
+COMPONENTS Interpreter)
 
 ##
 
Index: lld/CMakeLists.txt
=

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

2021-03-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 330698.
Anastasia added a comment.

Updated Driver test to check -x option.


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

https://reviews.llvm.org/D96771

Files:
  clang/include/clang/Basic/LangStandard.h
  clang/include/clang/Driver/Types.def
  clang/lib/Driver/Types.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/FrontendOptions.cpp
  clang/test/CodeGenOpenCLCXX/address-space-deduction.cl
  clang/test/CodeGenOpenCLCXX/address-space-deduction.cppcl
  clang/test/CodeGenOpenCLCXX/address-space-deduction2.cl
  clang/test/CodeGenOpenCLCXX/address-space-deduction2.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-conversion.cl
  clang/test/CodeGenOpenCLCXX/addrspace-conversion.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-operators.cl
  clang/test/CodeGenOpenCLCXX/addrspace-operators.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-references.cl
  clang/test/CodeGenOpenCLCXX/addrspace-references.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.cl
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.cppcl
  clang/test/CodeGenOpenCLCXX/addrspace_cast.cl
  clang/test/CodeGenOpenCLCXX/addrspace_cast.cppcl
  clang/test/CodeGenOpenCLCXX/atexit.cl
  clang/test/CodeGenOpenCLCXX/atexit.cppcl
  clang/test/CodeGenOpenCLCXX/constexpr.cl
  clang/test/CodeGenOpenCLCXX/constexpr.cppcl
  clang/test/CodeGenOpenCLCXX/global_init.cl
  clang/test/CodeGenOpenCLCXX/global_init.cppcl
  clang/test/CodeGenOpenCLCXX/local_addrspace_init.cl
  clang/test/CodeGenOpenCLCXX/local_addrspace_init.cppcl
  clang/test/CodeGenOpenCLCXX/method-overload-address-space.cl
  clang/test/CodeGenOpenCLCXX/method-overload-address-space.cppcl
  clang/test/CodeGenOpenCLCXX/template-address-spaces.cl
  clang/test/CodeGenOpenCLCXX/template-address-spaces.cppcl
  clang/test/Driver/cxx_for_opencl.cppcl
  clang/test/Driver/lit.local.cfg
  clang/test/SemaOpenCLCXX/address-space-castoperators.cl
  clang/test/SemaOpenCLCXX/address-space-castoperators.cppcl
  clang/test/SemaOpenCLCXX/address-space-cond.cl
  clang/test/SemaOpenCLCXX/address-space-cond.cppcl
  clang/test/SemaOpenCLCXX/address-space-deduction.cl
  clang/test/SemaOpenCLCXX/address-space-deduction.cppcl
  clang/test/SemaOpenCLCXX/address-space-lambda.cl
  clang/test/SemaOpenCLCXX/address-space-lambda.cppcl
  clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cl
  clang/test/SemaOpenCLCXX/address-space-of-this-class-scope.cppcl
  clang/test/SemaOpenCLCXX/address-space-of-this.cl
  clang/test/SemaOpenCLCXX/address-space-of-this.cppcl
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaOpenCLCXX/address-space-references.cppcl
  clang/test/SemaOpenCLCXX/address-space-templates.cl
  clang/test/SemaOpenCLCXX/address-space-templates.cppcl
  clang/test/SemaOpenCLCXX/address_space_overloading.cl
  clang/test/SemaOpenCLCXX/address_space_overloading.cppcl
  clang/test/SemaOpenCLCXX/addrspace-auto.cl
  clang/test/SemaOpenCLCXX/addrspace-auto.cppcl
  clang/test/SemaOpenCLCXX/addrspace_cast.cl
  clang/test/SemaOpenCLCXX/addrspace_cast.cppcl
  clang/test/SemaOpenCLCXX/addrspace_cast_ast_dump.cl
  clang/test/SemaOpenCLCXX/addrspace_cast_ast_dump.cppcl
  clang/test/SemaOpenCLCXX/invalid-kernel.cl
  clang/test/SemaOpenCLCXX/invalid-kernel.cppcl
  clang/test/SemaOpenCLCXX/members.cl
  clang/test/SemaOpenCLCXX/members.cppcl
  clang/test/SemaOpenCLCXX/method-overload-address-space.cl
  clang/test/SemaOpenCLCXX/method-overload-address-space.cppcl
  clang/test/SemaOpenCLCXX/newdelete.cl
  clang/test/SemaOpenCLCXX/newdelete.cppcl
  clang/test/SemaOpenCLCXX/references.cl
  clang/test/SemaOpenCLCXX/references.cppcl
  clang/test/SemaOpenCLCXX/restricted.cl
  clang/test/SemaOpenCLCXX/restricted.cppcl
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -26,7 +26,7 @@
 
 # suffixes: A list of file extensions to treat as test files.
 config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu',
-   '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs']
+   '.ll', '.cl', '.cppcl', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs']
 
 # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
 # subdirectories contain auxiliary inputs for various tests in their parent
Index: clang/test/SemaOpenCLCXX/restricted.cppcl
===
--- clang/test/SemaOpenCLCXX/restricted.cppcl
+++ clang/test/SemaOpenCLCXX/restricted.cppcl
@@ -

[PATCH] D98635: [libtooling][clang-tidy] Fix diagnostics not respecting and highlighting fed SourceRanges

2021-03-15 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

In D98635#2626464 , @whisperity wrote:

> Strange because I specifically ran both `check-clang` **and** 
> `check-clang-tools` locally, but will look into this.

Turns out there is a `check-clang-extra-unit` too, and it looks like those test 
TUs either didn't compile for me at all (as in, it was not commanded to compile 
them), or I messed something up during the rebase.
(But TIL we finally have some semblance of pre-merge checking instead of always 
reverting commits! 😋)

'll update the patch soon. Gonna do a clean build and a clean check, //just in 
case...//.

What's the outlook on the executive decision... changing the **schema** in 
`libToolingCore`... is such even allowed? I'm venturing into parts unknown here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98635

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


[PATCH] D98499: [clangd] Introduce ASTHooks to FeatureModules

2021-03-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.
Herald added a project: clang-tools-extra.

I'm getting a little nervous about the amount of stuff we're packing into 
modules without in-tree examples.
I should split out some of the "standard" features into modules as that's 
possible already.

My model for modules using this diagnostic stuff (apart from the build-system 
stuff which sadly can't be meaningfully upstreamed) are IncludeFixer, 
ClangTidy, and IWYU - worth thinking about how we'd build those on top of this 
model. (Doesn't mean we need to add a hook to emit diagnostics, but it probably 
means we should know where it would go)




Comment at: clang-tools-extra/clangd/FeatureModule.h:104
+  /// implementations don't need to be thread-safe.
+  struct ParseASTHooks {
+virtual ~ParseASTHooks() = default;

naming: giving this a plural name and having a collection of them is a little 
confusing (is `Hooks` the hooks from one module, or from all of them?). What 
about ASTListener?
(Listener suggests passive but listeners that "participate" is a common enough 
idiom I think)



Comment at: clang-tools-extra/clangd/FeatureModule.h:112
+  };
+  /// Can be called asynchronously before building an AST.
+  virtual std::unique_ptr astHooks() { return nullptr; }

This comment hints at what I *thought* was the idea: astHooks() is called each 
time we parse a file, the returned object has methods called on it while the 
file is being parsed, and is then destroyed.

But the code suggests we call once globally and it has effectively the same 
lifetime as the module.
This seems much less useful, e.g. if we want to observe several diagnostics, 
examine the preamble, and emit new diagnostics, then we have to plumb around 
some notion of "AST identity" rather than just tying it to the identity of the 
ParseASTHooks object itself.

(Lots of natural extensions here like providing ParseInputs to astHooks(), but 
YAGNI for now)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98499

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


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

2021-03-15 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

I had a second thought about the extension name and I realized that the reason 
why I initially wanted to use `clcpp` is that it aligns better with `clc++` 
which is used in `-cl-std`. Even though from the RFC the preference was towards 
`cppcl` it felt like there was no objection to `clcpp` either. So I just want 
to check one last time whether it would make sense to align with `clc++` and 
use `clcpp`. Perhaps, it make clang interface a bit more inconsistent?




Comment at: clang/test/Driver/cxx_for_opencl.cppcl:1
+// RUN: %clang %s -Xclang -verify -fsyntax-only
+// RUN: %clang %s -cl-std=clc++ -Xclang -verify -fsyntax-only

awarzynski wrote:
> This is a very neat test. Would it make sense to add something more basic 
> too? For example (in a separate file):
> 
> ```
> // RUN: %clang %s -fstynax-only -### | FileCheck %s
> 
> // CHECK: -x -cppcl
> ```
> 
> This way you would have a bit more explicit test to verifiy that the compiler 
> driver picks the right language based on the extension.
Good idea! Thanks!


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

https://reviews.llvm.org/D96771

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


[PATCH] D98505: [clangd] Propagate data in diagnostics

2021-03-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.
Herald added a project: clang-tools-extra.



Comment at: clang-tools-extra/clangd/Diagnostics.h:58
+  /// If true, Clangd will populate the data field in LSP diagnostic
+  /// representation. This is used to prevent extra data transfer with old
+  /// clients that doesn't support data field.

Second sentence is confusing because of inverted sense. And really I don't 
think the reason is that we don't want to send extra data, but rather the fear 
that old clients will choke on it.

If we're *not* afraid of that, i.e. we think they'll just drop it on the floor, 
then I don't think we should bother to feature-detect it just so *we* can drop 
it on the floor.
Not sure how you feel about this, but it's pretty tempting to me...



Comment at: clang-tools-extra/clangd/Diagnostics.h:82
+  // list.
+  std::vector FeatureModuleData;
 };

Maybe call this OpaqueData or Data?
I like the comment but I'm not sure where this is ultimately set is so 
important at this level (and we might use it in other ways!)



Comment at: clang-tools-extra/clangd/Protocol.h:853
+  /// and`textDocument/codeAction` request.
+  /// For clangd, this is always an array, with possibly zero elements.
+  llvm::json::Array data;

The array representation seems a bit awkward in practice: it's ~always going to 
have 1 element (or none), so it seems like unnecessary wrapping.
I think the "natural" representation is something like `{"fooTweakParam": 42}` 
or `{"fooTweakParams": {"x": 1, "y": 2}}`.

This array prevents tweaks from clobbering each other but OTOH it means the 
data they read doesn't match the data they write. I think making data an Object 
and passing in a mutable ref to it will work fine in practice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98505

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


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

2021-03-15 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Agreed. Lack of save temps is causing grief when debugging, so I keep on 
applying this patch locally. Let's go with this for now. and change to 
something better when we think of it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-15 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 330711.
arnamoy10 added a comment.

Clang-formatting and addressing reviewers' comments:

Moved the default directory append to `setFortranOpts()`


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

https://reviews.llvm.org/D97080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/intrinsic_module_path.f90

Index: flang/test/Driver/intrinsic_module_path.f90
===
--- /dev/null
+++ flang/test/Driver/intrinsic_module_path.f90
@@ -0,0 +1,35 @@
+! Ensure argument -fintrinsic-modules-path works as expected.
+! WITHOUT the option, the default location for the module is checked and no error generated.
+! With the option GIVEN, the module with the same name is PREPENDED, and considered over the
+! default one, causing a CHECKSUM error.
+
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fc1 -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: 'ieee_arithmetic.mod' was not found
+! WITHOUT-NOT: 'iso_fortran_env.mod' was not found
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: error: Cannot read module file for module 'ieee_arithmetic': File has invalid checksum
+! GIVEN: error: Cannot read module file for module 'iso_fortran_env': File has invalid checksum
+
+
+program test_intrinsic_module_path
+   use ieee_arithmetic, only: ieee_round_type
+   use iso_fortran_env, only: team_type, event_type, lock_type
+end program
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -35,6 +35,8 @@
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-NEXT: -fintrinsic-modules-path 
+! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -82,6 +84,8 @@
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
 ! HELP-FC1-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-FC1-NEXT: -fintrinsic-modules-path 
+! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -35,6 +35,8 @@
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
+! CHECK-NEXT: -fintrinsic-modules-path 
+! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -21,8 +21,11 @@
 #include "ll

[PATCH] D96875: [flang][driver] Add -fdebug-module-writer option

2021-03-15 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added a comment.

This has been merged, closing it.


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

https://reviews.llvm.org/D96875

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


[PATCH] D96875: [flang][driver] Add -fdebug-module-writer option

2021-03-15 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added a comment.

Abandon


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

https://reviews.llvm.org/D96875

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


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

2021-03-15 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb accepted this revision.
ronlieb added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96769

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


[PATCH] D98411: [OpenCL] Respect calling convention for builtin

2021-03-15 Thread Luke Drummond via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfcfd3fda7190: [OpenCL] Respect calling convention for 
builtin (authored by ldrumm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98411

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenOpenCL/sampler.cl


Index: clang/test/CodeGenOpenCL/sampler.cl
===
--- clang/test/CodeGenOpenCL/sampler.cl
+++ clang/test/CodeGenOpenCL/sampler.cl
@@ -39,7 +39,7 @@
   // Case 2b
   sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | 
CLK_FILTER_NEAREST;
   // CHECK: [[smp_ptr:%[A-Za-z0-9_\.]+]] = alloca %opencl.sampler_t 
addrspace(2)*
-  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 19)
+  // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 19)
   // CHECK: store %opencl.sampler_t addrspace(2)* [[SAMP]], %opencl.sampler_t 
addrspace(2)** [[smp_ptr]]
 
   // Case 1b
@@ -56,12 +56,12 @@
 
   // Case 1a/2a
   fnc4smp(glb_smp);
-  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
+  // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
   // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* 
[[SAMP]])
 
   // Case 1a/2c
   fnc4smp(glb_smp_const);
-  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
+  // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
   // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* 
[[SAMP]])
 
   // Case 1c
@@ -70,12 +70,12 @@
   // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* 
[[SAMP]])
 
   fnc4smp(5);
-  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 5)
+  // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 5)
   // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* 
[[SAMP]])
 
   const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
   fnc4smp(const_smp);
-   // CHECK: [[CONST_SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
+   // CHECK: [[CONST_SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t 
addrspace(2)* @__translate_sampler_initializer(i32 35)
   // CHECK: store %opencl.sampler_t addrspace(2)* [[CONST_SAMP]], 
%opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR:%[a-zA-Z0-9]+]]
   fnc4smp(const_smp);
   // CHECK: [[SAMP:%[0-9]+]] = load %opencl.sampler_t addrspace(2)*, 
%opencl.sampler_t addrspace(2)** [[CONST_SMP_PTR]]
@@ -83,7 +83,7 @@
 
   constant sampler_t constant_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
   fnc4smp(constant_smp);
-  // CHECK: [[SAMP:%[0-9]+]] = call %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
+  // CHECK: [[SAMP:%[0-9]+]] = call spir_func %opencl.sampler_t addrspace(2)* 
@__translate_sampler_initializer(i32 35)
   // CHECK: call spir_func void [[FUNCNAME]](%opencl.sampler_t addrspace(2)* 
[[SAMP]])
 
   // TODO: enable sampler initialization with non-constant integer.
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -6258,15 +6258,17 @@
 
   return *SanStats;
 }
+
 llvm::Value *
 CodeGenModule::createOpenCLIntToSamplerConversion(const Expr *E,
   CodeGenFunction &CGF) {
   llvm::Constant *C = ConstantEmitter(CGF).emitAbstract(E, E->getType());
-  auto SamplerT = getOpenCLRuntime().getSamplerType(E->getType().getTypePtr());
-  auto FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false);
-  return CGF.Builder.CreateCall(CreateRuntimeFunction(FTy,
-"__translate_sampler_initializer"),
-{C});
+  auto *SamplerT = 
getOpenCLRuntime().getSamplerType(E->getType().getTypePtr());
+  auto *FTy = llvm::FunctionType::get(SamplerT, {C->getType()}, false);
+  auto *Call = CGF.Builder.CreateCall(
+  CreateRuntimeFunction(FTy, "__translate_sampler_initializer"), {C});
+  Call->setCallingConv(Call->getCalledFunction()->getCallingConv());
+  return Call;
 }
 
 CharUnits CodeGenModule::getNaturalPointeeTypeAlignment(


Index: clang/test/CodeGenOpenCL/sampler.cl
===
--- clang/test/CodeGenOpenCL/sampler.cl
+++ clang/test/CodeGenOpenCL/sampler.cl
@@ -39,7 +3

[clang] 9628cb1 - [NFC] Use higher level constructs to check for whitespace/newlines in the lexer

2021-03-15 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-03-15T18:27:19+01:00
New Revision: 9628cb1feef63d764c57fd0652016f9188000e2f

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

LOG: [NFC] Use higher level constructs to check for whitespace/newlines in the 
lexer

It turns out that according to valgrind and perf, it's also slightly faster.

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

Added: 


Modified: 
clang/lib/Lex/Lexer.cpp

Removed: 




diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index e63574e306fb..75c0fb65f5b1 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -2061,7 +2061,7 @@ bool Lexer::LexAngledStringLiteral(Token &Result, const 
char *CurPtr) {
 if (C == '\\')
   C = getAndAdvanceChar(CurPtr, Result);
 
-if (C == '\n' || C == '\r' ||// Newline.
+if (isVerticalWhitespace(C) ||   // Newline.
 (C == 0 && (CurPtr - 1 == BufferEnd))) { // End of file.
   // If the filename is unterminated, then it must just be a lone <
   // character.  Return this as such.
@@ -3208,10 +3208,10 @@ bool Lexer::LexTokenInternal(Token &Result, bool 
TokAtPhysicalStartOfLine) {
   const char *CurPtr = BufferPtr;
 
   // Small amounts of horizontal whitespace is very common between tokens.
-  if ((*CurPtr == ' ') || (*CurPtr == '\t')) {
-++CurPtr;
-while ((*CurPtr == ' ') || (*CurPtr == '\t'))
+  if (isHorizontalWhitespace(*CurPtr)) {
+do {
   ++CurPtr;
+} while (isHorizontalWhitespace(*CurPtr));
 
 // If we are keeping whitespace and other tokens, just return what we just
 // skipped.  The next lexer invocation will return the token after the



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


[PATCH] D98637: [NFC] Use higher level constructs to check for whitespace/newlines in the lexer

2021-03-15 Thread serge 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 rG9628cb1feef6: [NFC] Use higher level constructs to check for 
whitespace/newlines in the lexer (authored by serge-sans-paille).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98637

Files:
  clang/lib/Lex/Lexer.cpp


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2061,7 +2061,7 @@
 if (C == '\\')
   C = getAndAdvanceChar(CurPtr, Result);
 
-if (C == '\n' || C == '\r' ||// Newline.
+if (isVerticalWhitespace(C) ||   // Newline.
 (C == 0 && (CurPtr - 1 == BufferEnd))) { // End of file.
   // If the filename is unterminated, then it must just be a lone <
   // character.  Return this as such.
@@ -3208,10 +3208,10 @@
   const char *CurPtr = BufferPtr;
 
   // Small amounts of horizontal whitespace is very common between tokens.
-  if ((*CurPtr == ' ') || (*CurPtr == '\t')) {
-++CurPtr;
-while ((*CurPtr == ' ') || (*CurPtr == '\t'))
+  if (isHorizontalWhitespace(*CurPtr)) {
+do {
   ++CurPtr;
+} while (isHorizontalWhitespace(*CurPtr));
 
 // If we are keeping whitespace and other tokens, just return what we just
 // skipped.  The next lexer invocation will return the token after the


Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2061,7 +2061,7 @@
 if (C == '\\')
   C = getAndAdvanceChar(CurPtr, Result);
 
-if (C == '\n' || C == '\r' ||// Newline.
+if (isVerticalWhitespace(C) ||   // Newline.
 (C == 0 && (CurPtr - 1 == BufferEnd))) { // End of file.
   // If the filename is unterminated, then it must just be a lone <
   // character.  Return this as such.
@@ -3208,10 +3208,10 @@
   const char *CurPtr = BufferPtr;
 
   // Small amounts of horizontal whitespace is very common between tokens.
-  if ((*CurPtr == ' ') || (*CurPtr == '\t')) {
-++CurPtr;
-while ((*CurPtr == ' ') || (*CurPtr == '\t'))
+  if (isHorizontalWhitespace(*CurPtr)) {
+do {
   ++CurPtr;
+} while (isHorizontalWhitespace(*CurPtr));
 
 // If we are keeping whitespace and other tokens, just return what we just
 // skipped.  The next lexer invocation will return the token after the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4aa510b - Allow __ieee128 as an alias to __float128 on ppc

2021-03-15 Thread via cfe-commits

Author: serge-sans-paille
Date: 2021-03-15T18:28:26+01:00
New Revision: 4aa510be78a75a4da82657fe433016f00dad0784

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

LOG: Allow __ieee128 as an alias to __float128 on ppc

This matches gcc behavior.

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/lib/Basic/IdentifierTable.cpp
clang/lib/Basic/Targets/PPC.cpp
clang/test/Sema/128bitfloat.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 620b0899507a2..7efc661002fe7 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -109,6 +109,7 @@ LANGOPT(Bool  , 1, 0, "bool, true, and false 
keywords")
 LANGOPT(Half  , 1, 0, "half keyword")
 LANGOPT(WChar , 1, CPlusPlus, "wchar_t keyword")
 LANGOPT(Char8 , 1, 0, "char8_t keyword")
+LANGOPT(IEEE128   , 1, 0, "__ieee128 keyword")
 LANGOPT(DeclSpecKeyword   , 1, 0, "__declspec keyword")
 BENIGN_LANGOPT(DollarIdents   , 1, 1, "'$' in identifiers")
 BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")

diff  --git a/clang/lib/Basic/IdentifierTable.cpp 
b/clang/lib/Basic/IdentifierTable.cpp
index 51c6e02e2e2e0..cedc94a935504 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -227,6 +227,9 @@ void IdentifierTable::AddKeywords(const LangOptions 
&LangOpts) {
   if (LangOpts.DeclSpecKeyword)
 AddKeyword("__declspec", tok::kw___declspec, KEYALL, LangOpts, *this);
 
+  if (LangOpts.IEEE128)
+AddKeyword("__ieee128", tok::kw___float128, KEYALL, LangOpts, *this);
+
   // Add the 'import' contextual keyword.
   get("import").setModulesImport(true);
 }

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 73ecc05f20154..78397abfe1f5e 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -566,6 +566,7 @@ void PPCTargetInfo::adjust(LangOptions &Opts) {
 LongDoubleFormat = Opts.PPCIEEELongDouble
? &llvm::APFloat::IEEEquad()
: &llvm::APFloat::PPCDoubleDouble();
+  Opts.IEEE128 = 1;
 }
 
 ArrayRef PPCTargetInfo::getTargetBuiltins() const {

diff  --git a/clang/test/Sema/128bitfloat.cpp b/clang/test/Sema/128bitfloat.cpp
index 4a826b479d017..6a9ae743c6f06 100644
--- a/clang/test/Sema/128bitfloat.cpp
+++ b/clang/test/Sema/128bitfloat.cpp
@@ -6,6 +6,13 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -verify -std=c++11 %s
 
 #if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
+
+#if defined(__ppc__)
+template  struct __is_float128 { static constexpr bool value = 
false; };
+template <> struct __is_float128<__float128> { static constexpr bool value = 
true; };
+static_assert(__is_float128<__ieee128>::value, "__ieee128 aliases to 
__float128");
+#endif
+
 __float128 f;
 template struct __is_floating_point_helper {};
 template<> struct __is_floating_point_helper<__float128> {};



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


  1   2   >