[clang-tools-extra] 223a43e - [clang-tidy] [NFC] Remove unnecessary matchers

2020-03-09 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-03-09T07:38:15Z
New Revision: 223a43ee8d899a0522bebe8291470b77e7dc7ab1

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

LOG: [clang-tidy] [NFC] Remove unnecessary matchers

Reviewers: aaron.ballman, alexfh, gribozavr2

Reviewed By: aaron.ballman

Subscribers: wuzish, nemanjai, xazax.hun, kbarton, cfe-commits

Tags: #clang, #clang-tools-extra

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
clang-tools-extra/clang-tidy/utils/Matchers.h

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp 
b/clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
index f43d9496994d..188d44da51d8 100644
--- a/clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
+++ b/clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
@@ -61,11 +61,10 @@ void 
ComparisonInTempFailureRetryCheck::registerMatchers(MatchFinder *Finder) {
   // we need to not complain about things like TEMP_FAILURE_RETRY(foo(x == 1)),
   // so we just match the assignment of `y = (x)` and inspect `x` from there.
   Finder->addMatcher(
-  binaryOperator(
-  hasOperatorName("="),
-  hasRHS(ignoringParenCasts(
-  binaryOperator(matchers::isComparisonOperator()).bind("binop"))),
-  isRHSATempFailureRetryArg()),
+  binaryOperator(hasOperatorName("="),
+ hasRHS(ignoringParenCasts(
+ 
binaryOperator(isComparisonOperator()).bind("binop"))),
+ isRHSATempFailureRetryArg()),
   this);
 }
 

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
index 98a1a0c37ecb..d5f392b592b8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
@@ -48,8 +48,7 @@ void MisplacedWideningCastCheck::registerMatchers(MatchFinder 
*Finder) {
   Finder->addMatcher(callExpr(hasAnyArgument(Cast)), this);
   Finder->addMatcher(binaryOperator(hasOperatorName("="), hasRHS(Cast)), this);
   Finder->addMatcher(
-  binaryOperator(matchers::isComparisonOperator(), hasEitherOperand(Cast)),
-  this);
+  binaryOperator(isComparisonOperator(), hasEitherOperand(Cast)), this);
 }
 
 static unsigned getMaxCalculationWidth(const ASTContext &Context,

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
index 8de64608a3c2..cad4072b0849 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
@@ -84,8 +84,7 @@ void SuspiciousStringCompareCheck::storeOptions(
 void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
   // Match relational operators.
   const auto ComparisonUnaryOperator = unaryOperator(hasOperatorName("!"));
-  const auto ComparisonBinaryOperator =
-  binaryOperator(matchers::isComparisonOperator());
+  const auto ComparisonBinaryOperator = binaryOperator(isComparisonOperator());
   const auto ComparisonOperator =
   expr(anyOf(ComparisonUnaryOperator, ComparisonBinaryOperator));
 
@@ -143,10 +142,9 @@ void 
SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
 
   // Detect suspicious operator with string compare function as operand.
   Finder->addMatcher(
-  binaryOperator(
-  unless(anyOf(matchers::isComparisonOperator(), hasOperatorName("&&"),
-   hasOperatorName("||"), hasOperatorName("="))),
-  hasEitherOperand(StringCompareCallExpr))
+  binaryOperator(unless(anyOf(isComparisonOperator(), 
hasOperatorName("&&"),
+  hasOperatorName("||"), 
hasOperatorName("="))),
+ hasEitherOperand(StringCompareCallExpr))
   .bind("suspicious-operator"),
   this);
 
@@ -158,7 +156,7 @@ void 
SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
 has(ignoringParenImpCasts(integerLiteral(unless(equals(0)),
 characterLiteral(), cxxBoolLiteral()));
 
-  Find

[PATCH] D75803: [clang-tidy] [NFC] Remove unnecessary matchers

2020-03-09 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG223a43ee8d89: [clang-tidy] [NFC] Remove unnecessary matchers 
(authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D75803?vs=248918&id=249040#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75803

Files:
  clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/MisplacedWideningCastCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
  clang-tools-extra/clang-tidy/utils/Matchers.h

Index: clang-tools-extra/clang-tidy/utils/Matchers.h
===
--- clang-tools-extra/clang-tidy/utils/Matchers.h
+++ clang-tools-extra/clang-tidy/utils/Matchers.h
@@ -16,20 +16,12 @@
 namespace tidy {
 namespace matchers {
 
-AST_MATCHER(BinaryOperator, isAssignmentOperator) {
-  return Node.isAssignmentOp();
-}
-
 AST_MATCHER(BinaryOperator, isRelationalOperator) {
   return Node.isRelationalOp();
 }
 
 AST_MATCHER(BinaryOperator, isEqualityOperator) { return Node.isEqualityOp(); }
 
-AST_MATCHER(BinaryOperator, isComparisonOperator) {
-  return Node.isComparisonOp();
-}
-
 AST_MATCHER(QualType, isExpensiveToCopy) {
   llvm::Optional IsExpensive =
   utils::type_traits::isExpensiveToCopy(Node, Finder->getASTContext());
Index: clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -41,7 +41,7 @@
 
   const auto WrongUse = anyOf(
   hasParent(binaryOperator(
-matchers::isComparisonOperator(),
+isComparisonOperator(),
 hasEitherOperand(ignoringImpCasts(anyOf(
 integerLiteral(equals(1)), integerLiteral(equals(0))
 .bind("SizeBinaryOp")),
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -836,9 +836,8 @@
   binaryOperator(anyOf(hasOperatorName("-"), hasOperatorName("/"),
hasOperatorName("%"), hasOperatorName("|"),
hasOperatorName("&"), hasOperatorName("^"),
-   matchers::isComparisonOperator(),
-   hasOperatorName("&&"), hasOperatorName("||"),
-   hasOperatorName("=")),
+   isComparisonOperator(), hasOperatorName("&&"),
+   hasOperatorName("||"), hasOperatorName("=")),
  operandsAreEquivalent(),
  // Filter noisy false positives.
  unless(isInTemplateInstantiation()),
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
@@ -91,8 +91,7 @@
 
   // Matching assignment to owners, with the rhs not being an owner nor creating
   // one.
-  Finder->addMatcher(binaryOperator(matchers::isAssignmentOperator(),
-hasLHS(IsOwnerType),
+  Finder->addMatcher(binaryOperator(isAssignmentOperator(), hasLHS(IsOwnerType),
 hasRHS(unless(ConsideredOwner)))
  .bind("owner_assignment"),
  this);
@@ -119,7 +118,7 @@
 
   // Matching on assignment operations where the RHS is a newly created owner,
   // but the LHS is not an owner.
-  Finder->addMatcher(binaryOperator(matchers::isAssignmentOperator(),
+  Finder->addMatcher(binaryOperator(isAssignmentOperator(),
 hasLHS(unless(IsOwnerType)),
 hasRHS(CreatesOwner))
  .bind("bad_owner_creation_assignment"),
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
@@ -84,8 +84,7 @@
 void SuspiciousStringCompareCheck::registerMatchers(MatchFinder *Finder) {
   // Match relational operators.
  

[PATCH] D65591: [AST] Add a flag indicating if any subexpression had errors

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

- rebase to master
- fix the crash


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65591

Files:
  clang/include/clang/AST/ASTDumperUtils.h
  clang/include/clang/AST/DependencyFlags.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/Type.h
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp

Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -540,6 +540,7 @@
   Record.push_back(E->isValueDependent());
   Record.push_back(E->isInstantiationDependent());
   Record.push_back(E->containsUnexpandedParameterPack());
+  Record.push_back(E->containsErrors());
   Record.push_back(E->getValueKind());
   Record.push_back(E->getObjectKind());
 }
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2281,6 +2281,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   //DeclRefExpr
@@ -2305,6 +2306,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   //Integer Literal
@@ -2324,6 +2326,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   //Character Literal
@@ -2343,6 +2346,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ValueDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //InstantiationDependent
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //UnexpandedParamPack
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); //ContainsErrors
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetValueKind
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); //GetObjectKind
   // CastExpr
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -106,7 +106,7 @@
 
 /// The number of record fields required for the Expr class
 /// itself.
-static const unsigned NumExprFields = NumStmtFields + 7;
+static const unsigned NumExprFields = NumStmtFields + ExprDependenceBits + 3;
 
 /// Read and initialize a ExplicitTemplateArgumentList structure.
 void ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
@@ -518,6 +518,7 @@
   bool ValueDependent = Record.readInt();
   bool InstantiationDependent = Record.readInt();
   bool ContainsUnexpandedTemplateParameters = Record.readInt();
+  bool ContainsErrors = Record.readInt();
   auto Deps = ExprDependence::None;
   if (TypeDependent)
 Deps |= ExprDependence::Type;
@@ -527,6 +528,8 @@
 Deps |= ExprDependence::Instantiation;
   if (ContainsUnexpandedTemplateParameters)
 Deps |= ExprDependence::UnexpandedPack;
+  if (ContainsErrors)
+Deps |= ExprDependence::Error;
   E->setDependence(Deps);
 
   E->setValueKind(static_cast(Record.readInt()));
Index: clang/lib/AST/TextNodeDumper.cpp
===
--- clang/lib/AST/TextNodeDumper.cpp
+++ clang/lib/AST/TextNodeDumper.cpp
@@ -128,6 +128,11 @@
   if (const auto *E = dyn_cast(Node)) {
 dumpType(E->getType());
 
+if (E->containsErrors()) {
+  ColorScope Color(OS, ShowColors, ErrorsColor);
+  OS << " contains-errors";
+}
+
 {
   ColorScope Color(OS, ShowColors, ValueKindColor);
   switch 

[clang-tools-extra] 2ce821c - Fix build failure from rG223a43ee8d89

2020-03-09 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-03-09T08:12:52Z
New Revision: 2ce821cbc90aa987fc370ec578ff92a3327f49ed

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

LOG: Fix build failure from rG223a43ee8d89

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
index aeef4a7df4ba..39776180d9c0 100644
--- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -567,7 +567,7 @@ matchRelationalIntegerConstantExpr(StringRef Id) {
   std::string OverloadId = (Id + "-overload").str();
 
   const auto RelationalExpr = ignoringParenImpCasts(binaryOperator(
-  matchers::isComparisonOperator(), expr().bind(Id),
+  isComparisonOperator(), expr().bind(Id),
   anyOf(allOf(hasLHS(matchSymbolicExpr(Id)),
   hasRHS(matchIntegerConstantExpr(Id))),
 allOf(hasLHS(matchIntegerConstantExpr(Id)),
@@ -942,7 +942,7 @@ void RedundantExpressionCheck::registerMatchers(MatchFinder 
*Finder) {
   const auto SymRight = matchSymbolicExpr("rhs");
 
   // Match expressions like: x  0xFF == 0xF00.
-  Finder->addMatcher(binaryOperator(matchers::isComparisonOperator(),
+  Finder->addMatcher(binaryOperator(isComparisonOperator(),
 hasEitherOperand(BinOpCstLeft),
 hasEitherOperand(CstRight))
  .bind("binop-const-compare-to-const"),
@@ -950,14 +950,14 @@ void 
RedundantExpressionCheck::registerMatchers(MatchFinder *Finder) {
 
   // Match expressions like: x  0xFF == x.
   Finder->addMatcher(
-  binaryOperator(matchers::isComparisonOperator(),
+  binaryOperator(isComparisonOperator(),
  anyOf(allOf(hasLHS(BinOpCstLeft), hasRHS(SymRight)),
allOf(hasLHS(SymRight), hasRHS(BinOpCstLeft
   .bind("binop-const-compare-to-sym"),
   this);
 
   // Match expressions like: x  10 == x  12.
-  Finder->addMatcher(binaryOperator(matchers::isComparisonOperator(),
+  Finder->addMatcher(binaryOperator(isComparisonOperator(),
 hasLHS(BinOpCstLeft), 
hasRHS(BinOpCstRight),
 // Already reported as redundant.
 unless(operandsAreEquivalent()))



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


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

2020-03-09 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

I wonder whether I should change "to/from the left" to "towards/from the front" 
and "to/from the right" to "towards/from the right"?


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] D75171: [Analyzer] Fix for incorrect use of container and iterator checkers

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

Correct diff.


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

https://reviews.llvm.org/D75171

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  
clang/test/Analysis/container-modeling-no-aggressive-binary-operation-simplification-warn.cpp
  
clang/test/Analysis/iterator-modeling-no-aggressive-binary-operation-simplification-no-crash.cpp
  clang/test/Analysis/loop-widening-notes.cpp

Index: clang/test/Analysis/loop-widening-notes.cpp
===
--- clang/test/Analysis/loop-widening-notes.cpp
+++ clang/test/Analysis/loop-widening-notes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha -analyzer-max-loop 2 -analyzer-config widen-loops=true -analyzer-output=text -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-max-loop 2 -analyzer-config widen-loops=true -analyzer-output=text -verify -analyzer-config eagerly-assume=false %s
 
 int *p_a;
 int bar();
Index: clang/test/Analysis/iterator-modeling-no-aggressive-binary-operation-simplification-no-crash.cpp
===
--- /dev/null
+++ clang/test/Analysis/iterator-modeling-no-aggressive-binary-operation-simplification-no-crash.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_analyze_cc1 -std=c++11\
+// RUN: -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection\
+// RUN: -analyzer-config c++-container-inlining=false %s 2>&1 | FileCheck %s
+
+// RUN: %clang_analyze_cc1 -std=c++11\
+// RUN: -analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection\
+// RUN: -analyzer-config c++-container-inlining=true -DINLINE=1 %s 2>&1 |\
+// RUN: FileCheck %s
+
+// CHECK: checker cannot be enabled with analyzer option 'aggressive-binary-operation-simplification' == false
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+template 
+long clang_analyzer_container_end(const Container&);
+template 
+long clang_analyzer_iterator_position(const Iterator&);
+
+void clang_analyzer_eval(bool);
+
+
+template 
+InputIterator nonStdFind(InputIterator first, InputIterator last,
+ const T &val) {
+  for (auto i = first; i != last; ++i) {
+if (*i == val) {
+  return i;
+}
+  }
+  return last;
+}
+
+void non_std_find(std::vector &V, int e) {
+  auto first = nonStdFind(V.begin(), V.end(), e);
+  clang_analyzer_eval(clang_analyzer_container_end(V) ==
+  clang_analyzer_iterator_position(first));
+  if (V.end() != first) {
+clang_analyzer_eval(clang_analyzer_container_end(V) ==
+clang_analyzer_iterator_position(first));
+  }
+}
Index: clang/test/Analysis/container-modeling-no-aggressive-binary-operation-simplification-warn.cpp
===
--- /dev/null
+++ clang/test/Analysis/container-modeling-no-aggressive-binary-operation-simplification-warn.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -std=c++11\
+// RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.ContainerModeling\
+// RUN: -analyzer-config c++-container-inlining=false %s 2>&1 | FileCheck %s
+
+// RUN: %clang_analyze_cc1 -std=c++11\
+// RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.ContainerModeling\
+// RUN: -analyzer-config c++-container-inlining=true -DINLINE=1 %s 2>&1 |\
+// RUN: FileCheck %s
+
+// CHECK: checker cannot be enabled with analyzer option 'aggressive-binary-operation-simplification' == false
Index: clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
@@ -12,6 +12,7 @@
 
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
@@ -1036,5 +1037,15 @@
 }
 
 bool ento::shouldRegisterContainerModeling(const CheckerManager &mgr) {
+  if (!mgr.getLangOpts().CPlusPlus)
+return false;
+
+  if (!mgr.getAnalyzerOptions().ShouldAggressivelySimplifyBinaryOperation) {
+mgr.getASTContext().getDiagnostics().Report(
+diag::err_analyzer_checker_incompatible_analyzer_option)
+  << "aggressive-binary-operation-simplification" << "false";
+return false;
+  }
+
   return true;
 }
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/Diagnos

[PATCH] D75739: [clangd][vscode] Enable dot-to-arrow fixes in clangd completion.

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

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75739

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -65,6 +65,15 @@
   }
 }
 
+class EnableEditsNearCursorFeature implements vscodelc.StaticFeature {
+  initialize() {}
+  fillClientCapabilities(capabilities: vscodelc.ClientCapabilities): void {
+const extendedCompletionCapabilities: any =
+capabilities.textDocument.completion;
+extendedCompletionCapabilities.editsNearCursor = true;
+  }
+}
+
 /**
  *  this method is called when your extension is activate
  *  your extension is activated the very first time the command is executed
@@ -107,17 +116,18 @@
 // By adding the prefix to the beginning of the filterText, we get a 
perfect
 // fuzzymatch score for every item.
 // The sortText (which reflects clangd ranking) breaks the tie.
+// This also prevents VSCode from filtering out any results due to the
+// differences in how fuzzy filtering is applies, e.g. enable 
dot-to-arrow
+// fixes in completion.
 //
 // We also have to mark the list as incomplete to force retrieving new 
rankings.
 // See https://github.com/microsoft/language-server-protocol/issues/898
 middleware: {
   provideCompletionItem: async (document, position, context, token, 
next) => {
-// Get the incomplete identifier before the cursor.
-let word = document.getWordRangeAtPosition(position);
-let prefix = word && document.getText(new vscode.Range(word.start, 
position));
-
 let list = await next(document, position, context, token);
 let items = (Array.isArray(list) ? list : list.items).map(item => {
+  // Gets the prefix used by vscode when doing fuzzymatch.
+  let prefix = document.getText(new vscode.Range(item.range.start, 
position))
   if (prefix)
 item.filterText = prefix + "_" + item.filterText;
   return item;
@@ -137,6 +147,7 @@
 vscode.Disposable.from(semanticHighlightingFeature));
 clangdClient.registerFeature(semanticHighlightingFeature);
   }
+  clangdClient.registerFeature(new EnableEditsNearCursorFeature);
   console.log('Clang Language Server is now active!');
   context.subscriptions.push(clangdClient.start());
   context.subscriptions.push(vscode.commands.registerCommand(


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -65,6 +65,15 @@
   }
 }
 
+class EnableEditsNearCursorFeature implements vscodelc.StaticFeature {
+  initialize() {}
+  fillClientCapabilities(capabilities: vscodelc.ClientCapabilities): void {
+const extendedCompletionCapabilities: any =
+capabilities.textDocument.completion;
+extendedCompletionCapabilities.editsNearCursor = true;
+  }
+}
+
 /**
  *  this method is called when your extension is activate
  *  your extension is activated the very first time the command is executed
@@ -107,17 +116,18 @@
 // By adding the prefix to the beginning of the filterText, we get a perfect
 // fuzzymatch score for every item.
 // The sortText (which reflects clangd ranking) breaks the tie.
+// This also prevents VSCode from filtering out any results due to the
+// differences in how fuzzy filtering is applies, e.g. enable dot-to-arrow
+// fixes in completion.
 //
 // We also have to mark the list as incomplete to force retrieving new rankings.
 // See https://github.com/microsoft/language-server-protocol/issues/898
 middleware: {
   provideCompletionItem: async (document, position, context, token, next) => {
-// Get the incomplete identifier before the cursor.
-let word = document.getWordRangeAtPosition(position);
-let prefix = word && document.getText(new vscode.Range(word.start, position));
-
 let list = await next(document, position, context, token);
 let items = (Array.isArray(list) ? list : list.items).map(item => {
+  // Gets the prefix used by vscode when doing fuzzymatch.
+  let prefix = document.getText(new vscode.Range(item.range.start, position))
   if (prefix)
 item.filterText = prefix + "_" 

[PATCH] D75739: [clangd][vscode] Enable dot-to-arrow fixes in clangd completion.

2020-03-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked 2 inline comments as done.
hokein added a comment.

In D75739#1909637 , @sammccall wrote:

> So the core of this is a better version of my patch, thanks!
>  It does work around the problem with dot-to-arrow, which is useful and we 
> should definitely enable that.
>
> We get into this mess because we merge two edits together, I think to avoid 
> LSP's vague prohibition about edits related to the cursor. My vote would be:
>
> 1. check this patch in, but without claiming it as the correct and carefully 
> architected fix for dot-to-arrow
> 2. try turning off range-merging, and test it in a couple of clients 
> (including vscode *without* this patch)
> 3. if it works, make that change in clangd


I think if we do that, we are likely to go back to the issue 
 that sending 
additionalEdit related to the cursor, and LSP clearly states it is not 
supported -- `Additional text edits should be used to change text unrelated to 
the current cursor position`, and it would not work in VSCode.

> However I actually think the dot-to-arrow problem is our bug at this point. 
> LSP is vague but the discussion on language-server-protocol#898 very sensibly 
> links filterText to textEdit.range. If we're sending filterText = "foo", 
> textEdit.range = ".f" then I don't think that *is* a match.

Regarding the mismatch between filterText and textEdit.range, there is another 
way to make them matched -- sending `filterText=".foo"` (rather than `foo`) 
from clangd,  vscode should work without this patch, but it looks like a hack 
in clangd to me...

> How does this handle cases where an object overloads the -> operator or worse 
> still overloads the operator and has conflicting names when accessed with .  
> or ->.

This patch shouldn't affect the existing behavior for the mentioned case,  it 
is handled by Sema. VSCode will show both candidates (one of them will correct 
the `.` while the other will not).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75739



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


[PATCH] D75614: [Analyzer][StreamChecker] Check for opened stream before operations.

2020-03-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 249044.
balazske added a comment.

rebase to master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75614

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -3,9 +3,9 @@
 typedef __typeof__(sizeof(int)) size_t;
 typedef __typeof__(sizeof(int)) fpos_t;
 typedef struct _IO_FILE FILE;
-#define SEEK_SET	0	/* Seek from beginning of file.  */
-#define SEEK_CUR	1	/* Seek from current position.  */
-#define SEEK_END	2	/* Seek from end of file.  */
+#define SEEK_SET  0  /* Seek from beginning of file.  */
+#define SEEK_CUR  1  /* Seek from current position.  */
+#define SEEK_END  2  /* Seek from end of file.  */
 extern FILE *fopen(const char *path, const char *mode);
 extern FILE *tmpfile(void);
 extern int fclose(FILE *fp);
@@ -108,19 +108,56 @@
 
 void f_double_close(void) {
   FILE *p = fopen("foo", "r");
-  fclose(p); 
-  fclose(p); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
+  if (!p)
+return;
+  fclose(p);
+  fclose(p); // expected-warning {{Stream might be already closed}}
 }
 
 void f_double_close_alias(void) {
   FILE *p1 = fopen("foo", "r");
+  if (!p1)
+return;
   FILE *p2 = p1;
   fclose(p1);
-  fclose(p2); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
+  fclose(p2); // expected-warning {{Stream might be already closed}}
+}
+
+void f_use_after_close(void) {
+  FILE *p = fopen("foo", "r");
+  if (!p)
+return;
+  fclose(p);
+  clearerr(p); // expected-warning {{Stream might be already closed}}
+}
+
+void f_open_after_close(void) {
+  FILE *p = fopen("foo", "r");
+  if (!p)
+return;
+  fclose(p);
+  p = fopen("foo", "r");
+  if (!p)
+return;
+  fclose(p);
+}
+
+void f_reopen_after_close(void) {
+  FILE *p = fopen("foo", "r");
+  if (!p)
+return;
+  fclose(p);
+  // Allow reopen after close.
+  p = freopen("foo", "w", p);
+  if (!p)
+return;
+  fclose(p);
 }
 
 void f_leak(int c) {
   FILE *p = fopen("foo.c", "r");
+  if (!p)
+return;
   if(c)
 return; // expected-warning {{Opened File never closed. Potential Resource leak}}
   fclose(p);
@@ -155,13 +192,13 @@
 if (f2) {
   // Check if f1 and f2 point to the same stream.
   fclose(f1);
-  fclose(f2); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
+  fclose(f2); // expected-warning {{Stream might be already closed.}}
 } else {
   // Reopen failed.
-  // f1 points now to a possibly invalid stream but this condition is currently not checked.
-  // f2 is NULL.
-  rewind(f1);
-  rewind(f2); // expected-warning {{Stream pointer might be NULL}}
+  // f1 is non-NULL but points to a possibly invalid stream.
+  rewind(f1); // expected-warning {{Stream might be invalid}}
+  // f2 is NULL but the previous error stops the checker.
+  rewind(f2);
 }
   }
 }
@@ -170,9 +207,9 @@
   FILE *f1 = fopen("foo.c", "r");
   if (f1) {
 // Unchecked result of freopen.
-// The f1 may be invalid after this call (not checked by the checker).
+// The f1 may be invalid after this call.
 freopen(0, "w", f1);
-rewind(f1);
+rewind(f1); // expected-warning {{Stream might be invalid}}
 fclose(f1);
   }
-}
+}
\ No newline at end of file
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -34,7 +34,7 @@
 
   bool isOpened() const { return K == Opened; }
   bool isClosed() const { return K == Closed; }
-  //bool isOpenFailed() const { return K == OpenFailed; }
+  bool isOpenFailed() const { return K == OpenFailed; }
   //bool isEscaped() const { return K == Escaped; }
 
   bool operator==(const StreamState &X) const { return K == X.K; }
@@ -74,7 +74,7 @@
 class StreamChecker
 : public Checker {
   mutable std::unique_ptr BT_nullfp, BT_illegalwhence,
-  BT_doubleclose, BT_ResourceLeak;
+  BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak;
 
 public:
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -88,7 +88,7 @@
{&StreamChecker::preFreopen, &StreamChecker::evalFreopen, 2}},
   {{"tmpfile"}, {nullptr, &StreamChecker::evalFopen, ArgNone}},
   {{"fclose", 1},
-   {&StreamChecker::preFclose, &StreamChecker::evalFclose, 0}},
+   {&StreamChecker::preDefault, &StreamChecker::evalFclose, 0}},
   {{"fread", 4}, {&StreamChecker::preDefault, nullptr, 3}},
   {{"fwrite", 4}, {&StreamChecker::preDefault, nullptr, 3}},
   {{"fseek", 3

[clang] ce1a862 - [Analyzer][StreamChecker] Check for opened stream before operations.

2020-03-09 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2020-03-09T11:00:03+01:00
New Revision: ce1a86251bb42fbbc7cc21feb416ed7a0bf411b7

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

LOG: [Analyzer][StreamChecker] Check for opened stream before operations.

Summary:
According to documentations, after an `fclose` call any other stream
operations cause undefined behaviour, regardless if the close failed
or not.
This change adds the check for the opened state before all other
(applicable) operations.

Reviewers: Szelethus

Reviewed By: Szelethus

Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, 
Szelethus, donat.nagy, dkrupp, gamesh411, Charusso, martong, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
clang/test/Analysis/stream.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 9d8d276bd701..7e5bf7c376f0 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -34,7 +34,7 @@ struct StreamState {
 
   bool isOpened() const { return K == Opened; }
   bool isClosed() const { return K == Closed; }
-  //bool isOpenFailed() const { return K == OpenFailed; }
+  bool isOpenFailed() const { return K == OpenFailed; }
   //bool isEscaped() const { return K == Escaped; }
 
   bool operator==(const StreamState &X) const { return K == X.K; }
@@ -74,7 +74,7 @@ SVal getStreamArg(const FnDescription *Desc, const CallEvent 
&Call) {
 class StreamChecker
 : public Checker {
   mutable std::unique_ptr BT_nullfp, BT_illegalwhence,
-  BT_doubleclose, BT_ResourceLeak;
+  BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak;
 
 public:
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -88,7 +88,7 @@ class StreamChecker
{&StreamChecker::preFreopen, &StreamChecker::evalFreopen, 2}},
   {{"tmpfile"}, {nullptr, &StreamChecker::evalFopen, ArgNone}},
   {{"fclose", 1},
-   {&StreamChecker::preFclose, &StreamChecker::evalFclose, 0}},
+   {&StreamChecker::preDefault, &StreamChecker::evalFclose, 0}},
   {{"fread", 4}, {&StreamChecker::preDefault, nullptr, 3}},
   {{"fwrite", 4}, {&StreamChecker::preDefault, nullptr, 3}},
   {{"fseek", 3}, {&StreamChecker::preFseek, nullptr, 0}},
@@ -110,8 +110,6 @@ class StreamChecker
   void evalFreopen(const FnDescription *Desc, const CallEvent &Call,
CheckerContext &C) const;
 
-  void preFclose(const FnDescription *Desc, const CallEvent &Call,
- CheckerContext &C) const;
   void evalFclose(const FnDescription *Desc, const CallEvent &Call,
   CheckerContext &C) const;
 
@@ -128,12 +126,11 @@ class StreamChecker
   ProgramStateRef ensureStreamNonNull(SVal StreamVal, CheckerContext &C,
   ProgramStateRef State) const;  
 
-  /// Check that the stream is not closed.
-  /// Return a state where the stream is guaranteed to not in closed state
-  /// (if data about it exists).
-  /// Generate error if the stream is provable in closed state.
-  ProgramStateRef ensureStreamNotClosed(SVal StreamVal, CheckerContext &C,
-ProgramStateRef State) const;
+  /// Check that the stream is the opened state.
+  /// If the stream is known to be not opened an error is generated
+  /// and nullptr returned, otherwise the original state is returned.
+  ProgramStateRef ensureStreamOpened(SVal StreamVal, CheckerContext &C,
+ ProgramStateRef State) const;
 
   /// Check the legality of the 'whence' argument of 'fseek'.
   /// Generate error and return nullptr if it is found to be illegal.
@@ -263,16 +260,6 @@ void StreamChecker::evalFreopen(const FnDescription *Desc,
   C.addTransition(StateRetNull);
 }
 
-void StreamChecker::preFclose(const FnDescription *Desc, const CallEvent &Call,
-  CheckerContext &C) const {
-  ProgramStateRef State = C.getState();
-  State = ensureStreamNotClosed(getStreamArg(Desc, Call), C, State);
-  if (!State)
-return;
-
-  C.addTransition(State);
-}
-
 void StreamChecker::evalFclose(const FnDescription *Desc, const CallEvent 
&Call,
CheckerContext &C) const {
   ProgramStateRef State = C.getState();
@@ -297,6 +284,9 @@ void StreamChecker::preFseek(const FnDescription *Desc, 
const CallEvent &Call,
   ProgramStateRef State = C.getState();
   SVal StreamVal = getStreamArg(Desc, Call);
   State = ensureStreamNonNull(StreamVal, C, State);
+  if (!State)
+return;
+  State = ensureStreamOpened(StreamVal, 

[clang] 2c36c23 - Recommit "[Driver] Default to -fno-common for all targets"

2020-03-09 Thread Sjoerd Meijer via cfe-commits

Author: Sjoerd Meijer
Date: 2020-03-09T10:07:37Z
New Revision: 2c36c23f3476baf3b9283ea387c579419a70b112

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

LOG: Recommit "[Driver] Default to -fno-common for all targets"

This includes fixes for:
- test-suite: some benchmarks need to be compiled with -fcommon, see D75557.
- compiler-rt: one test needed -fcommon, and another a change, see D75520.

Added: 
clang/test/Driver/no-common.c

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
clang/test/CodeGen/2009-10-20-GlobalDebug.c
clang/test/CodeGen/aarch64-sve.c
clang/test/CodeGen/address-space.c
clang/test/CodeGen/alias.c
clang/test/CodeGen/align-systemz.c
clang/test/CodeGen/alignment.c
clang/test/CodeGen/asm-label.c
clang/test/CodeGen/attr-weak-import.c
clang/test/CodeGen/attr-weakref2.c
clang/test/CodeGen/attributes.c
clang/test/CodeGen/blocks-windows.c
clang/test/CodeGen/bool-convert.c
clang/test/CodeGen/c11atomics.c
clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c
clang/test/CodeGen/cfstring-windows.c
clang/test/CodeGen/default-address-space.c
clang/test/CodeGen/dllexport-1.c
clang/test/CodeGen/dllexport.c
clang/test/CodeGen/dllimport.c
clang/test/CodeGen/microsoft-no-common-align.c
clang/test/CodeGen/no-common.c
clang/test/CodeGen/pr25786.c
clang/test/CodeGen/pragma-pack-1.c
clang/test/CodeGen/pragma-weak.c
clang/test/CodeGen/private-extern-redef.c
clang/test/CodeGen/tentative-decls.c
clang/test/CodeGen/tls-model.c
clang/test/CodeGen/visibility.c
clang/test/CodeGen/vlt_to_pointer.c
clang/test/CodeGen/volatile-1.c
clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c
clang/test/CodeGenCXX/clang-sections-tentative.c
clang/test/CodeGenObjC/constant-string-class.m
clang/test/CodeGenObjC/tentative-cfconstantstring.m
clang/test/CodeGenOpenCL/address-spaces.cl
clang/test/CodeGenOpenCL/amdgcn-large-globals.cl
clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
clang/test/Driver/apple-kext-mkernel.c
clang/test/Driver/clang_f_opts.c
clang/test/Driver/fuchsia.c
clang/test/Driver/xcore-opts.c
clang/test/Frontend/ast-codegen.c
clang/test/Headers/xmmintrin.c
clang/test/PCH/chain-external-defs.c
clang/test/PCH/external-defs.c
clang/test/PCH/tentative-defs.c
clang/test/Parser/pragma-visibility2.c
compiler-rt/test/asan/TestCases/Linux/odr_c_test.c
compiler-rt/test/asan/TestCases/set_shadow_test.c

Removed: 
clang/test/CodeGen/weak-global.c



diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 609e7fa66c00..5af9d64ae0fc 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1307,6 +1307,10 @@ Use colors in diagnostics
 
 .. option:: -fcommon, -fno-common
 
+Place definitions of variables with no storage class and no initializer
+(tentative definitions) in a common block, instead of generating individual
+zero-initialized definitions (default -fno-common).
+
 .. option:: -fcompile-resource=, --resource , --resource=
 
 .. option:: -fconstant-cfstrings, -fno-constant-cfstrings

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ce121ebe6055..664ae4e4167c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -84,6 +84,13 @@ future versions of Clang.
 Modified Compiler Flags
 ---
 
+- -fno-common has been enabled as the default for all targets.  Therefore, C
+  code that uses tentative definitions as definitions of a variable in multiple
+  translation units will trigger multiple-definition linker errors.  Generally,
+  this occurs when the use of the ``extern`` keyword is neglected in the 
declaration
+  of a variable in a header file. In some cases, no specific translation unit
+  provides a definition of the variable. The previous behavior can be restored 
by
+  specifying ``-fcommon``.
 
 New Pragmas in Clang
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0d5cba8d682a..bdcd771ff713 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -848,7 +848,8 @@ def fno_record_command_line : Flag<["-"], 
"fno-record-command-line">,
   Group;
 def : Flag<["-"], "frecord-gcc-switches">, Alias;
 def : Flag<["-"], "fno-record-gcc-switches">, Alias;
-def fcommon : Flag<["-"], "fcommon">, Group;
+def fcommon : Flag<["-"], "f

[PATCH] D75839: [Analyzer] Mark constant member functions const in CheckerManager

2020-03-09 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, Szelethus.
baloghadamsoftware added a project: clang.
Herald added subscribers: martong, steakhal, Charusso, gamesh411, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.

Most of the getter functions (and a reporter function) in `CheckerManager` are 
constant but not marked as `const`. This prevents functions having only a 
constant reference to `CheckerManager` using these member functions. This patch 
fixes this issue.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75839

Files:
  clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  clang/lib/StaticAnalyzer/Core/CheckerManager.cpp


Index: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -61,7 +61,8 @@
 }
 
 void CheckerManager::reportInvalidCheckerOptionValue(
-const CheckerBase *C, StringRef OptionName, StringRef ExpectedValueDesc) {
+const CheckerBase *C, StringRef OptionName,
+StringRef ExpectedValueDesc) const {
 
   Context.getDiagnostics()
   .Report(diag::err_analyzer_checker_option_invalid_input)
@@ -249,7 +250,7 @@
 }
 
 const std::vector &
-CheckerManager::getObjCMessageCheckers(ObjCMessageVisitKind Kind) {
+CheckerManager::getObjCMessageCheckers(ObjCMessageVisitKind Kind) const {
   switch (Kind) {
   case ObjCMessageVisitKind::Pre:
 return PreObjCMessageCheckers;
Index: clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -140,14 +140,14 @@
   void finishedCheckerRegistration();
 
   const LangOptions &getLangOpts() const { return LangOpts; }
-  AnalyzerOptions &getAnalyzerOptions() { return AOptions; }
-  ASTContext &getASTContext() { return Context; }
+  AnalyzerOptions &getAnalyzerOptions() const { return AOptions; }
+  ASTContext &getASTContext() const { return Context; }
 
   /// Emits an error through a DiagnosticsEngine about an invalid user supplied
   /// checker option value.
   void reportInvalidCheckerOptionValue(const CheckerBase *C,
StringRef OptionName,
-   StringRef ExpectedValueDesc);
+   StringRef ExpectedValueDesc) const;
 
   using CheckerRef = CheckerBase *;
   using CheckerTag = const void *;
@@ -620,7 +620,7 @@
   /// Returns the checkers that have registered for callbacks of the
   /// given \p Kind.
   const std::vector &
-  getObjCMessageCheckers(ObjCMessageVisitKind Kind);
+  getObjCMessageCheckers(ObjCMessageVisitKind Kind) const;
 
   std::vector PreObjCMessageCheckers;
   std::vector PostObjCMessageCheckers;


Index: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -61,7 +61,8 @@
 }
 
 void CheckerManager::reportInvalidCheckerOptionValue(
-const CheckerBase *C, StringRef OptionName, StringRef ExpectedValueDesc) {
+const CheckerBase *C, StringRef OptionName,
+StringRef ExpectedValueDesc) const {
 
   Context.getDiagnostics()
   .Report(diag::err_analyzer_checker_option_invalid_input)
@@ -249,7 +250,7 @@
 }
 
 const std::vector &
-CheckerManager::getObjCMessageCheckers(ObjCMessageVisitKind Kind) {
+CheckerManager::getObjCMessageCheckers(ObjCMessageVisitKind Kind) const {
   switch (Kind) {
   case ObjCMessageVisitKind::Pre:
 return PreObjCMessageCheckers;
Index: clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -140,14 +140,14 @@
   void finishedCheckerRegistration();
 
   const LangOptions &getLangOpts() const { return LangOpts; }
-  AnalyzerOptions &getAnalyzerOptions() { return AOptions; }
-  ASTContext &getASTContext() { return Context; }
+  AnalyzerOptions &getAnalyzerOptions() const { return AOptions; }
+  ASTContext &getASTContext() const { return Context; }
 
   /// Emits an error through a DiagnosticsEngine about an invalid user supplied
   /// checker option value.
   void reportInvalidCheckerOptionValue(const CheckerBase *C,
StringRef OptionName,
-   StringRef ExpectedValueDesc);
+   StringRef ExpectedValueDesc) const;
 
   using CheckerRef = CheckerBase *;
   using CheckerTag = const void *;
@@ -620,7 +620,7 @@
   /// Returns the checkers that have registered f

[PATCH] D74619: [ARM] Enabling range checks on Neon intrinsics' lane arguments

2020-03-09 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio added inline comments.



Comment at: clang/test/CodeGen/arm-neon-range-checks.c:7
+void test_vdot_lane(int32x2_t r, int8x8_t a, int8x8_t b) {
+  vdot_lane_s32(r, a, b, -1); // expected-error {{argument value -1 is outside 
the valid range}}
+  vdot_lane_s32(r, a, b, 2); // expected-error {{argument value 2 is outside 
the valid range}}

Could we have the valid range in the tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74619



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


[PATCH] D75614: [Analyzer][StreamChecker] Check for opened stream before operations.

2020-03-09 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce1a86251bb4: [Analyzer][StreamChecker] Check for opened 
stream before operations. (authored by balazske).

Changed prior to commit:
  https://reviews.llvm.org/D75614?vs=249044&id=249049#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75614

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -3,9 +3,9 @@
 typedef __typeof__(sizeof(int)) size_t;
 typedef __typeof__(sizeof(int)) fpos_t;
 typedef struct _IO_FILE FILE;
-#define SEEK_SET	0	/* Seek from beginning of file.  */
-#define SEEK_CUR	1	/* Seek from current position.  */
-#define SEEK_END	2	/* Seek from end of file.  */
+#define SEEK_SET  0  /* Seek from beginning of file.  */
+#define SEEK_CUR  1  /* Seek from current position.  */
+#define SEEK_END  2  /* Seek from end of file.  */
 extern FILE *fopen(const char *path, const char *mode);
 extern FILE *tmpfile(void);
 extern int fclose(FILE *fp);
@@ -108,19 +108,56 @@
 
 void f_double_close(void) {
   FILE *p = fopen("foo", "r");
-  fclose(p); 
-  fclose(p); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
+  if (!p)
+return;
+  fclose(p);
+  fclose(p); // expected-warning {{Stream might be already closed}}
 }
 
 void f_double_close_alias(void) {
   FILE *p1 = fopen("foo", "r");
+  if (!p1)
+return;
   FILE *p2 = p1;
   fclose(p1);
-  fclose(p2); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
+  fclose(p2); // expected-warning {{Stream might be already closed}}
+}
+
+void f_use_after_close(void) {
+  FILE *p = fopen("foo", "r");
+  if (!p)
+return;
+  fclose(p);
+  clearerr(p); // expected-warning {{Stream might be already closed}}
+}
+
+void f_open_after_close(void) {
+  FILE *p = fopen("foo", "r");
+  if (!p)
+return;
+  fclose(p);
+  p = fopen("foo", "r");
+  if (!p)
+return;
+  fclose(p);
+}
+
+void f_reopen_after_close(void) {
+  FILE *p = fopen("foo", "r");
+  if (!p)
+return;
+  fclose(p);
+  // Allow reopen after close.
+  p = freopen("foo", "w", p);
+  if (!p)
+return;
+  fclose(p);
 }
 
 void f_leak(int c) {
   FILE *p = fopen("foo.c", "r");
+  if (!p)
+return;
   if(c)
 return; // expected-warning {{Opened File never closed. Potential Resource leak}}
   fclose(p);
@@ -155,13 +192,13 @@
 if (f2) {
   // Check if f1 and f2 point to the same stream.
   fclose(f1);
-  fclose(f2); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
+  fclose(f2); // expected-warning {{Stream might be already closed.}}
 } else {
   // Reopen failed.
-  // f1 points now to a possibly invalid stream but this condition is currently not checked.
-  // f2 is NULL.
-  rewind(f1);
-  rewind(f2); // expected-warning {{Stream pointer might be NULL}}
+  // f1 is non-NULL but points to a possibly invalid stream.
+  rewind(f1); // expected-warning {{Stream might be invalid}}
+  // f2 is NULL but the previous error stops the checker.
+  rewind(f2);
 }
   }
 }
@@ -170,9 +207,9 @@
   FILE *f1 = fopen("foo.c", "r");
   if (f1) {
 // Unchecked result of freopen.
-// The f1 may be invalid after this call (not checked by the checker).
+// The f1 may be invalid after this call.
 freopen(0, "w", f1);
-rewind(f1);
+rewind(f1); // expected-warning {{Stream might be invalid}}
 fclose(f1);
   }
-}
+}
\ No newline at end of file
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -34,7 +34,7 @@
 
   bool isOpened() const { return K == Opened; }
   bool isClosed() const { return K == Closed; }
-  //bool isOpenFailed() const { return K == OpenFailed; }
+  bool isOpenFailed() const { return K == OpenFailed; }
   //bool isEscaped() const { return K == Escaped; }
 
   bool operator==(const StreamState &X) const { return K == X.K; }
@@ -74,7 +74,7 @@
 class StreamChecker
 : public Checker {
   mutable std::unique_ptr BT_nullfp, BT_illegalwhence,
-  BT_doubleclose, BT_ResourceLeak;
+  BT_UseAfterClose, BT_UseAfterOpenFailed, BT_ResourceLeak;
 
 public:
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -88,7 +88,7 @@
{&StreamChecker::preFreopen, &StreamChecker::evalFreopen, 2}},
   {{"tmpfile"}, {nullptr, &StreamChecker::evalFopen, ArgNone}},
   {{"fclose", 1},
-   {&StreamChecker::preFclose, &StreamChecker::evalFclose, 0}},
+   {&StreamChecker::pr

[clang] c8cd1a9 - [AArch64] Add support for Fujitsu A64FX

2020-03-09 Thread KAWASHIMA Takahiro via cfe-commits

Author: KAWASHIMA Takahiro
Date: 2020-03-09T19:15:09+09:00
New Revision: c8cd1a994d28e5e822bd0d3c9a6b0aae2abb510f

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

LOG: [AArch64] Add support for Fujitsu A64FX

A64FX is an Armv8.2-A CPU used in FUJITSU Supercomputer
PRIMEHPC FX1000, PRIMEHPC FX700, and supercomputer Fugaku.

https://www.fujitsu.com/global/products/computing/servers/supercomputer/specifications/

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

Added: 


Modified: 
clang/test/Driver/aarch64-cpus.c
clang/test/Preprocessor/aarch64-target-features.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/lib/Support/Host.cpp
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/test/CodeGen/AArch64/cpus.ll
llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
llvm/unittests/Support/Host.cpp
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Driver/aarch64-cpus.c 
b/clang/test/Driver/aarch64-cpus.c
index f1b53d98e150..36444f02e955 100644
--- a/clang/test/Driver/aarch64-cpus.c
+++ b/clang/test/Driver/aarch64-cpus.c
@@ -269,6 +269,20 @@
 // ARM64-THUNDERX2T99-TUNE: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"generic"
 // ARM64-THUNDERX2T99-TUNE-NOT: +v8.1a
 
+// RUN: %clang -target aarch64 -mcpu=a64fx -### -c %s 2>&1 | FileCheck 
-check-prefix=A64FX %s
+// RUN: %clang -target aarch64 -mlittle-endian -mcpu=a64fx -### -c %s 2>&1 | 
FileCheck -check-prefix=A64FX %s
+// RUN: %clang -target aarch64 -mtune=a64fx -### -c %s 2>&1 | FileCheck 
-check-prefix=A64FX-TUNE %s
+// RUN: %clang -target aarch64 -mlittle-endian -mtune=a64fx -### -c %s 2>&1 | 
FileCheck -check-prefix=A64FX-TUNE %s
+// A64FX: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "a64fx"
+// A64FX-TUNE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic"
+
+// RUN: %clang -target arm64 -mcpu=a64fx -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-A64FX %s
+// RUN: %clang -target arm64 -mlittle-endian -mcpu=a64fx -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-A64FX %s
+// RUN: %clang -target arm64 -mtune=a64fx -### -c %s 2>&1 | FileCheck 
-check-prefix=ARM64-A64FX-TUNE %s
+// RUN: %clang -target arm64 -mlittle-endian -mtune=a64fx -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64-A64FX-TUNE %s
+// ARM64-A64FX: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "a64fx"
+// ARM64-A64FX-TUNE: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"generic"
+
 // RUN: %clang -target aarch64_be -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s
 // RUN: %clang -target aarch64 -mbig-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s
 // RUN: %clang -target aarch64_be -mbig-endian -### -c %s 2>&1 | FileCheck 
-check-prefix=GENERIC-BE %s

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 9fb8dcecb9c0..c62c82a0c96a 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -160,6 +160,7 @@
 // RUN: %clang -target aarch64 -mcpu=exynos-m5 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-M4 %s
 // RUN: %clang -target aarch64 -mcpu=kryo -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-KRYO %s
 // RUN: %clang -target aarch64 -mcpu=thunderx2t99 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-THUNDERX2T99 %s
+// RUN: %clang -target aarch64 -mcpu=a64fx -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-MCPU-A64FX %s
 // CHECK-MCPU-APPLE-A7: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crypto" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" 
"+sha2" "-target-feature" "+aes"
 // CHECK-MCPU-APPLE-A10: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+rdm" "-target-feature" 
"+zcm" "-target-feature" "+zcz" "-target-feature" "+sha2" "-target-feature" 
"+aes"
 // CHECK-MCPU-APPLE-A11: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" 
"+zcm" "-target-feature" "+zcz" "-target-feature" "+sha2" "-target-feature" 
"+aes"
@@ -175,6 +176,7 @@
 // CHECK-MCPU-M4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fullfp16"
 // CHECK-MCPU-KRYO: "-cc1"{{.*}} "-tripl

[clang] 25f2639 - [OpenCL] Fix 'any' and 'all' builtins

2020-03-09 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-03-09T10:26:11Z
New Revision: 25f2639fab1187c3aca5570f23809721cc0a8f76

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

LOG: [OpenCL] Fix 'any' and 'all' builtins

These should only be defined for signed integer types according to
OpenCL v2.0 s6.12.6.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 876409848246..e5109dfbb048 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -687,7 +687,7 @@ foreach name = ["isfinite", "isinf", "isnan", "isnormal", 
"signbit"] in {
   def : Builtin;
 }
 foreach name = ["any", "all"] in {
-  def : Builtin;
+  def : Builtin;
 }
 
 // --- 2 arguments ---



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


[clang] f35d112 - Revert "Recommit "[Driver] Default to -fno-common for all targets""

2020-03-09 Thread Sjoerd Meijer via cfe-commits

Author: Sjoerd Meijer
Date: 2020-03-09T10:37:28Z
New Revision: f35d112efdb33abee853aeab8a5ed4a4743e204d

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

LOG: Revert "Recommit "[Driver] Default to -fno-common for all targets""

This reverts commit 2c36c23f3476baf3b9283ea387c579419a70b112.

Still problems in the test-suite, which I really thought I had fixed...

Added: 
clang/test/CodeGen/weak-global.c

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
clang/test/CodeGen/2009-10-20-GlobalDebug.c
clang/test/CodeGen/aarch64-sve.c
clang/test/CodeGen/address-space.c
clang/test/CodeGen/alias.c
clang/test/CodeGen/align-systemz.c
clang/test/CodeGen/alignment.c
clang/test/CodeGen/asm-label.c
clang/test/CodeGen/attr-weak-import.c
clang/test/CodeGen/attr-weakref2.c
clang/test/CodeGen/attributes.c
clang/test/CodeGen/blocks-windows.c
clang/test/CodeGen/bool-convert.c
clang/test/CodeGen/c11atomics.c
clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c
clang/test/CodeGen/cfstring-windows.c
clang/test/CodeGen/default-address-space.c
clang/test/CodeGen/dllexport-1.c
clang/test/CodeGen/dllexport.c
clang/test/CodeGen/dllimport.c
clang/test/CodeGen/microsoft-no-common-align.c
clang/test/CodeGen/no-common.c
clang/test/CodeGen/pr25786.c
clang/test/CodeGen/pragma-pack-1.c
clang/test/CodeGen/pragma-weak.c
clang/test/CodeGen/private-extern-redef.c
clang/test/CodeGen/tentative-decls.c
clang/test/CodeGen/tls-model.c
clang/test/CodeGen/visibility.c
clang/test/CodeGen/vlt_to_pointer.c
clang/test/CodeGen/volatile-1.c
clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c
clang/test/CodeGenCXX/clang-sections-tentative.c
clang/test/CodeGenObjC/constant-string-class.m
clang/test/CodeGenObjC/tentative-cfconstantstring.m
clang/test/CodeGenOpenCL/address-spaces.cl
clang/test/CodeGenOpenCL/amdgcn-large-globals.cl
clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
clang/test/Driver/apple-kext-mkernel.c
clang/test/Driver/clang_f_opts.c
clang/test/Driver/fuchsia.c
clang/test/Driver/xcore-opts.c
clang/test/Frontend/ast-codegen.c
clang/test/Headers/xmmintrin.c
clang/test/PCH/chain-external-defs.c
clang/test/PCH/external-defs.c
clang/test/PCH/tentative-defs.c
clang/test/Parser/pragma-visibility2.c
compiler-rt/test/asan/TestCases/Linux/odr_c_test.c
compiler-rt/test/asan/TestCases/set_shadow_test.c

Removed: 
clang/test/Driver/no-common.c



diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 5af9d64ae0fc..609e7fa66c00 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1307,10 +1307,6 @@ Use colors in diagnostics
 
 .. option:: -fcommon, -fno-common
 
-Place definitions of variables with no storage class and no initializer
-(tentative definitions) in a common block, instead of generating individual
-zero-initialized definitions (default -fno-common).
-
 .. option:: -fcompile-resource=, --resource , --resource=
 
 .. option:: -fconstant-cfstrings, -fno-constant-cfstrings

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 664ae4e4167c..ce121ebe6055 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -84,13 +84,6 @@ future versions of Clang.
 Modified Compiler Flags
 ---
 
-- -fno-common has been enabled as the default for all targets.  Therefore, C
-  code that uses tentative definitions as definitions of a variable in multiple
-  translation units will trigger multiple-definition linker errors.  Generally,
-  this occurs when the use of the ``extern`` keyword is neglected in the 
declaration
-  of a variable in a header file. In some cases, no specific translation unit
-  provides a definition of the variable. The previous behavior can be restored 
by
-  specifying ``-fcommon``.
 
 New Pragmas in Clang
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index bdcd771ff713..0d5cba8d682a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -848,8 +848,7 @@ def fno_record_command_line : Flag<["-"], 
"fno-record-command-line">,
   Group;
 def : Flag<["-"], "frecord-gcc-switches">, Alias;
 def : Flag<["-"], "fno-record-gcc-switches">, Alias;
-def fcommon : Flag<["-"], "fcommon">, Group,
-  Flags<[CoreOption, CC1Option]>, HelpText<"Place uninitializ

[PATCH] D64464: [CodeGen] Emit destructor calls to destruct compound literals

2020-03-09 Thread Gabor Marton via Phabricator via cfe-commits
martong resigned from this revision.
martong added a comment.

Looks good from the ASTImporter's point of view. I don't have the competence to 
review the rest, so I am resigning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64464



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


[PATCH] D75594: [AArch64] Add support for Fujitsu A64FX

2020-03-09 Thread KAWASHIMA Takahiro via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc8cd1a994d28: [AArch64] Add support for Fujitsu A64FX 
(authored by kawashima-fj).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75594

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
  llvm/unittests/Support/Host.cpp
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -964,9 +964,15 @@
   AArch64::AEK_RDM | AArch64::AEK_PROFILE | AArch64::AEK_FP16 |
   AArch64::AEK_FP16FML | AArch64::AEK_DOTPROD,
   "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "a64fx", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_FP16 | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_SVE | AArch64::AEK_RDM,
+  "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 36;
+static constexpr unsigned NumAArch64CPUArchs = 37;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
@@ -1107,6 +1113,12 @@
AArch64::ArchKind::INVALID, "fp16fml"));
   EXPECT_TRUE(testAArch64Extension("tsv110",
AArch64::ArchKind::INVALID, "dotprod"));
+  EXPECT_TRUE(testAArch64Extension("a64fx",
+   AArch64::ArchKind::INVALID, "fp16"));
+  EXPECT_TRUE(testAArch64Extension("a64fx",
+   AArch64::ArchKind::INVALID, "sve"));
+  EXPECT_FALSE(testAArch64Extension("a64fx",
+   AArch64::ArchKind::INVALID, "sve2"));
 
   EXPECT_FALSE(testAArch64Extension(
   "generic", AArch64::ArchKind::ARMV8A, "ras"));
Index: llvm/unittests/Support/Host.cpp
===
--- llvm/unittests/Support/Host.cpp
+++ llvm/unittests/Support/Host.cpp
@@ -249,6 +249,19 @@
   EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0x48\n"
   "CPU part: 0xd01"),
 "tsv110");
+
+  // Verify A64FX.
+  const std::string A64FXProcCpuInfo = R"(
+processor   : 0
+BogoMIPS: 200.00
+Features: fp asimd evtstrm sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm fcma dcpop sve
+CPU implementer : 0x46
+CPU architecture: 8
+CPU variant : 0x1
+CPU part: 0x001
+)";
+
+  EXPECT_EQ(sys::detail::getHostCPUNameForARM(A64FXProcCpuInfo), "a64fx");
 }
 
 #if defined(__APPLE__) || defined(_AIX)
Index: llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
===
--- llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
+++ llvm/test/CodeGen/AArch64/preferred-function-alignment.ll
@@ -8,6 +8,7 @@
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=cortex-a73 < %s | FileCheck --check-prefixes=ALIGN4,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=cortex-a75 < %s | FileCheck --check-prefixes=ALIGN4,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=cortex-a76 < %s | FileCheck --check-prefixes=ALIGN4,CHECK %s
+; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=a64fx < %s | FileCheck --check-prefixes=ALIGN5,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=cyclone < %s | FileCheck --check-prefixes=ALIGN2,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=falkor < %s | FileCheck --check-prefixes=ALIGN2,CHECK %s
 ; RUN: llc -mtriple=aarch64-unknown-linux -mcpu=kryo < %s | FileCheck --check-prefixes=ALIGN2,CHECK %s
Index: llvm/test/CodeGen/AArch64/cpus.ll
===
--- llvm/test/CodeGen/AArch64/cpus.ll
+++ llvm/test/CodeGen/AArch64/cpus.ll
@@ -25,6 +25,7 @@
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=thunderx2t99 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=tsv110 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=apple-latest 2>&1 | FileCheck %s
+; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=a64fx 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=invalidcpu 2>&1 | FileCheck %s --check-prefix=INVALID
 
 ; CHECK-NOT: {{.*}}  is not a recognized processor for this target
Index: llvm/lib/Target/AArch64/AArch64Subtarget.h
===

[clang] 8d67bcf - [ASTImporter] Added visibility check for variable templates.

2020-03-09 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2020-03-09T11:57:55+01:00
New Revision: 8d67bcf93c1ecb65d30f5e9b56b4f0c493bde1c3

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

LOG: [ASTImporter] Added visibility check for variable templates.

Summary:
ASTImporter makes now difference between variable templates
with same name in different translation units if not visible
outside.

Reviewers: a.sidorin, shafik, a_sidorin

Reviewed By: a_sidorin

Subscribers: dkrupp, Szelethus, gamesh411, teemperor, martong, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp
clang/unittests/AST/ASTImporterVisibilityTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 9f174e9c2440..ffe867cbee22 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -5489,6 +5489,10 @@ ExpectedDecl 
ASTNodeImporter::VisitVarTemplateDecl(VarTemplateDecl *D) {
   continue;
 
 if (VarTemplateDecl *FoundTemplate = dyn_cast(FoundDecl)) 
{
+  // Use the templated decl, some linkage flags are set only there.
+  if 
(!hasSameVisibilityContextAndLinkage(FoundTemplate->getTemplatedDecl(),
+  D->getTemplatedDecl()))
+continue;
   if (IsStructuralMatch(D, FoundTemplate)) {
 // The Decl in the "From" context has a definition, but in the
 // "To" context we already have a definition.

diff  --git a/clang/unittests/AST/ASTImporterVisibilityTest.cpp 
b/clang/unittests/AST/ASTImporterVisibilityTest.cpp
index 14a6706cc761..00a307b8940b 100644
--- a/clang/unittests/AST/ASTImporterVisibilityTest.cpp
+++ b/clang/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -49,6 +49,12 @@ struct GetFunTemplPattern {
 return functionTemplateDecl(hasName("f"));
   }
 };
+struct GetVarTemplPattern {
+  using DeclTy = VarTemplateDecl;
+  BindableMatcher operator()() {
+return namedDecl(hasName("v"), has(templateTypeParmDecl()));
+  }
+};
 struct GetClassTemplPattern {
   using DeclTy = ClassTemplateDecl;
   BindableMatcher operator()() { return classTemplateDecl(hasName("X")); 
}
@@ -80,6 +86,10 @@ const auto *AnonUsing = "namespace { using T = int; }";
 const auto *ExternFT = "template  void f();";
 const auto *StaticFT = "template  static void f();";
 const auto *AnonFT = "namespace { template  void f(); }";
+// VarTemplateDecl:
+const auto *ExternVT = "template  extern int v;";
+const auto *StaticVT = "template  static int v;";
+const auto *AnonVT = "namespace { template  extern int v; }";
 // ClassTemplateDecl:
 const auto *ExternCT = "template  class X;";
 const auto *AnonCT = "namespace { template  class X; }";
@@ -130,6 +140,8 @@ using ImportClassesVisibilityChain = 
ImportVisibilityChain;
 using ImportScopedEnumsVisibilityChain = ImportVisibilityChain;
 using ImportFunctionTemplatesVisibilityChain =
 ImportVisibilityChain;
+using ImportVariableTemplatesVisibilityChain =
+ImportVisibilityChain;
 using ImportClassTemplatesVisibilityChain =
 ImportVisibilityChain;
 
@@ -153,6 +165,10 @@ TEST_P(ImportScopedEnumsVisibilityChain, ImportChain) {
 TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
+// Value-parameterized test for variable templates.
+TEST_P(ImportVariableTemplatesVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
 // Value-parameterized test for class templates.
 TEST_P(ImportClassTemplatesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
@@ -190,6 +206,11 @@ INSTANTIATE_TEST_CASE_P(ParameterizedTests,
 ::testing::Combine(DefaultTestValuesForRunOptions,
::testing::Values(ExternFT, 
StaticFT,
  AnonFT)), );
+INSTANTIATE_TEST_CASE_P(ParameterizedTests,
+ImportVariableTemplatesVisibilityChain,
+::testing::Combine(DefaultTestValuesForRunOptions,
+   ::testing::Values(ExternVT,
+ AnonVT)), );
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, 
ImportClassTemplatesVisibilityChain,
 ::testing::Combine(DefaultTestValuesForRunOptions,
::testing::Values(ExternCT,
@@ -306,6 +327,7 @@ using ImportEnumsVisibility = 
ImportVisibility;
 using ImportScopedEnumsVisibility = ImportVisibility;
 using ImportTypedefNameVisibility = ImportVisibility;
 using ImportFunctionTemplatesVisibility = ImportVisibility;
+using ImportVariableTemplatesVisibility = ImportVisibility;
 using ImportClassTemplatesVisibility = Impor

[clang] 59a960b - [analyzer] Skip analysis of inherited ctor as top-level function

2020-03-09 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-03-09T12:05:11+01:00
New Revision: 59a960b83c2d1559f31e1dd75728dd24fae2f68c

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

LOG: [analyzer] Skip analysis of inherited ctor as top-level function

Summary:
This fixes a regression introduced in https://reviews.llvm.org/D74735

Reviewers: NoQ, Szelethus

Tags: #clang

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

Added: 
clang/test/Analysis/cxx-inherited-ctor-is-skipped-as-top-level.cpp

Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
index 60705dd27d6b..402acf667d53 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -896,6 +896,23 @@ class CXXConstructorCall : public AnyCXXConstructorCall {
 /// Represents a call to a C++ inherited constructor.
 ///
 /// Example: \c class T : public S { using S::S; }; T(1);
+///
+// Note, it is 
diff icult to model the parameters. This is one of the reasons
+// why we skip analysis of inheriting constructors as top-level functions.
+// CXXInheritedCtorInitExpr doesn't take arguments and doesn't model parameter
+// initialization because there is none: the arguments in the outer
+// CXXConstructExpr directly initialize the parameters of the base class
+// constructor, and no copies are made. (Making a copy of the parameter is
+// incorrect, at least if it's done in an observable way.) The derived class
+// constructor doesn't even exist in the formal model.
+/// E.g., in:
+///
+/// struct X { X *p = this; ~X() {} };
+/// struct A { A(X x) : b(x.p == &x) {} bool b; };
+/// struct B : A { using A::A; };
+/// B b = X{};
+///
+/// ... b.b is initialized to true.
 class CXXInheritedConstructorCall : public AnyCXXConstructorCall {
   friend class CallEventManager;
 

diff  --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp 
b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
index 417eb7ec3d31..a908aede68bb 100644
--- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -519,6 +519,13 @@ static bool shouldSkipFunction(const Decl *D,
   if (VisitedAsTopLevel.count(D))
 return true;
 
+  // Skip analysis of inheriting constructors as top-level functions. These
+  // constructors don't even have a body written down in the code, so even if
+  // we find a bug, we won't be able to display it.
+  if (const auto *CD = dyn_cast(D))
+if (CD->isInheritingConstructor())
+  return true;
+
   // We want to re-analyse the functions as top level in the following cases:
   // - The 'init' methods should be reanalyzed because
   //   ObjCNonNilReturnValueChecker assumes that '[super init]' never returns

diff  --git a/clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp 
b/clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp
index ff82c129bc70..8370ebfbde09 100644
--- a/clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp
+++ b/clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp
@@ -57,3 +57,19 @@ void test_B() {
   clang_analyzer_eval(b.z == 3); // expected-warning{{TRUE}}
 }
 } // namespace arguments_with_constructors
+
+namespace inherited_constructor_crash {
+class a {
+public:
+  a(int);
+};
+struct b : a {
+  using a::a; // Ihnerited ctor.
+};
+void c() {
+  int d;
+  // This construct expr utilizes the inherited ctor.
+  // Note that d must be uninitialized to cause the crash.
+  (b(d)); // expected-warning{{1st function call argument is an uninitialized 
value}}
+}
+} // namespace inherited_constructor_crash

diff  --git 
a/clang/test/Analysis/cxx-inherited-ctor-is-skipped-as-top-level.cpp 
b/clang/test/Analysis/cxx-inherited-ctor-is-skipped-as-top-level.cpp
new file mode 100644
index ..be7982e64114
--- /dev/null
+++ b/clang/test/Analysis/cxx-inherited-ctor-is-skipped-as-top-level.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-display-progress 
%s 2>&1 | FileCheck %s
+
+// Test that inheriting constructors are not analyzed as top-level functions.
+
+// CHECK: ANALYZE (Path,  Inline_Regular): {{.*}} c()
+// CHECK: ANALYZE (Path,  Inline_Regular): {{.*}} a::a(int)
+// CHECK-NOT: ANALYZE (Path,  Inline_Regular): {{.*}} b::a(int)
+
+class a {
+public:
+  a(int) {}
+};
+struct b : a {
+  using a::a; // Ihnerited ctor.
+};
+void c() {
+  int d;
+  (b(d));
+  (a(d));
+}



___
cf

[clang] c15c68a - [CallSiteInfo] Enable the call site info only for -g + optimizations

2020-03-09 Thread Djordje Todorovic via cfe-commits

Author: Djordje Todorovic
Date: 2020-03-09T12:12:44+01:00
New Revision: c15c68abdc6f1afece637bdedba808676191a8e6

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

LOG: [CallSiteInfo] Enable the call site info only for -g + optimizations

Emit call site info only in the case of '-g' + 'O>0' level.

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

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Frontend/CompilerInvocation.cpp
llvm/include/llvm/CodeGen/CommandFlags.inc
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/CodeGen/MachineFunction.cpp
llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
llvm/test/CodeGen/X86/call-site-info-output.ll
llvm/test/DebugInfo/AArch64/call-site-info-output.ll
llvm/test/DebugInfo/ARM/call-site-info-output.ll
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-expr-chain.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-expr-entry-value.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
llvm/test/DebugInfo/MIR/AArch64/implicit-def-dead-scope.mir
llvm/test/DebugInfo/MIR/ARM/call-site-info-vmovd.mir
llvm/test/DebugInfo/MIR/ARM/call-site-info-vmovs.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
llvm/test/DebugInfo/MIR/ARM/dbgcallsite-noreg-is-imm-check.mir
llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg-multiple-defs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 48c0df49e32d..3c8b0eeb47a5 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -64,6 +64,8 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
+CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
+   ///< '-g' + 'O>0' level.
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index b244fd499fb0..b6ca46e7e835 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -487,6 +487,7 @@ static void initTargetOptions(llvm::TargetOptions &Options,
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
   Options.EnableDebugEntryValues = CodeGenOpts.EnableDebugEntryValues;
   Options.ForceDwarfFrameSection = CodeGenOpts.ForceDwarfFrameSection;
+  Options.EmitCallSiteIn

[PATCH] D75068: libclang: Add static build support for Windows

2020-03-09 Thread Cristian Adam via Phabricator via cfe-commits
cristian.adam added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75068



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


[PATCH] D75271: [analyzer][NFC] Change LangOptions to CheckerManager in the shouldRegister* functions.

2020-03-09 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware accepted this revision.
baloghadamsoftware added a comment.
This revision is now accepted and ready to land.

OK, I agree, these issues should be solved in other patches. I already solved 
one, but the other one is strange. I will open a BugZilla ticket for it.


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

https://reviews.llvm.org/D75271



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


[PATCH] D75175: [CallSiteInfo] Enable the call site info only for -g + optimizations

2020-03-09 Thread Djordje Todorovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc15c68abdc6f: [CallSiteInfo] Enable the call site info only 
for -g + optimizations (authored by djtodoro).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D75175?vs=248667&id=249060#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75175

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/CodeGen/CommandFlags.inc
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/MIRParser/MIRParser.cpp
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
  llvm/test/CodeGen/X86/call-site-info-output.ll
  llvm/test/DebugInfo/AArch64/call-site-info-output.ll
  llvm/test/DebugInfo/ARM/call-site-info-output.ll
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-expr-chain.mir
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-expr-entry-value.mir
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
  llvm/test/DebugInfo/MIR/AArch64/implicit-def-dead-scope.mir
  llvm/test/DebugInfo/MIR/ARM/call-site-info-vmovd.mir
  llvm/test/DebugInfo/MIR/ARM/call-site-info-vmovs.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcallsite-noreg-is-imm-check.mir
  llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
  llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
  llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
  llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
  llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
  llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
  llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg-multiple-defs.mir
  llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
  llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
  llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
  llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
  llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
  llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
  llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
  llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
  llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
  llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll

Index: llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
===
--- llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
+++ llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
@@ -1,4 +1,4 @@
-; RUN: llc -debug-entry-values %s -o - -filetype=obj \
+; RUN: llc -emit-call-site-info -debug-entry-values %s -o - -filetype=obj \
 ; RUN:   | llvm-dwarfdump -statistics - | FileCheck %s
 ;
 ; The LLVM IR file was generated on this source code by using
Index: llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
===
--- llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
+++ llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
@@ -1,4 +1,4 @@
-; RUN: llc -O3 -debug-entry-values -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
+; RUN: llc -O3 -emit-call-site-info -debug-entry-values -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
===
--- llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
+++ llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
@@ -1,4 +1,4 @@
-; RUN: llc -O1 -debug-entry-values -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
+; RUN: llc -O1 -emit-call-site-info -debug-entry-values -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s
 
 ; Verify that the 64-bit call site 

[PATCH] D75678: [analyzer] Skip analysis of inherited ctor as top-level function

2020-03-09 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:511
+  //
+  // Also, we cannot model the parameters. CXXInheritedCtorInitExpr doesn't
+  // take arguments and doesn't model parameter initialization because there is

NoQ wrote:
> I'd rather put this Richard's comment somewhere near the respective 
> `CallEvent` definition. We clearly don't need to analyze these functions, so 
> it doesn't really matter for anybody who reads this code that there are 
> temporary technical difficulties with analyzing them. On the other hand, it 
> does matter a lot for people who try to understand how to implement the call 
> event correctly.
Ok, I moved this part of the comment into CallEvent.h .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75678



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


[PATCH] D75732: [ASTImporter] Added visibility check for variable templates.

2020-03-09 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8d67bcf93c1e: [ASTImporter] Added visibility check for 
variable templates. (authored by balazske).

Changed prior to commit:
  https://reviews.llvm.org/D75732?vs=248692&id=249059#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75732

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterVisibilityTest.cpp

Index: clang/unittests/AST/ASTImporterVisibilityTest.cpp
===
--- clang/unittests/AST/ASTImporterVisibilityTest.cpp
+++ clang/unittests/AST/ASTImporterVisibilityTest.cpp
@@ -49,6 +49,12 @@
 return functionTemplateDecl(hasName("f"));
   }
 };
+struct GetVarTemplPattern {
+  using DeclTy = VarTemplateDecl;
+  BindableMatcher operator()() {
+return namedDecl(hasName("v"), has(templateTypeParmDecl()));
+  }
+};
 struct GetClassTemplPattern {
   using DeclTy = ClassTemplateDecl;
   BindableMatcher operator()() { return classTemplateDecl(hasName("X")); }
@@ -80,6 +86,10 @@
 const auto *ExternFT = "template  void f();";
 const auto *StaticFT = "template  static void f();";
 const auto *AnonFT = "namespace { template  void f(); }";
+// VarTemplateDecl:
+const auto *ExternVT = "template  extern int v;";
+const auto *StaticVT = "template  static int v;";
+const auto *AnonVT = "namespace { template  extern int v; }";
 // ClassTemplateDecl:
 const auto *ExternCT = "template  class X;";
 const auto *AnonCT = "namespace { template  class X; }";
@@ -130,6 +140,8 @@
 using ImportScopedEnumsVisibilityChain = ImportVisibilityChain;
 using ImportFunctionTemplatesVisibilityChain =
 ImportVisibilityChain;
+using ImportVariableTemplatesVisibilityChain =
+ImportVisibilityChain;
 using ImportClassTemplatesVisibilityChain =
 ImportVisibilityChain;
 
@@ -153,6 +165,10 @@
 TEST_P(ImportFunctionTemplatesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
 }
+// Value-parameterized test for variable templates.
+TEST_P(ImportVariableTemplatesVisibilityChain, ImportChain) {
+  TypedTest_ImportChain();
+}
 // Value-parameterized test for class templates.
 TEST_P(ImportClassTemplatesVisibilityChain, ImportChain) {
   TypedTest_ImportChain();
@@ -190,6 +206,11 @@
 ::testing::Combine(DefaultTestValuesForRunOptions,
::testing::Values(ExternFT, StaticFT,
  AnonFT)), );
+INSTANTIATE_TEST_CASE_P(ParameterizedTests,
+ImportVariableTemplatesVisibilityChain,
+::testing::Combine(DefaultTestValuesForRunOptions,
+   ::testing::Values(ExternVT,
+ AnonVT)), );
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportClassTemplatesVisibilityChain,
 ::testing::Combine(DefaultTestValuesForRunOptions,
::testing::Values(ExternCT,
@@ -306,6 +327,7 @@
 using ImportScopedEnumsVisibility = ImportVisibility;
 using ImportTypedefNameVisibility = ImportVisibility;
 using ImportFunctionTemplatesVisibility = ImportVisibility;
+using ImportVariableTemplatesVisibility = ImportVisibility;
 using ImportClassTemplatesVisibility = ImportVisibility;
 
 // FunctionDecl.
@@ -356,6 +378,13 @@
 TEST_P(ImportFunctionTemplatesVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImport();
 }
+// VarTemplateDecl.
+TEST_P(ImportVariableTemplatesVisibility, ImportAfter) {
+  TypedTest_ImportAfter();
+}
+TEST_P(ImportVariableTemplatesVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImport();
+}
 // ClassTemplateDecl.
 TEST_P(ImportClassTemplatesVisibility, ImportAfter) { TypedTest_ImportAfter(); }
 TEST_P(ImportClassTemplatesVisibility, ImportAfterImport) {
@@ -463,6 +492,20 @@
 std::make_tuple(AnonFT, StaticFT, ExpectUnlinkedDeclChain),
 std::make_tuple(AnonFT, AnonFT, ExpectUnlinkedDeclChain))), );
 INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportVariableTemplatesVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(
+std::make_tuple(ExternVT, ExternVT, ExpectLinkedDeclChain),
+std::make_tuple(ExternVT, StaticVT, ExpectUnlinkedDeclChain),
+std::make_tuple(ExternVT, AnonVT, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticVT, ExternVT, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticVT, StaticVT, ExpectUnlinkedDeclChain),
+std::make_tuple(StaticVT, AnonVT, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonVT, ExternVT, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonVT, StaticVT, ExpectUnlinkedDeclChain),
+std::make_tuple(AnonVT, AnonVT, ExpectUnlinkedDeclChain))), );

[PATCH] D75805: Make malign-double effective only for x86

2020-03-09 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 249054.
kamleshbhalui added a reviewer: MaskRay.

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

https://reviews.llvm.org/D75805

Files:
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2916,7 +2916,8 @@
   Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, 
Diags);
-  Opts.AlignDouble = Args.hasArg(OPT_malign_double);
+  Opts.AlignDouble =
+  T.getArch() == llvm::Triple::x86 && Args.hasArg(OPT_malign_double);
   Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
 ? 128
 : Args.hasArg(OPT_mlong_double_64) ? 64 : 0;


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2916,7 +2916,8 @@
   Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
-  Opts.AlignDouble = Args.hasArg(OPT_malign_double);
+  Opts.AlignDouble =
+  T.getArch() == llvm::Triple::x86 && Args.hasArg(OPT_malign_double);
   Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
 ? 128
 : Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75678: [analyzer] Skip analysis of inherited ctor as top-level function

2020-03-09 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
martong marked an inline comment as done.
Closed by commit rG59a960b83c2d: [analyzer] Skip analysis of inherited ctor as 
top-level function (authored by martong).

Changed prior to commit:
  https://reviews.llvm.org/D75678?vs=248678&id=249058#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75678

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp
  clang/test/Analysis/cxx-inherited-ctor-is-skipped-as-top-level.cpp


Index: clang/test/Analysis/cxx-inherited-ctor-is-skipped-as-top-level.cpp
===
--- /dev/null
+++ clang/test/Analysis/cxx-inherited-ctor-is-skipped-as-top-level.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-display-progress 
%s 2>&1 | FileCheck %s
+
+// Test that inheriting constructors are not analyzed as top-level functions.
+
+// CHECK: ANALYZE (Path,  Inline_Regular): {{.*}} c()
+// CHECK: ANALYZE (Path,  Inline_Regular): {{.*}} a::a(int)
+// CHECK-NOT: ANALYZE (Path,  Inline_Regular): {{.*}} b::a(int)
+
+class a {
+public:
+  a(int) {}
+};
+struct b : a {
+  using a::a; // Ihnerited ctor.
+};
+void c() {
+  int d;
+  (b(d));
+  (a(d));
+}
Index: clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp
===
--- clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp
+++ clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp
@@ -57,3 +57,19 @@
   clang_analyzer_eval(b.z == 3); // expected-warning{{TRUE}}
 }
 } // namespace arguments_with_constructors
+
+namespace inherited_constructor_crash {
+class a {
+public:
+  a(int);
+};
+struct b : a {
+  using a::a; // Ihnerited ctor.
+};
+void c() {
+  int d;
+  // This construct expr utilizes the inherited ctor.
+  // Note that d must be uninitialized to cause the crash.
+  (b(d)); // expected-warning{{1st function call argument is an uninitialized 
value}}
+}
+} // namespace inherited_constructor_crash
Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -519,6 +519,13 @@
   if (VisitedAsTopLevel.count(D))
 return true;
 
+  // Skip analysis of inheriting constructors as top-level functions. These
+  // constructors don't even have a body written down in the code, so even if
+  // we find a bug, we won't be able to display it.
+  if (const auto *CD = dyn_cast(D))
+if (CD->isInheritingConstructor())
+  return true;
+
   // We want to re-analyse the functions as top level in the following cases:
   // - The 'init' methods should be reanalyzed because
   //   ObjCNonNilReturnValueChecker assumes that '[super init]' never returns
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -896,6 +896,23 @@
 /// Represents a call to a C++ inherited constructor.
 ///
 /// Example: \c class T : public S { using S::S; }; T(1);
+///
+// Note, it is difficult to model the parameters. This is one of the reasons
+// why we skip analysis of inheriting constructors as top-level functions.
+// CXXInheritedCtorInitExpr doesn't take arguments and doesn't model parameter
+// initialization because there is none: the arguments in the outer
+// CXXConstructExpr directly initialize the parameters of the base class
+// constructor, and no copies are made. (Making a copy of the parameter is
+// incorrect, at least if it's done in an observable way.) The derived class
+// constructor doesn't even exist in the formal model.
+/// E.g., in:
+///
+/// struct X { X *p = this; ~X() {} };
+/// struct A { A(X x) : b(x.p == &x) {} bool b; };
+/// struct B : A { using A::A; };
+/// B b = X{};
+///
+/// ... b.b is initialized to true.
 class CXXInheritedConstructorCall : public AnyCXXConstructorCall {
   friend class CallEventManager;
 


Index: clang/test/Analysis/cxx-inherited-ctor-is-skipped-as-top-level.cpp
===
--- /dev/null
+++ clang/test/Analysis/cxx-inherited-ctor-is-skipped-as-top-level.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-display-progress %s 2>&1 | FileCheck %s
+
+// Test that inheriting constructors are not analyzed as top-level functions.
+
+// CHECK: ANALYZE (Path,  Inline_Regular): {{.*}} c()
+// CHECK: ANALYZE (Path,  Inline_Regular): {{.*}} a::a(int)
+// CHECK-NOT: ANALYZE (Path,  Inline_Regu

[PATCH] D74766: [ARM] Fixing range checks for Neon's vqdmulhq_lane and vqrdmulhq_lane intrinsics

2020-03-09 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio added inline comments.



Comment at: clang/test/CodeGen/arm-neon-range-checks.c:284-285
+void test_vqdmulhq_lane(int32x4_t a, int32x2_t b) {
+  vqdmulhq_lane_s32(a, b, -1); // expected-error {{argument value -1 is 
outside the valid range}}
+  vqdmulhq_lane_s32(a, b, 2); // expected-error {{argument value 2 is outside 
the valid range}}
+  vqdmulhq_lane_s32(a, b, 0);

As the previous one, could we have it testing the actual ranges?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74766



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


[PATCH] D75841: [ASTMatchers] Add hasAnyOverloadedOperatorName matcher

2020-03-09 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75841

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -898,6 +898,12 @@
   DeclarationMatcher AnyOpStar = functionDecl(hasOverloadedOperatorName("*"));
   EXPECT_TRUE(matches("class Y; int operator*(Y &);", AnyOpStar));
   EXPECT_TRUE(matches("class Y { int operator*(); };", AnyOpStar));
+  DeclarationMatcher AnyAndOp =
+  functionDecl(hasAnyOverloadedOperatorName("&", "&&"));
+  EXPECT_TRUE(matches("class Y; Y operator&(Y &, Y &);", AnyAndOp));
+  EXPECT_TRUE(matches("class Y; Y operator&&(Y &, Y &);", AnyAndOp));
+  EXPECT_TRUE(matches("class Y { Y operator&(Y &); };", AnyAndOp));
+  EXPECT_TRUE(matches("class Y { Y operator&&(Y &); };", AnyAndOp));
 }
 
 
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -244,6 +244,7 @@
   REGISTER_MATCHER(hasAnyDeclaration);
   REGISTER_MATCHER(hasAnyName);
   REGISTER_MATCHER(hasAnyOperatorName);
+  REGISTER_MATCHER(hasAnyOverloadedOperatorName);
   REGISTER_MATCHER(hasAnyParameter);
   REGISTER_MATCHER(hasAnyPlacementArg);
   REGISTER_MATCHER(hasAnySelector);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -378,6 +378,11 @@
   return HasOpNameMatcher(vectorFromRefs(NameRefs));
 }
 
+HasOverloadOpNameMatcher
+hasAnyOverloadedOperatorNameFunc(ArrayRef NameRefs) {
+  return HasOverloadOpNameMatcher(vectorFromRefs(NameRefs));
+}
+
 HasNameMatcher::HasNameMatcher(std::vector N)
 : UseUnqualifiedMatch(llvm::all_of(
   N, [](StringRef Name) { return Name.find("::") == Name.npos; })),
@@ -861,6 +866,9 @@
 const internal::VariadicFunction
 hasAnyOperatorName = {};
+const internal::VariadicFunction
+hasAnyOverloadedOperatorName = {};
 const internal::VariadicFunction, StringRef,
  internal::hasAnySelectorFunc>
 hasAnySelector = {};
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -670,12 +670,12 @@
   static_assert(std::is_same::value ||
 std::is_base_of::value,
 "unsupported class for matcher");
-  static_assert(std::is_same::value,
-"argument type must be StringRef");
+  static_assert(std::is_same>::value,
+"argument type must be std::vector");
 
 public:
-  explicit HasOverloadedOperatorNameMatcher(const StringRef Name)
-  : SingleNodeMatcherInterface(), Name(Name) {}
+  explicit HasOverloadedOperatorNameMatcher(std::vector Names)
+  : SingleNodeMatcherInterface(), Names(std::move(Names)) {}
 
   bool matchesNode(const T &Node) const override {
 return matchesSpecialized(Node);
@@ -687,17 +687,18 @@
   /// so this function returns true if the call is to an operator of the given
   /// name.
   bool matchesSpecialized(const CXXOperatorCallExpr &Node) const {
-return getOperatorSpelling(Node.getOperator()) == Name;
+return llvm::is_contained(Names, getOperatorSpelling(Node.getOperator()));
   }
 
   /// Returns true only if CXXMethodDecl represents an overloaded
   /// operator and has the given operator name.
   bool matchesSpecialized(const FunctionDecl &Node) const {
 return Node.isOverloadedOperator() &&
-   getOperatorSpelling(Node.getOverloadedOperator()) == Name;
+   llvm::is_contained(
+   Names, getOperatorSpelling(Node.getOverloadedOperator()));
   }
 
-  std::string Name;
+  const std::vector Names;
 };
 
 /// Matches named declarations with a specific name.
@@ -1899,6 +1900,13 @@
 
 HasOpNameMatcher hasAnyOperatorNameFunc(ArrayRef NameRefs);
 
+using HasOverloadOpNameMatcher = PolymorphicMatcherWithParam1<
+HasOverloadedOperatorNameMatcher, std::vector,
+void(TypeList)>;
+
+HasOverloadOpNameMatcher
+hasAnyOverloadedOperatorNameFunc(ArrayRef NameRefs);
+
 } // namespace internal
 
 } // namespace ast_matchers
Index: clang/include/clang/ASTMa

[PATCH] D75714: Add Optional overload to DiagnosticBuilder operator <

2020-03-09 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang/include/clang/Basic/Diagnostic.h:1318
+   const llvm::Optional &Opt) {
+  if (Opt) {
+DB << *Opt;

Should this be disabled on functions that pass format args to the diagnostic so 
it will only optionally add things FixIts, Notes, Ranges...?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75714



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


[PATCH] D75184: [clang-tidy] Optional inheritance of file configs from parent directories 

2020-03-09 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@alexfh could you please take another look, I added more tests and updated the 
doc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184



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


[PATCH] D75839: [Analyzer] Mark constant member functions const in CheckerManager

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

LGTM, go for it! I don't think you need to wait for any more reviews on this 
before commiting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75839



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


[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

2020-03-09 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, Szelethus.
baloghadamsoftware added a project: clang.
Herald added subscribers: martong, steakhal, Charusso, gamesh411, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.

`CheckerRegistry` registers a checker either if it is excplicitly enabled or it 
is a dependency of an explicitly enabled checker and is not explicitly 
disabled. In both cases it is also important that the checker should be 
registered (`shoudRegister`//XXX//`()` returns true).

Currently there is a bug here: if the dependenct checker is not explicitly 
disabled it is registered regardless of whether it should be registered. This 
patch fixes this bug.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75842

Files:
  clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h


Index: clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
===
--- clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -166,7 +166,7 @@
 }
 
 bool isDisabled(const LangOptions &LO) const {
-  return State == StateFromCmdLine::State_Disabled && ShouldRegister(LO);
+  return State == StateFromCmdLine::State_Disabled || !ShouldRegister(LO);
 }
 
 // Since each checker must have a different full name, we can identify


Index: clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
===
--- clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -166,7 +166,7 @@
 }
 
 bool isDisabled(const LangOptions &LO) const {
-  return State == StateFromCmdLine::State_Disabled && ShouldRegister(LO);
+  return State == StateFromCmdLine::State_Disabled || !ShouldRegister(LO);
 }
 
 // Since each checker must have a different full name, we can identify
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75184: [clang-tidy] Optional inheritance of file configs from parent directories 

2020-03-09 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 249065.
DmitryPolukhin marked an inline comment as done.
DmitryPolukhin added a comment.
Herald added a subscriber: arphaman.

Also updated rst file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/clang-tidy/index.rst
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -7,6 +7,23 @@
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s -check-prefix=CHECK-CHILD2
 // CHECK-CHILD2: Checks: {{.*}}from-parent
 // CHECK-CHILD2: HeaderFilterRegex: parent
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/3/- -- | FileCheck %s -check-prefix=CHECK-CHILD3
+// CHECK-CHILD3: Checks: {{.*}}from-parent,from-child3
+// CHECK-CHILD3: HeaderFilterRegex: child3
 // RUN: clang-tidy -dump-config -checks='from-command-line' -header-filter='from command line' %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=CHECK-COMMAND-LINE
 // CHECK-COMMAND-LINE: Checks: {{.*}}from-parent,from-command-line
 // CHECK-COMMAND-LINE: HeaderFilterRegex: from command line
+
+// For this test we have to use names of the real checks because otherwise values are ignored.
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD4
+// CHECK-CHILD4: Checks: {{.*}}modernize-loop-convert,llvm-qualified-auto
+// CHECK-CHILD4: - key: llvm-qualified-auto.AddConstToQualified
+// CHECK-CHILD4-NEXT: value: '1
+// CHECK-CHILD4: - key: modernize-loop-convert.MaxCopySize
+// CHECK-CHILD4-NEXT: value: '20'
+// CHECK-CHILD4: - key: modernize-loop-convert.MinConfidence
+// CHECK-CHILD4-NEXT: value: reasonable
+
+// RUN: clang-tidy --explain-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-EXPLAIN
+// CHECK-EXPLAIN: 'llvm-qualified-auto' is enabled in the {{.*}}/Inputs/config-files/4/44/.clang-tidy.
+// CHECK-EXPLAIN: 'modernize-loop-convert' is enabled in the {{.*}}/Inputs/config-files/4/.clang-tidy.
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy
@@ -0,0 +1,7 @@
+InheritParentConfig: true
+Checks: 'llvm-qualified-auto'
+CheckOptions:
+  - key: modernize-loop-convert.MaxCopySize
+value:   '20'
+  - key: llvm-qualified-auto.AddConstToQualified
+value:   '1'
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy
@@ -0,0 +1,6 @@
+Checks: '-*,modernize-loop-convert'
+CheckOptions:
+  - key: modernize-loop-convert.MaxCopySize
+value:   '10'
+  - key: modernize-loop-convert.MinConfidence
+value:   reasonable
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
@@ -0,0 +1,3 @@
+InheritParentConfig: true
+Checks: 'from-child3'
+HeaderFilterRegex: 'child3'
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -244,17 +244,20 @@
   Configuration files:
 clang-tidy attempts to read configuration for each source file from a
 .clang-tidy file located in the closest parent directory of the source
-file. If any configuration options have a corresponding command-line
-option, command-line option takes precedence. The effective
-configuration can be inspected using -dump-config:
+file. If InheritParentConfig is true in a config file, the configuration file
+in the parent directory (if any exists) will be taken and current config file
+will be applied on top of the parent one. If any configuration optio

[PATCH] D75843: [ARM,CDE] Implement CDE feature test macros

2020-03-09 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: simon_tatham, dmgreen, ostannard, MarkMurrayARM.
Herald added subscribers: cfe-commits, danielkiss, kristof.beyls.
Herald added a project: clang.

This patch implements feature test macros for the CDE extension
according to the upcoming ACLE specification.

The following 2 macros are being added:

- __ARM_FEATURE_CDE - defined as '1' when any coprocessor is configured as a 
CDE coprocessor
- __ARM_FEATURE_CDE_COPROC - defined as an 8-bit mask, each bit of the mask 
corresponds to a coprocessor and is set when the corresponding coprocessor is 
configured as CDE (and cleared otherwise).

The patch also exposes the value of __ARM_FEATURE_CDE_COPROC in the
target-independent method TargetInfo::getARMCDECorpocMask, the method
will be used in follow-up patches implementing semantic checks of CDE
intrinsics (we want to diagnose the cases when CDE intrinsics are used
with coprocessors that are not configured as CDE).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75843

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/test/Preprocessor/arm-target-features.c

Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -800,6 +800,18 @@
 // CHECK-V81M-MVE-NODSP-NOT: #define __ARM_FEATURE_MVE
 // CHECK-V81M-MVE-NODSP-NOT: #define __ARM_FEATURE_DSP
 
+// Test CDE (Custom Datapath Extension) feature test macros
+
+// RUN: %clang -target arm-arm-none-eabi -march=armv8m.main -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-V8M-NOCDE %s
+// CHECK-V8M-NOCDE-NOT: #define __ARM_FEATURE_CDE
+// CHECK-V8M-NOCDE-NOT: #define __ARM_FEATURE_CDE_CORPOC
+// RUN: %clang -target arm-arm-none-eabi -march=armv8m.main+cdecp0+cdecp1+cdecp7 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V8M-CDE-MASK1 %s
+// CHECK-V8M-CDE-MASK1: #define __ARM_FEATURE_CDE 1
+// CHECK-V8M-CDE-MASK1: #define __ARM_FEATURE_CDE_COPROC 0x83
+// RUN: %clang -target arm-arm-none-eabi -march=armv8m.main+cdecp0+cdecp1+cdecp2+cdecp3+cdecp4+cdecp5+cdecp6+cdecp7 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V8M-CDE-MASK2 %s
+// CHECK-V8M-CDE-MASK2: #define __ARM_FEATURE_CDE 1
+// CHECK-V8M-CDE-MASK2: #define __ARM_FEATURE_CDE_COPROC 0xff
+
 // RUN: %clang -target armv8.1a-none-none-eabi -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81A %s
 // CHECK-V81A: #define __ARM_ARCH 8
 // CHECK-V81A: #define __ARM_ARCH_8_1A__ 1
Index: clang/lib/Basic/Targets/ARM.h
===
--- clang/lib/Basic/Targets/ARM.h
+++ clang/lib/Basic/Targets/ARM.h
@@ -108,6 +108,7 @@
   bool supportsThumb2() const;
   bool hasMVE() const;
   bool hasMVEFloat() const;
+  bool hasCDE() const;
 
   StringRef getCPUAttr() const;
   StringRef getCPUProfile() const;
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -154,6 +154,10 @@
   return hasMVE() && (MVE & MVE_FP);
 }
 
+bool ARMTargetInfo::hasCDE() const {
+  return getARMCDECorpocMask() != 0;
+}
+
 bool ARMTargetInfo::isThumb() const {
   return ArchISA == llvm::ARM::ISAKind::THUMB;
 }
@@ -422,6 +426,7 @@
   HWDiv = 0;
   DotProd = 0;
   HasFloat16 = true;
+  ARMCDECorpocMask = 0;
 
   // This does not diagnose illegal cases like having both
   // "+vfpv2" and "+vfpv3" or having "+neon" and "-fp64".
@@ -486,6 +491,9 @@
   FPU |= FPARMV8;
   MVE |= MVE_INT | MVE_FP;
   HW_FP |= HW_FP_SP | HW_FP_HP;
+} else if (Feature >= "+cdecp0" && Feature <= "+cdecp7") {
+  unsigned Coproc = Feature.back() - '0';
+  ARMCDECorpocMask |= (1U << Coproc);
 }
   }
 
@@ -758,6 +766,12 @@
 Builder.defineMacro("__ARM_FEATURE_MVE", hasMVEFloat() ? "3" : "1");
   }
 
+  if (hasCDE()) {
+Builder.defineMacro("__ARM_FEATURE_CDE", "1");
+Builder.defineMacro("__ARM_FEATURE_CDE_COPROC",
+"0x" + Twine::utohexstr(getARMCDECorpocMask()));
+  }
+
   Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
   Twine(Opts.WCharSize ? Opts.WCharSize : 4));
 
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -113,6 +113,7 @@
   HasBuiltinMSVaList = false;
   IsRenderScriptTarget = false;
   HasAArch64SVETypes = false;
+  ARMCDECorpocMask = 0;
 
   // Default to no types using fpret.
   RealTypeUsesObjCFPRet = 0;
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Bas

Re: [clang] 8e4a867 - Revert "PR45083: Mark statement expressions as being dependent if they contain"

2020-03-09 Thread Hans Wennborg via cfe-commits
On Sat, Mar 7, 2020 at 12:47 AM Richard Smith via cfe-commits
 wrote:
>
> On Fri, 6 Mar 2020 at 02:11, Stephan Herhut via cfe-commits 
>  wrote:
>>
>> Author: Stephan Herhut
>> Date: 2020-03-06T11:09:45+01:00
>> New Revision: 8e4a8677be3061317056335d298d85ce60c23dff
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/8e4a8677be3061317056335d298d85ce60c23dff
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/8e4a8677be3061317056335d298d85ce60c23dff.diff
>>
>> LOG: Revert "PR45083: Mark statement expressions as being dependent if they 
>> contain"
>>
>> This reverts commit a95cc77be154433c37a3110ac9af394b7447fcba.
>>
>> Causes an internal build failure. I followed up with the author by mail.
>
>
> The internal build failure is on invalid code that Clang incorrectly accepted 
> previously. Unreverting...

I can't see the unrevert. Did it land yet?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75360: [analyzer][NFC] Tie CheckerRegistry to CheckerManager, allow CheckerManager to be constructed for non-analysis purposes

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



Comment at: clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:178
+  const CheckerRegistry &getCheckerRegistry() { return Registry; }
+  DiagnosticsEngine &getDiagnostics() { return Diags; }
 

Please mark these getters as `const`.


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

https://reviews.llvm.org/D75360



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


[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

2020-03-09 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

I looked in the `unittests` directory but could not find tests for dependency 
handling. @Szelethus, feel free to commandeer this patch if you know how to 
test it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75842



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


[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

2020-03-09 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D75842#1912246 , @xazax.hun wrote:

> If we disable the dependency of a checker explicitly I think we should at 
> least emit a warning.


I agree, but I do not thik that this should be part of this patch. This is only 
a small bugfix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75842



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


[PATCH] D75844: [clang] Set begin loc on GNU attribute parsed attrs

2020-03-09 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: tstellar, serge-sans-paille.
tbaeder added a project: clang.
Herald added a subscriber: cfe-commits.

Otherwise the source range of the passed-in ParsedAttributesWithRange
ends up being invalid and the resulting error messages rather useless.
For example:

  

error: fallthrough annotation in unreachable code 
[-Werror,-Wimplicit-fallthrough]

Instead of the more useful error message, which is produced with this
commit:

  

./test.c:8:5: error: fallthrough annotation in unreachable code 
[-Werror,-Wimplicit-fallthrough]

  __attribute__((fallthrough));
  ^


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75844

Files:
  clang/lib/Parse/ParseStmt.cpp


Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -235,6 +235,7 @@
 
   case tok::kw___attribute: {
 GNUAttributeLoc = Tok.getLocation();
+Attrs.Range.setBegin(GNUAttributeLoc);
 ParseGNUAttributes(Attrs);
 goto Retry;
   }


Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -235,6 +235,7 @@
 
   case tok::kw___attribute: {
 GNUAttributeLoc = Tok.getLocation();
+Attrs.Range.setBegin(GNUAttributeLoc);
 ParseGNUAttributes(Attrs);
 goto Retry;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

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

If we disable the dependency of a checker explicitly I think we should at least 
emit a warning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75842



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


[clang-tools-extra] 6ba0a4e - [clangd][vscode] Enable dot-to-arrow fixes in clangd completion.

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

Author: Haojian Wu
Date: 2020-03-09T14:02:08+01:00
New Revision: 6ba0a4ec3bbfe71050b7b5c87f46820f3500e211

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

LOG: [clangd][vscode] Enable dot-to-arrow fixes in clangd completion.

Summary:
The previous issue is that the item was filtered out by vscode, because
the prefix (which contains ".") are not matched against the filterText.

This patch works around it by adjusting the item filterText, inspired by
https://reviews.llvm.org/D75623.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts

Removed: 




diff  --git a/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts 
b/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
index 3d8ed2d65564..4749cd1bb582 100644
--- a/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ b/clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -65,6 +65,15 @@ class ClangdLanguageClient extends vscodelc.LanguageClient {
   }
 }
 
+class EnableEditsNearCursorFeature implements vscodelc.StaticFeature {
+  initialize() {}
+  fillClientCapabilities(capabilities: vscodelc.ClientCapabilities): void {
+const extendedCompletionCapabilities: any =
+capabilities.textDocument.completion;
+extendedCompletionCapabilities.editsNearCursor = true;
+  }
+}
+
 /**
  *  this method is called when your extension is activate
  *  your extension is activated the very first time the command is executed
@@ -107,17 +116,18 @@ export function activate(context: 
vscode.ExtensionContext) {
 // By adding the prefix to the beginning of the filterText, we get a 
perfect
 // fuzzymatch score for every item.
 // The sortText (which reflects clangd ranking) breaks the tie.
+// This also prevents VSCode from filtering out any results due to the
+// 
diff erences in how fuzzy filtering is applies, e.g. enable dot-to-arrow
+// fixes in completion.
 //
 // We also have to mark the list as incomplete to force retrieving new 
rankings.
 // See https://github.com/microsoft/language-server-protocol/issues/898
 middleware: {
   provideCompletionItem: async (document, position, context, token, 
next) => {
-// Get the incomplete identifier before the cursor.
-let word = document.getWordRangeAtPosition(position);
-let prefix = word && document.getText(new vscode.Range(word.start, 
position));
-
 let list = await next(document, position, context, token);
 let items = (Array.isArray(list) ? list : list.items).map(item => {
+  // Gets the prefix used by vscode when doing fuzzymatch.
+  let prefix = document.getText(new vscode.Range(item.range.start, 
position))
   if (prefix)
 item.filterText = prefix + "_" + item.filterText;
   return item;
@@ -137,6 +147,7 @@ export function activate(context: vscode.ExtensionContext) {
 vscode.Disposable.from(semanticHighlightingFeature));
 clangdClient.registerFeature(semanticHighlightingFeature);
   }
+  clangdClient.registerFeature(new EnableEditsNearCursorFeature);
   console.log('Clang Language Server is now active!');
   context.subscriptions.push(clangdClient.start());
   context.subscriptions.push(vscode.commands.registerCommand(



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


[clang] 57f70d1 - [Analyzer] Mark constant member functions const in CheckerManager

2020-03-09 Thread Adam Balogh via cfe-commits

Author: Adam Balogh
Date: 2020-03-09T14:11:30+01:00
New Revision: 57f70d187706f572227b74c82c7446a3096f862f

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

LOG: [Analyzer] Mark constant member functions const in CheckerManager

Most of the getter functions (and a reporter function) in
`CheckerManager` are constant but not marked as `const`. This prevents
functions having only a constant reference to `CheckerManager` using
these member functions. This patch fixes this issue.

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
clang/lib/StaticAnalyzer/Core/CheckerManager.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h 
b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
index 246ff8f90d35..4454d7603b27 100644
--- a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -140,14 +140,14 @@ class CheckerManager {
   void finishedCheckerRegistration();
 
   const LangOptions &getLangOpts() const { return LangOpts; }
-  AnalyzerOptions &getAnalyzerOptions() { return AOptions; }
-  ASTContext &getASTContext() { return Context; }
+  AnalyzerOptions &getAnalyzerOptions() const { return AOptions; }
+  ASTContext &getASTContext() const { return Context; }
 
   /// Emits an error through a DiagnosticsEngine about an invalid user supplied
   /// checker option value.
   void reportInvalidCheckerOptionValue(const CheckerBase *C,
StringRef OptionName,
-   StringRef ExpectedValueDesc);
+   StringRef ExpectedValueDesc) const;
 
   using CheckerRef = CheckerBase *;
   using CheckerTag = const void *;
@@ -620,7 +620,7 @@ class CheckerManager {
   /// Returns the checkers that have registered for callbacks of the
   /// given \p Kind.
   const std::vector &
-  getObjCMessageCheckers(ObjCMessageVisitKind Kind);
+  getObjCMessageCheckers(ObjCMessageVisitKind Kind) const;
 
   std::vector PreObjCMessageCheckers;
   std::vector PostObjCMessageCheckers;

diff  --git a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp 
b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
index a9361837cf68..ce5e4a46d3e2 100644
--- a/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -61,7 +61,8 @@ void CheckerManager::finishedCheckerRegistration() {
 }
 
 void CheckerManager::reportInvalidCheckerOptionValue(
-const CheckerBase *C, StringRef OptionName, StringRef ExpectedValueDesc) {
+const CheckerBase *C, StringRef OptionName,
+StringRef ExpectedValueDesc) const {
 
   Context.getDiagnostics()
   .Report(diag::err_analyzer_checker_option_invalid_input)
@@ -249,7 +250,7 @@ void 
CheckerManager::runCheckersForObjCMessage(ObjCMessageVisitKind visitKind,
 }
 
 const std::vector &
-CheckerManager::getObjCMessageCheckers(ObjCMessageVisitKind Kind) {
+CheckerManager::getObjCMessageCheckers(ObjCMessageVisitKind Kind) const {
   switch (Kind) {
   case ObjCMessageVisitKind::Pre:
 return PreObjCMessageCheckers;



___
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-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Ping! @Anastasia I was hoping for your input on this, since it is OpenCLC++.


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] D75842: [Analyzer] Bugfix for CheckerRegistry

2020-03-09 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a subscriber: dcoughlin.
Szelethus added a comment.

In D75842#1912249 , 
@baloghadamsoftware wrote:

> In D75842#1912246 , @xazax.hun wrote:
>
> > If we disable the dependency of a checker explicitly I think we should at 
> > least emit a warning.
>
>
> I agree, but I do not thik that this should be part of this patch. This is 
> only a small bugfix.


Oof. We wanted to do that for a long time but there were compatibility concerns 
-- in any case, we totally could emit an //error// at least when 
`-analyzer-config-compatibility-mode` is false and for newer checkers and a 
warning for older ones.

I distinctively remember a lot of concerns being raised around this. 
@dcoughlin, @NoQ, how does what I suggested here sound like?

In D75842#1912250 , 
@baloghadamsoftware wrote:

> I looked in the `unittests` directory but could not find tests for dependency 
> handling. @Szelethus, feel free to commandeer this patch if you know how to 
> test it.


This should be the thing you're looking for:  
`clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp`. It might be a 
good idea to wait for me to land D67335  
first, though :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75842



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


[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri resigned from this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

No further comments from me, thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621



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


[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

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

I am not sure if I would call this a bugfix. Enabling a checker without one of 
its dependency will potentially cause the checker to misbehave. I am 
uncomfortable changing the current behavior to a more dangerous one without any 
diagnostics. Including the diagnostic with this patch should not make this too 
big.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75842



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


[PATCH] D51762: First part of the calendar stuff

2020-03-09 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
Herald added subscribers: Charusso, dexonsmith.

Committed in 5b08c1742a536f54bd5e270b00ff851cbc7314ef


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

https://reviews.llvm.org/D51762



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


[PATCH] D75839: [Analyzer] Mark constant member functions const in CheckerManager

2020-03-09 Thread Balogh, Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG57f70d187706: [Analyzer] Mark constant member functions 
const in CheckerManager (authored by baloghadamsoftware).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75839

Files:
  clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  clang/lib/StaticAnalyzer/Core/CheckerManager.cpp


Index: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -61,7 +61,8 @@
 }
 
 void CheckerManager::reportInvalidCheckerOptionValue(
-const CheckerBase *C, StringRef OptionName, StringRef ExpectedValueDesc) {
+const CheckerBase *C, StringRef OptionName,
+StringRef ExpectedValueDesc) const {
 
   Context.getDiagnostics()
   .Report(diag::err_analyzer_checker_option_invalid_input)
@@ -249,7 +250,7 @@
 }
 
 const std::vector &
-CheckerManager::getObjCMessageCheckers(ObjCMessageVisitKind Kind) {
+CheckerManager::getObjCMessageCheckers(ObjCMessageVisitKind Kind) const {
   switch (Kind) {
   case ObjCMessageVisitKind::Pre:
 return PreObjCMessageCheckers;
Index: clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -140,14 +140,14 @@
   void finishedCheckerRegistration();
 
   const LangOptions &getLangOpts() const { return LangOpts; }
-  AnalyzerOptions &getAnalyzerOptions() { return AOptions; }
-  ASTContext &getASTContext() { return Context; }
+  AnalyzerOptions &getAnalyzerOptions() const { return AOptions; }
+  ASTContext &getASTContext() const { return Context; }
 
   /// Emits an error through a DiagnosticsEngine about an invalid user supplied
   /// checker option value.
   void reportInvalidCheckerOptionValue(const CheckerBase *C,
StringRef OptionName,
-   StringRef ExpectedValueDesc);
+   StringRef ExpectedValueDesc) const;
 
   using CheckerRef = CheckerBase *;
   using CheckerTag = const void *;
@@ -620,7 +620,7 @@
   /// Returns the checkers that have registered for callbacks of the
   /// given \p Kind.
   const std::vector &
-  getObjCMessageCheckers(ObjCMessageVisitKind Kind);
+  getObjCMessageCheckers(ObjCMessageVisitKind Kind) const;
 
   std::vector PreObjCMessageCheckers;
   std::vector PostObjCMessageCheckers;


Index: clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
+++ clang/lib/StaticAnalyzer/Core/CheckerManager.cpp
@@ -61,7 +61,8 @@
 }
 
 void CheckerManager::reportInvalidCheckerOptionValue(
-const CheckerBase *C, StringRef OptionName, StringRef ExpectedValueDesc) {
+const CheckerBase *C, StringRef OptionName,
+StringRef ExpectedValueDesc) const {
 
   Context.getDiagnostics()
   .Report(diag::err_analyzer_checker_option_invalid_input)
@@ -249,7 +250,7 @@
 }
 
 const std::vector &
-CheckerManager::getObjCMessageCheckers(ObjCMessageVisitKind Kind) {
+CheckerManager::getObjCMessageCheckers(ObjCMessageVisitKind Kind) const {
   switch (Kind) {
   case ObjCMessageVisitKind::Pre:
 return PreObjCMessageCheckers;
Index: clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -140,14 +140,14 @@
   void finishedCheckerRegistration();
 
   const LangOptions &getLangOpts() const { return LangOpts; }
-  AnalyzerOptions &getAnalyzerOptions() { return AOptions; }
-  ASTContext &getASTContext() { return Context; }
+  AnalyzerOptions &getAnalyzerOptions() const { return AOptions; }
+  ASTContext &getASTContext() const { return Context; }
 
   /// Emits an error through a DiagnosticsEngine about an invalid user supplied
   /// checker option value.
   void reportInvalidCheckerOptionValue(const CheckerBase *C,
StringRef OptionName,
-   StringRef ExpectedValueDesc);
+   StringRef ExpectedValueDesc) const;
 
   using CheckerRef = CheckerBase *;
   using CheckerTag = const void *;
@@ -620,7 +620,7 @@
   /// Returns the checkers that have registered for callbacks of the
   /// given \p Kind.
   const std::vector &
-  getObjCMessageCheckers(ObjCMessageVisitKind Kind);
+  getObjCMessageCheckers(ObjCMessageVisitKind Kind) const;
 
   std::vector PreObjCMessageCheckers;
   std::vector PostObjCMessageCheckers;
___

[PATCH] D75739: [clangd][vscode] Enable dot-to-arrow fixes in clangd completion.

2020-03-09 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6ba0a4ec3bbf: [clangd][vscode] Enable dot-to-arrow fixes in 
clangd completion. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75739

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -65,6 +65,15 @@
   }
 }
 
+class EnableEditsNearCursorFeature implements vscodelc.StaticFeature {
+  initialize() {}
+  fillClientCapabilities(capabilities: vscodelc.ClientCapabilities): void {
+const extendedCompletionCapabilities: any =
+capabilities.textDocument.completion;
+extendedCompletionCapabilities.editsNearCursor = true;
+  }
+}
+
 /**
  *  this method is called when your extension is activate
  *  your extension is activated the very first time the command is executed
@@ -107,17 +116,18 @@
 // By adding the prefix to the beginning of the filterText, we get a 
perfect
 // fuzzymatch score for every item.
 // The sortText (which reflects clangd ranking) breaks the tie.
+// This also prevents VSCode from filtering out any results due to the
+// differences in how fuzzy filtering is applies, e.g. enable 
dot-to-arrow
+// fixes in completion.
 //
 // We also have to mark the list as incomplete to force retrieving new 
rankings.
 // See https://github.com/microsoft/language-server-protocol/issues/898
 middleware: {
   provideCompletionItem: async (document, position, context, token, 
next) => {
-// Get the incomplete identifier before the cursor.
-let word = document.getWordRangeAtPosition(position);
-let prefix = word && document.getText(new vscode.Range(word.start, 
position));
-
 let list = await next(document, position, context, token);
 let items = (Array.isArray(list) ? list : list.items).map(item => {
+  // Gets the prefix used by vscode when doing fuzzymatch.
+  let prefix = document.getText(new vscode.Range(item.range.start, 
position))
   if (prefix)
 item.filterText = prefix + "_" + item.filterText;
   return item;
@@ -137,6 +147,7 @@
 vscode.Disposable.from(semanticHighlightingFeature));
 clangdClient.registerFeature(semanticHighlightingFeature);
   }
+  clangdClient.registerFeature(new EnableEditsNearCursorFeature);
   console.log('Clang Language Server is now active!');
   context.subscriptions.push(clangdClient.start());
   context.subscriptions.push(vscode.commands.registerCommand(


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -65,6 +65,15 @@
   }
 }
 
+class EnableEditsNearCursorFeature implements vscodelc.StaticFeature {
+  initialize() {}
+  fillClientCapabilities(capabilities: vscodelc.ClientCapabilities): void {
+const extendedCompletionCapabilities: any =
+capabilities.textDocument.completion;
+extendedCompletionCapabilities.editsNearCursor = true;
+  }
+}
+
 /**
  *  this method is called when your extension is activate
  *  your extension is activated the very first time the command is executed
@@ -107,17 +116,18 @@
 // By adding the prefix to the beginning of the filterText, we get a perfect
 // fuzzymatch score for every item.
 // The sortText (which reflects clangd ranking) breaks the tie.
+// This also prevents VSCode from filtering out any results due to the
+// differences in how fuzzy filtering is applies, e.g. enable dot-to-arrow
+// fixes in completion.
 //
 // We also have to mark the list as incomplete to force retrieving new rankings.
 // See https://github.com/microsoft/language-server-protocol/issues/898
 middleware: {
   provideCompletionItem: async (document, position, context, token, next) => {
-// Get the incomplete identifier before the cursor.
-let word = document.getWordRangeAtPosition(position);
-let prefix = word && document.getText(new vscode.Range(word.start, position));
-
 let list = await next(document, position, context, token);
 let items = (Array.isArray(list) ? list : list.items).map(item => {
+  // Gets the prefix used by vscode when doing fuzzymatch.
+  let prefix = document.getText(new vscode.Rang

[PATCH] D75714: Add Optional overload to DiagnosticBuilder operator <

2020-03-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

What's the use case here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75714



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


[PATCH] D75768: Add a warning for builtin_return_address/frame_address with > 0 argument

2020-03-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri resigned from this revision.
lebedev.ri added a reviewer: aaron.ballman.
lebedev.ri added a comment.

This seems reasonable to me but i'll defer to other reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75768



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


[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-09 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.

LGTM




Comment at: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h:44-46
 bool parseFileExtensions(StringRef AllFileExtensions,
- FileExtensionsSet &FileExtensions, char Delimiter);
+ FileExtensionsSet &FileExtensions,
+ StringRef Delimiters);

Doesn't belong in this patch, but this function should be changed in a follow 
up to return an `Optional`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621



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


[PATCH] D75749: [clang-tidy] extend bugprone-signed-char-misuse check.

2020-03-09 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.
This revision is now accepted and ready to land.

LGTM

However, how does this handle cases when the type is written as `char`. They 
can be signed/unsigned based on what platform is being targeted. But on a 
platform where `char` is signed, comparison to an `unsigned char` is dangerous 
and the complimented case is the same. Surely any `char` comparison to `signed 
char` or `unsigned char` should be warned. But I'm not sure if that's in the 
scope of this check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75749



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


[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

2020-03-09 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D75842#1912293 , @xazax.hun wrote:

> I am not sure if I would call this a bugfix. Enabling a checker without one 
> of its dependency will potentially cause the checker to misbehave. I am 
> uncomfortable changing the current behavior to a more dangerous one without 
> any diagnostics. Including the diagnostic with this patch should not make 
> this too big.


This //is// a bugfix. The current behavior is wrong due to a mistake. A checker 
is registered which should not and this may cause crashes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75842



___
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-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 249085.
balazske added a comment.

Removed support for `fseek`, added `clearerr`.
This is now error handling only without fseek.
No functions set the error flags so test for
clearerr is not possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/stream-error.c
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -1,26 +1,6 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-store region -verify %s
 
-typedef __typeof__(sizeof(int)) size_t;
-typedef __typeof__(sizeof(int)) fpos_t;
-typedef struct _IO_FILE FILE;
-#define SEEK_SET  0  /* Seek from beginning of file.  */
-#define SEEK_CUR  1  /* Seek from current position.  */
-#define SEEK_END  2  /* Seek from end of file.  */
-extern FILE *fopen(const char *path, const char *mode);
-extern FILE *tmpfile(void);
-extern int fclose(FILE *fp);
-extern size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
-extern size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
-extern int fseek (FILE *__stream, long int __off, int __whence);
-extern long int ftell (FILE *__stream);
-extern void rewind (FILE *__stream);
-extern int fgetpos(FILE *stream, fpos_t *pos);
-extern int fsetpos(FILE *stream, const fpos_t *pos);
-extern void clearerr(FILE *stream);
-extern int feof(FILE *stream);
-extern int ferror(FILE *stream);
-extern int fileno(FILE *stream);
-extern FILE *freopen(const char *pathname, const char *mode, FILE *stream);
+#include "Inputs/system-header-simulator.h"
 
 void check_fread() {
   FILE *fp = tmpfile();
Index: clang/test/Analysis/stream-error.c
===
--- /dev/null
+++ clang/test/Analysis/stream-error.c
@@ -0,0 +1,40 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-checker=debug.ExprInspection -analyzer-store region -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+void clang_analyzer_eval(int);
+
+void error_fopen() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  clang_analyzer_eval(feof(F)); // expected-warning {{FALSE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  fclose(F);
+}
+
+void error_freopen() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  F = freopen(0, "w", F);
+  if (!F)
+return;
+  clang_analyzer_eval(feof(F)); // expected-warning {{FALSE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  fclose(F);
+}
+
+void error_clearerr() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  int ch = fputc('a', F);
+  if (ch == EOF) {
+// FIXME: fputc not handled by checker yet, should expect TRUE
+clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{FALSE}}
+clearerr(F);
+clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{FALSE}}
+  }
+  fclose(F);
+}
Index: clang/test/Analysis/Inputs/system-header-simulator.h
===
--- clang/test/Analysis/Inputs/system-header-simulator.h
+++ clang/test/Analysis/Inputs/system-header-simulator.h
@@ -9,7 +9,16 @@
 #define restrict /*restrict*/
 #endif
 
+typedef __typeof(sizeof(int)) size_t;
+typedef long long __int64_t;
+typedef __int64_t __darwin_off_t;
+typedef __darwin_off_t fpos_t;
+
 typedef struct _FILE FILE;
+#define SEEK_SET  0  /* Seek from beginning of file.  */
+#define SEEK_CUR  1  /* Seek from current position.  */
+#define SEEK_END  2  /* Seek from end of file.  */
+
 extern FILE *stdin;
 extern FILE *stdout;
 extern FILE *stderr;
@@ -24,11 +33,35 @@
 int fprintf(FILE *restrict, const char *restrict, ...);
 int getchar(void);
 
+void setbuf(FILE * restrict, char * restrict);
+int setvbuf(FILE * restrict, char * restrict, int, size_t);
+
+FILE *funopen(const void *,
+ int (*)(void *, char *, int),
+ int (*)(void *, const char *, int),
+ fpos_t (*)(void *, fpos_t, int),
+ int (*)(void *));
+
+FILE *fopen(const char *path, const char *mode);
+FILE *tmpfile(void);
+FILE *freopen(const char *pathname, const char *mode, FILE *stream);
+int fclose(FILE *fp);
+size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
+size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
+int fputc(int ch, FILE *stream);
+int fseek (FILE *__stream, long int __off, int __whence);
+long int ftell (FILE *__stream);
+void rewind (FILE *__stream);
+int fgetpos(FILE *stream, fpos_t *pos);
+int fsetpos(FILE *stream, const fpos_t *pos);
+void clearerr(FILE *stream);
+int feof(FILE *stream);
+int fe

[PATCH] D75843: [ARM,CDE] Implement CDE feature test macros

2020-03-09 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham requested changes to this revision.
simon_tatham added inline comments.
This revision now requires changes to proceed.



Comment at: clang/include/clang/Basic/TargetInfo.h:213
 
+  unsigned ARMCDECorpocMask : 8;
+

Typo: `Corpoc` → `Coproc`. Lots of those throughout this patch.



Comment at: clang/test/Preprocessor/arm-target-features.c:807
+// CHECK-V8M-NOCDE-NOT: #define __ARM_FEATURE_CDE
+// CHECK-V8M-NOCDE-NOT: #define __ARM_FEATURE_CDE_CORPOC
+// RUN: %clang -target arm-arm-none-eabi 
-march=armv8m.main+cdecp0+cdecp1+cdecp7 -x c -E -dM %s -o - | FileCheck 
-match-full-lines --check-prefix=CHECK-V8M-CDE-MASK1 %s

Especially important not to test for the //absence// of a misspelled macro – 
that can lead to false-positive test passes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75843



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


[PATCH] D75714: Add Optional overload to DiagnosticBuilder operator <

2020-03-09 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D75714#1912326 , @lebedev.ri wrote:

> What's the use case here?


Mainly syntactic sugar, If you have a function that maybe returns a `FixItHint` 
or `SourceRange` you can pass it directly to the `DiagnosticBuilder`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75714



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


[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-03-09 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

In D72841#1911330 , @rjmccall wrote:

> In D72841#1908084 , @mibintc wrote:
>
> > @rjmccall suggested that I needed to remove FPOptions from the Stmt class 
> > since the sizeof assertion failed. I moved that information into the 
> > relevant expression nodes and fixed a few small things that I didn't like 
> > in the previous version.
>
>
> You only need to do this for the expression nodes where it causes an overflow 
> in the size of the bit-field; I don't think you're overflowing the capacity 
> of UnaryOperatorBitfields, for example.


I added unsigned FPFeatures : 14; to class UnaryOperatorBitfields but I 
encountered the same assertion failure in the Stmt constructor, In constructor 
‘clang::Stmt::Stmt(clang::Stmt::StmtClass)’:
/iusers/sandbox/pragma-ws/llvm-project/clang/include/clang/AST/Stmt.h:1095:5: 
error: static assertion failed: changing bitfields changed sizeof(Stmt)

  static_assert(sizeof(*this) <= 8


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

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

In D75842#1912364 , 
@baloghadamsoftware wrote:

> In D75842#1912293 , @xazax.hun wrote:
>
> > I am not sure if I would call this a bugfix. Enabling a checker without one 
> > of its dependency will potentially cause the checker to misbehave. I am 
> > uncomfortable changing the current behavior to a more dangerous one without 
> > any diagnostics. Including the diagnostic with this patch should not make 
> > this too big.
>
>
> This //is// a bugfix. The current behavior is wrong due to a mistake. A 
> checker is registered which should not and this may cause crashes.


Oh, sorry. I misunderstood the description. My bad. In this case I am ok with 
having the diagnostic in a separate patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75842



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


[PATCH] D75739: [clangd][vscode] Enable dot-to-arrow fixes in clangd completion.

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

In D75739#1912051 , @hokein wrote:

> In D75739#1909637 , @sammccall wrote:
>
> > So the core of this is a better version of my patch, thanks!
> >  It does work around the problem with dot-to-arrow, which is useful and we 
> > should definitely enable that.
> >
> > We get into this mess because we merge two edits together, I think to avoid 
> > LSP's vague prohibition about edits related to the cursor. My vote would be:
> >
> > 1. check this patch in, but without claiming it as the correct and 
> > carefully architected fix for dot-to-arrow
> > 2. try turning off range-merging, and test it in a couple of clients 
> > (including vscode *without* this patch)
> > 3. if it works, make that change in clangd
>
>
> I think if we do that, we are likely to go back to the issue 
>  that 
> sending additionalEdit related to the cursor, and LSP clearly states it is 
> not supported -- `Additional text edits should be used to change text 
> unrelated to the current cursor position`, and it would not work in VSCode.


Sure, well if it doesn't work, then we should keep this hack instead.

>> However I actually think the dot-to-arrow problem is our bug at this point. 
>> LSP is vague but the discussion on language-server-protocol#898 very 
>> sensibly links filterText to textEdit.range. If we're sending filterText = 
>> "foo", textEdit.range = ".f" then I don't think that *is* a match.
> 
> Regarding the mismatch between filterText and textEdit.range, there is 
> another way to make them matched -- sending `filterText=".foo"` (rather than 
> `foo`) from clangd,  vscode should work without this patch, but it looks like 
> a hack in clangd to me...

Yes. And worse, it's a hack that's pretty hard to implement :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75739



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


[clang-tools-extra] e669d81 - [clangd] Bump vscode-clangd v0.0.21.

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

Author: Haojian Wu
Date: 2020-03-09T15:36:49+01:00
New Revision: e669d81715b591e18d51d7ebe82fe448345b6664

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

LOG: [clangd] Bump vscode-clangd v0.0.21.

CHANGELOG:
- better ranking for completions
- enable dot-to-arrow fix in code completion

Added: 


Modified: 
clang-tools-extra/clangd/clients/clangd-vscode/package.json

Removed: 




diff  --git a/clang-tools-extra/clangd/clients/clangd-vscode/package.json 
b/clang-tools-extra/clangd/clients/clangd-vscode/package.json
index 70011bfba792..6a4b948bb654 100644
--- a/clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ b/clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -2,7 +2,7 @@
 "name": "vscode-clangd",
 "displayName": "vscode-clangd",
 "description": "Clang Language Server",
-"version": "0.0.20",
+"version": "0.0.21",
 "publisher": "llvm-vs-code-extensions",
 "homepage": "https://clang.llvm.org/extra/clangd.html";,
 "engines": {



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


[PATCH] D75714: Add Optional overload to DiagnosticBuilder operator <

2020-03-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D75714#1912400 , @njames93 wrote:

> In D75714#1912326 , @lebedev.ri 
> wrote:
>
> > What's the use case here?
>
>
> Mainly syntactic sugar, If you have a function that maybe returns a 
> `FixItHint` or `SourceRange` you can pass it directly to the 
> `DiagnosticBuilder`.


This comes up with a fair amount of regularity, even just for things like 
printing a simple integer (consider optional attribute arguments, etc). 
However, it seems like we might want to express this via the format string so 
that we don't run into a situation where an unavailable optional argument 
changes the indexing in the case where it's not additional information like a 
source range or fixit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75714



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


[PATCH] D75690: [SVE][Inline-Asm] Add constraints for SVE ACLE types

2020-03-09 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 249092.
kmclaughlin added a comment.

- Added -emit-llvm to the RUN line of aarch64-sve-inline-asm-datatypes.c test. 
Added some more tests here for the Upl & y constraints and removed 
aarch64-sve-inline-asm-vec-low.c.
- Addressed formatting suggestions on previous patch.


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

https://reviews.llvm.org/D75690

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/aarch64-sve-inline-asm-crash.c
  clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c
  clang/test/CodeGen/aarch64-sve-inline-asm-negative-test.c

Index: clang/test/CodeGen/aarch64-sve-inline-asm-negative-test.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-inline-asm-negative-test.c
@@ -0,0 +1,21 @@
+// REQUIRES: aarch64-registered-target
+
+// RUN: not %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns \
+// RUN:   -target-feature +neon -S -O1 -o - %s | FileCheck %s
+
+// Assembler error
+// Output constraint : Set a vector constraint on an integer
+__SVFloat32_t funcB2()
+{
+  __SVFloat32_t ret ;
+  asm volatile (
+"fmov %[ret], wzr \n"
+: [ret] "=w" (ret)
+:
+:);
+
+  return ret ;
+}
+
+// CHECK: funcB2
+// CHECK-ERROR: error: invalid operand for instruction
Index: clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c
@@ -0,0 +1,252 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns \
+// RUN:   -target-feature +neon -S -O1 -o - -emit-llvm %s | FileCheck %s
+
+// Tests to check that all sve datatypes can be passed in as input operands
+// and passed out as output operands.
+
+#define SVINT_TEST(DT, KIND)\
+DT func_int_##DT##KIND(DT in)\
+{\
+  DT out;\
+  asm volatile (\
+"ptrue p0.b\n"\
+"mov %[out]." #KIND ", p0/m, %[in]." #KIND "\n"\
+: [out] "=w" (out)\
+: [in] "w" (in)\
+: "p0"\
+);\
+  return out;\
+}
+
+SVINT_TEST(__SVUint8_t,b);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.b, p0/m, $1.b\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVUint8_t,h);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.h, p0/m, $1.h\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVUint8_t,s);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.s, p0/m, $1.s\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVUint8_t,d);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.d, p0/m, $1.d\0A", "=w,w,~{p0}"( %in)
+
+SVINT_TEST(__SVUint16_t,b);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.b, p0/m, $1.b\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVUint16_t,h);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.h, p0/m, $1.h\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVUint16_t,s);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.s, p0/m, $1.s\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVUint16_t,d);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.d, p0/m, $1.d\0A", "=w,w,~{p0}"( %in)
+
+SVINT_TEST(__SVUint32_t,b);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.b, p0/m, $1.b\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVUint32_t,h);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.h, p0/m, $1.h\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVUint32_t,s);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.s, p0/m, $1.s\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVUint32_t,d);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.d, p0/m, $1.d\0A", "=w,w,~{p0}"( %in)
+
+SVINT_TEST(__SVUint64_t,b);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.b, p0/m, $1.b\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVUint64_t,h);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.h, p0/m, $1.h\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVUint64_t,s);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.s, p0/m, $1.s\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVUint64_t,d);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.d, p0/m, $1.d\0A", "=w,w,~{p0}"( %in)
+
+SVINT_TEST(__SVInt8_t,b);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.b, p0/m, $1.b\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVInt8_t,h);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.h, p0/m, $1.h\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVInt8_t,s);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.s, p0/m, $1.s\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVInt8_t,d);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.d, p0/m, $1.d\0A", "=w,w,~{p0}"( %in)
+
+SVINT_TEST(__SVInt16_t,b);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.b, p0/m, $1.b\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVInt16_t,h);
+// CHECK: call  asm sideeffect "ptrue p0.b\0Amov $0.h, p0/m, $1.h\0A", "=w,w,~{p0}"( %in)
+SVINT_TEST(__SVInt16_t,s);
+// CHECK: call  asm 

