[PATCH] D74692: [clang-tidy][bugprone-use-after-move] Warn on std::move for consts

2020-03-24 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

Gentle ping)


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

https://reviews.llvm.org/D74692



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


[PATCH] D69330: [AST] Add RecoveryExpr to retain expressions on semantic errors

2020-03-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 252238.
hokein marked 2 inline comments as done.
hokein added a comment.

add -fno-recovery-ast, and negative tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69330

Files:
  clang/include/clang/AST/ComputeDependence.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/AST/ast-dump-expr-errors.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/Index/getcursor-recovery.cpp
  clang/test/SemaTemplate/recovery-tree-transform.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -292,6 +292,7 @@
   case Stmt::ObjCDictionaryLiteralClass:
   case Stmt::ObjCBoxedExprClass:
   case Stmt::ObjCSubscriptRefExprClass:
+  case Stmt::RecoveryExprClass:
 K = CXCursor_UnexposedExpr;
 break;
 
Index: clang/test/SemaTemplate/recovery-tree-transform.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/recovery-tree-transform.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -verify -frecovery-ast %s
+
+template int *p = &void(T::error); // expected-error{{cannot take the address of an rvalue}} expected-error{{type 'int' cannot be used prior to '::'}}
+int *q = p; // expected-note{{in instantiation of variable template specialization 'p' requested here}}
Index: clang/test/Index/getcursor-recovery.cpp
===
--- /dev/null
+++ clang/test/Index/getcursor-recovery.cpp
@@ -0,0 +1,16 @@
+int foo(int, int);
+int foo(int, double);
+int x;
+
+void testTypedRecoveryExpr() {
+  // Inner foo() is a RecoveryExpr, outer foo() is an overloaded call.
+  foo(x, foo(x));
+}
+// RUN: c-index-test -cursor-at=%s:7:3 %s -Xclang -frecovery-ast | FileCheck -check-prefix=OUTER-FOO %s
+// OUTER-FOO: OverloadedDeclRef=foo[2:5, 1:5]
+// RUN: c-index-test -cursor-at=%s:7:7 %s -Xclang -frecovery-ast | FileCheck -check-prefix=OUTER-X %s
+// OUTER-X: DeclRefExpr=x:3:5
+// RUN: c-index-test -cursor-at=%s:7:10 %s -Xclang -frecovery-ast | FileCheck -check-prefix=INNER-FOO %s
+// INNER-FOO: OverloadedDeclRef=foo[2:5, 1:5]
+// RUN: c-index-test -cursor-at=%s:7:14 %s -Xclang -frecovery-ast | FileCheck -check-prefix=INNER-X %s
+// INNER-X: DeclRefExpr=x:3:5
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -0,0 +1,85 @@
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 -frecovery-ast -ast-dump %s | FileCheck -strict-whitespace %s
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 -fno-recovery-ast -ast-dump %s | FileCheck --check-prefix=DISABLED -strict-whitespace %s
+
+int some_func(int *);
+
+// CHECK: VarDecl {{.*}} invalid_call
+// CHECK-NEXT:`-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:  |-UnresolvedLookupExpr {{.*}} 'some_func'
+// CHECK-NEXT:  `-IntegerLiteral {{.*}} 123
+// DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
+int invalid_call = some_func(123);
+
+int ambig_func(double);
+int ambig_func(float);
+
+// CHECK: VarDecl {{.*}} ambig_call
+// CHECK-NEXT:`-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:  |-UnresolvedLookupExpr {{.*}} 'ambig_func'
+// CHECK-NEXT:  `-IntegerLiteral {{.*}} 123
+// DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
+int ambig_call = ambig_func(123);
+
+// CHECK: VarDecl {{.*}} unresolved_call1
+// CHECK-NEXT:`-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:  `-UnresolvedLookupExpr {{.*}} 'bar'
+// DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
+int unresolved_call1 = bar();
+
+// CHECK: VarDecl {{.*}} unresolved_call2
+// CHECK-NEXT:`-CallExpr {{.*}} contains-errors
+// CHECK-NEXT:  |-UnresolvedLookupExpr {{.*}} 'bar'
+// CHECK-NEXT:  |-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT

[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-24 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 252237.
oontvoo added a comment.

Cleanup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1676,6 +1676,9 @@
   }
   LE.write(Offset);
 
+  // Write this file UID.
+  LE.write(Data.HFI.UID);
+
   auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
 if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
   uint32_t Value = (ModID << 2) | (unsigned)Role;
@@ -1703,7 +1706,7 @@
 /// Write the header search block for the list of files that
 ///
 /// \param HS The header search structure to save.
-void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
+void ASTWriter::WriteHeaderSearch(HeaderSearch &HS) {
   HeaderFileInfoTrait GeneratorTrait(*this);
   llvm::OnDiskChainedHashTableGenerator Generator;
   SmallVector SavedStrings;
@@ -1781,7 +1784,7 @@
 // changed since it was loaded. Also skip it if it's for a modular header
 // from a different module; in that case, we rely on the module(s)
 // containing the header to provide this information.
-const HeaderFileInfo *HFI =
+HeaderFileInfo *HFI =
 HS.getExistingFileInfo(File, /*WantExternal*/!Chain);
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
   continue;
@@ -1799,8 +1802,11 @@
 HeaderFileInfoTrait::key_type Key = {
   Filename, File->getSize(), getTimestampForOutput(File)
 };
+// Set the UID for this HFI so that its importers could use it
+// when serializing.
+HFI->UID = UID;
 HeaderFileInfoTrait::data_type Data = {
-  *HFI, HS.getModuleMap().findAllModulesForHeader(File), {}
+  *HFI, HS.getModuleMap().findAllModulesForHeader(File), {},
 };
 Generator.insert(Key, Data, GeneratorTrait);
 ++NumHeaderSearchEntries;
@@ -2634,6 +2640,18 @@
   Stream.EmitRecord(SUBMODULE_IMPORTS, Record);
 }
 
+// Emit the imported header's UIDs.
+{
+  auto it = PP->Submodules.find(Mod);
+  if (it != PP->Submodules.end() && !it->second.IncludedFiles.empty()) {
+RecordData Record;
+for (const HeaderFileInfo* HFI : it->second.IncludedFiles) {
+  Record.push_back(HFI->UID);
+}
+Stream.EmitRecord(SUBMODULE_IMPORTED_HEADERS, Record);
+  }
+}
+
 // Emit the exports.
 if (!Mod->Exports.empty()) {
   RecordData Record;
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1898,6 +1898,9 @@
 HFI.Framework = HS->getUniqueFrameworkName(FrameworkName);
   }
 
+  // Read the file old UID
+  HFI.UID = endian::readNext(d);
+
   assert((End - d) % 4 == 0 &&
  "Wrong data length in HeaderFileInfo deserialization");
   while (d != End) {
@@ -5615,6 +5618,11 @@
   }
   break;
 
+  case SUBMODULE_IMPORTED_HEADERS:
+for (unsigned Idx = 0; Idx < Record.size(); ++Idx) {
+  PendingImportedHeaders[&F].push_back(Record[Idx]);
+}
+break;
 case SUBMODULE_EXPORTS:
   for (unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
 UnresolvedModuleRef Unresolved;
@@ -9271,6 +9279,38 @@
   for (auto *ND : PendingMergedDefinitionsToDeduplicate)
 getContext().deduplicateMergedDefinitonsFor(ND);
   PendingMergedDefinitionsToDeduplicate.clear();
+
+  // Fix up the HeaderSearchInfo UIDs.
+  if (!PendingImportedHeaders.empty()) {
+std::map UIDToIndex;
+
+// These HFIs were deserialized and assigned their "old"
+// UID.
+// We need to update them and populate the OldToIndex map
+// for use next.
+HeaderSearch &HS = PP.getHeaderSearchInfo();
+for (unsigned Idx = 0; Idx < HS.FileInfo.size(); ++Idx) {
+  UIDToIndex[HS.FileInfo[Idx].UID] = Idx;
+  // Clear the no longer useful UID fields.
+  HS.FileInfo[Idx].UID = 0;
+}
+
+const auto &Iter = PendingImportedHeaders.begin();
+for (unsigned I = 0; I < PendingImportedHeaders.size(); ++I) {
+  ModuleFile *ModFile = Iter[I].first;
+  auto &HeaderUIDs = Iter[I].second;
+  Module *M = HS.lookupModule(ModFile->ModuleName);
+
+  Preprocessor::SubmoduleState &SubState = PP.Submodules[M];
+  for (unsigned OldUID : HeaderUIDs) {
+auto IdxIt = UIDToIndex.find(OldUID);
+   

[clang] 733edf9 - [AST] Add RecoveryExpr to retain expressions on semantic errors

2020-03-24 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-03-24T09:20:37+01:00
New Revision: 733edf9750a4893d5f50329ad68b3901935303a9

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

LOG: [AST] Add RecoveryExpr to retain expressions on semantic errors

Normally clang avoids creating expressions when it encounters semantic
errors, even if the parser knows which expression to produce.

This works well for the compiler. However, this is not ideal for
source-level tools that have to deal with broken code, e.g. clangd is
not able to provide navigation features even for names that compiler
knows how to resolve.

The new RecoveryExpr aims to capture the minimal set of information
useful for the tools that need to deal with incorrect code:

source range of the expression being dropped,
subexpressions of the expression.
We aim to make constructing RecoveryExprs as simple as possible to
ensure writing code to avoid dropping expressions is easy.

Producing RecoveryExprs can result in new code paths being taken in the
frontend. In particular, clang can produce some new diagnostics now and
we aim to suppress bogus ones based on Expr::containsErrors.

We deliberately produce RecoveryExprs only in the parser for now to
minimize the code affected by this patch. Producing RecoveryExprs in
Sema potentially allows to preserve more information (e.g. type of an
expression), but also results in more code being affected. E.g.
SFINAE checks will have to take presence of RecoveryExprs into account.

Initial implementation only works in C++ mode, as it relies on compiler
postponing diagnostics on dependent expressions. C and ObjC often do not
do this, so they require more work to make sure we do not produce too
many bogus diagnostics on the new expressions.

See documentation of RecoveryExpr for more details.

original patch from Ilya
This change is based on https://reviews.llvm.org/D61722

Reviewers: sammccall, rsmith

Reviewed By: sammccall, rsmith

Tags: #clang

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

Added: 
clang/test/AST/ast-dump-expr-errors.cpp
clang/test/AST/ast-dump-recovery.cpp
clang/test/Index/getcursor-recovery.cpp
clang/test/SemaTemplate/recovery-tree-transform.cpp

Modified: 
clang/include/clang/AST/ComputeDependence.h
clang/include/clang/AST/Expr.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/StmtNodes.td
clang/include/clang/Driver/CC1Options.td
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprClassification.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExceptionSpec.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/tools/libclang/CXCursor.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ComputeDependence.h 
b/clang/include/clang/AST/ComputeDependence.h
index 69ccb6c676e5..02f826438d4d 100644
--- a/clang/include/clang/AST/ComputeDependence.h
+++ b/clang/include/clang/AST/ComputeDependence.h
@@ -45,6 +45,7 @@ class ExtVectorElementExpr;
 class BlockExpr;
 class AsTypeExpr;
 class DeclRefExpr;
+class RecoveryExpr;
 class CXXRewrittenBinaryOperator;
 class CXXStdInitializerListExpr;
 class CXXTypeidExpr;
@@ -122,6 +123,7 @@ ExprDependence computeDependence(ExtVectorElementExpr *E);
 ExprDependence computeDependence(BlockExpr *E);
 ExprDependence computeDependence(AsTypeExpr *E);
 ExprDependence computeDependence(DeclRefExpr *E, const ASTContext &Ctx);
+ExprDependence computeDependence(RecoveryExpr *E);
 ExprDependence computeDependence(CXXRewrittenBinaryOperator *E);
 ExprDependence computeDependence(CXXStdInitializerListExpr *E);
 ExprDependence computeDependence(CXXTypeidExpr *E);

diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index f960fbd9ce31..e27d7f04093b 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -5911,6 +5911,69 @@ class TypoExpr : public Expr {
   }
 
 };
+
+/// Frontend produces RecoveryExprs on semantic errors that prevent creating
+/// other well-formed expressions. E.g. when type-checking of a binary operator
+/// fails, we cannot produce a BinaryOperator expression. Instead, we can 
choose
+/// to produce a recovery expression storing left and

[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

@MarcusJohnson91 To get a review past its better that you mark the comments as 
done so the reviewers know when the comments have been addressed and not 
missed. (this is important as the number of comments grows)

Developers need to explain why they haven't changed something the reviewer has 
commented on, in some form or another, that means either an explanation of why 
they are not doing it, or they do it.. but leaving it ignored makes the 
reviewer feel the author hasn't got round to looking at it yet or missed it and 
so it isn't ready for re-review.

As for me, this is not off my radar,I get busy at work which means my time is 
reduced, but I visit the side daily and review where we are.  I've been back to 
this review 4 or 5 times to this one alone (normally on every ping) but the 
comments have not been addressed, so I'm afraid I'm unlikely to now go around 
as say, "Yeah its fine, put it in" without anything changing or being explained 
why. I probably should have explained that earlier (which is my bad).

Every reviewer has a different bar, for me its people changing tests.. In the 
review the tests changed and I'm thinking sorry but I can't trust its not 
breaking existing behavior. (I go by the Beyonce rule of testing, and no one 
should be changing Beyonce as surely she's perfect already!)

I've met this in my professional life where developers modify tests until their 
code works, and while you may not be doing that here, I have a personal 
aversion to them being changed having been burnt a few times. I personally 
don't care how many tests there are, the more the merrier is my view.

I also don't like tests which test 2 things at the same time. For me line #2463 
is it.  Its super subtle and probably 100% OK,  but I don't understand why you 
added the /* comment */, (by all means add that as another test), but I don't 
like changing the existing tests unless I absolutely have to.

My advice is address those comments, mark them done, but by all means canvas 
opinion from others if you think that's unfair. Its just my opinion, I'm not 
the only reviewer able to give an Accept.


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

https://reviews.llvm.org/D75791



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


[PATCH] D69330: [AST] Add RecoveryExpr to retain expressions on semantic errors

2020-03-24 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rG733edf9750a4: [AST] Add RecoveryExpr to retain expressions 
on semantic errors (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D69330?vs=252238&id=252243#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69330

Files:
  clang/include/clang/AST/ComputeDependence.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/AST/ast-dump-expr-errors.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/Index/getcursor-recovery.cpp
  clang/test/SemaTemplate/recovery-tree-transform.cpp
  clang/tools/libclang/CXCursor.cpp

Index: clang/tools/libclang/CXCursor.cpp
===
--- clang/tools/libclang/CXCursor.cpp
+++ clang/tools/libclang/CXCursor.cpp
@@ -292,6 +292,7 @@
   case Stmt::ObjCDictionaryLiteralClass:
   case Stmt::ObjCBoxedExprClass:
   case Stmt::ObjCSubscriptRefExprClass:
+  case Stmt::RecoveryExprClass:
 K = CXCursor_UnexposedExpr;
 break;
 
Index: clang/test/SemaTemplate/recovery-tree-transform.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/recovery-tree-transform.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -verify -frecovery-ast %s
+
+template int *p = &void(T::error); // expected-error{{cannot take the address of an rvalue}} expected-error{{type 'int' cannot be used prior to '::'}}
+int *q = p; // expected-note{{in instantiation of variable template specialization 'p' requested here}}
Index: clang/test/Index/getcursor-recovery.cpp
===
--- /dev/null
+++ clang/test/Index/getcursor-recovery.cpp
@@ -0,0 +1,16 @@
+int foo(int, int);
+int foo(int, double);
+int x;
+
+void testTypedRecoveryExpr() {
+  // Inner foo() is a RecoveryExpr, outer foo() is an overloaded call.
+  foo(x, foo(x));
+}
+// RUN: c-index-test -cursor-at=%s:7:3 %s -Xclang -frecovery-ast | FileCheck -check-prefix=OUTER-FOO %s
+// OUTER-FOO: OverloadedDeclRef=foo[2:5, 1:5]
+// RUN: c-index-test -cursor-at=%s:7:7 %s -Xclang -frecovery-ast | FileCheck -check-prefix=OUTER-X %s
+// OUTER-X: DeclRefExpr=x:3:5
+// RUN: c-index-test -cursor-at=%s:7:10 %s -Xclang -frecovery-ast | FileCheck -check-prefix=INNER-FOO %s
+// INNER-FOO: OverloadedDeclRef=foo[2:5, 1:5]
+// RUN: c-index-test -cursor-at=%s:7:14 %s -Xclang -frecovery-ast | FileCheck -check-prefix=INNER-X %s
+// INNER-X: DeclRefExpr=x:3:5
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- /dev/null
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -0,0 +1,85 @@
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 -frecovery-ast -ast-dump %s | FileCheck -strict-whitespace %s
+// RUN: not %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value -fcxx-exceptions -std=gnu++17 -fno-recovery-ast -ast-dump %s | FileCheck --check-prefix=DISABLED -strict-whitespace %s
+
+int some_func(int *);
+
+// CHECK: VarDecl {{.*}} invalid_call
+// CHECK-NEXT:`-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:  |-UnresolvedLookupExpr {{.*}} 'some_func'
+// CHECK-NEXT:  `-IntegerLiteral {{.*}} 123
+// DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
+int invalid_call = some_func(123);
+
+int ambig_func(double);
+int ambig_func(float);
+
+// CHECK: VarDecl {{.*}} ambig_call
+// CHECK-NEXT:`-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:  |-UnresolvedLookupExpr {{.*}} 'ambig_func'
+// CHECK-NEXT:  `-IntegerLiteral {{.*}} 123
+// DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
+int ambig_call = ambig_func(123);
+
+// CHECK: VarDecl {{.*}} unresolved_call1
+// CHECK-NEXT:`-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:  `-UnresolvedLookupExpr {{.*}} 'bar'
+// DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
+int unresolved_call1 = bar();
+
+// CHECK: VarDecl {{.*}} unresolved_call2
+// CHE

[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

> Not sure if tagging is considered rude, I figure that @MyDeveloperDay's 
> notification fell off your radar.

Definitely not rude from my perspective...perfectly happy to come and look and 
be tagged to get my attention. If I'm ignoring its, its only becuase I'm busy 
but will get to it asap.


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

https://reviews.llvm.org/D75791



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


[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:2468
"}");
-  verifyFormat("extern \"C\" int foo() {}");
-  verifyFormat("extern \"C\" int foo();");
-  verifyFormat("extern \"C\" int foo() {\n"
+  verifyFormat("extern \"C\" int FormatsExternC_2() {}");
+  verifyFormat("extern \"C\" int FormatsExternC_3();");

I know why you change these varaibles becuase when your developing its hard to 
see which test is failing because verifyFormat doesn't report the correct file 
and line number

but I like the use of `foo` because its 1 character more than your indent width 
and if there is going to be an out by one error you might hide it with a longer 
name


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

https://reviews.llvm.org/D75791



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


[PATCH] D75791: [clang-format] Added new option IndentExternBlock

2020-03-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1088
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (Style.BraceWrapping.AfterExternBlock) {
-  parseBlock(/*MustBeDeclaration=*/true);
-} else {
+if (Style.BraceWrapping.AfterExternBlock == true &&
+Style.IndentExternBlock == true) {

MarcusJohnson91 wrote:
> MyDeveloperDay wrote:
> > something here looks abit odd? there is too much repetition around you 
> > option, I think you doing something at the wrong level.
> I agree that the parseBlock function is doing too much, but it's written that 
> way to begin with.
> 
> The parseBlock function takes 3 parameters and has defaults for two of them, 
> I just changed the value for those defaults on the IndentExternBlock == false 
> versions to default to not indenting; that way the AfterExternBlock option 
> only handles bracewrapping extern blocks, without indenting as well.
I still feel this blocks of 4 if can be written better, its making my eyes 
hurt, every if calls parseBlock() with either true.true, of true,false 

I feel it could be something like

```
if (Style.BraceWrapping.AfterExternBlock){
addUnwrappedLine()
}
parseBlock(/*MustBeDeclaration=*/true,
 /*AddLevel=*/!Style.BraceWrapping.AfterExternBlock);
```


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

https://reviews.llvm.org/D75791



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


[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

2020-03-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

is there overlap here D76197: clang-format: Use block indentation for braced 
initializations 


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

https://reviews.llvm.org/D75034



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


[PATCH] D76678: [SveEmitter] Add range checks for immediates and predicate patterns.

2020-03-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: efriedma, SjoerdMeijer, rovka.
Herald added subscribers: mgrang, tschuett, mgorny.
Herald added a project: clang.
sdesmalen added a child revision: D76679: [SveEmitter] Add more immediate 
operand checks..

This patch adds a mechanism to easily add range checks for a builtin's
immediate operands. This patch is tested with the qdech intrinsic, which takes
both an enum for the predicate pattern, as well as an immediate for the
multiplier.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76678

Files:
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdech.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_qdech.c
  clang/utils/TableGen/SveEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -95,6 +95,7 @@
 void EmitSveBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitSveBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitSveTypeFlags(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSveRangeChecks(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
 void EmitMveHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitMveBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -74,6 +74,7 @@
   GenArmSveBuiltins,
   GenArmSveBuiltinCG,
   GenArmSveTypeFlags,
+  GenArmSveRangeChecks,
   GenArmCdeHeader,
   GenArmCdeBuiltinDef,
   GenArmCdeBuiltinSema,
@@ -197,6 +198,8 @@
"Generate arm_sve_builtin_cg_map.inc for clang"),
 clEnumValN(GenArmSveTypeFlags, "gen-arm-sve-typeflags",
"Generate arm_sve_typeflags.inc for clang"),
+clEnumValN(GenArmSveRangeChecks, "gen-arm-sve-sema-rangechecks",
+   "Generate arm_sve_sema_rangechecks.inc for clang"),
 clEnumValN(GenArmMveHeader, "gen-arm-mve-header",
"Generate arm_mve.h for clang"),
 clEnumValN(GenArmMveBuiltinDef, "gen-arm-mve-builtin-def",
@@ -390,6 +393,9 @@
   case GenArmSveTypeFlags:
 EmitSveTypeFlags(Records, OS);
 break;
+  case GenArmSveRangeChecks:
+EmitSveRangeChecks(Records, OS);
+break;
   case GenArmCdeHeader:
 EmitCdeHeader(Records, OS);
 break;
Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -46,6 +46,22 @@
 
 namespace {
 
+class ImmCheck {
+  int Arg;
+  int Kind;
+  int ElementSizeInBits;
+
+public:
+  ImmCheck(int Arg, int Kind, int ElementSizeInBits = 0)
+  : Arg(Arg), Kind(Kind), ElementSizeInBits(ElementSizeInBits) {}
+  ImmCheck(const ImmCheck &Other) = default;
+  ~ImmCheck() = default;
+
+  int getArg() const { return Arg; }
+  int getKind() const { return Kind; }
+  int getElementSizeInBits() const { return ElementSizeInBits; }
+};
+
 class SVEType {
   TypeSpec TS;
   bool Float, Signed, Immediate, Void, Constant, Pointer;
@@ -146,6 +162,8 @@
 
   unsigned Flags;
 
+  SmallVector ImmChecks;
+
 public:
   /// The type of predication.
   enum MergeType {
@@ -159,16 +177,18 @@
   } Merge;
 
   Intrinsic(StringRef Name, StringRef Proto, int64_t MT, StringRef LLVMName,
-unsigned Flags, TypeSpec BT, ClassKind Class, SVEEmitter &Emitter,
-StringRef Guard)
+unsigned Flags, ArrayRef ImmChecks, TypeSpec BT,
+ClassKind Class, SVEEmitter &Emitter, StringRef Guard)
   : Name(Name.str()), LLVMName(LLVMName), Proto(Proto.str()),
 BaseTypeSpec(BT), Class(Class), Guard(Guard.str()), BaseType(BT, 'd'),
-Flags(Flags), Merge(MergeType(MT)) {
-// Types[0] is the return value.
-for (unsigned I = 0; I < Proto.size(); ++I)
-  Types.emplace_back(BaseTypeSpec, Proto[I]);
+Flags(Flags), ImmChecks(ImmChecks.begin(), ImmChecks.end()),
+Merge(MergeType(MT)) {
+initialize(Emitter);
   }
 
+  // Initialize the types for this intrinsic.
+  void initialize(const SVEEmitter &Emitter);
+
   ~Intrinsic()=default;
 
   std::string getName() const { return Name; }
@@ -189,6 +209,8 @@
   unsigned getFlags() const { return Flags; }
   bool isFlagSet(uint64_t Flag) const { return Flags & Flag;}
 
+  ArrayRef getImmChecks() const { return ImmChecks; }
+
   

[PATCH] D76621: [clang-format] No space inserted between commas in C#

2020-03-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

nice, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76621



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


[PATCH] D76679: [SveEmitter] Add more immediate operand checks.

2020-03-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: efriedma, SjoerdMeijer, rovka.
Herald added a subscriber: tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.
sdesmalen added a parent revision: D76678: [SveEmitter] Add range checks for 
immediates and predicate patterns..
sdesmalen added a child revision: D76680: [SveEmitter] Add immediate checks for 
lanes and complex imms.

This patch adds a number of intrinsics that take immediates with
varying ranges based on the element size one of the operands.

  svext:   immediate ranging 0 to (2048/sizeinbits(elt) - 1)
  svasrd:  immediate ranging 1..sizeinbits(elt)
  svqshlu: immediate ranging 1..sizeinbits(elt)/2
  ftmad:   immediate ranging 0..(sizeinbits(elt) - 1)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76679

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_asrd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_asrd_shortform.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext_shortform.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_tmad.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_tmad_shortform.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_asrd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_ext.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_tmad.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_qshlu.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_qshlu_shortform.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_shrnb.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_shrnb_shortform.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/negative/acle_sve2_qshlu.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/negative/acle_sve2_shrnb.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -471,6 +471,9 @@
 Bitwidth = ElementBitwidth;
 NumVectors = 0;
 break;
+  case 'h':
+ElementBitwidth /= 2;
+break;
   case 'P':
 Signed = true;
 Float = false;
@@ -478,6 +481,11 @@
 Bitwidth = 16;
 ElementBitwidth = 1;
 break;
+  case 'u':
+Predicate = false;
+Signed = false;
+Float = false;
+break;
   case 'i':
 Predicate = false;
 Float = false;
Index: clang/test/CodeGen/aarch64-sve2-intrinsics/negative/acle_sve2_shrnb.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2-intrinsics/negative/acle_sve2_shrnb.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE2 %s
+
+
+#include 
+
+svint8_t test_svshrnb_n_s16(svint16_t op1)
+{
+  return svshrnb_n_s16(op1, 0); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [1, 8]}}
+}
+
+svint8_t test_svshrnb(svint16_t op1)
+{
+  return svshrnb(op1, 0); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [1, 8]}}
+}
+
+svint16_t test_svshrnb_n_s32(svint32_t op1)
+{
+  return svshrnb_n_s32(op1, 0); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+}
+
+svint16_t test_svshrnb_1(svint32_t op1)
+{
+  return svshrnb(op1, 0); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+}
+
+svint32_t test_svshrnb_n_s64(svint64_t op1)
+{
+  return svshrnb_n_s64(op1, 0); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [1, 32]}}
+}
+
+svint32_t test_svshrnb_2(svint64_t op1)
+{
+  return svshrnb(op1, 0); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [1, 32]}}
+}
+
+svuint8_t test_svshrnb_n_u16(svuint16_t op1)
+{
+  return svshrnb_n_u16(op1, 0); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [1, 8]}}
+}
+
+svuint8_t test_svshrnb_3(svuint16_t op1)
+{
+  return svshrnb(op1, 0); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [1, 8]}}
+}
+
+svuint16_t test_svshrnb_n_u32(svuint32_t op1)
+{
+  return svshrnb_n_u32(op1, 0); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+}
+
+svuint16_t test_svshrnb_4(svuint32_t op1)
+{
+  return svshrnb(op1, 0); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [1, 16]}}
+}
+
+svuint32_t test_svshrnb_n_u64(svuint64_t op1)
+{
+  return svshrnb_n_u64(op1, 0); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [1, 32]}}
+}
+
+svuint32_t test_svshrnb_5(svuint64_t op1)
+{
+  return svshrnb(op1, 0); // expected-error-re {{argument value {{[0-9

[PATCH] D75034: [clang-format] use spaces for alignment with UT_ForContinuationAndIndentation

2020-03-24 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I want to believe that it was a mistake on the original developers part, but I 
just can't tell.

A search of github shows people using this in their repos

https://github.com/search?q=ForContinuationAndIndentation&type=Code

I almost feel unless the original author can comment we are at an impasse, 
maybe we have to add:

`ForAllContinuationAndIndentation`

And if at some point in the future we can collapse both options into 1 then 
that would be better, but I just don't feel qualified to say change everyone 
when I don't use that option myself because I don't use tabs.

Whatever you add need to be heavily document that we mean everywhere, and if 
you ever find any cases where its doesn't work we intend for them to be 
changed. i.e. be very explicit in the review/commit comments


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

https://reviews.llvm.org/D75034



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


[PATCH] D76304: [clangd] Update TUStatus api to accommodate preamble thread

2020-03-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 252248.
kadircet marked 14 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76304

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -24,6 +24,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -40,13 +41,14 @@
 using ::testing::Pointee;
 using ::testing::UnorderedElementsAre;
 
-MATCHER_P2(TUState, State, ActionName, "") {
-  if (arg.Action.S != State) {
-*result_listener << "state is " << arg.Action.S;
+MATCHER_P2(TUState, PreambleActivity, ASTActivity, "") {
+  if (arg.PreambleActivity != PreambleActivity) {
+*result_listener << "preamblestate is "
+ << static_cast(arg.PreambleActivity);
 return false;
   }
-  if (arg.Action.Name != ActionName) {
-*result_listener << "name is " << arg.Action.Name;
+  if (arg.ASTActivity.K != ASTActivity) {
+*result_listener << "aststate is " << arg.ASTActivity.K;
 return false;
   }
   return true;
@@ -732,14 +734,13 @@
 
   // Update the source contents, which should trigger an initial build with
   // the header file missing.
-  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
-  [](std::vector Diags) {
-EXPECT_THAT(
-Diags,
-ElementsAre(
-Field(&Diag::Message, "'foo.h' file not found"),
-Field(&Diag::Message, "use of undeclared identifier 'a'")));
-  });
+  updateWithDiags(
+  S, Source, Inputs, WantDiagnostics::Yes, [](std::vector Diags) {
+EXPECT_THAT(Diags,
+ElementsAre(Field(&Diag::Message, "'foo.h' file not found"),
+Field(&Diag::Message,
+  "use of undeclared identifier 'a'")));
+  });
 
   // Add the header file. We need to recreate the inputs since we changed a
   // file from underneath the test FS.
@@ -749,18 +750,17 @@
 
   // The addition of the missing header file shouldn't trigger a rebuild since
   // we don't track missing files.
-  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
-  [](std::vector Diags) {
-ADD_FAILURE() << "Did not expect diagnostics for missing header update";
-  });
+  updateWithDiags(
+  S, Source, Inputs, WantDiagnostics::Yes, [](std::vector Diags) {
+ADD_FAILURE() << "Did not expect diagnostics for missing header update";
+  });
 
   // Forcing the reload should should cause a rebuild which no longer has any
   // errors.
   Inputs.ForceRebuild = true;
-  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
-  [](std::vector Diags) {
-EXPECT_THAT(Diags, IsEmpty());
-  });
+  updateWithDiags(
+  S, Source, Inputs, WantDiagnostics::Yes,
+  [](std::vector Diags) { EXPECT_THAT(Diags, IsEmpty()); });
 
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
 }
@@ -848,14 +848,21 @@
 
   EXPECT_THAT(CaptureTUStatus.allStatus(),
   ElementsAre(
-  // Statuses of "Update" action.
-  TUState(TUAction::RunningAction, "Update (1)"),
-  TUState(TUAction::BuildingPreamble, "Update (1)"),
-  TUState(TUAction::BuildingFile, "Update (1)"),
-
-  // Statuses of "Definitions" action
-  TUState(TUAction::RunningAction, "Definitions"),
-  TUState(TUAction::Idle, /*No action*/ "")));
+  // Everything starts with ASTWorker starting to execute an
+  // update
+  TUState(PreambleAction::Idle, ASTAction::RunningAction),
+  // We build the preamble
+  TUState(PreambleAction::Building, ASTAction::RunningAction),
+  // Preamble worker goes idle
+  TUState(PreambleAction::Idle, ASTAction::RunningAction),
+  // We start building the ast
+  TUState(PreambleAction::Idle, ASTAction::Building),
+  // Built finished succesffully
+  TUState(PreambleAction::Idle, ASTAction::Building),
+  // Rnning go to def
+  TUState(PreambleAction::Idle, ASTAction::RunningAction),
+  // both workers go idle
+  TUState(PreambleAction::Idle, ASTAction::Idle)));
 }
 
 TEST_F(TUSchedulerTests, CommandLineErrors) {
@@ -868,8 +875,7 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Dia

[PATCH] D76304: [clangd] Update TUStatus api to accommodate preamble thread

2020-03-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:277
   build(std::move(*CurrentReq));
+  bool IsEmpty = false;
+  {

sammccall wrote:
> kadircet wrote:
> > sammccall wrote:
> > > Seems clearer to do this immediately before blocking?
> > > 
> > > at the top:
> > > 
> > > ```
> > > if (!NextReq) {
> > >   Lock.unlock();
> > >   StatusManager.setPreambleAction(Idle);
> > >   Lock.lock();
> > >   ReqCV.wait(NextReq || Done);
> > > }
> > > if (Done)
> > >   break;
> > > ```
> > i agree, but I wanted to keep the current semantics. we only start emitting 
> > tustatuses after thread starts executing the first request.
> > 
> > happy to change *both* preamblethread and astworker to emit before blocking 
> > though. wdyt?
> I think the difference is moot - we never create either the AST or preamble 
> worker until there's something to do.
> 
> The code around scheduling/sleeping in the AST worker thread is way more 
> complicated, and I'm not confident moving the status broadcast to the top of 
> the loop would be clearer there.
> 
> Up to you: if you think both are clearer, move both. If you think the 
> preamble is clearer at the top and AST worker at the bottom, then you can 
> choose between consistency and clarity :-)
as discussed offline, this might make tests flaky due to a possible race 
between this thread and the thread issuing the write. so leaving it as it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76304



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


[PATCH] D76680: [SveEmitter] Add immediate checks for lanes and complex imms

2020-03-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: efriedma, SjoerdMeijer, rovka.
Herald added a subscriber: tschuett.
Herald added a project: clang.
sdesmalen added a parent revision: D76679: [SveEmitter] Add more immediate 
operand checks..

Adds another bunch of of intrinsics that take immediates with
varying ranges based, some being a complex rotation immediate
which are a set of allowed immediates rather than a range.

  svmla_lane:   lane immediate ranging 0..(128/(1*sizeinbits(elt)) - 1)
  svcmla_lane:  lane immediate ranging 0..(128/(2*sizeinbits(elt)) - 1)
  svdot_lane:   lane immediate ranging 0..(128/(4*sizeinbits(elt)) - 1)
  svcadd:   complex rotate immediate [90, 270]
  svcmla:
  svcmla_lane:  complex rotate immediate [0, 90, 180, 270]


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76680

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/arm_sve.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cmla_shortform.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dot_shortform.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_mla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_mla_shortform.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_qdech_shortform.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_cmla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_dot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_mla.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -471,9 +471,19 @@
 Bitwidth = ElementBitwidth;
 NumVectors = 0;
 break;
+  case 'e':
+Signed = false;
+ElementBitwidth /= 2;
+break;
   case 'h':
 ElementBitwidth /= 2;
 break;
+  case 'q':
+ElementBitwidth /= 4;
+break;
+  case 'o':
+ElementBitwidth *= 4;
+break;
   case 'P':
 Signed = true;
 Float = false;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_mla.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_mla.c
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify -D__ARM_FEATURE_SVE %s
+
+#include 
+//
+// mla
+//
+
+svfloat16_t test_svmla_lane_f16(svfloat16_t op1, svfloat16_t op2, svfloat16_t op3)
+{
+  return svmla_lane_f16(op1, op2, op3, 8); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [0, 7]}}
+}
+
+svfloat16_t test_svmla_lane(svfloat16_t op1, svfloat16_t op2, svfloat16_t op3)
+{
+  return svmla_lane(op1, op2, op3, -1); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [0, 7]}}
+}
+
+svfloat32_t test_svmla_lane_f32(svfloat32_t op1, svfloat32_t op2, svfloat32_t op3)
+{
+  return svmla_lane_f32(op1, op2, op3, -1); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [0, 3]}}
+}
+
+svfloat32_t test_svmla_lane_1(svfloat32_t op1, svfloat32_t op2, svfloat32_t op3)
+{
+  return svmla_lane(op1, op2, op3, 4); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [0, 3]}}
+}
+
+svfloat64_t test_svmla_lane_f64(svfloat64_t op1, svfloat64_t op2, svfloat64_t op3)
+{
+  return svmla_lane_f64(op1, op2, op3, 2); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [0, 1]}}
+}
+
+svfloat64_t test_svmla_lane_2(svfloat64_t op1, svfloat64_t op2, svfloat64_t op3)
+{
+  return svmla_lane(op1, op2, op3, -1); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [0, 1]}}
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_dot.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/negative/acle_sve_dot.c
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify -D__ARM_FEATURE_SVE %s
+
+#include 
+//
+// dot
+//
+
+svint32_t test_svdot_lane_s32(svint32_t op1, svint8_t op2, svint8_t op3)
+{
+  return svdot_lane_s32(op1, op2, op3, -1); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [0, 3]}}
+}
+
+svint32_t test_svdot_lane_s32_2(svint32_t op1, svint8_t op2, svint8_t op3)
+{
+  return svdot_lane_s32(op1, op2, op3, 4); // expected-error-re {{argument value {{[0-9]+}} is outside the valid range [0, 3]}}
+}
+
+svint64_t test_svdot_lane_s64(svint64_t op1, svint16_t op2, svint16_t op3)
+{
+  return svdot_lane_s64(op1, op2, op3, -1); // expected-error-re {{argument value {{[0-9]+}} is ou

[PATCH] D76595: [clangd-vscode] NFC; Improve wording in documentation and update VSCode tasks

2020-03-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

In D76595#1936408 , @hokein wrote:

> thanks. regarding files in `.vscode`, I think they are just local configs in 
> VSCode, we can probably remove the whole directory from git since we already 
> ignore them in the `llvm/.gitignore`.


I think those are hand-written VSCode tasks and removing those would result in 
the absence of compiling and debugging actions in VSCode. `llvm/.gitignore` is 
intended to ignore the configs, but I'm not sure it is a "config file" in 
traditional sensee. Am I missing something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76595



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


[PATCH] D76592: [Parser] Fix the assertion crash in ActOnStartOfSwitch stmt.

2020-03-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clang/lib/Sema/SemaStmt.cpp:709
   } SwitchDiagnoser(Cond);
