[clang] 12665f2 - [X86] Make XSAVEC/XSAVEOPT/XSAVES properly depend on XSAVE in both the frontend and the backend.

2020-06-26 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-06-26T00:14:58-07:00
New Revision: 12665f28129a7aefc635dc36d6fe0ad26583dd8a

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

LOG: [X86] Make XSAVEC/XSAVEOPT/XSAVES properly depend on XSAVE in both the 
frontend and the backend.

These features implicitly enabled XSAVE in the frontend, but not
the backend. Disabling XSAVE in the frontend disabled XSAVEOPT, but
not the other 2. Nothing happened in the backend.

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp
clang/test/Preprocessor/x86_target_features.c
llvm/lib/Target/X86/X86.td

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 184090fe104f..22ed922e678e 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -712,7 +712,7 @@ void 
X86TargetInfo::setFeatureEnabledImpl(llvm::StringMap &Features,
   setSSELevel(Features, SSE41, Enabled);
   } else if (Name == "xsave") {
 if (!Enabled)
-  Features["xsaveopt"] = false;
+  Features["xsaveopt"] = Features["xsavec"] = Features["xsaves"] = false;
   } else if (Name == "xsaveopt" || Name == "xsavec" || Name == "xsaves") {
 if (Enabled)
   Features["xsave"] = true;

diff  --git a/clang/test/Preprocessor/x86_target_features.c 
b/clang/test/Preprocessor/x86_target_features.c
index 6f3c0cffb17e..dc7c8109b4da 100644
--- a/clang/test/Preprocessor/x86_target_features.c
+++ b/clang/test/Preprocessor/x86_target_features.c
@@ -417,9 +417,11 @@
 // XSAVES: #define __XSAVES__ 1
 // XSAVES: #define __XSAVE__ 1
 
-// RUN: %clang -target i386-unknown-unknown -march=atom -mxsaveopt -mno-xsave 
-x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=NOXSAVE %s
+// RUN: %clang -target i386-unknown-unknown -march=atom -mxsaveopt -mxsavec 
-mxsaves -mno-xsave -x c -E -dM -o - %s | FileCheck -match-full-lines 
--check-prefix=NOXSAVE %s
 
+// NOXSAVE-NOT: #define __XSAVEC__ 1
 // NOXSAVE-NOT: #define __XSAVEOPT__ 1
+// NOXSAVE-NOT: #define __XSAVES__ 1
 // NOXSAVE-NOT: #define __XSAVE__ 1
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -mclflushopt -x c -E 
-dM -o - %s | FileCheck -match-full-lines --check-prefix=CLFLUSHOPT %s

diff  --git a/llvm/lib/Target/X86/X86.td b/llvm/lib/Target/X86/X86.td
index 3e85d4ab2a4c..d68fb970b571 100644
--- a/llvm/lib/Target/X86/X86.td
+++ b/llvm/lib/Target/X86/X86.td
@@ -52,13 +52,16 @@ def FeatureXSAVE   : SubtargetFeature<"xsave", "HasXSAVE", 
"true",
"Support xsave instructions">;
 
 def FeatureXSAVEOPT: SubtargetFeature<"xsaveopt", "HasXSAVEOPT", "true",
-   "Support xsaveopt instructions">;
+   "Support xsaveopt instructions",
+   [FeatureXSAVE]>;
 
 def FeatureXSAVEC  : SubtargetFeature<"xsavec", "HasXSAVEC", "true",
-   "Support xsavec instructions">;
+   "Support xsavec instructions",
+   [FeatureXSAVE]>;
 
 def FeatureXSAVES  : SubtargetFeature<"xsaves", "HasXSAVES", "true",
-   "Support xsaves instructions">;
+   "Support xsaves instructions",
+   [FeatureXSAVE]>;
 
 def FeatureSSE1: SubtargetFeature<"sse", "X86SSELevel", "SSE1",
   "Enable SSE instructions">;



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


[clang] ae47d15 - Remove "rm -f" workaround in acle_sve_adda.c

2020-06-26 Thread David Sherwood via cfe-commits

Author: David Sherwood
Date: 2020-06-26T08:16:40+01:00
New Revision: ae47d158a096abad43d8f9056518d83b66c5a4b7

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

LOG: Remove "rm -f" workaround in acle_sve_adda.c

Added: 


Modified: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c
index 9d9c33a891cd..853da8783faa 100644
--- a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c
@@ -1,5 +1,4 @@
 // REQUIRES: aarch64-registered-target
-// RUN: rm -f -- %S/acle_sve_adda.s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s
 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null 2>%t



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


[PATCH] D82501: [sve][acle] Add reinterpret intrinsics for brain float.

2020-06-26 Thread David Sherwood via Phabricator via cfe-commits
david-arm accepted this revision.
david-arm added a comment.
This revision is now accepted and ready to land.

Can you remove the duplicate tests before submitting? Otherwise LGTM!




Comment at: llvm/test/CodeGen/AArch64/sve-bitcast-bfloat.ll:8
+
+define  @bitcast_bfloat_to_i8( %v) {
+; CHECK-LABEL: bitcast_bfloat_to_i8:

Aren't these tests all duplicates of ones in 
llvm/test/CodeGen/AArch64/sve-bitcast.ll? Looks like you can remove this file 
completely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82501



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


[PATCH] D82498: [SourceManager] don't check invalid param of getLocalSLocEntry()

2020-06-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82498



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


[PATCH] D82312: Add `CharLiteral` to SyntaxTree

2020-06-26 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added a comment.

In D82312#2116028 , @vvereschaka wrote:

> Hello Eduardo,
>
> sorry, but one of your these commits break the clang unit tests on the 
> following builders:
>
> - http://lab.llvm.org:8011/builders/llvm-clang-x86_64-win-fast/builds/18313
> - http://lab.llvm.org:8011/builders/llvm-clang-win-x-aarch64/builds/256
> - http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l/builds/96
>
>   with the following errors: ``` FAILED: 
> tools/clang/unittests/Tooling/Syntax/CMakeFiles/SyntaxTests.dir/TreeTest.cpp.obj
>  
> C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\cl.exe
>   /nologo /TP -DGTEST_HAS_RTTI=0 -DGTEST_HAS_TR1_TUPLE=0 -DGTEST_LANG_CXX11=1 
> -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
> -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GNU_SOURCE 
> -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS 
> -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
> -D__STDC_LIMIT_MACROS -Itools\clang\unittests\Tooling\Syntax 
> -IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax
>  
> -IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\include
>  -Itools\clang\include -Iinclude 
> -IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\include
>  
> -IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\utils\unittest\googletest\include
>  
> -IC:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\utils\unittest\googlemock\include
>  /DWIN32 /D_WINDOWS   /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 
>  -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 
> -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 
> -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 
> -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 
> -wd4709 -wd4324 -w14062 -we4238 /Gw /MD /O2 
>  /Ob2 /DNDEBUG/EHs-c- /GR- 
> -std:c++14 /showIncludes 
> /Fotools\clang\unittests\Tooling\Syntax\CMakeFiles\SyntaxTests.dir\TreeTest.cpp.obj
>  /Fdtools\clang\unittests\Tooling\Syntax\CMakeFiles\SyntaxTests.dir\ /FS -c 
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp
>  
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
>  error C2017: illegal escape sequence 
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
>  error C2146: syntax error: missing ')' before identifier 'n' 
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
>  error C2660: 'testing::internal::GetBoolAssertionFailureMessage': function 
> does not take 2 arguments 
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\llvm\utils\unittest\googletest\include\gtest/internal/gtest-internal.h(226):
>  note: see declaration of 'testing::internal::GetBoolAssertionFailureMessage' 
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
>  error C2440: '': cannot convert from 'initializer list' 
> to 'testing::internal::AssertHelper' 
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
>  note: No constructor could take the source type, or constructor overload 
> resolution was ambiguous 
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
>  error C2146: syntax error: missing ';' before identifier 'n' 
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
>  error C2059: syntax error: ')' 
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
>  error C2065: 'n': undeclared identifier 
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1665):
>  error C2146: syntax error: missing ';' before identifier 'SyntaxTree' 
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
>  error C2065: 'SyntaxTree': undeclared identifier 
> C:\buildbot\as-builder-3\llvm-clang-x86_64-win-fast\llvm-project\clang\unittests\Tooling\Syntax\TreeTest.cpp(1639):
>  error C2143: syntax error: missing ';' before 'string' ``` see more details 
> here: 
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-win-fast/builds/18313/steps/test-check-clang-unit/logs/stdio
>
>   I mean the following commits: *221d7bbe49cceb0e408f0f46d9f8371e6c9fee2c 
> 

[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-06-26 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/include/clang/Format/Format.h:533
 
+  /// If ``true``, always break before concept declarations
+  bool AlwaysBreakBeforeConceptDeclarations;

It would be nice to have an example here in the doc.



Comment at: clang/unittests/Format/FormatTest.cpp:13540
   CHECK_PARSE_BOOL(AlignConsecutiveMacros);
+  CHECK_PARSE_BOOL(AlwaysBreakBeforeConceptDeclarations);
   CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);

Format: leading whitespace. Should it be in the same "group" as 
`AlignConsecutiveMacros`?



Comment at: clang/unittests/Format/FormatTest.cpp:16745
+   "::std::is_copy_constructable and "
+   "::std::is_move_constructable and\n"
+   "requires (T c) {\n"

Isn't it a strange indentation?


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

https://reviews.llvm.org/D79773



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


[PATCH] D82497: [Clang][SourceManager] optimize getFileIDLocal()

2020-06-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

For the record: 
http://llvm-compile-time-tracker.com/compare.php?from=ed8184b7814df4310dbad065a9a1c3bb8f3bfa86&to=408efffbe4a52bae05f1677a47eb3ccfd5cdc1d3&stat=instructions

https://photos.app.goo.gl/fJUS5jrMaJjvvmo1A


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82497



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


[PATCH] D82626: [CodeComplete] Tweak completion for else.

2020-06-26 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: sammccall, kadircet.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If an `if` statement uses braces for its `then` block, suggest braces for the 
`else` and `else if` completion blocks, Otherwise don't suggest them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82626

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaCodeComplete.cpp

Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -5743,7 +5743,7 @@
   CodeCompleteExpression(S, Data);
 }
 
-void Sema::CodeCompleteAfterIf(Scope *S) {
+void Sema::CodeCompleteAfterIf(Scope *S, bool IsBracedThen) {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
 CodeCompleter->getCodeCompletionTUInfo(),
 mapCodeCompletionContext(*this, PCC_Statement));
@@ -5760,15 +5760,28 @@
   // "else" block
   CodeCompletionBuilder Builder(Results.getAllocator(),
 Results.getCodeCompletionTUInfo());
+
+  auto AddCodePatterns = [&] {
+if (IsBracedThen) {
+  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Builder.AddChunk(CodeCompletionString::CK_LeftBrace);
+  Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
+  Builder.AddPlaceholderChunk("statements");
+  Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
+  Builder.AddChunk(CodeCompletionString::CK_RightBrace);
+} else {
+  // HorizontalSpace so the hint looks like 'else statement' instead of
+  // 'elsestatement'.
+  // FIXME, would be nicer if there was a CK_IndentationSpace option that
+  // would add the correct number of tabs/spaces.
+  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
+  Builder.AddPlaceholderChunk("statement");
+}
+  };
   Builder.AddTypedTextChunk("else");
-  if (Results.includeCodePatterns()) {
-Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-Builder.AddChunk(CodeCompletionString::CK_LeftBrace);
-Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
-Builder.AddPlaceholderChunk("statements");
-Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
-Builder.AddChunk(CodeCompletionString::CK_RightBrace);
-  }
+  if (Results.includeCodePatterns())
+AddCodePatterns();
   Results.AddResult(Builder.TakeString());
 
   // "else if" block
@@ -5781,12 +5794,7 @@
 Builder.AddPlaceholderChunk("expression");
   Builder.AddChunk(CodeCompletionString::CK_RightParen);
   if (Results.includeCodePatterns()) {
-Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-Builder.AddChunk(CodeCompletionString::CK_LeftBrace);
-Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
-Builder.AddPlaceholderChunk("statements");
-Builder.AddChunk(CodeCompletionString::CK_VerticalSpace);
-Builder.AddChunk(CodeCompletionString::CK_RightBrace);
+AddCodePatterns();
   }
   Results.AddResult(Builder.TakeString());
 
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -1348,6 +1348,8 @@
   if (IsConstexpr)
 ConstexprCondition = Cond.getKnownValue();
 
+  bool IsBracedThen = Tok.is(tok::l_brace);
+
   // C99 6.8.4p3 - In C99, the body of the if statement is a scope, even if
   // there is no compound stmt.  C90 does not have this clause.  We only do this
   // if the body isn't a compound statement to avoid push/pop in common cases.
@@ -1366,7 +1368,7 @@
   //would have to notify ParseStatement not to create a new scope. It's
   //simpler to let it create a new scope.
   //
-  ParseScope InnerScope(this, Scope::DeclScope, C99orCXX, Tok.is(tok::l_brace));
+  ParseScope InnerScope(this, Scope::DeclScope, C99orCXX, IsBracedThen);
 
   MisleadingIndentationChecker MIChecker(*this, MSK_if, IfLoc);
 
@@ -1427,7 +1429,7 @@
 // Pop the 'else' scope if needed.
 InnerScope.Exit();
   } else if (Tok.is(tok::code_completion)) {
-Actions.CodeCompleteAfterIf(getCurScope());
+Actions.CodeCompleteAfterIf(getCurScope(), IsBracedThen);
 cutOffParsing();
 return StmtError();
   } else if (InnerStatementTrailingElseLoc.isValid()) {
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -11922,7 +11922,7 @@
   void CodeCompleteDesignator(const QualType BaseType,
   llvm::ArrayRef InitExprs,
   const Designation &D);
-  void CodeCompleteAfterIf(Scope *S);
+  void CodeCompleteAfterIf(Scope *S, bool IsB

[PATCH] D82620: [clang-format] Preserve whitespace in selected macros

2020-06-26 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2706
+
+  For example: STRINGIZE
+

Shouldn't there be a configuration example like what's in `ForEachMacros` doc?
```
  In the .clang-format configuration file, this can be configured like:

  .. code-block:: yaml

WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']

  For example: BOOST_PP_STRINGIZE.
```




Comment at: clang/lib/Format/FormatTokenLexer.cpp:46-49
+  for (const std::string &WhitespaceSensitiveMacro :
+   Style.WhitespaceSensitiveMacros)
+Macros.insert(
+{&IdentTable.get(WhitespaceSensitiveMacro), TT_UntouchableMacroFunc});

Personally I would add braces around the loop body.



Comment at: clang/unittests/Format/FormatTest.cpp:13961
+  Style.WhitespaceSensitiveMacros.clear();
+  CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE]",
+  WhitespaceSensitiveMacros, 
std::vector{"STRINGIZE"});

Shouldn't that be:
`CHECK_PARSE("WhitespaceSensitiveMacros: ['STRINGIZE']",`
as in other options that take vector of strings?



Comment at: clang/unittests/Format/FormatTest.cpp:13963
+  WhitespaceSensitiveMacros, 
std::vector{"STRINGIZE"});
+  CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE, ASSERT]",
+  WhitespaceSensitiveMacros,

Ditto: apostrophes around strings.



Comment at: clang/unittests/Format/FormatTest.cpp:16482
+  // and these are all whitespace sensitive by definition
+  EXPECT_EQ("FOO(String-ized&Messy+But(: :Still)=Intentional);",
+format("FOO(String-ized&Messy+But(: :Still)=Intentional);", 
Style));

How about a test with escaped parentheses `\(` inside the macro argument?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82620



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


[clang-tools-extra] 1a30eab - Prevent unused error when assertions are disabled.

2020-06-26 Thread Tres Popp via cfe-commits

Author: Tres Popp
Date: 2020-06-26T10:12:04+02:00
New Revision: 1a30eab413cefb18e733ef6aec42dc04a4a76592

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

LOG: Prevent unused error when assertions are disabled.

Added: 