[PATCH] D75690: [SVE][Inline-Asm] Add constraints for SVE ACLE types

2020-03-09 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin marked 2 inline comments as done.
kmclaughlin added a comment.

Thanks for reviewing this, @efriedma!




Comment at: clang/lib/Basic/Targets/AArch64.h:95
+case 'U':   // Three-character constraint; add "@3" hint for later parsing.
+  R = std::string("@3") + std::string(Constraint, 3);
+  Constraint += 2;

efriedma wrote:
> Is "@3" some LLVM thing?  I don't think I've seen it before.
The "@" is used to indicate that this is a multi-letter constraint of a given 
length. This is parsed later by InlineAsm.cpp, see 
https://reviews.llvm.org/D66524



Comment at: clang/test/CodeGen/aarch64-sve-inline-asm-datatypes.c:2
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-fallow-half-arguments-and-returns \
+// RUN:   -target-feature +neon -S -O1 -o - %s | FileCheck %s
+

efriedma wrote:
> `REQUIRES: aarch64-registered-target` is necessary for any test that isn't 
> using -emit-llvm.
> 
> Generally, I'd prefer tests using -emit-llvm so we can independently verify 
> that the IR is what we expect, vs. the backend processing the IR the way we 
> expect.
I've added -emit-llvm here and updated the CHECK lines accordingly


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