+  // The TypoExpr might be corrected to a non-intergral-or-enum type in the
+  // later stage without the proper type check, which is invalid for switch

sammccall wrote:
> How do we know Cond is a TypoExpr directly rather than containing one?
> 
> I think the usual strategy when code can't deal with typo correction being 
> delayed further is to call CorrectDelayedTyposInExpr.
no sure whether we should consider the containing-typo Cond, we might still 
want to keep the typo correction? thinking a case like 
`switch(return_int(typo-expr)) {}`.

Do you suggest that we use the `CorrectDelayedTyposInExpr` to check the whether 
Cond is/has a TypoExpr? `CorrectDelayedTyposInExpr` has a side effect of 
emitting the typo-suggestion diagnostic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76592



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


[PATCH] D76605: [analyzer] Display the checker name in the text output

2020-03-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked 3 inline comments as done.
Szelethus added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def:313-316
+ANALYZER_OPTION(bool, ShouldDisplayCheckerNameForText, "display-checker-name",
+"Display the checker name for textual outputs",
+true)
+

NoQ wrote:
> Why do we need an option? Is it just for tests? Is it for clang-tidy to avoid 
> printing the checker name twice?
> 
> Why do we need an option?

Well, we don't, but there is just no reason not to make this configurable, as 
seen in the debug checker test file. It would be unnecessary noise in their 
case.

> Is it just for tests?

Tests are a big motivating factor, but it just doesn't hurt to know (just like 
in clang-tidy!). I suspect this change affects developers or powerusers more 
than any others, and could accelerate debugging and/or configuring just a tiny 
bit more.

> Is it for clang-tidy to avoid printing the checker name twice?

Clang-tidy isnt affected, as they use the PD_NONE output type, not PD_TEXT.



Comment at: clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp:112
 reportPiece(NoteID, Piece->getLocation().asLocation(),
-Piece->getString(), Piece->getRanges(), 
Piece->getFixits());
+Piece->getString().str(), Piece->getRanges(),
+Piece->getFixits());

NoQ wrote:
> Szelethus wrote:
> > martong wrote:
> > > Why the `.str()` ?
> > `StringRef` no longer converts to `std::string` implicitly.
> But it seems to have been fine before(?)
Mind that I changed the parameter of `reportPiece` to `std::string` from 
`StringRef`.



Comment at: clang/test/Analysis/incorrect-checker-names.cpp:6
+  int x = 0;
+  // FIXME: This shouldn't be tied to a modeling checker.
+  return &x; // expected-warning{{Address of stack memory associated with 
local variable 'x' returned to caller [core.StackAddrEscapeBase]}}

NoQ wrote:
> Do you have a plan to address this FIXME? Does clang-tidy have the same 
> problem?
It does not. This is the issue of emitting reports under the wrong name, and I 
do have plans to address it, though I'm very anxious about 
`RetainCountChecker`. Its huge, the modeling/bug emission parts of it a very 
much intertwined, and me dum dum about ObjC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76605



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


[PATCH] D76513: [ReleaseNotes,ARM] MVE intrinsics are all implemented!

2020-03-24 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 252252.
simon_tatham added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Added an entry to the Clang release notes as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76513

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -72,6 +72,9 @@
 
 During this release ...
 
+* Implemented C-language intrinsics for the full Arm v8.1-M MVE instruction
+  set.  now supports the complete API defined in the Arm C
+  Language Extensions.
 
 Changes to the MIPS Target
 --
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -57,6 +57,10 @@
 Non-comprehensive list of changes in this release
 -
 
+- For the ARM target, C-language intrinsics are now provided for the full Arm
+  v8.1-M MVE instruction set.  supports the complete API defined
+  in the Arm C Language Extensions.
+
 
 New Compiler Flags
 --


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -72,6 +72,9 @@
 
 During this release ...
 
+* Implemented C-language intrinsics for the full Arm v8.1-M MVE instruction
+  set.  now supports the complete API defined in the Arm C
+  Language Extensions.
 
 Changes to the MIPS Target
 --
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -57,6 +57,10 @@
 Non-comprehensive list of changes in this release
 -
 
+- For the ARM target, C-language intrinsics are now provided for the full Arm
+  v8.1-M MVE instruction set.  supports the complete API defined
+  in the Arm C Language Extensions.
+
 
 New Compiler Flags
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76617: [SveEmitter] Fix encoding/decoding of SVETypeFlags

2020-03-24 Thread Andrzej Warzynski via Phabricator via cfe-commits
andwar added a comment.

Cheers for the fix @sdesmalen !




Comment at: clang/include/clang/Basic/TargetBuiltins.h:187
 