Modified: 
clang-tools-extra/clangd/ConfigYAML.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ConfigYAML.cpp 
b/clang-tools-extra/clangd/ConfigYAML.cpp
index ee3331df8694..8575356132ca 100644
--- a/clang-tools-extra/clangd/ConfigYAML.cpp
+++ b/clang-tools-extra/clangd/ConfigYAML.cpp
@@ -80,8 +80,10 @@ class Parser {
 // It should emit diagnostics if the value is invalid (e.g. wrong type).
 // If Key is seen twice, Parse runs only once and an error is reported.
 void handle(llvm::StringLiteral Key, std::function Parse) {
-  for (const auto &Entry : Keys)
+  for (const auto &Entry : Keys) {
+(void) Entry;
 assert(Entry.first != Key && "duplicate key handler");
+  }
   Keys.emplace_back(Key, std::move(Parse));
 }
 



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


[PATCH] D82561: [analyzer][CrossTU] Lower CTUImportThreshold default value

2020-06-26 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

In D82561#2116091 , @balazske wrote:

> In D82561#2115578 , @xazax.hun wrote:
>
> > The analyzer inlines small functions within a TU regardless of the 
> > thresholds. I think it would be sensible to do the same across TUs in the 
> > case we don't do this already.
>
>
> That means perform a get CTU definition if the TU to be imported (where the 
> function comes from) is small? Otherwise it does not matter how small the 
> function is, it can result in importing of large amount of code. Determining 
> parameters (like "smallness") of the TU is probably not simple.


Measuring the smallness of a function is currently not trivial if the function 
is in another TU. But theoretically, the creation process of the CTU index has 
access to the number of declarations in a function, which could be used as a 
metric for complexity.

Another concern is memory usage. Currently I am working on a solution to 
approximate the memory usage of declarations by measuring the total memory 
usage, and the number of declarations inside a TU. Then I can come up with 
average values for memory used per declaration for projects I test. I could 
measure multiple projects per language and come up with some statistics that 
way, but I'm sure that I am not alone with the feeling that there should be a 
better metric for memory usage other than this roundabout method. All would be 
well if there were a way to get `sizeof(astunit)`, but I am not aware of any.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82561



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


[PATCH] D71491: [ubsan] Check implicit casts in ObjC for-in statements

2020-06-26 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/lib/CodeGen/CGObjC.cpp:1856
+  Selector IsKindOfClassSel = C.Selectors.getSelector(
+  llvm::array_lengthof(IsKindOfClassII), &IsKindOfClassII[0]);
+  CallArgList IsKindOfClassArgs;

Can you use `GetUnarySelector` here?



Comment at: clang/lib/CodeGen/CGObjC.cpp:1860
+  CGM.getObjCRuntime().GetClass(*this, InterfaceTy->getDecl());
+  Args.add(RValue::get(Cls), C.getObjCClassType());
+  llvm::Value *IsClass =

It looks like `Args` should be cleared before adding the argument. Or should 
the argument be added to `IsKindOfClassArg`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71491



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


[PATCH] D81676: [MSP430] Align the toolchain definition with the TI's msp430-gcc v8.3.1

2020-06-26 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Meanwhile, msp430-gcc v9.2.0 was released 
 on Jun 12. Will 
recheck against the new version slightly later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81676



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


[clang] 834c718 - [CodeComplete] Tweak code completion for `typename`.

2020-06-26 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-06-26T10:32:12+02:00
New Revision: 834c71829cc2e22841bf75e86b988c46252c70dc

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

LOG: [CodeComplete] Tweak code completion for `typename`.

Summary:
Currently, clangd always completes `typename` as `typename qualifier::name`, I 
think the current behavior is not useful when the code completion is triggered 
in `template <>`. So I tweak it to `typename identifier`.

Patch by @lh123 !

Reviewers: sammccall, kadircet

Reviewed By: kadircet

Subscribers: ilya-biryukov, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/ordinary-name-cxx11.cpp
clang/test/CodeCompletion/ordinary-name.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 913c43886b4e..8835ecc79b9f 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -1687,11 +1687,9 @@ static void AddTypeSpecifierResults(const LangOptions 
&LangOpts,
 Results.AddResult(Result("class", CCP_Type));
 Results.AddResult(Result("wchar_t", CCP_Type));
 
-// typename qualified-id
+// typename name
 Builder.AddTypedTextChunk("typename");
 Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
-Builder.AddPlaceholderChunk("qualifier");
-Builder.AddTextChunk("::");
 Builder.AddPlaceholderChunk("name");
 Results.AddResult(Result(Builder.TakeString()));
 

diff  --git a/clang/test/CodeCompletion/ordinary-name-cxx11.cpp 
b/clang/test/CodeCompletion/ordinary-name-cxx11.cpp
index e568ee1ee3d8..dcbb5ecb4f69 100644
--- a/clang/test/CodeCompletion/ordinary-name-cxx11.cpp
+++ b/clang/test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -57,7 +57,7 @@ void foo() {
   // CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : 
[#std::type_info#]typeid(<#expression-or-type#>)
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
@@ -107,7 +107,7 @@ void foo() {
   // CHECK-CC2-NEXT: COMPLETION: thread_local
   // CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
@@ -150,7 +150,7 @@ void foo() {
   // CHECK-CC3-NEXT: COMPLETION: Pattern : template<<#parameters#>>
   // CHECK-CC3-NEXT: COMPLETION: thread_local
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
-  // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC3-NEXT: COMPLETION: union
@@ -198,7 +198,7 @@ void foo() {
   // CHECK-CC4-NEXT: COMPLETION: Pattern : [#bool#]true
   // CHECK-CC4-NEXT: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC4-NEXT: COMPLETION: Pattern : 
[#std::type_info#]typeid(<#expression-or-type#>)
-  // CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC4-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC4-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC4-NEXT: COMPLETION: union
@@ -259,7 +259,7 @@ void foo() {
   // CHECK-NO-RTTI: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
   // CHECK-NO-RTTI-NOT: typeid
-  // CHECK-NO-RTTI: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-NO-RTTI: COMPLETION: Pattern : typename <#name#>
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union

diff  --git a/clang/test/CodeCompletion/ordinary-name.cpp 
b/clang/test/CodeCompletion/ordinary-name.cpp
index 3f891307bb74..a87c992d85f7 100644
--- a/clang/test/CodeCompletion/ordinary-name.cpp
+++ b/clang/test/CodeCompletion/ordinary-name.cpp
@@ -54,7 +54,7 @@ void foo() {
   // CHECK-CC1: COMP

[PATCH] D82535: [CodeComplete] Add code completion for using alias.

2020-06-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet requested changes to this revision.
kadircet added a comment.
This revision now requires changes to proceed.

this seems to be failing to merge, could you rebase on top of head?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82535



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


[PATCH] D82561: [analyzer][CrossTU] Lower CTUImportThreshold default value

2020-06-26 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def:324
 "for import when inlining functions during CTU analysis. "
 "Lowering this threshold can alleviate the memory burder of "
 "analysis with many interdependent definitions located in "

typo: burder -> burden


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82561



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


[PATCH] D82629: [libclang] Fix crash when visiting a captured VLA.

2020-06-26 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler created this revision.
ckandeler added a reviewer: milianw.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

When a variable-length array is being captured in a lambda, the AST
contains two captures, the first one having a null init expression.
Visiting that one triggers an assertion, so skip it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82629

Files:
  clang/test/Index/evaluate-cursor.cpp
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3272,7 +3272,7 @@
   }
   // Visit init captures
   for (auto InitExpr : E->capture_inits()) {
-if (Visit(InitExpr))
+if (InitExpr && Visit(InitExpr))
   return true;
   }
 
Index: clang/test/Index/evaluate-cursor.cpp
===
--- clang/test/Index/evaluate-cursor.cpp
+++ clang/test/Index/evaluate-cursor.cpp
@@ -29,6 +29,13 @@
 constexpr static int calc_val() { return 1 + 2; }
 const auto the_value = calc_val() + sizeof(char);
 
+void vlaTest()
+{
+  int msize = 4;
+  float arr[msize];
+  [&arr]{};
+}
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -65,3 +72,7 @@
 // CHECK-EXPR: Value: 3
 // CHECK-EXPR: unsigned, Value: 4
 // CHECK-EXPR: unsigned, Value: 1
+
+// RUN: c-index-test -evaluate-cursor-at=%s:36:5 \
+// RUN:-std=c++11 %s | FileCheck -check-prefix=VLA %s
+// VLA: Not Evaluatable


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3272,7 +3272,7 @@
   }
   // Visit init captures
   for (auto InitExpr : E->capture_inits()) {
-if (Visit(InitExpr))
+if (InitExpr && Visit(InitExpr))
   return true;
   }
 
Index: clang/test/Index/evaluate-cursor.cpp
===
--- clang/test/Index/evaluate-cursor.cpp
+++ clang/test/Index/evaluate-cursor.cpp
@@ -29,6 +29,13 @@
 constexpr static int calc_val() { return 1 + 2; }
 const auto the_value = calc_val() + sizeof(char);
 
+void vlaTest()
+{
+  int msize = 4;
+  float arr[msize];
+  [&arr]{};
+}
+
 // RUN: c-index-test -evaluate-cursor-at=%s:4:7 \
 // RUN:-evaluate-cursor-at=%s:8:7 \
 // RUN:-evaluate-cursor-at=%s:8:11 -std=c++11 %s | FileCheck %s
@@ -65,3 +72,7 @@
 // CHECK-EXPR: Value: 3
 // CHECK-EXPR: unsigned, Value: 4
 // CHECK-EXPR: unsigned, Value: 1
+
+// RUN: c-index-test -evaluate-cursor-at=%s:36:5 \
+// RUN:-std=c++11 %s | FileCheck -check-prefix=VLA %s
+// VLA: Not Evaluatable
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82373: [CodeComplete] Tweak code completion for `typename`.

2020-06-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG834c71829cc2: [CodeComplete] Tweak code completion for 
`typename`. (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82373

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ordinary-name-cxx11.cpp
  clang/test/CodeCompletion/ordinary-name.cpp

Index: clang/test/CodeCompletion/ordinary-name.cpp
===
--- clang/test/CodeCompletion/ordinary-name.cpp
+++ clang/test/CodeCompletion/ordinary-name.cpp
@@ -54,7 +54,7 @@
   // CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
@@ -97,7 +97,7 @@
   // CHECK-CC2-NEXT: COMPLETION: Pattern : template<<#parameters#>>
   // CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
@@ -134,7 +134,7 @@
   // CHECK-CC3-NEXT: COMPLETION: struct
   // CHECK-CC3-NEXT: COMPLETION: Pattern : template<<#parameters#>>
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
-  // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC3-NEXT: COMPLETION: union
@@ -176,7 +176,7 @@
   // CHECK-CC4-NEXT: COMPLETION: Pattern : [#bool#]true
   // CHECK-CC4-NEXT: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC4-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
-  // CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC4-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC4-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC4-NEXT: COMPLETION: union
@@ -227,7 +227,7 @@
   // CHECK-NO-RTTI: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
   // CHECK-NO-RTTI-NOT: typeid
-  // CHECK-NO-RTTI: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-NO-RTTI: COMPLETION: Pattern : typename <#name#>
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
Index: clang/test/CodeCompletion/ordinary-name-cxx11.cpp
===
--- clang/test/CodeCompletion/ordinary-name-cxx11.cpp
+++ clang/test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -57,7 +57,7 @@
   // CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
@@ -107,7 +107,7 @@
   // CHECK-CC2-NEXT: COMPLETION: thread_local
   // CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC2-NEXT: COMPLETION: union
@@ -150,7 +150,7 @@
   // CHECK-CC3-NEXT: COMPLETION: Pattern : template<<#parameters#>>
   // CHECK-CC3-NEXT: COMPLETION: thread_local
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
-  // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#name#>
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof(<#type#>)

[PATCH] D82631: [AST][RecoveryAST] Avoid spurious 'missing typename' diagnostic when the NNS contains errors.

2020-06-26 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82631

Files:
  clang/include/clang/AST/NestedNameSpecifier.h
  clang/lib/AST/NestedNameSpecifier.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaTemplate/missing-typename-recovery.cpp


Index: clang/test/SemaTemplate/missing-typename-recovery.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/missing-typename-recovery.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// There should be no extra errors about missing 'typename' keywords.
+void f() {
+  decltype(undef())::Type T; // expected-error {{use of undeclared identifier}}
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -750,7 +750,10 @@
 Diag(IILoc, IsTemplateName ? diag::err_no_member_template
: diag::err_typename_nested_not_found)
 << II << DC << SS->getRange();
-  else if (isDependentScopeSpecifier(*SS)) {
+  else if (SS->isValid() && SS->getScopeRep()->containsErrors()) {
+SuggestedType =
+ActOnTypenameType(S, SourceLocation(), *SS, *II, IILoc).get();
+  } else if (isDependentScopeSpecifier(*SS)) {
 unsigned DiagID = diag::err_typename_missing;
 if (getLangOpts().MSVCCompat && isMicrosoftMissingTypename(SS, S))
   DiagID = diag::ext_typename_missing;
Index: clang/lib/AST/NestedNameSpecifier.cpp
===
--- clang/lib/AST/NestedNameSpecifier.cpp
+++ clang/lib/AST/NestedNameSpecifier.cpp
@@ -243,6 +243,10 @@
   return getDependence() & NestedNameSpecifierDependence::UnexpandedPack;
 }
 
+bool NestedNameSpecifier::containsErrors() const {
+  return getDependence() & NestedNameSpecifierDependence::Error;
+}
+
 /// Print this nested name specifier to the given output
 /// stream.
 void NestedNameSpecifier::print(raw_ostream &OS, const PrintingPolicy &Policy,
Index: clang/include/clang/AST/NestedNameSpecifier.h
===
--- clang/include/clang/AST/NestedNameSpecifier.h
+++ clang/include/clang/AST/NestedNameSpecifier.h
@@ -214,6 +214,9 @@
   /// parameter pack (for C++11 variadic templates).
   bool containsUnexpandedParameterPack() const;
 
+  /// Whether this nested name specifier contains an error.
+  bool containsErrors() const;
+
   /// Print this nested name specifier to the given output stream. If
   /// `ResolveTemplateArguments` is true, we'll print actual types, e.g.
   /// `ns::SomeTemplate` instead of


Index: clang/test/SemaTemplate/missing-typename-recovery.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/missing-typename-recovery.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// There should be no extra errors about missing 'typename' keywords.
+void f() {
+  decltype(undef())::Type T; // expected-error {{use of undeclared identifier}}
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -750,7 +750,10 @@
 Diag(IILoc, IsTemplateName ? diag::err_no_member_template
: diag::err_typename_nested_not_found)
 << II << DC << SS->getRange();
-  else if (isDependentScopeSpecifier(*SS)) {
+  else if (SS->isValid() && SS->getScopeRep()->containsErrors()) {
+SuggestedType =
+ActOnTypenameType(S, SourceLocation(), *SS, *II, IILoc).get();
+  } else if (isDependentScopeSpecifier(*SS)) {
 unsigned DiagID = diag::err_typename_missing;
 if (getLangOpts().MSVCCompat && isMicrosoftMissingTypename(SS, S))
   DiagID = diag::ext_typename_missing;
Index: clang/lib/AST/NestedNameSpecifier.cpp
===
--- clang/lib/AST/NestedNameSpecifier.cpp
+++ clang/lib/AST/NestedNameSpecifier.cpp
@@ -243,6 +243,10 @@
   return getDependence() & NestedNameSpecifierDependence::UnexpandedPack;
 }
 
+bool NestedNameSpecifier::containsErrors() const {
+  return getDependence() & NestedNameSpecifierDependence::Error;
+}
+
 /// Print this nested name specifier to the given output
 /// stream.
 void NestedNameSpecifier::print(raw_ostream &OS, const PrintingPolicy &Policy,
Index: clang/include/clang/AST/NestedNameSpecifier.h
===
--- clang/include/clang/AST/NestedNameSpecifier.h
+++ clang/include/clang/AST/NestedNameSpecifier.h
@@ -214,6 +214,9 @@
   /// parameter pack (for C++11 variadic templates).
   bool containsUnexpandedParameterPack() const;
 
+  /// Whether this nested name specifier contains an error.
+  bool containsErrors() const;
+
   ///

[PATCH] D82561: [analyzer][CrossTU] Lower CTUImportThreshold default value

2020-06-26 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In D82561#2116194 , @gamesh411 wrote:

> In D82561#2116091 , @balazske wrote:
>
> > That means perform a get CTU definition if the TU to be imported (where the 
> > function comes from) is small? Otherwise it does not matter how small the 
> > function is, it can result in importing of large amount of code. 
> > Determining parameters (like "smallness") of the TU is probably not simple.
>
>
> Measuring the smallness of a function is currently not trivial if the 
> function is in another TU. But theoretically, the creation process of the CTU 
> index has access to the number of declarations in a function, which could be 
> used as a metric for complexity.


The number of declarations is not a good proxy for complexity. 
We talk about 3 calculations here:

1. Loading the TU from disk (which might involve parsing in case the analysis 
is on demand)
2. Merging the AST sub"trees"
3. Actual inline analysis

1-2 Is cached and the complexity of 2 is largely determined by the number of 
dependencies in a declaration. I suspect that the number of declarations in a 
function is not a good estimate of the number of unmerged dependencies (classes 
and so on).

For 3, we have the CFG node size as a complexity estimate.

The question is how the processing time is split between all these phases.

> Another concern is memory usage. Currently I am working on a solution to 
> approximate the memory usage of declarations by measuring the total memory 
> usage, and the number of declarations inside a TU. Then I can come up with 
> average values for memory used per declaration for projects I test. I could 
> measure multiple projects per language and come up with some statistics that 
> way, but I'm sure that I am not alone with the feeling that there should be a 
> better metric for memory usage other than this roundabout method. All would 
> be well if there were a way to get `sizeof(astunit)`, but I am not aware of 
> any.

Yeah, loading a big TU into the memory just for a single small function might 
not be the best to do. However, when we dramatically reducing the CTU 
threshold, the analysis will be more unstable in the sense that adding a new 
function call will change the order in which we analyze functions. That will 
change the order of CTU imports. That will change the set of TUs that will be 
imported. It might not be a problem as the analyzer already can exhibit this 
behavior: a small code change can make unrelated diagnostics appear or 
disappear. But a small CTU threshold will likely make this phenomenon worse.

Just to be clear I am on board with this patch, I was merely brainstorming for 
future improvements :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82561



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


[PATCH] D82535: [CodeComplete] Add code completion for using alias.

2020-06-26 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 273631.
lh123 added a comment.

Rebase to head.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82535

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ordinary-name-cxx11.cpp
  clang/test/CodeCompletion/ordinary-name.cpp

Index: clang/test/CodeCompletion/ordinary-name.cpp
===
--- clang/test/CodeCompletion/ordinary-name.cpp
+++ clang/test/CodeCompletion/ordinary-name.cpp
@@ -59,6 +59,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
+  // CHECK-CC1-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
@@ -103,6 +104,7 @@
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC2-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
   // CHECK-CC2-NEXT: COMPLETION: volatile
@@ -140,6 +142,7 @@
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
   // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC3-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -232,6 +235,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
   // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
+  // CHECK-NO-RTTI-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: void
   // CHECK-NO-RTTI-NEXT: COMPLETION: volatile
Index: clang/test/CodeCompletion/ordinary-name-cxx11.cpp
===
--- clang/test/CodeCompletion/ordinary-name-cxx11.cpp
+++ clang/test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -62,6 +62,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
@@ -113,6 +114,7 @@
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
   // CHECK-CC2-NEXT: COMPLETION: volatile
@@ -156,6 +158,7 @@
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
   // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -264,6 +267,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
   // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: void
   // CHECK-NO-RTTI-NEXT: COMPLETION: volatile
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1816,6 +1816,18 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
+// using name = type
+static void AddUsingAliasResult(CodeCompletionBuilder &Builder,
+ResultBuilder &Results) {
+  Builder.AddTypedTextChunk("using");
+  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Builder.AddPlaceholderChunk("name");
+  Builder.AddChunk(CodeCompletionString::CK_Equal);
+  Builder.AddPlaceholderChunk("type");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+  Results.AddResult(CodeCompletionResult(Builder.TakeString()));
+}
+
 static bool WantTypesInContext(Sema::ParserCompletionContext CCC,
const LangOptions &LangOpts) {
   switch (CCC) {
@@ -2059,6 +2071,9 @@
   Builder.AddChunk(CodeCompletionSt

[PATCH] D82199: [clang-format] restore indent in conditionals when AlignOperands is DontAlign

2020-06-26 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir marked an inline comment as done.
krasimir added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:6287
+  Style.BreakBeforeTernaryOperators = false;
+  verifyFormat("int x = aaa ? aa :\n"
+   "? cc :\n"

sammccall wrote:
> aligning the question marks here is a bit weird (given DontAlign) but that's 
> another patch.
> 
> If we disable the question-column behavior with dontalign, this patch will be 
> completely dead, right?
> May want to add a FIXME to remove in that case.
Added a FIXME. I think disabling question-column alignment with dontalign 
indeed can make this patch obsolete.



Comment at: clang/unittests/Format/FormatTest.cpp:6287
+  Style.BreakBeforeTernaryOperators = false;
+  verifyFormat("int x = aaa ? aa :\n"
+   "? cc :\n"

Typz wrote:
> krasimir wrote:
> > sammccall wrote:
> > > aligning the question marks here is a bit weird (given DontAlign) but 
> > > that's another patch.
> > > 
> > > If we disable the question-column behavior with dontalign, this patch 
> > > will be completely dead, right?
> > > May want to add a FIXME to remove in that case.
> > Added a FIXME. I think disabling question-column alignment with dontalign 
> > indeed can make this patch obsolete.
> I don't think this is so weird: even with DontAlign, there are other cases 
> when some alignment is performed: for exemple when formatting tables in 
> column.
> 
> As I see it, ternary operator formatting is a similar case of 2D formatting, 
> and while it needs indeed to respect the "general" line wrapping/indent mode 
> (as per AlignOperands), it is OK to keep the alignment of the ternary 
> operator themselves : otherwise, the whole "mode" for ternary operators need 
> to be disabled and makes no sense.
> 
> But anyway this is a different patch as you mentioned, and maybe some user of 
> DontAlign can come up with a better approach for formatting ternary ops in 
> that case.
Agree, this is more of a policy / preference on how we want these snippets to 
look like with DontAlign. We should discuss it in more detail whenever we 
attempt to refine this later. In a way, this touches back on djasper's comment 
on D50078, which I believe was left unaddressed:
> I don't think the alignment of "?" and ":" (in the WhitespaceManager) should 
> be always on. I think we'd need a flag for that part


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82199



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


[PATCH] D82470: [OpenMP][IRBuilder] Support nested parallel regions

2020-06-26 Thread Anchu Rajendran S via Phabricator via cfe-commits
anchu-rajendran added a comment.
Herald added a subscriber: rogfer01.

The change looks good to me. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82470



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


[PATCH] D82598: [analyzer][Liveness][NFC] Get rid of statement liveness, because such a thing doesn't exist

2020-06-26 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

In D82598#2115656 , @NoQ wrote:

> > We could just kill all subexpr at the end of the full expression
>
> I suspect that it would be pretty bad if you, say, kill the condition of the 
> `if`-statement before picking the branch. Or kill the initializer in the 
> `DeclStmt` before putting it into the variable (same for `CXXCtorInitializer` 
> which isn't even a `Stmt`!).


I would argue that the end of the full expression is AFTER the `if` was 
evaluated in this case. But I do see what you mean, thanks :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82598



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


[clang] edcfef8 - [AArch64][SVE] Add bfloat16 support to store intrinsics

2020-06-26 Thread Kerry McLaughlin via cfe-commits

Author: Kerry McLaughlin
Date: 2020-06-26T11:05:56+01:00
New Revision: edcfef8fee134cf98e0e812a6569c4900045d31c

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

LOG: [AArch64][SVE] Add bfloat16 support to store intrinsics

Summary:
Bfloat16 support added for the following intrinsics:
 - ST1
 - STNT1

Reviewers: sdesmalen, c-rhodes, fpetrogalli, efriedma, stuij, david-arm

Reviewed By: fpetrogalli

Subscribers: tschuett, kristof.beyls, hiraditya, rkruppe, psnobl, danielkiss, 
cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_stnt1-bfloat.c

Modified: 
clang/include/clang/Basic/arm_sve.td
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/test/CodeGen/AArch64/sve-intrinsics-st1-addressing-mode-reg-imm.ll
llvm/test/CodeGen/AArch64/sve-intrinsics-st1-addressing-mode-reg-reg.ll
llvm/test/CodeGen/AArch64/sve-intrinsics-st1.ll
llvm/test/CodeGen/AArch64/sve-intrinsics-stores.ll
llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll

llvm/test/CodeGen/AArch64/sve-pred-contiguous-ldst-addressing-mode-reg-imm.ll

llvm/test/CodeGen/AArch64/sve-pred-contiguous-ldst-addressing-mode-reg-reg.ll

llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll

llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 59adbeaf645f..e2aab5f2c344 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -563,6 +563,11 @@ def SVST1H_VNUM_U : MInst<"svst1h_vnum[_{d}]", "vPFld", 
"UiUl",[IsSt
 def SVST1W_VNUM_S : MInst<"svst1w_vnum[_{d}]", "vPCld", "l",   
[IsStore], MemEltTyInt32,   "aarch64_sve_st1">;
 def SVST1W_VNUM_U : MInst<"svst1w_vnum[_{d}]", "vPGld", "Ul",  
[IsStore], MemEltTyInt32,   "aarch64_sve_st1">;
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+  def SVST1_BF  : MInst<"svst1[_{d}]",  "vPpd",  "b", [IsStore], 
MemEltTyDefault, "aarch64_sve_st1">;
+  def SVST1_VNUM_BF : MInst<"svst1_vnum[_{d}]", "vPpld", "b", [IsStore], 
MemEltTyDefault, "aarch64_sve_st1">;
+}
+
 // Store one vector (vector base)
 def SVST1_SCATTER_BASES_U : MInst<"svst1_scatter[_{2}base_{d}]",  "vPud",  
"ilUiUlfd", [IsScatterStore], MemEltTyDefault, 
"aarch64_sve_st1_scatter_scalar_offset">;
 def SVST1B_SCATTER_BASES_U: MInst<"svst1b_scatter[_{2}base_{d}]", "vPud",  
"ilUiUl",   [IsScatterStore], MemEltTyInt8,
"aarch64_sve_st1_scatter_scalar_offset">;
@@ -654,6 +659,11 @@ def SVSTNT1 : MInst<"svstnt1[_{d}]", "vPpd", 
"csilUcUsUiUlhfd", [IsStore], MemEl
 // Store one vector, with no truncation, non-temporal (scalar base, VL 
displacement)
 def SVSTNT1_VNUM : MInst<"svstnt1_vnum[_{d}]", "vPpld", "csilUcUsUiUlhfd", 
[IsStore], MemEltTyDefault, "aarch64_sve_stnt1">;
 
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+  def SVSTNT1_BF  : MInst<"svstnt1[_{d}]",  "vPpd",  "b", [IsStore], 
MemEltTyDefault, "aarch64_sve_stnt1">;
+  def SVSTNT1_VNUM_BF : MInst<"svstnt1_vnum[_{d}]", "vPpld", "b", [IsStore], 
MemEltTyDefault, "aarch64_sve_stnt1">;
+}
+
 

 // Prefetches
 

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c
new file mode 100644
index ..b3756c8f7f90
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error -verify-ignore-unexpected=note %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#def

[PATCH] D82606: [clangd] Config: config struct propagated through Context

2020-06-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/CompileCommands.cpp:187
+  // FIXME: remove const_cast once unique_function is const-compatible.
+  for (auto &Edit : const_cast(Config::current()).CompileFlags.Edits)
+Edit(Cmd);

kadircet wrote:
> what's the rationale behind applying this before any other mangling?
> 
> I can see that the rest of the mangling happens to make sure clangd works 
> out-of-the-box for "more" users, so should be safe to apply as a final step.
> But on the other hand, applying config after those would give the user full 
> control over the final command, which I believe is equally important.
I'll be honest, I don't really know which is better here. The differences are 
subtle, and there are arguments for each. I think we should probably just pick 
one and be open to changing it later.

My reasoning for this behavior: currently the user view of compile commands is 
basically "strings in compile_commands.json", and this mangling we do is best 
thought of as modifying the behavior of the driver. E.g. in an ideal world 
`-fsyntax-only` would not be a flag, we'd just use APIs that imply that 
behavior.
In this view of the world, the user is expected to understand compile commands 
+ tweaks but not the mangling, so placing tweaks after mangling means they 
can't really reason about the transformations. And it allows stripping 
structurally important things we inject like `fsyntax-only` which seems wrong.

This argument works better for some args/manglings than others, and the way we 
log args cuts against it a bit too. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82606



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


[PATCH] D82313: [OpenCL] Reject block arguments

2020-06-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


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

https://reviews.llvm.org/D82313



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


[PATCH] D82345: [sve][acle] Implement some of the C intrinsics for brain float.

2020-06-26 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added a comment.

@fpetrogalli thanks for updating! I have a few more comments, sorry I missed a 
few things yesterday




Comment at: clang/include/clang/Basic/arm_sve.td:725-727
+  def NAME   : SInst;
+  let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+def _BF16: SInst;

nit: could you fix the spacing? I don't think it's worth trying to keep the two 
defs inline, single spaces everywhere would do



Comment at: clang/include/clang/Basic/arm_sve.td:1198
 def SVDUPQ_LANE  : SInst<"svdupq_lane[_{d}]", "ddn",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_dupq_lane">;
+let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16) && 
defined(__ARM_FEATURE_BF16_SCALAR_ARITHMETIC) " in {
+  def SVDUPQ_LANE_BF16  : SInst<"svdupq_lane[_{d}]", "ddn",  "b", MergeNone, 
"aarch64_sve_dupq_lane">;

`__ARM_FEATURE_BF16_SCALAR_ARITHMETIC` can be removed



Comment at: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td:426-427
+  let Predicates = [HasSVE, HasBF16] in {
+def : Pat<(nxv8bf16 (AArch64dup (bf16 FPR16:$src))),
+  (DUP_ZZI_H (INSERT_SUBREG (IMPLICIT_DEF), FPR16:$src, hsub), 0)>;
+  }

I think we're missing a test for this pattern in 
`llvm/test/CodeGen/AArch64/sve-vector-splat.ll`? Same applies to dup 0 patterns 
below.



Comment at: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td:431-436
+  def : Pat<(nxv8f16  (AArch64dup (f16 fpimm0))),  (DUP_ZI_H 0, 0)>;
+  def : Pat<(nxv4f16  (AArch64dup (f16 fpimm0))),  (DUP_ZI_H 0, 0)>;
+  def : Pat<(nxv2f16  (AArch64dup (f16 fpimm0))),  (DUP_ZI_H 0, 0)>;
+  def : Pat<(nxv4f32  (AArch64dup (f32 fpimm0))),  (DUP_ZI_S 0, 0)>;
+  def : Pat<(nxv2f32  (AArch64dup (f32 fpimm0))),  (DUP_ZI_S 0, 0)>;
+  def : Pat<(nxv2f64  (AArch64dup (f64 fpimm0))),  (DUP_ZI_D 0, 0)>;

formatting changes can be reverted



Comment at: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td:1496-1498
+def : Pat<(nxv2i64 (bitconvert (nxv8bf16 ZPR:$src))), (nxv2i64 ZPR:$src)>;
+def : Pat<(nxv8bf16 (bitconvert (nxv2i64 ZPR:$src))), (nxv8bf16 ZPR:$src)>;
+def : Pat<(nxv8bf16 (bitconvert (nxv8i16 ZPR:$src))), (nxv8bf16 ZPR:$src)>;

missing tests in `llvm/test/CodeGen/AArch64/sve-bitcast.ll`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82345



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


[PATCH] D82578: [AArch64][SVE2] Guard while intrinsics on scalar bfloat feature macro

2020-06-26 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82578



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


[PATCH] D82312: Add `CharLiteral` to SyntaxTree

2020-06-26 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

@vvereschaka Sorry about that. It looks like a bug in MSVC. I implemented a 
workaround in https://reviews.llvm.org/D82636 -- please review if you have time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82312



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


[PATCH] D82448: [AArch64][SVE] Add bfloat16 support to store intrinsics

2020-06-26 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGedcfef8fee13: [AArch64][SVE] Add bfloat16 support to store 
intrinsics (authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82448

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_stnt1-bfloat.c
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-st1-addressing-mode-reg-imm.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-st1-addressing-mode-reg-reg.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-st1.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-stores.ll
  llvm/test/CodeGen/AArch64/sve-masked-ldst-nonext.ll
  llvm/test/CodeGen/AArch64/sve-pred-contiguous-ldst-addressing-mode-reg-imm.ll
  llvm/test/CodeGen/AArch64/sve-pred-contiguous-ldst-addressing-mode-reg-reg.ll
  
llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll
  
llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll

Index: llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll
===
--- llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll
+++ llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-reg.ll
@@ -94,6 +94,20 @@
   ret void
 }
 
+define void @test_masked_ldst_sv8bf16(bfloat* %base,  %mask, i64 %offset) nounwind #0 {
+; CHECK-LABEL: test_masked_ldst_sv8bf16:
+; CHECK-NEXT: ldnt1h { z[[DATA:[0-9]+]].h }, p0/z, [x0, x1, lsl #1]
+; CHECK-NEXT: stnt1h { z[[DATA]].h }, p0, [x0, x1, lsl #1]
+; CHECK-NEXT: ret
+  %gep = getelementptr bfloat, bfloat* %base, i64 %offset
+  %data = call  @llvm.aarch64.sve.ldnt1.nxv8bf16( %mask,
+  bfloat* %gep)
+  call void @llvm.aarch64.sve.stnt1.nxv8bf16( %data,
+  %mask,
+ bfloat* %gep)
+  ret void
+}
+
 ; 16-lane non-temporal load/stores.
 
 define void @test_masked_ldst_sv16i8(i8* %base,  %mask, i64 %offset) nounwind {
@@ -121,6 +135,7 @@
 ; 8-element non-temporal loads.
 declare  @llvm.aarch64.sve.ldnt1.nxv8i16(, i16*)
 declare  @llvm.aarch64.sve.ldnt1.nxv8f16(, half*)
+declare  @llvm.aarch64.sve.ldnt1.nxv8bf16(, bfloat*)
 
 ; 16-element non-temporal loads.
 declare  @llvm.aarch64.sve.ldnt1.nxv16i8(, i8*)
@@ -128,14 +143,18 @@
 ; 2-element non-temporal stores.
 declare void @llvm.aarch64.sve.stnt1.nxv2i64(, , i64*)
 declare void @llvm.aarch64.sve.stnt1.nxv2f64(, , double*)
-  
-; 4-element non-temporal stores.
+
+; 4-element non-temporal stores.
 declare void @llvm.aarch64.sve.stnt1.nxv4i32(, , i32*)
 declare void @llvm.aarch64.sve.stnt1.nxv4f32(, , float*)
-  
-; 8-element non-temporal stores.
+
+; 8-element non-temporal stores.
 declare void @llvm.aarch64.sve.stnt1.nxv8i16(, , i16*)
 declare void @llvm.aarch64.sve.stnt1.nxv8f16(, , half*)
+declare void @llvm.aarch64.sve.stnt1.nxv8bf16(, , bfloat*)
 
 ; 16-element non-temporal stores.
 declare void @llvm.aarch64.sve.stnt1.nxv16i8(, , i8*)
+
+; +bf16 is required for the bfloat version.
+attributes #0 = { "target-features"="+sve,+bf16" }
Index: llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll
===
--- llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll
+++ llvm/test/CodeGen/AArch64/sve-pred-non-temporal-ldst-addressing-mode-reg-imm.ll
@@ -139,6 +139,23 @@
   ret void
 }
 
+define void @test_masked_ldst_sv8bf16( * %base,  %mask) nounwind #0 {
+; CHECK-LABEL: test_masked_ldst_sv8bf16:
+; CHECK-NEXT: ldnt1h { z[[DATA:[0-9]+]].h }, p0/z, [x0, #-1, mul vl]
+; CHECK-NEXT: stnt1h { z[[DATA]].h }, p0, [x0, #2, mul vl]
+; CHECK-NEXT: ret
+  %base_load = getelementptr , * %base, i64 -1
+  %base_load_bc = bitcast * %base_load to bfloat*
+  %data = call  @llvm.aarch64.sve.ldnt1.nxv8bf16( %mask,
+  bfloat* %base_load_bc)
+  %base_store = getelementptr ,  * %base, i64 2
+  %base_store_bc = bitcast * %base_store to bfloat*
+  call void @llvm.aarch64.sve.stnt1.nxv8bf16( %data,
+  %mask,
+ bfloat* %base_store_bc)
+  ret void
+}
+
 ; 16-lane non-temporal load/stores.
 
 define void @test_masked_ldst_sv16i8( * %base,  %mask) nounwind {
@@ -169,6 +186,7 @@
 ; 8-eleme

[PATCH] D82636: Work around a bug in MSVC in the syntax tree test

2020-06-26 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
gribozavr2 added reviewers: eduucaldas, vvereschaka.

MSVC does not handle raw string literals with embedded double quotes
correctly. I switched the affected test case to use regular string
literals insetad.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82636

Files:
  clang/unittests/Tooling/Syntax/TreeTest.cpp


Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -1636,33 +1636,33 @@
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
-  R"cpp(
-void test() {
-  R"SyntaxTree(
-  Hello "Syntax" \"
-  )SyntaxTree";
-}
-)cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-StringLiteralExpression
-| | `-R"SyntaxTree(
-  Hello "Syntax" \"
-  )SyntaxTree"
-| `-;
-`-}
-)txt"));
+  // This test uses regular string literals instead of raw string literals to
+  // hold source code and expected output because of a bug in MSVC up to MSVC
+  // 2019 16.2:
+  // 
https://developercommunity.visualstudio.com/content/problem/67300/stringifying-raw-string-literal.html
+  EXPECT_TRUE(treeDumpEqual( //
+  "void test() {\n"
+  "  R\"SyntaxTree(\n"
+  "  Hello \"Syntax\" \\\"\n"
+  "  )SyntaxTree\";\n"
+  "}\n",
+  "*: TranslationUnit\n"
+  "`-SimpleDeclaration\n"
+  "  |-void\n"
+  "  |-SimpleDeclarator\n"
+  "  | |-test\n"
+  "  | `-ParametersAndQualifiers\n"
+  "  |   |-(\n"
+  "  |   `-)\n"
+  "  `-CompoundStatement\n"
+  "|-{\n"
+  "|-ExpressionStatement\n"
+  "| |-StringLiteralExpression\n"
+  "| | `-R\"SyntaxTree(\n"
+  "  Hello \"Syntax\" \\\"\n"
+  "  )SyntaxTree\"\n"
+  "| `-;\n"
+  "`-}\n"));
 }
 
 TEST_P(SyntaxTreeTest, BoolLiteral) {


Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -1636,33 +1636,33 @@
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
-  R"cpp(
-void test() {
-  R"SyntaxTree(
-  Hello "Syntax" \"
-  )SyntaxTree";
-}
-)cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-StringLiteralExpression
-| | `-R"SyntaxTree(
-  Hello "Syntax" \"
-  )SyntaxTree"
-| `-;
-`-}
-)txt"));
+  // This test uses regular string literals instead of raw string literals to
+  // hold source code and expected output because of a bug in MSVC up to MSVC
+  // 2019 16.2:
+  // https://developercommunity.visualstudio.com/content/problem/67300/stringifying-raw-string-literal.html
+  EXPECT_TRUE(treeDumpEqual( //
+  "void test() {\n"
+  "  R\"SyntaxTree(\n"
+  "  Hello \"Syntax\" \\\"\n"
+  "  )SyntaxTree\";\n"
+  "}\n",
+  "*: TranslationUnit\n"
+  "`-SimpleDeclaration\n"
+  "  |-void\n"
+  "  |-SimpleDeclarator\n"
+  "  | |-test\n"
+  "  | `-ParametersAndQualifiers\n"
+  "  |   |-(\n"
+  "  |   `-)\n"
+  "  `-CompoundStatement\n"
+  "|-{\n"
+  "|-ExpressionStatement\n"
+  "| |-StringLiteralExpression\n"
+  "| | `-R\"SyntaxTree(\n"
+  "  Hello \"Syntax\" \\\"\n"
+  "  )SyntaxTree\"\n"
+  "| `-;\n"
+  "`-}\n"));
 }
 
 TEST_P(SyntaxTreeTest, BoolLiteral) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d45cf91 - [AArch64][SVE2] Guard while intrinsics on scalar bfloat feature macro

2020-06-26 Thread Cullen Rhodes via cfe-commits

Author: Cullen Rhodes
Date: 2020-06-26T10:25:42Z
New Revision: d45cf9105b5a88ed03382ffbbfcd54b461f1bb23

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

LOG: [AArch64][SVE2] Guard while intrinsics on scalar bfloat feature macro

Summary:
`svwhilerw_bf16` and `svwhilewr_bf16` intrinsics use the scalar
`bfloat16_t`
type which is predicated on `__ARM_FEATURE_BF16_SCALAR_ARITHMETIC`. This
patch changes the feature guard from `__ARM_FEATURE_SVE_BF16` to the
scalar bfloat feature macro.

The verify tests for `+bf16` are also removed in this patch. The purpose
of these checks was to match the SVE2 ACLE tests that look for an
implicit declaration warning if the feature isn't set. They worked when
the intrinsics were guarded on `__ARM_FEATURE_SVE_BF16` as the
`bfloat16_t`
was guarded on a different macro, but with both the type and intrinsic
guarded on the same macro an earlier error is triggered in the ACLE
regarding the type and we don't get a warning as we do for SVE2.

Reviewers: sdesmalen, fpetrogalli, kmclaughlin, rengolin, efriedma

Reviewed By: sdesmalen, fpetrogalli

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

Added: 


Modified: 
clang/include/clang/Basic/arm_sve.td
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index e2aab5f2c344..3327b347 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1981,7 +1981,7 @@ def SVWHILEWR_S : SInst<"svwhilewr[_{1}]", "Pcc", "iUif", 
MergeNone, "aarch64_sv
 def SVWHILEWR_D : SInst<"svwhilewr[_{1}]", "Pcc", "lUld", MergeNone, 
"aarch64_sve_whilewr_d", [IsOverloadWhileRW]>;
 }
 
-let ArchGuard = "defined(__ARM_FEATURE_SVE2) && 
defined(__ARM_FEATURE_SVE_BF16)" in {
+let ArchGuard = "defined(__ARM_FEATURE_SVE2) && 
defined(__ARM_FEATURE_BF16_SCALAR_ARITHMETIC)" in {
 def SVWHILERW_H_BF16 : SInst<"svwhilerw[_{1}]", "Pcc", "b", MergeNone, 
"aarch64_sve_whilerw_h", [IsOverloadWhileRW]>;
 def SVWHILEWR_H_BF16 : SInst<"svwhilewr[_{1}]", "Pcc", "b", MergeNone, 
"aarch64_sve_whilewr_h", [IsOverloadWhileRW]>;
 }

diff  --git 
a/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c 
b/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
index 60c9cffd44eb..9ea4ebc9ddce 100644
--- a/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
+++ b/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
@@ -1,18 +1,7 @@
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple 
aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 
-DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
-
-// Test expected warnings for implicit declaration when +sve2 is missing
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error %s
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-fsyntax-only -verify=overload -verify-ignore-unexpected=error %s
-
-// Test expected warnings for implicit declaration when +bf16 is missing
-// NOTE: +bf16 doesn't currently imply __ARM_FEATURE_SVE_BF16, once the
-// implementation is complete it will, at which point -target-feature +bf16
-// should be removed.
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu 
-target-feature +sve2 -target-feature +bf16 -fallow-half-arguments-and-returns 
-fsyntax-only -verify -verify-ignore-unexpected=error %s
-
-// Test expected ambiguous call error for overloaded form when +bf16 is missing
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify=overload-bf16 
-verify-ignore-unex

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

2020-06-26 Thread Gui Andrade via Phabricator via cfe-commits
guiand updated this revision to Diff 273558.
guiand added a comment.

Made DetermineNoUndef more robust


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp

Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp
===
--- llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -929,6 +929,7 @@
   case Attribute::StrictFP:
   case Attribute::UWTable:
   case Attribute::NoCfCheck:
+  case Attribute::NoUndef:
 break;
   }
 
Index: llvm/lib/IR/Attributes.cpp
===
--- llvm/lib/IR/Attributes.cpp
+++ llvm/lib/IR/Attributes.cpp
@@ -443,6 +443,8 @@
 return "cold";
   if (hasAttribute(Attribute::ImmArg))
 return "immarg";
+  if (hasAttribute(Attribute::NoUndef))
+return "noundef";
 
   if (hasAttribute(Attribute::ByVal)) {
 std::string Result;
Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
===
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -731,6 +731,8 @@
 return bitc::ATTR_KIND_SANITIZE_MEMTAG;
   case Attribute::Preallocated:
 return bitc::ATTR_KIND_PREALLOCATED;
+  case Attribute::NoUndef:
+return bitc::ATTR_KIND_NOUNDEF;
   case Attribute::EndAttrKinds:
 llvm_unreachable("Can not encode end-attribute kinds marker.");
   case Attribute::None:
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
===
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1532,6 +1532,8 @@
 return Attribute::SanitizeMemTag;
   case bitc::ATTR_KIND_PREALLOCATED:
 return Attribute::Preallocated;
+  case bitc::ATTR_KIND_NOUNDEF:
+return Attribute::NoUndef;
   }
 }
 
Index: llvm/lib/AsmParser/LLToken.h
===
--- llvm/lib/AsmParser/LLToken.h
+++ llvm/lib/AsmParser/LLToken.h
@@ -196,6 +196,7 @@
   kw_naked,
   kw_nest,
   kw_noalias,
+  kw_noundef,
   kw_nobuiltin,
   kw_nocapture,
   kw_noduplicate,
Index: llvm/lib/AsmParser/LLParser.cpp
===
--- llvm/lib/AsmParser/LLParser.cpp
+++ llvm/lib/AsmParser/LLParser.cpp
@@ -1374,6 +1374,7 @@
 case lltok::kw_inalloca:
 case lltok::kw_nest:
 case lltok::kw_noalias:
+case lltok::kw_noundef:
 case lltok::kw_nocapture:
 case lltok::kw_nonnull:
 case lltok::kw_returned:
@@ -1677,6 +1678,9 @@
 case lltok::kw_inalloca:B.addAttribute(Attribute::InAlloca); break;
 case lltok::kw_inreg:   B.addAttribute(Attribute::InReg); break;
 case lltok::kw_nest:B.addAttribute(Attribute::Nest); break;
+case lltok::kw_noundef:
+  B.addAttribute(Attribute::NoUndef);
+  break;
 case lltok::kw_noalias: B.addAttribute(Attribute::NoAlias); break;
 case lltok::kw_nocapture:   B.addAttribute(Attribute::NoCapture); break;
 case lltok::kw_nofree:  B.addAttribute(Attribute::NoFree); break;
@@ -1774,6 +1778,9 @@
 }
 case lltok::kw_inreg:   B.addAttribute(Attribute::InReg); break;
 case lltok::kw_noalias: B.addAttribute(Attribute::NoAlias); break;
+case lltok::kw_noundef:
+  B.addAttribute(Attribute::NoUndef);
+  break;
 case lltok::kw_nonnull: B.addAttribute(Attribute::NonNull); break;
 case lltok::kw_signext: B.addAttribute(Attribute::SExt); break;
 case lltok::kw_zeroext: B.addAttribute(Attribute::ZExt); break;
Index: llvm/lib/AsmParser/LLLexer.cpp
===
--- llvm/lib/AsmParser/LLLexer.cpp
+++ llvm/lib/AsmParser/LLLexer.cpp
@@ -696,6 +696,7 @@
   KEYWORD(writeonly);
   KEYWORD(zeroext);
   KEYWORD(immarg);
+  KEYWORD(noundef);
 
   KEYWORD(type);
   KEYWORD(opaque);
Index: llvm/include/llvm/IR/Attributes.td
===
--- llvm/include/llvm/IR/Attributes.td
+++ llvm/include/llvm/IR/Attributes.td
@@ -39,6 +39,9 @@
 /// Pass structure by value.
 def ByVal : TypeAttr<"byval">;
 
+/// Parameter or return value may not contain uninitialized or poison bits
+def NoUndef : EnumAttr<"no

[PATCH] D82317: [Clang/Test]: Update tests where `noundef` attribute is necessary

2020-06-26 Thread Gui Andrade via Phabricator via cfe-commits
guiand updated this revision to Diff 273570.
guiand retitled this revision from "[Clang/Test]: Update tests where `frozen` 
attribute is necessary" to "[Clang/Test]: Update tests where `noundef` 
attribute is necessary".
guiand edited the summary of this revision.
guiand added a comment.
Herald added subscribers: aaron.ballman, ormris, mgrang.
Herald added a reviewer: sscalpone.

Updated almost all tests to rename frozen->noundef. Still needs rebase to master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82317

Files:
  clang/test/ARCMT/objcmt-instancetype.m
  clang/test/ARCMT/objcmt-instancetype.m.result
  clang/test/ARCMT/objcmt-numeric-literals.m
  clang/test/ARCMT/objcmt-numeric-literals.m.result
  clang/test/AST/ast-dump-openmp-begin-declare-variant_6.c
  clang/test/ASTMerge/unnamed_fields/test.cpp
  clang/test/Analysis/casts.c
  clang/test/Analysis/inlining/DynDispatchBifurcate.m
  clang/test/Analysis/inlining/InlineObjCClassMethod.m
  clang/test/Analysis/misc-ps-region-store.m
  clang/test/Analysis/missing-bind-temporary.cpp
  clang/test/Analysis/silence-checkers-and-packages-core-all.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p4.cpp
  clang/test/CXX/dcl.dcl/basic.namespace/namespace.udecl/p11.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp
  clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-var.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p2-cxx0x.cpp
  clang/test/CXX/drs/dr0xx.cpp
  clang/test/CXX/except/except.spec/p14-ir.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
  clang/test/CXX/modules-ts/codegen-basics.cppm
  clang/test/CXX/special/class.copy/p3.cpp
  clang/test/CodeGen/2004-02-13-Memset.c
  clang/test/CodeGen/2004-06-17-UnorderedCompares.c
  clang/test/CodeGen/2006-05-19-SingleEltReturn.c
  clang/test/CodeGen/2007-02-25-C-DotDotDot.c
  clang/test/CodeGen/2007-06-18-SextAttrAggregate.c
  clang/test/CodeGen/2008-03-05-syncPtr.c
  clang/test/CodeGen/2008-07-29-override-alias-decl.c
  clang/test/CodeGen/2008-07-30-implicit-initialization.c
  clang/test/CodeGen/2008-07-31-promotion-of-compound-pointer-arithmetic.c
  clang/test/CodeGen/2009-02-13-zerosize-union-field.c
  clang/test/CodeGen/2009-05-04-EnumInreg.c
  clang/test/CodeGen/2009-09-24-SqrtErrno.c
  clang/test/CodeGen/3dnow-builtins.c
  clang/test/CodeGen/64bit-swiftcall.c
  clang/test/CodeGen/PR3589-freestanding-libcalls.c
  clang/test/CodeGen/_Bool-conversion.c
  clang/test/CodeGen/aapcs-align.cpp
  clang/test/CodeGen/aapcs64-align.cpp
  clang/test/CodeGen/aarch64-args.cpp
  clang/test/CodeGen/aarch64-byval-temp.c
  clang/test/CodeGen/aarch64-neon-3v.c
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-dot-product.c
  clang/test/CodeGen/aarch64-neon-extract.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-ldst-one.c
  clang/test/CodeGen/aarch64-neon-scalar-copy.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-neon-vcombine.c
  clang/test/CodeGen/aarch64-neon-vget-hilo.c
  clang/test/CodeGen/aarch64-neon-vget.c
  clang/test/CodeGen/aarch64-poly128.c
  clang/test/CodeGen/aarch64-poly64.c
  clang/test/CodeGen/aarch64-varargs-ms.c
  clang/test/CodeGen/aarch64-varargs.c
  clang/test/CodeGen/address-space-avr.c
  clang/test/CodeGen/address-space-field1.c
  clang/test/CodeGen/address-space.c
  clang/test/CodeGen/aggregate-assign-call.c
  clang/test/CodeGen/aix-return.c
  clang/test/CodeGen/aix-struct-arg.c
  clang/test/CodeGen/aix-vaargs.c
  clang/test/CodeGen/alias.c
  clang/test/CodeGen/align-param.c
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/arc/arguments.c
  clang/test/CodeGen/arc/struct-align.c
  clang/test/CodeGen/arm-aapcs-vfp.c
  clang/test/CodeGen/arm-abi-vector.c
  clang/test/CodeGen/arm-arguments.c
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/CodeGen/arm-byval-align.c
  clang/test/CodeGen/arm-cmse-attr.c
  clang/test/CodeGen/arm-cmse-call.c
  clang/test/CodeGen/arm-float-helpers.c
  clang/test/CodeGen/arm-fp16-arguments.c
  clang/test/CodeGen/arm-homogenous.c
  clang/test/CodeGen/arm-mangle-bf16.cpp
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm-neon-dot-product.c
  clang/test/CodeGen/arm-neon-fma.c
  clang/test/CodeGen/arm-neon-numeric-maxmin.c
  clang/test/CodeGen/arm-neon-vcvtX.c
  clang/test/CodeGen/arm-pcs.c
  clang/test/CodeGen/arm-swiftcall.c
  clang/test/CodeGen/arm-varargs.c
  clang/test/CodeGen/arm-vector-arguments.c
  clang/test/CodeGen/arm-vfp16-arguments.c
  clang/test/CodeGen/arm-vfp16-arguments2.cpp
  clang/test/CodeGen/arm64-aapcs-arguments.c
  clang/test/CodeGen/arm64-abi-vector.c
  clang/test/CodeGen/arm64-arguments.c
  clang/test/CodeGen/arm64-microsoft-arguments.cpp
  clang/test/CodeGen/ar

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

2020-06-26 Thread Gui Andrade via Phabricator via cfe-commits
guiand marked an inline comment as done.
guiand added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2082
+  const Type *RetTyPtr = RetTy.getTypePtr();
+  if (!RetTy->isVoidType() && !RetTyPtr->isRecordType() &&
+  RetAI.getKind() != ABIArgInfo::Indirect) {

guiand wrote:
> guiand wrote:
> > rsmith wrote:
> > > Other types that we should think about from a padding perspective:
> > > 
> > >  * `nullptr_t` (which has the same size and alignment as `void*` but is 
> > > all padding)
> > >  * 80-bit `long double` and `_Complex long double` (I don't know whether 
> > > we guarantee to initialize the 6 padding bytes)
> > >  * member pointers might contain padding under some ABI rules -- under 
> > > the MS ABI, you get a struct containing N pointers followed by M ints, 
> > > which could have 4 bytes of tail padding on 64-bit targets
> > >  * vector types with tail padding (eg, a vector of 3 `char`s is sometimes 
> > > passed as an `i32` with one byte `undef`)
> > >  * matrix types (presumably the same concerns as for vector types apply 
> > > here)
> > >  * maybe Obj-C object types?
> > >  * `_ExtInt` types (eg, returning an `_ExtInt(65)` initialized to 0 
> > > produces an `{i64, i64}` containing 7 bytes of `undef`)
> > > 
> > > It would be safer to list exactly those types for which we know this 
> > > assumption is correct rather than assuming that it's correct by default 
> > > -- I think more than half of the `Type` subclasses for concrete canonical 
> > > types can have undef bits in their IR representation.
> > This is a good point, and I think there was some nuance that I had 
> > previously included in determining this for records (since removed) that I 
> > didn't think to include in CGCall.cpp.
> > 
> > I think one particular check, `llvm::DataLayout::typeSizeEqualsStoreSize`, 
> > handles a lot of these cases:
> > - `long double`
> > - oddly-sized vectors
> > - `_ExtInt` types
> > 
> > I don't know if the `matrix` type has internal padding (like structs) but 
> > if not it would cover that as well.  
> > I believe that the struct with padding wouldn't be an issue as we're 
> > excluding record types here.  
> > And I'd have to take a closer look at `nullptr_t` to see how it behaves 
> > here.
> > 
> > ~~~
> > 
> > But if I'd like to build an exhaustive list of types I think will work 
> > correctly with a check like this:
> > - scalars
> > - floating point numbers
> > - pointers
> > 
> > I think I'd need also need an inner `typeSizeEqualsStoreSize` check on the 
> > base type of vectors/complex numbers.
> > nullptr_t (which has the same size and alignment as void* but is all 
> > padding)
> 
> From what I can gather looking at the IR of `test/CodeGenCXX/nullptr.cpp`, it 
> looks like `nullptr_t` arguments and return values are represented as normal 
> `i8*` types but given the special value `null`. From this it seems like we 
> can mark them `noundef` without worry?
Actually I've been thinking more about these cases, and they should only really 
be a problem if clang coerces them away from their native types to something 
larger.

For example, if clang emits `i33` that's not a problem, as potential padding 
belonging to `i33` can be always be determined by looking at the data layout.
But if it emits `{ i32, i32 }` or `i64` or something similar, it's introducing 
new hidden/erased padding and so we can't mark it `noundef`.
Same thing goes for `long double`: if it's emitted as `x86_fp80` that's no 
problem.

There's been some confusion wrt this in the LangRef patch as well. I think what 
we really want is an attribute that indicates the presence of undef bits *not 
inherent to the IR type*. So (for the sake of argument, we're not handling 
structs right now) `struct { char; short }` emitted as `{ i8, i16 } noundef` is 
fine, but emitting it as `i64` is a problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D82578: [AArch64][SVE2] Guard while intrinsics on scalar bfloat feature macro

2020-06-26 Thread Cullen Rhodes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd45cf9105b5a: [AArch64][SVE2] Guard while intrinsics on 
scalar bfloat feature macro (authored by c-rhodes).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82578

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c


Index: clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c
===
--- clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c
+++ clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c
@@ -1,18 +1,7 @@
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 -triple 
aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -D__ARM_FEATURE_SVE_BF16 
-DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
-
-// Test expected warnings for implicit declaration when +sve2 is missing
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error %s
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-fsyntax-only -verify=overload -verify-ignore-unexpected=error %s
-
-// Test expected warnings for implicit declaration when +bf16 is missing
-// NOTE: +bf16 doesn't currently imply __ARM_FEATURE_SVE_BF16, once the
-// implementation is complete it will, at which point -target-feature +bf16
-// should be removed.
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu 
-target-feature +sve2 -target-feature +bf16 -fallow-half-arguments-and-returns 
-fsyntax-only -verify -verify-ignore-unexpected=error %s
-
-// Test expected ambiguous call error for overloaded form when +bf16 is missing
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify=overload-bf16 
-verify-ignore-unexpected=note %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -triple aarch64-none-linux-gnu 
-target-feature +sve2 -target-feature +bf16 -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 
-fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -fsyntax-only 
-verify=overload -verify-ignore-unexpected=error %s
 
 #include 
 
@@ -29,8 +18,7 @@
   // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.whilewr.h.nxv8i1.p0bf16(bfloat* %op1, bfloat* %op2)
   // CHECK: %[[INTRINSIC_REINT:.*]] = call  
@llvm.aarch64.sve.convert.to.svbool.nxv8i1( %[[INTRINSIC]])
   // CHECK: ret  %[[INTRINSIC_REINT]]
-  // overload-warning@+3 {{implicit declaration of function 'svwhilewr'}}
-  // expected-warning@+2 {{implicit declaration of function 'svwhilewr_bf16'}}
-  // overload-bf16-error@+1 {{call to 'svwhilewr' is ambiguous}}
+  // overload-warning@+2 {{implicit declaration of function 'svwhilewr'}}
+  // expected-warning@+1 {{implicit declaration of function 'svwhilewr_bf16'}}
   return SVE_ACLE_FUNC(svwhilewr,_bf16,,)(op1, op2);
 }
Index: clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilerw-bfloat.c
===
--- clang/test/CodeGen/aarch

[PATCH] D82623: [sve][acle] Enable feature macros for SVE ACLE extensions.

2020-06-26 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

Hi @fpetrogalli , I see the patch is still missing a few tests to 
`clang/test/Preprocessor/aarch64-target-features.c`.

Not specifically to be done in this patch, but we'll also needs changes to make 
sure that the bfloat macros are set for armv8.6 (e.g. `-march=armv8.6-a+sve*`).
See `DecodeAArch64Features` in `clang/lib/Driver/ToolChains/Arch/AArch64`.




Comment at: clang/lib/Basic/Targets/AArch64.cpp:315
+Builder.defineMacro("__ARM_FEATURE_SVE_BF16", "1");
+Builder.defineMacro("__ARM_FEATURE_BF16_SCALAR_ARITHMETIC", "1");
+  }

Should `__ARM_FEATURE_BF16_SCALAR_ARITHMETIC` not be defined under 
`HasBFloat16`?



Comment at: 
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_whilewr-bfloat.c:14
-
-// Test expected ambiguous call error for overloaded form when +bf16 is missing
-// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 
-D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve2 -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify=overload-bf16 
-verify-ignore-unexpected=note %s

unrelated change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82623



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


[PATCH] D53891: [LTO] Add option to enable LTOUnit splitting, and disable unless needed

2020-06-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.
Herald added a subscriber: hiraditya.

Would be possible to add some documentation for this flag? From a quick search 
it's not clear to me what it does and when one is supposed to use it.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D53891



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


[PATCH] D82642: [clangd] Run formatting operations asynchronously.

2020-06-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kbobyrev.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

They don't need ASTs or anything, so they should still run immediately.

These were sync for historical reasons (they predate clangd having a pervasive
threading model). This worked ok as they were "cheap".
Aside for consistency, there are a couple of reasons to make them async:

- they do IO (finding .clang-format) so aren't trivially cheap
- having TUScheduler involved in running these tasks means we can use it as an 
injection point for configuration. (TUScheduler::run will need to learn about 
which file is being operated on, but that's an easy change).
- adding the config system adds more potential IO, too


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82642

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.cpp
  clang-tools-extra/clangd/unittests/SyncAPI.h

Index: clang-tools-extra/clangd/unittests/SyncAPI.h
===
--- clang-tools-extra/clangd/unittests/SyncAPI.h
+++ clang-tools-extra/clangd/unittests/SyncAPI.h
@@ -44,6 +44,9 @@
 Position Pos, StringRef NewName,
 const clangd::RenameOptions &RenameOpts);
 
+llvm::Expected
+runFormatFile(ClangdServer &Server, PathRef File, StringRef Code);
+
 std::string runDumpAST(ClangdServer &Server, PathRef File);
 
 llvm::Expected>
Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -105,6 +105,13 @@
   return std::move(*Result);
 }
 
+llvm::Expected
+runFormatFile(ClangdServer &Server, PathRef File, StringRef Code) {
+  llvm::Optional> Result;
+  Server.formatFile(File, Code, capture(Result));
+  return std::move(*Result);
+}
+
 std::string runDumpAST(ClangdServer &Server, PathRef File) {
   llvm::Optional Result;
   Server.dumpAST(File, capture(Result));
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -877,7 +877,7 @@
   FS.Files[Path] = Code;
   runAddDocument(Server, Path, Code);
 
-  auto Replaces = Server.formatFile(Code, Path);
+  auto Replaces = runFormatFile(Server, Path, Code);
   EXPECT_TRUE(static_cast(Replaces));
   auto Changed = tooling::applyAllReplacements(Code, *Replaces);
   EXPECT_TRUE(static_cast(Changed));
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -247,18 +247,17 @@
   Callback CB);
 
   /// Run formatting for \p Rng inside \p File with content \p Code.
-  llvm::Expected formatRange(StringRef Code,
-PathRef File, Range Rng);
+  void formatRange(PathRef File, StringRef Code, Range Rng,
+   Callback CB);
 
   /// Run formatting for the whole \p File with content \p Code.
-  llvm::Expected formatFile(StringRef Code,
-   PathRef File);
+  void formatFile(PathRef File, StringRef Code,
+  Callback CB);
 
   /// Run formatting after \p TriggerText was typed at \p Pos in \p File with
   /// content \p Code.
-  llvm::Expected> formatOnType(StringRef Code,
- PathRef File, Position Pos,
- StringRef TriggerText);
+  void formatOnType(PathRef File, StringRef Code, Position Pos,
+StringRef TriggerText, Callback> CB);
 
   /// Test the validity of a rename operation.
   void prepareRename(PathRef File, Position Pos,
@@ -323,11 +322,9 @@
   blockUntilIdleForTest(llvm::Optional TimeoutSeconds = 10);
 
 private:
-  /// FIXME: This stats several files to find a .clang-format file. I/O can be
-  /// slow. Think of a way to cache this.
-  llvm::Expected
-  formatCode(llvm::StringRef Code, PathRef File,
- ArrayRef Ranges);
+  void formatCode(PathRef File, llvm::StringRef Code,
+  ArrayRef Ranges,
+  Callback CB);
 
   const ThreadsafeFS &TFS;
 
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -296,40 +296,46 @@

[PATCH] D82470: [OpenMP][IRBuilder] Support nested parallel regions

2020-06-26 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX added a comment.

Overall this seems great Thanks! I have one minor concern:
This patch seems to do 2 things: Support for nested parallel regions(which was 
crashing earlier) and some infrastructure change(introducing AllocBuilder..).
I'm not sure of this, but is it possible to separate these as 2( or more) 
patches ? 1 for Nested parallel region support and other patch as a 
infrastructure change ?

Main benefit of this approach would be that this would be easier to 
track/maintain changes in future.
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82470



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


[clang] 94e8ec6 - [AST] Add fixed-point division constant evaluation.

2020-06-26 Thread Bevin Hansson via cfe-commits

Author: Bevin Hansson
Date: 2020-06-26T13:38:11+02:00
New Revision: 94e8ec631dda98639930c3fcf6b84148cd58cd59

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

LOG: [AST] Add fixed-point division constant evaluation.

Reviewers: rjmccall, leonardchan, bjope

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/FixedPoint.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Basic/FixedPoint.cpp
clang/test/Frontend/fixed_point_div.c

Removed: 




diff  --git a/clang/include/clang/Basic/FixedPoint.h 
b/clang/include/clang/Basic/FixedPoint.h
index 2566169cfd23..8937bccb0edb 100644
--- a/clang/include/clang/Basic/FixedPoint.h
+++ b/clang/include/clang/Basic/FixedPoint.h
@@ -130,6 +130,7 @@ class APFixedPoint {
APFixedPoint add(const APFixedPoint &Other, bool *Overflow = nullptr) const;
APFixedPoint sub(const APFixedPoint &Other, bool *Overflow = nullptr) const;
APFixedPoint mul(const APFixedPoint &Other, bool *Overflow = nullptr) const;
+   APFixedPoint div(const APFixedPoint &Other, bool *Overflow = nullptr) const;
 
/// Perform a unary negation (-X) on this fixed point type, taking into
/// account saturation if applicable.

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 35aeb6f8f089..b55499fd5075 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12948,6 +12948,15 @@ bool 
FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
   return false;
 return Success(Result, E);
   }
+  case BO_Div: {
+bool AddOverflow, ConversionOverflow;
+APFixedPoint Result = LHSFX.div(RHSFX, &AddOverflow)
+   .convert(ResultFXSema, &ConversionOverflow);
+if ((AddOverflow || ConversionOverflow) &&
+!HandleOverflow(Info, E, Result, E->getType()))
+  return false;
+return Success(Result, E);
+  }
   default:
 return false;
   }

diff  --git a/clang/lib/Basic/FixedPoint.cpp b/clang/lib/Basic/FixedPoint.cpp
index 21fa1c00aa83..e8db43c6fe90 100644
--- a/clang/lib/Basic/FixedPoint.cpp
+++ b/clang/lib/Basic/FixedPoint.cpp
@@ -254,6 +254,61 @@ APFixedPoint APFixedPoint::mul(const APFixedPoint &Other,
   CommonFXSema);
 }
 
+APFixedPoint APFixedPoint::div(const APFixedPoint &Other,
+   bool *Overflow) const {
+  auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
+  APFixedPoint ConvertedThis = convert(CommonFXSema);
+  APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
+  llvm::APSInt ThisVal = ConvertedThis.getValue();
+  llvm::APSInt OtherVal = ConvertedOther.getValue();
+  bool Overflowed = false;
+
+  // Widen the LHS and RHS so we can perform a full division.
+  unsigned Wide = CommonFXSema.getWidth() * 2;
+  if (CommonFXSema.isSigned()) {
+ThisVal = ThisVal.sextOrSelf(Wide);
+OtherVal = OtherVal.sextOrSelf(Wide);
+  } else {
+ThisVal = ThisVal.zextOrSelf(Wide);
+OtherVal = OtherVal.zextOrSelf(Wide);
+  }
+
+  // Upscale to compensate for the loss of precision from division, and
+  // perform the full division.
+  ThisVal = ThisVal.shl(CommonFXSema.getScale());
+  llvm::APSInt Result;
+  if (CommonFXSema.isSigned()) {
+llvm::APInt Rem;
+llvm::APInt::sdivrem(ThisVal, OtherVal, Result, Rem);
+// If the quotient is negative and the remainder is nonzero, round
+// towards negative infinity by subtracting epsilon from the result.
+if (Result.isNegative() && !Rem.isNullValue())
+  Result = Result - 1;
+  } else
+Result = ThisVal.udiv(OtherVal);
+  Result.setIsSigned(CommonFXSema.isSigned());
+
+  // If our result lies outside of the representative range of the common
+  // semantic, we either have overflow or saturation.
+  llvm::APSInt Max = APFixedPoint::getMax(CommonFXSema).getValue()
+   .extOrTrunc(Wide);
+  llvm::APSInt Min = APFixedPoint::getMin(CommonFXSema).getValue()
+   .extOrTrunc(Wide);
+  if (CommonFXSema.isSaturated()) {
+if (Result < Min)
+  Result = Min;
+else if (Result > Max)
+  Result = Max;
+  } else
+Overflowed = Result < Min || Result > Max;
+
+  if (Overflow)
+*Overflow = Overflowed;
+
+  return APFixedPoint(Result.sextOrTrunc(CommonFXSema.getWidth()),
+  CommonFXSema);
+}
+
 void APFixedPoint::toString(llvm::SmallVectorImpl &Str) const {
   llvm::APSInt Val = getValue();
   unsigned Scale = getScale();

diff  --git a/clang/test/Frontend/fixed_point_div.c 
b/clang/test/Frontend/fixed_point_div.c
index ec17e082558c..28fa5e0e9cbc 100644
--- a/clang/test/Frontend/fixed

[clang] da2f852 - [AST] Fix certain consteval assignment and comma operator issues with fixed-point types.

2020-06-26 Thread Bevin Hansson via cfe-commits

Author: Bevin Hansson
Date: 2020-06-26T13:38:11+02:00
New Revision: da2f852e1913a16a1c6940ce3d3e47158ae5ba0e

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

LOG: [AST] Fix certain consteval assignment and comma operator issues with 
fixed-point types.

Summary:
Assignment and comma operators for fixed-point types were being constevaled as 
other
binary operators, but they need special treatment.

Reviewers: rjmccall, leonardchan, bjope

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang/test/Frontend/fixed_point_crash.c

Modified: 
clang/lib/AST/ExprConstant.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 35b5bad677a0..ebe09c99429f 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12920,6 +12920,9 @@ bool FixedPointExprEvaluator::VisitCastExpr(const 
CastExpr *E) {
 }
 
 bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
+  if (E->isPtrMemOp() || E->isAssignmentOp() || E->getOpcode() == BO_Comma)
+return ExprEvaluatorBaseTy::VisitBinaryOperator(E);
+
   const Expr *LHS = E->getLHS();
   const Expr *RHS = E->getRHS();
   FixedPointSemantics ResultFXSema =

diff  --git a/clang/test/Frontend/fixed_point_crash.c 
b/clang/test/Frontend/fixed_point_crash.c
new file mode 100644
index ..12dc1944f018
--- /dev/null
+++ b/clang/test/Frontend/fixed_point_crash.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify -ffixed-point %s
+
+union a {
+  _Accum x;
+  int i;
+};
+
+int fn1() {
+  union a m;
+  m.x = 5.6k;
+  return m.i;
+}
+
+int fn2() {
+  union a m;
+  m.x = 7, 5.6k; // expected-warning {{expression result unused}}
+  return m.x, m.i; // expected-warning {{expression result unused}}
+}
+
+_Accum acc = (0.5r, 6.9k); // expected-warning {{expression result unused}}



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


[clang] 53f5c8b - [AST] Add fixed-point multiplication constant evaluation.

2020-06-26 Thread Bevin Hansson via cfe-commits

Author: Bevin Hansson
Date: 2020-06-26T13:38:11+02:00
New Revision: 53f5c8b4a14c2ef89d44062a3a045be064bdc0e7

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

LOG: [AST] Add fixed-point multiplication constant evaluation.

Reviewers: rjmccall, leonardchan, bjope

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/FixedPoint.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Basic/FixedPoint.cpp
clang/test/Frontend/fixed_point_mul.c

Removed: 




diff  --git a/clang/include/clang/Basic/FixedPoint.h 
b/clang/include/clang/Basic/FixedPoint.h
index 1f3251982325..2566169cfd23 100644
--- a/clang/include/clang/Basic/FixedPoint.h
+++ b/clang/include/clang/Basic/FixedPoint.h
@@ -129,6 +129,7 @@ class APFixedPoint {
// explanation of the Overflow parameter.
APFixedPoint add(const APFixedPoint &Other, bool *Overflow = nullptr) const;
APFixedPoint sub(const APFixedPoint &Other, bool *Overflow = nullptr) const;
+   APFixedPoint mul(const APFixedPoint &Other, bool *Overflow = nullptr) const;
 
/// Perform a unary negation (-X) on this fixed point type, taking into
/// account saturation if applicable.

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 5cdeb3cd0e67..35aeb6f8f089 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12939,6 +12939,15 @@ bool 
FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
   return false;
 return Success(Result, E);
   }
+  case BO_Mul: {
+bool AddOverflow, ConversionOverflow;
+APFixedPoint Result = LHSFX.mul(RHSFX, &AddOverflow)
+   .convert(ResultFXSema, &ConversionOverflow);
+if ((AddOverflow || ConversionOverflow) &&
+!HandleOverflow(Info, E, Result, E->getType()))
+  return false;
+return Success(Result, E);
+  }
   default:
 return false;
   }

diff  --git a/clang/lib/Basic/FixedPoint.cpp b/clang/lib/Basic/FixedPoint.cpp
index 29d532f49561..21fa1c00aa83 100644
--- a/clang/lib/Basic/FixedPoint.cpp
+++ b/clang/lib/Basic/FixedPoint.cpp
@@ -197,6 +197,63 @@ APFixedPoint APFixedPoint::sub(const APFixedPoint &Other,
   return APFixedPoint(Result, CommonFXSema);
 }
 
+APFixedPoint APFixedPoint::mul(const APFixedPoint &Other,
+   bool *Overflow) const {
+  auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
+  APFixedPoint ConvertedThis = convert(CommonFXSema);
+  APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
+  llvm::APSInt ThisVal = ConvertedThis.getValue();
+  llvm::APSInt OtherVal = ConvertedOther.getValue();
+  bool Overflowed = false;
+
+  // Widen the LHS and RHS so we can perform a full multiplication.
+  unsigned Wide = CommonFXSema.getWidth() * 2;
+  if (CommonFXSema.isSigned()) {
+ThisVal = ThisVal.sextOrSelf(Wide);
+OtherVal = OtherVal.sextOrSelf(Wide);
+  } else {
+ThisVal = ThisVal.zextOrSelf(Wide);
+OtherVal = OtherVal.zextOrSelf(Wide);
+  }
+
+  // Perform the full multiplication and downscale to get the same scale.
+  //
+  // Note that the right shifts here perform an implicit downwards rounding.
+  // This rounding could discard bits that would technically place the result
+  // outside the representable range. We interpret the spec as allowing us to
+  // perform the rounding step first, avoiding the overflow case that would
+  // arise.
+  llvm::APSInt Result;
+  if (CommonFXSema.isSigned())
+Result = ThisVal.smul_ov(OtherVal, Overflowed)
+.ashr(CommonFXSema.getScale());
+  else
+Result = ThisVal.umul_ov(OtherVal, Overflowed)
+.lshr(CommonFXSema.getScale());
+  assert(!Overflowed && "Full multiplication cannot overflow!");
+  Result.setIsSigned(CommonFXSema.isSigned());
+
+  // If our result lies outside of the representative range of the common
+  // semantic, we either have overflow or saturation.
+  llvm::APSInt Max = APFixedPoint::getMax(CommonFXSema).getValue()
+   .extOrTrunc(Wide);
+  llvm::APSInt Min = APFixedPoint::getMin(CommonFXSema).getValue()
+   .extOrTrunc(Wide);
+  if (CommonFXSema.isSaturated()) {
+if (Result < Min)
+  Result = Min;
+else if (Result > Max)
+  Result = Max;
+  } else
+Overflowed = Result < Min || Result > Max;
+
+  if (Overflow)
+*Overflow = Overflowed;
+
+  return APFixedPoint(Result.sextOrTrunc(CommonFXSema.getWidth()),
+  CommonFXSema);
+}
+
 void APFixedPoint::toString(llvm::SmallVectorImpl &Str) const {
   llvm::APSInt Val = getValue();
   unsigned Scale = getScale();

di

[clang] 474177c - [AST] Improve overflow diagnostics for fixed-point constant evaluation.

2020-06-26 Thread Bevin Hansson via cfe-commits

Author: Bevin Hansson
Date: 2020-06-26T13:38:11+02:00
New Revision: 474177c05381a6eb2971e67753481b5efc78d848

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

LOG: [AST] Improve overflow diagnostics for fixed-point constant evaluation.

Summary:
Diagnostics for overflow were not being produced for fixed-point
evaluation. This patch refactors a bit of the evaluator and adds
a proper diagnostic for these cases.

Reviewers: rjmccall, leonardchan, bjope

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticASTKinds.td
clang/lib/AST/ExprConstant.cpp
clang/test/Frontend/fixed_point_errors.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticASTKinds.td 
b/clang/include/clang/Basic/DiagnosticASTKinds.td
index 75c4d0e0a139..905e3158cf40 100644
--- a/clang/include/clang/Basic/DiagnosticASTKinds.td
+++ b/clang/include/clang/Basic/DiagnosticASTKinds.td
@@ -346,6 +346,9 @@ def err_experimental_clang_interp_failed : Error<
 def warn_integer_constant_overflow : Warning<
   "overflow in expression; result is %0 with type %1">,
   InGroup>;
+def warn_fixedpoint_constant_overflow : Warning<
+  "overflow in expression; result is %0 with type %1">,
+  InGroup>;
 
 // This is a temporary diagnostic, and shall be removed once our
 // implementation is complete, and like the preceding constexpr notes belongs

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index b55499fd5075..35b5bad677a0 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12881,8 +12881,14 @@ bool FixedPointExprEvaluator::VisitCastExpr(const 
CastExpr *E) {
   return false;
 bool Overflowed;
 APFixedPoint Result = Src.convert(DestFXSema, &Overflowed);
-if (Overflowed && !HandleOverflow(Info, E, Result, DestType))
-  return false;
+if (Overflowed) {
+  if (Info.checkingForUndefinedBehavior())
+Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
+ 
diag::warn_fixedpoint_constant_overflow)
+  << Result.toString() << E->getType();
+  else if (!HandleOverflow(Info, E, Result, E->getType()))
+return false;
+}
 return Success(Result, E);
   }
   case CK_IntegralToFixedPoint: {
@@ -12894,8 +12900,14 @@ bool FixedPointExprEvaluator::VisitCastExpr(const 
CastExpr *E) {
 APFixedPoint IntResult = APFixedPoint::getFromIntValue(
 Src, Info.Ctx.getFixedPointSemantics(DestType), &Overflowed);
 
-if (Overflowed && !HandleOverflow(Info, E, IntResult, DestType))
-  return false;
+if (Overflowed) {
+  if (Info.checkingForUndefinedBehavior())
+Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
+ 
diag::warn_fixedpoint_constant_overflow)
+  << IntResult.toString() << E->getType();
+  else if (!HandleOverflow(Info, E, IntResult, E->getType()))
+return false;
+}
 
 return Success(IntResult, E);
   }
@@ -12920,47 +12932,41 @@ bool 
FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
   if (!EvaluateFixedPointOrInteger(RHS, RHSFX, Info))
 return false;
 
+  bool OpOverflow = false, ConversionOverflow = false;
+  APFixedPoint Result(LHSFX.getSemantics());
   switch (E->getOpcode()) {
   case BO_Add: {
-bool AddOverflow, ConversionOverflow;
-APFixedPoint Result = LHSFX.add(RHSFX, &AddOverflow)
-   .convert(ResultFXSema, &ConversionOverflow);
-if ((AddOverflow || ConversionOverflow) &&
-!HandleOverflow(Info, E, Result, E->getType()))
-  return false;
-return Success(Result, E);
+Result = LHSFX.add(RHSFX, &OpOverflow)
+  .convert(ResultFXSema, &ConversionOverflow);
+break;
   }
   case BO_Sub: {
-bool AddOverflow, ConversionOverflow;
-APFixedPoint Result = LHSFX.sub(RHSFX, &AddOverflow)
-   .convert(ResultFXSema, &ConversionOverflow);
-if ((AddOverflow || ConversionOverflow) &&
-!HandleOverflow(Info, E, Result, E->getType()))
-  return false;
-return Success(Result, E);
+Result = LHSFX.sub(RHSFX, &OpOverflow)
+  .convert(ResultFXSema, &ConversionOverflow);
+break;
   }
   case BO_Mul: {
-bool AddOverflow, ConversionOverflow;
-APFixedPoint Result = LHSFX.mul(RHSFX, &AddOverflow)
-   .convert(ResultFXSema, &ConversionOverflow);
-if ((AddOverflow || ConversionOverflow) &&
-!HandleOverflow(Info, E, Result, E->getType()))
-  return false;
-return Success(Result, E);
+Result = LHSFX.mul(RHSFX, &OpOverflow)
+  .convert(ResultFXSem

[clang] eccf7fc - [AST] Add fixed-point subtraction constant evaluation.

2020-06-26 Thread Bevin Hansson via cfe-commits

Author: Bevin Hansson
Date: 2020-06-26T13:38:11+02:00
New Revision: eccf7fc7b31a00823a0fe6c782ef312b3ba743c4

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

LOG: [AST] Add fixed-point subtraction constant evaluation.

Reviewers: rjmccall, leonardchan

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/FixedPoint.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Basic/FixedPoint.cpp
clang/test/Frontend/fixed_point_sub.c

Removed: 




diff  --git a/clang/include/clang/Basic/FixedPoint.h 
b/clang/include/clang/Basic/FixedPoint.h
index 55465c604a7d..1f3251982325 100644
--- a/clang/include/clang/Basic/FixedPoint.h
+++ b/clang/include/clang/Basic/FixedPoint.h
@@ -28,8 +28,8 @@ class QualType;
 /// The fixed point semantics work similarly to llvm::fltSemantics. The width
 /// specifies the whole bit width of the underlying scaled integer (with 
padding
 /// if any). The scale represents the number of fractional bits in this type.
-/// When HasUnsignedPadding is true and this type is signed, the first bit
-/// in the value this represents is treaded as padding.
+/// When HasUnsignedPadding is true and this type is unsigned, the first bit
+/// in the value this represents is treated as padding.
 class FixedPointSemantics {
 public:
   FixedPointSemantics(unsigned Width, unsigned Scale, bool IsSigned,
@@ -125,9 +125,10 @@ class APFixedPoint {
 
// Perform binary operations on a fixed point type. The resulting fixed 
point
// value will be in the common, full precision semantics that can represent
-   // the precision and ranges os both input values. See convert() for an
+   // the precision and ranges of both input values. See convert() for an
// explanation of the Overflow parameter.
APFixedPoint add(const APFixedPoint &Other, bool *Overflow = nullptr) const;
+   APFixedPoint sub(const APFixedPoint &Other, bool *Overflow = nullptr) const;
 
/// Perform a unary negation (-X) on this fixed point type, taking into
/// account saturation if applicable.

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index afae020f3dd2..5cdeb3cd0e67 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12924,7 +12924,16 @@ bool 
FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
   case BO_Add: {
 bool AddOverflow, ConversionOverflow;
 APFixedPoint Result = LHSFX.add(RHSFX, &AddOverflow)
-  .convert(ResultFXSema, &ConversionOverflow);
+   .convert(ResultFXSema, &ConversionOverflow);
+if ((AddOverflow || ConversionOverflow) &&
+!HandleOverflow(Info, E, Result, E->getType()))
+  return false;
+return Success(Result, E);
+  }
+  case BO_Sub: {
+bool AddOverflow, ConversionOverflow;
+APFixedPoint Result = LHSFX.sub(RHSFX, &AddOverflow)
+   .convert(ResultFXSema, &ConversionOverflow);
 if ((AddOverflow || ConversionOverflow) &&
 !HandleOverflow(Info, E, Result, E->getType()))
   return false;

diff  --git a/clang/lib/Basic/FixedPoint.cpp b/clang/lib/Basic/FixedPoint.cpp
index 05600dfc6d21..29d532f49561 100644
--- a/clang/lib/Basic/FixedPoint.cpp
+++ b/clang/lib/Basic/FixedPoint.cpp
@@ -173,6 +173,30 @@ APFixedPoint APFixedPoint::add(const APFixedPoint &Other,
   return APFixedPoint(Result, CommonFXSema);
 }
 
+APFixedPoint APFixedPoint::sub(const APFixedPoint &Other,
+   bool *Overflow) const {
+  auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
+  APFixedPoint ConvertedThis = convert(CommonFXSema);
+  APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
+  llvm::APSInt ThisVal = ConvertedThis.getValue();
+  llvm::APSInt OtherVal = ConvertedOther.getValue();
+  bool Overflowed = false;
+
+  llvm::APSInt Result;
+  if (CommonFXSema.isSaturated()) {
+Result = CommonFXSema.isSigned() ? ThisVal.ssub_sat(OtherVal)
+ : ThisVal.usub_sat(OtherVal);
+  } else {
+Result = ThisVal.isSigned() ? ThisVal.ssub_ov(OtherVal, Overflowed)
+: ThisVal.usub_ov(OtherVal, Overflowed);
+  }
+
+  if (Overflow)
+*Overflow = Overflowed;
+
+  return APFixedPoint(Result, CommonFXSema);
+}
+
 void APFixedPoint::toString(llvm::SmallVectorImpl &Str) const {
   llvm::APSInt Val = getValue();
   unsigned Scale = getScale();

diff  --git a/clang/test/Frontend/fixed_point_sub.c 
b/clang/test/Frontend/fixed_point_sub.c
index 59b2e0a43aed..1e449537ae23 100644
--- a/clang/test/Frontend/fixed_point_sub.c
+++ b/clang/test/Frontend/fixed_point_sub.c
@@ -1,6 +1,55 @@
 // RUN: %clang_cc1 -ff

[clang] bb26838 - [clang driver] Move default module cache from system temporary directory

2020-06-26 Thread David Zarzycki via cfe-commits

Author: David Zarzycki
Date: 2020-06-26T07:46:03-04:00
New Revision: bb26838ceffb5feaa18186f55f7525a08084899e

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

LOG: [clang driver] Move default module cache from system temporary directory

1) Shared writable directories like /tmp are a security problem.
2) Systems provide dedicated cache directories these days anyway.
3) This also refines LLVM's cache_directory() on Darwin platforms to use
   the Darwin per-user cache directory.

Reviewers: compnerd, aprantl, jakehehrlich, espindola, respindola, 
ilya-biryukov, pcc, sammccall

Reviewed By: compnerd, sammccall

Subscribers: hiraditya, llvm-commits, cfe-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Driver.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/modules-cache-path.m
clang/unittests/Driver/ModuleCacheTest.cpp
llvm/lib/Support/Unix/Path.inc

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 15e6d35117b4..c24c289f94b4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -104,6 +104,10 @@ New Compiler Flags
   simplify access to the many single purpose floating point options. The 
default
   setting is ``precise``.
 
+- The default module cache has moved from /tmp to a per-user cache directory.
+  By default, this is ~/.cache but on some platforms or installations, this
+  might be elsewhere. The -fmodules-cache-path=... flag continues to work.
+
 Deprecated Compiler Flags
 -
 

diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index b024d6a0d3a3..dc18f1314f81 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -621,7 +621,8 @@ class Driver {
   static bool GetReleaseVersion(StringRef Str,
 MutableArrayRef Digits);
   /// Compute the default -fmodule-cache-path.
-  static void getDefaultModuleCachePath(SmallVectorImpl &Result);
+  /// \return True if the system provides a default cache directory.
+  static bool getDefaultModuleCachePath(SmallVectorImpl &Result);
 };
 
 /// \return True if the last defined optimization level is -Ofast.

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 8903641a26c6..1fd638f435b9 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -721,38 +721,6 @@ static void addDashXForInput(const ArgList &Args, const 
InputInfo &Input,
   }
 }
 
-static void appendUserToPath(SmallVectorImpl &Result) {
-#ifdef LLVM_ON_UNIX
-  const char *Username = getenv("LOGNAME");
-#else
-  const char *Username = getenv("USERNAME");
-#endif
-  if (Username) {
-// Validate that LoginName can be used in a path, and get its length.
-size_t Len = 0;
-for (const char *P = Username; *P; ++P, ++Len) {
-  if (!clang::isAlphanumeric(*P) && *P != '_') {
-Username = nullptr;
-break;
-  }
-}
-
-if (Username && Len > 0) {
-  Result.append(Username, Username + Len);
-  return;
-}
-  }
-
-// Fallback to user id.
-#ifdef LLVM_ON_UNIX
-  std::string UID = llvm::utostr(getuid());
-#else
-  // FIXME: Windows seems to have an 'SID' that might work.
-  std::string UID = "";
-#endif
-  Result.append(UID.begin(), UID.end());
-}
-
 static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
const Driver &D, const InputInfo &Output,
const ArgList &Args,
@@ -3201,11 +3169,13 @@ static void RenderBuiltinOptions(const ToolChain &TC, 
const llvm::Triple &T,
 CmdArgs.push_back("-fno-math-builtin");
 }
 
-void Driver::getDefaultModuleCachePath(SmallVectorImpl &Result) {
-  llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/false, Result);
-  llvm::sys::path::append(Result, "org.llvm.clang.");
-  appendUserToPath(Result);
-  llvm::sys::path::append(Result, "ModuleCache");
+bool Driver::getDefaultModuleCachePath(SmallVectorImpl &Result) {
+  if (llvm::sys::path::cache_directory(Result)) {
+llvm::sys::path::append(Result, "clang");
+llvm::sys::path::append(Result, "ModuleCache");
+return true;
+  }
+  return false;
 }
 
 static void RenderModulesOptions(Compilation &C, const Driver &D,
@@ -3262,6 +3232,7 @@ static void RenderModulesOptions(Compilation &C, const 
Driver &D,
 if (Arg *A = Args.getLastArg(options::OPT_fmodules_cache_path))
   Path = A->getValue();
 
+bool HasPath = true;
 if (C.isForDiagnostics()) {
   // When generating crash reports, we want to emit the modules along with

[PATCH] D82362: Move default module cache from system temporary directory

2020-06-26 Thread David Zarzycki via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb26838ceffb: [clang driver] Move default module cache from 
system temporary directory (authored by davezarzycki).

Changed prior to commit:
  https://reviews.llvm.org/D82362?vs=272655&id=273674#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82362

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/modules-cache-path.m
  clang/unittests/Driver/ModuleCacheTest.cpp
  llvm/lib/Support/Unix/Path.inc

Index: llvm/lib/Support/Unix/Path.inc
===
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -1133,19 +1133,6 @@
   return true;
 }
 
-bool cache_directory(SmallVectorImpl &result) {
-  if (const char *RequestedDir = getenv("XDG_CACHE_HOME")) {
-result.clear();
-result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
-return true;
-  }
-  if (!home_directory(result)) {
-return false;
-  }
-  append(result, ".cache");
-  return true;
-}
-
 static bool getDarwinConfDir(bool TempDir, SmallVectorImpl &Result) {
   #if defined(_CS_DARWIN_USER_TEMP_DIR) && defined(_CS_DARWIN_USER_CACHE_DIR)
   // On Darwin, use DARWIN_USER_TEMP_DIR or DARWIN_USER_CACHE_DIR.
@@ -1171,6 +1158,27 @@
   return false;
 }
 
+bool cache_directory(SmallVectorImpl &result) {
+#ifdef __APPLE__
+  if (getDarwinConfDir(false/*tempDir*/, result)) {
+return true;
+  }
+#else
+  // XDG_CACHE_HOME as defined in the XDG Base Directory Specification:
+  // http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
+  if (const char *RequestedDir = getenv("XDG_CACHE_HOME")) {
+result.clear();
+result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
+return true;
+  }
+#endif
+  if (!home_directory(result)) {
+return false;
+  }
+  append(result, ".cache");
+  return true;
+}
+
 static const char *getEnvTempDir() {
   // Check whether the temporary directory is specified by an environment
   // variable.
Index: clang/unittests/Driver/ModuleCacheTest.cpp
===
--- clang/unittests/Driver/ModuleCacheTest.cpp
+++ clang/unittests/Driver/ModuleCacheTest.cpp
@@ -21,7 +21,7 @@
   SmallString<128> Buf;
   Driver::getDefaultModuleCachePath(Buf);
   StringRef Path = Buf;
-  EXPECT_TRUE(Path.find("org.llvm.clang") != Path.npos);
+  EXPECT_TRUE(Path.find("clang") != Path.npos);
   EXPECT_TRUE(Path.endswith("ModuleCache"));  
 }
 } // end anonymous namespace.
Index: clang/test/Driver/modules-cache-path.m
===
--- clang/test/Driver/modules-cache-path.m
+++ clang/test/Driver/modules-cache-path.m
@@ -1,5 +1,2 @@
-// RUN: env USERNAME=asdf LOGNAME=asdf %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-SET
-// CHECK-SET: -fmodules-cache-path={{.*}}org.llvm.clang.asdf{{[/\\]+}}ModuleCache
-
 // RUN: %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-DEFAULT
-// CHECK-DEFAULT: -fmodules-cache-path={{.*}}org.llvm.clang.{{[A-Za-z0-9_]*[/\\]+}}ModuleCache
+// CHECK-DEFAULT: -fmodules-cache-path={{.*}}clang{{[/\\]+}}ModuleCache
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -721,38 +721,6 @@
   }
 }
 
-static void appendUserToPath(SmallVectorImpl &Result) {
-#ifdef LLVM_ON_UNIX
-  const char *Username = getenv("LOGNAME");
-#else
-  const char *Username = getenv("USERNAME");
-#endif
-  if (Username) {
-// Validate that LoginName can be used in a path, and get its length.
-size_t Len = 0;
-for (const char *P = Username; *P; ++P, ++Len) {
-  if (!clang::isAlphanumeric(*P) && *P != '_') {
-Username = nullptr;
-break;
-  }
-}
-
-if (Username && Len > 0) {
-  Result.append(Username, Username + Len);
-  return;
-}
-  }
-
-// Fallback to user id.
-#ifdef LLVM_ON_UNIX
-  std::string UID = llvm::utostr(getuid());
-#else
-  // FIXME: Windows seems to have an 'SID' that might work.
-  std::string UID = "";
-#endif
-  Result.append(UID.begin(), UID.end());
-}
-
 static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
const Driver &D, const InputInfo &Output,
const ArgList &Args,
@@ -3201,11 +3169,13 @@
 CmdArgs.push_back("-fno-math-builtin");
 }
 
-void Driver::getDefaultModuleCachePath(SmallVectorImpl &Result) {
-  llvm::sys::path::system_temp_directory(/*erasedOnReboot=*/false, Result);
-  llvm::sys::path::append(Result, "org.llvm.clang.");
-  appendUserToPath(Result);
-  llvm::sys::path::append(Result, "ModuleCache");
+bool Dri

[PATCH] D73187: [AST] Add fixed-point division constant evaluation.

2020-06-26 Thread Bevin Hansson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG94e8ec631dda: [AST] Add fixed-point division constant 
evaluation. (authored by ebevhan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73187

Files:
  clang/include/clang/Basic/FixedPoint.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/FixedPoint.cpp
  clang/test/Frontend/fixed_point_div.c

Index: clang/test/Frontend/fixed_point_div.c
===
--- clang/test/Frontend/fixed_point_div.c
+++ clang/test/Frontend/fixed_point_div.c
@@ -1,6 +1,70 @@
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -fpadding-on-unsigned-fixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED
 
+// Division between different fixed point types
+short _Accum sa_const = 1.0hk / 2.0hk;  // CHECK-DAG: @sa_const  = {{.*}}global i16 64, align 2
+_Accum a_const = 1.0hk / 2.0k;  // CHECK-DAG: @a_const   = {{.*}}global i32 16384, align 4
+long _Accum la_const = 1.0hk / 2.0lk;   // CHECK-DAG: @la_const  = {{.*}}global i64 1073741824, align 8
+short _Accum sa_const2 = 0.5hr / 2.0hk; // CHECK-DAG: @sa_const2  = {{.*}}global i16 32, align 2
+short _Accum sa_const3 = 0.5r / 2.0hk;  // CHECK-DAG: @sa_const3  = {{.*}}global i16 32, align 2
+short _Accum sa_const4 = 0.5lr / 2.0hk; // CHECK-DAG: @sa_const4  = {{.*}}global i16 32, align 2
+short _Accum sa_const5 = 2.0hk / 0.5lr; // CHECK-DAG: @sa_const5  = {{.*}}global i16 512, align 2
+
+// Unsigned division
+unsigned short _Accum usa_const = 3.0uhk / 2.0uhk;
+// CHECK-SIGNED-DAG:   @usa_const = {{.*}}global i16 192, align 2
+// CHECK-UNSIGNED-DAG: @usa_const = {{.*}}global i16 384, align 2
+
+// Unsigned / signed
+short _Accum sa_const6 = 1.0uhk / 2.0hk;
+// CHECK-DAG: @sa_const6 = {{.*}}global i16 64, align 2
+
+// Division with negative number
+short _Accum sa_const7 = 0.5hr / (-2.0hk);
+// CHECK-DAG: @sa_const7 = {{.*}}global i16 -32, align 2
+
+// Int division
+unsigned short _Accum usa_const2 = 2 / 0.5uhk;
+// CHECK-SIGNED-DAG:   @usa_const2 = {{.*}}global i16 512, align 2
+// CHECK-UNSIGNED-DAG: @usa_const2 = {{.*}}global i16 1024, align 2
+short _Accum sa_const8 = 2 / (-0.5hk);   // CHECK-DAG: @sa_const8 = {{.*}}global i16 -512, align 2
+short _Accum sa_const9 = 256 / 2.0hk;// CHECK-DAG: @sa_const9 = {{.*}}global i16 16384, align 2
+long _Fract lf_const = 0.5lr / -1;   // CHECK-DAG: @lf_const  = {{.*}}global i32 -1073741824, align 4
+
+// Saturated division
+_Sat short _Accum sat_sa_const = (_Sat short _Accum)128.0hk / (-0.25hk);
+// CHECK-DAG: @sat_sa_const = {{.*}}global i16 -32768, align 2
+_Sat unsigned short _Accum sat_usa_const = (_Sat unsigned short _Accum)128.0uhk / (0.25uhk);
+// CHECK-SIGNED-DAG:   @sat_usa_const = {{.*}}global i16 65535, align 2
+// CHECK-UNSIGNED-DAG: @sat_usa_const = {{.*}}global i16 32767, align 2
+_Sat short _Accum sat_sa_const2 = (_Sat short _Accum)-128.0hk / (-0.0125hr);
+// CHECK-DAG: @sat_sa_const2 = {{.*}}global i16 32767, align 2
+_Sat unsigned short _Accum sat_usa_const2 = (_Sat unsigned short _Accum)128.0uhk / (-128);
+// CHECK-SIGNED-DAG:   @sat_usa_const2 = {{.*}}global i16 65535, align 2
+// CHECK-UNSIGNED-DAG: @sat_usa_const2 = {{.*}}global i16 32767, align 2
+_Sat unsigned short _Accum sat_usa_const3 = (_Sat unsigned short _Accum)0.5uhk / -1;
+// CHECK-DAG:   @sat_usa_const3 = {{.*}}global i16 0, align 2
+_Sat short _Accum sat_sa_const3 = (_Sat short _Accum)-128.0hk / 128;
+// CHECK-DAG: @sat_sa_const3 = {{.*}}global i16 -128, align 2
+_Sat short _Accum sat_sa_const4 = (_Sat short _Accum)-25.7hk / 0.1lk;
+// CHECK-DAG: @sat_sa_const4 = {{.*}}global i16 -32768, align 2
+
+// Some more cases
+short _Accum sa_const10 = 255.9921875hk / 255.9921875hk;
+// CHECK-DAG: @sa_const10 = {{.*}}global i16 128, align 2
+short _Accum sat_sa_const5 = (_Sat short _Accum)(-255.0hk - 1.0hk) / 0.0078125hk;
+// CHECK-DAG: @sat_sa_const5 = {{.*}}global i16 -32768, align 2
+_Sat short _Accum sat_sa_const6 = (_Sat short _Accum)(-255.0hk - 1.0hk) / -0.0078125hk;
+// CHECK-DAG: @sat_sa_const6 = {{.*}}global i16 32767, align 2
+short _Accum sa_const12 = 255.9921875hk / -1.0hk;
+// CHECK-DAG: @sa_const12 = {{.*}}global i16 -32767, align 2
+_Sat short _Accum sat_sa_const7 = (_Sat short _Accum)(-255.0hk - 1.0hk) / -1.0hk;
+// CHECK-DAG: @sat_sa_const7 = {{.*}}global i16 32767, align 2
+short _Accum sa_const13 = 0.0234375hk / 2.0hk;
+// CHECK-DAG: @sa_const13 = {{.*}}global i16 1, align 2
+short _Accum sa_const14 = -0.0234375hk / 2.0hk;
+// CHECK-DAG: @sa_const14 = {{.*}}global i16 -2, align 2
+
 void SignedDivision() {
   // CHECK-LABEL: SignedDivision
   short _Accum sa;
Index: clang/lib/Basic/FixedPoint.cpp
=

[PATCH] D73188: [AST] Improve overflow diagnostics for fixed-point constant evaluation.

2020-06-26 Thread Bevin Hansson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG474177c05381: [AST] Improve overflow diagnostics for 
fixed-point constant evaluation. (authored by ebevhan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73188

Files:
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/test/Frontend/fixed_point_errors.c

Index: clang/test/Frontend/fixed_point_errors.c
===
--- clang/test/Frontend/fixed_point_errors.c
+++ clang/test/Frontend/fixed_point_errors.c
@@ -250,3 +250,17 @@
 char c_const = 256.0uk;   // expected-warning{{implicit conversion from 256.0 cannot fit within the range of values for 'char'}}
 short _Accum sa_const5 = 256; // expected-warning{{implicit conversion from 256 cannot fit within the range of values for 'short _Accum'}}
 unsigned short _Accum usa_const2 = -2;// expected-warning{{implicit conversion from -2 cannot fit within the range of values for 'unsigned short _Accum'}}
+
+short _Accum add_ovf1 = 255.0hk + 20.0hk; // expected-warning {{overflow in expression; result is -237.0 with type 'short _Accum'}}
+short _Accum add_ovf2 = 10 + 0.5hr;   // expected-warning {{overflow in expression; result is 0.5 with type 'short _Fract'}}
+short _Accum sub_ovf1 = 16.0uhk - 32.0uhk;// expected-warning {{overflow in expression; result is 240.0 with type 'unsigned short _Accum'}}
+short _Accum sub_ovf2 = -255.0hk - 20;// expected-warning {{overflow in expression; result is 237.0 with type 'short _Accum'}}
+short _Accum mul_ovf1 = 200.0uhk * 10.0uhk;   // expected-warning {{overflow in expression; result is 208.0 with type 'unsigned short _Accum'}}
+short _Accum mul_ovf2 = (-0.5hr - 0.5hr) * (-0.5hr - 0.5hr);  // expected-warning {{overflow in expression; result is -1.0 with type 'short _Fract'}}
+short _Accum div_ovf1 = 255.0hk / 0.5hk;  // expected-warning {{overflow in expression; result is -2.0 with type 'short _Accum'}}
+
+// No warnings for saturation
+short _Fract add_sat  = (_Sat short _Fract)0.5hr + 0.5hr;
+short _Accum sub_sat  = (_Sat short _Accum)-200.0hk - 80.0hk;
+short _Accum mul_sat  = (_Sat short _Accum)80.0hk * 10.0hk;
+short _Fract div_sat  = (_Sat short _Fract)0.9hr / 0.1hr;
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -12881,8 +12881,14 @@
   return false;
 bool Overflowed;
 APFixedPoint Result = Src.convert(DestFXSema, &Overflowed);
-if (Overflowed && !HandleOverflow(Info, E, Result, DestType))
-  return false;
+if (Overflowed) {
+  if (Info.checkingForUndefinedBehavior())
+Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
+ diag::warn_fixedpoint_constant_overflow)
+  << Result.toString() << E->getType();
+  else if (!HandleOverflow(Info, E, Result, E->getType()))
+return false;
+}
 return Success(Result, E);
   }
   case CK_IntegralToFixedPoint: {
@@ -12894,8 +12900,14 @@
 APFixedPoint IntResult = APFixedPoint::getFromIntValue(
 Src, Info.Ctx.getFixedPointSemantics(DestType), &Overflowed);
 
-if (Overflowed && !HandleOverflow(Info, E, IntResult, DestType))
-  return false;
+if (Overflowed) {
+  if (Info.checkingForUndefinedBehavior())
+Info.Ctx.getDiagnostics().Report(E->getExprLoc(),
+ diag::warn_fixedpoint_constant_overflow)
+  << IntResult.toString() << E->getType();
+  else if (!HandleOverflow(Info, E, IntResult, E->getType()))
+return false;
+}
 
 return Success(IntResult, E);
   }
@@ -12920,47 +12932,41 @@
   if (!EvaluateFixedPointOrInteger(RHS, RHSFX, Info))
 return false;
 
+  bool OpOverflow = false, ConversionOverflow = false;
+  APFixedPoint Result(LHSFX.getSemantics());
   switch (E->getOpcode()) {
   case BO_Add: {
-bool AddOverflow, ConversionOverflow;
-APFixedPoint Result = LHSFX.add(RHSFX, &AddOverflow)
-   .convert(ResultFXSema, &ConversionOverflow);
-if ((AddOverflow || ConversionOverflow) &&
-!HandleOverflow(Info, E, Result, E->getType()))
-  return false;
-return Success(Result, E);
+Result = LHSFX.add(RHSFX, &OpOverflow)
+  .convert(ResultFXSema, &ConversionOverflow);
+break;
   }
   case BO_Sub: {
-bool AddOverflow, ConversionOverflow;
-APFixedPoint Result = LHSFX.sub(RHSFX, &AddOverflow)
-   .convert(ResultFXSema, &ConversionOverflow);
-if ((AddOverflow || ConversionOverflow) &&
-!HandleOverflow(Info, E, Result, E->ge

[PATCH] D73189: [AST] Fix certain consteval assignment and comma operator issues with fixed-point types.

2020-06-26 Thread Bevin Hansson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGda2f852e1913: [AST] Fix certain consteval assignment and 
comma operator issues with fixed… (authored by ebevhan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73189

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/Frontend/fixed_point_crash.c


Index: clang/test/Frontend/fixed_point_crash.c
===
--- /dev/null
+++ clang/test/Frontend/fixed_point_crash.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify -ffixed-point %s
+
+union a {
+  _Accum x;
+  int i;
+};
+
+int fn1() {
+  union a m;
+  m.x = 5.6k;
+  return m.i;
+}
+
+int fn2() {
+  union a m;
+  m.x = 7, 5.6k; // expected-warning {{expression result unused}}
+  return m.x, m.i; // expected-warning {{expression result unused}}
+}
+
+_Accum acc = (0.5r, 6.9k); // expected-warning {{expression result unused}}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -12920,6 +12920,9 @@
 }
 
 bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
+  if (E->isPtrMemOp() || E->isAssignmentOp() || E->getOpcode() == BO_Comma)
+return ExprEvaluatorBaseTy::VisitBinaryOperator(E);
+
   const Expr *LHS = E->getLHS();
   const Expr *RHS = E->getRHS();
   FixedPointSemantics ResultFXSema =


Index: clang/test/Frontend/fixed_point_crash.c
===
--- /dev/null
+++ clang/test/Frontend/fixed_point_crash.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -verify -ffixed-point %s
+
+union a {
+  _Accum x;
+  int i;
+};
+
+int fn1() {
+  union a m;
+  m.x = 5.6k;
+  return m.i;
+}
+
+int fn2() {
+  union a m;
+  m.x = 7, 5.6k; // expected-warning {{expression result unused}}
+  return m.x, m.i; // expected-warning {{expression result unused}}
+}
+
+_Accum acc = (0.5r, 6.9k); // expected-warning {{expression result unused}}
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -12920,6 +12920,9 @@
 }
 
 bool FixedPointExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
+  if (E->isPtrMemOp() || E->isAssignmentOp() || E->getOpcode() == BO_Comma)
+return ExprEvaluatorBaseTy::VisitBinaryOperator(E);
+
   const Expr *LHS = E->getLHS();
   const Expr *RHS = E->getRHS();
   FixedPointSemantics ResultFXSema =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73186: [AST] Add fixed-point multiplication constant evaluation.

2020-06-26 Thread Bevin Hansson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG53f5c8b4a14c: [AST] Add fixed-point multiplication constant 
evaluation. (authored by ebevhan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73186

Files:
  clang/include/clang/Basic/FixedPoint.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/FixedPoint.cpp
  clang/test/Frontend/fixed_point_mul.c

Index: clang/test/Frontend/fixed_point_mul.c
===
--- clang/test/Frontend/fixed_point_mul.c
+++ clang/test/Frontend/fixed_point_mul.c
@@ -1,6 +1,49 @@
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -fpadding-on-unsigned-fixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED
 
+// Multiplication between different fixed point types
+short _Accum sa_const = 2.0hk * 2.0hk;  // CHECK-DAG: @sa_const  = {{.*}}global i16 512, align 2
+_Accum a_const = 3.0hk * 2.0k;  // CHECK-DAG: @a_const   = {{.*}}global i32 196608, align 4
+long _Accum la_const = 4.0hk * 2.0lk;   // CHECK-DAG: @la_const  = {{.*}}global i64 17179869184, align 8
+short _Accum sa_const2 = 0.5hr * 2.0hk; // CHECK-DAG: @sa_const2  = {{.*}}global i16 128, align 2
+short _Accum sa_const3 = 0.5r * 3.0hk;  // CHECK-DAG: @sa_const3  = {{.*}}global i16 192, align 2
+short _Accum sa_const4 = 0.5lr * 4.0hk; // CHECK-DAG: @sa_const4  = {{.*}}global i16 256, align 2
+
+// Unsigned multiplication
+unsigned short _Accum usa_const = 1.0uhk * 2.0uhk;
+// CHECK-SIGNED-DAG:   @usa_const = {{.*}}global i16 768, align 2
+// CHECK-UNSIGNED-DAG: @usa_const = {{.*}}global i16 384, align 2
+
+// Unsigned * signed
+short _Accum sa_const5 = 20.0uhk * 3.0hk;
+// CHECK-DAG: @sa_const5 = {{.*}}global i16 7680, align 2
+
+// Multiplication with negative number
+short _Accum sa_const6 = 0.5hr * (-2.0hk);
+// CHECK-DAG: @sa_const6 = {{.*}}global i16 -128, align 2
+
+// Int multiplication
+unsigned short _Accum usa_const2 = 5 * 10.5uhk;
+// CHECK-SIGNED-DAG:   @usa_const2 = {{.*}}global i16 640, align 2
+// CHECK-UNSIGNED-DAG: @usa_const2 = {{.*}}global i16 320, align 2
+short _Accum sa_const7 = 3 * (-0.5hk);   // CHECK-DAG: @sa_const7 = {{.*}}global i16 -192, align 2
+short _Accum sa_const8 = 100 * (-2.0hk); // CHECK-DAG: @sa_const8 = {{.*}}global i16 -25600, align 2
+long _Fract lf_const = -0.25lr * 3;  // CHECK-DAG: @lf_const  = {{.*}}global i32 -1610612736, align 4
+
+// Saturated multiplication
+_Sat short _Accum sat_sa_const = (_Sat short _Accum)128.0hk * 3.0hk;
+// CHECK-DAG: @sat_sa_const = {{.*}}global i16 32767, align 2
+_Sat unsigned short _Accum sat_usa_const = (_Sat unsigned short _Accum)128.0uhk * 128.0uhk;
+// CHECK-SIGNED-DAG:   @sat_usa_const = {{.*}}global i16 65535, align 2
+// CHECK-UNSIGNED-DAG: @sat_usa_const = {{.*}}global i16 32767, align 2
+_Sat short _Accum sat_sa_const2 = (_Sat short _Accum)128.0hk * -128;
+// CHECK-DAG: @sat_sa_const2 = {{.*}}global i16 -32768, align 2
+_Sat unsigned short _Accum sat_usa_const2 = (_Sat unsigned short _Accum)128.0uhk * 30;
+// CHECK-SIGNED-DAG:   @sat_usa_const2 = {{.*}}global i16 65535, align 2
+// CHECK-UNSIGNED-DAG: @sat_usa_const2 = {{.*}}global i16 32767, align 2
+_Sat unsigned short _Accum sat_usa_const3 = (_Sat unsigned short _Accum)0.5uhk * (-2);
+// CHECK-DAG:   @sat_usa_const3 = {{.*}}global i16 0, align 2
+
 void SignedMultiplication() {
   // CHECK-LABEL: SignedMultiplication
   short _Accum sa;
Index: clang/lib/Basic/FixedPoint.cpp
===
--- clang/lib/Basic/FixedPoint.cpp
+++ clang/lib/Basic/FixedPoint.cpp
@@ -197,6 +197,63 @@
   return APFixedPoint(Result, CommonFXSema);
 }
 
+APFixedPoint APFixedPoint::mul(const APFixedPoint &Other,
+   bool *Overflow) const {
+  auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
+  APFixedPoint ConvertedThis = convert(CommonFXSema);
+  APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
+  llvm::APSInt ThisVal = ConvertedThis.getValue();
+  llvm::APSInt OtherVal = ConvertedOther.getValue();
+  bool Overflowed = false;
+
+  // Widen the LHS and RHS so we can perform a full multiplication.
+  unsigned Wide = CommonFXSema.getWidth() * 2;
+  if (CommonFXSema.isSigned()) {
+ThisVal = ThisVal.sextOrSelf(Wide);
+OtherVal = OtherVal.sextOrSelf(Wide);
+  } else {
+ThisVal = ThisVal.zextOrSelf(Wide);
+OtherVal = OtherVal.zextOrSelf(Wide);
+  }
+
+  // Perform the full multiplication and downscale to get the same scale.
+  //
+  // Note that the right shifts here perform an implicit downwards rounding.
+  // This rounding could discard bits that would technically place the result
+  // outside the representable range. We interpret t

[PATCH] D73185: [AST] Add fixed-point subtraction constant evaluation.

2020-06-26 Thread Bevin Hansson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeccf7fc7b31a: [AST] Add fixed-point subtraction constant 
evaluation. (authored by ebevhan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73185

Files:
  clang/include/clang/Basic/FixedPoint.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/FixedPoint.cpp
  clang/test/Frontend/fixed_point_sub.c

Index: clang/test/Frontend/fixed_point_sub.c
===
--- clang/test/Frontend/fixed_point_sub.c
+++ clang/test/Frontend/fixed_point_sub.c
@@ -1,6 +1,55 @@
 // RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
 // RUN: %clang_cc1 -ffixed-point -fpadding-on-unsigned-fixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED
 
+// Subtraction between different fixed point types
+short _Accum sa_const = 1.0hk - 2.0hk;  // CHECK-DAG: @sa_const  = {{.*}}global i16 -128, align 2
+_Accum a_const = 1.0hk - 2.0k;  // CHECK-DAG: @a_const   = {{.*}}global i32 -32768, align 4
+long _Accum la_const = 1.0hk - 2.0lk;   // CHECK-DAG: @la_const  = {{.*}}global i64 -2147483648, align 8
+short _Accum sa_const2 = 0.5hr - 2.0hk; // CHECK-DAG: @sa_const2  = {{.*}}global i16 -192, align 2
+short _Accum sa_const3 = 0.5r - 2.0hk;  // CHECK-DAG: @sa_const3  = {{.*}}global i16 -192, align 2
+short _Accum sa_const4 = 0.5lr - 2.0hk; // CHECK-DAG: @sa_const4  = {{.*}}global i16 -192, align 2
+short _Accum sa_const5 = 2.0hk - 0.5lr; // CHECK-DAG: @sa_const5  = {{.*}}global i16 192, align 2
+
+// Unsigned subtraction
+unsigned short _Accum usa_const = 3.0uhk - 2.0uhk;
+// CHECK-SIGNED-DAG:   @usa_const = {{.*}}global i16 768, align 2
+// CHECK-UNSIGNED-DAG: @usa_const = {{.*}}global i16 384, align 2
+
+// Unsigned - signed
+short _Accum sa_const6 = 1.0uhk - 2.0hk;
+// CHECK-DAG: @sa_const6 = {{.*}}global i16 -128, align 2
+
+// Subtraction with negative number
+short _Accum sa_const7 = 0.5hr - (-2.0hk);
+// CHECK-DAG: @sa_const7 = {{.*}}global i16 320, align 2
+
+// Int subtraction
+unsigned short _Accum usa_const2 = 2 - 0.5uhk;
+// CHECK-SIGNED-DAG:   @usa_const2 = {{.*}}global i16 640, align 2
+// CHECK-UNSIGNED-DAG: @usa_const2 = {{.*}}global i16 320, align 2
+short _Accum sa_const8 = 2 - (-0.5hk);   // CHECK-DAG: @sa_const8 = {{.*}}global i16 320, align 2
+short _Accum sa_const9 = 257 - 2.0hk;// CHECK-DAG: @sa_const9 = {{.*}}global i16 32640, align 2
+long _Fract lf_const = 0.5lr - 1;// CHECK-DAG: @lf_const  = {{.*}}global i32 -1073741824, align 4
+
+// Saturated subtraction
+_Sat short _Accum sat_sa_const = (_Sat short _Accum)128.0hk - (-128.0hk);
+// CHECK-DAG: @sat_sa_const = {{.*}}global i16 32767, align 2
+_Sat unsigned short _Accum sat_usa_const = (_Sat unsigned short _Accum)128.0uhk - (-128.0uhk);
+// CHECK-SIGNED-DAG:   @sat_usa_const = {{.*}}global i16 65535, align 2
+// CHECK-UNSIGNED-DAG: @sat_usa_const = {{.*}}global i16 32767, align 2
+_Sat short _Accum sat_sa_const2 = (_Sat short _Accum)128.0hk - (-128);
+// CHECK-DAG: @sat_sa_const2 = {{.*}}global i16 32767, align 2
+_Sat unsigned short _Accum sat_usa_const2 = (_Sat unsigned short _Accum)128.0uhk - (-128);
+// CHECK-SIGNED-DAG:   @sat_usa_const2 = {{.*}}global i16 65535, align 2
+// CHECK-UNSIGNED-DAG: @sat_usa_const2 = {{.*}}global i16 32767, align 2
+_Sat unsigned short _Accum sat_usa_const3 = (_Sat unsigned short _Accum)0.5uhk - 2;
+// CHECK-DAG:   @sat_usa_const3 = {{.*}}global i16 0, align 2
+_Sat short _Accum sat_sa_const3 = (_Sat short _Accum)-128.0hk - 128;
+// CHECK-DAG: @sat_sa_const3 = {{.*}}global i16 -32768, align 2
+_Sat short _Accum sat_sa_const4 = (_Sat short _Accum)-150.0hk - 130.0lk;
+// CHECK-DAG: @sat_sa_const4 = {{.*}}global i16 -32768, align 2
+
+
 void SignedSubtraction() {
   // CHECK-LABEL: SignedSubtraction
   short _Accum sa;
Index: clang/lib/Basic/FixedPoint.cpp
===
--- clang/lib/Basic/FixedPoint.cpp
+++ clang/lib/Basic/FixedPoint.cpp
@@ -173,6 +173,30 @@
   return APFixedPoint(Result, CommonFXSema);
 }
 
+APFixedPoint APFixedPoint::sub(const APFixedPoint &Other,
+   bool *Overflow) const {
+  auto CommonFXSema = Sema.getCommonSemantics(Other.getSemantics());
+  APFixedPoint ConvertedThis = convert(CommonFXSema);
+  APFixedPoint ConvertedOther = Other.convert(CommonFXSema);
+  llvm::APSInt ThisVal = ConvertedThis.getValue();
+  llvm::APSInt OtherVal = ConvertedOther.getValue();
+  bool Overflowed = false;
+
+  llvm::APSInt Result;
+  if (CommonFXSema.isSaturated()) {
+Result = CommonFXSema.isSigned() ? ThisVal.ssub_sat(OtherVal)
+ : ThisVal.usub_sat(OtherVal);
+  } else {
+Result = ThisVal.isSigned() ? ThisVal.ssub_ov(OtherVal, Overflowed)
+: ThisVal.usub_ov(Oth

[clang] f0bab78 - Triple.h - reduce Twine.h include to forward declarations. NFC.

2020-06-26 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-06-26T13:06:57+01:00
New Revision: f0bab7875e78e01c149d12302dcc4b6d4c43e25c

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

LOG: Triple.h - reduce Twine.h include to forward declarations. NFC.

Move include down to a number of other files that had an implicit dependency on 
the Twine class.

Added: 


Modified: 
clang/lib/Basic/IdentifierTable.cpp
clang/lib/Basic/Targets/Mips.h
llvm/include/llvm/ADT/Triple.h
llvm/include/llvm/Support/TargetRegistry.h
llvm/lib/MC/MCSectionELF.cpp
llvm/lib/Support/Triple.cpp
llvm/unittests/ADT/TripleTest.cpp
llvm/unittests/Frontend/OpenMPContextTest.cpp
llvm/unittests/Support/ThreadPool.cpp

Removed: 




diff  --git a/clang/lib/Basic/IdentifierTable.cpp 
b/clang/lib/Basic/IdentifierTable.cpp
index 36b26d9b7c68..55d3f6a447b2 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -23,6 +23,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"

diff  --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index b475c03889a1..e2fcda3329ab 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -16,6 +16,7 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/Compiler.h"
 
 namespace clang {

diff  --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index 89679619dd55..c039d424487d 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -9,7 +9,8 @@
 #ifndef LLVM_ADT_TRIPLE_H
 #define LLVM_ADT_TRIPLE_H
 
-#include "llvm/ADT/Twine.h"
+#include "llvm/ADT/StringRef.h"
+#include 
 
 // Some system headers or GCC predefined macros conflict with identifiers in
 // this file.  Undefine them here.
@@ -19,6 +20,7 @@
 
 namespace llvm {
 
+class Twine;
 class VersionTuple;
 
 /// Triple - Helper class for working with autoconf configuration names. For

diff  --git a/llvm/include/llvm/Support/TargetRegistry.h 
b/llvm/include/llvm/Support/TargetRegistry.h
index d91eabae8235..5592879630de 100644
--- a/llvm/include/llvm/Support/TargetRegistry.h
+++ b/llvm/include/llvm/Support/TargetRegistry.h
@@ -22,6 +22,7 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/ErrorHandling.h"

diff  --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index 77c259c27a04..ce94409a5429 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -8,6 +8,7 @@
 
 #include "llvm/MC/MCSectionELF.h"
 #include "llvm/ADT/Triple.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCExpr.h"

diff  --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
index 75ec257e15b5..c35ca9641f60 100644
--- a/llvm/lib/Support/Triple.cpp
+++ b/llvm/lib/Support/Triple.cpp
@@ -11,6 +11,7 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/SwapByteOrder.h"
@@ -18,6 +19,7 @@
 #include "llvm/Support/VersionTuple.h"
 #include 
 #include 
+
 using namespace llvm;
 
 StringRef Triple::getArchTypeName(ArchType Kind) {

diff  --git a/llvm/unittests/ADT/TripleTest.cpp 
b/llvm/unittests/ADT/TripleTest.cpp
index dc7a28c72f20..1dd6b32cb8eb 100644
--- a/llvm/unittests/ADT/TripleTest.cpp
+++ b/llvm/unittests/ADT/TripleTest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "llvm/ADT/Triple.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/VersionTuple.h"
 #include "gtest/gtest.h"
 

diff  --git a/llvm/unittests/Frontend/OpenMPContextTest.cpp 
b/llvm/unittests/Frontend/OpenMPContextTest.cpp
index eb505be042cb..9cdbd783ae18 100644
--- a/llvm/unittests/Frontend/OpenMPContextTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPContextTest.cpp
@@ -8,6 +8,7 @@
 
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Frontend/OpenMP/OMPContext.h"
+#include "llvm/ADT/Twine.h"
 #include "gtest/gtest.h"
 
 using namespace llvm;

diff  --git a/llvm/unittests/Support/ThreadPool.cpp 
b/llvm/unittests/Support/ThreadPool.cpp
index 43882d0f3cee..1f0b6804338b 100644
--- a/llvm/unittests/Support/ThreadPool.cpp
+++ b

[PATCH] D70411: [analyzer] CERT STR rule checkers: STR31-C

2020-06-26 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:859
+
+def Str31cChecker : Checker<"31c">,
+  HelpText<"SEI CERT checker of rules defined in STR31-C">,

Maybe we could have more descriptive names for these checkers and mention the 
number of the rule in the `HelpText` only.



Comment at: clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp:66
+  void checkStrcpy(const CallEvent &Call, const CallContext &CallC,
+   CheckerContext &C) const;
+  /// \}

I would avoid reusing the prefix `check` for functions that are not inherited 
from `Checker`. Alternatives could be `handle`, `process` etc. for modeling and 
`verify`, `validate` etc. for checking for error.


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

https://reviews.llvm.org/D70411



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


[PATCH] D70411: [analyzer] CERT STR rule checkers: STR31-C

2020-06-26 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt:21
   CastValueChecker.cpp
+  cert/StrChecker.cpp
   CheckObjCDealloc.cpp

Are there so many things common among checkers for SEI CERT string rules that 
the best option is to implemenet them in a single huge class/file? Would not it 
be more appropriate to create a library instead for common functions and then 
implement each rule in a separate checker class? Huge classes are difficult to 
understand.


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

https://reviews.llvm.org/D70411



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


[PATCH] D80932: [SYCL] Make default address space a superset of OpenCL address spaces.

2020-06-26 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

In D80932#2085848 , @Anastasia wrote:

> In D80932#2083185 , @bader wrote:
>
> > In D80932#2080631 , @Anastasia 
> > wrote:
> >
> > > > @Anastasia, if we make this change specific to SYCL mode, will it 
> > > > address your concerns?
> > >
> > > I can't answer this question for the reasons I have explained above.
> >
> >
> > Sorry, I'm not sure that I get your concern correctly, so let me clarify: 
> > is it allowing conversion between pointers w/ and w/o address space 
> > annotation in non-SYCL mode or using OpenCL address space attributes in 
> > SYCL mode?
> >
> > Just to help you to understand the proposed design, I created the full 
> > patch for address space handling in SYCL: 
> > https://github.com/bader/llvm/pull/18. There are few CodeGen tests 
> > validating LLVM IR for SPIR target. Fee free to ask any questions on this 
> > PR.
>
>
> Thanks! This is good but it is only an implementation of the design. Deducing 
> the design from an implementation is time-consuming and not sure it is even 
> feasible. I don't want to waste our time to provide you detailed feedback 
> based on my interpretation of your design and invalid assumptions. I don't 
> want to bind you to any particular format and we don't have any strict 
> requirement for this in LLVM either, but I would encourage you to take a look 
> at some of RFC threads sent to cfe-dev that explain new design concepts. 
> Perhaps, they can help you to understand what information can be provided as 
> a starting point to new design discussions.
>
> Particularly I would suggest covering these two points:
>
> - SYCL specifies address spaces as classes and it is not very obvious how did 
> you come from libraries classes to modifications in Clang? I believe there 
> are a number of design choices that you could make. One might think that you 
> can just implement address space classes using existing Clang functionality. 
> But if it is not sufficient it is important to understand what modifications 
> are required and why.
> - Other aspects that are important to highlight whether your design has any 
> limitations. For example, I don't quite understand your need for 
> `SPIR*SYCLDeviceTargetInfo`. Is there anything in your design that limits 
> compilation to one particular target?
>
>   Overall, I see that there are a lot of changes in CodeGen that are related 
> to the language semantic. I believe that CodeGen is supposed to be dialing 
> primarily with target-specific logic and I don't know if you should change 
> them to query target specific details instead. Also most of your CodeGen 
> changes are not related to OpenCL so I would make sure to loop @rjmccall in 
> this thread.


@Anastasia, sorry for the delay.
I've sent an email with RFC covering these questions to cfe-dev mailing list - 
http://lists.llvm.org/pipermail/cfe-dev/2020-June/066047.html.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80932



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


[PATCH] D82391: [AArch64][SVE] Add bfloat16 support to svext intrinsic

2020-06-26 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes updated this revision to Diff 273685.
c-rhodes added a comment.

Changes:

- Add tests for bfloat bitcast patterns.


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

https://reviews.llvm.org/D82391

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext-bfloat.c
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/test/CodeGen/AArch64/sve-bitcast.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -516,6 +516,16 @@
   ret  %out
 }
 
+define  @ext_bf16( %a,  %b) #0 {
+; CHECK-LABEL: ext_bf16:
+; CHECK: ext z0.b, z0.b, z1.b, #6
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ext.nxv8bf16( %a,
+%b,
+   i32 3)
+  ret  %out
+}
+
 define  @ext_f16( %a,  %b) {
 ; CHECK-LABEL: ext_f16:
 ; CHECK: ext z0.b, z0.b, z1.b, #6
@@ -1885,6 +1895,7 @@
 declare  @llvm.aarch64.sve.ext.nxv8i16(, , i32)
 declare  @llvm.aarch64.sve.ext.nxv4i32(, , i32)
 declare  @llvm.aarch64.sve.ext.nxv2i64(, , i32)
+declare  @llvm.aarch64.sve.ext.nxv8bf16(, , i32)
 declare  @llvm.aarch64.sve.ext.nxv8f16(, , i32)
 declare  @llvm.aarch64.sve.ext.nxv4f32(, , i32)
 declare  @llvm.aarch64.sve.ext.nxv2f64(, , i32)
Index: llvm/test/CodeGen/AArch64/sve-bitcast.ll
===
--- llvm/test/CodeGen/AArch64/sve-bitcast.ll
+++ llvm/test/CodeGen/AArch64/sve-bitcast.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s
-; RUN: not --crash llc -mtriple=aarch64_be -mattr=+sve < %s
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve,+bf16 < %s 2>%t | FileCheck %s
+; RUN: not --crash llc -mtriple=aarch64_be -mattr=+sve,+bf16 < %s
 ; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
 
 ; WARN-NOT: warning
@@ -53,6 +53,14 @@
   ret  %bc
 }
 
+define  @bitcast_bfloat_to_i8( %v) {
+; CHECK-LABEL: bitcast_bfloat_to_i8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ret
+  %bc = bitcast  %v to 
+  ret  %bc
+}
+
 define  @bitcast_i8_to_i16( %v) {
 ; CHECK-LABEL: bitcast_i8_to_i16:
 ; CHECK:   // %bb.0:
@@ -101,6 +109,14 @@
   ret  %bc
 }
 
+define  @bitcast_bfloat_to_i16( %v) {
+; CHECK-LABEL: bitcast_bfloat_to_i16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ret
+  %bc = bitcast  %v to 
+  ret  %bc
+}
+
 define  @bitcast_i8_to_i32( %v) {
 ; CHECK-LABEL: bitcast_i8_to_i32:
 ; CHECK:   // %bb.0:
@@ -340,3 +356,19 @@
   %bc = bitcast  %v to 
   ret  %bc
 }
+
+define  @bitcast_i8_to_bfloat( %v) {
+; CHECK-LABEL: bitcast_i8_to_bfloat:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ret
+  %bc = bitcast  %v to 
+  ret  %bc
+}
+
+define  @bitcast_i16_to_bfloat( %v) {
+; CHECK-LABEL: bitcast_i16_to_bfloat:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ret
+  %bc = bitcast  %v to 
+  ret  %bc
+}
Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -1444,7 +1444,6 @@
 def : Pat<(nxv8i16 (bitconvert (nxv4i32 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 def : Pat<(nxv8i16 (bitconvert (nxv2i64 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 def : Pat<(nxv8i16 (bitconvert (nxv8f16 ZPR:$src))), (nxv8i16 ZPR:$src)>;
-def : Pat<(nxv8i16 (bitconvert (nxv8bf16 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 def : Pat<(nxv8i16 (bitconvert (nxv4f32 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 def : Pat<(nxv8i16 (bitconvert (nxv2f64 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 
@@ -1464,7 +1463,6 @@
 
 def : Pat<(nxv8f16 (bitconvert (nxv16i8 ZPR:$src))), (nxv8f16 ZPR:$src)>;
 def : Pat<(nxv8f16 (bitconvert (nxv8i16 ZPR:$src))), (nxv8f16 ZPR:$src)>;
-def : Pat<(nxv8bf16 (bitconvert (nxv8i16 ZPR:$src))), (nxv8bf16 ZPR:$src)>;
 def : Pat<(nxv8f16 (bitconvert (nxv4i32 ZPR:$src))), (nxv8f16 ZPR:$src)>;
 def : Pat<(nxv8f16 (bitconvert (nxv2i64 ZPR:$src))), (nxv8f16 ZPR:$src)>;
 def : Pat<(nxv8f16 (bitconvert (nxv4f32 ZPR:$src))), (nxv8f16 ZPR:$src)>;
@@ -1483,6 +1481,16 @@
 def : Pat<(nxv2f64 (bitconvert (nxv2i64 ZPR:$src))), (nxv2f64 ZPR:$src)>;
 def : Pat<(nxv2f64 (bitconvert (nxv8f16 ZPR:$src))), (nxv2f64 ZPR:$src)>;
 def : Pat<(nxv2f64 (bitconvert (nxv4f32 ZPR:$src))), (nxv2f64 ZPR:$src)>;
+
+  }
+
+  let Predicates = [IsLE, HasBF16] in {
+def : Pat<(nxv16i8 (bitconvert (nxv8bf16 ZPR:$src))), (nxv16i8 ZPR:$src)>;
+
+def : Pat<(nxv8i16 (bitconvert (nxv8bf16 ZPR:$src))), (nxv8i16 ZPR:$src)>;
+
+def : Pat<(nxv8bf16 (bitconvert (nxv16i8 ZPR:$src))), (nxv8bf16 ZP

[clang] cb56fa2 - [MSP430] Update register names

2020-06-26 Thread Anton Korobeynikov via cfe-commits

Author: Anatoly Trosinenko
Date: 2020-06-26T15:32:07+03:00
New Revision: cb56fa2196c5d80ce72e8e8f6ee2a7ac80acca77

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

LOG: [MSP430] Update register names

When writing a unit test on replacing standard epilogue sequences with `BR 
__mspabi_func_epilog_`, by manually asm-clobbering `rN` - `r10` for N = 
4..10, everything worked well except for seeming inability to clobber r4.

The problem was that MSP430 code generator of LLVM used an obsolete name FP for 
that register. Things were worse because when `llc` read an unknown register 
name, it silently ignored it.

That is, I cannot use `fp` register name from the C code because Clang does not 
accept it (exactly like GCC). But the accepted name `r4` is not recognised by 
`llc` (it can be used in listings passed to `llvm-mc` and even `fp` is replace 
to `r4` by `llvm-mc`). So I can specify any of `fp` or `r4` for the string 
literal of `asm(...)` but nothing in the clobber list.

This patch replaces `MSP430::FP` with `MSP430::R4` in the backend code (even 
[MSP430 EABI](http://www.ti.com/lit/an/slaa534/slaa534.pdf) doesn't mention FP 
as a register name). The R0 - R3 registers, on the other hand, are left as is 
in the backend code (after all, they have some special meaning on the ISA 
level). It is just ensured clang is renaming them as expected by the downstream 
tools. There is probably not much sense in **marking them clobbered** but 
rename them //just in case// for use at potentially different contexts.

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

Added: 
clang/test/CodeGen/msp430-register-names.c
llvm/test/CodeGen/MSP430/inline-asm-register-names.ll

Modified: 
clang/lib/Basic/Targets/MSP430.h
llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
llvm/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp
llvm/lib/Target/MSP430/MSP430FrameLowering.cpp
llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
llvm/lib/Target/MSP430/MSP430RegisterInfo.cpp
llvm/lib/Target/MSP430/MSP430RegisterInfo.td
llvm/test/CodeGen/MSP430/asm-clobbers.ll

Removed: 




diff  --git a/clang/lib/Basic/Targets/MSP430.h 
b/clang/lib/Basic/Targets/MSP430.h
index 620f12d2b8e3..9d42e4d4bb18 100644
--- a/clang/lib/Basic/Targets/MSP430.h
+++ b/clang/lib/Basic/Targets/MSP430.h
@@ -64,8 +64,14 @@ class LLVM_LIBRARY_VISIBILITY MSP430TargetInfo : public 
TargetInfo {
   ArrayRef getGCCRegNames() const override;
 
   ArrayRef getGCCRegAliases() const override {
-// No aliases.
-return None;
+// Make r0 - r3 be recognized by llc (f.e., in clobber list)
+static const TargetInfo::GCCRegAlias GCCRegAliases[] = {
+{{"r0"}, "pc"},
+{{"r1"}, "sp"},
+{{"r2"}, "sr"},
+{{"r3"}, "cg"},
+};
+return llvm::makeArrayRef(GCCRegAliases);
   }
 
   bool validateAsmConstraint(const char *&Name,

diff  --git a/clang/test/CodeGen/msp430-register-names.c 
b/clang/test/CodeGen/msp430-register-names.c
new file mode 100644
index ..106b6c933a49
--- /dev/null
+++ b/clang/test/CodeGen/msp430-register-names.c
@@ -0,0 +1,105 @@
+// Registers R0 - R3 have 
diff erent names inside the LLVM MSP430 target code.
+// Test that they are handled properly when used inside clobber lists.
+// At the time of writing, llc silently ignores unknown register names.
+
+// REQUIRES: msp430-registered-target
+// RUN: %clang -target msp430 -c %s -mllvm -stop-after=finalize-isel -o- | 
FileCheck %s
+
+void test_function(void) {
+  asm volatile(""
+   :
+   :
+   : "r0");
+  asm volatile(""
+   :
+   :
+   : "r1");
+  asm volatile(""
+   :
+   :
+   : "r2");
+  asm volatile(""
+   :
+   :
+   : "r3");
+  asm volatile(""
+   :
+   :
+   : "r4");
+  asm volatile(""
+   :
+   :
+   : "r5");
+  asm volatile(""
+   :
+   :
+   : "r6");
+  asm volatile(""
+   :
+   :
+   : "r7");
+  asm volatile(""
+   :
+   :
+   : "r8");
+  asm volatile(""
+   :
+   :
+   : "r9");
+  asm volatile(""
+   :
+   :
+   : "r10");
+  asm volatile(""
+   :
+   :
+   : "r11");
+  asm volatile(""
+   :
+   :
+   : "r12");
+  asm volatile(""
+   :
+   :
+   : "r13");
+  asm volatile(""
+   :
+   :
+   : "r14");
+  asm volatile(""
+   :
+   :

[PATCH] D82646: [MSP430] Align the _Complex ABI with current msp430-gcc

2020-06-26 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko created this revision.
atrosinenko added reviewers: krisb, awygle, pftbest.
Herald added a project: clang.

Assembler output is checked against msp430-gcc 9.2.0.50 from TI.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82646

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/msp430-abi-complex.c

Index: clang/test/CodeGen/msp430-abi-complex.c
===
--- /dev/null
+++ clang/test/CodeGen/msp430-abi-complex.c
@@ -0,0 +1,96 @@
+// REQUIRES: msp430-registered-target
+// RUN: %clang -target msp430 -Os -S -o- %s | FileCheck %s
+
+volatile int N;
+volatile float f1, f2;
+volatile double d1, d2;
+
+void complex_float_arg_first(float _Complex x, int n) {
+// CHECK-LABEL: @complex_float_arg_first
+  f1 = __real__ x;
+// CHECK-DAG: mov r12, &f1
+// CHECK-DAG: mov r13, &f1+2
+  f2 = __imag__ x;
+// CHECK-DAG: mov r14, &f2
+// CHECK-DAG: mov r15, &f2+2
+  N = n;
+// CHECK-DAG: mov 2(r1), &N
+// CHECK: ret
+}
+
+void complex_float_arg_second(int n, float _Complex x) {
+// CHECK-LABEL: @complex_float_arg_second
+  N = n;
+// CHECK-DAG: mov r12, &N
+  f1 = __real__ x;
+// CHECK-DAG: mov 2(r1), &f1
+// CHECK-DAG: mov 4(r1), &f1+2
+// CHECK-DAG: mov 6(r1), &f2
+// CHECK-DAG: mov 8(r1), &f2+2
+  f2 = __imag__ x;
+// CHECK: ret
+}
+
+void complex_double_arg_first(double _Complex x, int n) {
+// CHECK-LABEL: @complex_double_arg_first
+  d1 = __real__ x;
+// CHECK-DAG: mov 2(r1), &d1
+// CHECK-DAG: mov 4(r1), &d1+2
+// CHECK-DAG: mov 6(r1), &d1+4
+// CHECK-DAG: mov 8(r1), &d1+6
+  d2 = __imag__ x;
+// CHECK-DAG: mov 10(r1), &d2
+// CHECK-DAG: mov 12(r1), &d2+2
+// CHECK-DAG: mov 14(r1), &d2+4
+// CHECK-DAG: mov 16(r1), &d2+6
+  N = n;
+// CHECK-DAG: mov r12, &N
+// CHECK: ret
+}
+
+void complex_double_arg_second(int n, double _Complex x) {
+// CHECK-LABEL: @complex_double_arg_second
+  d1 = __real__ x;
+// CHECK-DAG: mov 2(r1), &d1
+// CHECK-DAG: mov 4(r1), &d1+2
+// CHECK-DAG: mov 6(r1), &d1+4
+// CHECK-DAG: mov 8(r1), &d1+6
+  d2 = __imag__ x;
+// CHECK-DAG: mov 10(r1), &d2
+// CHECK-DAG: mov 12(r1), &d2+2
+// CHECK-DAG: mov 14(r1), &d2+4
+// CHECK-DAG: mov 16(r1), &d2+6
+  N = n;
+// CHECK-DAG: mov r12, &N
+// CHECK: ret
+}
+
+float _Complex complex_float_res(void) {
+// CHECK-LABEL: @complex_float_res
+  float _Complex res;
+  __real__ res = 1;
+// CHECK-DAG: clr r12
+// CHECK-DAG: mov #16256, r13
+  __imag__ res = -1;
+// CHECK-DAG: clr r14
+// CHECK-DAG: mov #-16512, r15
+  return res;
+// CHECK: ret
+}
+
+double _Complex complex_double_res(void) {
+// CHECK-LABEL: @complex_double_res
+  double _Complex res;
+  __real__ res = 1;
+// CHECK-DAG: clr 0(r12)
+// CHECK-DAG: clr 2(r12)
+// CHECK-DAG: clr 4(r12)
+// CHECK-DAG: mov #16368, 6(r12)
+  __imag__ res = -1;
+// CHECK-DAG: clr 8(r12)
+// CHECK-DAG: clr 10(r12)
+// CHECK-DAG: clr 12(r12)
+// CHECK-DAG: mov #-16400, 14(r12)
+  return res;
+// CHECK: ret
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -7370,10 +7370,49 @@
 
 namespace {
 
+class MSP430ABIInfo : public DefaultABIInfo {
+  static ABIArgInfo complexArgInfo() {
+ABIArgInfo Info = ABIArgInfo::getDirect();
+Info.setCanBeFlattened(false);
+return Info;
+  }
+
+public:
+  MSP430ABIInfo(CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
+
+  ABIArgInfo classifyReturnType(QualType RetTy) const {
+if (RetTy->isComplexType())
+  return complexArgInfo();
+
+return DefaultABIInfo::classifyReturnType(RetTy);
+  }
+
+  ABIArgInfo classifyArgumentType(QualType RetTy) const {
+if (RetTy->isComplexType())
+  return complexArgInfo();
+
+return DefaultABIInfo::classifyArgumentType(RetTy);
+  }
+
+  // Just copy the original implementations because
+  // DefaultABIInfo::classify{Return,Argument}Type() are not virtual
+  void computeInfo(CGFunctionInfo &FI) const override {
+if (!getCXXABI().classifyReturnType(FI))
+  FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+for (auto &I : FI.arguments())
+  I.info = classifyArgumentType(I.type);
+  }
+
+  Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
+QualType Ty) const override {
+return EmitVAArgInstr(CGF, VAListAddr, Ty, classifyArgumentType(Ty));
+  }
+};
+
 class MSP430TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   MSP430TargetCodeGenInfo(CodeGenTypes &CGT)
-  : TargetCodeGenInfo(std::make_unique(CGT)) {}
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &M) const override;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81869: Modify FPFeatures to use delta not absolute settings to solve PCH compatibility problems

2020-06-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Would you please add the following lit test

F12245277: diff.pch.txt 

If you change FastMath, FiniteMathOnly and UnsafeFPMath to COMPATIBLE_LANGOPT, 
the test should pass.




Comment at: clang/include/clang/Basic/LangOptions.def:192
 COMPATIBLE_LANGOPT(Deprecated, 1, 0, "__DEPRECATED predefined macro")
-COMPATIBLE_LANGOPT(FastMath  , 1, 0, "fast FP math optimizations, and 
__FAST_MATH__ predefined macro")
-COMPATIBLE_LANGOPT(FiniteMathOnly, 1, 0, "__FINITE_MATH_ONLY__ predefined 
macro")
-COMPATIBLE_LANGOPT(UnsafeFPMath  , 1, 0, "Unsafe Floating Point Math")
-COMPATIBLE_LANGOPT(AllowFPReassoc, 1, 0, "Permit Floating Point 
reassociation")
-COMPATIBLE_LANGOPT(NoHonorNaNs   , 1, 0, "Permit Floating Point 
optimization without regard to NaN")
-COMPATIBLE_LANGOPT(NoHonorInfs   , 1, 0, "Permit Floating Point 
optimization without regard to infinities")
-COMPATIBLE_LANGOPT(NoSignedZero  , 1, 0, "Permit Floating Point 
optimization without regard to signed zeros")
-COMPATIBLE_LANGOPT(AllowRecip, 1, 0, "Permit Floating Point 
reciprocal")
-COMPATIBLE_LANGOPT(ApproxFunc, 1, 0, "Permit Floating Point 
approximation")
+BENIGN_LANGOPT(FastMath  , 1, 0, "fast FP math optimizations, and 
__FAST_MATH__ predefined macro")
+BENIGN_LANGOPT(FiniteMathOnly, 1, 0, "__FINITE_MATH_ONLY__ predefined 
macro")

mibintc wrote:
> Here's another problem, I added the test case from bug 46166 @yaxunl but that 
> test case reports incompatibility because the pch is compiled with different 
> settings than where it is used. I thought maybe based on the name, 
> BENIGN_LANGOPT would  allow different option values to not get the pch 
> complaint but that didn't work, clang still complained about the different 
> option values.  Is there some existing way to get around the option complaint 
> or do I need to invent a new field in the LANGOPT e.g. a boolean that says 
> "Allow opton values to differ between pch-create and pch-use".  I haven't 
> deeply studied this to see if I'm missing something. I wanted to send this 
> out to get comments on my other questions 
can you make FastMath, FiniteMathOnly and UnsafeFPMath COMPATIBLE_LANGOPT as 
before? This allows users to use -fno-validate-pch to relax the check on them. 
This is the old behavior and I do not see a reason to change that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81869



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


[PATCH] D82650: [HIP] Set default FP_CONTRACT to ON

2020-06-26 Thread Daniil Fukalov via Phabricator via cfe-commits
dfukalov created this revision.
dfukalov added reviewers: yaxunl, b-sumner, rampitec.
Herald added subscribers: cfe-commits, Anastasia.
Herald added a project: clang.

With the FAST default FP_CONTRACT mode' setting for
`func(float a, float b, float c) { return a + b * c; }` FE generates pair
`fmul contract` + `fadd contract` that are fused to an fma operation in BE.

But OpenCL fuses these in FE. This approach seems more effective since avoids a
probabilty that these instructions are not fused in BE. Default setting can be
overridden with `#pragma STDC FP_CONTRACT` by a programmer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82650

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenHIP/fp-contract.hip
  clang/test/CodeGenHIP/lit.local.cfg


Index: clang/test/CodeGenHIP/lit.local.cfg
===
--- /dev/null
+++ clang/test/CodeGenHIP/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.cpp', '.hip']
Index: clang/test/CodeGenHIP/fp-contract.hip
===
--- /dev/null
+++ clang/test/CodeGenHIP/fp-contract.hip
@@ -0,0 +1,36 @@
+// By default we should fuse multiply/add into llvm.fmuladd instruction.
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm 
-fcuda-is-device -o - %s | FileCheck -check-prefixes ENABLED,ALL %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm 
-ffp-contract=on -fcuda-is-device -o - %s | FileCheck -check-prefixes 
ENABLED,ALL %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm 
-ffp-contract=fast -fcuda-is-device -o - %s | FileCheck -check-prefixes 
FAST,ALL %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm 
-ffp-contract=off -fcuda-is-device -o - %s | FileCheck -check-prefixes 
DISABLED,ALL %s
+
+#define __device__ __attribute__((device))
+
+// ALL-LABEL: func
+// ENABLED: call float @llvm.fmuladd.f32
+// FAST: fmul contract float
+// FAST-NEXT: fadd contract float
+// DISABLED: fmul float
+// DISABLED-NEXT: fadd float
+__device__ float func(float a, float b, float c) { return a + b * c; }
+
+// ALL-LABEL: func_on
+// ALL: call float @llvm.fmuladd.f32
+#pragma STDC FP_CONTRACT ON
+__device__ float func_on(float a, float b, float c) { return a + b * c; }
+
+// ALL-LABEL: func_off
+// ALL: fmul float
+// ALL-NEXT: fadd float
+#pragma STDC FP_CONTRACT OFF
+__device__ float func_off(float a, float b, float c) { return a + b * c; }
+
+// ALL-LABEL: func_def
+// ENABLED: call float @llvm.fmuladd.f32
+// FAST: fmul contract float
+// FAST-NEXT: fadd contract float
+// DISABLED: fmul float
+// DISABLED-NEXT: fadd float
+#pragma STDC FP_CONTRACT DEFAULT
+__device__ float func_def(float a, float b, float c) { return a + b * c; }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2374,6 +2374,10 @@
 // Set default FP_CONTRACT to FAST.
 Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
 
+  // Set default FP_CONTRACT to ON like for OpenCL.
+  if (Opts.HIP)
+Opts.setDefaultFPContractMode(LangOptions::FPM_On);
+
   Opts.RenderScript = IK.getLanguage() == Language::RenderScript;
   if (Opts.RenderScript) {
 Opts.NativeHalfType = 1;


Index: clang/test/CodeGenHIP/lit.local.cfg
===
--- /dev/null
+++ clang/test/CodeGenHIP/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.cpp', '.hip']
Index: clang/test/CodeGenHIP/fp-contract.hip
===
--- /dev/null
+++ clang/test/CodeGenHIP/fp-contract.hip
@@ -0,0 +1,36 @@
+// By default we should fuse multiply/add into llvm.fmuladd instruction.
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm -fcuda-is-device -o - %s | FileCheck -check-prefixes ENABLED,ALL %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm -ffp-contract=on -fcuda-is-device -o - %s | FileCheck -check-prefixes ENABLED,ALL %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm -ffp-contract=fast -fcuda-is-device -o - %s | FileCheck -check-prefixes FAST,ALL %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -emit-llvm -ffp-contract=off -fcuda-is-device -o - %s | FileCheck -check-prefixes DISABLED,ALL %s
+
+#define __device__ __attribute__((device))
+
+// ALL-LABEL: func
+// ENABLED: call float @llvm.fmuladd.f32
+// FAST: fmul contract float
+// FAST-NEXT: fadd contract float
+// DISABLED: fmul float
+// DISABLED-NEXT: fadd float
+__device__ float func(float a, float b, float c) { return a + b * c; }
+
+// ALL-LABEL: func_on
+// ALL: call float @llvm.fmuladd.f32
+#pragma STDC FP_CONTRACT ON
+__device__ float func_on(float a, float b, float c) { return a + b * c; }
+
+// 

[PATCH] D82184: [MSP430] Update register names

2020-06-26 Thread Anton Korobeynikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb56fa2196c5: [MSP430] Update register names (authored by 
atrosinenko, committed by asl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82184

Files:
  clang/lib/Basic/Targets/MSP430.h
  clang/test/CodeGen/msp430-register-names.c
  llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp
  llvm/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp
  llvm/lib/Target/MSP430/MSP430FrameLowering.cpp
  llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
  llvm/lib/Target/MSP430/MSP430RegisterInfo.cpp
  llvm/lib/Target/MSP430/MSP430RegisterInfo.td
  llvm/test/CodeGen/MSP430/asm-clobbers.ll
  llvm/test/CodeGen/MSP430/inline-asm-register-names.ll

Index: llvm/test/CodeGen/MSP430/inline-asm-register-names.ll
===
--- /dev/null
+++ llvm/test/CodeGen/MSP430/inline-asm-register-names.ll
@@ -0,0 +1,59 @@
+; RUN: llc < %s | FileCheck %s
+target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8"
+target triple = "msp430-generic-generic"
+
+; Test that correct register names are accepted *inside* inline asm listings.
+; Tested with PUSH instruction since it does not support memory operands.
+
+define void @accepted_rN() nounwind {
+; CHECK-LABEL: accepted_rN
+  call void asm sideeffect "push r0", ""() nounwind
+; CHECK: push r0
+  call void asm sideeffect "push r1", ""() nounwind
+; CHECK: push r1
+  call void asm sideeffect "push r2", ""() nounwind
+; CHECK: push r2
+  call void asm sideeffect "push r3", ""() nounwind
+; CHECK: push r3
+  call void asm sideeffect "push r4", ""() nounwind
+; CHECK: push r4
+  call void asm sideeffect "push r5", ""() nounwind
+; CHECK: push r5
+  call void asm sideeffect "push r6", ""() nounwind
+; CHECK: push r6
+  call void asm sideeffect "push r7", ""() nounwind
+; CHECK: push r7
+  call void asm sideeffect "push r8", ""() nounwind
+; CHECK: push r8
+  call void asm sideeffect "push r9", ""() nounwind
+; CHECK: push r9
+  call void asm sideeffect "push r10", ""() nounwind
+; CHECK: push r10
+  call void asm sideeffect "push r11", ""() nounwind
+; CHECK: push r11
+  call void asm sideeffect "push r12", ""() nounwind
+; CHECK: push r12
+  call void asm sideeffect "push r13", ""() nounwind
+; CHECK: push r13
+  call void asm sideeffect "push r14", ""() nounwind
+; CHECK: push r14
+  call void asm sideeffect "push r15", ""() nounwind
+; CHECK: push r15
+  ret void
+}
+
+define void @accepted_reg_aliases() nounwind {
+; CHECK-LABEL: accepted_reg_aliases
+; Ensure register aliases are renamed as expected
+call void asm sideeffect "push pc", ""() nounwind
+; CHECK: push r0
+call void asm sideeffect "push sp", ""() nounwind
+; CHECK: push r1
+call void asm sideeffect "push sr", ""() nounwind
+; CHECK: push r2
+call void asm sideeffect "push cg", ""() nounwind
+; CHECK: push r3
+call void asm sideeffect "push fp", ""() nounwind
+; CHECK: push r4
+ret void
+}
Index: llvm/test/CodeGen/MSP430/asm-clobbers.ll
===
--- llvm/test/CodeGen/MSP430/asm-clobbers.ll
+++ llvm/test/CodeGen/MSP430/asm-clobbers.ll
@@ -3,9 +3,52 @@
 target datalayout = "e-m:e-p:16:16-i32:16:32-a:16-n8:16"
 target triple = "msp430---elf"
 
-define void @test() {
+define void @test_no_clobber() {
 entry:
-; CHECK-LABEL: test:
+; CHECK-LABEL: test_no_clobber
+; CHECK-NOT: push
+  call void asm sideeffect "", ""()
+; CHECK-NOT: pop
+  ret void
+; CHECK: -- End function
+}
+
+define void @test_1() {
+entry:
+; CHECK-LABEL: test_1:
+; CHECK: push r8
+; CHECK: push r6
+; CHECK: push r4
+  call void asm sideeffect "", "~{r4},~{r6},~{r8}"()
+; CHECK: pop r4
+; CHECK: pop r6
+; CHECK: pop r8
+  ret void
+}
+
+define void @test_2() {
+entry:
+; CHECK-LABEL: test_2:
+; CHECK: push r9
+; CHECK: push r7
+; CHECK: push r5
+  call void asm sideeffect "", "~{r5},~{r7},~{r9}"()
+; CHECK: pop r5
+; CHECK: pop r7
+; CHECK: pop r9
+  ret void
+}
+
+; The r10 register is special because the sequence
+;   pop r10
+;   ret
+; can be replaced with
+;   jmp __mspabi_func_epilog_1
+; or other such function (depending on previous instructions).
+; Still, it is not replaced *yet*.
+define void @test_r10() {
+entry:
+; CHECK-LABEL: test_r10:
 ; CHECK: push r10
   call void asm sideeffect "", "~{r10}"()
 ; CHECK: pop r10
Index: llvm/lib/Target/MSP430/MSP430RegisterInfo.td
===
--- llvm/lib/Target/MSP430/MSP430RegisterInfo.td
+++ llvm/lib/Target/MSP430/MSP430RegisterInfo.td
@@ -36,7 +36,7 @@
 def SPB  : MSP430Reg<1,  "r1", ["sp"]>;
 def SRB  : MSP430Reg<2,  "r2", ["sr"]>;
 def CGB  : MSP430Reg<3,  "r3", ["cg"]>;
-def FPB  : MSP430Reg<4,  "r4", ["fp"]>;
+def R4B  : MSP430Reg<4,  "r4", ["fp"]>;
 def R5B  : MSP430Reg<5,  "r5">;
 def R6B  : MSP430Reg<6,  "r6">;
 def R7B  : MSP430Reg<7,  "r7">;
@@ -56,7 +56

[PATCH] D81408: [builtins] Improve compatibility with 16 bit targets

2020-06-26 Thread Anton Korobeynikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa4e8f7fe3f38: [builtins] Improve compatibility with 16 bit 
targets (authored by atrosinenko, committed by asl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81408

Files:
  compiler-rt/lib/builtins/floatdidf.c
  compiler-rt/lib/builtins/floatundidf.c
  compiler-rt/lib/builtins/fp_lib.h


Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -46,7 +46,7 @@
 #define REP_C UINT32_C
 #define significandBits 23
 
-static __inline int rep_clz(rep_t a) { return __builtin_clz(a); }
+static __inline int rep_clz(rep_t a) { return clzsi(a); }
 
 // 32x32 --> 64 bit multiply
 static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
Index: compiler-rt/lib/builtins/floatundidf.c
===
--- compiler-rt/lib/builtins/floatundidf.c
+++ compiler-rt/lib/builtins/floatundidf.c
@@ -90,7 +90,7 @@
 // a is now rounded to DBL_MANT_DIG bits
   }
   double_bits fb;
-  fb.u.s.high = ((e + 1023) << 20) |  // exponent
+  fb.u.s.high = ((su_int)(e + 1023) << 20) |  // exponent
 ((su_int)(a >> 32) & 0x000F); // mantissa-high
   fb.u.s.low = (su_int)a; // mantissa-low
   return fb.f;
Index: compiler-rt/lib/builtins/floatdidf.c
===
--- compiler-rt/lib/builtins/floatdidf.c
+++ compiler-rt/lib/builtins/floatdidf.c
@@ -87,7 +87,7 @@
   }
   double_bits fb;
   fb.u.s.high = ((su_int)s & 0x8000) |// sign
-((e + 1023) << 20) |  // exponent
+((su_int)(e + 1023) << 20) |  // exponent
 ((su_int)(a >> 32) & 0x000F); // mantissa-high
   fb.u.s.low = (su_int)a; // mantissa-low
   return fb.f;


Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -46,7 +46,7 @@
 #define REP_C UINT32_C
 #define significandBits 23
 
-static __inline int rep_clz(rep_t a) { return __builtin_clz(a); }
+static __inline int rep_clz(rep_t a) { return clzsi(a); }
 
 // 32x32 --> 64 bit multiply
 static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) {
Index: compiler-rt/lib/builtins/floatundidf.c
===
--- compiler-rt/lib/builtins/floatundidf.c
+++ compiler-rt/lib/builtins/floatundidf.c
@@ -90,7 +90,7 @@
 // a is now rounded to DBL_MANT_DIG bits
   }
   double_bits fb;
-  fb.u.s.high = ((e + 1023) << 20) |  // exponent
+  fb.u.s.high = ((su_int)(e + 1023) << 20) |  // exponent
 ((su_int)(a >> 32) & 0x000F); // mantissa-high
   fb.u.s.low = (su_int)a; // mantissa-low
   return fb.f;
Index: compiler-rt/lib/builtins/floatdidf.c
===
--- compiler-rt/lib/builtins/floatdidf.c
+++ compiler-rt/lib/builtins/floatdidf.c
@@ -87,7 +87,7 @@
   }
   double_bits fb;
   fb.u.s.high = ((su_int)s & 0x8000) |// sign
-((e + 1023) << 20) |  // exponent
+((su_int)(e + 1023) << 20) |  // exponent
 ((su_int)(a >> 32) & 0x000F); // mantissa-high
   fb.u.s.low = (su_int)a; // mantissa-low
   return fb.f;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81869: Modify FPFeatures to use delta not absolute settings to solve PCH compatibility problems

2020-06-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D81869#2116752 , @yaxunl wrote:

> Would you please add the following lit test
>
> F12245277: diff.pch.txt 
>
> If you change FastMath, FiniteMathOnly and UnsafeFPMath to 
> COMPATIBLE_LANGOPT, the test should pass.


Yes I'll do that, thanks for your review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81869



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


[PATCH] D42157: [clang-cl] Let /FA output use intel assembly.

2020-06-26 Thread naoyuki nabana via Phabricator via cfe-commits
Cartman0 added a comment.

hi! I try to assemble the .asm outputted from `clang-cl` by ML/ML64.exe on 
windows10.
The ".asm" files outputted from `clang-cl /FA` / are supports to assemble by 
ML/ML64.exe on windows?

when assemble by ML64.exe, occured " A2008:syntax error" and  A2044:invalid 
character in file.

(Developer Command Prompt for VS 2019)

  >ml helloworld.asm
  Microsoft (R) Macro Assembler Version 14.26.28806.0
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
   Assembling: helloworld.asm
  helloworld.asm(1) : error A2008:syntax error : .
  helloworld.asm(2) : error A2008:syntax error : .
  helloworld.asm(3) : error A2008:syntax error : .
  helloworld.asm(4) : error A2008:syntax error : .type
  helloworld.asm(5) : error A2008:syntax error : .
  helloworld.asm(6) : error A2008:syntax error : .
  helloworld.asm(7) : error A2008:syntax error : .
  helloworld.asm(8) : error A2008:syntax error : .
  helloworld.asm(9) : error A2008:syntax error : .
  helloworld.asm(10) : error A2008:syntax error : .
  helloworld.asm(11) : error A2008:syntax error : .
  helloworld.asm(12) : error A2008:syntax error : .type
  helloworld.asm(13) : error A2008:syntax error : .
  helloworld.asm(14) : error A2044:invalid character in file
  helloworld.asm(15) : error A2008:syntax error : .
  helloworld.asm(16) : error A2044:invalid character in file
  helloworld.asm(17) : error A2044:invalid character in file
  helloworld.asm(18) : error A2044:invalid character in file
  helloworld.asm(19) : error A2044:invalid character in file
  helloworld.asm(20) : error A2044:invalid character in file
  helloworld.asm(21) : error A2044:invalid character in file
  helloworld.asm(22) : error A2044:invalid character in file
  helloworld.asm(23) : error A2044:invalid character in file
  helloworld.asm(24) : error A2044:invalid character in file
  helloworld.asm(25) : error A2044:invalid character in file
  helloworld.asm(26) : error A2044:invalid character in file
  helloworld.asm(27) : error A2044:invalid character in file
  helloworld.asm(28) : error A2044:invalid character in file
  helloworld.asm(29) : error A2044:invalid character in file
  helloworld.asm(30) : error A2044:invalid character in file
  helloworld.asm(31) : error A2044:invalid character in file
  helloworld.asm(32) : error A2044:invalid character in file
  helloworld.asm(33) : error A2044:invalid character in file
  helloworld.asm(34) : error A2044:invalid character in file
  helloworld.asm(35) : error A2044:invalid character in file
  helloworld.asm(36) : error A2044:invalid character in file
  helloworld.asm(37) : error A2044:invalid character in file
  helloworld.asm(38) : error A2044:invalid character in file
  helloworld.asm(39) : error A2044:invalid character in file
  helloworld.asm(40) : error A2044:invalid character in file
  helloworld.asm(41) : error A2044:invalid character in file
  helloworld.asm(42) : error A2044:invalid character in file
  helloworld.asm(43) : error A2044:invalid character in file
  helloworld.asm(44) : error A2044:invalid character in file
  helloworld.asm(45) : error A2044:invalid character in file
  helloworld.asm(46) : error A2044:invalid character in file
  helloworld.asm(47) : error A2044:invalid character in file
  helloworld.asm(48) : error A2044:invalid character in file
  helloworld.asm(49) : error A2044:invalid character in file
  helloworld.asm(50) : error A2044:invalid character in file
  helloworld.asm(51) : error A2044:invalid character in file
  helloworld.asm(52) : error A2044:invalid character in file
  helloworld.asm(53) : error A2044:invalid character in file
  helloworld.asm(54) : error A2044:invalid character in file
  helloworld.asm(55) : error A2044:invalid character in file
  helloworld.asm(56) : error A2044:invalid character in file
  helloworld.asm(57) : error A2044:invalid character in file
  helloworld.asm(58) : error A2044:invalid character in file
  helloworld.asm(59) : error A2044:invalid character in file
  helloworld.asm(60) : error A2044:invalid character in file
  helloworld.asm(61) : error A2044:invalid character in file
  helloworld.asm(62) : error A2044:invalid character in file
  helloworld.asm(63) : error A2044:invalid character in file
  helloworld.asm(64) : error A2044:invalid character in file
  helloworld.asm(65) : error A2044:invalid character in file
  helloworld.asm(66) : error A2044:invalid character in file
  helloworld.asm(67) : error A2044:invalid character in file
  helloworld.asm(68) : error A2044:invalid character in file
  helloworld.asm(69) : error A2044:invalid character in file
  helloworld.asm(70) : error A2044:invalid character in file
  helloworld.asm(71) : error A2044:invalid character in file
  helloworld.asm(72) : error A2044:invalid character in file
  helloworld.asm(73) : error A2044:invalid character in file
  helloworld.asm(74) : error A2044:invalid character in file
  helloworld.asm(75) : error A2044:invalid character in file
  helloworld.asm(76) : error

[PATCH] D82654: [libTooling] Improve error message from failure in selection Stencil

2020-06-26 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr2.
Herald added a project: clang.

This patch improves the error message provided by the stencil that handles
source from a range selector.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82654

Files:
  clang/lib/Tooling/Transformer/Stencil.cpp


Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
 #include 
 #include 
 #include 
@@ -232,8 +233,31 @@
 return RawRange.takeError();
   CharSourceRange Range = Lexer::makeFileCharRange(
   *RawRange, *Match.SourceManager, Match.Context->getLangOpts());
+  if (Range.isInvalid()) {
+// Validate the original range to attempt to get a meaningful error 
message.
+// If it's valid, then something else is the cause and we just return the
+// generic failure message.
+if (auto Err = tooling::validateEditRange(*RawRange, *Match.SourceManager))
+  return handleErrors(std::move(Err), [](std::unique_ptr E) {
+assert(E->convertToErrorCode() ==
+   llvm::make_error_code(errc::invalid_argument) &&
+   "Validation errors must be carry the invalid_argument code");
+return llvm::createStringError(
+errc::invalid_argument,
+"selected range could not be resolved to a valid source range; " +
+E->getMessage());
+  });
+return llvm::createStringError(
+errc::invalid_argument,
+"selected range could not be resolved to a valid source range");
+  }
+  // Validate `Range`, because `makeFileCharRange` accepts some ranges that
+  // `validateEditRange` rejects.
   if (auto Err = tooling::validateEditRange(Range, *Match.SourceManager))
-return Err;
+return joinErrors(
+llvm::createStringError(errc::invalid_argument,
+"selected range is not valid for editing"),
+std::move(Err));
   *Result += tooling::getText(Range, *Match.Context);
   return Error::success();
 }


Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -19,6 +19,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
 #include 
 #include 
 #include 
@@ -232,8 +233,31 @@
 return RawRange.takeError();
   CharSourceRange Range = Lexer::makeFileCharRange(
   *RawRange, *Match.SourceManager, Match.Context->getLangOpts());
+  if (Range.isInvalid()) {
+// Validate the original range to attempt to get a meaningful error message.
+// If it's valid, then something else is the cause and we just return the
+// generic failure message.
+if (auto Err = tooling::validateEditRange(*RawRange, *Match.SourceManager))
+  return handleErrors(std::move(Err), [](std::unique_ptr E) {
+assert(E->convertToErrorCode() ==
+   llvm::make_error_code(errc::invalid_argument) &&
+   "Validation errors must be carry the invalid_argument code");
+return llvm::createStringError(
+errc::invalid_argument,
+"selected range could not be resolved to a valid source range; " +
+E->getMessage());
+  });
+return llvm::createStringError(
+errc::invalid_argument,
+"selected range could not be resolved to a valid source range");
+  }
+  // Validate `Range`, because `makeFileCharRange` accepts some ranges that
+  // `validateEditRange` rejects.
   if (auto Err = tooling::validateEditRange(Range, *Match.SourceManager))
-return Err;
+return joinErrors(
+llvm::createStringError(errc::invalid_argument,
+"selected range is not valid for editing"),
+std::move(Err));
   *Result += tooling::getText(Range, *Match.Context);
   return Error::success();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82650: [HIP] Set default FP_CONTRACT to ON

2020-06-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

I think the point of -ffp-contract=fast is that it allows emitting fma across 
statements if there are such opportunities whereas -ffp-contract=on only allows 
fma in one statement

https://llvm.org/docs/CompileCudaWithLLVM.html#flags-that-control-numerical-code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82650



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


[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-06-26 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 273708.
Xiangling_L marked 2 inline comments as done.
Xiangling_L added a comment.

Corrected the comments;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719

Files:
  clang/include/clang/AST/RecordLayout.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/RecordLayout.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/PPC.h
  clang/test/Layout/aix-double-struct-member.cpp
  clang/test/Layout/aix-no-unique-address-with-double.cpp
  clang/test/Layout/aix-virtual-function-and-base-with-double.cpp

Index: clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
===
--- /dev/null
+++ clang/test/Layout/aix-virtual-function-and-base-with-double.cpp
@@ -0,0 +1,112 @@
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s 2>/dev/null | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc64-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s 2>/dev/null | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+
+namespace test1 {
+struct A {
+  double d1;
+  virtual void boo() {}
+};
+
+struct B {
+  double d2;
+  A a;
+};
+
+struct C : public A {
+  double d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::A
+// CHECK-NEXT:0 |   (A vtable pointer)
+// CHECK32-NEXT:  4 |   double d1
+// CHECK32-NEXT:| [sizeof=12, dsize=12, align=4, preferredalign=4,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:  8 |   double d1
+// CHECK64-NEXT:| [sizeof=16, dsize=16, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=16, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::B
+// CHECK-NEXT:0 |   double d2
+// CHECK-NEXT:8 |   struct test1::A a
+// CHECK-NEXT:8 | (A vtable pointer)
+// CHECK32-NEXT: 12 | double d1
+// CHECK32-NEXT:| [sizeof=24, dsize=20, align=4, preferredalign=8,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4, preferrednvalign=8]
+// CHECK64-NEXT: 16 | double d1
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test1::C
+// CHECK-NEXT:0 |   struct test1::A (primary base)
+// CHECK-NEXT:0 | (A vtable pointer)
+// CHECK32-NEXT:  4 | double d1
+// CHECK32-NEXT: 12 |   double d3
+// CHECK32-NEXT:| [sizeof=20, dsize=20, align=4, preferredalign=4,
+// CHECK32-NEXT:|  nvsize=20, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:  8 | double d1
+// CHECK64-NEXT: 16 |   double d3
+// CHECK64-NEXT:| [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK64-NEXT:|  nvsize=24, nvalign=8, preferrednvalign=8]
+
+} // namespace test1
+
+namespace test2 {
+struct A {
+  long long l1;
+};
+
+struct B : public virtual A {
+  double d2;
+};
+
+#pragma pack(2)
+struct C : public virtual A {
+  double __attribute__((aligned(4))) d3;
+};
+
+int i = sizeof(B);
+int j = sizeof(C);
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::A
+// CHECK-NEXT:0 |   long long l1
+// CHECK-NEXT:  | [sizeof=8, dsize=8, align=8, preferredalign=8,
+// CHECK-NEXT:  |  nvsize=8, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::B
+// CHECK-NEXT:0 |   (B vtable pointer)
+// CHECK32-NEXT:  4 |   double d2
+// CHECK64-NEXT:  8 |   double d2
+// CHECK-NEXT:   16 |   struct test2::A (virtual base)
+// CHECK-NEXT:   16 | long long l1
+// CHECK-NEXT:  | [sizeof=24, dsize=24, align=8, preferredalign=8,
+// CHECK32-NEXT:|  nvsize=12, nvalign=4, preferrednvalign=4]
+// CHECK64-NEXT:|  nvsize=16, nvalign=8, preferrednvalign=8]
+
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:0 | struct test2::C
+// CHECK-NEXT:0 |   (C vtable pointer)
+// CHECK32-NEXT:  4 |   double d3
+// CHECK32-NEXT: 12 |   struct test2::A (virtual base)
+// CHECK32-NEXT: 12 | long long l1
+// CHECK32-NEXT:| [sizeof=20, dsize=20, align=2, preferredalign=2,
+// CHECK32-NEXT:|  nvsize=12, nvalign=2,

[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:16665
 // Record the component - we don't have any declaration associated.
-Components.emplace_back(OASE, nullptr);
+Components.emplace_back(OASE, nullptr, false);
 return RelevantExpr || Visit(E);

`/*IsNonContiguous=*/false`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:16685
   // Record the component if haven't found base decl.
-  Components.emplace_back(UO, nullptr);
+  Components.emplace_back(UO, nullptr, false);
 }

`/*IsNonContiguous=*/false`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:18470-18473
+MVLI.VarComponents.back().emplace_back(
+OMPClauseMappableExprCommon::MappableComponent(
+SimpleRefExpr, D,
+/*IsNonContiguous=*/false));

`.emplace_back(SimpleRefExpr, D, /*IsNonContiguous=*/false);`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972



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


[clang] 0069824 - Revert rGf0bab7875e78e01c149d12302dcc4b6d4c43e25c - "Triple.h - reduce Twine.h include to forward declarations. NFC."

2020-06-26 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-06-26T14:46:40+01:00
New Revision: 0069824feab0af5ade571d975deb1efd893c2466

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

LOG: Revert rGf0bab7875e78e01c149d12302dcc4b6d4c43e25c - "Triple.h - reduce 
Twine.h include to forward declarations. NFC."

This causes ICEs on the clang-ppc64be buildbots and I've limited ability to 
triage the problem.

Added: 


Modified: 
clang/lib/Basic/IdentifierTable.cpp
clang/lib/Basic/Targets/Mips.h
llvm/include/llvm/ADT/Triple.h
llvm/include/llvm/Support/TargetRegistry.h
llvm/lib/MC/MCSectionELF.cpp
llvm/lib/Support/Triple.cpp
llvm/unittests/ADT/TripleTest.cpp
llvm/unittests/Frontend/OpenMPContextTest.cpp
llvm/unittests/Support/ThreadPool.cpp

Removed: 




diff  --git a/clang/lib/Basic/IdentifierTable.cpp 
b/clang/lib/Basic/IdentifierTable.cpp
index 55d3f6a447b2..36b26d9b7c68 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -23,7 +23,6 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/Twine.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"

diff  --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h
index e2fcda3329ab..b475c03889a1 100644
--- a/clang/lib/Basic/Targets/Mips.h
+++ b/clang/lib/Basic/Targets/Mips.h
@@ -16,7 +16,6 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/TargetOptions.h"
 #include "llvm/ADT/Triple.h"
-#include "llvm/ADT/Twine.h"
 #include "llvm/Support/Compiler.h"
 
 namespace clang {

diff  --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index c039d424487d..89679619dd55 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -9,8 +9,7 @@
 #ifndef LLVM_ADT_TRIPLE_H
 #define LLVM_ADT_TRIPLE_H
 
-#include "llvm/ADT/StringRef.h"
-#include 
+#include "llvm/ADT/Twine.h"
 
 // Some system headers or GCC predefined macros conflict with identifiers in
 // this file.  Undefine them here.
@@ -20,7 +19,6 @@
 
 namespace llvm {
 
-class Twine;
 class VersionTuple;
 
 /// Triple - Helper class for working with autoconf configuration names. For

diff  --git a/llvm/include/llvm/Support/TargetRegistry.h 
b/llvm/include/llvm/Support/TargetRegistry.h
index 5592879630de..d91eabae8235 100644
--- a/llvm/include/llvm/Support/TargetRegistry.h
+++ b/llvm/include/llvm/Support/TargetRegistry.h
@@ -22,7 +22,6 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
-#include "llvm/ADT/Twine.h"
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/CodeGen.h"
 #include "llvm/Support/ErrorHandling.h"

diff  --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index ce94409a5429..77c259c27a04 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -8,7 +8,6 @@
 
 #include "llvm/MC/MCSectionELF.h"
 #include "llvm/ADT/Triple.h"
-#include "llvm/ADT/Twine.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/MCExpr.h"

diff  --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp
index c35ca9641f60..75ec257e15b5 100644
--- a/llvm/lib/Support/Triple.cpp
+++ b/llvm/lib/Support/Triple.cpp
@@ -11,7 +11,6 @@
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/ADT/Twine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Support/SwapByteOrder.h"
@@ -19,7 +18,6 @@
 #include "llvm/Support/VersionTuple.h"
 #include 
 #include 
-
 using namespace llvm;
 
 StringRef Triple::getArchTypeName(ArchType Kind) {

diff  --git a/llvm/unittests/ADT/TripleTest.cpp 
b/llvm/unittests/ADT/TripleTest.cpp
index 1dd6b32cb8eb..dc7a28c72f20 100644
--- a/llvm/unittests/ADT/TripleTest.cpp
+++ b/llvm/unittests/ADT/TripleTest.cpp
@@ -7,7 +7,6 @@
 
//===--===//
 
 #include "llvm/ADT/Triple.h"
-#include "llvm/ADT/Twine.h"
 #include "llvm/Support/VersionTuple.h"
 #include "gtest/gtest.h"
 

diff  --git a/llvm/unittests/Frontend/OpenMPContextTest.cpp 
b/llvm/unittests/Frontend/OpenMPContextTest.cpp
index 9cdbd783ae18..eb505be042cb 100644
--- a/llvm/unittests/Frontend/OpenMPContextTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPContextTest.cpp
@@ -8,7 +8,6 @@
 
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Frontend/OpenMP/OMPContext.h"
-#include "llvm/ADT/Twine.h"
 #include "gtest/gtest.h"
 
 using namespace llvm;

diff  --git a/llvm/unittests/Support/ThreadPool.cpp 
b/llvm/unittests/Support/ThreadPool.cpp
index 1f0b6804338b..43882d0f3cee 10

[clang] 5547a83 - [CodeComplete] Add code completion for using alias.

2020-06-26 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-06-26T15:55:45+02:00
New Revision: 5547a83c0b68a03a806d47782a4d3a6dc3b5d5f5

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

LOG: [CodeComplete] Add code completion for using alias.

Add code completion for using alias.

Patch By @lh123 !

Reviewers: kadircet

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

Added: 


Modified: 
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/ordinary-name-cxx11.cpp
clang/test/CodeCompletion/ordinary-name.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 8835ecc79b9f..a96ea1e69bcc 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -1816,6 +1816,18 @@ static void AddTypedefResult(ResultBuilder &Results) {
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
+// using name = type
+static void AddUsingAliasResult(CodeCompletionBuilder &Builder,
+ResultBuilder &Results) {
+  Builder.AddTypedTextChunk("using");
+  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Builder.AddPlaceholderChunk("name");
+  Builder.AddChunk(CodeCompletionString::CK_Equal);
+  Builder.AddPlaceholderChunk("type");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+  Results.AddResult(CodeCompletionResult(Builder.TakeString()));
+}
+
 static bool WantTypesInContext(Sema::ParserCompletionContext CCC,
const LangOptions &LangOpts) {
   switch (CCC) {
@@ -2059,6 +2071,9 @@ static void 
AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S,
   Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(Result(Builder.TakeString()));
 
+  if (SemaRef.getLangOpts().CPlusPlus11)
+AddUsingAliasResult(Builder, Results);
+
   // using typename qualifier::name (only in a dependent context)
   if (SemaRef.CurContext->isDependentContext()) {
 Builder.AddTypedTextChunk("using typename");
@@ -2139,6 +2154,9 @@ static void 
AddOrdinaryNameResults(Sema::ParserCompletionContext CCC, Scope *S,
 
   case Sema::PCC_RecoveryInFunction:
   case Sema::PCC_Statement: {
+if (SemaRef.getLangOpts().CPlusPlus11)
+  AddUsingAliasResult(Builder, Results);
+
 AddTypedefResult(Results);
 
 if (SemaRef.getLangOpts().CPlusPlus && Results.includeCodePatterns() &&

diff  --git a/clang/test/CodeCompletion/ordinary-name-cxx11.cpp 
b/clang/test/CodeCompletion/ordinary-name-cxx11.cpp
index dcbb5ecb4f69..7593d00210e7 100644
--- a/clang/test/CodeCompletion/ordinary-name-cxx11.cpp
+++ b/clang/test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -62,6 +62,7 @@ void foo() {
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
@@ -113,6 +114,7 @@ void foo() {
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
   // CHECK-CC2-NEXT: COMPLETION: volatile
@@ -156,6 +158,7 @@ void foo() {
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
   // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -264,6 +267,7 @@ void foo() {
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
   // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: void
   // CHECK-NO-RTTI-NEXT: COMPLETION: volatile

diff  --git a/clang/test/CodeCompletion/ordinary-name.cpp 
b/clang/test/CodeCompletion/ordinary-name.cpp
index a87c992d85f7..3c3d0c5d6883 100644
--- a/clang/test/CodeCompletion/ordinary-name.cpp
+++ b/clang/test/CodeCompletion/ordinary-name.cpp
@@ -59,6 +59,7 @@ void foo() {
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
+  // CHECK

[PATCH] D82654: [libTooling] Improve error message from failure in selection Stencil

2020-06-26 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

Any chance for a test?




Comment at: clang/lib/Tooling/Transformer/Stencil.cpp:244
+   llvm::make_error_code(errc::invalid_argument) &&
+   "Validation errors must be carry the invalid_argument code");
+return llvm::createStringError(

must be carry => must carry


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82654



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


[PATCH] D82657: [AST][RecoveryAST] Preserve the type by default for recovery expression.

2020-06-26 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

DO NOT SUBMIT.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82657

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
  clang/test/SemaTemplate/dependent-names.cpp


Index: clang/test/SemaTemplate/dependent-names.cpp
===
--- clang/test/SemaTemplate/dependent-names.cpp
+++ clang/test/SemaTemplate/dependent-names.cpp
@@ -176,7 +176,8 @@
 void f(char&); // expected-note {{candidate function not viable}}
 
 template struct C {
-  static const int n = f(T()); // expected-error {{no matching function}}
+  static const int n = f(T()); // expected-error {{no matching function}} \
+   // expected-error {{cannot initialize a 
variable of type 'const int' with an lvalue of type 'void'}}
 };
   }
 
Index: clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
+++ clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
@@ -123,7 +123,10 @@
   template struct S {};
   template using U = S; // expected-note 
2{{template parameter is declared here}}
   template U &f(U, Ts...); // expected-error 
2{{pack expansion used as argument for non-pack parameter of alias template}}
-  S &s1 = f({}, 0, 0.0); // expected-error {{no matching 
function}}
+  // FIXME: suppress the spurious "annot bind to a value of unrelated type 
'int'" diagnostic.
+  // The template function f is invalid, and int is the fallback return type?
+  S &s1 = f({}, 0, 0.0); // expected-error {{no matching 
function}} \
+   // expected-error {{non-const 
lvalue reference to type 'S' cannot bind to a value of 
unrelated type 'int'}}
 }
 
 namespace PR18401 {
Index: clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
===
--- clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
+++ clang/test/CXX/temp/temp.constr/temp.constr.order/function-templates.cpp
@@ -67,7 +67,8 @@
 // expected-note@-1 {{candidate function [with T = long long, U = int]}}
 
 static_assert(sizeof(f()));
-// expected-error@-1 {{call to 'f' is ambiguous}}
+// expected-error@-1 {{call to 'f' is ambiguous}} \
+   expected-error@-1 {{invalid application of 'sizeof' to an incomplete type 
'void'}}
 
 template
 concept C3 = true;
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2926,8 +2926,8 @@
   // Recovery AST still heavily relies on dependent-type machinery.
   Opts.RecoveryAST =
   Args.hasFlag(OPT_frecovery_ast, OPT_fno_recovery_ast, Opts.CPlusPlus);
-  Opts.RecoveryASTType =
-  Args.hasFlag(OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, false);
+  Opts.RecoveryASTType = Args.hasFlag(
+  OPT_frecovery_ast_type, OPT_fno_recovery_ast_type, Opts.CPlusPlus);
   Opts.HeinousExtensions = Args.hasArg(OPT_fheinous_gnu_extensions);
   Opts.AccessControl = !Args.hasArg(OPT_fno_access_control);
   Opts.ElideConstructors = !Args.hasArg(OPT_fno_elide_constructors);


Index: clang/test/SemaTemplate/dependent-names.cpp
===
--- clang/test/SemaTemplate/dependent-names.cpp
+++ clang/test/SemaTemplate/dependent-names.cpp
@@ -176,7 +176,8 @@
 void f(char&); // expected-note {{candidate function not viable}}
 
 template struct C {
-  static const int n = f(T()); // expected-error {{no matching function}}
+  static const int n = f(T()); // expected-error {{no matching function}} \
+   // expected-error {{cannot initialize a variable of type 'const int' with an lvalue of type 'void'}}
 };
   }
 
Index: clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
+++ clang/test/CXX/temp/temp.decls/temp.variadic/fixed-expansion.cpp
@@ -123,7 +123,10 @@
   template struct S {};
   template using U = S; // expected-note 2{{template parameter is declared here}}
   template U &f(U, Ts...); // expected-error 2{{pack expansion used as argument for non-pack parameter of alias template}}
-  S &s1 = f({}, 0, 0.0); // expected-error {{no matching function}}
+  // FIXME: suppress the spurious "annot bind to a value of unrelated type 'int'" diagnostic.
+  // The template function f is invalid, and int is the fallback return type?

[PATCH] D82226: Add Metadata to Transformer tooling

2020-06-26 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

In D82226#2115406 , @asoffer wrote:

> I think the tradeoff here is 
>  Dynamic typing -- faster compile times, type safety checked at run-time (in 
> tests), lower maintenance cost
>  Templates -- Faster runtime, type safety checked at compile-time, better 
> user expereience


For me, the more important part of the tradeoff is whether we will have one 
type or multiple. If we use Any, then all `AtomicChange` regardless of what 
produced them, will have the same type. If we use templates, then 
`AtomicChange` is a different type from `AtomicChange`. So based on that 
I think using Any is a better choice, since infrastructure code would want to 
handle with `AtomicChange` objects and not have to be implemented as a template 
over arbitrary metadata type.

Regarding the metadata itself, WDYT about using a map from string to any 
instead of just one any? This way multiple layers of the system would be able 
to attach metadata without interfering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82226



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


[PATCH] D82535: [CodeComplete] Add code completion for using alias.

2020-06-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5547a83c0b68: [CodeComplete] Add code completion for using 
alias. (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82535

Files:
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/ordinary-name-cxx11.cpp
  clang/test/CodeCompletion/ordinary-name.cpp

Index: clang/test/CodeCompletion/ordinary-name.cpp
===
--- clang/test/CodeCompletion/ordinary-name.cpp
+++ clang/test/CodeCompletion/ordinary-name.cpp
@@ -59,6 +59,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
+  // CHECK-CC1-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
@@ -103,6 +104,7 @@
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC2-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
   // CHECK-CC2-NEXT: COMPLETION: volatile
@@ -140,6 +142,7 @@
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
   // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC3-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -232,6 +235,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
   // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
+  // CHECK-NO-RTTI-NOT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: void
   // CHECK-NO-RTTI-NEXT: COMPLETION: volatile
Index: clang/test/CodeCompletion/ordinary-name-cxx11.cpp
===
--- clang/test/CodeCompletion/ordinary-name-cxx11.cpp
+++ clang/test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -62,6 +62,7 @@
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-CC1-NEXT: COMPLETION: union
   // CHECK-CC1-NEXT: COMPLETION: unsigned
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC1-NEXT: COMPLETION: void
   // CHECK-CC1-NEXT: COMPLETION: volatile
@@ -113,6 +114,7 @@
   // CHECK-CC2-NEXT: COMPLETION: union
   // CHECK-CC2-NEXT: COMPLETION: unsigned
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>;
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-CC2-NEXT: COMPLETION: void
   // CHECK-CC2-NEXT: COMPLETION: volatile
@@ -156,6 +158,7 @@
   // CHECK-CC3-NEXT: COMPLETION: union
   // CHECK-CC3-NEXT: COMPLETION: unsigned
   // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>
+  // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-CC3-NEXT: COMPLETION: virtual
   // CHECK-CC3-NEXT: COMPLETION: void
   // CHECK-CC3-NEXT: COMPLETION: volatile
@@ -264,6 +267,7 @@
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
   // CHECK-NO-RTTI-NEXT: COMPLETION: union
   // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned
+  // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>;
   // CHECK-NO-RTTI-NEXT: COMPLETION: void
   // CHECK-NO-RTTI-NEXT: COMPLETION: volatile
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -1816,6 +1816,18 @@
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
+// using name = type
+static void AddUsingAliasResult(CodeCompletionBuilder &Builder,
+ResultBuilder &Results) {
+  Builder.AddTypedTextChunk("using");
+  Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
+  Builder.AddPlaceholderChunk("name");
+  Builder.AddChunk(CodeCompletionString::CK_Equal);
+  Builder.AddPlaceholderChunk("type");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
+  Results.AddResult(CodeCompletionResult(Builder.TakeString()));
+}
+
 static bool WantTypesInCont

[PATCH] D82620: [clang-format] Preserve whitespace in selected macros

2020-06-26 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD marked 10 inline comments as done.
JakeMerdichAMD added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2706
+
+  For example: STRINGIZE
+

curdeius wrote:
> Shouldn't there be a configuration example like what's in `ForEachMacros` doc?
> ```
>   In the .clang-format configuration file, this can be configured like:
> 
>   .. code-block:: yaml
> 
> WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
> 
>   For example: BOOST_PP_STRINGIZE.
> ```
> 
Done. I also added PP_STRINGIZE and BOOST_PP_STRINGIZE as defaults; seems 
reasonable.



Comment at: clang/unittests/Format/FormatTest.cpp:13961
+  Style.WhitespaceSensitiveMacros.clear();
+  CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE]",
+  WhitespaceSensitiveMacros, 
std::vector{"STRINGIZE"});

curdeius wrote:
> Shouldn't that be:
> `CHECK_PARSE("WhitespaceSensitiveMacros: ['STRINGIZE']",`
> as in other options that take vector of strings?
I'll add it since it ought to be tested, but they aren't required to my 
knowledge due to 'YAML reasons' and most of the other tests omit them.



Comment at: clang/unittests/Format/FormatTest.cpp:16482
+  // and these are all whitespace sensitive by definition
+  EXPECT_EQ("FOO(String-ized&Messy+But(: :Still)=Intentional);",
+format("FOO(String-ized&Messy+But(: :Still)=Intentional);", 
Style));

curdeius wrote:
> How about a test with escaped parentheses `\(` inside the macro argument?
Done. Note that parens always need to be matched anyhow, and the escaping 
doesn't actually mean anything outside of a string literal (tested on MSVC, 
gcc, clang), so no functionality change is needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82620



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


[clang] 056a539 - [libTooling] Rename overloaded `range` range selector.

2020-06-26 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-06-26T14:23:25Z
New Revision: 056a539e570a49e27f88f4555d42f00be0500749

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

LOG: [libTooling] Rename overloaded `range` range selector.

Renames the overloaded `RangeSelector` combinator `range` to the more
descriptive `enclose` and `encloseNodes`. The old overloads are left in place
and marked deprected and will be deleted at a future time.

Reviewed By: tdl-g

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

Added: 


Modified: 
clang/include/clang/Tooling/Transformer/RangeSelector.h
clang/lib/Tooling/Transformer/RangeSelector.cpp
clang/unittests/Tooling/RangeSelectorTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Transformer/RangeSelector.h 
b/clang/include/clang/Tooling/Transformer/RangeSelector.h
index eaab3fc4c0c7..2807037bc208 100644
--- a/clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ b/clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -32,10 +32,20 @@ inline RangeSelector charRange(CharSourceRange R) {
 }
 
 /// Selects from the start of \p Begin and to the end of \p End.
-RangeSelector range(RangeSelector Begin, RangeSelector End);
+RangeSelector enclose(RangeSelector Begin, RangeSelector End);
 
 /// Convenience version of \c range where end-points are bound nodes.
-RangeSelector range(std::string BeginID, std::string EndID);
+RangeSelector encloseNodes(std::string BeginID, std::string EndID);
+
+/// DEPRECATED. Use `enclose`.
+inline RangeSelector range(RangeSelector Begin, RangeSelector End) {
+  return enclose(std::move(Begin), std::move(End));
+}
+
+/// DEPRECATED. Use `encloseNodes`.
+inline RangeSelector range(std::string BeginID, std::string EndID) {
+  return encloseNodes(std::move(BeginID), std::move(EndID));
+}
 
 /// Selects the (empty) range [B,B) when \p Selector selects the range [B,E).
 RangeSelector before(RangeSelector Selector);

diff  --git a/clang/lib/Tooling/Transformer/RangeSelector.cpp 
b/clang/lib/Tooling/Transformer/RangeSelector.cpp
index baf2e785bfd0..29b1a5b0372e 100644
--- a/clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ b/clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -146,7 +146,7 @@ RangeSelector transformer::statement(std::string ID) {
   };
 }
 
-RangeSelector transformer::range(RangeSelector Begin, RangeSelector End) {
+RangeSelector transformer::enclose(RangeSelector Begin, RangeSelector End) {
   return [Begin, End](const MatchResult &Result) -> Expected {
 Expected BeginRange = Begin(Result);
 if (!BeginRange)
@@ -165,8 +165,9 @@ RangeSelector transformer::range(RangeSelector Begin, 
RangeSelector End) {
   };
 }
 
-RangeSelector transformer::range(std::string BeginID, std::string EndID) {
-  return transformer::range(node(std::move(BeginID)), node(std::move(EndID)));
+RangeSelector transformer::encloseNodes(std::string BeginID,
+std::string EndID) {
+  return transformer::enclose(node(std::move(BeginID)), 
node(std::move(EndID)));
 }
 
 RangeSelector transformer::member(std::string ID) {

diff  --git a/clang/unittests/Tooling/RangeSelectorTest.cpp 
b/clang/unittests/Tooling/RangeSelectorTest.cpp
index da5b3c524e4b..e2d7723eab11 100644
--- a/clang/unittests/Tooling/RangeSelectorTest.cpp
+++ b/clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -201,7 +201,7 @@ TEST(RangeSelectorTest, RangeOpNodes) {
   )cc";
   auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
   hasArgument(1, expr().bind("a1")));
-  RangeSelector R = range("a0", "a1");
+  RangeSelector R = encloseNodes("a0", "a1");
   TestMatch Match = matchCode(Code, Matcher);
   EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
 }
@@ -213,7 +213,7 @@ TEST(RangeSelectorTest, RangeOpGeneral) {
   )cc";
   auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
   hasArgument(1, expr().bind("a1")));
-  RangeSelector R = range(node("a0"), node("a1"));
+  RangeSelector R = enclose(node("a0"), node("a1"));
   TestMatch Match = matchCode(Code, Matcher);
   EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
 }



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


[PATCH] D82606: [clangd] Config: config struct propagated through Context

2020-06-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

oops, thought I've stamped it last time.




Comment at: clang-tools-extra/clangd/CompileCommands.cpp:187
+  // FIXME: remove const_cast once unique_function is const-compatible.
+  for (auto &Edit : const_cast(Config::current()).CompileFlags.Edits)
+Edit(Cmd);

sammccall wrote:
> kadircet wrote:
> > what's the rationale behind applying this before any other mangling?
> > 
> > I can see that the rest of the mangling happens to make sure clangd works 
> > out-of-the-box for "more" users, so should be safe to apply as a final step.
> > But on the other hand, applying config after those would give the user full 
> > control over the final command, which I believe is equally important.
> I'll be honest, I don't really know which is better here. The differences are 
> subtle, and there are arguments for each. I think we should probably just 
> pick one and be open to changing it later.
> 
> My reasoning for this behavior: currently the user view of compile commands 
> is basically "strings in compile_commands.json", and this mangling we do is 
> best thought of as modifying the behavior of the driver. E.g. in an ideal 
> world `-fsyntax-only` would not be a flag, we'd just use APIs that imply that 
> behavior.
> In this view of the world, the user is expected to understand compile 
> commands + tweaks but not the mangling, so placing tweaks after mangling 
> means they can't really reason about the transformations. And it allows 
> stripping structurally important things we inject like `fsyntax-only` which 
> seems wrong.
> 
> This argument works better for some args/manglings than others, and the way 
> we log args cuts against it a bit too. 
SG, as you mentioned in the last paragraph I would be looking at logs to figure 
out what my compile commands for a file are, but may be it's just me. Hence 
having this tweaking in the middle was a little bit surprising. (Moreover, if 
one day we decide to have build system integrations it might imply there won't 
be any written compile_commands.json, but we'll rather fetch them on the fly 
and logs might be the only way to look at those commands. Even in such a 
scenario, I suppose changing the way we log might be a better approach because 
we indeed do more manipulations even after logging e.g. turning off preamble 
related options)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82606



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


[PATCH] D82620: [clang-format] Preserve whitespace in selected macros

2020-06-26 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD updated this revision to Diff 273722.
JakeMerdichAMD marked 3 inline comments as done.
JakeMerdichAMD added a comment.

Address feedback (nits, better docs, more defaults)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82620

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13957,6 +13957,18 @@
   CHECK_PARSE("NamespaceMacros: [TESTSUITE, SUITE]", NamespaceMacros,
   std::vector({"TESTSUITE", "SUITE"}));
 
+  Style.WhitespaceSensitiveMacros.clear();
+  CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE]",
+  WhitespaceSensitiveMacros, std::vector{"STRINGIZE"});
+  CHECK_PARSE("WhitespaceSensitiveMacros: [STRINGIZE, ASSERT]",
+  WhitespaceSensitiveMacros,
+  std::vector({"STRINGIZE", "ASSERT"}));
+  CHECK_PARSE("WhitespaceSensitiveMacros: ['STRINGIZE']",
+  WhitespaceSensitiveMacros, std::vector{"STRINGIZE"});
+  CHECK_PARSE("WhitespaceSensitiveMacros: ['STRINGIZE', 'ASSERT']",
+  WhitespaceSensitiveMacros,
+  std::vector({"STRINGIZE", "ASSERT"}));
+
   Style.IncludeStyle.IncludeCategories.clear();
   std::vector ExpectedCategories = {
   {"abc/.*", 2, 0}, {".*", 1, 0}};
@@ -16466,6 +16478,36 @@
   verifyFormat("foo(operator, , -42);", Style);
 }
 
+TEST_F(FormatTest, WhitespaceSensitiveMacros) {
+  FormatStyle Style = getLLVMStyle();
+  Style.WhitespaceSensitiveMacros.push_back("FOO");
+
+  // Don't use the helpers here, since 'mess up' will change the whitespace
+  // and these are all whitespace sensitive by definition
+  EXPECT_EQ("FOO(String-ized&Messy+But(: :Still)=Intentional);",
+format("FOO(String-ized&Messy+But(: :Still)=Intentional);", Style));
+  EXPECT_EQ(
+  "FOO(String-ized&Messy+But\\(: :Still)=Intentional);",
+  format("FOO(String-ized&Messy+But\\(: :Still)=Intentional);", Style));
+  EXPECT_EQ("FOO(String-ized&Messy+But,: :Still=Intentional);",
+format("FOO(String-ized&Messy+But,: :Still=Intentional);", Style));
+  EXPECT_EQ("FOO(String-ized&Messy+But,: :\n"
+"   Still=Intentional);",
+format("FOO(String-ized&Messy+But,: :\n"
+   "   Still=Intentional);",
+   Style));
+  Style.AlignConsecutiveAssignments = true;
+  EXPECT_EQ("FOO(String-ized=&Messy+But,: :\n"
+"   Still=Intentional);",
+format("FOO(String-ized=&Messy+But,: :\n"
+   "   Still=Intentional);",
+   Style));
+
+  Style.ColumnLimit = 21;
+  EXPECT_EQ("FOO(String-ized&Messy+But: :Still=Intentional);",
+format("FOO(String-ized&Messy+But: :Still=Intentional);", Style));
+}
+
 TEST_F(FormatTest, VeryLongNamespaceCommentSplit) {
   // These tests are not in NamespaceFixer because that doesn't
   // test its interaction with line wrapping
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -160,6 +160,27 @@
 return false;
   }
 
+  bool parseUntouchableParens() {
+while (CurrentToken) {
+  CurrentToken->Finalized = true;
+  switch (CurrentToken->Tok.getKind()) {
+  case tok::l_paren:
+next();
+if (!parseUntouchableParens())
+  return false;
+continue;
+  case tok::r_paren:
+next();
+return true;
+  default:
+// no-op
+break;
+  }
+  next();
+}
+return false;
+  }
+
   bool parseParens(bool LookForDecls = false) {
 if (!CurrentToken)
   return false;
@@ -171,6 +192,11 @@
 Contexts.back().ColonIsForRangeExpr =
 Contexts.size() == 2 && Contexts[0].ColonIsForRangeExpr;
 
+if (Left->Previous && Left->Previous->is(TT_UntouchableMacroFunc)) {
+  Left->Finalized = true;
+  return parseUntouchableParens();
+}
+
 bool StartsObjCMethodExpr = false;
 if (FormatToken *MaybeSel = Left->Previous) {
   // @selector( starts a selector.
@@ -1311,7 +1337,7 @@
 TT_TypenameMacro, TT_FunctionLBrace, TT_ImplicitStringLiteral,
 TT_InlineASMBrace, TT_JsFatArrow, TT_LambdaArrow, TT_NamespaceMacro,
 TT_OverloadedOperator, TT_RegexLiteral, TT_TemplateString,
-TT_ObjCStringLiteral))
+TT_ObjCStringLiteral, TT_UntouchableMacroFunc))
   CurrentToken->setType(TT_Unknown);
 CurrentToken->Role.reset();
 CurrentToken->MatchingParen = nullptr

[PATCH] D82654: [libTooling] Improve error message from failure in selection Stencil

2020-06-26 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D82654#2116906 , @gribozavr2 wrote:

> Any chance for a test?


StencilTest.CatOfInvalidRangeFails essentially covers this (indeed, earlier 
versions of the code failed this test).  
https://github.com/llvm/llvm-project/blob/master/clang/unittests/Tooling/StencilTest.cpp#L419
I can make it more specific, but since this only affects the error message and 
not the control flow, I didn't update the test.  Let me know if you disagree -- 
I generally avoid testing error message content in tests, but I know there's a 
variety of opinions on this subject...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82654



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


[PATCH] D82226: Add Metadata to Transformer tooling

2020-06-26 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D82226#2116931 , @gribozavr2 wrote:

> In D82226#2115406 , @asoffer wrote:
>
> > I think the tradeoff here is 
> >  Dynamic typing -- faster compile times, type safety checked at run-time 
> > (in tests), lower maintenance cost
> >  Templates -- Faster runtime, type safety checked at compile-time, better 
> > user expereience
>
>
> For me, the more important part of the tradeoff is whether we will have one 
> type or multiple. If we use Any, then all `AtomicChange` regardless of what 
> produced them, will have the same type. If we use templates, then 
> `AtomicChange` is a different type from `AtomicChange`. So based on 
> that I think using Any is a better choice, since infrastructure code would 
> want to handle with `AtomicChange` objects and not have to be implemented as 
> a template over arbitrary metadata type.


I'm convinced (both yours and Andy's arguments). Andy, please consider whether 
any of this belongs in comments. (I don't have much opinion).

> Regarding the metadata itself, WDYT about using a map from string to any 
> instead of just one any? This way multiple layers of the system would be able 
> to attach metadata without interfering.

Sounds good, but I'm fine either way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82226



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


[PATCH] D82486: RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order traversal

2020-06-26 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr updated this revision to Diff 273723.
gribozavr added a comment.

Addressed review comments, added more fixes that must be committed in the same
change, because splitting them would break tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82486

Files:
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -117,18 +117,13 @@
   Code,
   R"txt(
 TraverseIntegerLiteral IntegerLiteral(1)
-WalkUpFromStmt IntegerLiteral(1)
 TraverseIntegerLiteral IntegerLiteral(2)
-WalkUpFromStmt IntegerLiteral(2)
 TraverseIntegerLiteral IntegerLiteral(3)
-WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt DeclRefExpr(add)
 WalkUpFromStmt ImplicitCastExpr
 TraverseIntegerLiteral IntegerLiteral(4)
-WalkUpFromStmt IntegerLiteral(4)
 TraverseIntegerLiteral IntegerLiteral(5)
-WalkUpFromStmt IntegerLiteral(5)
 WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -189,18 +184,13 @@
   Code,
   R"txt(
 TraverseIntegerLiteral IntegerLiteral(1)
-WalkUpFromIntegerLiteral IntegerLiteral(1)
 TraverseIntegerLiteral IntegerLiteral(2)
-WalkUpFromIntegerLiteral IntegerLiteral(2)
 TraverseIntegerLiteral IntegerLiteral(3)
-WalkUpFromIntegerLiteral IntegerLiteral(3)
 WalkUpFromExpr BinaryOperator(+)
 WalkUpFromExpr DeclRefExpr(add)
 WalkUpFromExpr ImplicitCastExpr
 TraverseIntegerLiteral IntegerLiteral(4)
-WalkUpFromIntegerLiteral IntegerLiteral(4)
 TraverseIntegerLiteral IntegerLiteral(5)
-WalkUpFromIntegerLiteral IntegerLiteral(5)
 WalkUpFromExpr CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -315,7 +305,6 @@
 WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromStmt IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt DeclRefExpr(add)
 WalkUpFromStmt ImplicitCastExpr
 WalkUpFromStmt IntegerLiteral(4)
@@ -383,7 +372,6 @@
 WalkUpFromExpr IntegerLiteral(1)
 WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromExpr IntegerLiteral(3)
-WalkUpFromBinaryOperator BinaryOperator(+)
 WalkUpFromExpr DeclRefExpr(add)
 WalkUpFromExpr ImplicitCastExpr
 WalkUpFromExpr IntegerLiteral(4)
@@ -500,7 +488,6 @@
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt BinaryOperator(+)
 TraverseCallExpr CallExpr(add)
-WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
 }
@@ -560,7 +547,6 @@
 WalkUpFromExpr IntegerLiteral(3)
 WalkUpFromExpr BinaryOperator(+)
 TraverseCallExpr CallExpr(add)
-WalkUpFromCallExpr CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
 }
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -578,15 +578,19 @@
 // RAV traverses it as a statement, we produce invalid node kinds in that
 // case.
 // FIXME: should do this in RAV instead?
-if (S->getInit() && !TraverseStmt(S->getInit()))
-  return false;
-if (S->getLoopVariable() && !TraverseDecl(S->getLoopVariable()))
-  return false;
-if (S->getRangeInit() && !TraverseStmt(S->getRangeInit()))
-  return false;
-if (S->getBody() && !TraverseStmt(S->getBody()))
-  return false;
-return true;
+bool Result = [&, this]() {
+  if (S->getInit() && !TraverseStmt(S->getInit()))
+return false;
+  if (S->getLoopVariable() && !TraverseDecl(S->getLoopVariable()))
+return false;
+  if (S->getRangeInit() && !TraverseStmt(S->getRangeInit()))
+return false;
+  if (S->getBody() && !TraverseStmt(S->getBody()))
+return false;
+  return true;
+}();
+WalkUpFromCXXForRangeStmt(S);
+return Result;
   }
 
   bool TraverseStmt(Stmt *S) {
Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -331,6 +331,32 @@
   struct has_same_member_pointer_type
   : std::true_type {};
 
+  template  struct is_same_method_impl {
+template 
+static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
+ SecondMethodPtrTy SecondMethodPtr) {
+  return false;
+}
+  };
+
+  template <> struct is_same_method_impl {
+template 
+static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
+ SecondMethodPtrTy SecondMethodPtr) {
+  re

[PATCH] D82620: [clang-format] Preserve whitespace in selected macros

2020-06-26 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD added a comment.

Thanks for the fast review, @curdeius, and thanks for mentioning PP_STRINGIZE 
and BOOST_PP_STRINGIZE too!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82620



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


[PATCH] D82486: RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order traversal

2020-06-26 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 marked 2 inline comments as done.
gribozavr2 added inline comments.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:335
+  template  struct is_same_method_impl {
+static bool isSameMethod(...) { return false; }
+  };

ymandel wrote:
> Why use var-args rather than spelling out the type arguments like you have on 
> lines 339-341 or, simpler, line 351?
Because all of those things are not relevant. However I do see your point, that 
in some sense it is a trick to reduce the number of characters, but somewhat 
hurting readability, so I changed the signature to be explicit.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:339
+  template <> struct is_same_method_impl {
+template  Given that we've established them to be the same type, why two sets of 
> template arguments?
Indeed, simplified the code now!



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:637
   case Stmt::CLASS##Class: 
\
-TRY_TO(WalkUpFrom##CLASS(static_cast(S))); break;
+if (isSameMethod(&RecursiveASTVisitor::Traverse##CLASS,
\
+ &Derived::Traverse##CLASS)) { 
\

ymandel wrote:
> Do you explain this logic somewhere? Or do you feel it will be obvious to the 
> reader? (I don't have a good intuition about this class to judge).
Added a comment. The RecursiveASTVisitor is full of tricky logic so no, none of 
this is obvious.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82486



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


[PATCH] D82501: [sve][acle] Add reinterpret intrinsics for brain float.

2020-06-26 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli marked 2 inline comments as done.
fpetrogalli added inline comments.



Comment at: llvm/test/CodeGen/AArch64/sve-bitcast-bfloat.ll:8
+
+define  @bitcast_bfloat_to_i8( %v) {
+; CHECK-LABEL: bitcast_bfloat_to_i8:

david-arm wrote:
> Aren't these tests all duplicates of ones in 
> llvm/test/CodeGen/AArch64/sve-bitcast.ll? Looks like you can remove this file 
> completely.
(facepalm). yes, I remember thinking "I have to remove them before updating the 
patch", and then I forgot... I will do it before submitting. Thank you for 
pointing this out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82501



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


[PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences

2020-06-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:117-118
 
-  // TODO: Add a note to bug reports describing this decision.
-  C.addTransition(
-  State->BindExpr(Call.getOriginExpr(), C.getLocationContext(),
-  C.getSValBuilder().makeZeroVal(Call.getResultType(;
+  if (checkDeferenceOps(Call, C))
+return true;
+

By returning "true" here you're saying that operators `*` and `->` do nothing. 
That's not quite right; they return a value. You should not return `true` from 
`evalCall` unless you //fully// model the call.

I wouldn't mind moving //precondition// checks such as this one into 
`checkPreCall`, even if you do `evalCall` later. That would clearly separate 
concerns and avoid the need to figure out whether we still need to model the 
call after the bug-reporting routine finishes (the engine will do that for you 
automatically).

In fact i wouldn't mind moving all bug reporting functionality into a separate 
//checker//. But that's a story for another time^^


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

https://reviews.llvm.org/D81315



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


[PATCH] D82362: Move default module cache from system temporary directory

2020-06-26 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on Mac: http://45.33.8.238/mac/16222/step_11.txt

Please take a look and revert for now if this takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82362



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


[PATCH] D82650: [HIP] Set default FP_CONTRACT to ON

2020-06-26 Thread Daniil Fukalov via Phabricator via cfe-commits
dfukalov planned changes to this revision.
dfukalov added a comment.

In D82650#2116849 , @yaxunl wrote:

> I think the point of -ffp-contract=fast is that it allows emitting fma across 
> statements if there are such opportunities whereas -ffp-contract=on only 
> allows fma in one statement
>
> https://llvm.org/docs/CompileCudaWithLLVM.html#flags-that-control-numerical-code


Yes, you're right. I was confused by current FE behavior and a number of 
different commits, reverts and re-commits.

Currently FE checks `allowFPContractWithinStatement()` and it returns false for 
FAST mode. As I understand, FAST mode should be more aggressive and include 
this case.
I'll re-work the change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82650



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


[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-06-26 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson marked an inline comment as done.
tejohnson added a comment.

In D73242#1963451 , @evgeny777 wrote:

> This needs to be rebased


Sorry for the delay, I've been side tracked on other work. Rebased and beefed 
up the test as requested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73242



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


[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-06-26 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 273730.
tejohnson added a comment.

Rebase and beef up test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73242

Files:
  llvm/include/llvm/IR/ModuleSummaryIndex.h
  llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/Bitcode/summary_version.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/ThinLTO/X86/Inputs/cfi-unsat.ll
  llvm/test/ThinLTO/X86/cfi-unsat.ll
  llvm/test/ThinLTO/X86/nodevirt-nonpromoted-typeid.ll
  llvm/test/ThinLTO/X86/type_test_noindircall.ll
  llvm/test/Transforms/WholeProgramDevirt/branch-funnel.ll
  llvm/test/Transforms/WholeProgramDevirt/devirt-single-impl2.ll
  llvm/test/Transforms/WholeProgramDevirt/export-single-impl.ll
  llvm/test/Transforms/WholeProgramDevirt/export-uniform-ret-val.ll
  llvm/test/Transforms/WholeProgramDevirt/export-unique-ret-val.ll
  llvm/test/Transforms/WholeProgramDevirt/export-vcp.ll
  llvm/test/Transforms/WholeProgramDevirt/import-indir.ll
  llvm/test/Transforms/WholeProgramDevirt/uniform-retval.ll

Index: llvm/test/Transforms/WholeProgramDevirt/uniform-retval.ll
===
--- llvm/test/Transforms/WholeProgramDevirt/uniform-retval.ll
+++ llvm/test/Transforms/WholeProgramDevirt/uniform-retval.ll
@@ -25,7 +25,7 @@
   %fptr = load i8*, i8** %fptrptr
   %fptr_casted = bitcast i8* %fptr to i32 (i8*)*
   %result = call i32 %fptr_casted(i8* %obj)
-  ; CHECK-NOT: call
+  ; CHECK-NOT: call i32 %
   ; CHECK: ret i32 123
   ret i32 %result
 }
Index: llvm/test/Transforms/WholeProgramDevirt/import-indir.ll
===
--- llvm/test/Transforms/WholeProgramDevirt/import-indir.ll
+++ llvm/test/Transforms/WholeProgramDevirt/import-indir.ll
@@ -32,7 +32,7 @@
 ; SUMMARY-NEXT: TypeIdMap:
 ; SUMMARY-NEXT:   typeid1:
 ; SUMMARY-NEXT: TTRes:
-; SUMMARY-NEXT:   Kind:Unsat
+; SUMMARY-NEXT:   Kind:Unknown
 ; SUMMARY-NEXT:   SizeM1BitWidth:  0
 ; SUMMARY-NEXT:   AlignLog2:   0
 ; SUMMARY-NEXT:   SizeM1:  0
Index: llvm/test/Transforms/WholeProgramDevirt/export-vcp.ll
===
--- llvm/test/Transforms/WholeProgramDevirt/export-vcp.ll
+++ llvm/test/Transforms/WholeProgramDevirt/export-vcp.ll
@@ -9,7 +9,7 @@
 ; SUMMARY:  TypeIdMap:
 ; SUMMARY-NEXT:   typeid3:
 ; SUMMARY-NEXT: TTRes:
-; SUMMARY-NEXT:   Kind:Unsat
+; SUMMARY-NEXT:   Kind:Unknown
 ; SUMMARY-NEXT:   SizeM1BitWidth:  0
 ; SUMMARY-NEXT:   AlignLog2:   0
 ; SUMMARY-NEXT:   SizeM1:  0
@@ -29,7 +29,7 @@
 ; SUMMARY-ARM-NEXT: Bit: 1
 ; SUMMARY-NEXT:   typeid4:
 ; SUMMARY-NEXT: TTRes:
-; SUMMARY-NEXT:   Kind:Unsat
+; SUMMARY-NEXT:   Kind:Unknown
 ; SUMMARY-NEXT:   SizeM1BitWidth:  0
 ; SUMMARY-NEXT:   AlignLog2:   0
 ; SUMMARY-NEXT:   SizeM1:  0
Index: llvm/test/Transforms/WholeProgramDevirt/export-unique-ret-val.ll
===
--- llvm/test/Transforms/WholeProgramDevirt/export-unique-ret-val.ll
+++ llvm/test/Transforms/WholeProgramDevirt/export-unique-ret-val.ll
@@ -6,7 +6,7 @@
 ; SUMMARY:  TypeIdMap:
 ; SUMMARY-NEXT:   typeid3:
 ; SUMMARY-NEXT: TTRes:
-; SUMMARY-NEXT:   Kind:Unsat
+; SUMMARY-NEXT:   Kind:Unknown
 ; SUMMARY-NEXT:   SizeM1BitWidth:  0
 ; SUMMARY-NEXT:   AlignLog2:   0
 ; SUMMARY-NEXT:   SizeM1:  0
@@ -24,7 +24,7 @@
 ; SUMMARY-NEXT: Bit: 0
 ; SUMMARY-NEXT:   typeid4:
 ; SUMMARY-NEXT: TTRes:
-; SUMMARY-NEXT:   Kind:Unsat
+; SUMMARY-NEXT:   Kind:Unknown
 ; SUMMARY-NEXT:   SizeM1BitWidth:  0
 ; SUMMARY-NEXT:   AlignLog2:   0
 ; SUMMARY-NEXT:   SizeM1:  0
Index: llvm/test/Transforms/WholeProgramDevirt/export-uniform-ret-val.ll
===
--- llvm/test/Transforms/WholeProgramDevirt/export-uniform-ret-val.ll
+++ llvm/test/Transforms/WholeProgramDevirt/export-uniform-ret-val.ll
@@ -6,7 +6,7 @@
 ; SUMMARY:  TypeIdMap:
 ; SUMMARY-NEXT:   typeid4:
 ; SUMMARY-NEXT: TTRes:
-; SUMMARY-NEXT:   Kind:Unsat
+; SUMMARY-NEXT:   Kind:Unknown
 ; SUMMARY-NEXT:   SizeM1BitWidth:  0
 ; SUMMARY-NEXT:   AlignLog2:   0
 ; SUMMARY-NE

[PATCH] D82592: [libTooling] Rename overloaded `range` range selector.

2020-06-26 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG056a539e570a: [libTooling] Rename overloaded `range` range 
selector. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82592

Files:
  clang/include/clang/Tooling/Transformer/RangeSelector.h
  clang/lib/Tooling/Transformer/RangeSelector.cpp
  clang/unittests/Tooling/RangeSelectorTest.cpp


Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -201,7 +201,7 @@
   )cc";
   auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
   hasArgument(1, expr().bind("a1")));
-  RangeSelector R = range("a0", "a1");
+  RangeSelector R = encloseNodes("a0", "a1");
   TestMatch Match = matchCode(Code, Matcher);
   EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
 }
@@ -213,7 +213,7 @@
   )cc";
   auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
   hasArgument(1, expr().bind("a1")));
-  RangeSelector R = range(node("a0"), node("a1"));
+  RangeSelector R = enclose(node("a0"), node("a1"));
   TestMatch Match = matchCode(Code, Matcher);
   EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
 }
Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -146,7 +146,7 @@
   };
 }
 
-RangeSelector transformer::range(RangeSelector Begin, RangeSelector End) {
+RangeSelector transformer::enclose(RangeSelector Begin, RangeSelector End) {
   return [Begin, End](const MatchResult &Result) -> Expected {
 Expected BeginRange = Begin(Result);
 if (!BeginRange)
@@ -165,8 +165,9 @@
   };
 }
 
-RangeSelector transformer::range(std::string BeginID, std::string EndID) {
-  return transformer::range(node(std::move(BeginID)), node(std::move(EndID)));
+RangeSelector transformer::encloseNodes(std::string BeginID,
+std::string EndID) {
+  return transformer::enclose(node(std::move(BeginID)), 
node(std::move(EndID)));
 }
 
 RangeSelector transformer::member(std::string ID) {
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -32,10 +32,20 @@
 }
 
 /// Selects from the start of \p Begin and to the end of \p End.
-RangeSelector range(RangeSelector Begin, RangeSelector End);
+RangeSelector enclose(RangeSelector Begin, RangeSelector End);
 
 /// Convenience version of \c range where end-points are bound nodes.
-RangeSelector range(std::string BeginID, std::string EndID);
+RangeSelector encloseNodes(std::string BeginID, std::string EndID);
+
+/// DEPRECATED. Use `enclose`.
+inline RangeSelector range(RangeSelector Begin, RangeSelector End) {
+  return enclose(std::move(Begin), std::move(End));
+}
+
+/// DEPRECATED. Use `encloseNodes`.
+inline RangeSelector range(std::string BeginID, std::string EndID) {
+  return encloseNodes(std::move(BeginID), std::move(EndID));
+}
 
 /// Selects the (empty) range [B,B) when \p Selector selects the range [B,E).
 RangeSelector before(RangeSelector Selector);


Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -201,7 +201,7 @@
   )cc";
   auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
   hasArgument(1, expr().bind("a1")));
-  RangeSelector R = range("a0", "a1");
+  RangeSelector R = encloseNodes("a0", "a1");
   TestMatch Match = matchCode(Code, Matcher);
   EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
 }
@@ -213,7 +213,7 @@
   )cc";
   auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
   hasArgument(1, expr().bind("a1")));
-  RangeSelector R = range(node("a0"), node("a1"));
+  RangeSelector R = enclose(node("a0"), node("a1"));
   TestMatch Match = matchCode(Code, Matcher);
   EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
 }
Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -146,7 +146,7 @@
   };
 }
 
-RangeSelector transformer::range(RangeSelector Begin, RangeSelector End) {
+RangeSelector transformer::enclose(RangeSelector Begin, RangeSelector End) {
   return [Begin, End](const MatchResult &Result) -> Expected {
 Expected Beg

[clang] fa1b488 - Work around a bug in MSVC in the syntax tree test

2020-06-26 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-06-26T16:43:30+02:00
New Revision: fa1b488776185827274637f8fdd38b20b6b5c036

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

LOG: Work around a bug in MSVC in the syntax tree test

Summary:
MSVC does not handle raw string literals with embedded double quotes
correctly. I switched the affected test case to use regular string
literals insetad.

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/Syntax/TreeTest.cpp 
b/clang/unittests/Tooling/Syntax/TreeTest.cpp
index 5dd6cc747628..0e48e138c408 100644
--- a/clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -1636,33 +1636,33 @@ TEST_P(SyntaxTreeTest, StringLiteralRaw) {
   if (!GetParam().isCXX11OrLater()) {
 return;
   }
-  EXPECT_TRUE(treeDumpEqual(
-  R"cpp(
-void test() {
-  R"SyntaxTree(
-  Hello "Syntax" \"
-  )SyntaxTree";
-}
-)cpp",
-  R"txt(
-*: TranslationUnit
-`-SimpleDeclaration
-  |-void
-  |-SimpleDeclarator
-  | |-test
-  | `-ParametersAndQualifiers
-  |   |-(
-  |   `-)
-  `-CompoundStatement
-|-{
-|-ExpressionStatement
-| |-StringLiteralExpression
-| | `-R"SyntaxTree(
-  Hello "Syntax" \"
-  )SyntaxTree"
-| `-;
-`-}
-)txt"));
+  // This test uses regular string literals instead of raw string literals to
+  // hold source code and expected output because of a bug in MSVC up to MSVC
+  // 2019 16.2:
+  // 
https://developercommunity.visualstudio.com/content/problem/67300/stringifying-raw-string-literal.html
+  EXPECT_TRUE(treeDumpEqual( //
+  "void test() {\n"
+  "  R\"SyntaxTree(\n"
+  "  Hello \"Syntax\" \\\"\n"
+  "  )SyntaxTree\";\n"
+  "}\n",
+  "*: TranslationUnit\n"
+  "`-SimpleDeclaration\n"
+  "  |-void\n"
+  "  |-SimpleDeclarator\n"
+  "  | |-test\n"
+  "  | `-ParametersAndQualifiers\n"
+  "  |   |-(\n"
+  "  |   `-)\n"
+  "  `-CompoundStatement\n"
+  "|-{\n"
+  "|-ExpressionStatement\n"
+  "| |-StringLiteralExpression\n"
+  "| | `-R\"SyntaxTree(\n"
+  "  Hello \"Syntax\" \\\"\n"
+  "  )SyntaxTree\"\n"
+  "| `-;\n"
+  "`-}\n"));
 }
 
 TEST_P(SyntaxTreeTest, BoolLiteral) {



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


[PATCH] D82486: RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order traversal

2020-06-26 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added inline comments.



Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:646
+ * receives a DataRecursionQueue, can't call WalkUpFrom after traversing   
\
+ * children because it only enqueues the children. and does not traverse   
\
+ * them. TraverseStmt traverses the enqueued children, and we call 
\

delete stray period after "children"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82486



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


[clang] e91c4b2 - [NFC] Eliminate an unneeded -vv used in test development.

2020-06-26 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-06-26T11:09:16-04:00
New Revision: e91c4b2af2c03ef599623243e625f347e166673d

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

LOG: [NFC] Eliminate an unneeded -vv used in test development.

Added: 


Modified: 
clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c 
b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
index 473d3ba53e96..d42fb1e02cad 100644
--- a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
+++ b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
@@ -12,7 +12,7 @@
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +fullfp16 \
 // RUN: -ffp-exception-behavior=strict \
 // RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone -o - %s \
-// RUN: | FileCheck -vv --check-prefix=COMMON --check-prefix=CHECK-ASM %s
+// RUN: | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
 
 // REQUIRES: aarch64-registered-target
 



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


[PATCH] D82617: Disable GCC's -Woverloaded-virtual, which has false positives.

2020-06-26 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

FWIW, I think the example you gave is **correct** for GCC to warn on. You said:

  class Base {
virtual void foo(); // to be overridden
void foo(int); // implemented in terms of foo()
  };

foo(int) is hidden in derived classes. So if someone derives from Base (which 
someone must, because Base is polymorphic), then the derived class violates the 
Liskov substitution principle: it doesn't have an `obj.foo(42)` method. The 
correct solution is to rename the implementation method from `foo()` to e.g. 
`fooImpl()` or (my personal style, following the NVI idiom) `do_foo()`.

GCC is correct to warn that this code is confusing and hard to maintain because 
of name hiding. The solution is to adjust the code until it is clear and 
maintainable, at which point it'll no longer trigger the warning. I don't see 
any problem with GCC's warning here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82617



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


[PATCH] D82259: Deprecate error prone temporary directory APIs

2020-06-26 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki abandoned this revision.
davezarzycki added a comment.

Now that my core concern is addressed (moving clang's default module cache out 
of /tmp), I don't have the time to push for this deprecation. Sorry.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82259



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


[PATCH] D82654: [libTooling] Improve error message from failure in selection Stencil

2020-06-26 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

> I generally avoid testing error message content in tests, but I know there's 
> a variety of opinions on this subject...

If you thought that the quality of the error message matters enough to improve 
it, then it is worth testing the message, I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82654



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


[PATCH] D82486: RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order traversal

2020-06-26 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr updated this revision to Diff 273736.
gribozavr added a comment.

Removed a stray period in a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82486

Files:
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -117,18 +117,13 @@
   Code,
   R"txt(
 TraverseIntegerLiteral IntegerLiteral(1)
-WalkUpFromStmt IntegerLiteral(1)
 TraverseIntegerLiteral IntegerLiteral(2)
-WalkUpFromStmt IntegerLiteral(2)
 TraverseIntegerLiteral IntegerLiteral(3)
-WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt DeclRefExpr(add)
 WalkUpFromStmt ImplicitCastExpr
 TraverseIntegerLiteral IntegerLiteral(4)
-WalkUpFromStmt IntegerLiteral(4)
 TraverseIntegerLiteral IntegerLiteral(5)
-WalkUpFromStmt IntegerLiteral(5)
 WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -189,18 +184,13 @@
   Code,
   R"txt(
 TraverseIntegerLiteral IntegerLiteral(1)
-WalkUpFromIntegerLiteral IntegerLiteral(1)
 TraverseIntegerLiteral IntegerLiteral(2)
-WalkUpFromIntegerLiteral IntegerLiteral(2)
 TraverseIntegerLiteral IntegerLiteral(3)
-WalkUpFromIntegerLiteral IntegerLiteral(3)
 WalkUpFromExpr BinaryOperator(+)
 WalkUpFromExpr DeclRefExpr(add)
 WalkUpFromExpr ImplicitCastExpr
 TraverseIntegerLiteral IntegerLiteral(4)
-WalkUpFromIntegerLiteral IntegerLiteral(4)
 TraverseIntegerLiteral IntegerLiteral(5)
-WalkUpFromIntegerLiteral IntegerLiteral(5)
 WalkUpFromExpr CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -315,7 +305,6 @@
 WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromStmt IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt DeclRefExpr(add)
 WalkUpFromStmt ImplicitCastExpr
 WalkUpFromStmt IntegerLiteral(4)
@@ -383,7 +372,6 @@
 WalkUpFromExpr IntegerLiteral(1)
 WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromExpr IntegerLiteral(3)
-WalkUpFromBinaryOperator BinaryOperator(+)
 WalkUpFromExpr DeclRefExpr(add)
 WalkUpFromExpr ImplicitCastExpr
 WalkUpFromExpr IntegerLiteral(4)
@@ -500,7 +488,6 @@
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt BinaryOperator(+)
 TraverseCallExpr CallExpr(add)
-WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
 }
@@ -560,7 +547,6 @@
 WalkUpFromExpr IntegerLiteral(3)
 WalkUpFromExpr BinaryOperator(+)
 TraverseCallExpr CallExpr(add)
-WalkUpFromCallExpr CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
 }
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -578,15 +578,19 @@
 // RAV traverses it as a statement, we produce invalid node kinds in that
 // case.
 // FIXME: should do this in RAV instead?
-if (S->getInit() && !TraverseStmt(S->getInit()))
-  return false;
-if (S->getLoopVariable() && !TraverseDecl(S->getLoopVariable()))
-  return false;
-if (S->getRangeInit() && !TraverseStmt(S->getRangeInit()))
-  return false;
-if (S->getBody() && !TraverseStmt(S->getBody()))
-  return false;
-return true;
+bool Result = [&, this]() {
+  if (S->getInit() && !TraverseStmt(S->getInit()))
+return false;
+  if (S->getLoopVariable() && !TraverseDecl(S->getLoopVariable()))
+return false;
+  if (S->getRangeInit() && !TraverseStmt(S->getRangeInit()))
+return false;
+  if (S->getBody() && !TraverseStmt(S->getBody()))
+return false;
+  return true;
+}();
+WalkUpFromCXXForRangeStmt(S);
+return Result;
   }
 
   bool TraverseStmt(Stmt *S) {
Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -331,6 +331,32 @@
   struct has_same_member_pointer_type
   : std::true_type {};
 
+  template  struct is_same_method_impl {
+template 
+static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
+ SecondMethodPtrTy SecondMethodPtr) {
+  return false;
+}
+  };
+
+  template <> struct is_same_method_impl {
+template 
+static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
+ SecondMethodPtrTy SecondMethodPtr) {
+  return FirstMethodPtr == SecondMethodPtr;
+}
+  };
+
+  /// Returns true if and only if \p

[PATCH] D81920: [clangd] Change FSProvider::getFileSystem to take CurrentWorkingDirectory

2020-06-26 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang-tools-extra/clangd/support/FSProvider.h:37
+  /// This is an overload instead of an optional to make implicit string ->
+  /// StringRef conversion possible.
+  virtual llvm::IntrusiveRefCntPtr

Re how to fix the GCC warning: I haven't fully understood this code yet 
(because it's hard to understand! :)) but I think what you're trying to do here 
is something like
```
class FileSystemProvider {
public:
llvm::IntrusiveRefCntPtr
getFileSystem(std::optional CWD) const {
if (CWD.has_value()) {
return this->doGetDefaultFileSystem();  // virtual call
} else {
return this->doGetFileSystem(CWD);  // virtual call
}
}
private:
virtual llvm::IntrusiveRefCntPtr
doGetDefaultFileSystem() const = 0;
virtual llvm::IntrusiveRefCntPtr
doGetFileSystem(PathRef) const;
};
```
And then in `class RealFileSystemProvider`, you want to override 
`doGetDefaultFileSystem()` while leaving `doGetFileSystem` untouched. Does that 
basically reflect your intent here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81920



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


  1   2   3   >