https://reviews.llvm.org/D75690



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


[PATCH] D75740: [ASTImporter] Corrected import of repeated friend declarations.

2020-03-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 249100.
balazske marked 2 inline comments as done.
balazske added a comment.

Fixes according to comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75740

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp

Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -797,6 +797,27 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+TEST_F(StructuralEquivalenceRecordTest, SameFriendMultipleTimes) {
+  auto t = makeNamedDecls("struct foo { friend class X; };",
+  "struct foo { friend class X; friend class X; };",
+  Lang_CXX);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceRecordTest, SameFriendsDifferentOrder) {
+  auto t = makeNamedDecls("struct foo { friend class X; friend class Y; };",
+  "struct foo { friend class Y; friend class X; };",
+  Lang_CXX);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceRecordTest, SameFriendsSameOrder) {
+  auto t = makeNamedDecls("struct foo { friend class X; friend class Y; };",
+  "struct foo { friend class X; friend class Y; };",
+  Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
 struct StructuralEquivalenceLambdaTest : StructuralEquivalenceTest {};
 
 TEST_F(StructuralEquivalenceLambdaTest, LambdaClassesWithDifferentMethods) {
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4005,6 +4005,56 @@
   EXPECT_EQ(ImportedFwd, ImportedDef->getPreviousDecl());
 }
 
+TEST_P(ImportFriendClasses, ImportOfRepeatedFriendType) {
+  const auto *Code =
+  R"(
+  class Container {
+friend class X;
+friend class X;
+  };
+  )";
+  Decl *ToTu = getToTuDecl(Code, Lang_CXX);
+  Decl *FromTu = getTuDecl(Code, Lang_CXX, "from.cc");
+
+  auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
+  auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
+  auto *FromFriend1 =
+  FirstDeclMatcher().match(FromTu, friendDecl());
+  auto *FromFriend2 = LastDeclMatcher().match(FromTu, friendDecl());
+
+  FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX);
+  FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX);
+
+  EXPECT_NE(ToImportedFriend1, ToImportedFriend2);
+  EXPECT_EQ(ToFriend1, ToImportedFriend1);
+  EXPECT_EQ(ToFriend2, ToImportedFriend2);
+}
+
+TEST_P(ImportFriendClasses, ImportOfRepeatedFriendDecl) {
+  const auto *Code =
+  R"(
+  class Container {
+friend void f();
+friend void f();
+  };
+  )";
+  Decl *ToTu = getToTuDecl(Code, Lang_CXX);
+  Decl *FromTu = getTuDecl(Code, Lang_CXX, "from.cc");
+
+  auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
+  auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
+  auto *FromFriend1 =
+  FirstDeclMatcher().match(FromTu, friendDecl());
+  auto *FromFriend2 = LastDeclMatcher().match(FromTu, friendDecl());
+
+  FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX);
+  FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX);
+
+  EXPECT_NE(ToImportedFriend1, ToImportedFriend2);
+  EXPECT_EQ(ToFriend1, ToImportedFriend1);
+  EXPECT_EQ(ToFriend2, ToImportedFriend2);
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, FriendFunInClassTemplate) {
   auto *Code = R"(
   template 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3632,6 +3632,45 @@
   return ToIndirectField;
 }
 