-SVETypeFlags(uint64_t F) : Flags(F) {}
-SVETypeFlags(EltType ET, bool IsUnsigned) : Flags(ET) {}
+SVETypeFlags(uint64_t F) : Flags(F), EltTypeShift(0), MemEltTypeShift(0) {
+  EltTypeShift = llvm::countTrailingZeros(EltTypeMask);

`EltTypeShift` and `MemEltTypeShift` are initialised twice in one constructor.

If removing them from the member initialisation list throws a warning, perhaps 
you could use in-class initialisers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76617



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


[clang] 080d046 - [ARM][CMSE] Implement CMSE attributes

2020-03-24 Thread Momchil Velikov via cfe-commits

Author: Momchil Velikov
Date: 2020-03-24T10:21:26Z
New Revision: 080d046c91d26bd3b0afba817cf5c2f99d1288ff

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

LOG: [ARM][CMSE] Implement CMSE attributes

This patch adds CMSE attributes `cmse_nonsecure_call` and
`cmse_nonsecure_entry`.  As usual, specification is available here:
https://developer.arm.com/docs/ecm0359818/latest

Patch by Javed Absar, Bradley Smith, David Green, Momchil Velikov,
possibly others.

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

Added: 
clang/test/CodeGen/arm-cmse-attr.c
clang/test/CodeGen/arm-cmse-call.c
clang/test/Sema/arm-cmse.c
clang/test/Sema/arm-no-cmse.c
clang/test/SemaCXX/arm-cmse.cpp

Modified: 
clang/include/clang/AST/Type.h
clang/include/clang/AST/TypeProperties.td
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/CodeGen/CGFunctionInfo.h
clang/lib/AST/TypePrinter.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/AST/ast-dump-arm-attr.c
clang/test/Driver/ropi-rwpi.c
clang/test/Driver/save-temps.c
clang/test/Misc/pragma-attribute-supported-attributes-list.test

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 05c6167dcbb2..16db1d5cbc3a 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1546,7 +1546,7 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
 
 /// Extra information which affects how the function is called, like
 /// regparm and the calling convention.
-unsigned ExtInfo : 12;
+unsigned ExtInfo : 13;
 
 /// The ref-qualifier associated with a \c FunctionProtoType.
 ///
@@ -3568,12 +3568,12 @@ class FunctionType : public Type {
   class ExtInfo {
 friend class FunctionType;
 
-// Feel free to rearrange or add bits, but if you go over 12,
-// you'll need to adjust both the Bits field below and
-// Type::FunctionTypeBitfields.
+// Feel free to rearrange or add bits, but if you go over 16, you'll need 
to
+// adjust the Bits field below, and if you add bits, you'll need to adjust
+// Type::FunctionTypeBitfields::ExtInfo as well.
 
-//   |  CC  |noreturn|produces|nocallersavedregs|regparm|nocfcheck|
-//   |0 .. 4|   5|6   |   7 |8 .. 10|11   |
+// |  CC  
|noreturn|produces|nocallersavedregs|regparm|nocfcheck|cmsenscall|
+// |0 .. 4|   5|6   |   7 |8 .. 10|11   |12
|
 //
 // regparm is either 0 (no regparm attribute) or the regparm value+1.
 enum { CallConvMask = 0x1F };
@@ -3581,26 +3581,29 @@ class FunctionType : public Type {
 enum { ProducesResultMask = 0x40 };
 enum { NoCallerSavedRegsMask = 0x80 };
 enum { NoCfCheckMask = 0x800 };
+enum { CmseNSCallMask = 0x1000 };
 enum {
   RegParmMask = ~(CallConvMask | NoReturnMask | ProducesResultMask |
-  NoCallerSavedRegsMask | NoCfCheckMask),
+  NoCallerSavedRegsMask | NoCfCheckMask | CmseNSCallMask),
   RegParmOffset = 8
 }; // Assumed to be the last field
 uint16_t Bits = CC_C;
 
 ExtInfo(unsigned Bits) : Bits(static_cast(Bits)) {}
 
-   public:
- // Constructor with no defaults. Use this when you know that you
- // have all the elements (when reading an AST file for example).
- ExtInfo(bool noReturn, bool hasRegParm, unsigned regParm, CallingConv cc,
- bool producesResult, bool noCallerSavedRegs, bool NoCfCheck) {
-   assert((!hasRegParm || regParm < 7) && "Invalid regparm value");
-   Bits = ((unsigned)cc) | (noReturn ? NoReturnMask : 0) |
-  (producesResult ? ProducesResultMask : 0) |
-  (noCallerSavedRegs ? NoCallerSavedRegsMask : 0) |
-  (hasRegParm ? ((regParm + 1) << RegParmOffset) : 0) |
-  (NoCfCheck ? NoCfCheckMask : 0);
+  public:
+// Constructor with no defaults. Use this when you know that you
+// have all the elements (when reading an AST file for example).
+ExtInfo(bool noReturn, bool hasRegParm, unsigned regParm, CallingConv cc,
+bool producesResult, bool noCallerSavedRegs, bool NoCfCheck,
+bool cmseNSCall) {
+  assert((!hasRegParm || regParm < 7) && "Invalid regparm value");
+  Bits = ((unsigned)cc) | (noReturn ? NoReturnMask : 0) |
+ (producesResult ? ProducesResultMask : 0

[PATCH] D76617: [SveEmitter] Fix encoding/decoding of SVETypeFlags

2020-03-24 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

Patches with functional changes but without tests are a bit "suspicious".  In 
this case, I see it might be tricky. You could argue that it should be 
incorporated in the patch that includes the tests, so we can see what's 
happening. But perhaps separating this out is cleaner, if the other patch is 
big. But can you at least make the next patch dependent on this one, so we know 
where this is used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76617



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


[PATCH] D71129: [ARM][CMSE] Implement CMSE attributes

2020-03-24 Thread Momchil Velikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG080d046c91d2: [ARM][CMSE] Implement CMSE attributes 
(authored by chill).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71129

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/AST/ast-dump-arm-attr.c
  clang/test/CodeGen/arm-cmse-attr.c
  clang/test/CodeGen/arm-cmse-call.c
  clang/test/Driver/ropi-rwpi.c
  clang/test/Driver/save-temps.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/arm-cmse.c
  clang/test/Sema/arm-no-cmse.c
  clang/test/SemaCXX/arm-cmse.cpp

Index: clang/test/SemaCXX/arm-cmse.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/arm-cmse.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple thumbv8m.base-none-eabi -mcmse -verify %s
+
+extern "C" void foo() __attribute__((cmse_nonsecure_entry)) {}
+
+void bar() __attribute__((cmse_nonsecure_entry)) {} // expected-error{{function type with 'cmse_nonsecure_entry' attribute must have C linkage}}
Index: clang/test/Sema/arm-no-cmse.c
===
--- /dev/null
+++ clang/test/Sema/arm-no-cmse.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple thumbv8m.base-none-eabi -verify %s
+
+typedef void (*callback_ns_1t)()
+  __attribute__((cmse_nonsecure_call)); // expected-warning{{'cmse_nonsecure_call' attribute ignored}}
+
+void f()
+  __attribute__((cmse_nonsecure_entry)) {} // expected-warning{{'cmse_nonsecure_entry' attribute ignored}}
Index: clang/test/Sema/arm-cmse.c
===
--- /dev/null
+++ clang/test/Sema/arm-cmse.c
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -triple thumbv8m.base-none-eabi -mcmse -verify %s
+
+typedef void (*callback_ns_1t)() __attribute__((cmse_nonsecure_call));
+typedef void (*callback_1t)();
+typedef void (*callback_ns_2t)() __attribute__((cmse_nonsecure_call));
+typedef void (*callback_2t)();
+
+void foo(callback_ns_1t nsfptr, // expected-error{{functions may not be declared with 'cmse_nonsecure_call' attribute}}
+ callback_1t fptr) __attribute__((cmse_nonsecure_call))
+{
+  callback_1t fp1 = nsfptr; // expected-warning{{incompatible function pointer types initializing 'callback_1t'}}
+  callback_ns_1t fp2 = fptr; // expected-warning{{incompatible function pointer types initializing 'callback_ns_1t'}}
+  callback_2t fp3 = fptr;
+  callback_ns_2t fp4 = nsfptr;
+}
+
+static void bar() __attribute__((cmse_nonsecure_entry)) // expected-warning{{'cmse_nonsecure_entry' cannot be applied to functions with internal linkage}}
+{
+}
+
+typedef void nonsecure_fn_t(int) __attribute__((cmse_nonsecure_call));
+extern nonsecure_fn_t baz; // expected-error{{functions may not be declared with 'cmse_nonsecure_call' attribute}}
+
+int v0 __attribute__((cmse_nonsecure_call)); // expected-warning {{'cmse_nonsecure_call' only applies to function types; type here is 'int'}}
+int v1 __attribute__((cmse_nonsecure_entry)); // expected-warning {{'cmse_nonsecure_entry' attribute only applies to functions}}
+
+void fn0() __attribute__((cmse_nonsecure_entry));
+void fn1() __attribute__((cmse_nonsecure_entry(1)));  // expected-error {{'cmse_nonsecure_entry' attribute takes no arguments}}
+
+typedef void (*fn2_t)() __attribute__((cmse_nonsecure_call("abc"))); // expected-error {{'cmse_nonsecure_call' attribute takes no argument}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -39,6 +39,7 @@
 // CHECK-NEXT: Callback (SubjectMatchRule_function)
 // CHECK-NEXT: Capability (SubjectMatchRule_record, SubjectMatchRule_type_alias)
 // CHECK-NEXT: CarriesDependency (SubjectMatchRule_variable_is_parameter, SubjectMatchRule_objc_method, SubjectMatchRule_function)
+// CHECK-NEXT: CmseNSEntry (SubjectMatchRule_function)
 // CHECK-NEXT: Cold (SubjectMatchRule_function)
 // CHECK-NEXT: Common (SubjectMatchRule_variable)
 // CHECK-NEXT: ConstInit (SubjectMatchRule_variable_is_global)
Index: clang/test/Driver/save-temps.c
=

[PATCH] D76622: [analyzer] ConstraintManager - use EXPENSIVE_CHECKS instead of (gcc specific) __OPTIMIZE__ guard

2020-03-24 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In D76622#1938009 , @NoQ wrote:

> Sounds good but eventually i hope we re-enable this assert in release+assert 
> builds (D57062 ).


SGTM as long as you don't reintroduce a compiler specific guard


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76622



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


[PATCH] D76513: [ReleaseNotes,ARM] MVE intrinsics are all implemented!

2020-03-24 Thread Kristof Beyls via Phabricator via cfe-commits
kristof.beyls accepted this revision.
kristof.beyls added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76513



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


[clang-tools-extra] b194e7d - [clangd] Change line break behaviour for hoverinfo

2020-03-24 Thread Sam McCall via cfe-commits

Author: Lorenz Junglas
Date: 2020-03-24T12:41:08+01:00
New Revision: b194e7d6313be3b6e6db6e2d617a76c6dde2651b

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

LOG: [clangd] Change line break behaviour for hoverinfo

`parseDocumentation` retains hard line breaks and removes soft line
breaks inside documentation comments.
Wether a line break is hard or soft is determined by the following rules
(some of which have been discussed in
https://github.com/clangd/clangd/issues/95):

Line breaks that are preceded by a punctuation are retained
Line breaks that are followed by "interesting characters" (e.g. Markdown
syntax, doxygen commands) are retained
All other line breaks are removed

Related issue: https://github.com/clangd/clangd/issues/95

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

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/Hover.h
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 5c1288c14b58..1d41f0a3e046 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -520,6 +520,49 @@ llvm::Optional getHoverContents(const Expr *E, 
ParsedAST &AST) {
   }
   return llvm::None;
 }
+
+bool isParagraphLineBreak(llvm::StringRef Str, size_t LineBreakIndex) {
+  return Str.substr(LineBreakIndex + 1)
+  .drop_while([](auto C) { return C == ' ' || C == '\t'; })
+  .startswith("\n");
+};
+
+bool isPunctuationLineBreak(llvm::StringRef Str, size_t LineBreakIndex) {
+  constexpr llvm::StringLiteral Punctuation = R"txt(.:,;!?)txt";
+
+  return LineBreakIndex > 0 && Punctuation.contains(Str[LineBreakIndex - 1]);
+};
+
+bool isFollowedByHardLineBreakIndicator(llvm::StringRef Str,
+size_t LineBreakIndex) {
+  // '-'/'*' md list, '@'/'\' documentation command, '>' md blockquote,
+  // '#' headings, '`' code blocks
+  constexpr llvm::StringLiteral LinbreakIdenticators = R"txt(-*@\>#`)txt";
+
+  auto NextNonSpaceCharIndex = Str.find_first_not_of(' ', LineBreakIndex + 1);
+
+  if (NextNonSpaceCharIndex == llvm::StringRef::npos) {
+return false;
+  }
+
+  auto FollowedBySingleCharIndicator =
+  LinbreakIdenticators.find(Str[NextNonSpaceCharIndex]) !=
+  llvm::StringRef::npos;
+
+  auto FollowedByNumberedListIndicator =
+  llvm::isDigit(Str[NextNonSpaceCharIndex]) &&
+  NextNonSpaceCharIndex + 1 < Str.size() &&
+  (Str[NextNonSpaceCharIndex + 1] == '.' ||
+   Str[NextNonSpaceCharIndex + 1] == ')');
+
+  return FollowedBySingleCharIndicator || FollowedByNumberedListIndicator;
+};
+
+bool isHardLineBreak(llvm::StringRef Str, size_t LineBreakIndex) {
+  return isPunctuationLineBreak(Str, LineBreakIndex) ||
+ isFollowedByHardLineBreakIndicator(Str, LineBreakIndex);
+}
+
 } // namespace
 
 llvm::Optional getHover(ParsedAST &AST, Position Pos,
@@ -652,7 +695,7 @@ markup::Document HoverInfo::present() const {
   }
 
   if (!Documentation.empty())
-Output.addParagraph().appendText(Documentation);
+parseDocumentation(Documentation, Output);
 
   if (!Definition.empty()) {
 Output.addRuler();
@@ -675,6 +718,45 @@ markup::Document HoverInfo::present() const {
   return Output;
 }
 
+void parseDocumentation(llvm::StringRef Input, markup::Document &Output) {
+
+  constexpr auto WhiteSpaceChars = "\t\n\v\f\r ";
+
+  auto TrimmedInput = Input.trim();
+
+  std::string CurrentLine;
+
+  for (size_t CharIndex = 0; CharIndex < TrimmedInput.size();) {
+if (TrimmedInput[CharIndex] == '\n') {
+  // Trim whitespace infront of linebreak
+  const auto LastNonSpaceCharIndex =
+  CurrentLine.find_last_not_of(WhiteSpaceChars) + 1;
+  CurrentLine.erase(LastNonSpaceCharIndex);
+
+  if (isParagraphLineBreak(TrimmedInput, CharIndex) ||
+  isHardLineBreak(TrimmedInput, CharIndex)) {
+// FIXME: maybe distinguish between line breaks and paragraphs
+Output.addParagraph().appendText(CurrentLine);
+CurrentLine = "";
+  } else {
+// Ommit linebreak
+CurrentLine += ' ';
+  }
+
+  CharIndex++;
+  // After a linebreak always remove spaces to avoid 4 space markdown code
+  // blocks, also skip all additional linebreaks since they have no effect
+  CharIndex = TrimmedInput.find_first_not_of(WhiteSpaceChars, CharIndex);
+} else {
+  CurrentLine += TrimmedInput[CharIndex];
+  CharIndex++;
+}
+  }
+  if (!CurrentLine.empty()) {
+Output.addParagraph().appendText(CurrentLine);
+  }
+}
+
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
   const HoverInfo::Param &P) {
   std::vector Output;

diff  --git a/clang-tool

[clang] f282b6a - [ReleaseNotes, ARM] MVE intrinsics are all implemented!

2020-03-24 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-03-24T11:42:25Z
New Revision: f282b6ab23a0f6ede0f1c8b6ccb5ad3c17a5ed2f

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

LOG: [ReleaseNotes,ARM] MVE intrinsics are all implemented!

Summary:
The next release of LLVM will support the full ACLE spec for MVE intrinsics,
so it's worth saying so in the release notes.

Reviewers: kristof.beyls

Reviewed By: kristof.beyls

Subscribers: cfe-commits, hans, dmgreen, llvm-commits

Tags: #llvm, #clang

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9f20c271b50e..ad13fb1b3e95 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -57,6 +57,10 @@ Improvements to Clang's diagnostics
 Non-comprehensive list of changes in this release
 -
 
+- For the ARM target, C-language intrinsics are now provided for the full Arm
+  v8.1-M MVE instruction set.  supports the complete API defined
+  in the Arm C Language Extensions.
+
 
 New Compiler Flags
 --

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index bbfcc6076c01..4f6e759bbeb3 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -72,6 +72,9 @@ Changes to the ARM Backend
 
 During this release ...
 
+* Implemented C-language intrinsics for the full Arm v8.1-M MVE instruction
+  set.  now supports the complete API defined in the Arm C
+  Language Extensions.
 
 Changes to the MIPS Target
 --



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


[clang] 8fa322d - Increase DIAG_SIZE_DRIVER as we're close to hitting it

2020-03-24 Thread Russell Gallop via cfe-commits

Author: Russell Gallop
Date: 2020-03-24T11:45:53Z
New Revision: 8fa322dd39a8ac32c46479511e8be20ab898f897

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

LOG: Increase DIAG_SIZE_DRIVER as we're close to hitting it

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticIDs.h

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticIDs.h 
b/clang/include/clang/Basic/DiagnosticIDs.h
index 5b9391b5a452..46f0fa423a39 100644
--- a/clang/include/clang/Basic/DiagnosticIDs.h
+++ b/clang/include/clang/Basic/DiagnosticIDs.h
@@ -28,7 +28,7 @@ namespace clang {
 // Size of each of the diagnostic categories.
 enum {
   DIAG_SIZE_COMMON=  300,
-  DIAG_SIZE_DRIVER=  200,
+  DIAG_SIZE_DRIVER=  250,
   DIAG_SIZE_FRONTEND  =  150,
   DIAG_SIZE_SERIALIZATION =  120,
   DIAG_SIZE_LEX   =  400,



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


[PATCH] D76605: [analyzer] Display the checker name in the text output

2020-03-24 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def:313-316
+ANALYZER_OPTION(bool, ShouldDisplayCheckerNameForText, "display-checker-name",
+"Display the checker name for textual outputs",
+true)
+

Szelethus wrote:
> NoQ wrote:
> > Why do we need an option? Is it just for tests? Is it for clang-tidy to 
> > avoid printing the checker name twice?
> > 
> > Why do we need an option?
> 
> Well, we don't, but there is just no reason not to make this configurable, as 
> seen in the debug checker test file. It would be unnecessary noise in their 
> case.
> 
> > Is it just for tests?
> 
> Tests are a big motivating factor, but it just doesn't hurt to know (just 
> like in clang-tidy!). I suspect this change affects developers or powerusers 
> more than any others, and could accelerate debugging and/or configuring just 
> a tiny bit more.
> 
> > Is it for clang-tidy to avoid printing the checker name twice?
> 
> Clang-tidy isnt affected, as they use the PD_NONE output type, not PD_TEXT.
> Clang-tidy isnt affected, as they use the PD_NONE output type, not PD_TEXT.

But they do have path notes printed out. It would have been terrible if they 
didn't have path notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76605



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


[PATCH] D76513: [ReleaseNotes,ARM] MVE intrinsics are all implemented!

2020-03-24 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf282b6ab23a0: [ReleaseNotes,ARM] MVE intrinsics are all 
implemented! (authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76513

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -72,6 +72,9 @@
 
 During this release ...
 
+* Implemented C-language intrinsics for the full Arm v8.1-M MVE instruction
+  set.  now supports the complete API defined in the Arm C
+  Language Extensions.
 
 Changes to the MIPS Target
 --
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -57,6 +57,10 @@
 Non-comprehensive list of changes in this release
 -
 
+- For the ARM target, C-language intrinsics are now provided for the full Arm
+  v8.1-M MVE instruction set.  supports the complete API defined
+  in the Arm C Language Extensions.
+
 
 New Compiler Flags
 --


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -72,6 +72,9 @@
 
 During this release ...
 
+* Implemented C-language intrinsics for the full Arm v8.1-M MVE instruction
+  set.  now supports the complete API defined in the Arm C
+  Language Extensions.
 
 Changes to the MIPS Target
 --
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -57,6 +57,10 @@
 Non-comprehensive list of changes in this release
 -
 
+- For the ARM target, C-language intrinsics are now provided for the full Arm
+  v8.1-M MVE instruction set.  supports the complete API defined
+  in the Arm C Language Extensions.
+
 
 New Compiler Flags
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76094: [clangd] Change line break behaviour for hoverinfo

2020-03-24 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb194e7d6313b: [clangd] Change line break behaviour for 
hoverinfo (authored by lolleko, committed by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D76094?vs=252159&id=252269#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76094

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1883,6 +1883,71 @@
   }
 }
 
+TEST(Hover, DocCommentLineBreakConversion) {
+  struct Case {
+llvm::StringRef Documentation;
+llvm::StringRef ExpectedRenderMarkdown;
+llvm::StringRef ExpectedRenderPlainText;
+  } Cases[] = {{
+   " \n foo\nbar",
+   "foo bar",
+   "foo bar",
+   },
+   {
+   "foo\nbar \n  ",
+   "foo bar",
+   "foo bar",
+   },
+   {
+   "foo  \nbar",
+   "foo bar",
+   "foo bar",
+   },
+   {
+   "foo\nbar",
+   "foo bar",
+   "foo bar",
+   },
+   {
+   "foo\n\n\nbar",
+   "foo  \nbar",
+   "foo\nbar",
+   },
+   {
+   "foo\n\n\n\tbar",
+   "foo  \nbar",
+   "foo\nbar",
+   },
+   {
+   "foo\n\n\n bar",
+   "foo  \nbar",
+   "foo\nbar",
+   },
+   {
+   "foo.\nbar",
+   "foo.  \nbar",
+   "foo.\nbar",
+   },
+   {
+   "foo\n*bar",
+   "foo  \n\\*bar",
+   "foo\n*bar",
+   },
+   {
+   "foo\nbar",
+   "foo bar",
+   "foo bar",
+   }};
+
+  for (const auto &C : Cases) {
+markup::Document Output;
+parseDocumentation(C.Documentation, Output);
+
+EXPECT_EQ(Output.asMarkdown(), C.ExpectedRenderMarkdown);
+EXPECT_EQ(Output.asPlainText(), C.ExpectedRenderPlainText);
+  }
+}
+
 // This is a separate test as headings don't create any differences in plaintext
 // mode.
 TEST(Hover, PresentHeadings) {
Index: clang-tools-extra/clangd/Hover.h
===
--- clang-tools-extra/clangd/Hover.h
+++ clang-tools-extra/clangd/Hover.h
@@ -74,6 +74,10 @@
   /// Produce a user-readable information.
   markup::Document present() const;
 };
+
+// Try to infer structure of a documentation comment (e.g. line breaks).
+void parseDocumentation(llvm::StringRef Input, markup::Document &Output);
+
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const HoverInfo::Param &);
 inline bool operator==(const HoverInfo::Param &LHS,
const HoverInfo::Param &RHS) {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -520,6 +520,49 @@
   }
   return llvm::None;
 }
+
+bool isParagraphLineBreak(llvm::StringRef Str, size_t LineBreakIndex) {
+  return Str.substr(LineBreakIndex + 1)
+  .drop_while([](auto C) { return C == ' ' || C == '\t'; })
+  .startswith("\n");
+};
+
+bool isPunctuationLineBreak(llvm::StringRef Str, size_t LineBreakIndex) {
+  constexpr llvm::StringLiteral Punctuation = R"txt(.:,;!?)txt";
+
+  return LineBreakIndex > 0 && Punctuation.contains(Str[LineBreakIndex - 1]);
+};
+
+bool isFollowedByHardLineBreakIndicator(llvm::StringRef Str,
+size_t LineBreakIndex) {
+  // '-'/'*' md list, '@'/'\' documentation command, '>' md blockquote,
+  // '#' headings, '`' code blocks
+  constexpr llvm::StringLiteral LinbreakIdenticators = R"txt(-*@\>#`)txt";
+
+  auto NextNonSpaceCharIndex = Str.find_first_not_of(' ', LineBreakIndex + 1);
+
+  if (NextNonSpaceCharIndex == llvm::StringRef::npos) {
+return false;
+  }
+
+  auto FollowedBySingleCharIndicator =
+  LinbreakIdenticators.find(Str[NextNonSpaceCharIndex]) !=
+  llvm::StringRef::npos;
+
+  auto FollowedByNumberedListIndicator =
+  llvm::isDigit(Str[NextNonSpaceCharIndex]) &&
+  NextNonSpaceCharIndex + 1 < Str.size() &&
+  (Str[NextNonSpaceCharIndex + 1] == '.' ||
+   Str[NextNonSpaceCharIndex + 1] == ')');
+
+  return FollowedBySingleCharIndicator || FollowedByNumberedListIndic

[PATCH] D76688: [AArch64][SVE] Add SVE intrinsics for masked loads & stores

2020-03-24 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, andwar, efriedma, cameron.mcinally, 
dancgr.
Herald added subscribers: danielkiss, psnobl, rkruppe, hiraditya, 
kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: LLVM.

Implements the following intrinsics for contiguous loads & stores:

- @llvm.aarch64.sve.ld1
- @llvm.aarch64.sve.st1


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76688

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/sve-intrinsics-ldst1.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-ldst1.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-ldst1.ll
@@ -0,0 +1,182 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; LD1B
+;
+
+define  @ld1b_i8( %pred, i8* %addr) {
+; CHECK-LABEL: ld1b_i8:
+; CHECK: ld1b { z0.b }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv16i8( %pred,
+   i8* %addr)
+  ret  %res
+}
+
+;
+; LD1H
+;
+
+define  @ld1h_i16( %pred, i16* %addr) {
+; CHECK-LABEL: ld1h_i16:
+; CHECK: ld1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv8i16( %pred,
+   i16* %addr)
+  ret  %res
+}
+
+define  @ld1h_f16( %pred, half* %addr) {
+; CHECK-LABEL: ld1h_f16:
+; CHECK: ld1h { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv8f16( %pred,
+half* %addr)
+  ret  %res
+}
+
+;
+; LD1W
+;
+
+define  @ld1w_i32( %pred, i32* %addr) {
+; CHECK-LABEL: ld1w_i32:
+; CHECK: ld1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv4i32( %pred,
+   i32* %addr)
+  ret  %res
+}
+
+define  @ld1w_f32( %pred, float* %addr) {
+; CHECK-LABEL: ld1w_f32:
+; CHECK: ld1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv4f32( %pred,
+ float* %addr)
+  ret  %res
+}
+
+;
+; LD1D
+;
+
+define  @ld1d_i64( %pred, i64* %addr) {
+; CHECK-LABEL: ld1d_i64:
+; CHECK: ld1d { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv2i64( %pred,
+   i64* %addr)
+  ret  %res
+}
+
+define  @ld1d_f64( %pred, double* %addr) {
+; CHECK-LABEL: ld1d_f64:
+; CHECK: ld1d { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1.nxv2f64( %pred,
+  double* %addr)
+  ret  %res
+}
+
+;
+; ST1B
+;
+
+define void @st1b_i8( %data,  %pred, i8* %addr) {
+; CHECK-LABEL: st1b_i8:
+; CHECK: st1b { z0.b }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv16i8( %data,
+   %pred,
+  i8* %addr)
+  ret void
+}
+
+;
+; ST1H
+;
+
+define void @st1h_i16( %data,  %pred, i16* %addr) {
+; CHECK-LABEL: st1h_i16:
+; CHECK: st1h { z0.h }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv8i16( %data,
+   %pred,
+  i16* %addr)
+  ret void
+}
+
+define void @st1h_f16( %data,  %pred, half* %addr) {
+; CHECK-LABEL: st1h_f16:
+; CHECK: st1h { z0.h }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv8f16( %data,
+   %pred,
+  half* %addr)
+  ret void
+}
+
+;
+; ST1W
+;
+
+define void @st1w_i32( %data,  %pred, i32* %addr) {
+; CHECK-LABEL: st1w_i32:
+; CHECK: st1w { z0.s }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv4i32( %data,
+   %pred,
+  i32* %addr)
+  ret void
+}
+
+define void @st1w_f32( %data,  %pred, float* %addr) {
+; CHECK-LABEL: st1w_f32:
+; CHECK: st1w { z0.s }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv4f32( %data,
+   %pred,
+  float* %addr)
+  ret void
+}
+
+;
+; ST1D
+;
+
+define void @st1d_i64( %data,  %pred, i64* %addr) {
+; CHECK-LABEL: st1d_i64:
+; CHECK: st1d { z0.d }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv2i64( %data,
+   %pred,
+  i64* %addr)
+  ret void
+}
+
+define void @st1d_f64( %data,  %pred, double* %addr) {
+; CHECK-LABEL: st1d_f64:
+; CHECK: st1d { z0.d }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv2f64( %data,
+

[clang] 896fa30 - Fix unused variable warning

2020-03-24 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-03-24T11:51:49Z
New Revision: 896fa30fc03091f7ea679f38616cae05166fb4be

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

LOG: Fix unused variable warning

Added: 


Modified: 
clang/lib/Tooling/Syntax/BuildTree.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Syntax/BuildTree.cpp 
b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 4103a4d92c7d..82c87ba02b74 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -1059,7 +1059,7 @@ void syntax::TreeBuilder::markStmtChild(Stmt *Child, 
NodeRole Role) {
 
   // This is an expression in a statement position, consume the trailing
   // semicolon and form an 'ExpressionStatement' node.
-  if (auto *E = dyn_cast(Child)) {
+  if (isa(Child)) {
 setRole(ChildNode, NodeRole::ExpressionStatement_expression);
 ChildNode = new (allocator()) syntax::ExpressionStatement;
 // (!) 'getStmtRange()' ensures this covers a trailing semicolon.



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


Re: [PATCH] D71129: [ARM][CMSE] Implement CMSE attributes

2020-03-24 Thread Russell Gallop via cfe-commits
Hi Momchil,

Can I just check that you've seen this bot failure here since this patch:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/64604/steps/test-check-all/logs/FAIL%3A%20Clang%3A%3Asave-temps.c


The new case that you've added to save-temps.c doesn't work if you only
build with -DLLVM_TARGETS_TO_BUILD=X86 (i.e. not building ARM).
Please could you take a look?

Thanks
Russ

On Tue, 24 Mar 2020 at 10:45, Momchil Velikov via Phabricator via
cfe-commits  wrote:

> This revision was automatically updated to reflect the committed changes.
> Closed by commit rG080d046c91d2: [ARM][CMSE] Implement CMSE attributes
> (authored by chill).
> Herald added a project: clang.
> Herald added a subscriber: cfe-commits.
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D71129/new/
>
> https://reviews.llvm.org/D71129
>
> Files:
>   clang/include/clang/AST/Type.h
>   clang/include/clang/AST/TypeProperties.td
>   clang/include/clang/Basic/Attr.td
>   clang/include/clang/Basic/AttrDocs.td
>   clang/include/clang/Basic/DiagnosticDriverKinds.td
>   clang/include/clang/Basic/DiagnosticSemaKinds.td
>   clang/include/clang/CodeGen/CGFunctionInfo.h
>   clang/lib/AST/TypePrinter.cpp
>   clang/lib/CodeGen/CGCall.cpp
>   clang/lib/Driver/ToolChains/Clang.cpp
>   clang/lib/Sema/SemaDecl.cpp
>   clang/lib/Sema/SemaDeclAttr.cpp
>   clang/lib/Sema/SemaExpr.cpp
>   clang/lib/Sema/SemaType.cpp
>   clang/lib/Serialization/ASTWriter.cpp
>   clang/test/AST/ast-dump-arm-attr.c
>   clang/test/CodeGen/arm-cmse-attr.c
>   clang/test/CodeGen/arm-cmse-call.c
>   clang/test/Driver/ropi-rwpi.c
>   clang/test/Driver/save-temps.c
>   clang/test/Misc/pragma-attribute-supported-attributes-list.test
>   clang/test/Sema/arm-cmse.c
>   clang/test/Sema/arm-no-cmse.c
>   clang/test/SemaCXX/arm-cmse.cpp
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76690: [AST][SVE] Treat built-in SVE types as POD

2020-03-24 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added subscribers: cfe-commits, psnobl, rkruppe, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.

Built-in SVE types are POD in much the same that scalars and
fixed-length vectors are.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76690

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -272,6 +272,7 @@
   __builtin_va_list va;
 
   __builtin_va_start(va, first);
+  __builtin_va_arg(va, svint8_t);
   __builtin_va_end(va);
   return count;
 }
@@ -502,6 +503,16 @@
   _Static_assert(!__is_assignable(svint8_t, svint8_t), "");
   _Static_assert(__is_assignable(svint8_t &, svint8_t), "");
   _Static_assert(!__is_assignable(svint8_t &, svint16_t), "");
+  _Static_assert(__has_nothrow_assign(svint8_t), "");
+  _Static_assert(__has_nothrow_move_assign(svint8_t), "");
+  _Static_assert(__has_nothrow_copy(svint8_t), "");
+  _Static_assert(__has_nothrow_constructor(svint8_t), "");
+  _Static_assert(__has_trivial_assign(svint8_t), "");
+  _Static_assert(__has_trivial_move_assign(svint8_t), "");
+  _Static_assert(__has_trivial_copy(svint8_t), "");
+  _Static_assert(__has_trivial_constructor(svint8_t), "");
+  _Static_assert(__has_trivial_move_constructor(svint8_t), "");
+  _Static_assert(__has_trivial_destructor(svint8_t), "");
   _Static_assert(!__has_virtual_destructor(svint8_t), "");
   _Static_assert(!__is_abstract(svint8_t), "");
   _Static_assert(!__is_aggregate(svint8_t), "");
@@ -513,6 +524,7 @@
   _Static_assert(!__is_enum(svint8_t), "");
   _Static_assert(!__is_final(svint8_t), "");
   _Static_assert(!__is_literal(svint8_t), "");
+  _Static_assert(__is_pod(svint8_t), "");
   _Static_assert(!__is_polymorphic(svint8_t), "");
   _Static_assert(__is_object(svint8_t), "");
   _Static_assert(!__is_arithmetic(svint8_t), "");
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2511,6 +2511,9 @@
   const Type *BaseTy = ty->getBaseElementTypeUnsafe();
   assert(BaseTy && "NULL element type");
 
+  if (BaseTy->isSizelessBuiltinType())
+return true;
+
   // Return false for incomplete types after skipping any incomplete array
   // types which are expressly allowed by the standard and thus our API.
   if (BaseTy->isIncompleteType())


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -272,6 +272,7 @@
   __builtin_va_list va;
 
   __builtin_va_start(va, first);
+  __builtin_va_arg(va, svint8_t);
   __builtin_va_end(va);
   return count;
 }
@@ -502,6 +503,16 @@
   _Static_assert(!__is_assignable(svint8_t, svint8_t), "");
   _Static_assert(__is_assignable(svint8_t &, svint8_t), "");
   _Static_assert(!__is_assignable(svint8_t &, svint16_t), "");
+  _Static_assert(__has_nothrow_assign(svint8_t), "");
+  _Static_assert(__has_nothrow_move_assign(svint8_t), "");
+  _Static_assert(__has_nothrow_copy(svint8_t), "");
+  _Static_assert(__has_nothrow_constructor(svint8_t), "");
+  _Static_assert(__has_trivial_assign(svint8_t), "");
+  _Static_assert(__has_trivial_move_assign(svint8_t), "");
+  _Static_assert(__has_trivial_copy(svint8_t), "");
+  _Static_assert(__has_trivial_constructor(svint8_t), "");
+  _Static_assert(__has_trivial_move_constructor(svint8_t), "");
+  _Static_assert(__has_trivial_destructor(svint8_t), "");
   _Static_assert(!__has_virtual_destructor(svint8_t), "");
   _Static_assert(!__is_abstract(svint8_t), "");
   _Static_assert(!__is_aggregate(svint8_t), "");
@@ -513,6 +524,7 @@
   _Static_assert(!__is_enum(svint8_t), "");
   _Static_assert(!__is_final(svint8_t), "");
   _Static_assert(!__is_literal(svint8_t), "");
+  _Static_assert(__is_pod(svint8_t), "");
   _Static_assert(!__is_polymorphic(svint8_t), "");
   _Static_assert(__is_object(svint8_t), "");
   _Static_assert(!__is_arithmetic(svint8_t), "");
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2511,6 +2511,9 @@
   const Type *BaseTy = ty->getBaseElementTypeUnsafe();
   assert(BaseTy && "NULL element type");
 
+  if (BaseTy->isSizelessBuiltinType())
+return true;
+
   // Return false for incomplete types after skipping any incomplete array
   // types which are expressly allowed by the standard and thus our API.
   if (BaseTy->isIncompleteType())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76691: [AST][SVE] Treat built-in SVE types as trivially copyable

2020-03-24 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added subscribers: cfe-commits, psnobl, rkruppe, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.
rsandifo-arm added a child revision: D76692: [AST][SVE] Treat built-in SVE 
types as trivial.

SVE types are trivially copyable: they can be copied simply
by reproducing the byte representation of the source object.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76691

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -489,6 +489,7 @@
   (void)typeid(ref_int8);
   (void)typeid(static_int8_ptr);
 
+  _Static_assert(__is_trivially_copyable(svint8_t), "");
   _Static_assert(__is_trivially_destructible(svint8_t), "");
   _Static_assert(!__is_nothrow_assignable(svint8_t, svint8_t), "");
   _Static_assert(__is_nothrow_assignable(svint8_t &, svint8_t), "");
@@ -602,9 +603,7 @@
   for (const svint8_t &x : wrapper()) { // expected-warning {{loop 
variable 'x' binds to a temporary value produced by a range of type 
'wrapper'}} expected-note {{use non-reference type}}
 (void)x;
   }
-  // This warning is bogus and will be removed by a later patch.
-  // The point is to show that it's being removed for the right reasons.
-  for (const svint8_t x : wrapper()) { // expected-warning 
{{loop variable 'x' creates a copy from type 'const svint8_t'}} expected-note 
{{use reference type}}
+  for (const svint8_t x : wrapper()) {
 (void)x;
   }
 #endif
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2318,6 +2318,9 @@
   if (CanonicalType->isDependentType())
 return false;
 
+  if (CanonicalType->isSizelessBuiltinType())
+return true;
+
   // Return false for incomplete types after skipping any incomplete array 
types
   // which are expressly allowed by the standard and thus our API.
   if (CanonicalType->isIncompleteType())


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -489,6 +489,7 @@
   (void)typeid(ref_int8);
   (void)typeid(static_int8_ptr);
 
+  _Static_assert(__is_trivially_copyable(svint8_t), "");
   _Static_assert(__is_trivially_destructible(svint8_t), "");
   _Static_assert(!__is_nothrow_assignable(svint8_t, svint8_t), "");
   _Static_assert(__is_nothrow_assignable(svint8_t &, svint8_t), "");
@@ -602,9 +603,7 @@
   for (const svint8_t &x : wrapper()) { // expected-warning {{loop variable 'x' binds to a temporary value produced by a range of type 'wrapper'}} expected-note {{use non-reference type}}
 (void)x;
   }
-  // This warning is bogus and will be removed by a later patch.
-  // The point is to show that it's being removed for the right reasons.
-  for (const svint8_t x : wrapper()) { // expected-warning {{loop variable 'x' creates a copy from type 'const svint8_t'}} expected-note {{use reference type}}
+  for (const svint8_t x : wrapper()) {
 (void)x;
   }
 #endif
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2318,6 +2318,9 @@
   if (CanonicalType->isDependentType())
 return false;
 
+  if (CanonicalType->isSizelessBuiltinType())
+return true;
+
   // Return false for incomplete types after skipping any incomplete array types
   // which are expressly allowed by the standard and thus our API.
   if (CanonicalType->isIncompleteType())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76692: [AST][SVE] Treat built-in SVE types as trivial

2020-03-24 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added subscribers: cfe-commits, psnobl, rkruppe, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.
rsandifo-arm added a parent revision: D76691: [AST][SVE] Treat built-in SVE 
types as trivially copyable.

Built-in SVE types are trivial, since they're trivially copyable
and support default construction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76692

Files:
  clang/lib/AST/Type.cpp
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -527,6 +527,7 @@
   _Static_assert(!__is_literal(svint8_t), "");
   _Static_assert(__is_pod(svint8_t), "");
   _Static_assert(!__is_polymorphic(svint8_t), "");
+  _Static_assert(__is_trivial(svint8_t), "");
   _Static_assert(__is_object(svint8_t), "");
   _Static_assert(!__is_arithmetic(svint8_t), "");
   _Static_assert(!__is_floating_point(svint8_t), "");
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2264,6 +2264,9 @@
   if ((*this)->isArrayType())
 return Context.getBaseElementType(*this).isTrivialType(Context);
 
+  if ((*this)->isSizelessBuiltinType())
+return true;
+
   // Return false for incomplete types after skipping any incomplete array
   // types which are expressly allowed by the standard and thus our API.
   if ((*this)->isIncompleteType())


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -527,6 +527,7 @@
   _Static_assert(!__is_literal(svint8_t), "");
   _Static_assert(__is_pod(svint8_t), "");
   _Static_assert(!__is_polymorphic(svint8_t), "");
+  _Static_assert(__is_trivial(svint8_t), "");
   _Static_assert(__is_object(svint8_t), "");
   _Static_assert(!__is_arithmetic(svint8_t), "");
   _Static_assert(!__is_floating_point(svint8_t), "");
Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -2264,6 +2264,9 @@
   if ((*this)->isArrayType())
 return Context.getBaseElementType(*this).isTrivialType(Context);
 
+  if ((*this)->isSizelessBuiltinType())
+return true;
+
   // Return false for incomplete types after skipping any incomplete array
   // types which are expressly allowed by the standard and thus our API.
   if ((*this)->isIncompleteType())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76689: [Sema][SVE] Fix handling of initialisers for built-in SVE types

2020-03-24 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added subscribers: cfe-commits, psnobl, rkruppe, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.

The built-in SVE types are supposed to be treated as opaque types.
This means that for initialisation purposes they should be treated
as a single unit, much like a scalar type.

clang-format would have changed the formatting of the initKind
calculation to:

  int initKind =
  T->isArrayType()
  ? 0
  : T->isVectorType()
? 1
: T->isScalarType() || T->isScalarType()
  ...

I can't remember seeing that style elsewhere, so the patch instead
uses an if-else, like some other diagnostics do.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76689

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/sizeless-1.c
  clang/test/SemaCXX/sizeless-1.cpp


Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -94,9 +94,15 @@
 
 #if __cplusplus >= 201103L
   int empty_brace_init_int = {};
+  svint8_t empty_brace_init_int8 = {};
 #else
   int empty_brace_init_int = {}; // expected-error {{scalar initializer cannot 
be empty}}
+  svint8_t empty_brace_init_int8 = {}; // expected-error {{scalar initializer 
cannot be empty}}
 #endif
+  svint8_t brace_init_int8 = {local_int8};
+  svint8_t bad_brace_init_int8_1 = {local_int8, 0}; // expected-error {{excess 
elements in scalar initializer}}
+  svint8_t bad_brace_init_int8_2 = {0}; // expected-error {{rvalue 
of type 'int'}}
+  svint8_t bad_brace_init_int8_3 = {local_int16};   // expected-error {{lvalue 
of type 'svint16_t'}}
 
   const svint8_t const_int8 = local_int8; // expected-note {{declared const 
here}}
   const svint8_t uninit_const_int8;   // expected-error {{default 
initialization of an object of const type 'const svint8_t'}}
@@ -454,6 +460,11 @@
   local_int8 = ref_int8;
 
 #if __cplusplus >= 201103L
+  svint8_t zero_init_int8{};
+  svint8_t init_int8{local_int8};
+  svint8_t bad_brace_init_int8_1{local_int8, 0}; // expected-error {{excess 
elements in scalar initializer}}
+  svint8_t bad_brace_init_int8_2{0}; // expected-error {{rvalue of 
type 'int'}}
+  svint8_t bad_brace_init_int8_3{local_int16};   // expected-error {{lvalue of 
type 'svint16_t'}}
   svint8_t wrapper_init_int8{wrapper()};
   svint8_t &ref_init_int8{local_int8};
 
Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -83,6 +83,11 @@
   svint8_t bad_init_int8 = for; // expected-error {{expected expression}}
 
   int empty_brace_init_int = {}; // expected-error {{scalar initializer cannot 
be empty}}
+  svint8_t empty_brace_init_int8 = {}; // expected-error {{scalar initializer 
cannot be empty}}
+  svint8_t brace_init_int8 = {local_int8};
+  svint8_t bad_brace_init_int8_1 = {local_int8, 0}; // expected-warning 
{{excess elements in scalar initializer}}
+  svint8_t bad_brace_init_int8_2 = {0}; // expected-error 
{{incompatible type 'int'}}
+  svint8_t bad_brace_init_int8_3 = {local_int16};   // expected-error 
{{incompatible type 'svint16_t'}}
 
   const svint8_t const_int8 = local_int8; // expected-note {{declared const 
here}}
   const svint8_t uninit_const_int8;
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -1204,11 +1204,18 @@
   SemaRef.Diag(IList->getInit(Index)->getBeginLoc(), DK)
   << IList->getInit(Index)->getSourceRange();
 } else {
-  int initKind = T->isArrayType() ? 0 :
- T->isVectorType() ? 1 :
- T->isScalarType() ? 2 :
- T->isUnionType() ? 3 :
- 4;
+  int initKind = 4;
+  if (T->isArrayType())
+initKind = 0;
+  else if (T->isVectorType())
+initKind = 1;
+  // Since we apply the rules for scalar types to sizeless built-in types,
+  // we get more consistent error messages by treating them as scalar
+  // here.  "sizeless initializer" wouldn't make much sense anyhow.
+  else if (T->isScalarType() || T->isSizelessBuiltinType())
+initKind = 2;
+  else if (T->isUnionType())
+initKind = 3;
 
   unsigned DK = ExtraInitsIsError ? diag::err_excess_initializers
   : diag::ext_excess_initializers;
@@ -1295,7 +1302,8 @@
 if (!VerifyOnly)
   SemaRef.Diag(IList->getBeginLoc(), diag::err_init_objc_class) << 
DeclType;
 hadError = true;
-  } else if (DeclType->isOCLIntelSubgroupAVCType()) {
+  } else if (DeclType->isOCLIntelSubgroupAVCType() ||
+ DeclType->isSizel

[PATCH] D76694: [Sema][SVE] Allow casting SVE types to themselves in C

2020-03-24 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added subscribers: cfe-commits, psnobl, rkruppe, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.

Casts from an SVE type to itself aren't very useful, but they are
supposed to be valid, and could occur in things like macro expansions.

Such casts already work for C++ and are tested by sizeless-1.cpp.
This patch makes them work for C too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76694

Files:
  clang/lib/Sema/SemaCast.cpp
  clang/test/Sema/sizeless-1.c


Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -113,6 +113,8 @@
 
   sel = local_int8; // expected-error {{assigning to 'int' from incompatible 
type 'svint8_t'}}
 
+  local_int8 = (svint8_t)local_int8;
+  local_int8 = (const svint8_t)local_int8;
   local_int8 = (svint8_t)local_int16; // expected-error {{used type 'svint8_t' 
(aka '__SVInt8_t') where arithmetic or pointer type is required}}
   local_int8 = (svint8_t)0;   // expected-error {{used type 'svint8_t' 
(aka '__SVInt8_t') where arithmetic or pointer type is required}}
   sel = (int)local_int8;  // expected-error {{operand of type 
'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}}
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2652,6 +2652,13 @@
 return;
   }
 
+  // Allow casting a sizeless built-in type to itself.
+  if (DestType->isSizelessBuiltinType() &&
+  Self.Context.hasSameUnqualifiedType(DestType, SrcType)) {
+Kind = CK_NoOp;
+return;
+  }
+
   if (!DestType->isScalarType() && !DestType->isVectorType()) {
 const RecordType *DestRecordTy = DestType->getAs();
 


Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -113,6 +113,8 @@
 
   sel = local_int8; // expected-error {{assigning to 'int' from incompatible type 'svint8_t'}}
 
+  local_int8 = (svint8_t)local_int8;
+  local_int8 = (const svint8_t)local_int8;
   local_int8 = (svint8_t)local_int16; // expected-error {{used type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}}
   local_int8 = (svint8_t)0;   // expected-error {{used type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}}
   sel = (int)local_int8;  // expected-error {{operand of type 'svint8_t' (aka '__SVInt8_t') where arithmetic or pointer type is required}}
Index: clang/lib/Sema/SemaCast.cpp
===
--- clang/lib/Sema/SemaCast.cpp
+++ clang/lib/Sema/SemaCast.cpp
@@ -2652,6 +2652,13 @@
 return;
   }
 
+  // Allow casting a sizeless built-in type to itself.
+  if (DestType->isSizelessBuiltinType() &&
+  Self.Context.hasSameUnqualifiedType(DestType, SrcType)) {
+Kind = CK_NoOp;
+return;
+  }
+
   if (!DestType->isScalarType() && !DestType->isVectorType()) {
 const RecordType *DestRecordTy = DestType->getAs();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76693: [Sema][SVE] Allow ?: to select between SVE types in C

2020-03-24 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm created this revision.
rsandifo-arm added reviewers: sdesmalen, efriedma, rovka, rjmccall.
Herald added subscribers: cfe-commits, psnobl, rkruppe, tschuett.
Herald added a reviewer: rengolin.
Herald added a project: clang.

When compiling C, a ?: between two values of the same SVE type
currently gives an error such as:

  incompatible operand types ('svint8_t' (aka '__SVInt8_t') and 'svint8_t')

It's supposed to be valid to select between (cv-qualified versions of)
the same SVE type, so this patch adds that case.

These expressions already work for C++ and are tested by
SemaCXX/sizeless-1.cpp.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76693

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/sizeless-1.c


Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -131,6 +131,11 @@
 
   const_volatile_int8 = local_int8; // expected-error {{cannot assign to 
variable 'const_volatile_int8' with const-qualified type 'const volatile 
svint8_t'}}
 
+  init_int8 = sel ? init_int8 : local_int8;
+  init_int8 = sel ? init_int8 : const_int8;
+  init_int8 = sel ? volatile_int8 : const_int8;
+  init_int8 = sel ? volatile_int8 : const_volatile_int8;
+
   pass_int8(local_int8);
   pass_int8(local_int16); // expected-error {{passing 'svint16_t' (aka 
'__SVInt16_t') to parameter of incompatible type 'svint8_t'}}
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7586,6 +7586,11 @@
   /*IsIntFirstExpr=*/false))
 return LHSTy;
 
+  // Allow ?: operations in which both operands have the same
+  // built-in sizeless type.
+  if (LHSTy->isSizelessBuiltinType() && LHSTy == RHSTy)
+return LHSTy;
+
   // Emit a better diagnostic if one of the expressions is a null pointer
   // constant and the other is not a pointer type. In this case, the user most
   // likely forgot to take the address of the other expression.


Index: clang/test/Sema/sizeless-1.c
===
--- clang/test/Sema/sizeless-1.c
+++ clang/test/Sema/sizeless-1.c
@@ -131,6 +131,11 @@
 
   const_volatile_int8 = local_int8; // expected-error {{cannot assign to variable 'const_volatile_int8' with const-qualified type 'const volatile svint8_t'}}
 
+  init_int8 = sel ? init_int8 : local_int8;
+  init_int8 = sel ? init_int8 : const_int8;
+  init_int8 = sel ? volatile_int8 : const_int8;
+  init_int8 = sel ? volatile_int8 : const_volatile_int8;
+
   pass_int8(local_int8);
   pass_int8(local_int16); // expected-error {{passing 'svint16_t' (aka '__SVInt16_t') to parameter of incompatible type 'svint8_t'}}
 
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7586,6 +7586,11 @@
   /*IsIntFirstExpr=*/false))
 return LHSTy;
 
+  // Allow ?: operations in which both operands have the same
+  // built-in sizeless type.
+  if (LHSTy->isSizelessBuiltinType() && LHSTy == RHSTy)
+return LHSTy;
+
   // Emit a better diagnostic if one of the expressions is a null pointer
   // constant and the other is not a pointer type. In this case, the user most
   // likely forgot to take the address of the other expression.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76592: [Parser] Fix the assertion crash in ActOnStartOfSwitch stmt.

2020-03-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 252280.
hokein added a comment.

adjust the assertion based on the offline discussion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76592

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Parser/switch-typo-correction.cpp


Index: clang/test/Parser/switch-typo-correction.cpp
===
--- /dev/null
+++ clang/test/Parser/switch-typo-correction.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace c { double xxx; } // expected-note{{'c::xxx' declared here}}
+namespace d { float xxx; }
+namespace z { namespace xxx {} }
+
+void crash() {
+  switch (xxx) {} // expected-error{{use of undeclared identifier 'xxx'; did 
you mean }}
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -730,11 +730,11 @@
 
   if (CondExpr && !CondExpr->isTypeDependent()) {
 // We have already converted the expression to an integral or enumeration
-// type, when we parsed the switch condition. If we don't have an
-// appropriate type now, enter the switch scope but remember that it's
-// invalid.
-assert(CondExpr->getType()->isIntegralOrEnumerationType() &&
-   "invalid condition type");
+// type, when we parsed the switch condition. There are cases where we 
don't
+// have an appropriate type, e.g. a typo-expr Cond was corrected to an
+// inappropriate-type expr, we just returns an error.
+if (!CondExpr->getType()->isIntegralOrEnumerationType())
+  return StmtError();
 if (CondExpr->isKnownToHaveBooleanValue()) {
   // switch(bool_expr) {...} is often a programmer error, e.g.
   //   switch(n && mask) { ... }  // Doh - should be "n & mask".


Index: clang/test/Parser/switch-typo-correction.cpp
===
--- /dev/null
+++ clang/test/Parser/switch-typo-correction.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace c { double xxx; } // expected-note{{'c::xxx' declared here}}
+namespace d { float xxx; }
+namespace z { namespace xxx {} }
+
+void crash() {
+  switch (xxx) {} // expected-error{{use of undeclared identifier 'xxx'; did you mean }}
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -730,11 +730,11 @@
 
   if (CondExpr && !CondExpr->isTypeDependent()) {
 // We have already converted the expression to an integral or enumeration
-// type, when we parsed the switch condition. If we don't have an
-// appropriate type now, enter the switch scope but remember that it's
-// invalid.
-assert(CondExpr->getType()->isIntegralOrEnumerationType() &&
-   "invalid condition type");
+// type, when we parsed the switch condition. There are cases where we don't
+// have an appropriate type, e.g. a typo-expr Cond was corrected to an
+// inappropriate-type expr, we just returns an error.
+if (!CondExpr->getType()->isIntegralOrEnumerationType())
+  return StmtError();
 if (CondExpr->isKnownToHaveBooleanValue()) {
   // switch(bool_expr) {...} is often a programmer error, e.g.
   //   switch(n && mask) { ... }  // Doh - should be "n & mask".
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76592: [Parser] Fix the assertion crash in ActOnStartOfSwitch stmt.

2020-03-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 252281.
hokein added a comment.

fix a typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76592

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Parser/switch-typo-correction.cpp


Index: clang/test/Parser/switch-typo-correction.cpp
===
--- /dev/null
+++ clang/test/Parser/switch-typo-correction.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace c { double xxx; } // expected-note{{'c::xxx' declared here}}
+namespace d { float xxx; }
+namespace z { namespace xxx {} }
+
+void crash() {
+  switch (xxx) {} // expected-error{{use of undeclared identifier 'xxx'; did 
you mean }}
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -730,11 +730,11 @@
 
   if (CondExpr && !CondExpr->isTypeDependent()) {
 // We have already converted the expression to an integral or enumeration
-// type, when we parsed the switch condition. If we don't have an
-// appropriate type now, enter the switch scope but remember that it's
-// invalid.
-assert(CondExpr->getType()->isIntegralOrEnumerationType() &&
-   "invalid condition type");
+// type, when we parsed the switch condition. There are cases where we 
don't
+// have an appropriate type, e.g. a typo-expr Cond was corrected to an
+// inappropriate-type expr, we just return an error.
+if (!CondExpr->getType()->isIntegralOrEnumerationType())
+  return StmtError();
 if (CondExpr->isKnownToHaveBooleanValue()) {
   // switch(bool_expr) {...} is often a programmer error, e.g.
   //   switch(n && mask) { ... }  // Doh - should be "n & mask".


Index: clang/test/Parser/switch-typo-correction.cpp
===
--- /dev/null
+++ clang/test/Parser/switch-typo-correction.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace c { double xxx; } // expected-note{{'c::xxx' declared here}}
+namespace d { float xxx; }
+namespace z { namespace xxx {} }
+
+void crash() {
+  switch (xxx) {} // expected-error{{use of undeclared identifier 'xxx'; did you mean }}
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -730,11 +730,11 @@
 
   if (CondExpr && !CondExpr->isTypeDependent()) {
 // We have already converted the expression to an integral or enumeration
-// type, when we parsed the switch condition. If we don't have an
-// appropriate type now, enter the switch scope but remember that it's
-// invalid.
-assert(CondExpr->getType()->isIntegralOrEnumerationType() &&
-   "invalid condition type");
+// type, when we parsed the switch condition. There are cases where we don't
+// have an appropriate type, e.g. a typo-expr Cond was corrected to an
+// inappropriate-type expr, we just return an error.
+if (!CondExpr->getType()->isIntegralOrEnumerationType())
+  return StmtError();
 if (CondExpr->isKnownToHaveBooleanValue()) {
   // switch(bool_expr) {...} is often a programmer error, e.g.
   //   switch(n && mask) { ... }  // Doh - should be "n & mask".
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] d9b9621 - Reland D73534: [DebugInfo] Enable the debug entry values feature by default

2020-03-24 Thread Djordje via cfe-commits
Hi David,

On 23.3.20. 18:51, David Blaikie wrote:
> On Mon, Mar 23, 2020 at 12:56 AM Djordje  > wrote:
>
> (+ CCing some debug info folks as well)
>
> Hi David,
>
> OK, I agree, my apologize.
>
> The patch enables the whole feature by default and removes the 
> experimental option that has been used during the implementation.
> We tested the code (and the assertions regarding the feature itself) by 
> using the experimental option on some large projects, but since the feature 
> became that huge (and new patches regarding the feature are coming every day 
> -- which is nice), it is impossible to test everything.
>
>
> Certainly not possible to test everything - and sometimes testing on the 
> buildbots is the best we have, though in that  case (when you know there's 
> likely some "testing in production" to do) it's probably best to commit it 
> during an off-peak time if possible (not always possible, not asking you to 
> work weekends, etc) and plan to revert it once you get the buildbot feedback 
> you need to make progress, etc.
>
> The other thing I'm interested in/suggesting is that when you commit 
> something and it fails on buildbots, it gets reverted - especially with 
> something big like this, I think it's important/worthwhile to look at what 
> testing wasn't done pre-commit that found failures post-commit, and not just 
> addressing the specific failure the buildbots found, but rerunning the 
> broader set of testing (if it's possible for you to do so - you might not 
> haev the available hardware, etc - but if it's about building with 
> sanitizers, building with different targets enabled, etc) as well, as 
> generalized as much as possible, to increase the chances the next time around.
>
> That's what I expect/hope to see when something is recommitted "This was 
> reverted in XXX due to  which was addressed in  and 
> validated with ".
>  
OK, I understand, thanks a lot for the feedback! :)
>
>
> The Debug Entry Values implementation grows these days, and new 
> functionalities comes in, but it has all been tested with the experimental 
> option, so committing this particular patch imposes all the cases developers 
> oversighted during the implementation.
>
> My impression is that, before adding new functionalities to the feature, 
> we should make sure the D73534 is stable and gets stuck. We should have done 
> it before, but I think that is the lesson learned here.
>
> In general, experimental options are very good up to the some point, but 
> if the feature being tested grows a lot, a "breakpoint" should be set up and 
> take care the experimental option is removed and the code is well tested on 
> the real cases out there, and then moving to the next stage of the 
> implementation.
>
>
> Yes, generally the idea with an experimental feature like this one where the 
> cost/benefit (size increase compared to debug info usability improvements) is 
> in question, etc would be, imho, to stabilize the feature representing the 
> best (or at least a "good enough") cost/benefit, etc, and then make it 
> non-experimental - if it's still a moving target/with changes being made, 
> maybe it's still experimental?
Speaking of this feature, we agreed it is ready to be ON by default, since the 
debug info statistics was shown, time/size costs, benefits to end users etc.. 
But, we have also continued to adding new code (besides fixes the bugs imposed 
by this patch), which is great, but it imposed new failures and new 
reverts/recommits.
>  
>
> Besides this, CISCO is using the feature ON by default for some time, and 
> we have good experience there. This really improves the debugging user 
> experience while debugging the "optimized" code.
>
> Best regards,
> Djordje
>
> On 22.3.20. 16:30, David Blaikie wrote:
> > Also, this patch was reverted and recommitted several times (more than 
> I think would be ideal) - please include more details in the commit message 
> about what went wrong, what was fixed, what testing was missed in the first 
> place and done in subsequent precommit validation (& is there anything more 
> broadly we could learn from this patches story to avoid this kind of 
> revert/recommit repetition in the future?)
> >
> > On Sat, Mar 21, 2020 at 8:13 PM David Blaikie    >> wrote:
> >
> >     Please include the "Differential Revision" line so that Phab picks 
> up commits like this and ties them into the review (& also makes it 
> conveniently clickable to jump from the commit mail to the review)
> >
> >     On Thu, Mar 19, 2020 at 5:58 AM Djordje Todorovic via cfe-commits 
> mailto:cfe-commits@lists.llvm.org> 
> >> 
> wrote:
> >
> >
> >         Author: Djordje Todorovic
> >         Date: 2020-03-19T13:57:3

[PATCH] D76696: [AST] Build recovery expressions by default for C++.

2020-03-24 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/D76696

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp
  clang/test/Parser/objcxx0x-lambda-expressions.mm
  clang/test/Parser/objcxx11-invalid-lambda.cpp
  clang/test/SemaCXX/builtins.cpp
  clang/test/SemaCXX/cast-conversion.cpp
  clang/test/SemaCXX/cxx1z-copy-omission.cpp
  clang/test/SemaCXX/decltype-crash.cpp
  clang/test/SemaCXX/varargs.cpp
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaTemplate/instantiate-init.cpp
  clang/unittests/Sema/CodeCompleteTest.cpp

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -487,6 +487,7 @@
 auto x = decltype(&1)(^);
 auto y = new decltype(&1)(^);
   )cpp";
-  EXPECT_THAT(collectPreferredTypes(Code), Each("NULL TYPE"));
+  EXPECT_THAT(collectPreferredTypes(Code),
+  Each("decltype((1))"));
 }
 } // namespace
Index: clang/test/SemaTemplate/instantiate-init.cpp
===
--- clang/test/SemaTemplate/instantiate-init.cpp
+++ clang/test/SemaTemplate/instantiate-init.cpp
@@ -100,7 +100,7 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
   Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
   ));
 
Index: clang/test/SemaOpenCLCXX/address-space-references.cl
===
--- clang/test/SemaOpenCLCXX/address-space-references.cl
+++ clang/test/SemaOpenCLCXX/address-space-references.cl
@@ -11,7 +11,7 @@
 int bar(const unsigned int &i);
 
 void foo() {
-  bar(1) // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
+  bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
 }
 
 // Test addr space conversion with nested pointers
Index: clang/test/SemaCXX/varargs.cpp
===
--- clang/test/SemaCXX/varargs.cpp
+++ clang/test/SemaCXX/varargs.cpp
@@ -22,7 +22,8 @@
 // default ctor.
 void record_context(int a, ...) {
   struct Foo {
-// expected-error@+1 {{'va_start' cannot be used outside a function}}
+// expected-error@+2 {{'va_start' cannot be used outside a function}}
+// expected-error@+1 {{default argument references parameter 'a'}}
 void meth(int a, int b = (__builtin_va_start(ap, a), 0)) {}
   };
 }
Index: clang/test/SemaCXX/decltype-crash.cpp
===
--- clang/test/SemaCXX/decltype-crash.cpp
+++ clang/test/SemaCXX/decltype-crash.cpp
@@ -3,5 +3,8 @@
 int& a();
 
 void f() {
-  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} expected-error {{use of undeclared identifier 'decltype'}}
+  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} \
+   // expected-error {{use of undeclared identifier 'decltype'}} \
+   // expected-error {{expected ';' after expression}} \
+   // expected-error {{use of undeclared identifier 'c'}}
 }