+/// Used as return type of getFriendCountAndPosition.
+struct FriendCountAndIndex {
+  /// Number of similar looking friends.
+  unsigned int TotalCount;
+  /// Index of the specific FriendDecl.
+  unsigned int IndexOfDecl;
+};
+
+FriendCountAndIndex getFriendCountAndPosition(const FriendDecl *FD) {
+  unsigned int FriendCount = 0;
+  llvm::Optional FriendPosition;
+  const auto *RD = cast(FD->getLexicalDeclContext());
+  if (FD->getFriendType()) {
+QualType TypeOfFriend = FD->getFriendType()->getType().getCanonicalType();
+for (const FriendDecl *FoundFriend : RD->friends()) {
+  if (FoundFriend == FD) {
+FriendPosition = FriendCount;
+++FriendCount;
+  } else if (FoundFriend->getFriendType() &&
+ FoundFriend->getFriendType()->getType().getCanonicalType() ==
+ TypeOfFriend)
+++FriendCount;
+}
+  } e

[PATCH] D75740: [ASTImporter] Corrected import of repeated friend declarations.

2020-03-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 9 inline comments as done.
balazske added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:3640
+  auto *RD = cast(FD->getLexicalDeclContext());
+  if (FD->getFriendType()) {
+QualType TypeOfFriend = FD->getFriendType()->getType().getCanonicalType();

a_sidorin wrote:
> ```if (const TypeSourceInfo *FriendType = FD->getFriendType()) {
> QualType TypeOfFriend = FriendType->getType().getCanonicalType();
> ...```
> ?
In the current way the branches (after `if` and `else`) look relatively 
similar, I like that better.



Comment at: clang/lib/AST/ASTImporter.cpp:3699
+
+  assert(ImportedEquivalentFriends.size() <= std::get<0>(CountAndPosition) &&
+ "Class with non-matching friends is imported, ODR check wrong?");

a_sidorin wrote:
> Why not strictly equal?
`D` id the Decl to be imported, `ImportedEquivalentFriends` contains the 
similar friends already  imported. This may be less than the total (0 at first 
time) if not all friends are imported yet (should be a temporary state). The 
next line checks for equality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75740



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


[PATCH] D75714: Add Optional overload to DiagnosticBuilder operator <

2020-03-09 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

I can see it being useful for fix-its and source ranges, however I have a 
concern about it accidentally eating arguments that were supposed to go into a 
format string. For that, I second Aaron's suggestion to implement an extension 
for format strings. If you don't want to do that far, I think adding specific 
overloads for optional fix-its and optional source ranges would work, and won't 
trigger in unexpected situations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75714



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


[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs marked an inline comment as done.
jroelofs added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h:44-46
 bool parseFileExtensions(StringRef AllFileExtensions,
- FileExtensionsSet &FileExtensions, char Delimiter);
+ FileExtensionsSet &FileExtensions,
+ StringRef Delimiters);

njames93 wrote:
> Doesn't belong in this patch, but this function should be changed in a follow 
> up to return an `Optional`.
Looking at the uses, I'm not convinced this would be better in this specific 
case.

Compare:
```
if (Optional HFE = parseFileExtensions(Extensions, 
Delimiters)) {
  HeaderFileExtensions = *HFE;
} else {
  errs() << "Invalid extensions: " << Extensions;
}
```

With the status quo:
```
if (!parseFileExtensions(Extensions, HeaderFileExtensions, Delimiters)) {
  errs() << "Invalid extensions: " << Extensions;
}
```

Optional's explicit operator bool is great for when you want to guard on the 
presence of the thing, but not so great when you want to check for it not being 
there. I feel like we'd need some new utility to go with Optional to make this 
nice:

```
if (not(HeaderFileExtensions) = parseFileExtensions(Extensions, Delimiters)) {
  errs() << "Invalid extensions: " << Extensions;
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621



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


[PATCH] D72874: [clangd] Add a textual fallback for go-to-definition

2020-03-09 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:258
+
+// For now, only consider exact name matches, including case.
+// This is to avoid too many false positives.

sammccall wrote:
> nridge wrote:
> > sammccall wrote:
> > > I wouldn't bother qualifying this as "for now". Any code is subject to 
> > > change in the future, but requiring an exact name match for index-based 
> > > results seems more like a design decision than a fixme.
> > Do we want to rule out the possibility of handling typos in an identifier 
> > name in a comment (in cases where we have high confidence in the match, 
> > e.g. a long / unique name, small edit distance, only one potential match) 
> > in the future?
> > 
> > This is also relevant to whether we want to keep the `FuzzyMatcher` or not.
> No idea whether typo-correction is a good idea in principle - tradeoff 
> between current false negatives and false positives+compute.
> 
> However neither FuzzyMatcher nor the existing index implementations 
> support/can easily support real typo correction, and it seems implausible to 
> me we'd add it for this feature.
> 
> Compare to e.g:
>  - allowing case-insensitive match in some cases: `fooBar` vs `FooBar` is a 
> plausible "typo". This is easy to implement.
>  - correct the typo where we see the fixed version used as an identifier in 
> this file (and not the original). Excludes some cases, but drives 
> false-positives way down, and easy to implement.
> 
> I don't think we need to rule things out, but I'm uncertain enough about the 
> approach to think that putting comments, fuzzymatcher etc here speculatively 
> isn't worth it.
Perhaps I'm unclear on the distinction between fuzzy matching and typo 
correction. Are they not both a matter of comparing a candidate string against 
a test string, and considering it a match if the they are "close enough" 
according to some metric (with the metric potentially being a simple edit 
distance in the case of typo correction)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72874



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


[PATCH] D75843: [ARM,CDE] Implement CDE feature test macros

2020-03-09 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki updated this revision to Diff 249103.
miyuki added a comment.

Fixed typos and formatting.


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

https://reviews.llvm.org/D75843

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/test/Preprocessor/arm-target-features.c

Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -800,6 +800,18 @@
 // CHECK-V81M-MVE-NODSP-NOT: #define __ARM_FEATURE_MVE
 // CHECK-V81M-MVE-NODSP-NOT: #define __ARM_FEATURE_DSP
 
+// Test CDE (Custom Datapath Extension) feature test macros
+
+// RUN: %clang -target arm-arm-none-eabi -march=armv8m.main -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-V8M-NOCDE %s
+// CHECK-V8M-NOCDE-NOT: #define __ARM_FEATURE_CDE
+// CHECK-V8M-NOCDE-NOT: #define __ARM_FEATURE_CDE_COPROC
+// RUN: %clang -target arm-arm-none-eabi -march=armv8m.main+cdecp0+cdecp1+cdecp7 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V8M-CDE-MASK1 %s
+// CHECK-V8M-CDE-MASK1: #define __ARM_FEATURE_CDE 1
+// CHECK-V8M-CDE-MASK1: #define __ARM_FEATURE_CDE_COPROC 0x83
+// RUN: %clang -target arm-arm-none-eabi -march=armv8m.main+cdecp0+cdecp1+cdecp2+cdecp3+cdecp4+cdecp5+cdecp6+cdecp7 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V8M-CDE-MASK2 %s
+// CHECK-V8M-CDE-MASK2: #define __ARM_FEATURE_CDE 1
+// CHECK-V8M-CDE-MASK2: #define __ARM_FEATURE_CDE_COPROC 0xff
+
 // RUN: %clang -target armv8.1a-none-none-eabi -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81A %s
 // CHECK-V81A: #define __ARM_ARCH 8
 // CHECK-V81A: #define __ARM_ARCH_8_1A__ 1
Index: clang/lib/Basic/Targets/ARM.h
===
--- clang/lib/Basic/Targets/ARM.h
+++ clang/lib/Basic/Targets/ARM.h
@@ -108,6 +108,7 @@
   bool supportsThumb2() const;
   bool hasMVE() const;
   bool hasMVEFloat() const;
+  bool hasCDE() const;
 
   StringRef getCPUAttr() const;
   StringRef getCPUProfile() const;
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -154,6 +154,8 @@
   return hasMVE() && (MVE & MVE_FP);
 }
 
+bool ARMTargetInfo::hasCDE() const { return getARMCDECoprocMask() != 0; }
+
 bool ARMTargetInfo::isThumb() const {
   return ArchISA == llvm::ARM::ISAKind::THUMB;
 }
@@ -422,6 +424,7 @@
   HWDiv = 0;
   DotProd = 0;
   HasFloat16 = true;
+  ARMCDECoprocMask = 0;
 
   // This does not diagnose illegal cases like having both
   // "+vfpv2" and "+vfpv3" or having "+neon" and "-fp64".
@@ -486,6 +489,9 @@
   FPU |= FPARMV8;
   MVE |= MVE_INT | MVE_FP;
   HW_FP |= HW_FP_SP | HW_FP_HP;
+} else if (Feature >= "+cdecp0" && Feature <= "+cdecp7") {
+  unsigned Coproc = Feature.back() - '0';
+  ARMCDECoprocMask |= (1U << Coproc);
 }
   }
 
@@ -758,6 +764,12 @@
 Builder.defineMacro("__ARM_FEATURE_MVE", hasMVEFloat() ? "3" : "1");
   }
 
+  if (hasCDE()) {
+Builder.defineMacro("__ARM_FEATURE_CDE", "1");
+Builder.defineMacro("__ARM_FEATURE_CDE_COPROC",
+"0x" + Twine::utohexstr(getARMCDECoprocMask()));
+  }
+
   Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
   Twine(Opts.WCharSize ? Opts.WCharSize : 4));
 
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -113,6 +113,7 @@
   HasBuiltinMSVaList = false;
   IsRenderScriptTarget = false;
   HasAArch64SVETypes = false;
+  ARMCDECoprocMask = 0;
 
   // Default to no types using fpret.
   RealTypeUsesObjCFPRet = 0;
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -210,6 +210,8 @@
 
   unsigned HasAArch64SVETypes : 1;
 
+  unsigned ARMCDECoprocMask : 8;
+
   // TargetInfo Constructor.  Default initializes all fields.
   TargetInfo(const llvm::Triple &T);
 
@@ -808,6 +810,10 @@
   /// available on this target.
   bool hasAArch64SVETypes() const { return HasAArch64SVETypes; }
 
+  /// For ARM targets returns a mask defining which coprocessors are configured
+  /// as Custom Datapath.
+  uint32_t getARMCDECoprocMask() const { return ARMCDECoprocMask; }
+
   /// Returns whether the passed in string is a valid clobber in an
   /// inline asm statement.
   ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7b66160 - Fix Target Multiversioning renaming.

2020-03-09 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2020-03-09T08:29:18-07:00
New Revision: 7b661608287e84d6bec24262a0a42c1d8b65fcc6

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

LOG: Fix Target Multiversioning renaming.

The initial implementation only did 'first declaration renaming' when
a default version came after. This is insufficient in cases where a
default does not exist, so this patch makes sure that we do the renaming
in all cases.

This renaming is necessary because we emit the first declaration before
knowing that it IS a target multiversion function, which would change
its name. The second declaration (the one that caused the
multiversioning) then needs to make sure that the first one has its name
changed to be consistent with the resolver usage.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/attr-target-mv.c

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 0ee315776d33..415633536ad8 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3141,8 +3141,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
   (void)OpenMPRuntime->emitDeclareVariant(GD, /*IsForDefinition=*/true);
 
 if (FD->isMultiVersion()) {
-  const auto *TA = FD->getAttr();
-  if (TA && TA->isDefaultVersion())
+  if (FD->hasAttr())
 UpdateMultiVersionNames(GD, FD);
   if (!IsForDefinition)
 return GetOrCreateMultiVersionResolver(GD, Ty, FD);

diff  --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index c0c3de5f991a..c089b06d238c 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -47,6 +47,9 @@ void bar5() {
   fwd_decl_avx();
 }
 
+int __attribute__((target("avx"))) changed_to_mv(void) { return 0;}
+int __attribute__((target("fma4"))) changed_to_mv(void) { return 1;}
+
 // LINUX: @foo.ifunc = weak_odr ifunc i32 (), i32 ()* ()* @foo.resolver
 // LINUX: @foo_inline.ifunc = weak_odr ifunc i32 (), i32 ()* ()* 
@foo_inline.resolver
 // LINUX: @foo_decls.ifunc = weak_odr ifunc void (), void ()* ()* 
@foo_decls.resolver
@@ -194,6 +197,12 @@ void bar5() {
 // WINDOWS: call i32 @fwd_decl_avx.avx
 // WINDOWS: call i32 @fwd_decl_avx
 
+// LINUX: define i32 @changed_to_mv.avx()
+// LINUX: define i32 @changed_to_mv.fma4()
+
+// WINDOWS: define dso_local i32 @changed_to_mv.avx()
+// WINDOWS: define dso_local i32 @changed_to_mv.fma4()
+
 // LINUX: declare i32 @foo.arch_sandybridge()
 // WINDOWS: declare dso_local i32 @foo.arch_sandybridge()
 



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


[PATCH] D72635: Allow arbitrary capability name in Thread Safety Analysis

2020-03-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D72635#1911844 , @aaronpuchert 
wrote:

> In D72635#1911671 , @aaron.ballman 
> wrote:
>
> > However, do we want to diagnose when the capability strings are different?
>
>
> Hmm, interesting question. The way I think about ordering capabilities is 
> this: assuming I have more than one capability in my program, and 
> occasionally I hold multiple capabilities at the same time. Then deadlocks 
> can occur, unless I'm being careful. One way to avoid deadlocks is to have a 
> partial order on capabilities that is a total order on the subsets of 
> capabilities that are acquired together. It's not hard to see that this is 
> sufficient, and I even think it's necessary. (In the sense that whenever I 
> have a deadlock-free program, such an order exists. I have no proof for that, 
> but that's just for lack of trying.)
>
> Now if I acquire capabilities of different types, then the order also has to 
> incorporate these different types. So my answer would be no, I think we have 
> to allow this.


Okay, I think that makes sense, but is probably something we should mention 
explicitly in the thread safety documentation so we don't lose track of why 
this is the way it is. WDYT?

> In fact (but that's for another change) I've even thought about warning when 
> a cap. is acquired and it's not ordered with another already-held capability 
> (under `-beta` of course).

Ah, interesting idea!


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

https://reviews.llvm.org/D72635



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


[PATCH] D75843: [ARM,CDE] Implement CDE feature test macros

2020-03-09 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added inline comments.



Comment at: clang/lib/Basic/Targets/ARM.cpp:492
   HW_FP |= HW_FP_SP | HW_FP_HP;
+} else if (Feature >= "+cdecp0" && Feature <= "+cdecp7") {
+  unsigned Coproc = Feature.back() - '0';

As far as I can see, feature names have not already been checked against any 
whitelist of known strings by the time we get here.

So this test will catch strings like `+cdecp0sdfsdfsdf` as well as the eight 
strings you actually wanted.

And then the next line makes an out-of-range shift count from the last 
character.


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

https://reviews.llvm.org/D75843



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


[PATCH] D75850: [ARM, CDE] Generalize MVE intrinsics infrastructure to support CDE

2020-03-09 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: simon_tatham, MarkMurrayARM, ostannard, dmgreen.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, kristof.beyls, 
mgorny.
Herald added projects: clang, LLVM.
miyuki added a parent revision: D75843: [ARM,CDE] Implement CDE feature test 
macros.

This patch generalizes the existing code to support CDE intrinsics
which will share some properties with existing MVE intrinsics
(some of the intrinsics will be polymorphic and accept/return values
of MVE vector types).
Specifically the patch:

- Adds new tablegen backends -gen-arm-cde-builtin-def, 
-gen-arm-cde-builtin-codegen, -gen-arm-cde-builtin-sema, 
-gen-arm-cde-builtin-aliases, -gen-arm-cde-builtin-header based on existing MVE 
backends.
- Renames the '__clang_arm_mve_alias' attribute into 
'__clang_arm_builtin_alias' (it will be used with CDE intrinsics as well as MVE 
intrinsics)
- Implements semantic checks for the coprocessor argument of the CDE intrinsics 
as well as the existing coprocessor intrinsics.
- Adds one CDE intrinsic __arm_cx1 to test the above changes


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75850

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/BuiltinsARM.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/arm_cde.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/arm-cde-gpr.c
  clang/test/Headers/arm-cde-header.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/arm-cde-immediates.c
  clang/test/Sema/arm-mve-alias-attribute.c
  clang/utils/TableGen/MveEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/include/llvm/IR/IntrinsicsARM.td

Index: llvm/include/llvm/IR/IntrinsicsARM.td
===
--- llvm/include/llvm/IR/IntrinsicsARM.td
+++ llvm/include/llvm/IR/IntrinsicsARM.td
@@ -1243,4 +1243,11 @@
 llvm_i32_ty /* unsigned output */, llvm_i32_ty /* unsigned input */,
 llvm_i32_ty /* top half */, llvm_anyvector_ty /* pred */], [IntrNoMem]>;
 
+// CDE (Custom Datapath Extension)
+
+def int_arm_cde_cx1: Intrinsic<
+  [llvm_i32_ty],
+  [llvm_i32_ty /* coproc */, llvm_i32_ty /* imm */],
+  [IntrNoMem, ImmArg<0>, ImmArg<1>]>;
+
 } // end TargetPrefix
Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -97,6 +97,12 @@
 void EmitMveBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitMveBuiltinAliases(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
+void EmitCdeHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinAliases(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+
 void EmitClangAttrDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitClangDiagDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitClangOptDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -70,6 +70,11 @@
   GenArmMveBuiltinSema,
   GenArmMveBuiltinCG,
   GenArmMveBuiltinAliases,
+  GenArmCdeHeader,
+  GenArmCdeBuiltinDef,
+  GenArmCdeBuiltinSema,
+  GenArmCdeBuiltinCG,
+  GenArmCdeBuiltinAliases,
   GenAttrDocs,
   GenDiagDocs,
   GenOptDocs,
@@ -190,6 +195,16 @@
"Generate ARM MVE builtin code-generator for clang"),
 clEnumValN(GenArmMveBuiltinAliases, "gen-arm-mve-builtin-aliases",
"Generate list of valid ARM MVE builtin aliases for clang"),
+clEnumValN(GenArmCdeHeader, "gen-arm-cde-header",
+   "Generate arm_cde.h for clang"),
+clEnumValN(GenArmCdeBuiltinDef, "gen-arm-cde-builtin-def",
+   "Generate ARM CDE builtin definitions for clang"),
+clEnumValN(GenArmCdeBuiltinSema, "gen-arm-cde-builtin-sema",
+   "Generate ARM CDE builtin sema checks for clang"),
+clEnumValN(GenArmCdeBuiltinCG, "gen-arm-cde-builtin-codegen",
+   "Generate ARM CDE builtin code-generator for clang"),
+clEnumValN(GenArmCdeBuiltinAliases, "gen-arm-cde-builtin-aliases",
+  

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

2020-03-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 249107.
balazske added a comment.

Fixed lint warnings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/stream-error.c
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -1,26 +1,6 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-store region -verify %s
 
-typedef __typeof__(sizeof(int)) size_t;
-typedef __typeof__(sizeof(int)) fpos_t;
-typedef struct _IO_FILE FILE;
-#define SEEK_SET  0  /* Seek from beginning of file.  */
-#define SEEK_CUR  1  /* Seek from current position.  */
-#define SEEK_END  2  /* Seek from end of file.  */
-extern FILE *fopen(const char *path, const char *mode);
-extern FILE *tmpfile(void);
-extern int fclose(FILE *fp);
-extern size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
-extern size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
-extern int fseek (FILE *__stream, long int __off, int __whence);
-extern long int ftell (FILE *__stream);
-extern void rewind (FILE *__stream);
-extern int fgetpos(FILE *stream, fpos_t *pos);
-extern int fsetpos(FILE *stream, const fpos_t *pos);
-extern void clearerr(FILE *stream);
-extern int feof(FILE *stream);
-extern int ferror(FILE *stream);
-extern int fileno(FILE *stream);
-extern FILE *freopen(const char *pathname, const char *mode, FILE *stream);
+#include "Inputs/system-header-simulator.h"
 
 void check_fread() {
   FILE *fp = tmpfile();
Index: clang/test/Analysis/stream-error.c
===
--- /dev/null
+++ clang/test/Analysis/stream-error.c
@@ -0,0 +1,40 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-checker=debug.ExprInspection -analyzer-store region -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+void clang_analyzer_eval(int);
+
+void error_fopen() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  clang_analyzer_eval(feof(F)); // expected-warning {{FALSE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  fclose(F);
+}
+
+void error_freopen() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  F = freopen(0, "w", F);
+  if (!F)
+return;
+  clang_analyzer_eval(feof(F)); // expected-warning {{FALSE}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  fclose(F);
+}
+
+void error_clearerr() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  int ch = fputc('a', F);
+  if (ch == EOF) {
+// FIXME: fputc not handled by checker yet, should expect TRUE
+clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{FALSE}}
+clearerr(F);
+clang_analyzer_eval(feof(F) || ferror(F)); // expected-warning {{FALSE}}
+  }
+  fclose(F);
+}
Index: clang/test/Analysis/Inputs/system-header-simulator.h
===
--- clang/test/Analysis/Inputs/system-header-simulator.h
+++ clang/test/Analysis/Inputs/system-header-simulator.h
@@ -9,7 +9,16 @@
 #define restrict /*restrict*/
 #endif
 
+typedef __typeof(sizeof(int)) size_t;
+typedef long long __int64_t;
+typedef __int64_t __darwin_off_t;
+typedef __darwin_off_t fpos_t;
+
 typedef struct _FILE FILE;
+#define SEEK_SET 0 /* Seek from beginning of file. */
+#define SEEK_CUR 1 /* Seek from current position. */
+#define SEEK_END 2 /* Seek from end of file. */
+
 extern FILE *stdin;
 extern FILE *stdout;
 extern FILE *stderr;
@@ -24,11 +33,35 @@
 int fprintf(FILE *restrict, const char *restrict, ...);
 int getchar(void);
 
+void setbuf(FILE *restrict, char *restrict);
+int setvbuf(FILE *restrict, char *restrict, int, size_t);
+
+FILE *funopen(const void *,
+  int (*)(void *, char *, int),
+  int (*)(void *, const char *, int),
+  fpos_t (*)(void *, fpos_t, int),
+  int (*)(void *));
+
+FILE *fopen(const char *path, const char *mode);
+FILE *tmpfile(void);
+FILE *freopen(const char *pathname, const char *mode, FILE *stream);
+int fclose(FILE *fp);
+size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
+size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
+int fputc(int ch, FILE *stream);
+int fseek(FILE *__stream, long int __off, int __whence);
+long int ftell(FILE *__stream);
+void rewind(FILE *__stream);
+int fgetpos(FILE *stream, fpos_t *pos);
+int fsetpos(FILE *stream, const fpos_t *pos);
+void clearerr(FILE *stream);
+int feof(FILE *stream);
+int ferror(FILE *stream);
+int fileno(FILE *stream);
+
 // Note, on some platforms errno macro gets replaced with a function call.
 extern int errno;
 
-typedef __typeof(sizeof(i

[PATCH] D75768: Add a warning for builtin_return_address/frame_address with > 0 argument

2020-03-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

I did a bit of research and I don't think i know of anything better than 'most' 
here, and noone else had an opinion at the end of last week so I'll take that 
silence as consent.  Approved!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75768



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


[PATCH] D71018: [ASTImporter] Improved import of TypeSourceInfo (TypeLoc)

2020-03-09 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:3281
 
+  // Import the function parameters.
+  SmallVector Parameters;

balazske wrote:
> shafik wrote:
> > I am curious, why move this chunk of code up?
> See comments at line 8238?
I moved the TypeLoc import part of VisitFunctionDecl to VisitFunctionTypeLoc. 
But, that was possible only if first we import the parameters and only then we 
import the TypeLoc (TypeSourceInfo) in VisitFunctionDecl, so I made that 
reorganization here.



Comment at: clang/lib/AST/ASTImporter.cpp:8133
+  Error VisitTypedefTypeLoc(TypedefTypeLoc From) {
+return VisitTypeSpecTypeLoc(From);
+  }

balazske wrote:
> teemperor wrote:
> > I know the ASTImporter is doing these reimplementation of the default 
> > visitor behavior quite often, but I feel in this case it would be much more 
> > readable to omit all these default implementations and just let the 
> > TypeLocVisitor do the dispatch to parent class logic. Especially since from 
> > what I understand it's unlikely that we need custom logic for all these 
> > TypeLoc subclasses in the future? It would also make this code less fragile 
> > in case the inheritance hierarchy every gets another intermediate class 
> > that might require special handling.
> It is really better to remove these redundant visit branches.
OK, indeed we don't need them. So, I removed these default implementations.



Comment at: clang/unittests/AST/ASTImporterTest.cpp:5850
+
+TEST_P(ImportTypeLoc, Function) {
+  Decl *FromTU = getTuDecl(

balazske wrote:
> shafik wrote:
> > Maybe I am missing it but these tests don't seem like they cover all the 
> > visit methods of `TypeLocImporter`.
> It could be useful to add some kind of generic imported AST similarity tests. 
> These can test for things that should match in the imported and original AST, 
> for example source locations.
> (The AST does not always match after import but often.) Such a test can catch 
> many import errors with objects that have no specific test.
> The test in https://reviews.llvm.org/D60463 is somewhat similar but it uses 
> text dump of the AST, this can be improved. Actually that test was used to 
> discover the import problems of `SourceLocation` and `TypeSourceInfo`.
I added tests only for the non-trivial cases like FunctionTypeLoc, in that case 
we moved some code out from `VisitFunctionDecl` to the typeloc importer. 

All the other branches are very trivial and type loc import happens only in the 
type loc importer. So, I think it would be the best if we could test them in a 
generic way as @balazske suggests: we could extend the existing unittests to 
check for typelocations too. But that is not that trivial to do (may require 
another typeloc visitation in the test, I don't know yet). I'd rather do that 
in a separate patch, if that's okay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71018



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


[PATCH] D75843: [ARM,CDE] Implement CDE feature test macros

2020-03-09 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki marked an inline comment as done.
miyuki added inline comments.



Comment at: clang/lib/Basic/Targets/ARM.cpp:492
   HW_FP |= HW_FP_SP | HW_FP_HP;
+} else if (Feature >= "+cdecp0" && Feature <= "+cdecp7") {
+  unsigned Coproc = Feature.back() - '0';

simon_tatham wrote:
> As far as I can see, feature names have not already been checked against any 
> whitelist of known strings by the time we get here.
> 
> So this test will catch strings like `+cdecp0sdfsdfsdf` as well as the eight 
> strings you actually wanted.
> 
> And then the next line makes an out-of-range shift count from the last 
> character.
Doh!


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

https://reviews.llvm.org/D75843



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


[PATCH] D71018: [ASTImporter] Improved import of TypeSourceInfo (TypeLoc)

2020-03-09 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 249106.
martong marked 10 inline comments as done.
martong added a comment.

- Remove default visit functions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71018

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5845,6 +5845,53 @@
   EXPECT_TRUE(isa(To->getReturnType()));
 }
 
+struct ImportTypeLoc : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportTypeLoc, Function) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  int f(int p) {
+return 1;
+  }
+  )",
+  Lang_CXX11, "input0.cc");
+  FunctionDecl *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("f")));
+  FunctionDecl *ToF = Import(FromF, Lang_CXX11);
+  ASSERT_TRUE(ToF);
+  FunctionProtoTypeLoc TL =
+  ToF->getTypeSourceInfo()->getTypeLoc().castAs();
+  EXPECT_EQ(TL.getNumParams(), 1u);
+  EXPECT_TRUE(TL.getParam(0));
+}
+
+TEST_P(ImportTypeLoc, Lambda) {
+  // In this test case, first the CXXRecordDecl of the lambda is imported, then
+  // the operator().
+  Decl *FromTU = getTuDecl(
+  R"(
+  auto l1 = [](unsigned lp) { return 1; };
+  int f(int p) {
+return l1(p);
+  }
+  )",
+  Lang_CXX11, "input0.cc");
+  FunctionDecl *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("f")));
+  FunctionDecl *ToF = Import(FromF, Lang_CXX11);
+  ASSERT_TRUE(ToF);
+
+  TranslationUnitDecl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+  CXXMethodDecl *ToLambdaMD = FirstDeclMatcher()
+  .match(ToTU, lambdaExpr())
+  ->getCallOperator();
+  FunctionProtoTypeLoc TL = ToLambdaMD->getTypeSourceInfo()
+->getTypeLoc()
+.castAs();
+  EXPECT_EQ(TL.getNumParams(), 1u);
+  EXPECT_TRUE(TL.getParam(0));
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
@@ -5903,5 +5950,8 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, LLDBLookupTest,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportTypeLoc,
+DefaultTestValuesForRunOptions, );
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -42,6 +42,7 @@
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLoc.h"
+#include "clang/AST/TypeLocVisitor.h"
 #include "clang/AST/TypeVisitor.h"
 #include "clang/AST/UnresolvedSet.h"
 #include "clang/Basic/Builtins.h"
@@ -695,6 +696,8 @@
 // that type is declared inside the body of the function.
 // E.g. auto f() { struct X{}; return X(); }
 bool hasAutoReturnTypeDeclaredInside(FunctionDecl *D);
+
+friend class TypeLocImporter;
   };
 
 template 
@@ -3275,6 +3278,15 @@
 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
   }
 
+  // Import the function parameters.
+  SmallVector Parameters;
+  for (auto P : D->parameters()) {
+if (Expected ToPOrErr = import(P))
+  Parameters.push_back(*ToPOrErr);
+else
+  return ToPOrErr.takeError();
+  }
+
   QualType T;
   TypeSourceInfo *TInfo;
   SourceLocation ToInnerLocStart, ToEndLoc;
@@ -3288,15 +3300,6 @@
   else
 return Imp.takeError();
 
-  // Import the function parameters.
-  SmallVector Parameters;
-  for (auto P : D->parameters()) {
-if (Expected ToPOrErr = import(P))
-  Parameters.push_back(*ToPOrErr);
-else
-  return ToPOrErr.takeError();
-  }
-
   // Create the imported function.
   FunctionDecl *ToFunction = nullptr;
   if (auto *FromConstructor = dyn_cast(D)) {
@@ -3402,16 +3405,6 @@
   }
   ToFunction->setParams(Parameters);
 
-  // We need to complete creation of FunctionProtoTypeLoc manually with setting
-  // params it refers to.
-  if (TInfo) {
-if (auto ProtoLoc =
-TInfo->getTypeLoc().IgnoreParens().getAs()) {
-  for (unsigned I = 0, N = Parameters.size(); I != N; ++I)
-ProtoLoc.setParam(I, Parameters[I]);
-}
-  }
-
   // Import the describing template function, if any.
   if (FromFT) {
 auto ToFTOrErr = import(FromFT);
@@ -8111,20 +8104,312 @@
   return ToContext.getQualifiedType(*ToTOrErr, FromT.getLocalQualifiers());
 }
 
+namespace clang {
+
+#define IMPORT_TYPE_LOC_OR_RETURN_ERROR(NAME)  \
+  if (auto ImpOrErr = Importer.Import(From.get##NAME()))   \
+To.set##NAME(*ImpOrErr); 

[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-09 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h:44-46
 bool parseFileExtensions(StringRef AllFileExtensions,
- FileExtensionsSet &FileExtensions, char Delimiter);
+ FileExtensionsSet &FileExtensions,
+ StringRef Delimiters);

jroelofs wrote:
> njames93 wrote:
> > Doesn't belong in this patch, but this function should be changed in a 
> > follow up to return an `Optional`.
> Looking at the uses, I'm not convinced this would be better in this specific 
> case.
> 
> Compare:
> ```
> if (Optional HFE = parseFileExtensions(Extensions, 
> Delimiters)) {
>   HeaderFileExtensions = *HFE;
> } else {
>   errs() << "Invalid extensions: " << Extensions;
> }
> ```
> 
> With the status quo:
> ```
> if (!parseFileExtensions(Extensions, HeaderFileExtensions, Delimiters)) {
>   errs() << "Invalid extensions: " << Extensions;
> }
> ```
> 
> Optional's explicit operator bool is great for when you want to guard on the 
> presence of the thing, but not so great when you want to check for it not 
> being there. I feel like we'd need some new utility to go with Optional to 
> make this nice:
> 
> ```
> if (not(HeaderFileExtensions) = parseFileExtensions(Extensions, Delimiters)) {
>   errs() << "Invalid extensions: " << Extensions;
> }
> ```
To be honest it should probably be `Expected` rather than `Optional`, but that 
still doesn't help solve the cleanliness issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621



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


[PATCH] D74054: [clangd] Include the underlying decls in go-to-definition.

2020-03-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

friendly ping, this patch should be ready for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74054



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


[PATCH] D75579: [WIP] Replace MCTargetOptionsCommandFlags.inc and CommandFlags.inc by libraries

2020-03-09 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 249109.
serge-sans-paille added a comment.

@MaskRay The library version prooved to be a bad path: we wanted clang-cpp to 
always link to a shared library, which interacts in ungraceful ways with 
BUILD_SHARED_LIBS.

This is another attempt that looks better to me: all options are available in 
LLVMCodeGen, but only registered if a given static constructor is called by 
client code. Some doc and asserts are missing but that's the rough idea. Any 
thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75579

Files:
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
  lld/Common/TargetOptionsCommandFlags.cpp
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/CommandFlags.inc
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.inc
  llvm/include/llvm/module.modulemap
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/MC/CMakeLists.txt
  llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
  llvm/tools/dsymutil/DwarfStreamer.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llc/CMakeLists.txt
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/CMakeLists.txt
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
  llvm/tools/llvm-lto/CMakeLists.txt
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/CMakeLists.txt
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/CMakeLists.txt
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/lto/lto.cpp
  llvm/tools/opt/opt.cpp
  llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp

Index: llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
+++ llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
@@ -25,7 +25,7 @@
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/MC/MCTargetOptionsCommandFlags.inc"
+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
 #include "llvm/PassAnalysisSupport.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -433,7 +433,7 @@
TripleName,
inconvertibleErrorCode());
 
-  MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
+  MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags();
   MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
   if (!MAI)
 return make_error("no asm info for target " + TripleName,
Index: llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
===
--- llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
+++ llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
@@ -22,3 +22,4 @@
   )
 
 target_link_libraries(DebugInfoDWARFTests PRIVATE LLVMTestingSupport)
+target_link_libraries(DebugInfoDWARFTests PUBLIC LLVMMCCommandFlags)
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -22,7 +22,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Bitcode/BitcodeWriterPass.h"
-#include "llvm/CodeGen/CommandFlags.inc"
+#include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DataLayout.h"
@@ -62,6 +62,8 @@
 using namespace llvm;
 using namespace opt_tool;
 
+static codegen::InitializeCodeGenFlags CFG;
+
 // The OptimizationList is automatically populated with registered Passes by the
 // PassNameParser.
 //
@@ -471,16 +473,17 @@
StringRef FeaturesStr,
const TargetOptions &Options) {
   std::string Error;
-  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple,
- Error);
+  const Target *TheTarget =
+  TargetRegistry::lookupTarget(codegen::getMArch(), TheTriple, Error);
   // Some modules don't specify a triple, and this is okay.
   if (!TheTarget) {
 return nullptr;
   }
 
-  return TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr,
-FeaturesStr, Options, getRelocModel(),
-getCodeModel(), GetCodeGenOptLevel());
+  return TheTarget->createTargetMachine(
+  TheTriple.getTriple(), codegen::getCP

[PATCH] D75621: [clang-tidy] Use ; as separator for HeaderFileExtensions

2020-03-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs marked an inline comment as done.
jroelofs added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h:44-46
 bool parseFileExtensions(StringRef AllFileExtensions,
- FileExtensionsSet &FileExtensions, char Delimiter);
+ FileExtensionsSet &FileExtensions,
+ StringRef Delimiters);

njames93 wrote:
> jroelofs wrote:
> > njames93 wrote:
> > > Doesn't belong in this patch, but this function should be changed in a 
> > > follow up to return an `Optional`.
> > Looking at the uses, I'm not convinced this would be better in this 
> > specific case.
> > 
> > Compare:
> > ```
> > if (Optional HFE = parseFileExtensions(Extensions, 
> > Delimiters)) {
> >   HeaderFileExtensions = *HFE;
> > } else {
> >   errs() << "Invalid extensions: " << Extensions;
> > }
> > ```
> > 
> > With the status quo:
> > ```
> > if (!parseFileExtensions(Extensions, HeaderFileExtensions, Delimiters)) {
> >   errs() << "Invalid extensions: " << Extensions;
> > }
> > ```
> > 
> > Optional's explicit operator bool is great for when you want to guard on 
> > the presence of the thing, but not so great when you want to check for it 
> > not being there. I feel like we'd need some new utility to go with Optional 
> > to make this nice:
> > 
> > ```
> > if (not(HeaderFileExtensions) = parseFileExtensions(Extensions, 
> > Delimiters)) {
> >   errs() << "Invalid extensions: " << Extensions;
> > }
> > ```
> To be honest it should probably be `Expected` rather than `Optional`, but 
> that still doesn't help solve the cleanliness issue.
Implementation of the `not` idea here:

https://gcc.godbolt.org/z/XZh39g


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75621



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


[clang] 58884eb - [analyzer][NFC] Refactor the checker registration unit test file

2020-03-09 Thread Kirstóf Umann via cfe-commits

Author: Kirstóf Umann
Date: 2020-03-09T16:38:30+01:00
New Revision: 58884eb6489880646896d72fcd723813f8a13299

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

LOG: [analyzer][NFC] Refactor the checker registration unit test file

Nothing exciting to see here! The new interface allows for more fine tuning
(register but disable a checker, add custom checker registry functions, etc),
that was basically the point.

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

Added: 
clang/unittests/StaticAnalyzer/CheckerRegistration.h

Modified: 
clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h 
b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
index bc258160ada4..269c226f2e1d 100644
--- a/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ b/clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -204,16 +204,14 @@ class CheckerRegistry {
 
   using PackageInfoList = llvm::SmallVector;
 
-private:
-  template  static void initializeManager(CheckerManager &mgr) {
+  template  static void addToCheckerMgr(CheckerManager &mgr) {
 mgr.registerChecker();
   }
 
-  template  static bool returnTrue(const LangOptions &LO) {
+  static bool returnTrue(const LangOptions &LO) {
 return true;
   }
 
-public:
   /// Adds a checker to the registry. Use this non-templated overload when your
   /// checker requires custom initialization.
   void addChecker(InitializationFunction Fn, ShouldRegisterFunction sfn,
@@ -227,9 +225,8 @@ class CheckerRegistry {
   bool IsHidden = false) {
 // Avoid MSVC's Compiler Error C2276:
 // http://msdn.microsoft.com/en-us/library/850cstw1(v=VS.80).aspx
-addChecker(&CheckerRegistry::initializeManager,
-   &CheckerRegistry::returnTrue, FullName, Desc, DocsUri,
-   IsHidden);
+addChecker(&CheckerRegistry::addToCheckerMgr,
+   &CheckerRegistry::returnTrue, FullName, Desc, DocsUri, 
IsHidden);
   }
 
   /// Makes the checker with the full name \p fullName depends on the checker

diff  --git a/clang/unittests/StaticAnalyzer/CheckerRegistration.h 
b/clang/unittests/StaticAnalyzer/CheckerRegistration.h
new file mode 100644
index ..0bbed9b7784f
--- /dev/null
+++ b/clang/unittests/StaticAnalyzer/CheckerRegistration.h
@@ -0,0 +1,81 @@
+//===- unittests/StaticAnalyzer/RegisterCustomCheckersTest.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
+//
+//===--===//
+
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
+#include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
+#include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
+#include "clang/Tooling/Tooling.h"
+
+namespace clang {
+namespace ento {
+
+class DiagConsumer : public PathDiagnosticConsumer {
+  llvm::raw_ostream &Output;
+
+public:
+  DiagConsumer(llvm::raw_ostream &Output) : Output(Output) {}
+  void FlushDiagnosticsImpl(std::vector &Diags,
+FilesMade *filesMade) override {
+for (const auto *PD : Diags)
+  Output << PD->getCheckerName() << ":" << PD->getShortDescription() << 
'\n';
+  }
+
+  StringRef getName() const override { return "Test"; }
+};
+
+using AddCheckerFn = void(AnalysisASTConsumer &AnalysisConsumer,
+  AnalyzerOptions &AnOpts);
+
+template 
+void addChecker(AnalysisASTConsumer &AnalysisConsumer,
+AnalyzerOptions &AnOpts) {
+  Fn1(AnalysisConsumer, AnOpts);
+  addChecker(AnalysisConsumer, AnOpts);
+}
+
+template 
+void addChecker(AnalysisASTConsumer &AnalysisConsumer,
+AnalyzerOptions &AnOpts) {
+  Fn1(AnalysisConsumer, AnOpts);
+}
+
+template 
+class TestAction : public ASTFrontendAction {
+  llvm::raw_ostream &DiagsOutput;
+
+public:
+  TestAction(llvm::raw_ostream &DiagsOutput) : DiagsOutput(DiagsOutput) {}
+
+  std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
+ StringRef File) override {
+std::unique_ptr AnalysisConsumer =
+CreateAnalysisConsumer(Compiler);
+AnalysisConsumer->AddDiagnosticConsumer(new DiagConsumer(DiagsOutput));
+addChecker(*AnalysisConsumer

[PATCH] D75843: [ARM,CDE] Implement CDE feature test macros

2020-03-09 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki updated this revision to Diff 249115.
miyuki added a comment.

Fix condition check


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

https://reviews.llvm.org/D75843

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/test/Preprocessor/arm-target-features.c

Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -800,6 +800,18 @@
 // CHECK-V81M-MVE-NODSP-NOT: #define __ARM_FEATURE_MVE
 // CHECK-V81M-MVE-NODSP-NOT: #define __ARM_FEATURE_DSP
 
+// Test CDE (Custom Datapath Extension) feature test macros
+
+// RUN: %clang -target arm-arm-none-eabi -march=armv8m.main -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-V8M-NOCDE %s
+// CHECK-V8M-NOCDE-NOT: #define __ARM_FEATURE_CDE
+// CHECK-V8M-NOCDE-NOT: #define __ARM_FEATURE_CDE_COPROC
+// RUN: %clang -target arm-arm-none-eabi -march=armv8m.main+cdecp0+cdecp1+cdecp7 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V8M-CDE-MASK1 %s
+// CHECK-V8M-CDE-MASK1: #define __ARM_FEATURE_CDE 1
+// CHECK-V8M-CDE-MASK1: #define __ARM_FEATURE_CDE_COPROC 0x83
+// RUN: %clang -target arm-arm-none-eabi -march=armv8m.main+cdecp0+cdecp1+cdecp2+cdecp3+cdecp4+cdecp5+cdecp6+cdecp7 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V8M-CDE-MASK2 %s
+// CHECK-V8M-CDE-MASK2: #define __ARM_FEATURE_CDE 1
+// CHECK-V8M-CDE-MASK2: #define __ARM_FEATURE_CDE_COPROC 0xff
+
 // RUN: %clang -target armv8.1a-none-none-eabi -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V81A %s
 // CHECK-V81A: #define __ARM_ARCH 8
 // CHECK-V81A: #define __ARM_ARCH_8_1A__ 1
Index: clang/lib/Basic/Targets/ARM.h
===
--- clang/lib/Basic/Targets/ARM.h
+++ clang/lib/Basic/Targets/ARM.h
@@ -108,6 +108,7 @@
   bool supportsThumb2() const;
   bool hasMVE() const;
   bool hasMVEFloat() const;
+  bool hasCDE() const;
 
   StringRef getCPUAttr() const;
   StringRef getCPUProfile() const;
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -154,6 +154,8 @@
   return hasMVE() && (MVE & MVE_FP);
 }
 
+bool ARMTargetInfo::hasCDE() const { return getARMCDECoprocMask() != 0; }
+
 bool ARMTargetInfo::isThumb() const {
   return ArchISA == llvm::ARM::ISAKind::THUMB;
 }
@@ -422,6 +424,7 @@
   HWDiv = 0;
   DotProd = 0;
   HasFloat16 = true;
+  ARMCDECoprocMask = 0;
 
   // This does not diagnose illegal cases like having both
   // "+vfpv2" and "+vfpv3" or having "+neon" and "-fp64".
@@ -486,6 +489,10 @@
   FPU |= FPARMV8;
   MVE |= MVE_INT | MVE_FP;
   HW_FP |= HW_FP_SP | HW_FP_HP;
+} else if (Feature.size() == strlen("+cdecp0") && Feature >= "+cdecp0" &&
+   Feature <= "+cdecp7") {
+  unsigned Coproc = Feature.back() - '0';
+  ARMCDECoprocMask |= (1U << Coproc);
 }
   }
 
@@ -758,6 +765,12 @@
 Builder.defineMacro("__ARM_FEATURE_MVE", hasMVEFloat() ? "3" : "1");
   }
 
+  if (hasCDE()) {
+Builder.defineMacro("__ARM_FEATURE_CDE", "1");
+Builder.defineMacro("__ARM_FEATURE_CDE_COPROC",
+"0x" + Twine::utohexstr(getARMCDECoprocMask()));
+  }
+
   Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
   Twine(Opts.WCharSize ? Opts.WCharSize : 4));
 
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -113,6 +113,7 @@
   HasBuiltinMSVaList = false;
   IsRenderScriptTarget = false;
   HasAArch64SVETypes = false;
+  ARMCDECoprocMask = 0;
 
   // Default to no types using fpret.
   RealTypeUsesObjCFPRet = 0;
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -210,6 +210,8 @@
 
   unsigned HasAArch64SVETypes : 1;
 
+  unsigned ARMCDECoprocMask : 8;
+
   // TargetInfo Constructor.  Default initializes all fields.
   TargetInfo(const llvm::Triple &T);
 
@@ -808,6 +810,10 @@
   /// available on this target.
   bool hasAArch64SVETypes() const { return HasAArch64SVETypes; }
 
+  /// For ARM targets returns a mask defining which coprocessors are configured
+  /// as Custom Datapath.
+  uint32_t getARMCDECoprocMask() const { return ARMCDECoprocMask; }
+
   /// Returns whether the passed in string is a valid clobber in an
   /// inline asm statement.
   ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75805: Make malign-double effective only for x86

2020-03-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

`-Xclang -malign-double` passes a CC1 option. This is like poking into the 
compiler internals. The interface is not stable, and some flags may not make 
sense (they can be precluded by clang/lib/Driver logic), so I am not sure why 
it is reported as a bug in the first place.

edit: The problem is that Opts.AlignDouble in TargetInfo.cpp needs some 
adaptation to make it work for aarch64_32. I will on a patch.


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

https://reviews.llvm.org/D75805



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


[PATCH] D75851: [Analyzer][StreamChecker] Added evaluation of fseek.

2020-03-09 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, martong, Charusso, gamesh411, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a project: clang.
balazske added a parent revision: D75682: [Analyzer][StreamChecker] 
Introduction of stream error handling..

Function `fseek` is now evaluated with setting error return value
and error flags.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75851

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-error.c


Index: clang/test/Analysis/stream-error.c
===
--- clang/test/Analysis/stream-error.c
+++ clang/test/Analysis/stream-error.c
@@ -38,3 +38,20 @@
   }
   fclose(F);
 }
+
+void error_fseek() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc) {
+int Eof = feof(F), Error = ferror(F);
+clang_analyzer_eval(Eof || Error); // expected-warning {{FALSE}} \
+   // expected-warning {{TRUE}}
+clang_analyzer_eval(Eof && Error); // expected-warning {{FALSE}}
+  } else {
+clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  }
+  fclose(F);
+}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -128,7 +128,7 @@
{&StreamChecker::preDefault, &StreamChecker::evalFclose, 0}},
   {{"fread", 4}, {&StreamChecker::preDefault, nullptr, 3}},
   {{"fwrite", 4}, {&StreamChecker::preDefault, nullptr, 3}},
-  {{"fseek", 3}, {&StreamChecker::preFseek, nullptr, 0}},
+  {{"fseek", 3}, {&StreamChecker::preFseek, &StreamChecker::evalFseek, 0}},
   {{"ftell", 1}, {&StreamChecker::preDefault, nullptr, 0}},
   {{"rewind", 1}, {&StreamChecker::preDefault, nullptr, 0}},
   {{"fgetpos", 2}, {&StreamChecker::preDefault, nullptr, 0}},
@@ -154,6 +154,8 @@
 
   void preFseek(const FnDescription *Desc, const CallEvent &Call,
 CheckerContext &C) const;
+  void evalFseek(const FnDescription *Desc, const CallEvent &Call,
+ CheckerContext &C) const;
 
   void preDefault(const FnDescription *Desc, const CallEvent &Call,
   CheckerContext &C) const;
@@ -340,6 +342,48 @@
   C.addTransition(State);
 }
 
+void StreamChecker::evalFseek(const FnDescription *Desc, const CallEvent &Call,
+  CheckerContext &C) const {
+  ProgramStateRef State = C.getState();
+  SymbolRef StreamSym = getStreamArg(Desc, Call).getAsSymbol();
+  if (!StreamSym)
+return;
+
+  const CallExpr *CE = dyn_cast_or_null(Call.getOriginExpr());
+  if (!CE)
+return;
+
+  // Ignore the call if the stream is not tracked.
+  if (!State->get(StreamSym))
+return;
+
+  DefinedSVal RetVal = makeRetVal(C, CE);
+
+  // Make expression result.
+  State = State->BindExpr(CE, C.getLocationContext(), RetVal);
+
+  // Bifurcate the state into failed and non-failed.
+  // Return zero on success, nonzero on error.
+  ProgramStateRef StateNotFailed, StateFailed;
+  std::tie(StateFailed, StateNotFailed) =
+  C.getConstraintManager().assumeDual(State, RetVal);
+
+  // Reset the state to opened with no error.
+  StateNotFailed =
+  StateNotFailed->set(StreamSym, StreamState::getOpened());
+  // There are two ways of failure:
+  // We get some error (ferror or feof).
+  ProgramStateRef StateFailedWithFError = StateFailed->set(
+  StreamSym, StreamState::getOpenedWithAnyError());
+  // We get none of the error flags.
+  ProgramStateRef StateFailedWithoutFError =
+  StateFailed->set(StreamSym, StreamState::getOpened());
+
+  C.addTransition(StateNotFailed);
+  C.addTransition(StateFailedWithFError);
+  C.addTransition(StateFailedWithoutFError);
+}
+
 void StreamChecker::evalClearerr(const FnDescription *Desc,
  const CallEvent &Call,
  CheckerContext &C) const {


Index: clang/test/Analysis/stream-error.c
===
--- clang/test/Analysis/stream-error.c
+++ clang/test/Analysis/stream-error.c
@@ -38,3 +38,20 @@
   }
   fclose(F);
 }
+
+void error_fseek() {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc) {
+int Eof = feof(F), Error = ferror(F);
+clang_analyzer_eval(Eof || Error); // expected-warning {{FALSE}} \
+   // expected-warning {{TRUE}}
+clang_analyzer_eval(Eof && Error); // expected-warning {{FALSE}}
+  } else {
+clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+clang_analyzer_eval(fe

[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

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

The thing to note here is checkers that are not `isDisabled()` won't get 
enabled, only if they are `isEnabled()` as well :)

Please add a unit test, otherwise LGTM. I just landed D67335 
, so it should be easy to do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75842



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


[PATCH] D75714: Add Optional overload to DiagnosticBuilder operator <

2020-03-09 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 249121.
njames93 added a comment.

- Removed template in favour of specific overloads


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75714

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


Index: clang/include/clang/Basic/Diagnostic.h
===
--- clang/include/clang/Basic/Diagnostic.h
+++ clang/include/clang/Basic/Diagnostic.h
@@ -21,6 +21,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
@@ -1288,6 +1289,45 @@
   return DB;
 }
 
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,
+   const llvm::Optional &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,
+   const llvm::Optional> &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,
+   const llvm::Optional &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB, const llvm::Optional &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,
+   const llvm::Optional> &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
 /// A nullability kind paired with a bit indicating whether it used a
 /// context-sensitive keyword.
 using DiagNullabilityKind = std::pair;


Index: clang/include/clang/Basic/Diagnostic.h
===
--- clang/include/clang/Basic/Diagnostic.h
+++ clang/include/clang/Basic/Diagnostic.h
@@ -21,6 +21,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
@@ -1288,6 +1289,45 @@
   return DB;
 }
 
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,
+   const llvm::Optional &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,
+   const llvm::Optional> &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,
+   const llvm::Optional &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB, const llvm::Optional &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,
+   const llvm::Optional> &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
 /// A nullability kind paired with a bit indicating whether it used a
 /// context-sensitive keyword.
 using DiagNullabilityKind = std::pair;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75788: [WIP][OpenMP] Reuse CUDA wrappers in `nvptx` target regions.

2020-03-09 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Couple of nits below. LGTM for CUDA headers otherwise.




Comment at: clang/lib/Headers/__clang_cuda_math_forward_declares.h:42-43
 __DEVICE__ long long abs(long long);
-__DEVICE__ double abs(double);
-__DEVICE__ float abs(float);
-#endif

Shouldn't float and double abs variants be preserved?



Comment at: clang/lib/Headers/cuda_wrappers/new:107
+#pragma omp end declare variant
+#endif
+

You may want to push/pop `__DEVICE__` macro here and in other headers where 
it's not done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75788



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


[PATCH] D72841: [RFC] Add support for pragma float_control, to control precision and exception behavior at the source level

2020-03-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D72841#1912416 , @mibintc wrote:

> In D72841#1911330 , @rjmccall wrote:
>
> > In D72841#1908084 , @mibintc wrote:
> >
> > > @rjmccall suggested that I needed to remove FPOptions from the Stmt class 
> > > since the sizeof assertion failed. I moved that information into the 
> > > relevant expression nodes and fixed a few small things that I didn't like 
> > > in the previous version.
> >
> >
> > You only need to do this for the expression nodes where it causes an 
> > overflow in the size of the bit-field; I don't think you're overflowing the 
> > capacity of UnaryOperatorBitfields, for example.
>
>
> I added unsigned FPFeatures : 14; to class UnaryOperatorBitfields but I 
> encountered the same assertion failure in the Stmt constructor, In 
> constructor ‘clang::Stmt::Stmt(clang::Stmt::StmtClass)’:
>  
> /iusers/sandbox/pragma-ws/llvm-project/clang/include/clang/AST/Stmt.h:1095:5: 
> error: static assertion failed: changing bitfields changed sizeof(Stmt)
>
>   static_assert(sizeof(*this) <= 8


Oh, okay.  It's actually pretty unfortunate that we need to increase the memory 
use of every UnaryOperator, BinaryOperator, and CallExpr in the AST just in 
case these pragmas are in use.  Most instances of these expressions provably 
have nothing to do with floating-point, and in practice the pragmas are very 
rarely used.

I mentioned up-thread that it would be nice to make serialized AST actually 
agnostic about the basic language settings.  That would require us to track not 
just the active option set, but what overrides were actually in place when 
parsing any given expression; we could then merge the two pretty easily in 
IRGen.   (We could represent this with masks: we could then merge the 
information by taking the default-settings mask, bitwise-and'ing with the 
override mask to clear any values that will be overridden, and bitwise-or'ing 
the override values on top.)  But if we did that, then it would be easy for us 
to identify when creating an AST node that no overrides are in effect; that 
would let us just store a single flag in the class indicating whether there 
were overrides, then use trailing storage for the actual overrides if present.  
This would relieve almost all of the pressure to keep the storage size down.

We could take it a step further by trying to recognize when building certain 
AST nodes that they're not floating-point operations and just building them 
with no overrides.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D67335: [analyzer][NFC] Refactor the checker registration unit test file

2020-03-09 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG58884eb64898: [analyzer][NFC] Refactor the checker 
registration unit test file (authored by Szelethus).
Herald added subscribers: martong, steakhal.

Changed prior to commit:
  https://reviews.llvm.org/D67335?vs=219279&id=249125#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67335

Files:
  clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  clang/unittests/StaticAnalyzer/CheckerRegistration.h
  clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Index: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
===
--- clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -6,11 +6,13 @@
 //
 //===--===//
 
+#include "CheckerRegistration.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
 #include "clang/StaticAnalyzer/Frontend/CheckerRegistry.h"
 #include "clang/Tooling/Tooling.h"
@@ -20,53 +22,10 @@
 namespace ento {
 namespace {
 
-template 
-class TestAction : public ASTFrontendAction {
-  class DiagConsumer : public PathDiagnosticConsumer {
-llvm::raw_ostream &Output;
-
-  public:
-DiagConsumer(llvm::raw_ostream &Output) : Output(Output) {}
-void FlushDiagnosticsImpl(std::vector &Diags,
-  FilesMade *filesMade) override {
-  for (const auto *PD : Diags)
-Output << PD->getCheckerName() << ":" << PD->getShortDescription();
-}
-
-StringRef getName() const override { return "Test"; }
-  };
-
-  llvm::raw_ostream &DiagsOutput;
-
-public:
-  TestAction(llvm::raw_ostream &DiagsOutput) : DiagsOutput(DiagsOutput) {}
-
-  std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
- StringRef File) override {
-std::unique_ptr AnalysisConsumer =
-CreateAnalysisConsumer(Compiler);
-AnalysisConsumer->AddDiagnosticConsumer(new DiagConsumer(DiagsOutput));
-Compiler.getAnalyzerOpts()->CheckersAndPackages = {
-{"custom.CustomChecker", true}};
-AnalysisConsumer->AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
-  Registry.addChecker("custom.CustomChecker", "Description", "");
-});
-return std::move(AnalysisConsumer);
-  }
-};
-
-template 
-bool runCheckerOnCode(const std::string &Code, std::string &Diags) {
-  llvm::raw_string_ostream OS(Diags);
-  return tooling::runToolOnCode(std::make_unique>(OS),
-Code);
-}
-template 
-bool runCheckerOnCode(const std::string &Code) {
-  std::string Diags;
-  return runCheckerOnCode(Code, Diags);
-}
-
+//===--===//
+// Just a minimal test for how checker registration works with statically
+// linked, non TableGen generated checkers.
+//===--===//
 
 class CustomChecker : public Checker {
 public:
@@ -78,12 +37,25 @@
   }
 };
 
+void addCustomChecker(AnalysisASTConsumer &AnalysisConsumer,
+  AnalyzerOptions &AnOpts) {
+  AnOpts.CheckersAndPackages = {{"custom.CustomChecker", true}};
+  AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
+Registry.addChecker("custom.CustomChecker", "Description",
+   "");
+  });
+}
+
 TEST(RegisterCustomCheckers, RegisterChecker) {
   std::string Diags;
-  EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags));
-  EXPECT_EQ(Diags, "custom.CustomChecker:Custom diagnostic description");
+  EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags));
+  EXPECT_EQ(Diags, "custom.CustomChecker:Custom diagnostic description\n");
 }
 
+//===--===//
+// Pretty much the same.
+//===--===//
+
 class LocIncDecChecker : public Checker {
 public:
   void checkLocation(SVal Loc, bool IsLoad, const Stmt *S,
@@ -95,11 +67,20 @@
   }
 };
 
+void addLocIncDecChecker(AnalysisASTConsumer &AnalysisConsumer,
+ AnalyzerOptions &AnOpts) {
+  AnOpts.CheckersAndPackages = {{"test.LocIncDecChecker", true}};
+  AnalysisConsumer.AddCheckerRegistrationFn([](CheckerRegistry &Registry) {
+Registry.addChecker("test.LocIncDecChecker", "Description",
+  

[clang] cdeeb54 - [ARM,CDE] Implement CDE feature test macros

2020-03-09 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-03-09T16:14:06Z
New Revision: cdeeb548bbebdff7661fb20b72839b920be0adbe

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

LOG: [ARM,CDE] Implement CDE feature test macros

Summary:
This patch implements feature test macros for the CDE extension
according to the upcoming ACLE specification.

The following 2 macros are being added:
- __ARM_FEATURE_CDE - defined as '1' when any coprocessor is
  configured as a CDE coprocessor
- __ARM_FEATURE_CDE_COPROC - defined as an 8-bit mask, each bit of the
  mask corresponds to a coprocessor and is set when the corresponding
  coprocessor is configured as CDE (and cleared otherwise).

The patch also exposes the value of __ARM_FEATURE_CDE_COPROC in the
target-independent method TargetInfo::getARMCDECorpocMask, the method
will be used in follow-up patches implementing semantic checks of CDE
intrinsics (we want to diagnose the cases when CDE intrinsics are used
with coprocessors that are not configured as CDE).

Reviewers: simon_tatham, dmgreen, ostannard, MarkMurrayARM

Reviewed By: simon_tatham

Subscribers: kristof.beyls, danielkiss, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/ARM.cpp
clang/lib/Basic/Targets/ARM.h
clang/test/Preprocessor/arm-target-features.c

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 80581eabe1b7..cbfcece1b666 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -210,6 +210,8 @@ class TargetInfo : public virtual TransferrableTargetInfo,
 
   unsigned HasAArch64SVETypes : 1;
 
+  unsigned ARMCDECoprocMask : 8;
+
   // TargetInfo Constructor.  Default initializes all fields.
   TargetInfo(const llvm::Triple &T);
 
@@ -808,6 +810,10 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// available on this target.
   bool hasAArch64SVETypes() const { return HasAArch64SVETypes; }
 
+  /// For ARM targets returns a mask defining which coprocessors are configured
+  /// as Custom Datapath.
+  uint32_t getARMCDECoprocMask() const { return ARMCDECoprocMask; }
+
   /// Returns whether the passed in string is a valid clobber in an
   /// inline asm statement.
   ///

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 3a21a19e1f19..58d018c5bd3e 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -113,6 +113,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : 
TargetOpts(), Triple(T) {
   HasBuiltinMSVaList = false;
   IsRenderScriptTarget = false;
   HasAArch64SVETypes = false;
+  ARMCDECoprocMask = 0;
 
   // Default to no types using fpret.
   RealTypeUsesObjCFPRet = 0;

diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 02144c6ebe85..4ab794ef3c09 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -154,6 +154,8 @@ bool ARMTargetInfo::hasMVEFloat() const {
   return hasMVE() && (MVE & MVE_FP);
 }
 
+bool ARMTargetInfo::hasCDE() const { return getARMCDECoprocMask() != 0; }
+
 bool ARMTargetInfo::isThumb() const {
   return ArchISA == llvm::ARM::ISAKind::THUMB;
 }
@@ -422,6 +424,7 @@ bool 
ARMTargetInfo::handleTargetFeatures(std::vector &Features,
   HWDiv = 0;
   DotProd = 0;
   HasFloat16 = true;
+  ARMCDECoprocMask = 0;
 
   // This does not diagnose illegal cases like having both
   // "+vfpv2" and "+vfpv3" or having "+neon" and "-fp64".
@@ -486,6 +489,10 @@ bool 
ARMTargetInfo::handleTargetFeatures(std::vector &Features,
   FPU |= FPARMV8;
   MVE |= MVE_INT | MVE_FP;
   HW_FP |= HW_FP_SP | HW_FP_HP;
+} else if (Feature.size() == strlen("+cdecp0") && Feature >= "+cdecp0" &&
+   Feature <= "+cdecp7") {
+  unsigned Coproc = Feature.back() - '0';
+  ARMCDECoprocMask |= (1U << Coproc);
 }
   }
 
@@ -758,6 +765,12 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 Builder.defineMacro("__ARM_FEATURE_MVE", hasMVEFloat() ? "3" : "1");
   }
 
+  if (hasCDE()) {
+Builder.defineMacro("__ARM_FEATURE_CDE", "1");
+Builder.defineMacro("__ARM_FEATURE_CDE_COPROC",
+"0x" + Twine::utohexstr(getARMCDECoprocMask()));
+  }
+
   Builder.defineMacro("__ARM_SIZEOF_WCHAR_T",
   Twine(Opts.WCharSize ? Opts.WCharSize : 4));
 

diff  --git a/clang/lib/Basic/Targets/ARM.h b/clang/lib/Basic/Targets/ARM.h
index 9696a4404589..725954038602 100644
--- a/clang/lib/Basic/Targets/ARM.h
+++ b/clang/lib/Basic/Targets/ARM.h
@@ -108,6 +108,7 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public 
Ta

[PATCH] D75524: [www] cxx_status: Update Reflection TS to Cologne draft

2020-03-09 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75524



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


[PATCH] D68578: [HIP] Fix device stub name

2020-03-09 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Few nits. LGTM otherwise.




Comment at: clang/include/clang/AST/GlobalDecl.h:61
 assert(!isa(D) && "Use other ctor with dtor decls!");
+assert(!D->hasAttr() && "Use other ctor with HIP 
kernels!");
 

Wording inconsitency -- we're checking for `CUDAGlobalAttr` but complaining 
about 'HIP kernels'. Just drop 'HIP' or replace with 'GPU'?



Comment at: clang/include/clang/AST/GlobalDecl.h:85
+  : Value(D, unsigned(Kind)) {
+assert(D->hasAttr() && "Decl is not a HIP kernel!");
+  }

Ditto.



Comment at: clang/include/clang/AST/GlobalDecl.h:129
+   cast(getDecl())->hasAttr() &&
+   "Decl is not a HIP kernel!");
+return static_cast(Value.getInt());

Same wording nit.



Comment at: clang/include/clang/AST/GlobalDecl.h:188
+   cast(getDecl())->hasAttr() &&
+   "Decl is not a HIP kernel!");
+GlobalDecl Result(*this);

Ditto.



Comment at: clang/lib/CodeGen/CGCUDARuntime.h:69
   virtual llvm::Function *makeModuleDtorFunction() = 0;
-
-  /// Construct and return the stub name of a kernel.
-  virtual std::string getDeviceStubName(llvm::StringRef Name) const = 0;
+  virtual std::string getDeviceSideName(const Decl *ND) = 0;
 };

Adding a descriptive comment would be great. Otherwise anyone looking at the 
function decl without the context of this patch will be puzzled about its 
meaning and purpose.

Also, perhaps the argument type should be a `NamedDecl` -- the function is not 
used on or useful for regular `Decl`. It will save us few casts in other 
places, too.


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

https://reviews.llvm.org/D68578



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


[PATCH] D75184: [clang-tidy] Optional inheritance of file configs from parent directories 

2020-03-09 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

How are local and global options handled. 
For example in root .clang-tidy:

  CheckOptions:
- key: some-check.GlobalOption
  value:   '1'

and in a subfolder .clang-tidy:

  CheckOptions:
- key: GlobalOption
  value:   '0'

Should some-check read GlobalOption (with `Options::getLocalOrGlobal`) as:

- 0 - from the highest level config file or
- 1 - from the highest level local config option.

From what I can gather it will read the value as `1` as the local option is 
checked first no matter which file it was defined in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184



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


[PATCH] D75523: [www] cxx_status: Update title to mention C++20

2020-03-09 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75523



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


  1   2   3   >