Index: clang/test/SemaCXX/cxx1z-copy-omission.cpp
===
--- clang/test/SemaCXX/cxx1z-copy-omission.cpp
+++ clang/test/SemaCXX/cxx1z-copy-omission.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify -Wno-unused %s
 
 struct Noncopyable {
   Noncopyable();
@@ -107,8 +107,10 @@
   sizeof(make_indestructible()); // expected-error {{deleted}}
   sizeof(make_incomplete()); // expected-error {{incomplete}}
   typeid(Indestructible{}); // expected-error {{deleted}}
-  typeid(make_indestructible()); // expected-error {{deleted}}
-  typeid(make_incomplete()); // expected-error {{incomplete}}
+  typeid(make_indestructible()); // expected-error {{deleted}} \
+ // expected-error {{need to include }}
+  typeid(make_incomplete()); // expected-error {{incomplete}} \
+ // expected-error {{need to include }}
 
   // FIXME: The first two cases here are now also valid in C++17 onwards.
   using I = decltype(Indestructible()); // expected-error {{deleted}}
Index: clang/test/SemaCXX/ca

[clang] a2aa997 - [AST] Use TypeDependence bitfield to calculate dependence on Types. NFC

2020-03-24 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-03-24T13:56:38+01:00
New Revision: a2aa9970e1fec589591f7b8ac5557c47be4e8550

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

LOG: [AST] Use TypeDependence bitfield to calculate dependence on Types. NFC

Summary:
This clears the way for adding an Error dependence bit to Type and having it
mostly-automatically propagated.

Reviewers: hokein

Subscribers: jfb, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/DependenceFlags.h
clang/include/clang/AST/LocInfoType.h
clang/include/clang/AST/Type.h
clang/include/clang/AST/TypeProperties.td
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Type.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index ee6439fc984c..788227156c4d 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -115,6 +115,32 @@ inline ExprDependence 
turnTypeToValueDependence(ExprDependence D) {
   // type dependency.
   return D & ~ExprDependence::Type;
 }
+inline ExprDependence turnValueToTypeDependence(ExprDependence D) {
+  // Type-dependent expressions are always be value-dependent.
+  if (D & ExprDependence::Value)
+D |= ExprDependence::Type;
+  return D;
+}
+
+// Returned type-dependence will never have VariablyModified set.
+inline TypeDependence toTypeDependence(ExprDependence D) {
+  // Supported bits all have the same representation.
+  return static_cast(D & (ExprDependence::UnexpandedPack |
+  ExprDependence::Instantiation |
+  ExprDependence::Type));
+}
+inline TypeDependence toTypeDependence(NestedNameSpecifierDependence D) {
+  // Supported bits all have the same representation.
+  return static_cast(D);
+}
+inline TypeDependence toTypeDependence(TemplateNameDependence D) {
+  // Supported bits all have the same representation.
+  return static_cast(D);
+}
+inline TypeDependence toTypeDependence(TemplateArgumentDependence D) {
+  // Supported bits all have the same representation.
+  return static_cast(D);
+}
 
 inline NestedNameSpecifierDependence
 toNestedNameSpecifierDependendence(TypeDependence D) {

diff  --git a/clang/include/clang/AST/LocInfoType.h 
b/clang/include/clang/AST/LocInfoType.h
index 1073174bcf91..7e845ad03587 100644
--- a/clang/include/clang/AST/LocInfoType.h
+++ b/clang/include/clang/AST/LocInfoType.h
@@ -35,10 +35,7 @@ class LocInfoType : public Type {
   TypeSourceInfo *DeclInfo;
 
   LocInfoType(QualType ty, TypeSourceInfo *TInfo)
-  : Type((TypeClass)LocInfo, ty, ty->isDependentType(),
- ty->isInstantiationDependentType(), ty->isVariablyModifiedType(),
- ty->containsUnexpandedParameterPack()),
-DeclInfo(TInfo) {
+  : Type((TypeClass)LocInfo, ty, ty->getDependence()), DeclInfo(TInfo) {
 assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in 
TC?");
   }
   friend class Sema;

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 16db1d5cbc3a..b8f49127bbd0 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1818,23 +1818,11 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
 protected:
   friend class ASTContext;
 
-  Type(TypeClass tc, QualType canon, bool Dependent,
-   bool InstantiationDependent, bool VariablyModified,
-   bool ContainsUnexpandedParameterPack)
+  Type(TypeClass tc, QualType canon, TypeDependence Dependence)
   : ExtQualsTypeCommonBase(this,
canon.isNull() ? QualType(this_(), 0) : canon) {
-auto Deps = TypeDependence::None;
-if (Dependent)
-  Deps |= TypeDependence::Dependent | TypeDependence::Instantiation;
-if (InstantiationDependent)
-  Deps |= TypeDependence::Instantiation;
-if (ContainsUnexpandedParameterPack)
-  Deps |= TypeDependence::UnexpandedPack;
-if (VariablyModified)
-  Deps |= TypeDependence::VariablyModified;
-
 TypeBits.TC = tc;
-TypeBits.Dependence = static_cast(Deps);
+TypeBits.Dependence = static_cast(Dependence);
 TypeBits.CacheValid = false;
 TypeBits.CachedLocalOrUnnamed = false;
 TypeBits.CachedLinkage = NoLinkage;
@@ -1844,41 +1832,11 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
   // silence VC++ warning C4355: 'this' : used in base member initializer list
   Type *this_() { return this; }
 
-  void setDependent(bool D = true) {
-if (!D) {
-  TypeBits.Dependence &= ~static_cast(TypeDependence::Dependent);
-  return;
-}
-TypeBits.Dependence |= static_cast(TypeDependence::Dependent |
-  

[clang] 0b59982 - [CodeGen] Fix test attr-noreturn.c when run from my home directory

2020-03-24 Thread via cfe-commits

Author: Sam McCall
Date: 2020-03-24T13:59:16+01:00
New Revision: 0b5998213415147d901d394cfc47d7daedacc3cf

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

LOG: [CodeGen] Fix test attr-noreturn.c when run from my home directory

Added: 


Modified: 
clang/test/CodeGen/attr-noreturn.c

Removed: 




diff  --git a/clang/test/CodeGen/attr-noreturn.c 
b/clang/test/CodeGen/attr-noreturn.c
index b420edfc0595..5dca4fa1f520 100644
--- a/clang/test/CodeGen/attr-noreturn.c
+++ b/clang/test/CodeGen/attr-noreturn.c
@@ -6,5 +6,5 @@ fptrs_t p __attribute__((noreturn));
 void __attribute__((noreturn)) f() {
   p[0]();
 }
-// CHECK: call
+// CHECK: call void
 // CHECK-NEXT: unreachable



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


Re: [PATCH] D71129: [ARM][CMSE] Implement CMSE attributes

2020-03-24 Thread Momchil Velikov via cfe-commits
From: Russell Gallop 
> The new case that you've added to save-temps.c doesn't work if you only build 
> with
> DLLVM_TARGETS_TO_BUILD=X86 (i.e. not building ARM). Please could you take a 
> look?

Yes, I've been looking into it. I may revert that test alone, until I figure 
out how to fix it. https://reviews.llvm.org/D76695
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76424: [AST] Use TypeDependence bitfield to calculate dependence on Types. NFC

2020-03-24 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa2aa9970e1fe: [AST] Use TypeDependence bitfield to calculate 
dependence on Types. NFC (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76424

Files:
  clang/include/clang/AST/DependenceFlags.h
  clang/include/clang/AST/LocInfoType.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp

Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/DependenceFlags.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/NonTrivialTypeVisitor.h"
@@ -123,14 +124,15 @@
 //
 //   template int arr[] = {N...};
 : Type(tc, can,
-   et->isDependentType() || (sz && sz->isValueDependent()) ||
-   tc == DependentSizedArray,
-   et->isInstantiationDependentType() ||
-   (sz && sz->isInstantiationDependent()) ||
-   tc == DependentSizedArray,
-   (tc == VariableArray || et->isVariablyModifiedType()),
-   et->containsUnexpandedParameterPack() ||
-   (sz && sz->containsUnexpandedParameterPack())),
+   et->getDependence() |
+   (sz ? toTypeDependence(
+ turnValueToTypeDependence(sz->getDependence()))
+   : TypeDependence::None) |
+   (tc == VariableArray ? TypeDependence::VariablyModified
+: TypeDependence::None) |
+   (tc == DependentSizedArray
+? TypeDependence::DependentInstantiation
+: TypeDependence::None)),
   ElementType(et) {
   ArrayTypeBits.IndexTypeQuals = tq;
   ArrayTypeBits.SizeModifier = sm;
@@ -217,14 +219,16 @@
   E->Profile(ID, Context, true);
 }
 
-DependentVectorType::DependentVectorType(
-const ASTContext &Context, QualType ElementType, QualType CanonType,
-Expr *SizeExpr, SourceLocation Loc, VectorType::VectorKind VecKind)
-: Type(DependentVector, CanonType, /*Dependent=*/true,
-   /*InstantiationDependent=*/true,
-   ElementType->isVariablyModifiedType(),
-   ElementType->containsUnexpandedParameterPack() ||
-   (SizeExpr && SizeExpr->containsUnexpandedParameterPack())),
+DependentVectorType::DependentVectorType(const ASTContext &Context,
+ QualType ElementType,
+ QualType CanonType, Expr *SizeExpr,
+ SourceLocation Loc,
+ VectorType::VectorKind VecKind)
+: Type(DependentVector, CanonType,
+   TypeDependence::DependentInstantiation |
+   ElementType->getDependence() |
+   (SizeExpr ? toTypeDependence(SizeExpr->getDependence())
+ : TypeDependence::None)),
   Context(Context), ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
   VectorTypeBits.VecKind = VecKind;
 }
@@ -238,19 +242,16 @@
   SizeExpr->Profile(ID, Context, true);
 }
 
-DependentSizedExtVectorType::DependentSizedExtVectorType(const
- ASTContext &Context,
- QualType ElementType,
- QualType can,
- Expr *SizeExpr,
- SourceLocation loc)
-: Type(DependentSizedExtVector, can, /*Dependent=*/true,
-   /*InstantiationDependent=*/true,
-   ElementType->isVariablyModifiedType(),
-   (ElementType->containsUnexpandedParameterPack() ||
-(SizeExpr && SizeExpr->containsUnexpandedParameterPack(,
-  Context(Context), SizeExpr(SizeExpr), ElementType(ElementType),
-  loc(loc) {}
+DependentSizedExtVectorType::DependentSizedExtVectorType(
+const ASTContext &Context, QualType ElementType, QualType can,
+Expr *SizeExpr, SourceLocation loc)
+: Type(DependentSizedExtVector, can,
+   TypeDependence::DependentInstantiation |
+   ElementType->getDependence() |
+   (SizeExpr ? toTypeDependence(SizeExpr->getDependence())
+ : TypeDependence::None)),
+  Context(Context), SizeExpr(SizeExpr), ElementType(ElementType), loc(loc) {
+}
 
 void
 DependentSizedExtVectorType::Profile(llvm::FoldingSetNodeID &ID,
@@ -260,15 +261,16 @@
   SizeExpr->Profile(ID, Context, true);
 }
 
-DependentAddressSpaceType::DependentAddr

[clang] 2ae2564 - [CUDA][HIP] Add -Xarch_device and -Xarch_host options

2020-03-24 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-03-24T10:13:05-04:00
New Revision: 2ae25647d1a363515ecbd193dc66d8ada80dd054

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

LOG: [CUDA][HIP] Add -Xarch_device and -Xarch_host options

The argument after -Xarch_device will be added to the arguments for CUDA/HIP
device compilation and will be removed for host compilation.

The argument after -Xarch_host will be added to the arguments for CUDA/HIP
host compilation and will be removed for device compilation.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/Compilation.cpp
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Driver/ToolChains/HIP.cpp
clang/test/Driver/hip-options.hip

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 19bb72c55aa8..1358b463eb1a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -466,6 +466,10 @@ def Xanalyzer : Separate<["-"], "Xanalyzer">,
   HelpText<"Pass  to the static analyzer">, MetaVarName<"">,
   Group;
 def Xarch__ : JoinedAndSeparate<["-"], "Xarch_">, Flags<[DriverOption]>;
+def Xarch_host : Separate<["-"], "Xarch_host">, Flags<[DriverOption]>,
+  HelpText<"Pass  to the CUDA/HIP host compilation">, 
MetaVarName<"">;
+def Xarch_device : Separate<["-"], "Xarch_device">, Flags<[DriverOption]>,
+  HelpText<"Pass  to the CUDA/HIP device compilation">, 
MetaVarName<"">;
 def Xassembler : Separate<["-"], "Xassembler">,
   HelpText<"Pass  to the assembler">, MetaVarName<"">,
   Group;

diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 115d5ff20f07..66f22d538138 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -296,10 +296,20 @@ class ToolChain {
   SmallVectorImpl &AllocatedArgs) const;
 
   /// Append the argument following \p A to \p DAL assuming \p A is an Xarch
-  /// argument.
-  virtual void TranslateXarchArgs(const llvm::opt::DerivedArgList &Args,
-  llvm::opt::Arg *&A,
-  llvm::opt::DerivedArgList *DAL) const;
+  /// argument. If \p AllocatedArgs is null pointer, synthesized arguments are
+  /// added to \p DAL, otherwise they are appended to \p AllocatedArgs.
+  virtual void TranslateXarchArgs(
+  const llvm::opt::DerivedArgList &Args, llvm::opt::Arg *&A,
+  llvm::opt::DerivedArgList *DAL,
+  SmallVectorImpl *AllocatedArgs = nullptr) const;
+
+  /// Translate -Xarch_ arguments. If there are no such arguments, return
+  /// a null pointer, otherwise return a DerivedArgList containing the
+  /// translated arguments.
+  virtual llvm::opt::DerivedArgList *
+  TranslateXarchArgs(const llvm::opt::DerivedArgList &Args, StringRef 
BoundArch,
+ Action::OffloadKind DeviceOffloadKind,
+ SmallVectorImpl *AllocatedArgs) const;
 
   /// Choose a tool to use to handle the action \p JA.
   ///

diff  --git a/clang/lib/Driver/Compilation.cpp 
b/clang/lib/Driver/Compilation.cpp
index 52477576b2eb..05ee5091396b 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -76,16 +76,29 @@ Compilation::getArgsForToolChain(const ToolChain *TC, 
StringRef BoundArch,
   *TranslatedArgs, SameTripleAsHost, AllocatedArgs);
 }
 
+DerivedArgList *NewDAL = nullptr;
 if (!OpenMPArgs) {
+  NewDAL = TC->TranslateXarchArgs(*TranslatedArgs, BoundArch,
+  DeviceOffloadKind, &AllocatedArgs);
+} else {
+  NewDAL = TC->TranslateXarchArgs(*OpenMPArgs, BoundArch, 
DeviceOffloadKind,
+  &AllocatedArgs);
+  if (!NewDAL)
+NewDAL = OpenMPArgs;
+  else
+delete OpenMPArgs;
+}
+
+if (!NewDAL) {
   Entry = TC->TranslateArgs(*TranslatedArgs, BoundArch, DeviceOffloadKind);
   if (!Entry)
 Entry = TranslatedArgs;
 } else {
-  Entry = TC->TranslateArgs(*OpenMPArgs, BoundArch, DeviceOffloadKind);
+  Entry = TC->TranslateArgs(*NewDAL, BoundArch, DeviceOffloadKind);
   if (!Entry)
-Entry = OpenMPArgs;
+Entry = NewDAL;
   else
-delete OpenMPArgs;
+delete NewDAL;
 }
 
 // Add allocated arguments to the final DAL.

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index b1626900318f..b958473e2423 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1103,11 +1103,20 @@ llvm::opt::DerivedArgList 
*ToolChain::TranslateOpenMPT

[clang] 386f95e - [Parser] Fix the assertion crash in ActOnStartOfSwitch stmt.

2020-03-24 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-03-24T15:17:04+01:00
New Revision: 386f95e168b09603595864a5956624792ccb59c4

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

LOG: [Parser] Fix the assertion crash in ActOnStartOfSwitch stmt.

Summary:
After we parse the switch condition, we don't do the type check for
type-dependent expr (e.g. TypoExpr) (in Sema::CheckSwitchCondition), then the
TypoExpr is corrected to an invalid-type expr (in Sema::MakeFullExpr) and passed
to the ActOnStartOfSwitchStmt, which triggers the assertion.

Fix https://github.com/clangd/clangd/issues/311

Reviewers: sammccall

Subscribers: ilya-biryukov, kadircet, usaxena95, cfe-commits

Tags: #clang

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

Added: 
clang/test/Parser/switch-typo-correction.cpp

Modified: 
clang/lib/Sema/SemaStmt.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 2104add400e0..68de776e83e6 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -730,11 +730,11 @@ StmtResult Sema::ActOnStartOfSwitchStmt(SourceLocation 
SwitchLoc,
 
   if (CondExpr && !CondExpr->isTypeDependent()) {
 // We have already converted the expression to an integral or enumeration
-// type, when we parsed the switch condition. If we don't have an
-// appropriate type now, enter the switch scope but remember that it's
-// invalid.
-assert(CondExpr->getType()->isIntegralOrEnumerationType() &&
-   "invalid condition type");
+// type, when we parsed the switch condition. There are cases where we 
don't
+// have an appropriate type, e.g. a typo-expr Cond was corrected to an
+// inappropriate-type expr, we just return an error.
+if (!CondExpr->getType()->isIntegralOrEnumerationType())
+  return StmtError();
 if (CondExpr->isKnownToHaveBooleanValue()) {
   // switch(bool_expr) {...} is often a programmer error, e.g.
   //   switch(n && mask) { ... }  // Doh - should be "n & mask".

diff  --git a/clang/test/Parser/switch-typo-correction.cpp 
b/clang/test/Parser/switch-typo-correction.cpp
new file mode 100644
index ..ebf1c18f2b86
--- /dev/null
+++ b/clang/test/Parser/switch-typo-correction.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace c { double xxx; } // expected-note{{'c::xxx' declared here}}
+namespace d { float xxx; }
+namespace z { namespace xxx {} }
+
+void crash() {
+  switch (xxx) {} // expected-error{{use of undeclared identifier 'xxx'; did 
you mean }}
+}



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


[clang] 10bd842 - [ARM][CMSE] Fix clang/test/Driver/save-temps.c test.

2020-03-24 Thread Alexander Belyaev via cfe-commits

Author: Alexander Belyaev
Date: 2020-03-24T15:24:14+01:00
New Revision: 10bd8422d041e2964c146a38b5514d9d92fc458d

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

LOG: [ARM][CMSE] Fix clang/test/Driver/save-temps.c test.

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

Added: 


Modified: 
clang/test/Driver/save-temps.c

Removed: 




diff  --git a/clang/test/Driver/save-temps.c b/clang/test/Driver/save-temps.c
index ae46f1e6b565..b0cfa4fd814a 100644
--- a/clang/test/Driver/save-temps.c
+++ b/clang/test/Driver/save-temps.c
@@ -83,9 +83,9 @@
 // CHECK-SAVE-TEMPS: "-cc1as"
 // CHECK-SAVE-TEMPS: "-dwarf-version={{.}}"
 
-// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse 
-save-temps -c -v %s 2>&1 \
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse 
-save-temps -c -v %s -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS-CMSE
-// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -x 
assembler -c -v %s 2>&1 \
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -x 
assembler -c -v %s -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS-CMSE
 // CHECK-SAVE-TEMPS-CMSE: -cc1as
 // CHECK-SAVE-TEMPS-CMSE: +8msecext



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


[PATCH] D76688: [AArch64][SVE] Add SVE intrinsics for masked loads & stores

2020-03-24 Thread Cameron McInally via Phabricator via cfe-commits
cameron.mcinally accepted this revision.
cameron.mcinally added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76688



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


[PATCH] D76617: [SveEmitter] Fix encoding/decoding of SVETypeFlags

2020-03-24 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

In D76617#1938787 , @SjoerdMeijer 
wrote:

> Patches with functional changes but without tests are a bit "suspicious".  In 
> this case, I see it might be tricky. You could argue that it should be 
> incorporated in the patch that includes the tests, so we can see what's 
> happening. But perhaps separating this out is cleaner, if the other patch is 
> big. But can you at least make the next patch dependent on this one, so we 
> know where this is used?


Yes you're right, the patch that I've made dependent needs this one to work 
properly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76617



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


[PATCH] D76703: [ARM][CMSE] Fix clang/test/Driver/save-temps.c test.

2020-03-24 Thread Alexander Belyaev via Phabricator via cfe-commits
pifon2a created this revision.
Herald added subscribers: cfe-commits, kristof.beyls.
Herald added a project: clang.
pifon2a added reviewers: bkramer, momchil.velikov.
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

looks good


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76703

Files:
  clang/test/Driver/save-temps.c


Index: clang/test/Driver/save-temps.c
===
--- clang/test/Driver/save-temps.c
+++ clang/test/Driver/save-temps.c
@@ -83,9 +83,9 @@
 // CHECK-SAVE-TEMPS: "-cc1as"
 // CHECK-SAVE-TEMPS: "-dwarf-version={{.}}"
 
-// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse 
-save-temps -c -v %s 2>&1 \
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse 
-save-temps -c -v %s -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS-CMSE
-// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -x 
assembler -c -v %s 2>&1 \
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -x 
assembler -c -v %s -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS-CMSE
 // CHECK-SAVE-TEMPS-CMSE: -cc1as
 // CHECK-SAVE-TEMPS-CMSE: +8msecext


Index: clang/test/Driver/save-temps.c
===
--- clang/test/Driver/save-temps.c
+++ clang/test/Driver/save-temps.c
@@ -83,9 +83,9 @@
 // CHECK-SAVE-TEMPS: "-cc1as"
 // CHECK-SAVE-TEMPS: "-dwarf-version={{.}}"
 
-// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -save-temps -c -v %s 2>&1 \
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -save-temps -c -v %s -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS-CMSE
-// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -x assembler -c -v %s 2>&1 \
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -x assembler -c -v %s -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS-CMSE
 // CHECK-SAVE-TEMPS-CMSE: -cc1as
 // CHECK-SAVE-TEMPS-CMSE: +8msecext
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76703: [ARM][CMSE] Fix clang/test/Driver/save-temps.c test.

2020-03-24 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.
This revision is now accepted and ready to land.

looks good


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76703



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


[PATCH] D76704: Don't normalise CXX11/C2X attribute names to start with ::

2020-03-24 Thread John Brawn via Phabricator via cfe-commits
john.brawn created this revision.
john.brawn added reviewers: erichkeane, aaron.ballman, rjmccall.
Herald added a project: clang.
john.brawn added a child revision: D31343: Add an attribute plugin example.

Currently square-bracket-style (CXX11/C2X) attribute names are normalised to 
start with :: if they don't have a namespace. This is a bit odd, as such names 
are rejected when parsing, so don't do this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76704

Files:
  clang/lib/Basic/Attributes.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3739,10 +3739,8 @@
 for (const auto &S : GetFlattenedSpellings(Attr)) {
   const std::string &RawSpelling = S.name();
   std::string Spelling;
-  if (S.variety() == "CXX11" || S.variety() == "C2x") {
-Spelling += S.nameSpace();
-Spelling += "::";
-  }
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
   if (S.variety() == "GNU")
 Spelling += NormalizeGNUAttrSpelling(RawSpelling);
   else
@@ -3815,12 +3813,12 @@
 const std::string &Variety = S.variety();
 if (Variety == "CXX11") {
   Matches = &CXX11;
-  Spelling += S.nameSpace();
-  Spelling += "::";
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
 } else if (Variety == "C2x") {
   Matches = &C2x;
-  Spelling += S.nameSpace();
-  Spelling += "::";
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
 } else if (Variety == "GNU")
   Matches = &GNU;
 else if (Variety == "Declspec")
Index: clang/lib/Basic/Attributes.cpp
===
--- clang/lib/Basic/Attributes.cpp
+++ clang/lib/Basic/Attributes.cpp
@@ -85,11 +85,8 @@
   StringRef ScopeName = normalizeAttrScopeName(Scope, SyntaxUsed);
   StringRef AttrName = normalizeAttrName(Name, ScopeName, SyntaxUsed);
 
-  // Ensure that in the case of C++11 attributes, we look for '::foo' if it is
-  // unscoped.
   SmallString<64> FullName = ScopeName;
-  if (Scope || SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
-  SyntaxUsed == AttributeCommonInfo::AS_C2x)
+  if (!ScopeName.empty())
 FullName += "::";
   FullName += AttrName;
 


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3739,10 +3739,8 @@
 for (const auto &S : GetFlattenedSpellings(Attr)) {
   const std::string &RawSpelling = S.name();
   std::string Spelling;
-  if (S.variety() == "CXX11" || S.variety() == "C2x") {
-Spelling += S.nameSpace();
-Spelling += "::";
-  }
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
   if (S.variety() == "GNU")
 Spelling += NormalizeGNUAttrSpelling(RawSpelling);
   else
@@ -3815,12 +3813,12 @@
 const std::string &Variety = S.variety();
 if (Variety == "CXX11") {
   Matches = &CXX11;
-  Spelling += S.nameSpace();
-  Spelling += "::";
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
 } else if (Variety == "C2x") {
   Matches = &C2x;
-  Spelling += S.nameSpace();
-  Spelling += "::";
+  if (!S.nameSpace().empty())
+Spelling += S.nameSpace() + "::";
 } else if (Variety == "GNU")
   Matches = &GNU;
 else if (Variety == "Declspec")
Index: clang/lib/Basic/Attributes.cpp
===
--- clang/lib/Basic/Attributes.cpp
+++ clang/lib/Basic/Attributes.cpp
@@ -85,11 +85,8 @@
   StringRef ScopeName = normalizeAttrScopeName(Scope, SyntaxUsed);
   StringRef AttrName = normalizeAttrName(Name, ScopeName, SyntaxUsed);
 
-  // Ensure that in the case of C++11 attributes, we look for '::foo' if it is
-  // unscoped.
   SmallString<64> FullName = ScopeName;
-  if (Scope || SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
-  SyntaxUsed == AttributeCommonInfo::AS_C2x)
+  if (!ScopeName.empty())
 FullName += "::";
   FullName += AttrName;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31343: Add an attribute plugin example

2020-03-24 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 252309.
john.brawn added a comment.

A few small changes:

- Don't start C++11 spelling with :: (changes to name normalisation to allow 
this are in D76704 )
- Don't check that the Decl is null in diagAppertainsToDecl
- Return AttributeNotApplied on errors in handleDeclAttribute


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

https://reviews.llvm.org/D31343

Files:
  clang/docs/ClangPlugins.rst
  clang/examples/Attribute/Attribute.cpp
  clang/examples/Attribute/CMakeLists.txt
  clang/examples/CMakeLists.txt
  clang/test/CMakeLists.txt
  clang/test/Frontend/plugin-attribute.cpp

Index: clang/test/Frontend/plugin-attribute.cpp
===
--- /dev/null
+++ clang/test/Frontend/plugin-attribute.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -S %s -o - 2>&1 | FileCheck %s --check-prefix=ATTRIBUTE
+// RUN: not %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -DBAD_ATTRIBUTE -S %s -o - 2>&1 | FileCheck %s --check-prefix=BADATTRIBUTE
+// REQUIRES: plugins, examples
+
+void fn1a() __attribute__((example)) { }
+[[example]] void fn1b() { }
+[[plugin::example]] void fn1c() { }
+void fn2() __attribute__((example("somestring"))) { }
+// ATTRIBUTE: warning: 'example' attribute only applies to functions
+int var1 __attribute__((example("otherstring"))) = 1;
+
+// ATTRIBUTE: [[STR1_VAR:@.+]] = private unnamed_addr constant [10 x i8] c"example()\00"
+// ATTRIBUTE: [[STR2_VAR:@.+]] = private unnamed_addr constant [20 x i8] c"example(somestring)\00"
+// ATTRIBUTE: @llvm.global.annotations = {{.*}}@{{.*}}fn1a{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1b{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1c{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn2{{.*}}[[STR2_VAR]]
+
+#ifdef BAD_ATTRIBUTE
+class Example {
+  // BADATTRIBUTE: error: 'example' attribute only allowed at file scope
+  void __attribute__((example)) fn3();
+};
+// BADATTRIBUTE: error: 'example' attribute requires a string
+void fn4() __attribute__((example(123))) { }
+// BADATTRIBUTE: error: 'example' attribute takes no more than 1 argument
+void fn5() __attribute__((example("a","b"))) { }
+#endif
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -81,6 +81,7 @@
 
 if (CLANG_BUILD_EXAMPLES)
   list(APPEND CLANG_TEST_DEPS
+Attribute
 AnnotateFunctions
 clang-interpreter
 PrintFunctionNames
Index: clang/examples/CMakeLists.txt
===
--- clang/examples/CMakeLists.txt
+++ clang/examples/CMakeLists.txt
@@ -6,3 +6,4 @@
 add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)
+add_subdirectory(Attribute)
Index: clang/examples/Attribute/CMakeLists.txt
===
--- /dev/null
+++ clang/examples/Attribute/CMakeLists.txt
@@ -0,0 +1,11 @@
+add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  target_link_libraries(AnnotateFunctions ${cmake_2_8_12_PRIVATE}
+clangAST
+clangBasic
+clangFrontend
+clangLex
+LLVMSupport
+)
+endif()
Index: clang/examples/Attribute/Attribute.cpp
===
--- /dev/null
+++ clang/examples/Attribute/Attribute.cpp
@@ -0,0 +1,80 @@
+//===- Attribute.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Example clang plugin which adds an an annotation to file-scope declarations
+// with the 'example' attribute.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Attr.h"
+#include "clang/Sema/ParsedAttr.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaDiagnostic.h"
+#include "llvm/IR/Attributes.h"
+using namespace clang;
+
+namespace {
+
+struct ExampleAttrInfo : public ParsedAttrInfo {
+  ExampleAttrInfo() {
+// Can take an optional string argument (the check that the argument
+// actually is a string happens in handleDeclAttribute).
+OptArgs = 1;
+// GNU-style __attribute__(("example")) and C++-style [[example]] and
+// [[plugin::example]] supported.
+Spellings.push_back({ParsedAttr::AS_GNU, "example"});
+Spellings.push_back({ParsedAttr::AS_CXX11, "example"});
+Spellings.push_back({ParsedAttr::AS_CXX11, "plugin::example"});
+  }
+
+  bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr,
+  

[PATCH] D76592: [Parser] Fix the assertion crash in ActOnStartOfSwitch stmt.

2020-03-24 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG386f95e168b0: [Parser] Fix the assertion crash in 
ActOnStartOfSwitch stmt. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76592

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Parser/switch-typo-correction.cpp


Index: clang/test/Parser/switch-typo-correction.cpp
===
--- /dev/null
+++ clang/test/Parser/switch-typo-correction.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace c { double xxx; } // expected-note{{'c::xxx' declared here}}
+namespace d { float xxx; }
+namespace z { namespace xxx {} }
+
+void crash() {
+  switch (xxx) {} // expected-error{{use of undeclared identifier 'xxx'; did 
you mean }}
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -730,11 +730,11 @@
 
   if (CondExpr && !CondExpr->isTypeDependent()) {
 // We have already converted the expression to an integral or enumeration
-// type, when we parsed the switch condition. If we don't have an
-// appropriate type now, enter the switch scope but remember that it's
-// invalid.
-assert(CondExpr->getType()->isIntegralOrEnumerationType() &&
-   "invalid condition type");
+// type, when we parsed the switch condition. There are cases where we 
don't
+// have an appropriate type, e.g. a typo-expr Cond was corrected to an
+// inappropriate-type expr, we just return an error.
+if (!CondExpr->getType()->isIntegralOrEnumerationType())
+  return StmtError();
 if (CondExpr->isKnownToHaveBooleanValue()) {
   // switch(bool_expr) {...} is often a programmer error, e.g.
   //   switch(n && mask) { ... }  // Doh - should be "n & mask".


Index: clang/test/Parser/switch-typo-correction.cpp
===
--- /dev/null
+++ clang/test/Parser/switch-typo-correction.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+namespace c { double xxx; } // expected-note{{'c::xxx' declared here}}
+namespace d { float xxx; }
+namespace z { namespace xxx {} }
+
+void crash() {
+  switch (xxx) {} // expected-error{{use of undeclared identifier 'xxx'; did you mean }}
+}
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -730,11 +730,11 @@
 
   if (CondExpr && !CondExpr->isTypeDependent()) {
 // We have already converted the expression to an integral or enumeration
-// type, when we parsed the switch condition. If we don't have an
-// appropriate type now, enter the switch scope but remember that it's
-// invalid.
-assert(CondExpr->getType()->isIntegralOrEnumerationType() &&
-   "invalid condition type");
+// type, when we parsed the switch condition. There are cases where we don't
+// have an appropriate type, e.g. a typo-expr Cond was corrected to an
+// inappropriate-type expr, we just return an error.
+if (!CondExpr->getType()->isIntegralOrEnumerationType())
+  return StmtError();
 if (CondExpr->isKnownToHaveBooleanValue()) {
   // switch(bool_expr) {...} is often a programmer error, e.g.
   //   switch(n && mask) { ... }  // Doh - should be "n & mask".
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76703: [ARM][CMSE] Fix clang/test/Driver/save-temps.c test.

2020-03-24 Thread Alexander Belyaev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG10bd8422d041: [ARM][CMSE] Fix clang/test/Driver/save-temps.c 
test. (authored by pifon2a).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76703

Files:
  clang/test/Driver/save-temps.c


Index: clang/test/Driver/save-temps.c
===
--- clang/test/Driver/save-temps.c
+++ clang/test/Driver/save-temps.c
@@ -83,9 +83,9 @@
 // CHECK-SAVE-TEMPS: "-cc1as"
 // CHECK-SAVE-TEMPS: "-dwarf-version={{.}}"
 
-// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse 
-save-temps -c -v %s 2>&1 \
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse 
-save-temps -c -v %s -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS-CMSE
-// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -x 
assembler -c -v %s 2>&1 \
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -x 
assembler -c -v %s -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS-CMSE
 // CHECK-SAVE-TEMPS-CMSE: -cc1as
 // CHECK-SAVE-TEMPS-CMSE: +8msecext


Index: clang/test/Driver/save-temps.c
===
--- clang/test/Driver/save-temps.c
+++ clang/test/Driver/save-temps.c
@@ -83,9 +83,9 @@
 // CHECK-SAVE-TEMPS: "-cc1as"
 // CHECK-SAVE-TEMPS: "-dwarf-version={{.}}"
 
-// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -save-temps -c -v %s 2>&1 \
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -save-temps -c -v %s -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS-CMSE
-// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -x assembler -c -v %s 2>&1 \
+// RUN: %clang --target=arm-arm-none-eabi -march=armv8-m.main -mcmse -x assembler -c -v %s -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS-CMSE
 // CHECK-SAVE-TEMPS-CMSE: -cc1as
 // CHECK-SAVE-TEMPS-CMSE: +8msecext
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76520: [CUDA][HIP] Add -Xarch_device and -Xarch_host options

2020-03-24 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ae25647d1a3: [CUDA][HIP] Add -Xarch_device and -Xarch_host 
options (authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D76520?vs=252105&id=252311#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76520

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-options.hip

Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -13,3 +13,16 @@
 // RUN:   -mllvm -amdgpu-early-inline-all=true  %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=MLLVM %s
 // MLLVM-NOT: "-mllvm"{{.*}}"-amdgpu-early-inline-all=true"{{.*}}"-mllvm"{{.*}}"-amdgpu-early-inline-all=true"
+
+// RUN: %clang -### -Xarch_device -g -nogpulib --cuda-gpu-arch=gfx900 \
+// RUN:   -Xarch_device -fcf-protection=branch \
+// RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=DEV %s
+// DEV: clang{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" {{.*}} "-fcf-protection=branch"
+// DEV: clang{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" {{.*}} "-fcf-protection=branch"
+// DEV-NOT: clang{{.*}} {{.*}} "-debug-info-kind={{.*}}"
+
+// RUN: %clang -### -Xarch_host -g -nogpulib --cuda-gpu-arch=gfx900 \
+// RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=HOST %s
+// HOST-NOT: clang{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}"
+// HOST-NOT: clang{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}"
+// HOST: clang{{.*}} "-debug-info-kind={{.*}}"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -378,12 +378,6 @@
   const OptTable &Opts = getDriver().getOpts();
 
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_Xarch__)) {
-  // Skip this argument unless the architecture matches BoundArch.
-  if (BoundArch.empty() || A->getValue(0) != BoundArch)
-continue;
-  TranslateXarchArgs(Args, A, DAL);
-}
 DAL->append(A);
   }
 
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -800,12 +800,6 @@
   }
 
   for (Arg *A : Args) {
-if (A->getOption().matches(options::OPT_Xarch__)) {
-  // Skip this argument unless the architecture matches BoundArch
-  if (BoundArch.empty() || A->getValue(0) != BoundArch)
-continue;
-  TranslateXarchArgs(Args, A, DAL);
-}
 DAL->append(A);
   }
 
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -1103,11 +1103,20 @@
   return nullptr;
 }
 
-void ToolChain::TranslateXarchArgs(const llvm::opt::DerivedArgList &Args,
-   llvm::opt::Arg *&A,
-   llvm::opt::DerivedArgList *DAL) const {
+// TODO: Currently argument values separated by space e.g.
+// -Xclang -mframe-pointer=no cannot be passed by -Xarch_. This should be
+// fixed.
+void ToolChain::TranslateXarchArgs(
+const llvm::opt::DerivedArgList &Args, llvm::opt::Arg *&A,
+llvm::opt::DerivedArgList *DAL,
+SmallVectorImpl *AllocatedArgs) const {
   const OptTable &Opts = getDriver().getOpts();
-  unsigned Index = Args.getBaseArgs().MakeIndex(A->getValue(1));
+  unsigned ValuePos = 1;
+  if (A->getOption().matches(options::OPT_Xarch_device) ||
+  A->getOption().matches(options::OPT_Xarch_host))
+ValuePos = 0;
+
+  unsigned Index = Args.getBaseArgs().MakeIndex(A->getValue(ValuePos));
   unsigned Prev = Index;
   std::unique_ptr XarchArg(Opts.ParseOneArg(Args, Index));
 
@@ -1130,5 +1139,49 @@
   }
   XarchArg->setBaseArg(A);
   A = XarchArg.release();
-  DAL->AddSynthesizedArg(A);
+  if (!AllocatedArgs)
+DAL->AddSynthesizedArg(A);
+  else
+AllocatedArgs->push_back(A);
+}
+
+llvm::opt::DerivedArgList *ToolChain::TranslateXarchArgs(
+const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
+Action::OffloadKind OFK,
+SmallVectorImpl *AllocatedArgs) const {
+  DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
+  bool Modified = false;
+
+  bool IsGPU = OFK == Action::OFK_Cuda || OFK == Action::OFK_HIP;
+  for (Arg *A : Args) {
+bool NeedTrans = false;
+bool Skip = false;
+if (A->getOption().matches(options::OPT_Xarch_device)) {
+  NeedTrans = IsGPU;
+   

[PATCH] D76696: [AST] Build recovery expressions by default for C++.

2020-03-24 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 252320.
hokein added a comment.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous.

fix the clangd test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76696

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp
  clang/test/Parser/objcxx0x-lambda-expressions.mm
  clang/test/Parser/objcxx11-invalid-lambda.cpp
  clang/test/SemaCXX/builtins.cpp
  clang/test/SemaCXX/cast-conversion.cpp
  clang/test/SemaCXX/cxx1z-copy-omission.cpp
  clang/test/SemaCXX/decltype-crash.cpp
  clang/test/SemaCXX/varargs.cpp
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaTemplate/instantiate-init.cpp
  clang/unittests/Sema/CodeCompleteTest.cpp

Index: clang/unittests/Sema/CodeCompleteTest.cpp
===
--- clang/unittests/Sema/CodeCompleteTest.cpp
+++ clang/unittests/Sema/CodeCompleteTest.cpp
@@ -487,6 +487,7 @@
 auto x = decltype(&1)(^);
 auto y = new decltype(&1)(^);
   )cpp";
-  EXPECT_THAT(collectPreferredTypes(Code), Each("NULL TYPE"));
+  EXPECT_THAT(collectPreferredTypes(Code),
+  Each("decltype((1))"));
 }
 } // namespace
Index: clang/test/SemaTemplate/instantiate-init.cpp
===
--- clang/test/SemaTemplate/instantiate-init.cpp
+++ clang/test/SemaTemplate/instantiate-init.cpp
@@ -100,7 +100,7 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
   Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
   ));
 
Index: clang/test/SemaOpenCLCXX/address-space-references.cl
===
--- clang/test/SemaOpenCLCXX/address-space-references.cl
+++ clang/test/SemaOpenCLCXX/address-space-references.cl
@@ -11,7 +11,7 @@
 int bar(const unsigned int &i);
 
 void foo() {
-  bar(1) // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
+  bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
 }
 
 // Test addr space conversion with nested pointers
Index: clang/test/SemaCXX/varargs.cpp
===
--- clang/test/SemaCXX/varargs.cpp
+++ clang/test/SemaCXX/varargs.cpp
@@ -22,7 +22,8 @@
 // default ctor.
 void record_context(int a, ...) {
   struct Foo {
-// expected-error@+1 {{'va_start' cannot be used outside a function}}
+// expected-error@+2 {{'va_start' cannot be used outside a function}}
+// expected-error@+1 {{default argument references parameter 'a'}}
 void meth(int a, int b = (__builtin_va_start(ap, a), 0)) {}
   };
 }
Index: clang/test/SemaCXX/decltype-crash.cpp
===
--- clang/test/SemaCXX/decltype-crash.cpp
+++ clang/test/SemaCXX/decltype-crash.cpp
@@ -3,5 +3,8 @@
 int& a();
 
 void f() {
-  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} expected-error {{use of undeclared identifier 'decltype'}}
+  decltype(a()) c; // expected-warning {{'decltype' is a keyword in C++11}} \
+   // expected-error {{use of undeclared identifier 'decltype'}} \
+   // expected-error {{expected ';' after expression}} \
+   // expected-error {{use of undeclared identifier 'c'}}
 }
Index: clang/test/SemaCXX/cxx1z-copy-omission.cpp
===
--- clang/test/SemaCXX/cxx1z-copy-omission.cpp
+++ clang/test/SemaCXX/cxx1z-copy-omission.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++1z -verify %s
+// RUN: %clang_cc1 -std=c++1z -verify -Wno-unused %s
 
 struct Noncopyable {
   Noncopyable();
@@ -107,8 +107,10 @@
   sizeof(make_indestructible()); // expected-error {{deleted}}
   sizeof(make_incomplete()); // expected-error {{incomplete}}
   typeid(Indestructible{}); // expected-error {{deleted}}
-  typeid(make_indestructible()); // expected-error {{deleted}}
-  typeid(make_incomplete()); // expected-error {{incomplete}}
+  typeid(make_indestructible()); // expected-error {{deleted}} \
+ // expected-error {{need to include }}
+  typeid(make_incomplete()); // expected-error {{incomplete}} \
+ // expected-error {{need to i

[PATCH] D76620: [SYCL] Implement __builtin_unique_stable_name.

2020-03-24 Thread Alexey Bader via Phabricator via cfe-commits
bader accepted this revision.
bader added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D76620



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


[PATCH] D76360: [PPC][AIX] Emit correct Vaarg for 32BIT-AIX in clang

2020-03-24 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 252325.
ZarkoCA marked 2 inline comments as done.
ZarkoCA added a comment.

Renamed PPC32_SVR4ABIInfo class to PPC32ABIInfo.
Fixed test case to use builtins.
Changed comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76360

Files:
  clang/lib/Basic/Targets/PPC.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aix-vararg.c

Index: clang/test/CodeGen/aix-vararg.c
===
--- /dev/null
+++ clang/test/CodeGen/aix-vararg.c
@@ -0,0 +1,39 @@
+// REQUIRES: powerpc-registered-target
+// REQUIRES: asserts
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm -o - %s | FileCheck %s --check-prefix=32BIT
+//
+void aix_varg(int a, ...) {
+  __builtin_va_list arg;
+  __builtin_va_start(arg, a);
+  __builtin_va_list arg2;
+  __builtin_va_arg(arg, int);
+  __builtin_va_copy(arg2, arg);
+  __builtin_va_end(arg);
+  __builtin_va_end(arg2);
+}
+
+// 32BIT:   define void @aix_varg(i32 %a, ...) #0 {
+// 32BIT-NEXT:  entry:
+// 32BIT-NEXT:%a.addr = alloca i32, align 4
+// 32BIT-NEXT:%arg = alloca i8*, align 4
+// 32BIT-NEXT:%arg2 = alloca i8*, align 4
+// 32BIT-NEXT:store i32 %a, i32* %a.addr, align 4
+// 32BIT-NEXT:%arg1 = bitcast i8** %arg to i8*
+// 32BIT-NEXT:call void @llvm.va_start(i8* %arg1)
+// 32BIT-NEXT:%argp.cur = load i8*, i8** %arg, align 4
+// 32BIT-NEXT:%argp.next = getelementptr inbounds i8, i8* %argp.cur, i32 4
+// 32BIT-NEXT:store i8* %argp.next, i8** %arg, align 4
+// 32BIT-NEXT:%0 = bitcast i8* %argp.cur to i32*
+// 32BIT-NEXT:%1 = load i32, i32* %0, align 4
+// 32BIT-NEXT:%2 = bitcast i8** %arg2 to i8*
+// 32BIT-NEXT:%3 = bitcast i8** %arg to i8*
+// 32BIT-NEXT:call void @llvm.va_copy(i8* %2, i8* %3)
+// 32BIT-NEXT:%arg3 = bitcast i8** %arg to i8*
+// 32BIT-NEXT:call void @llvm.va_end(i8* %arg3)
+// 32BIT-NEXT:%arg24 = bitcast i8** %arg2 to i8*
+// 32BIT-NEXT:call void @llvm.va_end(i8* %arg24)
+// 32BIT-NEXT:ret void
+// 32BIT-NEXT:  }
+// 32BIT: declare void @llvm.va_start(i8*) #1
+// 32BIT: declare void @llvm.va_copy(i8*, i8*) #1
+// 32BIT: declare void @llvm.va_end(i8*) #1
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -4172,14 +4172,15 @@
 
 // PowerPC-32
 namespace {
-/// PPC32_SVR4_ABIInfo - The 32-bit PowerPC ELF (SVR4) ABI information.
-class PPC32_SVR4_ABIInfo : public DefaultABIInfo {
+/// PowerPC32ABIInfo - The 32-bit PowerPC ABI information, used by PowerPC ELF
+/// (SVR4), Darwin, and AIX.
+class PowerPC32ABIInfo : public DefaultABIInfo {
   bool IsSoftFloatABI;
 
   CharUnits getParamTypeAlignment(QualType Ty) const;
 
 public:
-  PPC32_SVR4_ABIInfo(CodeGen::CodeGenTypes &CGT, bool SoftFloatABI)
+  PowerPC32ABIInfo(CodeGen::CodeGenTypes &CGT, bool SoftFloatABI)
   : DefaultABIInfo(CGT), IsSoftFloatABI(SoftFloatABI) {}
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
@@ -4189,7 +4190,7 @@
 class PPC32TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   PPC32TargetCodeGenInfo(CodeGenTypes &CGT, bool SoftFloatABI)
-  : TargetCodeGenInfo(new PPC32_SVR4_ABIInfo(CGT, SoftFloatABI)) {}
+  : TargetCodeGenInfo(new PowerPC32ABIInfo(CGT, SoftFloatABI)) {}
 
   int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
 // This is recovered from gcc output.
@@ -4201,7 +4202,7 @@
 };
 }
 
-CharUnits PPC32_SVR4_ABIInfo::getParamTypeAlignment(QualType Ty) const {
+CharUnits PowerPC32ABIInfo::getParamTypeAlignment(QualType Ty) const {
   // Complex types are passed just like their elements
   if (const ComplexType *CTy = Ty->getAs())
 Ty = CTy->getElementType();
@@ -4227,9 +4228,12 @@
 
 // TODO: this implementation is now likely redundant with
 // DefaultABIInfo::EmitVAArg.
-Address PPC32_SVR4_ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAList,
+Address PowerPC32ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAList,
   QualType Ty) const {
-  if (getTarget().getTriple().isOSDarwin()) {
+  // TODO: Add AIX ABI Info. Currently, we are relying on PowerPC32ABIInfo to
+  // emit correct VAArg.
+  if (getTarget().getTriple().isOSDarwin() ||
+  getTarget().getTriple().isOSAIX()) {
 auto TI = getContext().getTypeInfoInChars(Ty);
 TI.second = getParamTypeAlignment(Ty);
 
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -369,7 +369,8 @@
   }
 
   BuiltinVaListKind getBuiltinVaListKind() const override {
-// This is the ELF definition, and is overridden by the Darwin sub-target
+// This is the ELF definition, and is overridden by the Darwin an

[PATCH] D76360: [PPC][AIX] Emit correct Vaarg for 32BIT-AIX in clang

2020-03-24 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA marked 6 inline comments as done.
ZarkoCA added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:4175
 namespace {
 /// PPC32_SVR4_ABIInfo - The 32-bit PowerPC ELF (SVR4) ABI information.
 class PPC32_SVR4_ABIInfo : public DefaultABIInfo {

sfertile wrote:
> ZarkoCA wrote:
> > sfertile wrote:
> > > This name and comment is misleading, the class is used for both SVR4 and 
> > > Darwin, and after this patch AIX. We need to fix the name comment to 
> > > reflect that.
> > Does this wording of the comment work? 
> Missed updating the class name. Suggested: `PPC32_SVR4_ABIInfo` --> 
> `PowerPC32ABIInfo`.
Sorry, missed updating the class name the first time.  



Comment at: clang/test/CodeGen/aix-vararg.c:4
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -emit-llvm -o - %s | 
FileCheck %s --check-prefix=32BIT
+#include 
+

hubert.reinterpretcast wrote:
> ZarkoCA wrote:
> > hubert.reinterpretcast wrote:
> > > Can we use built-in types and functions in place of a header inclusion?
> > I'm worried about legal/copyright issues with using contents from AIX 
> > system headers to LLVM testcases. But I can do that for sure once I 
> > understand what I am allowed to do.   
> I just mean:
> `__builtin_va_list`
> `__builtin_va_start`
> `__builtin_va_copy`
> `__builtin_va_arg`
> `__builtin_va_end`
> 
Thanks, I wasn't clear.  Done as that now. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76360



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


[PATCH] D76620: [SYCL] Implement __builtin_unique_stable_name.

2020-03-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D76620#1939224 , @bader wrote:

> LGTM. Thanks!


Thanks! I'll give this 24 hrs for other comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D76620



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


[PATCH] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Does anyone have any comments for me?  This is blocking using pipes on windows 
targets.


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

https://reviews.llvm.org/D75685



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


[PATCH] D76582: [Hexagon] Don't clear libpath when target is linux-musl

2020-03-24 Thread Brian Cain via Phabricator via cfe-commits
bcain added a comment.

Seems like we might want a new test case for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76582



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


[PATCH] D71524: [analyzer] Support tainted objects in GenericTaintChecker

2020-03-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.
Herald added a subscriber: ASDenysPetrov.

In D71524#1924508 , @steakhal wrote:

> I think `CallDescription` can only identify objects/functions which has 
> `IdefntifyerInfo` in them. AFAIK operators don't have such. Though somehow 
> AST matchers of Clang Tidy were triggered with this: 
> `functionDecl(hasName("operator>>"))`


Yup, we could make improvements on `CallDescription` as well :)

> I'm afraid it needs to be a different patch to replace with 
> `CallDescriptionMap`, even though I agree with you.

I don't mean to deploy the map in this patch, but if this lands as-is, the 
proposed logic will have to be revisited again.


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

https://reviews.llvm.org/D71524



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


[PATCH] D63279: [Analyzer] Unroll for-loops where the upper boundary is a variable with know value

2020-03-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.
Herald added a subscriber: ASDenysPetrov.

(note: I forgot to submit this a couple weeks ago)

LLVM is crashing on me due to the issue mentioned in D75678 
, but on Bitcoin, Xerces, CppCheck and Rtags I 
observed no difference in between the 2 runs. I recall that others mentioned 
that @szepet used to run his analyses with other configurations. I'll read 
final report and take another look later.

http://lists.llvm.org/pipermail/cfe-dev/2017-August/055259.html


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

https://reviews.llvm.org/D63279



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


[PATCH] D75677: [Analyzer] Only add iterator note tags to the operations of the affected iterators

2020-03-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp:541-542
+BR.markInteresting(It1);
+if (const auto &LCV1 = It1.getAs()) {
+  BR.markInteresting(LCV1->getRegion());
+}

NoQ wrote:
> baloghadamsoftware wrote:
> > NoQ wrote:
> > > I'm opposed to this code for the same reason that i'm opposed to it in 
> > > the debug checker. Parent region is an undocumented implementation detail 
> > > of `RegionStore`. It is supposed to be immaterial to the user. You should 
> > > not rely on its exact value.
> > > 
> > > @baloghadamsoftware Can we eliminate all such code from iterator checkers 
> > > and instead identify all iterators by regions in which they're stored? 
> > > Does my improved C++ support help with this anyhow whenever it kicks in?
> > How to find the region where it is stored? I am open to find better 
> > solutions, but it was the only one I could find so far. If we ignore 
> > `LazyCompoundVal` then everything falls apart, we can remove all the 
> > iterator-related checkers.
> It's the region from which you loaded it. If you obtained it as 
> `Call.getArgSVal()` then it's the parameter region for the call. If you 
> obtained it as `Call.getReturnValue()` then it's the target region can be 
> obtained by looking at the //construction context// for the call.
`LazyCompoundVal` and friends seem to be a constantly emerging headache for 
almost everyone. For how long I've spent in the analyzer, and have religiously 
studied conversations and your workbook about it, I still feel anxious whenever 
it comes up.

It would be great to have this documented in the code sometime.



Comment at: clang/test/Analysis/iterator-modelling.cpp:169
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // 
expected-warning{{TRUE}}
 // 
expected-note@-1{{TRUE}}

baloghadamsoftware wrote:
> Szelethus wrote:
> > Interestingness won't be propagated here because 
> > `clang_analyzer_iterator_container(i2) == &v` is interesting, not 
> > `clang_analyzer_iterator_container(i2)`, correct?
> Currently only `clang_analyzer_express()` marks its argument as interesting. 
> This could be extended in the future, however the argument of 
> `clang_analyzer_eval()` is usually the result of the comparison, not the 
> symbolic comparison itself so the sides of the comparison are not reachable 
> at that point.
Fair enough.


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

https://reviews.llvm.org/D75677



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


[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

2020-03-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D75682#1931108 , @balazske wrote:

> Adding special test functions is not as easy, then `StreamState` should be 
> accessible from another checker. It could be added to the same file, or new 
> file but then moving the data structures into header is needed.


For the time being, I don't fancy the idea of moving code to a header file.

> At least for short-term it is more simple to add a stream function that 
> generates error state (`fseek` is applicable or other). This is why the 
> `fseek` patch is better to be included in this change (but makes it more 
> complicated). Otherwise this revision must be added without tests for state 
> observer functions.

It seems like D75356  should have been the 
revision to finish, after all :^). I agree -- don't worry about bloating the 
patch a bit, I've spend a lot of time with your patches, I feel confident in my 
ability at this point to be able to thoroughly review it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682



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


[PATCH] D76604: [Analyzer] Model `size()` member function of containers

2020-03-24 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp:456
+   SVal RetVal) const {
+  const auto *ContReg = Cont.getAsRegion();
+  if (!ContReg)

martong wrote:
> Just out of curiosity: How do we handle containers that do not have a 
> contiguous memory region? Balanced trees, bucketed hash-maps, etc.
I suspect that this is referring to the memory address of the container object, 
not the storage of the elements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76604



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


[PATCH] D63279: [Analyzer] Unroll for-loops where the upper boundary is a variable with know value

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

In D63279#1939349 , @Szelethus wrote:

> (note: I forgot to submit this a couple weeks ago)
>
> LLVM is crashing on me due to the issue mentioned in D75678 
> , but on Bitcoin, Xerces, CppCheck and Rtags 
> I observed no difference in between the 2 runs. I recall that others 
> mentioned that @szepet used to run his analyses with other configurations. 
> I'll read final report and take another look later.
>
> http://lists.llvm.org/pipermail/cfe-dev/2017-August/055259.html


You mean no difference in the reports? It is very unlikely to get lucky and 
gain/loose reports. Peter used to check the statistics emitted by the analyzer 
such as basic block coverage.


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

https://reviews.llvm.org/D63279



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


[PATCH] D74144: [OPENMP50]Add basic support for array-shaping operation.

2020-03-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

Ping 7


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74144



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


[PATCH] D76696: [AST] Build recovery expressions by default for C++.

2020-03-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Do you also want to update LangOpts.td to make the default for the langopt 
equal to CPlusPlus?
(I saw other opts doing that, not sure exactly what it affects, may be voodoo 
cargo cult stuff)




Comment at: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp:1198
 #define ID(X) X
-  ID(foo $p^( foo(10), ^ ))
+  ID(foo $p^( 10, ^ ))
 })cpp"};

Why did the original test start failing? Is this a regression?

(This certainly seems OK to regress and fix later, but there may be other 
consequences?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76696



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


[PATCH] D70411: [analyzer] CERT: STR31-C

2020-03-24 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:803
+
+} // end "cert.str"
+

NoQ wrote:
> `alpha.cert.str`.
This text may be hard to understand. The option means "if it is off, the 
problem report happens only if there is no hand-written null termination of the 
string"? I looked at the CERT rule but did not find out why is null termination 
by hand important here. (I did not look at the code to find out what it does.) 
And "WarnOnCall" suggests that there is warning made on calls if on, or not at 
all or at other location if off, is this correct?



Comment at: clang/lib/StaticAnalyzer/Checkers/AllocationState.h:28
 
+/// \returns The MallocBugVisitor.
+std::unique_ptr getMallocBRVisitor(SymbolRef Sym);

This documentation could be improved or left out.



Comment at: clang/test/Analysis/cert/str31-c-notes-warn-on-call-off.cpp:68
+
+  do_something(dest);
+  // expected-warning@-1 {{'dest' is not null-terminated}}

Maybe I have wrong expectations about what this checker does but did understand 
it correctly yet. The main problem here is that `dest` may be not large enough 
(if size of `src` is not known). This would be a better text for the error 
message? And if this happens (the write outside) it is already a fatal error, 
can cause crash. If no buffer overflow happens the terminating zero is copied 
from `src`, so why would `dst` be not null terminated?


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] D76447: Apply ConstantEvaluated evaluation contexts to more manifestly constant evaluated scopes

2020-03-24 Thread Wyatt Childers via Phabricator via cfe-commits
wchilders updated this revision to Diff 252357.
wchilders added a comment.

Updated the patch to correct formatting issues, and removed application of the 
`ConstantEvaluated` evaluation context to var decls as it introduces too much 
complexity.

Additionally removed a fix for `decltype` with immediate functions that snuck 
into this patch. This will be submitted separately.


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

https://reviews.llvm.org/D76447

Files:
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h


Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -12169,7 +12169,9 @@
   // FIXME: Sema's lambda-building mechanism expects us to push an expression
   // evaluation context even if we're not transforming the function body.
   getSema().PushExpressionEvaluationContext(
-  Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
+  E->getCallOperator()->getConstexprKind() == CSK_consteval
+  ? Sema::ExpressionEvaluationContext::ConstantEvaluated
+  : Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
 
   // Instantiate the body of the lambda expression.
   StmtResult Body =
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4644,7 +4644,9 @@
   Function->setInnerLocStart(PatternDecl->getInnerLocStart());
 
   EnterExpressionEvaluationContext EvalContext(
-  *this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
+  *this, PatternDecl->getConstexprKind() == CSK_consteval
+ ? Sema::ExpressionEvaluationContext::ConstantEvaluated
+ : Sema::ExpressionEvaluationContext::PotentiallyEvaluated);
 
   // Introduce a new scope where local variable instantiations will be
   // recorded, unless we're actually a member function within a local
@@ -4947,8 +4949,13 @@
 Var->setImplicitlyInline();
 
   if (OldVar->getInit()) {
+bool IsConstexpr = OldVar->isConstexpr() || isConstantEvaluated();
 EnterExpressionEvaluationContext Evaluated(
-*this, Sema::ExpressionEvaluationContext::PotentiallyEvaluated, Var);
+*this,
+getLangOpts().CPlusPlus2a && IsConstexpr
+? Sema::ExpressionEvaluationContext::ConstantEvaluated
+: Sema::ExpressionEvaluationContext::PotentiallyEvaluated,
+Var);
 
 // Instantiate the initializer.
 ExprResult Init;
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -1329,10 +1329,19 @@
   // Parse the condition.
   StmtResult InitStmt;
   Sema::ConditionResult Cond;
-  if (ParseParenExprOrCondition(&InitStmt, Cond, IfLoc,
-IsConstexpr ? Sema::ConditionKind::ConstexprIf
-: Sema::ConditionKind::Boolean))
-return StmtError();
+
+  {
+EnterExpressionEvaluationContext Unevaluated(
+Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated,
+/*LambdaContextDecl=*/nullptr, /*ExprContext=*/
+Sema::ExpressionEvaluationContextRecord::EK_Other,
+/*ShouldEnter=*/IsConstexpr);
+
+if (ParseParenExprOrCondition(&InitStmt, Cond, IfLoc,
+  IsConstexpr ? 
Sema::ConditionKind::ConstexprIf
+  : Sema::ConditionKind::Boolean))
+  return StmtError();
+  }
 
   llvm::Optional ConstexprCondition;
   if (IsConstexpr)
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -2974,11 +2974,20 @@
 /// be a constant-expression.
 ExprResult Parser::ParseCXXMemberInitializer(Decl *D, bool IsFunction,
  SourceLocation &EqualLoc) {
+  using EEC = Sema::ExpressionEvaluationContext;
+
   assert(Tok.isOneOf(tok::equal, tok::l_brace)
  && "Data member initializer not starting with '=' or '{'");
 
+  bool IsConstexpr = false;
+  if (auto *VD = dyn_cast_or_null(D))
+IsConstexpr = VD->isConstexpr();
+
   EnterExpressionEvaluationContext Context(
-  Actions, Sema::ExpressionEvaluationContext::PotentiallyEvaluated, D);
+  Actions,
+  getLangOpts().CPlusPlus2a && IsConstexpr ? EEC::ConstantEvaluated
+   : EEC::PotentiallyEvaluated,
+  D);
   if (TryConsumeToken(tok::equal, EqualLoc)) {
 if (Tok.is(tok::kw_delete)) {
   // In principle, an initializer of '= delete p;' is legal, but it will


Index: clang

[PATCH] D76714: [ARM,MVE] Add missing tests for vqdmlash intrinsics.

2020-03-24 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham created this revision.
simon_tatham added a reviewer: miyuki.
Herald added subscribers: cfe-commits, dmgreen, kristof.beyls.
Herald added a project: clang.

These were accidentally left out of D76123 . I 
added tests for the
other three instructions in this small cross-product family (vqdmlah,
vqrdmlah, vqrdmlash) but missed this one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76714

Files:
  clang/test/CodeGen/arm-mve-intrinsics/ternary.c
  llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll
===
--- llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/ternary.ll
@@ -295,6 +295,38 @@
   ret <4 x i32> %0
 }
 
+define arm_aapcs_vfpcc <16 x i8> @test_vqdmlashq_n_s8(<16 x i8> %m1, <16 x i8> %m2, i8 signext %add) {
+; CHECK-LABEL: test_vqdmlashq_n_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmlash.s8 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i8 %add to i32
+  %1 = tail call <16 x i8> @llvm.arm.mve.vqdmlash.v16i8(<16 x i8> %m1, <16 x i8> %m2, i32 %0)
+  ret <16 x i8> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vqdmlashq_n_s16(<8 x i16> %m1, <8 x i16> %m2, i16 signext %add) {
+; CHECK-LABEL: test_vqdmlashq_n_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmlash.s16 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %add to i32
+  %1 = tail call <8 x i16> @llvm.arm.mve.vqdmlash.v8i16(<8 x i16> %m1, <8 x i16> %m2, i32 %0)
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vqdmlashq_n_s32(<4 x i32> %m1, <4 x i32> %m2, i32 %add) {
+; CHECK-LABEL: test_vqdmlashq_n_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vqdmlash.s32 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vqdmlash.v4i32(<4 x i32> %m1, <4 x i32> %m2, i32 %add)
+  ret <4 x i32> %0
+}
+
 define arm_aapcs_vfpcc <16 x i8> @test_vqrdmlahq_n_s8(<16 x i8> %a, <16 x i8> %b, i8 signext %c) {
 ; CHECK-LABEL: test_vqrdmlahq_n_s8:
 ; CHECK:   @ %bb.0: @ %entry
@@ -711,6 +743,50 @@
   ret <4 x i32> %2
 }
 
+define arm_aapcs_vfpcc <16 x i8> @test_vqdmlashq_m_n_s8(<16 x i8> %m1, <16 x i8> %m2, i8 signext %add, i16 zeroext %p) {
+; CHECK-LABEL: test_vqdmlashq_m_n_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vqdmlasht.s8 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i8 %add to i32
+  %1 = zext i16 %p to i32
+  %2 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %1)
+  %3 = tail call <16 x i8> @llvm.arm.mve.vqdmlash.predicated.v16i8.v16i1(<16 x i8> %m1, <16 x i8> %m2, i32 %0, <16 x i1> %2)
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vqdmlashq_m_n_s16(<8 x i16> %m1, <8 x i16> %m2, i16 signext %add, i16 zeroext %p) {
+; CHECK-LABEL: test_vqdmlashq_m_n_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vqdmlasht.s16 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %add to i32
+  %1 = zext i16 %p to i32
+  %2 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %1)
+  %3 = tail call <8 x i16> @llvm.arm.mve.vqdmlash.predicated.v8i16.v8i1(<8 x i16> %m1, <8 x i16> %m2, i32 %0, <8 x i1> %2)
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vqdmlashq_m_n_s32(<4 x i32> %m1, <4 x i32> %m2, i32 %add, i16 zeroext %p) {
+; CHECK-LABEL: test_vqdmlashq_m_n_s32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vqdmlasht.s32 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = tail call <4 x i32> @llvm.arm.mve.vqdmlash.predicated.v4i32.v4i1(<4 x i32> %m1, <4 x i32> %m2, i32 %add, <4 x i1> %1)
+  ret <4 x i32> %2
+}
+
 define arm_aapcs_vfpcc <16 x i8> @test_vqrdmlahq_m_n_s8(<16 x i8> %a, <16 x i8> %b, i8 signext %c, i16 zeroext %p) {
 ; CHECK-LABEL: test_vqrdmlahq_m_n_s8:
 ; CHECK:   @ %bb.0: @ %entry
@@ -816,6 +892,9 @@
 declare <16 x i8> @llvm.arm.mve.vqdmlah.v16i8(<16 x i8>, <16 x i8>, i32)
 declare <8 x i16> @llvm.arm.mve.vqdmlah.v8i16(<8 x i16>, <8 x i16>, i32)
 declare <4 x i32> @llvm.arm.mve.vqdmlah.v4i32(<4 x i32>, <4 x i32>, i32)
+declare <16 x i8> @llvm.arm.mve.vqdmlash.v16i8(<16 x i8>, <16 x i8>, i32)
+declare <8 x i16> @llvm.arm.mve.vqdmlash.v8i16(<8 x i16>, <8 x i16>, i32)
+declare <4 x i32> @llvm.arm.mve.vqdmlash.v4i32(<4 x i32>, <4 x i32>, i32)
 declare <16 x i8> @llvm.arm.mve.vqrdmlah.v16i8(<16 x i8>, <16 x i8>, i32)
 declare <8 x i16> @llvm.arm.mve.vqrdmlah.v8i16(<8 x i16>, <8 x i16>, i32)
 declare <4 x i32> @llvm.arm.mve.vqrdmlah.v4i32(<4 x i32>, <4 x i32>, i32)
@@ -825,6 +904,9 @@
 declare <16 x i8> @llvm.arm.mve.vqdmlah.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, i32, <16 x i1>)
 declare <8 x i16>

[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-03-24 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 252364.
baloghadamsoftware added a comment.

Updated according to a comment.


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

https://reviews.llvm.org/D73720

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/test/Analysis/container-modeling.cpp
  clang/test/Analysis/iterator-range.cpp

Index: clang/test/Analysis/iterator-range.cpp
===
--- clang/test/Analysis/iterator-range.cpp
+++ clang/test/Analysis/iterator-range.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false %s -verify
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=false -analyzer-output=text %s -verify
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-config aggressive-binary-operation-simplification=true -analyzer-config c++-container-inlining=true -DINLINE=1 -analyzer-output=text %s -verify
 
 #include "Inputs/system-header-simulator-cxx.h"
 
@@ -32,6 +32,7 @@
 void deref_end(const std::vector &V) {
   auto i = V.end();
   *i; // expected-warning{{Past-the-end iterator dereferenced}}
+  // expected-note@-1{{Past-the-end iterator dereferenced}}
 }
 
 // Prefix increment - operator++()
@@ -59,6 +60,7 @@
 void incr_end(const std::vector &V) {
   auto i = V.end();
   ++i; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Postfix increment - operator++(int)
@@ -86,6 +88,7 @@
 void end_incr(const std::vector &V) {
   auto i = V.end();
   i++; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+   // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Prefix decrement - operator--()
@@ -93,6 +96,7 @@
 void decr_begin(const std::vector &V) {
   auto i = V.begin();
   --i; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_behind_begin(const std::vector &V) {
@@ -120,6 +124,7 @@
 void begin_decr(const std::vector &V) {
   auto i = V.begin();
   i--; // expected-warning{{Iterator decremented ahead of its valid range}}
+   // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void behind_begin_decr(const std::vector &V) {
@@ -168,11 +173,13 @@
 void incr_by_2_ahead_of_end(const std::vector &V) {
   auto i = --V.end();
   i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 void incr_by_2_end(const std::vector &V) {
   auto i = V.end();
   i += 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Addition - operator+(int)
@@ -201,11 +208,13 @@
 void incr_by_2_copy_ahead_of_end(const std::vector &V) {
   auto i = --V.end();
   auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 void incr_by_2_copy_end(const std::vector &V) {
   auto i = V.end();
   auto j = i + 2; // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+  // expected-note@-1{{Iterator incremented behind the past-the-end iterator}}
 }
 
 // Subtraction assignment - operator-=(int)
@@ -213,11 +222,13 @@
 void decr_by_2_begin(const std::vector &V) {
   auto i = V.begin();
   i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_by_2_behind_begin(const std::vector &V) {
   auto i = ++V.begin();
   i -= 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+  // expected-note@-1{{Iterator decremented ahead of its valid range}}
 }
 
 void decr_by_2_behind_begin_by_2(const std::vector &V) {
@@ -246,11 +257,13 @@
 void decr_by_2_copy_begin(const std::vector &V) {
   auto i = V.begin();
   auto j = i - 2; // expected-warning{{Iterator decremented ahead of its valid range}}
+ 

[PATCH] D73720: [Analyzer] Use note tags to track container begin and and changes

2020-03-24 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp:713
+  StringRef Name;
+  if (const auto *DRE = dyn_cast(ContE->IgnoreParenCasts())) {
+Name = DRE->getDecl()->getName();

NoQ wrote:
> NoQ wrote:
> > baloghadamsoftware wrote:
> > > baloghadamsoftware wrote:
> > > > NoQ wrote:
> > > > > Hmm, i think you should instead look at `ContReg`, i.e. whether it's 
> > > > > a non-anonymous `VarRegion` or a `FieldRegion` or something like that 
> > > > > (in other patches as well). It would work more often and it'll 
> > > > > transparently handle references.
> > > > Unfortunately it is a `SymRegion` so it does not work :-( (Even using 
> > > > `getMostDerivedRegion()` does not help.)
> > > You mean the first checking form `SymbolicRegion`, then get its symbol, 
> > > check for `SymbolRegionValue`, then get its `TypedValueRegion`, check for 
> > > `DeclRegion` and use its `Decl`? This sound waaay more complicated and 
> > > less readable. I am not sure which are the side cases: is it always 
> > > `SymbolicRegion`? Is the `Symbol` of `SymbolicRegion` always a 
> > > `SymbolRegionValue`? Is ithe `TypedValueRegion` (the return value of its 
> > > `getRegion()`) always a `DeclRegion`?
> > > Unfortunately it is a `SymRegion`
> > 
> > Emm, that's rarely the case. Only if it's a reference passed into a 
> > top-level function as a parameter.
> (or to another unknown location) (please learn what `SymbolicRegion` is, it 
> is very important for your work)
> 
> I guess you should do both then, because when the analyzer is able to resolve 
> the reference it's better in this case to point out what is the actual 
> container that's being modified.
Is it OK now?


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

https://reviews.llvm.org/D73720



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


[PATCH] D76717: feedback

2020-03-24 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76717

Files:
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -136,14 +136,17 @@
   if (!this->VFS)
 this->VFS = llvm::vfs::getRealFileSystem();
 
-  if (llvm::sys::path::is_relative(SysRoot)) {
-SysRoot = GetResourcesPath(ClangExecutable, SysRoot);
-  }
-
   Name = std::string(llvm::sys::path::filename(ClangExecutable));
   Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
   InstalledDir = Dir; // Provide a sensible default installed dir.
 
+  if (llvm::sys::path::is_relative(SysRoot)) {
+// Prepend InstalledDir if SysRoot is relative
+SmallString<128> fullpath(InstalledDir);
+llvm::sys::path::append(fullpath, SysRoot);
+SysRoot = std::string(fullpath);
+  }
+
 #if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
   SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR;
 #endif


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -136,14 +136,17 @@
   if (!this->VFS)
 this->VFS = llvm::vfs::getRealFileSystem();
 
-  if (llvm::sys::path::is_relative(SysRoot)) {
-SysRoot = GetResourcesPath(ClangExecutable, SysRoot);
-  }
-
   Name = std::string(llvm::sys::path::filename(ClangExecutable));
   Dir = std::string(llvm::sys::path::parent_path(ClangExecutable));
   InstalledDir = Dir; // Provide a sensible default installed dir.
 
+  if (llvm::sys::path::is_relative(SysRoot)) {
+// Prepend InstalledDir if SysRoot is relative
+SmallString<128> fullpath(InstalledDir);
+llvm::sys::path::append(fullpath, SysRoot);
+SysRoot = std::string(fullpath);
+  }
+
 #if defined(CLANG_CONFIG_FILE_SYSTEM_DIR)
   SystemConfigDir = CLANG_CONFIG_FILE_SYSTEM_DIR;
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76078: [AArch64][SVE] Add a pass for SVE intrinsic optimisations

2020-03-24 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 252368.
kmclaughlin marked 3 inline comments as done.
kmclaughlin added a comment.

Use SmallPtrSet instead of SmallVector for storing functions found by 
runOnModule
Add more comments to clarify the purpose of the pass and some of the negative 
reinterpret tests


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

https://reviews.llvm.org/D76078

Files:
  llvm/lib/Target/AArch64/AArch64.h
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/lib/Target/AArch64/CMakeLists.txt
  llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
  llvm/test/CodeGen/AArch64/O3-pipeline.ll
  llvm/test/CodeGen/AArch64/sve-intrinsic-opts-ptest.ll
  llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsic-opts-reinterpret.ll
@@ -0,0 +1,203 @@
+; RUN: opt -S -sve-intrinsic-opts -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck --check-prefix OPT %s
+
+define  @reinterpret_test_h( %a) {
+; OPT-LABEL: @reinterpret_test_h(
+; OPT-NOT: convert
+; OPT: ret  %a
+  %1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %1)
+  ret  %2
+}
+
+; Reinterprets are not redundant because the second reinterpret zeros the
+; lanes that don't exist within its input.
+define  @reinterpret_test_h_rev( %a) {
+; OPT-LABEL: @reinterpret_test_h_rev(
+; OPT: %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %a)
+; OPT-NEXT: %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %1)
+; OPT-NEXT: ret  %2
+  %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv8i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv8i1( %1)
+  ret  %2
+}
+
+define  @reinterpret_test_w( %a) {
+; OPT-LABEL: @reinterpret_test_w(
+; OPT-NOT: convert
+; OPT: ret  %a
+  %1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %1)
+  ret  %2
+}
+
+; Reinterprets are not redundant because the second reinterpret zeros the
+; lanes that don't exist within its input.
+define  @reinterpret_test_w_rev( %a) {
+; OPT-LABEL: @reinterpret_test_w_rev(
+; OPT: %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %a)
+; OPT-NEXT: %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %1)
+; OPT-NEXT: ret  %2
+  %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv4i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv4i1( %1)
+  ret  %2
+}
+
+define  @reinterpret_test_d( %a) {
+; OPT-LABEL: @reinterpret_test_d(
+; OPT-NOT: convert
+; OPT: ret  %a
+  %1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %1)
+  ret  %2
+}
+
+; Reinterprets are not redundant because the second reinterpret zeros the
+; lanes that don't exist within its input.
+define  @reinterpret_test_d_rev( %a) {
+; OPT-LABEL: @reinterpret_test_d_rev(
+; OPT: %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %a)
+; OPT-NEXT: %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %1)
+; OPT-NEXT: ret  %2
+  %1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %a)
+  %2 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %1)
+  ret  %2
+}
+
+define  @reinterpret_reductions(i32 %cond,  %a,  %b,  %c) {
+; OPT-LABEL: reinterpret_reductions
+; OPT-NOT: convert
+; OPT-NOT: phi 
+; OPT: phi  [ %a, %br_phi_a ], [ %b, %br_phi_b ], [ %c, %br_phi_c ]
+; OPT-NOT: convert
+; OPT: ret
+
+entry:
+  switch i32 %cond, label %br_phi_c [
+ i32 43, label %br_phi_a
+ i32 45, label %br_phi_b
+  ]
+
+br_phi_a:
+  %a1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %a)
+  br label %join
+
+br_phi_b:
+  %b1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %b)
+  br label %join
+
+br_phi_c:
+  %c1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %c)
+  br label %join
+
+join:
+  %pg = phi  [ %a1, %br_phi_a ], [ %b1, %br_phi_b ], [ %c1, %br_phi_c ]
+  %pg1 = tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  ret  %pg1
+}
+
+; No transform as the reinterprets are converting from different types (nxv2i1 & nxv4i1)
+; As the incoming values to the phi must all be the same type, we cannot remove the reinterprets.
+define  @reinterpret_reductions_1(i32 %cond,  %a,  %b,  %c) {
+; OPT-LABEL: reinterpret_reductions_1
+; OPT: convert
+; OPT: phi  [ %a1, %br_phi_a ], [ %b1, %br_phi_b ], [ %c1, %br_phi_c ]
+; OPT-NOT: phi 
+; OPT: tail call  @llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+; OPT: ret
+
+entry:
+  switch i32 %cond, label %br_phi_c [
+ i32 43, label %br_phi_a
+ i32 45, label %br_phi_b
+  ]
+
+br_phi_a:
+  %a1 = tail call  @llvm.aarch64.sve.convert.to.svbool.nxv2i1( %a)
+  br label %join
+
+br_phi_b:
+  %b1 = tail call  

[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-24 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo marked an inline comment as done.
oontvoo added a comment.

Addressed comments. PTAL. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951



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


[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-03-24 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 252371.
oontvoo added a comment.

clang format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1619,7 +1619,7 @@
   endian::Writer LE(Out, little);
   unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
   LE.write(KeyLen);
-  unsigned DataLen = 1 + 2 + 4 + 4;
+  unsigned DataLen = 1 + 2 + 4 + 4 + 4;
   for (auto ModInfo : Data.KnownHeaders)
 if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
   DataLen += 4;
@@ -1676,6 +1676,9 @@
   }
   LE.write(Offset);
 
+  // Write this file UID.
+  LE.write(Data.HFI.UID);
+
   auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
 if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
   uint32_t Value = (ModID << 2) | (unsigned)Role;
@@ -1703,7 +1706,7 @@
 /// Write the header search block for the list of files that
 ///
 /// \param HS The header search structure to save.
-void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
+void ASTWriter::WriteHeaderSearch(HeaderSearch &HS) {
   HeaderFileInfoTrait GeneratorTrait(*this);
   llvm::OnDiskChainedHashTableGenerator Generator;
   SmallVector SavedStrings;
@@ -1781,8 +1784,7 @@
 // changed since it was loaded. Also skip it if it's for a modular header
 // from a different module; in that case, we rely on the module(s)
 // containing the header to provide this information.
-const HeaderFileInfo *HFI =
-HS.getExistingFileInfo(File, /*WantExternal*/!Chain);
+HeaderFileInfo *HFI = HS.getExistingFileInfo(File, /*WantExternal*/ !Chain);
 if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
   continue;
 
@@ -1799,8 +1801,13 @@
 HeaderFileInfoTrait::key_type Key = {
   Filename, File->getSize(), getTimestampForOutput(File)
 };
+// Set the UID for this HFI so that its importers could use it
+// when serializing.
+HFI->UID = UID;
 HeaderFileInfoTrait::data_type Data = {
-  *HFI, HS.getModuleMap().findAllModulesForHeader(File), {}
+*HFI,
+HS.getModuleMap().findAllModulesForHeader(File),
+{},
 };
 Generator.insert(Key, Data, GeneratorTrait);
 ++NumHeaderSearchEntries;
@@ -2634,6 +2641,18 @@
   Stream.EmitRecord(SUBMODULE_IMPORTS, Record);
 }
 
+// Emit the imported header's UIDs.
+{
+  auto it = PP->Submodules.find(Mod);
+  if (it != PP->Submodules.end() && !it->second.IncludedFiles.empty()) {
+RecordData Record;
+for (const HeaderFileInfo *HFI : it->second.IncludedFiles) {
+  Record.push_back(HFI->UID);
+}
+Stream.EmitRecord(SUBMODULE_IMPORTED_HEADERS, Record);
+  }
+}
+
 // Emit the exports.
 if (!Mod->Exports.empty()) {
   RecordData Record;
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -1898,6 +1898,9 @@
 HFI.Framework = HS->getUniqueFrameworkName(FrameworkName);
   }
 
+  // Read the file old UID
+  HFI.UID = endian::readNext(d);
+
   assert((End - d) % 4 == 0 &&
  "Wrong data length in HeaderFileInfo deserialization");
   while (d != End) {
@@ -5615,6 +5618,11 @@
   }
   break;
 
+case SUBMODULE_IMPORTED_HEADERS:
+  for (unsigned Idx = 0; Idx < Record.size(); ++Idx) {
+PendingImportedHeaders[&F].push_back(Record[Idx]);
+  }
+  break;
 case SUBMODULE_EXPORTS:
   for (unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
 UnresolvedModuleRef Unresolved;
@@ -9271,6 +9279,38 @@
   for (auto *ND : PendingMergedDefinitionsToDeduplicate)
 getContext().deduplicateMergedDefinitonsFor(ND);
   PendingMergedDefinitionsToDeduplicate.clear();
+
+  // Fix up the HeaderSearchInfo UIDs.
+  if (!PendingImportedHeaders.empty()) {
+std::map UIDToIndex;
+
+// These HFIs were deserialized and assigned their "old"
+// UID.
+// We need to update them and populate the OldToIndex map
+// for use next.
+HeaderSearch &HS = PP.getHeaderSearchInfo();
+for (unsigned Idx = 0; Idx < HS.FileInfo.size(); ++Idx) {
+  UIDToIndex[HS.FileInfo[Idx].UID] = Idx;
+  // Clear the no longer useful UID fields.
+  HS.FileInfo[Idx].UID

[PATCH] D76704: Don't normalise CXX11/C2X attribute names to start with ::

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

LGTM, thank you for this cleanup!




Comment at: clang/lib/Basic/Attributes.cpp:89
   SmallString<64> FullName = ScopeName;
-  if (Scope || SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
-  SyntaxUsed == AttributeCommonInfo::AS_C2x)
+  if (!ScopeName.empty())
 FullName += "::";

I think we should add an assert that the syntax used is either CXX11 or C2x if 
the scope name is not empty.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76704



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


[PATCH] D31343: Add an attribute plugin example

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

LGTM, thank you!


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

https://reviews.llvm.org/D31343



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


[PATCH] D76078: [AArch64][SVE] Add a pass for SVE intrinsic optimisations

2020-03-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp:233
+  bool Changed = false;
+  for (auto *F : Functions) {
+DominatorTree *DT = 
&getAnalysis(*F).getDomTree();

Iterating over a SmallPtrSet is non-deterministic.

In this context, probably SetVector is the right data structure.


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

https://reviews.llvm.org/D76078



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


[PATCH] D73846: [PCH] make sure to not warn about unused macros from -D

2020-03-24 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

Ping.


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

https://reviews.llvm.org/D73846



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


[PATCH] D74846: fix -fcodegen-modules code when used with PCH (PR44953)

2020-03-24 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

Ping..


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D69585: PerformPendingInstatiations() already in the PCH

2020-03-24 Thread Luboš Luňák via Phabricator via cfe-commits
llunak added a comment.

Ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D69585



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


[PATCH] D70411: [analyzer] CERT: STR31-C

2020-03-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked 4 inline comments as done.
Charusso added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:803
+
+} // end "cert.str"
+

balazske wrote:
> NoQ wrote:
> > `alpha.cert.str`.
> This text may be hard to understand. The option means "if it is off, the 
> problem report happens only if there is no hand-written null termination of 
> the string"? I looked at the CERT rule but did not find out why is null 
> termination by hand important here. (I did not look at the code to find out 
> what it does.) And "WarnOnCall" suggests that there is warning made on calls 
> if on, or not at all or at other location if off, is this correct?
You let the buffer overflow by a bugprone function call, then you adjust the 
null-terminator by simply `buf[size] = '\0'`, then you made sure the buffer 
cannot overflow, since you have terminated it. It is a very common idiom 
therefore I do not think a hand-written null-termination is a security issue. 
The SEI CERT rules are all theoretical so you will not find anything useful in 
practice. My solution is practical.

> This text may be hard to understand.
Please note that this text only made for Static Analyzer developers. Let us 
rephrase it then:

> Whether the checker needs to warn on the bugprone function calls immediately 
> or look for bugprone hand-written null-termination of bugprone function call 
> made strings. It is a common idiom to null-terminate the string by hand after 
> the insecure function call produce the string which could be misused so that 
> it is on by default. It is useful to turn it off to reduce the noise of the 
> checker, because people usually null-terminate the string by hand immediately 
> after the bugprone function call produce the string.

Do you buy that?



Comment at: clang/lib/StaticAnalyzer/Checkers/AllocationState.h:28
 
+/// \returns The MallocBugVisitor.
+std::unique_ptr getMallocBRVisitor(SymbolRef Sym);

balazske wrote:
> This documentation could be improved or left out.
Totally, I have already forgotten I wanted to remove it. Thanks!



Comment at: clang/test/Analysis/cert/str31-c-notes-warn-on-call-off.cpp:68
+
+  do_something(dest);
+  // expected-warning@-1 {{'dest' is not null-terminated}}

balazske wrote:
> Maybe I have wrong expectations about what this checker does but did 
> understand it correctly yet. The main problem here is that `dest` may be not 
> large enough (if size of `src` is not known). This would be a better text for 
> the error message? And if this happens (the write outside) it is already a 
> fatal error, can cause crash. If no buffer overflow happens the terminating 
> zero is copied from `src`, so why would `dst` be not null terminated?
I like that error message because that is the truth, that is the issue. If it 
would crash so the operating system would detect a fatal error we should not 
develop Static Analyzer and vulnerabilities would not exist. That would be 
cool, btw.


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] D76689: [Sema][SVE] Fix handling of initialisers for built-in SVE types

2020-03-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Semantically, this makes sense.

I'm not really happy with the use of the term "scalar initializer" to refer to 
initializing a vector.  Seems likely to confuse users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76689



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


[PATCH] D76724: Prevent immediate evaluations inside of decltype

2020-03-24 Thread Wyatt Childers via Phabricator via cfe-commits
wchilders created this revision.
wchilders added reviewers: Tyker, rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes an issue where immediate invocations were queued inside of decltype, 
resulting in decltype's operand being evaluated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76724

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/decltype-consteval.cpp


Index: clang/test/SemaCXX/decltype-consteval.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/decltype-consteval.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s
+// expected-no-diagnostics
+
+struct MaybeConsteval {
+  MaybeConsteval* ptr = nullptr;
+
+  consteval MaybeConsteval(bool Valid) : ptr(this) {
+if (Valid) {
+  ptr = nullptr;
+}
+  }
+};
+
+consteval decltype(MaybeConsteval(false)) foo() {
+  return { true };
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15377,9 +15377,16 @@
   }
 }
 
+// Check to see if this expression is part of a decltype specifier.
+// We're not interested in evaluating this expression, immediately or 
otherwise.
+static bool isInDeclType(Sema &SemaRef) {
+  return SemaRef.ExprEvalContexts.back().ExprContext ==
+ Sema::ExpressionEvaluationContextRecord::EK_Decltype;
+}
+
 ExprResult Sema::CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl) 
{
   if (!E.isUsable() || !Decl || !Decl->isConsteval() || isConstantEvaluated() 
||
-  RebuildingImmediateInvocation)
+  isInDeclType(*this) || RebuildingImmediateInvocation)
 return E;
 
   /// Opportunistically remove the callee from ReferencesToConsteval if we can.


Index: clang/test/SemaCXX/decltype-consteval.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/decltype-consteval.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2a %s
+// expected-no-diagnostics
+
+struct MaybeConsteval {
+  MaybeConsteval* ptr = nullptr;
+
+  consteval MaybeConsteval(bool Valid) : ptr(this) {
+if (Valid) {
+  ptr = nullptr;
+}
+  }
+};
+
+consteval decltype(MaybeConsteval(false)) foo() {
+  return { true };
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15377,9 +15377,16 @@
   }
 }
 
+// Check to see if this expression is part of a decltype specifier.
+// We're not interested in evaluating this expression, immediately or otherwise.
+static bool isInDeclType(Sema &SemaRef) {
+  return SemaRef.ExprEvalContexts.back().ExprContext ==
+ Sema::ExpressionEvaluationContextRecord::EK_Decltype;
+}
+
 ExprResult Sema::CheckForImmediateInvocation(ExprResult E, FunctionDecl *Decl) {
   if (!E.isUsable() || !Decl || !Decl->isConsteval() || isConstantEvaluated() ||
-  RebuildingImmediateInvocation)
+  isInDeclType(*this) || RebuildingImmediateInvocation)
 return E;
 
   /// Opportunistically remove the callee from ReferencesToConsteval if we can.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76694: [Sema][SVE] Allow casting SVE types to themselves in C

2020-03-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Is it not legal to cast an SVE type to any type other than itself?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76694



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


[PATCH] D76690: [AST][SVE] Treat built-in SVE types as POD

2020-03-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/AST/Type.cpp:2515
+  if (BaseTy->isSizelessBuiltinType())
+return true;
+

Can you rearrange this so isSizelessBuiltinType() is at the bottom?  It should 
be rare.  (Assuming it doesn't need to be before the isIncompleteType() check.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76690



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


[PATCH] D76693: [Sema][SVE] Allow ?: to select between SVE types in C

2020-03-24 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Do we want to allow stuff like `x ? (svint8_t)0 : (signed char)0`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76693



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


[PATCH] D76725: [clangd] Build ASTs only with fresh preambles or after building a new preamble

2020-03-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
javed.absar, ilya-biryukov.
Herald added a project: clang.
kadircet added a parent revision: D76304: [clangd] Update TUStatus api to 
accommodate preamble thread.

This is another step for out-of-order preamble builds. To keep the
diagnostic behavior same, we only build ASTs either with "reusable" preambles,
the ones that are fully applicable to a given ParseInput, or after building a
new preamble. Which is the same behaviour as what we do today.

ASTs built through preamble callbacks are not cached as they are built on a
different thread and ASTWorker heavily relies on being the only thread updating
cached ASTs. This results in possibly building some ASTs twice (when there's an
immediate read after a preamble built without any write in between).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76725

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -66,8 +66,7 @@
   auto CI = buildCompilerInvocation(Inputs, Diags);
   assert(CI && "Failed to build compilation invocation.");
   auto Preamble =
-  buildPreamble(FullFilename, *CI,
-/*OldPreamble=*/nullptr, Inputs,
+  buildPreamble(FullFilename, *CI, Inputs,
 /*StoreInMemory=*/true, /*PreambleCallback=*/nullptr);
   auto AST =
   buildAST(FullFilename, std::move(CI), Diags.take(), Inputs, Preamble);
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -570,6 +570,17 @@
   auto Bar = testPath("bar.cpp");
   auto Baz = testPath("baz.cpp");
 
+  // Build all of the files once, so that we've got their preambles ready.
+  updateWithCallback(S, Foo, SourceContents, WantDiagnostics::Yes,
+ [&BuiltASTCounter]() { ++BuiltASTCounter; });
+  updateWithCallback(S, Bar, SourceContents, WantDiagnostics::Yes,
+ [&BuiltASTCounter]() { ++BuiltASTCounter; });
+  updateWithCallback(S, Baz, SourceContents, WantDiagnostics::Yes,
+ [&BuiltASTCounter]() { ++BuiltASTCounter; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+  ASSERT_EQ(BuiltASTCounter.load(), 3);
+  BuiltASTCounter = 0;
+
   // Build one file in advance. We will not access it later, so it will be the
   // one that the cache will evict.
   updateWithCallback(S, Foo, SourceContents, WantDiagnostics::Yes,
@@ -697,26 +708,29 @@
   };
 
   // Test that subsequent updates with the same inputs do not cause rebuilds.
-  ASSERT_TRUE(DoUpdate(SourceContents));
-  ASSERT_FALSE(DoUpdate(SourceContents));
+  ASSERT_TRUE(DoUpdate(SourceContents));  // Builds preamble
+  ASSERT_TRUE(DoUpdate(SourceContents));  // Builds AST
+  ASSERT_FALSE(DoUpdate(SourceContents)); // Reuses it
 
   // Update to a header should cause a rebuild, though.
   Timestamps[Header] = time_t(1);
-  ASSERT_TRUE(DoUpdate(SourceContents));
-  ASSERT_FALSE(DoUpdate(SourceContents));
+  ASSERT_TRUE(DoUpdate(SourceContents));  // Builds preamble
+  ASSERT_TRUE(DoUpdate(SourceContents));  // Builds AST
+  ASSERT_FALSE(DoUpdate(SourceContents)); // Reuses AST
 
   // Update to the contents should cause a rebuild.
   auto OtherSourceContents = R"cpp(
   #include "foo.h"
   int c = d;
 )cpp";
-  ASSERT_TRUE(DoUpdate(OtherSourceContents));
-  ASSERT_FALSE(DoUpdate(OtherSourceContents));
+  ASSERT_TRUE(DoUpdate(OtherSourceContents));  // Builds AST, reusing preamble
+  ASSERT_FALSE(DoUpdate(OtherSourceContents)); // Reuses AST
 
   // Update to the compile commands should also cause a rebuild.
   CDB.ExtraClangFlags.push_back("-DSOMETHING");
-  ASSERT_TRUE(DoUpdate(OtherSourceContents));
-  ASSERT_FALSE(DoUpdate(OtherSourceContents));
+  ASSERT_TRUE(DoUpdate(SourceContents));   // Builds preamble
+  ASSERT_TRUE(DoUpdate(OtherSourceContents));  // Builds AST
+  ASSERT_FALSE(DoUpdate(OtherSourceContents)); // Reuses it
 }
 
 TEST_F(TUSchedulerTests, ForceRebuild) {
@@ -732,6 +746,10 @@
 
   ParseInputs Inputs = getInputs(Source, SourceContents);
 
+  // Send an initial update to make sure we've got preamble ready.
+  S.update(Source, Inputs, WantDiagnostics::Yes);
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+
   // Update the source contents, which should trigger an initial build with
   // the header file

[PATCH] D76617: [SveEmitter] Fix encoding/decoding of SVETypeFlags

2020-03-24 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

> Yes you're right, the patch that I've made dependent needs this one to work 
> properly.

Ah ok, I may have missed that, will have a look


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76617



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


  1   2   >