[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-28 Thread Aaron Smith via Phabricator via cfe-commits
asmith updated this revision to Diff 260551.
asmith added a comment.

Fix line breaks like this:

enum { a=1, b=2, c=3
} myEnum;

which becomes:

enum 
{

  a=1,
  b=2,
  c=3

} myEnum;


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

https://reviews.llvm.org/D78982

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp

Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1764,6 +1764,8 @@
   }
 }
 if (FormatTok->Tok.getKind() == ClosingBraceKind) {
+  if (!Style.AllowEnumsOnASingleLine)
+addUnwrappedLine();
   nextToken();
   return !HasError;
 }
@@ -1822,6 +1824,8 @@
   break;
 case tok::comma:
   nextToken();
+  if (!Style.AllowEnumsOnASingleLine)
+addUnwrappedLine();
   break;
 default:
   nextToken();
@@ -2280,9 +2284,17 @@
 return true;
   }
 
+  if (!Style.AllowEnumsOnASingleLine)
+addUnwrappedLine();
   // Parse enum body.
   nextToken();
+  if (!Style.AllowEnumsOnASingleLine) {
+addUnwrappedLine();
+Line->Level += 1;
+  }
   bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowEnumsOnASingleLine)
+Line->Level -= 1;
   if (HasError) {
 if (FormatTok->is(tok::semi))
   nextToken();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -397,6 +397,8 @@
Style.AllowAllConstructorInitializersOnNextLine);
 IO.mapOptional("AllowAllParametersOfDeclarationOnNextLine",
Style.AllowAllParametersOfDeclarationOnNextLine);
+IO.mapOptional("AllowEnumsOnASingleLine",
+   Style.AllowEnumsOnASingleLine);
 IO.mapOptional("AllowShortBlocksOnASingleLine",
Style.AllowShortBlocksOnASingleLine);
 IO.mapOptional("AllowShortCaseLabelsOnASingleLine",
@@ -752,6 +754,7 @@
   LLVMStyle.AllowAllArgumentsOnNextLine = true;
   LLVMStyle.AllowAllConstructorInitializersOnNextLine = true;
   LLVMStyle.AllowAllParametersOfDeclarationOnNextLine = true;
+  LLVMStyle.AllowEnumsOnASingleLine = true;
   LLVMStyle.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
   LLVMStyle.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
   LLVMStyle.AllowShortCaseLabelsOnASingleLine = false;
@@ -1137,6 +1140,7 @@
   Style.BraceWrapping.BeforeCatch = true;
   Style.BraceWrapping.BeforeElse = true;
   Style.PenaltyReturnTypeOnItsOwnLine = 1000;
+  Style.AllowEnumsOnASingleLine = false;
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
   Style.AllowShortCaseLabelsOnASingleLine = false;
   Style.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -221,6 +221,20 @@
   /// \endcode
   bool AllowAllParametersOfDeclarationOnNextLine;
 
+  /// Allow enums on a single line.
+  /// \code
+  ///   true:
+  ///   enum { A, B } myEnum;
+  ///
+  ///   false:
+  ///   enum
+  ///   {
+  /// A,
+  /// B,
+  ///   } myEnum;
+  /// \endcode
+  bool AllowEnumsOnASingleLine;
+  
   /// Different styles for merging short blocks containing at most one
   /// statement.
   enum ShortBlockStyle {
@@ -2160,6 +2174,7 @@
R.AllowAllConstructorInitializersOnNextLine &&
AllowAllParametersOfDeclarationOnNextLine ==
R.AllowAllParametersOfDeclarationOnNextLine &&
+   AllowEnumsOnASingleLine == R.AllowEnumsOnASingleLine &&
AllowShortBlocksOnASingleLine == R.AllowShortBlocksOnASingleLine &&
AllowShortCaseLabelsOnASingleLine ==
R.AllowShortCaseLabelsOnASingleLine &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-04-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked 8 inline comments as done.
hokein added a comment.

In D78350#2006469 , 
@hubert.reinterpretcast wrote:

> In D78350#1988416 , @hokein wrote:
>
> > @ebevhan, @hubert.reinterpretcast, the patch is based on 
> > fd7a34186137168064ffe2ca536823559b92d939 
> > , it 
> > should contain all the fixes.
> >  it would be nice if you can test it again in your downstream clang. Thanks!
>
>
> Got it. I'll put together a build.


Thank you! Look forward to the result. The patch should work on the latest 
master (b73290be9fa413d8bc426512cdf4fa01bc005954 
).




Comment at: clang/test/CXX/class.access/p4.cpp:1
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions 
-fsyntax-only -verify -std=c++98 %s
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions 
-fsyntax-only -verify -std=c++11 %s

for review, this reverts the changes introduced in 
https://github.com/llvm/llvm-project/commit/9657385960350150b77ed652175b4c3801abd7fa.



Comment at: clang/test/CXX/special/class.ctor/p5-0x.cpp:1
 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 
-Wno-defaulted-function-deleted
 

for review, this reverts the changes introduced in 
https://github.com/llvm/llvm-project/commit/9657385960350150b77ed652175b4c3801abd7fa.



Comment at: clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp:23
 
   template
+auto begin(T &&t) -> decltype(t.alt_begin()) { return t.alt_begin(); } // 
expected-note {{selected 'begin' template [with T = }} \

this reverts the changes introduced in 
https://github.com/llvm/llvm-project/commit/89d9912cbf45068770ac8c1e2ef97b74c3b662ab.



Comment at: clang/test/SemaCXX/constant-expression-cxx11.cpp:880
 constexpr Base *nullB1 = 0;
-static_assert((Bottom*)nullB == 0, ""); // expected-error {{static_assert 
expression is not an integral constant expression}}
+static_assert((Bottom*)nullB == 0, "");
 static_assert((Derived*)nullB1 == 0, "");

This reverts the changes introduced in 
https://github.com/llvm/llvm-project/commit/89d9912cbf45068770ac8c1e2ef97b74c3b662ab.



Comment at: clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp:1
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
 

This reverts the changes introduced in 
https://github.com/llvm/llvm-project/commit/9657385960350150b77ed652175b4c3801abd7fa.



Comment at: clang/test/SemaCXX/for-range-dereference.cpp:88
   // expected-error@-1 {{no viable conversion from 'Data' to 'Data *'}}
+  // expected-note@4 {{selected 'begin' function with iterator type 'Data *'}}
 }

This reverted the changes in 
https://github.com/llvm/llvm-project/commit/89d9912cbf45068770ac8c1e2ef97b74c3b662ab,
 



Comment at: clang/test/SemaCXX/virtual-base-used.cpp:43
   // expected-note@-9 {{default constructor of 'B' is implicitly deleted 
because field 'x' has an inaccessible destructor}}
-  // expected-note@-10 {{destructor of 'B' is implicitly deleted}}
 #endif
 #endif

This reverts the changes introduced in 
https://github.com/llvm/llvm-project/commit/9657385960350150b77ed652175b4c3801abd7fa.




Comment at: clang/test/SemaObjCXX/arc-0x.mm:118
   // ARC is enabled and the union has an ObjC pointer field.
   union U0 {
+id f0; // expected-note 6 {{'U0' is implicitly deleted because variant 
field 'f0' is an ObjC pointer}}

This reverts the changes introduced in 
https://github.com/llvm/llvm-project/commit/9657385960350150b77ed652175b4c3801abd7fa.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78350



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

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

In D77229#2007038 , 
@baloghadamsoftware wrote:

> As I wrote, I debugged and analyzed it and I am facing a problem for which I 
> need help. Operator calls are very poorly implemented in the AST.


Yes, indeed very poorly. A C++ operator call is either implemented as 
`CXXOperatorCall` or `CXXMethodCall` randomly. In the former case the `this` 
parameter is explicit at the beginning, in the latter case it is implicit. I 
managed to solve it using this piece of code:

  const auto *Call = cast(CallSite);
  unsigned Index = PVD->getFunctionScopeIndex();
  // For `CallExpr` of C++ member operators we must shift the index by 1
  if (isa(Call)) {
if (const auto *CMD = dyn_cast(SFC->getDecl())) {
  if (CMD->isOverloadedOperator())
++Index;
}
  }

But this is not the only problem with indices. I have no solution for the 
following call (is it really a call?) resulting in an assertion because 
overindexing in `nullability.mm`:

  Dummy *_Nonnull (^myblock)(void) = ^Dummy *_Nonnull(void) {

Even if I try to get the `FunctionDecl` it still says that it has `0` 
parameters, exactly what `CallExpr` says, but we //have// a parameter here with 
index of `0`. How can it be? How should I handle this strange case? I only have 
very basic //Objective-C// knowledge.


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

https://reviews.llvm.org/D77229



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


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

2020-04-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 260552.
hokein added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78350

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_namespace_1.cpp
  clang/test/CXX/class.access/p4.cpp
  clang/test/CXX/special/class.ctor/p5-0x.cpp
  clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
  clang/test/OpenMP/target_update_from_messages.cpp
  clang/test/OpenMP/target_update_to_messages.cpp
  clang/test/Parser/objcxx0x-lambda-expressions.mm
  clang/test/Parser/objcxx11-invalid-lambda.cpp
  clang/test/SemaCXX/cast-conversion.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/constructor-initializer.cpp
  clang/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
  clang/test/SemaCXX/cxx1z-copy-omission.cpp
  clang/test/SemaCXX/decltype-crash.cpp
  clang/test/SemaCXX/for-range-dereference.cpp
  clang/test/SemaCXX/recovery-default-init.cpp
  clang/test/SemaCXX/recovery-initializer.cpp
  clang/test/SemaCXX/varargs.cpp
  clang/test/SemaCXX/virtual-base-used.cpp
  clang/test/SemaObjCXX/arc-0x.mm
  clang/test/SemaOpenCLCXX/address-space-references.cl
  clang/test/SemaTemplate/instantiate-init.cpp

Index: clang/test/SemaTemplate/instantiate-init.cpp
===
--- clang/test/SemaTemplate/instantiate-init.cpp
+++ clang/test/SemaTemplate/instantiate-init.cpp
@@ -108,7 +108,7 @@
 integral_c<1> ic1 = array_lengthof(Description::data);
 (void)sizeof(array_lengthof(Description::data));
 
-sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
+(void)sizeof(array_lengthof( // expected-error{{no matching function for call to 'array_lengthof'}}
   Description::data // expected-note{{in instantiation of static data member 'PR7985::Description::data' requested here}}
   ));
 
Index: clang/test/SemaOpenCLCXX/address-space-references.cl
===
--- clang/test/SemaOpenCLCXX/address-space-references.cl
+++ clang/test/SemaOpenCLCXX/address-space-references.cl
@@ -11,7 +11,7 @@
 int bar(const unsigned int &i);
 
 void foo() {
-  bar(1) // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
+  bar(1); // expected-error{{binding reference of type 'const __global unsigned int' to value of type 'int' changes address space}}
 }
 
 // Test addr space conversion with nested pointers
Index: clang/test/SemaObjCXX/arc-0x.mm
===
--- clang/test/SemaObjCXX/arc-0x.mm
+++ clang/test/SemaObjCXX/arc-0x.mm
@@ -116,13 +116,13 @@
   // Implicitly-declared special functions of a union are deleted by default if
   // ARC is enabled and the union has an ObjC pointer field.
   union U0 {
-id f0; // expected-note 7 {{'U0' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+id f0; // expected-note 6 {{'U0' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
   };
 
   union U1 {
-__weak id f0; // expected-note 13 {{'U1' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+__weak id f0; // expected-note 12 {{'U1' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
 U1() = default; // expected-warning {{explicitly defaulted default constructor is implicitly deleted}} expected-note {{explicitly defaulted function was implicitly deleted here}}
-~U1() = default; // expected-warning {{explicitly defaulted destructor is implicitly deleted}} expected-note 2{{explicitly defaulted function was implicitly deleted here}}
+~U1() = default; // expected-warning {{explicitly defaulted destructor is implicitly deleted}} expected-note {{explicitly defaulted function was implicitly deleted here}}
 U1(const U1 &) = default; // expected-warning {{explicitly defaulted copy constructor is implicitly deleted}} expected-note 2 {{explicitly defaulted function was implicitly deleted here}}
 U1(U1 &&) = default; // expected-warning {{explicitly defaulted move constructor is implicitly deleted}}
 U1 & operator=(const U1 &) = default; // expected-warning {{explicitly defaulted copy assignment operator is implicitly deleted}} expected-note 2 {{explicitly defaulted function was implicitly deleted here}}
@@ -154,15 +154,15 @@
   // functions of the containing class.
   struct S0 {
 union {
-  id f0; // expected-note 7 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  id f0; // expected-note 6 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
   char f1;
 };
   };

[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

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

In D77229#2006106 , @NoQ wrote:

> If your change causes a crash, please debug it. That's a completely normal 
> thing that programmers do every day. Unfortunately, I can't afford to 
> spoon-feed you the solution step-by-step.


I do not require it, but I noticed to you at the very beginning that I need 
assistance. I work on the analyzer for less than 5 years, and not full time, 
because I also create Tidy checkers sometimes, I also have our internal stuff 
(most of which I would like to upstream). As far as I know, you have more than 
10 years experience in the Analyzer. I am already have deep knowledge in some 
parts (e.g. constraint handling, AST), I am somewhat familiar with others 
(`SValBuilder`, `ExprEngine`, `BugReporter` etc.) but I never touched regions 
and store.


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

https://reviews.llvm.org/D77229



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


[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-04-28 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 260554.
gamesh411 added a comment.

Remove arch target from another invocation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665

Files:
  clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
  clang/lib/CrossTU/CMakeLists.txt
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Analysis/Inputs/ctu-other.c
  clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.txt
  clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/ctu-different-triples.cpp
  clang/test/Analysis/ctu-main.c
  clang/test/Analysis/ctu-main.cpp
  clang/test/Analysis/ctu-on-demand-parsing-ambigous-compilation-database.c
  clang/test/Analysis/ctu-on-demand-parsing.c
  clang/test/Analysis/ctu-on-demand-parsing.cpp
  clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
  clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -7,10 +7,11 @@
 //===--===//
 
 #include "clang/CrossTU/CrossTranslationUnit.h"
-#include "clang/Frontend/CompilerInstance.h"
 #include "clang/AST/ASTConsumer.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/ToolOutputFile.h"
@@ -162,7 +163,7 @@
   IndexFile.os().flush();
   EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
   llvm::Expected> IndexOrErr =
-  parseCrossTUIndex(IndexFileName, "");
+  parseCrossTUIndex(IndexFileName);
   EXPECT_TRUE((bool)IndexOrErr);
   llvm::StringMap ParsedIndex = IndexOrErr.get();
   for (const auto &E : Index) {
@@ -173,25 +174,5 @@
 EXPECT_TRUE(Index.count(E.getKey()));
 }
 
-TEST(CrossTranslationUnit, CTUDirIsHandledCorrectly) {
-  llvm::StringMap Index;
-  Index["a"] = "/b/c/d";
-  std::string IndexText = createCrossTUIndexString(Index);
-
-  int IndexFD;
-  llvm::SmallString<256> IndexFileName;
-  ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("index", "txt", IndexFD,
-  IndexFileName));
-  llvm::ToolOutputFile IndexFile(IndexFileName, IndexFD);
-  IndexFile.os() << IndexText;
-  IndexFile.os().flush();
-  EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
-  llvm::Expected> IndexOrErr =
-  parseCrossTUIndex(IndexFileName, "/ctudir");
-  EXPECT_TRUE((bool)IndexOrErr);
-  llvm::StringMap ParsedIndex = IndexOrErr.get();
-  EXPECT_EQ(ParsedIndex["a"], "/ctudir/b/c/d");
-}
-
 } // end namespace cross_tu
 } // end namespace clang
Index: clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
===
--- clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
+++ clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
@@ -5,7 +5,7 @@
 // RUN: mkdir -p %t/ctudir
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
 // RUN:   -emit-pch -o %t/ctudir/ctu-other.cpp.ast %S/Inputs/ctu-other.cpp
-// RUN: cp %S/Inputs/ctu-other.cpp.externalDefMap.txt %t/ctudir/externalDefMap.txt
+// RUN: cp %S/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt %t/ctudir/externalDefMap.txt
 // RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu \
 // RUN:   -analyzer-checker=core,debug.ExprInspection \
 // RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
Index: clang/test/Analysis/ctu-on-demand-parsing.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-on-demand-parsing.cpp
@@ -0,0 +1,102 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/ctudir
+// RUN: cp %s %t/ctu-on-demand-parsing.cpp
+// RUN: cp %S/ctu-hdr.h %t/ctu-hdr.h
+// RUN: cp %S/Inputs/ctu-chain.cpp %t/ctudir/ctu-chain.cpp
+// RUN: cp %S/Inputs/ctu-other.cpp %t/ctudir/ctu-other.cpp
+// Path substitutions on Windows platform could contain backslashes. These are escaped in the json file.
+// RUN: echo '[{"directory":"%t/ctudir","command":"clang++ -c ctu-chain.cpp","file":"ctu-chain.cpp"},{"directory":"%t/ctudir","command":"clang++ -c ctu-other.cpp","file":"ctu-other.cpp"}]' | sed -e 's/\\//g' > %t/compile_commands.json
+// RUN: cd "%t/ctudir" && %clang_extdef_map ctu-chain.cpp ctu-other.cpp > externalDefMap.txt
+// RUN: cd "%t" && %clang_a

[clang] 62e747f - [analyzer] StdLibraryFunctionsChecker: Associate summaries to FunctionDecls

2020-04-28 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-04-28T10:00:50+02:00
New Revision: 62e747f6172942db0e9fd55a6a25f166f338459a

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

LOG: [analyzer] StdLibraryFunctionsChecker: Associate summaries to FunctionDecls

Summary:
Currently we map function summaries to names (i.e. strings). We can
associate more summaries with different signatures to one name, this way
we support overloading. During a call event we check whether the
signature of the summary matches the signature of the callee and we
apply the summary only in that case.

In this patch we change this mapping to associate a summary to a
FunctionDecl. We do lookup operations when the summary map is
initialized. We lookup the given name and we match the signature of the
given summary against the lookup results. If the summary matches the
FunctionDecl (got from the lookup result) then we add that to the
summary map. During a call event we compare FunctionDecl pointers.
Advantages of this new refactor:
- Cleaner mapping and structure for the checker.
- Possibly way more efficient handling of call events.
- A summary is added only if that is relevant for the given TU.
- We can get the concrete FunctionDecl by the time when we create the
  summary, this opens up possibilities of further sanity checks
  regarding the summary cases and argument constraints.
- Opens up to future work when we'd like to store summaries from IR to a
  FunctionDecl (or from the Attributor results of the given
  FunctionDecl).

Note, we cannot support old C functions without prototypes.

Reviewers: NoQ, Szelethus, balazske, jdoerfert, sstefan1, uenoku

Subscribers: whisperity, xazax.hun, baloghadamsoftware, szepet, rnkovacs, 
a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, gamesh411, Charusso, steakhal, 
uenoku, ASDenysPetrov, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 5e36938b613d..b9719a086668 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -266,21 +266,15 @@ class StdLibraryFunctionsChecker
   return T;
 }
 
-/// Try our best to figure out if the call expression is the call of
+/// Try our best to figure out if the summary's signature matches
 /// *the* library function to which this specification applies.
-bool matchesCall(const FunctionDecl *FD) const;
+bool matchesSignature(const FunctionDecl *FD) const;
   };
 
-  // The same function (as in, function identifier) may have 
diff erent
-  // summaries assigned to it, with 
diff erent argument and return value types.
-  // We call these "variants" of the function. This can be useful for handling
-  // C++ function overloads, and also it can be used when the same function
-  // may have 
diff erent definitions on 
diff erent platforms.
-  typedef std::vector Summaries;
-
   // The map of all functions supported by the checker. It is initialized
   // lazily, and it doesn't change after initialization.
-  mutable llvm::StringMap FunctionSummaryMap;
+  using FunctionSummaryMapType = llvm::DenseMap;
+  mutable FunctionSummaryMapType FunctionSummaryMap;
 
   mutable std::unique_ptr BT_InvalidArg;
 
@@ -289,14 +283,6 @@ class StdLibraryFunctionsChecker
   static QualType getArgType(const Summary &Summary, ArgNo ArgN) {
 return Summary.getArgType(ArgN);
   }
-  static QualType getArgType(const CallEvent &Call, ArgNo ArgN) {
-return ArgN == Ret ? Call.getResultType().getCanonicalType()
-   : Call.getArgExpr(ArgN)->getType().getCanonicalType();
-  }
-  static QualType getArgType(const CallExpr *CE, ArgNo ArgN) {
-return ArgN == Ret ? CE->getType().getCanonicalType()
-   : CE->getArg(ArgN)->getType().getCanonicalType();
-  }
   static SVal getArgSVal(const CallEvent &Call, ArgNo ArgN) {
 return ArgN == Ret ? Call.getReturnValue() : Call.getArgSVal(ArgN);
   }
@@ -440,7 +426,7 @@ ProgramStateRef 
StdLibraryFunctionsChecker::ComparisonConstraint::apply(
   BinaryOperator::Opcode Op = getOpcode();
   ArgNo OtherArg = getOtherArgNo();
   SVal OtherV = getArgSVal(Call, OtherArg);
-  QualType OtherT = getArgType(Call, OtherArg);
+  QualType OtherT = getArgType(Summary, OtherArg);
   // Note: we avoid integral promotion for comparison.
   OtherV = SVB.evalCast(OtherV, T, OtherT);
   if (auto CompV = SVB.evalBinOp(State, Op, V, OtherV, CondT)
@@ -530,7 +516,7 @@ bool StdLibraryFunctionsChecker::evalCall(const CallEven

[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> Yes, indeed very poorly. A C++ operator call is either implemented as 
> CXXOperatorCall or CXXMethodCall randomly. In the former case the this 
> parameter is explicit at the beginning, in the latter case it is implicit.

We have methods on `CallEvent` to handle this, namely 
`getAdjustedParameterIndex()` and `getASTArgumentIndex()`. They were added in 
D49443 .

> But this is not the only problem with indices. I have no solution for the 
> following call (is it really a call?) resulting in an assertion because 
> overindexing in `nullability.mm`:
> 
>   Dummy *_Nonnull (^myblock)(void) = ^Dummy *_Nonnull(void) {
> 
> 
> Even if I try to get the `FunctionDecl` it still says that it has `0` 
> parameters, exactly what `CallExpr` says, but we //have// a parameter here 
> with index of `0`. How can it be? How should I handle this strange case? I 
> only have very basic //Objective-C// knowledge.

These are blocks. They are like lambdas, just different syntax. They aren't 
part of Objective-C; they're a non-standard extension to C supported by both 
gcc and clang.

The line you quoted is not a call, it only defines a block and assigns it into 
a variable of block pointer type. Here's the full code of the test:

  358 void testNilReturnWithBlock(Dummy *p) {
  359   p = 0;
  360   Dummy *_Nonnull (^myblock)(void) = ^Dummy *_Nonnull(void) {
  361 return p; // TODO: We should warn in blocks.
  362   };
  363   myblock();
  364 }

The block is invoked on line 363. Parameter `p` of the surrounding function is 
accessible from the block because it was captured; it is not a parameter of the 
block itself.

> As far as I know, you have more than 10 years experience in the Analyzer. I 
> work on the analyzer for less than 5 years, and not full time, because I also 
> create Tidy checkers sometimes, I also have our internal stuff (most of which 
> I would like to upstream).

I started in mid-2014. I too am regularly distracted to stuff that isn't 
particularly educational about the analyzer.


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

https://reviews.llvm.org/D77229



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

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

Oh, it is not only //Objective-C//. I have been programming in //C// for 25+ 
years and teaching it for 15+ years, but I never met such syntactical 
construction:

  dispatch_sync(queue, ^(void){ 

Here it is worse than at the //Objective-C// code above, because the index is 
`1`, but the number of args is `0`. Thus this is an overindexing by 2. What are 
these strange constructions and how to get parameter type if they have no 
arguments? (Even if I get the function declaration from the stack frame, they 
have no parameters.) How can we have a parameter for them? How to handle them, 
how to return the type for a parameter that should not exist but it does?


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

https://reviews.llvm.org/D77229



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


[PATCH] D77641: [analyzer] StdLibraryFunctionsChecker: Associate summaries to FunctionDecls

2020-04-28 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG62e747f61729: [analyzer] StdLibraryFunctionsChecker: 
Associate summaries to FunctionDecls (authored by martong).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77641

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -266,21 +266,15 @@
   return T;
 }
 
-/// Try our best to figure out if the call expression is the call of
+/// Try our best to figure out if the summary's signature matches
 /// *the* library function to which this specification applies.
-bool matchesCall(const FunctionDecl *FD) const;
+bool matchesSignature(const FunctionDecl *FD) const;
   };
 
-  // The same function (as in, function identifier) may have different
-  // summaries assigned to it, with different argument and return value types.
-  // We call these "variants" of the function. This can be useful for handling
-  // C++ function overloads, and also it can be used when the same function
-  // may have different definitions on different platforms.
-  typedef std::vector Summaries;
-
   // The map of all functions supported by the checker. It is initialized
   // lazily, and it doesn't change after initialization.
-  mutable llvm::StringMap FunctionSummaryMap;
+  using FunctionSummaryMapType = llvm::DenseMap;
+  mutable FunctionSummaryMapType FunctionSummaryMap;
 
   mutable std::unique_ptr BT_InvalidArg;
 
@@ -289,14 +283,6 @@
   static QualType getArgType(const Summary &Summary, ArgNo ArgN) {
 return Summary.getArgType(ArgN);
   }
-  static QualType getArgType(const CallEvent &Call, ArgNo ArgN) {
-return ArgN == Ret ? Call.getResultType().getCanonicalType()
-   : Call.getArgExpr(ArgN)->getType().getCanonicalType();
-  }
-  static QualType getArgType(const CallExpr *CE, ArgNo ArgN) {
-return ArgN == Ret ? CE->getType().getCanonicalType()
-   : CE->getArg(ArgN)->getType().getCanonicalType();
-  }
   static SVal getArgSVal(const CallEvent &Call, ArgNo ArgN) {
 return ArgN == Ret ? Call.getReturnValue() : Call.getArgSVal(ArgN);
   }
@@ -440,7 +426,7 @@
   BinaryOperator::Opcode Op = getOpcode();
   ArgNo OtherArg = getOtherArgNo();
   SVal OtherV = getArgSVal(Call, OtherArg);
-  QualType OtherT = getArgType(Call, OtherArg);
+  QualType OtherT = getArgType(Summary, OtherArg);
   // Note: we avoid integral promotion for comparison.
   OtherV = SVB.evalCast(OtherV, T, OtherT);
   if (auto CompV = SVB.evalBinOp(State, Op, V, OtherV, CondT)
@@ -530,7 +516,7 @@
   llvm_unreachable("Unknown invalidation kind!");
 }
 
-bool StdLibraryFunctionsChecker::Summary::matchesCall(
+bool StdLibraryFunctionsChecker::Summary::matchesSignature(
 const FunctionDecl *FD) const {
   // Check number of arguments:
   if (FD->param_size() != ArgTys.size())
@@ -565,28 +551,10 @@
 
   initFunctionSummaries(C);
 
-  IdentifierInfo *II = FD->getIdentifier();
-  if (!II)
-return None;
-  StringRef Name = II->getName();
-  if (Name.empty() || !C.isCLibraryFunction(FD, Name))
-return None;
-
-  auto FSMI = FunctionSummaryMap.find(Name);
+  auto FSMI = FunctionSummaryMap.find(FD->getCanonicalDecl());
   if (FSMI == FunctionSummaryMap.end())
 return None;
-
-  // Verify that function signature matches the spec in advance.
-  // Otherwise we might be modeling the wrong function.
-  // Strict checking is important because we will be conducting
-  // very integral-type-sensitive operations on arguments and
-  // return values.
-  const Summaries &SpecVariants = FSMI->second;
-  for (const Summary &Spec : SpecVariants)
-if (Spec.matchesCall(FD))
-  return Spec;
-
-  return None;
+  return FSMI->second;
 }
 
 Optional
@@ -598,6 +566,21 @@
   return findFunctionSummary(FD, C);
 }
 
+llvm::Optional
+lookupGlobalCFunction(StringRef Name, const ASTContext &ACtx) {
+  IdentifierInfo &II = ACtx.Idents.get(Name);
+  auto LookupRes = ACtx.getTranslationUnitDecl()->lookup(&II);
+  if (LookupRes.size() == 0)
+return None;
+
+  assert(LookupRes.size() == 1 && "In C, identifiers should be unique");
+  Decl *D = LookupRes.front()->getCanonicalDecl();
+  auto *FD = dyn_cast(D);
+  if (!FD)
+return None;
+  return FD->getCanonicalDecl();
+}
+
 void StdLibraryFunctionsChecker::initFunctionSummaries(
 CheckerContext &C) const {
   if (!FunctionSummaryMap.empty())
@@ -652,6 +635,38 @@
 return -1;
   }();
 
+  // Auxiliary class to aid adding summaries to the summary map.
+  struct AddToFunctionSummaryMap {
+const ASTContext &ACtx;
+FunctionSummaryMapType ⤅
+AddToFunctionSummaryMap(

[clang] f03b505 - Revert f8990feb125a "[libclang] Install both libclang.a and libclang.so when LIBCLANG_BUILD_STATIC=ON"

2020-04-28 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-04-28T10:10:33+02:00
New Revision: f03b505ee7f23018493b93e3828fc3672c6f903c

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

LOG: Revert f8990feb125a "[libclang] Install both libclang.a and libclang.so 
when LIBCLANG_BUILD_STATIC=ON"

This broke builds configured with

$ cmake -GNinja -DCMAKE_BUILD_TYPE=Release '-DLLVM_ENABLE_PROJECTS=clang' 
'-DLLVM_TARGETS_TO_BUILD=X86' -DLLVM_ENABLE_PIC=OFF ../llvm

CMake Error at
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/tools/libclang/CMakeLists.txt:123
(target_compile_definitions):
target_compile_definitions called with non-compilable target type

This reverts commit f8990feb125a0f8d3f2892a589bc6fad3c430858.

Added: 


Modified: 
clang/cmake/modules/AddClang.cmake

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index d68218eed073..c1bb386de6f7 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -99,40 +99,38 @@ macro(add_clang_library name)
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
-  foreach(lib ${name} ${name}_static)
-if(TARGET ${lib})
-  target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS})
-
-  if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
-set(export_to_clangtargets)
-if(${lib} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
-"clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
-NOT LLVM_DISTRIBUTION_COMPONENTS)
-  set(export_to_clangtargets EXPORT ClangTargets)
-  set_property(GLOBAL PROPERTY CLANG_HAS_EXPORTS True)
-endif()
-
-install(TARGETS ${lib}
-  COMPONENT ${lib}
-  ${export_to_clangtargets}
-  LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-  ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-  RUNTIME DESTINATION bin)
-
-if (NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-${lib}
-   DEPENDS ${lib}
-   COMPONENT ${lib})
-endif()
-
-set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${lib})
+  if(TARGET ${name})
+target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
+
+if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
+  set(export_to_clangtargets)
+  if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
+  "clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
+  NOT LLVM_DISTRIBUTION_COMPONENTS)
+set(export_to_clangtargets EXPORT ClangTargets)
+set_property(GLOBAL PROPERTY CLANG_HAS_EXPORTS True)
   endif()
-  set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${lib})
-else()
-  # Add empty "phony" target
-  add_custom_target(${lib})
+
+  install(TARGETS ${name}
+COMPONENT ${name}
+${export_to_clangtargets}
+LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+RUNTIME DESTINATION bin)
+
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-${name}
+ DEPENDS ${name}
+ COMPONENT ${name})
+  endif()
+
+  set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name})
 endif()
-  endforeach()
+set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
+  else()
+# Add empty "phony" target
+add_custom_target(${name})
+  endif()
 
   set_target_properties(${name} PROPERTIES FOLDER "Clang libraries")
   set_clang_windows_version_resource_properties(${name})



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

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

In D77229#2007125 , @NoQ wrote:

> > Yes, indeed very poorly. A C++ operator call is either implemented as 
> > CXXOperatorCall or CXXMethodCall randomly. In the former case the this 
> > parameter is explicit at the beginning, in the latter case it is implicit.
>
> We have methods on `CallEvent` to handle this, namely 
> `getAdjustedParameterIndex()` and `getASTArgumentIndex()`. They were added in 
> D49443 .


Unfortunately, in `ExprEngine::VisitCommonDeclRefExpr` we do not have 
`CallEvent`, only `CallExpr`.

> These are blocks. They are like lambdas, just different syntax. They aren't 
> part of Objective-C; they're a non-standard extension to C supported by both 
> gcc and clang.
> 
> The line you quoted is not a call, it only defines a block and assigns it 
> into a variable of block pointer type. Here's the full code of the test:
> 
>   358 void testNilReturnWithBlock(Dummy *p) {
>   359   p = 0;
>   360   Dummy *_Nonnull (^myblock)(void) = ^Dummy *_Nonnull(void) {
>   361 return p; // TODO: We should warn in blocks.
>   362   };
>   363   myblock();
>   364 }
>
> 
> The block is invoked on line 363. Parameter `p` of the surrounding function 
> is accessible from the block because it was captured; it is not a parameter 
> of the block itself.

Sorry, all my studies were about standard things only. Everything else was 
banned. This is the philosophy of my university, it seems.

What do you suggest, how to retrieve the type for them? We stored the 
`CallExpr` as `OriginExpr` for the region. Should we store something else in 
case of blocks, or should we handle this in `getType()`? How to distinguish 
parameters of the block from the captured parameters of the function? This case 
sounds very complicated to handle.


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

https://reviews.llvm.org/D77229



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


[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Before looking into the merit of the change, it needs a couple of things

- This needs unit tests in clang/unittests/Format to demonstrate the problem 
and test this fixing it
- This also needs the ClangStyleOptions.rst file generated with the 
clang/tools/dump_style.py
- We should add a release note too


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

https://reviews.llvm.org/D78982



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


[PATCH] D77641: [analyzer] StdLibraryFunctionsChecker: Associate summaries to FunctionDecls

2020-04-28 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D77641#2004273 , @Szelethus wrote:

> I think you can go ahead and commit. You seem to have a firm grasp on this 
> project, I believe your experience with ASTImporter has more then prepared 
> you for digging functions out of the `std` namespace, or whatever else that 
> might come up :^)


Alright, thanks, just did the commit. Let me know guys if you find anything 
else and I'll address the concerns. Also, if there is any regression I'll do 
the revert, just leave a note here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77641



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

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



Comment at: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp:601-603
+if (LCtx->getAnalysis()->isLive(Loc,
+  PR->getOriginExpr()))
+  return true;

NoQ wrote:
> > I implemented the basic `isLive()` and `getBinding()` functions which 
> > reduced the number of failing tests by `0`.
> 
> This line in particular is very incorrect. In fact, most of the time the 
> result will be `false`.
OK, but what should I check for liveness here? We do not have a `Decl`. We 
could retrieve the `Expr` for the `Arg`, except for `CXXNewOperator` because 
there the size argument cannot be retrieved.


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

https://reviews.llvm.org/D77229



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


[PATCH] D78534: [libclang] Install both libclang.a and libclang.so when LIBCLANG_BUILD_STATIC=ON

2020-04-28 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

This broke builds configured with -DLLVM_ENABLE_PIC=OFF, e.g.

$ cmake -GNinja -DCMAKE_BUILD_TYPE=Release '-DLLVM_ENABLE_PROJECTS=clang' 
'-DLLVM_TARGETS_TO_BUILD=X86' -DLLVM_ENABLE_PIC=OFF ../llvm

 
  CMake Error at 
  
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/tools/libclang/CMakeLists.txt:123
  (target_compile_definitions):  
  target_compile_definitions called with non-compilable target type

I've reverted in f03b505ee7f23018493b93e3828fc3672c6f903c 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78534



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


[PATCH] D78985: [clang-tidy] NFC: Cleanup Python scripts

2020-04-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: hokein.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Silence few PEP8 warnings.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78985

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -1,14 +1,15 @@
 #!/usr/bin/env python
 #
-#===- run-clang-tidy.py - Parallel clang-tidy runner -*- python -*--===#
+#===- run-clang-tidy.py - Parallel clang-tidy runner *- python -*--===#
 #
 # 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
 #
-#======#
+#===---===#
 # FIXME: Integrate with clang-tidy-diff.py
 
+
 """
 Parallel clang-tidy runner
 ==
@@ -60,6 +61,7 @@
 else:
 import queue as queue
 
+
 def find_compilation_database(path):
   """Adjusts the directory until a compilation database is found."""
   result = './'
@@ -112,7 +114,7 @@
   """Merge all replacement files in a directory into a single file"""
   # The fixes suggested by clang-tidy >= 4.0.0 are given under
   # the top level key 'Diagnostics' in the output yaml files
-  mergekey="Diagnostics"
+  mergekey = "Diagnostics"
   merged=[]
   for replacefile in glob.iglob(os.path.join(tmpdir, '*.yaml')):
 content = yaml.safe_load(open(replacefile, 'r'))
@@ -125,7 +127,7 @@
 # include/clang/Tooling/ReplacementsYaml.h, but the value
 # is actually never used inside clang-apply-replacements,
 # so we set it to '' here.
-output = { 'MainSourceFile': '', mergekey: merged }
+output = {'MainSourceFile': '', mergekey: merged}
 with open(mergefile, 'w') as out:
   yaml.safe_dump(output, out)
   else:
@@ -324,11 +326,12 @@
 except:
   print('Error applying fixes.\n', file=sys.stderr)
   traceback.print_exc()
-  return_code=1
+  return_code = 1
 
   if tmpdir:
 shutil.rmtree(tmpdir)
   sys.exit(return_code)
 
+
 if __name__ == '__main__':
   main()
Index: clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -1,12 +1,12 @@
 #!/usr/bin/env python
 #
-#===- clang-tidy-diff.py - ClangTidy Diff Checker *- python -*--===#
+#===- clang-tidy-diff.py - ClangTidy Diff Checker ---*- python -*--===#
 #
 # 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
 #
-#======#
+#===---===#
 
 r"""
 ClangTidy Diff Checker
@@ -75,7 +75,7 @@
 sys.stderr.write('Failed: ' + str(e) + ': '.join(command) + '\n')
 finally:
   with lock:
-if (not timeout is None) and (not watchdog is None):
+if not (timeout is None or watchdog is None):
   if not watchdog.is_alive():
   sys.stderr.write('Terminated by timeout: ' +
' '.join(command) + '\n')
@@ -89,6 +89,7 @@
 t.daemon = True
 t.start()
 
+
 def merge_replacement_files(tmpdir, mergefile):
   """Merge all replacement files in a directory into a single file"""
   # The fixes suggested by clang-tidy >= 4.0.0 are given under
@@ -106,7 +107,7 @@
 # include/clang/Tooling/ReplacementsYaml.h, but the value
 # is actually never used inside clang-apply-replacements,
 # so we set it to '' here.
-output = { 'MainSourceFile': '', mergekey: merged }
+output = {'MainSourceFile': '', mergekey: merged}
 with open(mergefile, 'w') as out:
   yaml.safe_dump(output, out)
   else:
Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -1,12 +1,12 @@
 #!/usr/bin/env python
 #
-#===- rename_check.py - clang-tidy check renamer -*- python -*--===#
+#===- rename_check.py - clang-tidy check renamer *- python -*--===#
 #
 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 # Se

[PATCH] D75453: [Driver][ARM] fix undefined behaviour when checking architecture version

2020-04-28 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added a comment.

Please update the title and the summary because those will be the commit 
message.
IMHO the test a case would be extended with a test where the body of the 
modified if condition is tested.
Otherwise LGTM.


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

https://reviews.llvm.org/D75453



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


[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I think the name should be `AllowShortEnumsOnASingleLine`

As once the enum goes over a certain width it will revert to as it was before.

  enum { EOF, VOID, CHAR, SHORT, DOT, NUMBER, IDENTIFIER } A;

vs

  enum {
EOF,
VOID,
CHAR,
SHORT,
INT,
LONG,
SIGNED,
UNSIGNED,
BOOL,
FLOAT,
DOUBLE,
COMPLEX,
CONST,
RESTRICT,
VOLATILE,
ATOMIC,
STRUCT,
UNION,
ENUM,
LPAREN,
RPAREN,
LBRACKET,
RBRACKET,
ASTERISK,
DOT,
NUMBER,
IDENTIFIER
  } A;




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

https://reviews.llvm.org/D78982



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


[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

So it doesn't overcome the trailing "," issue. (which is sometimes used to put 
enums on multiple lines)  - (NOTE: maybe it shouldn't)

  ---
  Language: Cpp
  BasedOnStyle: LLVM
  AllowEnumsOnASingleLine: true



  enum
  {
B,
C,
D,
  } A, B;

vs

  enum { B, C, D } A, B;


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

https://reviews.llvm.org/D78982



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


[PATCH] D78985: [clang-tidy] NFC: Cleanup Python scripts

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

thanks for cleaning up.




Comment at: clang-tools-extra/clang-tidy/add_new_check.py:1
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #

we should keep using `python` I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78985



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


[PATCH] D78879: [clang-format] [PR45357] Fix issue found with operator spacing

2020-04-28 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

In D78879#2004856 , @MyDeveloperDay 
wrote:

> @sylvestre.ledru , @Abpostelnicu
>
> I believe to fix your original request you need a combination of D76850: 
> clang-format: Fix pointer alignment for overloaded operators (PR45107) 
>  and this fix (this fix will handle the `* 
> *` issue in `gecko-dev/ipc/mscom/Ptr.h`
>
> I've run this  new binary over `gecko-dev/ipc/mscom` and `gecko-dev/xpcom/ds` 
> and it shows no clang-format warnings
>
> I hope this helps


Yes, definitely you are right D76850 , only 
partially fixes the issue introduced by D69573 
, and your fix it's a good add-on in order to 
have a complete fix for the regression.


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

https://reviews.llvm.org/D78879



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


[PATCH] D78879: [clang-format] [PR45357] Fix issue found with operator spacing

2020-04-28 Thread Andi via Phabricator via cfe-commits
Abpostelnicu added a comment.

Just to clarify something here, for me the patch looks good but until I will 
accept the revision I want to test it on the mozilla codebase.


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

https://reviews.llvm.org/D78879



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


[PATCH] D78982: [clang-format] Fix Microsoft style for enums

2020-04-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/Format.cpp:1143
   Style.PenaltyReturnTypeOnItsOwnLine = 1000;
+  Style.AllowEnumsOnASingleLine = false;
   Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;

You'll need to fix up the C# tests

```
C:/llvm-project/clang/unittests/Format/FormatTestCSharp.cpp(48): error:   
Expected: Code.str()
  Which is: "public enum var { none, @string, bool, @enum }"
To be equal to: format(Code, Style)
  Which is: "public enum var\n{\nnone,\n@string,\nbool,\n
@enum\n}"
With diff:
@@ -1,1 +1,7 @@
-public enum var { none, @string, bool, @enum }
+public enum var
+{
+none,
+@string,
+bool,
+@enum
+}
```

I think that is ok as most of the documentation seems to show them not on a 
single line

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/enum




Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1768
+  if (!Style.AllowEnumsOnASingleLine)
+addUnwrappedLine();
   nextToken();

see below, I think you need to know this braced Initialization is part of a enum



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1829
+addUnwrappedLine();
   break;
 default:

I'm wondering if this is going to impact other braced constructs?

```
void main()
{
std::vector list = { 1,2,3};
}
```

becomes

```
void main() {
  std::vector list = {1,
  2,
  3
  };
}
```




Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2295
+  }
   bool HasError = !parseBracedList(/*ContinueOnSemicolons=*/true);
+  if (!Style.AllowEnumsOnASingleLine)

I think you are going to have to pass down that this BracedList is for a enum 
only


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

https://reviews.llvm.org/D78982



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


[PATCH] D78990: [analyzer] Allow bindings of the CompoundLiteralRegion

2020-04-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, Charusso, 
dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a project: clang.

CompoundLiteralRegions have been properly modeled before, but
'getBindingForElement` was not changed to accommodate this change
properly.

rdar://problem/46144644


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78990

Files:
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/test/Analysis/compound-literals.c
  clang/test/Analysis/retain-release-compound-literal.m
  clang/unittests/StaticAnalyzer/StoreTest.cpp

Index: clang/unittests/StaticAnalyzer/StoreTest.cpp
===
--- clang/unittests/StaticAnalyzer/StoreTest.cpp
+++ clang/unittests/StaticAnalyzer/StoreTest.cpp
@@ -15,89 +15,146 @@
 namespace ento {
 namespace {
 
+class StoreTestConsumer : public ExprEngineConsumer {
+public:
+  StoreTestConsumer(CompilerInstance &C) : ExprEngineConsumer(C) {}
+
+  struct TestContext {
+StoreManager &SManager;
+SValBuilder &Builder;
+MemRegionManager &MRManager;
+ASTContext &ASTContext;
+
+/* implicit */ TestContext(ExprEngine &Engine)
+: SManager(Engine.getStoreManager()), Builder(Engine.getSValBuilder()),
+  MRManager(SManager.getRegionManager()),
+  ASTContext(Engine.getContext()) {}
+  };
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (const auto *D : DG)
+  performTest(Eng, D);
+return true;
+  }
+
+private:
+  virtual void performTest(TestContext Context, const Decl *D) = 0;
+};
+
+template  class TestAction : public ASTFrontendAction {
+public:
+  std::unique_ptr CreateASTConsumer(CompilerInstance &Compiler,
+ StringRef File) override {
+return std::make_unique(Compiler);
+  }
+};
+
 // Test that we can put a value into an int-type variable and load it
 // back from that variable. Test what happens if default bindings are used.
-class VariableBindConsumer : public ExprEngineConsumer {
-  void performTest(const Decl *D) {
-StoreManager &StMgr = Eng.getStoreManager();
-SValBuilder &SVB = Eng.getSValBuilder();
-MemRegionManager &MRMgr = StMgr.getRegionManager();
-const ASTContext &ACtx = Eng.getContext();
-
+class VariableBindConsumer : public StoreTestConsumer {
+  void performTest(TestContext Ctxt, const Decl *D) {
 const auto *VDX0 = findDeclByName(D, "x0");
 const auto *VDY0 = findDeclByName(D, "y0");
 const auto *VDZ0 = findDeclByName(D, "z0");
 const auto *VDX1 = findDeclByName(D, "x1");
 const auto *VDY1 = findDeclByName(D, "y1");
-assert(VDX0 && VDY0 && VDZ0 && VDX1 && VDY1);
+
+ASSERT_TRUE(VDX0 && VDY0 && VDZ0 && VDX1 && VDY1);
 
 const StackFrameContext *SFC =
 Eng.getAnalysisDeclContextManager().getStackFrame(D);
 
-Loc LX0 = loc::MemRegionVal(MRMgr.getVarRegion(VDX0, SFC));
-Loc LY0 = loc::MemRegionVal(MRMgr.getVarRegion(VDY0, SFC));
-Loc LZ0 = loc::MemRegionVal(MRMgr.getVarRegion(VDZ0, SFC));
-Loc LX1 = loc::MemRegionVal(MRMgr.getVarRegion(VDX1, SFC));
-Loc LY1 = loc::MemRegionVal(MRMgr.getVarRegion(VDY1, SFC));
+Loc LX0 = loc::MemRegionVal(Ctxt.MRManager.getVarRegion(VDX0, SFC));
+Loc LY0 = loc::MemRegionVal(Ctxt.MRManager.getVarRegion(VDY0, SFC));
+Loc LZ0 = loc::MemRegionVal(Ctxt.MRManager.getVarRegion(VDZ0, SFC));
+Loc LX1 = loc::MemRegionVal(Ctxt.MRManager.getVarRegion(VDX1, SFC));
+Loc LY1 = loc::MemRegionVal(Ctxt.MRManager.getVarRegion(VDY1, SFC));
 
-Store StInit = StMgr.getInitialStore(SFC).getStore();
-SVal Zero = SVB.makeZeroVal(ACtx.IntTy);
-SVal One = SVB.makeIntVal(1, ACtx.IntTy);
-SVal NarrowZero = SVB.makeZeroVal(ACtx.CharTy);
+Store StInit = Ctxt.SManager.getInitialStore(SFC).getStore();
+SVal Zero = Ctxt.Builder.makeZeroVal(Ctxt.ASTContext.IntTy);
+SVal One = Ctxt.Builder.makeIntVal(1, Ctxt.ASTContext.IntTy);
+SVal NarrowZero = Ctxt.Builder.makeZeroVal(Ctxt.ASTContext.CharTy);
 
 // Bind(Zero)
-Store StX0 =
-StMgr.Bind(StInit, LX0, Zero).getStore();
-ASSERT_EQ(Zero, StMgr.getBinding(StX0, LX0, ACtx.IntTy));
+Store StX0 = Ctxt.SManager.Bind(StInit, LX0, Zero).getStore();
+EXPECT_EQ(Zero, Ctxt.SManager.getBinding(StX0, LX0, Ctxt.ASTContext.IntTy));
 
 // BindDefaultInitial(Zero)
 Store StY0 =
-StMgr.BindDefaultInitial(StInit, LY0.getAsRegion(), Zero).getStore();
-ASSERT_EQ(Zero, StMgr.getBinding(StY0, LY0, ACtx.IntTy));
-ASSERT_EQ(Zero, *StMgr.getDefaultBinding(StY0, LY0.getAsRegion()));
+Ctxt.SManager.BindDefaultInitial(StInit, LY0.getAsRegion(), Zero)
+.getStore();
+EXPECT_EQ(Zero, Ctxt.SManager.getBinding(StY0, LY0, Ctxt.ASTContext.IntTy));
+EXPECT_EQ(Zero, *Ctxt.SManager.getDefaultBinding(StY0, LY

[PATCH] D78777: [AST] Use PrintingPolicy for format string diagnosis

2020-04-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78777



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


[PATCH] D77378: [Clang] Include size and maximum in vector size error message.

2020-04-28 Thread Florian Hahn via Phabricator via cfe-commits
fhahn abandoned this revision.
fhahn added a comment.

With the recent size increase for vector dimensions I am not sure this is too 
useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77378



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


[PATCH] D78979: OpenCL: Include builtin header by default

2020-04-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a subscriber: svenvh.
Anastasia added a comment.

> I'm somewhat confused by the way this is supposed to work, or why a
>  separate option exists for OpenCL. The other language flags seem to be
>  implemented in the driver, not cc1 like OpenCL. I'm not sure this is
>  the right set of flag naming decisions, or if we really need the
>  fno-include-default-header cc1 flag.

Originally we didn't want to include the header by default for 2 reasons:

1. Many vendors used their own header.
2. It takes long time to parse the header.

However, we might be in a different position now because the header exists for 
long time and I think we have fixed all the issues so it should be recommended 
to use it instead of vendor's header. It is generally good to include it by 
default for the upstream user. However, I am still concerned with the parsing 
time. To mitigate this we have developed an alternative way to include the 
functions utilizing TableGen:
https://llvm.org/devmtg/2019-10/talk-abstracts.html#lit5
Unfortunately, we are not that far with testing yet to be able to use it by 
default. But hopefully we should be able to switch to is as a default option at 
some point soon.

To summarize I am generally not against the inclusion of the header by default 
and I think it's best if we just reuse the standard non-OpenCL specific flags. 
We would just need to understand how it will work with the fast TableGen-based 
solution that is enabled using `-fdeclare-opencl-builtins`. I am looping in 
@svenvh to discuss this further. Sven, do you think we should rename this flag 
due to current proposed change? Should it be moved out of `-cc1` too?


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

https://reviews.llvm.org/D78979



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


[PATCH] D78286: [analyzer] Track runtime types represented by Obj-C Class objects

2020-04-28 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 260580.
vsavchenko added a comment.

Move getSelfSVal from CallEvent to ProgramState


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78286

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicType.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeInfo.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
  clang/lib/StaticAnalyzer/Checkers/ObjCSuperDeallocChecker.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/DynamicType.cpp
  clang/lib/StaticAnalyzer/Core/ProgramState.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/class-object-state-dump.m
  clang/test/Analysis/inlining/InlineObjCClassMethod.m
  clang/test/Analysis/inlining/ObjCDynTypePopagation.m
  clang/test/Analysis/retain-release-inline.m

Index: clang/test/Analysis/retain-release-inline.m
===
--- clang/test/Analysis/retain-release-inline.m
+++ clang/test/Analysis/retain-release-inline.m
@@ -13,6 +13,7 @@
 // It includes the basic definitions for the test cases below.
 //===--===//
 #define NULL 0
+#define nil ((id)0)
 typedef unsigned int __darwin_natural_t;
 typedef unsigned long uintptr_t;
 typedef unsigned int uint32_t;
@@ -21,14 +22,14 @@
 typedef signed long CFIndex;
 typedef CFIndex CFByteOrder;
 typedef struct {
-CFIndex location;
-CFIndex length;
+  CFIndex location;
+  CFIndex length;
 } CFRange;
 static __inline__ __attribute__((always_inline)) CFRange CFRangeMake(CFIndex loc, CFIndex len) {
-CFRange range;
-range.location = loc;
-range.length = len;
-return range;
+  CFRange range;
+  range.location = loc;
+  range.length = len;
+  return range;
 }
 typedef const void * CFTypeRef;
 typedef const struct __CFString * CFStringRef;
@@ -91,6 +92,7 @@
 - (BOOL)isEqual:(id)object;
 - (id)retain;
 - (oneway void)release;
+- (Class)class;
 - (id)autorelease;
 - (id)init;
 @end  @protocol NSCopying  - (id)copyWithZone:(NSZone *)zone;
@@ -100,6 +102,7 @@
 @interface NSObject  {}
 + (id)allocWithZone:(NSZone *)zone;
 + (id)alloc;
++ (Class)class;
 - (void)dealloc;
 @end
 @interface NSObject (NSCoderMethods)
@@ -481,3 +484,33 @@
   [self test_inline_tiny_when_reanalyzing];
 }
 @end
+
+// Original problem: rdar://problem/50739539
+@interface MyClassThatLeaksDuringInit : NSObject
+
++ (MyClassThatLeaksDuringInit *)getAnInstance1;
++ (MyClassThatLeaksDuringInit *)getAnInstance2;
+
+@end
+
+@implementation MyClassThatLeaksDuringInit
+
++ (MyClassThatLeaksDuringInit *)getAnInstance1 {
+  return [[[MyClassThatLeaksDuringInit alloc] init] autorelease]; // expected-warning{{leak}}
+}
+
++ (MyClassThatLeaksDuringInit *)getAnInstance2 {
+  return self class] alloc] init] autorelease]; // expected-warning{{leak}}
+}
+
+- (instancetype)init {
+  if (1) {
+return nil;
+  }
+
+  if (nil != (self = [super init])) {
+  }
+  return self;
+}
+
+@end
Index: clang/test/Analysis/inlining/ObjCDynTypePopagation.m
===
--- clang/test/Analysis/inlining/ObjCDynTypePopagation.m
+++ clang/test/Analysis/inlining/ObjCDynTypePopagation.m
@@ -7,68 +7,67 @@
 PublicSubClass2 *getObj();
 
 @implementation PublicParent
-- (int) getZeroOverridden {
-   return 1;
+- (int)getZeroOverridden {
+  return 1;
 }
-- (int) getZero {
-   return 0;
+- (int)getZero {
+  return 0;
 }
 @end
 
 @implementation PublicSubClass2
-- (int) getZeroOverridden {
-   return 0;
+- (int)getZeroOverridden {
+  return 0;
 }
 
 /* Test that we get the right type from call to alloc. */
-+ (void) testAllocSelf {
++ (void)testAllocSelf {
   id a = [self alloc];
   clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}}
 }
 
-
-+ (void) testAllocClass {
++ (void)testAllocClass {
   id a = [PublicSubClass2 alloc];
   clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}}
 }
 
-+ (void) testAllocSuperOverriden {
++ (void)testAllocSuperOverriden {
   id a = [super alloc];
   // Evaluates to 1 in the parent.
-  clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{FALSE}} 
+  clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{FALSE}}
 }
 
-+ (void) testAllocSuper {
++ (void)testAllocSuper {
   id a = [super alloc];
   clang_analyzer_eval([a getZero] == 0); // expected-warning{{TRUE}}
 }
 
-+ (void) testAllocInit {
++ (void)testAllocInit {
   id a = [[self alloc] init];
   clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}}
 }
 
-+ (void) testNewSelf {
++ (void)testNewSelf {
   

[PATCH] D78882: [IR] Replace all uses of CallBase::getCalledValue() with getCalledOperand().

2020-04-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.

Looks great - thanks for the pointer type fixup(s) along the way too!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78882



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


[PATCH] D78882: [IR] Replace all uses of CallBase::getCalledValue() with getCalledOperand().

2020-04-28 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa58b62b4a2b9: [IR] Replace all uses of 
CallBase::getCalledValue() with getCalledOperand(). (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78882

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  lldb/source/Expression/IRInterpreter.cpp
  lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp
  lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/CodeGen/FastISel.h
  llvm/include/llvm/IR/AbstractCallSite.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/Analysis/AliasAnalysisEvaluator.cpp
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/Lint.cpp
  llvm/lib/Analysis/MemorySSA.cpp
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Analysis/StackSafetyAnalysis.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp
  llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/CodeGen/WasmEHPrepare.cpp
  llvm/lib/CodeGen/WinEHPrepare.cpp
  llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64PromoteConstant.cpp
  llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp
  llvm/lib/Target/AMDGPU/AMDGPUFixFunctionBitcasts.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/ARM/ARMFastISel.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86WinEHState.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/IPO/CalledValuePropagation.cpp
  llvm/lib/Transforms/IPO/GlobalOpt.cpp
  llvm/lib/Transforms/IPO/PruneEH.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/lib/Transforms/Instrumentation/ValueProfilePlugins.inc
  llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
  llvm/lib/Transforms/Utils/CallPromotionUtils.cpp
  llvm/lib/Transforms/Utils/Evaluator.cpp
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/lib/Transforms/Utils/LowerInvoke.cpp
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp
  llvm/test/LTO/X86/type-mapping-bug3.ll
  llvm/tools/llvm-diff/DiffConsumer.cpp
  llvm/tools/llvm-diff/DifferenceEngine.cpp
  mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp

Index: mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
===
--- mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -720,7 +720,7 @@
   op = b.create(loc, tys, b.getSymbolRefAttr(callee->getName()),
 ops);
 } else {
-  Value calledValue = processValue(ci->getCalledValue());
+  Value calledValue = processValue(ci->getCalledOperand());
   if (!calledValue)
 return failure();
   ops.insert(ops.begin(), calledValue);
@@ -766,7 +766,7 @@
   ops, blocks[ii->getNormalDest()], normalArgs,
   blocks[ii->getUnwindDest()], unwindArgs);
 } else {
-  ops.insert(ops.begin(), processValue(ii->getCalledValue()));
+  ops.insert(ops.begin(), processValue(ii->getCalledOperand()));
   op = b.create(loc, tys, ops, blocks[ii->getNormalDest()],
   normalArgs, blocks[ii->getUnwindDest()],
   unwindArgs);
Index: llvm/tools/llvm-diff/DifferenceEngine.cpp
===
--- llvm/tools/llvm-diff/DifferenceEngine.cpp
+++ llvm/tools/llvm-diff/DifferenceEngine.cpp
@@ -224,7 +224,7 @@
 
   bool diffCallSites(CallBase &L, CallBase &R, bool Compl

[PATCH] D77923: OpenCL: Fix some missing predefined macros

2020-04-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The current solution seems very specific and doesn't provide generic uniform 
mechanisms for the targets. Would something based on a triple component not 
work?


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

https://reviews.llvm.org/D77923



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


[PATCH] D78694: [clang-format] Fix lambda with ellipsis in return type

2020-04-28 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

Thank you!

I think this is OK as-is.


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

https://reviews.llvm.org/D78694



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


[clang] fe667e8 - [OpenCL] Fixed test for the cast operators.

2020-04-28 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2020-04-28T12:46:36+01:00
New Revision: fe667e8522a6be5f73b2aed1adf4ec92d0470695

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

LOG: [OpenCL] Fixed test for the cast operators.

The test had unused variable because it missed to cover
case with __constant address space. This change now
completes the testing fully.

Added: 


Modified: 
clang/test/SemaOpenCLCXX/address-space-castoperators.cl

Removed: 




diff  --git a/clang/test/SemaOpenCLCXX/address-space-castoperators.cl 
b/clang/test/SemaOpenCLCXX/address-space-castoperators.cl
index d61a9a72573c..7fd7f728fda3 100644
--- a/clang/test/SemaOpenCLCXX/address-space-castoperators.cl
+++ b/clang/test/SemaOpenCLCXX/address-space-castoperators.cl
@@ -9,4 +9,9 @@ void nester_ptr() {
   gengen = static_cast(locgen); //expected-error{{static_cast from 
'__local int *__generic *' to '__generic int *__generic *' is not allowed}}
 // CHECK-NOT: AddressSpaceConversion
   gengen = reinterpret_cast(locgen); 
//expected-warning{{reinterpret_cast from '__local int *__generic *' to 
'__generic int *__generic *' changes address space of nested pointers}}
+
+  gengen = const_cast(congen); //expected-error{{const_cast from 
'__constant int *__generic *' to '__generic int *__generic *' is not allowed}}
+  gengen = static_cast(congen); //expected-error{{static_cast from 
'__constant int *__generic *' to '__generic int *__generic *' is not allowed}}
+// CHECK-NOT: AddressSpaceConversion
+  gengen = reinterpret_cast(congen); 
//expected-warning{{reinterpret_cast from '__constant int *__generic *' to 
'__generic int *__generic *' changes address space of nested pointers}}
 }



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


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

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

@aganea: This change reverts only a small part of my previous change (see my 
comment here from Feb 23). Hans reverted the original change only until this 
problem gets sorted out (see his comment from Feb 27 right before the revert).


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D78979: OpenCL: Include builtin header by default

2020-04-28 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

In D78979#2007356 , @Anastasia wrote:

> Originally we didn't want to include the header by default for 2 reasons:
>
> 1. Many vendors used their own header.
> 2. It takes long time to parse the header.
>
>   However, we might be in a different position now because the header exists 
> for long time and I think we have fixed all the issues so it should be 
> recommended to use it instead of vendor's header. It is generally good to 
> include it by default for the upstream user. However, I am still concerned 
> with the parsing time. To mitigate this we have developed an alternative way 
> to include the functions utilizing TableGen: 
> https://llvm.org/devmtg/2019-10/talk-abstracts.html#lit5 Unfortunately, we 
> are not that far with testing yet to be able to use it by default. But 
> hopefully we should be able to switch to is as a default option at some point 
> soon.


The main thing that's missing from the TableGen approach is support for 
builtins taking enum arguments, and then there is completeness testing as you 
mentioned.  So I think it is not ready yet to become the default way of 
handling OpenCL builtins.

> To summarize I am generally not against the inclusion of the header by 
> default and I think it's best if we just reuse the standard non-OpenCL 
> specific flags.

I agree.

> We would just need to understand how it will work with the fast 
> TableGen-based solution that is enabled using `-fdeclare-opencl-builtins`.

The combination of `-fdeclare-opencl-builtins` and `finclude-default-header` 
currently causes a smaller include file (that is fast to parse) to be included. 
So we should include the small header by default for 
`-fdeclare-opencl-builtins`.

> I am looping in @svenvh to discuss this further. Sven, do you think we should 
> rename this flag due to current proposed change? Should it be moved out of 
> `-cc1` too?

I would leave `-fdeclare-opencl-builtins` as it is, until it is complete and 
taken out of its "experimental" status.  Then we can discuss if we want to use 
TableGen instead of the header as a default.


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

https://reviews.llvm.org/D78979



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


[PATCH] D62368: Add support for Hygon Dhyana processor

2020-04-28 Thread Jinke Fan via Phabricator via cfe-commits
fanjinke marked an inline comment as done.
fanjinke added inline comments.



Comment at: compiler-rt/lib/scudo/scudo_utils.cpp:85
+   (Ecx == signature_HYGON_ecx);
+  if (!IsIntel && !IsAMD && !IsHygon)
 return false;

craig.topper wrote:
> fanjinke wrote:
> > craig.topper wrote:
> > > What's the rationale for the vendor check here anyway? Why isn't the bit 
> > > in ecx sufficient?
> > Using the cpuid instruction to get the vendor id will return the ASCII code 
> > of the vendor id, which is stored in the ebx,ecx,edx registers.
> > The ASCII code in the Hygon CPU is "HygonGenuine",  the ecx = "eniu".
> > For better differentiation from other cpus in the future,  by following 
> > AMD/Intel way, we use full ASCII code to identify Hygon CPU.
> > 
> Sorry, my question was about why this was restricted to Intel/AMD in the 
> first place. Why should this code need to be updated every time a new vendor 
> comes along? Why isn’t checking for sse4.2 regardless of vendor sufficient.
For this question, original author[1] may be more appropriate to reply.
From CPU specification, Bit20 of CPUID Fn_0001_ecx is SSE42 on Intel, AMD, 
and Hygon CPUs, but we are not sure that this is true for all x86 vendors.

Cryptoad, Any comments?

[1]: https://reviews.llvm.org/D40322


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62368



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


[PATCH] D78694: [clang-format] Fix lambda with ellipsis in return type

2020-04-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

Me too LGTM


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

https://reviews.llvm.org/D78694



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


[PATCH] D78915: [clang-format] Improved parser for C# properties

2020-04-28 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe updated this revision to Diff 260599.
jbcoe marked 3 inline comments as done.
jbcoe added a comment.

Added missing comments.

Complied with LLVM style.


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

https://reviews.llvm.org/D78915

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -611,6 +611,64 @@
 public string Name {
   get => _name;
   set => _name = value;
+})",
+   Style);
+
+  // Examples taken from
+  // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
+  verifyFormat(R"(
+// Expression body definitions
+public class SaleItem {
+  public decimal Price {
+get => _cost;
+set => _cost = value;
+  }
+})",
+   Style);
+
+  verifyFormat(R"(
+// Properties with backing fields
+class TimePeriod {
+  public double Hours {
+get { return _seconds / 3600; }
+set {
+  if (value < 0 || value > 24)
+throw new ArgumentOutOfRangeException(
+$"{nameof(value)} must be between 0 and 24.");
+  _seconds = value * 3600;
+}
+  }
+})",
+   Style);
+
+  verifyFormat(R"(
+// Auto-implemented properties
+public class SaleItem {
+  public decimal Price { get; set; }
+})",
+   Style);
+
+  // Add column limit to wrap long lines.
+  Style.ColumnLimit = 100;
+
+  // Examples with assignment to default value.
+  verifyFormat(R"(
+// Long assignment to default value
+class MyClass {
+  public override VeryLongNamedTypeIndeed VeryLongNamedValue { get; set } =
+  VeryLongNamedTypeIndeed.Create(DefaultFirstArgument, DefaultSecondArgument,
+ DefaultThirdArgument);
+})",
+   Style);
+
+  verifyFormat(R"(
+// Long assignment to default value with expression body
+class MyClass {
+  public override VeryLongNamedTypeIndeed VeryLongNamedValue {
+get => veryLongNamedField;
+set => veryLongNamedField = value;
+  } = VeryLongNamedTypeIndeed.Create(DefaultFirstArgument, DefaultSecondArgument,
+ DefaultThirdArgument);
 })",
Style);
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "UnwrappedLineParser.h"
+#include "FormatToken.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
@@ -1495,9 +1496,7 @@
   if (FormatTok->Previous->isNot(tok::identifier))
 return false;
 
-  // Try to parse the property accessor braces and contents:
-  // `{ get; set; } = new MyType(defaultValue);`
-  //  ^
+  // See if we are inside a property accessor.
   //
   // Record the current tokenPosition so that we can advance and
   // reset the current token. `Next` is not set yet so we need
@@ -1505,7 +1504,11 @@
   unsigned int StoredPosition = Tokens->getPosition();
   FormatToken *Tok = Tokens->getNextToken();
 
+  // A trivial property accessor is of the form:
+  // { [ACCESS_SPECIFIER] [get]; [ACCESS_SPECIFIER] [set] }
+  // Track these as they do not require line breaks to be introduced.
   bool HasGetOrSet = false;
+  bool IsTrivialPropertyAccessor = true;
   while (!eof()) {
 if (Tok->isOneOf(tok::semi, tok::kw_public, tok::kw_private,
  tok::kw_protected, Keywords.kw_internal, Keywords.kw_get,
@@ -1515,10 +1518,9 @@
   Tok = Tokens->getNextToken();
   continue;
 }
-if (Tok->is(tok::r_brace))
-  break;
-Tokens->setPosition(StoredPosition);
-return false;
+if (Tok->isNot(tok::r_brace))
+  IsTrivialPropertyAccessor = false;
+break;
   }
 
   if (!HasGetOrSet) {
@@ -1526,33 +1528,51 @@
 return false;
   }
 
+  // Try to parse the property accessor:
+  // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
   Tokens->setPosition(StoredPosition);
-  while (FormatTok->isNot(tok::r_brace)) {
-nextToken();
-  }
-
-  // Try to parse (optional) assignment to default value:
-  // `{ get; set; } = new MyType(defaultValue);`
-  //^^^
-  // There may be some very complicated expressions inside default value
-  // assignment, the simple parse block below will not handle them.
-  // The parse block below would need extending to handle opening parens etc.
-  StoredPosition = Tokens->getPosition();
-  Tok = Tokens->getNextToken();
-  bool NextTokenIsEqual = Tok->is(tok::equal);
-  Tokens->setPosition(StoredPosition);
-
-  if (NextTokenIsEqual) {
-do

[PATCH] D78915: [clang-format] Improved parser for C# properties

2020-04-28 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.

Thank you!


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

https://reviews.llvm.org/D78915



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


[PATCH] D78812: [SVE][CodeGen] Fix legalisation for scalable types

2020-04-28 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 260603.
kmclaughlin added a comment.

- Use ElementCount with getVectorVT


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

https://reviews.llvm.org/D78812

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll

Index: llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll
===
--- llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll
+++ llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll
@@ -22,6 +22,37 @@
   ret  %div
 }
 
+define  @sdiv_split_i32( %a,  %b) {
+; CHECK-LABEL: @sdiv_split_i32
+; CHECK-DAG: ptrue p0.s
+; CHECK-DAG: sdiv z0.s, p0/m, z0.s, z2.s
+; CHECK-DAG: sdiv z1.s, p0/m, z1.s, z3.s
+; CHECK-NEXT: ret
+  %div = sdiv  %a, %b
+  ret  %div
+}
+
+define  @sdiv_widen_i32( %a,  %b) {
+; CHECK-LABEL: @sdiv_widen_i32
+; CHECK-DAG: ptrue p0.d
+; CHECK-DAG: sxtw z1.d, p0/m, z1.d
+; CHECK-DAG: sxtw z0.d, p0/m, z0.d
+; CHECK-DAG: sdiv z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %div = sdiv  %a, %b
+  ret  %div
+}
+
+define  @sdiv_split_i64( %a,  %b) {
+; CHECK-LABEL: @sdiv_split_i64
+; CHECK-DAG: ptrue p0.d
+; CHECK-DAG: sdiv z0.d, p0/m, z0.d, z2.d
+; CHECK-DAG: sdiv z1.d, p0/m, z1.d, z3.d
+; CHECK-NEXT: ret
+  %div = sdiv  %a, %b
+  ret  %div
+}
+
 ;
 ; UDIV
 ;
@@ -43,3 +74,34 @@
   %div = udiv  %a, %b
   ret  %div
 }
+
+define  @udiv_split_i32( %a,  %b) {
+; CHECK-LABEL: @udiv_split_i32
+; CHECK-DAG: ptrue p0.s
+; CHECK-DAG: udiv z0.s, p0/m, z0.s, z2.s
+; CHECK-DAG: udiv z1.s, p0/m, z1.s, z3.s
+; CHECK-NEXT: ret
+  %div = udiv  %a, %b
+  ret  %div
+}
+
+define  @udiv_widen_i32( %a,  %b) {
+; CHECK-LABEL: @udiv_widen_i32
+; CHECK-DAG: ptrue p0.d
+; CHECK-DAG: and z1.d, z1.d, #0x
+; CHECK-DAG: and z0.d, z0.d, #0x
+; CHECK-DAG: udiv z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %div = udiv  %a, %b
+  ret  %div
+}
+
+define  @udiv_split_i64( %a,  %b) {
+; CHECK-LABEL: @udiv_split_i64
+; CHECK-DAG: ptrue p0.d
+; CHECK-DAG: udiv z0.d, p0/m, z0.d, z2.d
+; CHECK-DAG: udiv z1.d, p0/m, z1.d, z3.d
+; CHECK-NEXT: ret
+  %div = udiv  %a, %b
+  ret  %div
+}
Index: llvm/lib/CodeGen/TargetLoweringBase.cpp
===
--- llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -1392,7 +1392,7 @@
 EVT &IntermediateVT,
 unsigned &NumIntermediates,
 MVT &RegisterVT) const {
-  unsigned NumElts = VT.getVectorNumElements();
+  ElementCount EltCnt = VT.getVectorElementCount();
 
   // If there is a wider vector type with the same element type as this one,
   // or a promoted vector type that has the same number of elements which
@@ -1400,7 +1400,7 @@
   // This handles things like <2 x float> -> <4 x float> and
   // <4 x i1> -> <4 x i32>.
   LegalizeTypeAction TA = getTypeAction(Context, VT);
-  if (NumElts != 1 && (TA == TypeWidenVector || TA == TypePromoteInteger)) {
+  if (EltCnt.Min != 1 && (TA == TypeWidenVector || TA == TypePromoteInteger)) {
 EVT RegisterEVT = getTypeToTransformTo(Context, VT);
 if (isTypeLegal(RegisterEVT)) {
   IntermediateVT = RegisterEVT;
@@ -1417,22 +1417,22 @@
 
   // FIXME: We don't support non-power-of-2-sized vectors for now.  Ideally we
   // could break down into LHS/RHS like LegalizeDAG does.
-  if (!isPowerOf2_32(NumElts)) {
-NumVectorRegs = NumElts;
-NumElts = 1;
+  if (!isPowerOf2_32(EltCnt.Min)) {
+NumVectorRegs = EltCnt.Min;
+EltCnt.Min = 1;
   }
 
   // Divide the input until we get to a supported size.  This will always
   // end with a scalar if the target doesn't support vectors.
-  while (NumElts > 1 && !isTypeLegal(
-   EVT::getVectorVT(Context, EltTy, NumElts))) {
-NumElts >>= 1;
+  while (EltCnt.Min > 1 &&
+ !isTypeLegal(EVT::getVectorVT(Context, EltTy, EltCnt))) {
+EltCnt.Min >>= 1;
 NumVectorRegs <<= 1;
   }
 
   NumIntermediates = NumVectorRegs;
 
-  EVT NewVT = EVT::getVectorVT(Context, EltTy, NumElts);
+  EVT NewVT = EVT::getVectorVT(Context, EltTy, EltCnt);
   if (!isTypeLegal(NewVT))
 NewVT = EltTy;
   IntermediateVT = NewVT;
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -731,10 +731,10 @@
 IntermediateVT.getVectorNumElements() : 1;
 
   // Convert the vector to the appropriate type if necessary.
-  unsigned DestVectorNoElts = NumIntermediates * IntermediateNumElts;
-
+  auto DestEltCnt = ElementCount(NumIntermediates * IntermediateNumElts,
+ ValueVT.isScalableVector());
   EVT BuiltVectorTy = EV

[PATCH] D77802: [analyzer] Improved RangeSet::Negate support of unsigned ranges

2020-04-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 260604.
ASDenysPetrov edited the summary of this revision.
ASDenysPetrov added a comment.

@baloghadamsoftware 
I have added regression tests as you asked. You can now check them. Thanks.
@NoQ,
I kindly ask you to look at the changes, seems that it has a full set to be 
load-ready. I really need your feedback here, since the changes is in the core.


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

https://reviews.llvm.org/D77802

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/test/Analysis/constraint_manager_negate_difference.c
  clang/unittests/StaticAnalyzer/CMakeLists.txt
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -0,0 +1,141 @@
+//===- unittests/StaticAnalyzer/RangeSetTest.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/Basic/Builtins.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ento {
+namespace {
+
+// TestCase contains to lists of ranges.
+// Original one has to be negated.
+// Expected one has to be compared to negated original range.
+template  struct TestCase {
+  RangeSet original;
+  RangeSet expected;
+
+  TestCase(BasicValueFactory &BVF, RangeSet::Factory &F,
+   const std::initializer_list &originalList,
+   const std::initializer_list &expectedList)
+  : original(createRangeSetFromList(BVF, F, originalList)),
+expected(createRangeSetFromList(BVF, F, expectedList)) {}
+
+private:
+  RangeSet createRangeSetFromList(BasicValueFactory &BVF, RangeSet::Factory &F,
+  const std::initializer_list &rangeList) {
+llvm::APSInt from(sizeof(T) * 8, std::is_unsigned::value);
+llvm::APSInt to = from;
+RangeSet rangeSet = F.getEmptySet();
+for (auto it = rangeList.begin(); it != rangeList.end(); it += 2) {
+  from = *it;
+  to = *(it + 1);
+  rangeSet = rangeSet.addRange(
+  F, RangeSet(F, BVF.getValue(from), BVF.getValue(to)));
+}
+return rangeSet;
+  }
+};
+
+class RangeSetTest : public testing::Test {
+protected:
+  // Init block
+  IntrusiveRefCntPtr Diags{new DiagnosticIDs};
+  IntrusiveRefCntPtr DiagOpts{new DiagnosticOptions};
+  DiagnosticsEngine Diag{Diags, DiagOpts};
+  FileSystemOptions FileSystemOpts;
+  FileManager FileMgr{FileSystemOpts};
+  SourceManager SM{Diag, FileMgr};
+  LangOptions LOpts;
+  IdentifierTable idents;
+  SelectorTable sels;
+  Builtin::Context builtins;
+  ASTContext context{LOpts, SM, idents, sels, builtins};
+  llvm::BumpPtrAllocator alloc;
+  BasicValueFactory BVF{context, alloc};
+  RangeSet::Factory F;
+  // End init block
+
+  template  void checkNegate() {
+using type = T;
+
+// Use next values of the range {MIN, A, B, MID, C, D, MAX}.
+
+// MID is a value in the middle of the range
+// which unary minus does not affect on,
+// e.g. int8/int32(0), uint8(128), uint32(2147483648).
+
+constexpr type MIN = std::numeric_limits::min();
+constexpr type MAX = std::numeric_limits::max();
+constexpr type MID = std::is_signed::value
+ ? 0
+ : ~(static_cast(-1) / static_cast(2));
+constexpr type A = MID - static_cast(42 + 42);
+constexpr type B = MID - static_cast(42);
+constexpr type C = -B;
+constexpr type D = -A;
+
+static_assert(MIN < A && A < B && B < MID && MID < C && C < D && D < MAX,
+  "Values shall be in an ascending order");
+
+// Left {[x, y], [x, y]} is what shall be negated.
+// Right {[x, y], [x, y]} is what shall be compared to a negation result.
+TestCase cases[] = {
+{BVF, F, {MIN, A}, {MIN, MIN, D, MAX}},
+{BVF, F, {MIN, C}, {MIN, MIN, B, MAX}},
+{BVF, F, {MIN, MID}, {MIN, MIN, MID, MAX}},
+{BVF, F, {MIN, MAX}, {MIN, MAX}},
+{BVF, F, {A, D}, {A, D}},
+{BVF, F, {A, B}, {C, D}},
+{BVF, F, {MIN, A, D, MAX}, {MIN, A, D, MAX}},
+{BVF, F, {MIN, B, MID, D}, {MIN, MIN, A, MID, C, MAX}},
+{BVF, F, {MIN, MID, C, D}, {MIN, MIN, A, B, MID, MAX}},
+{BVF, F, {MIN, MID, C, MAX}, {MIN, B, MID, MAX}},
+{BVF, F, {A, MID, D, MAX}, {MIN + 1, A, MID, D}},
+{BVF, F, {A, A}, {D, D}},
+{BVF, F, {MID, MID}, {MID, MID}},
+{BVF, F, {MAX, MAX}, {MIN + 1, MIN + 1}},
+};
+
+for (const auto &

[PATCH] D78995: [SveEmitter] NFCI: Describe splat operands like any other modifier

2020-04-28 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: SjoerdMeijer, efriedma.
Herald added a subscriber: tschuett.
Herald added a reviewer: rengolin.

For scalar operands that need to be splat to a vector,
this patch adds a bool to the SVEType struct so that the
`applyModifier` function sets the value appropriately.
This makes the implementation/meaning of the modifiers more
transparent.


https://reviews.llvm.org/D78995

Files:
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -65,6 +65,7 @@
 
 class SVEType {
   TypeSpec TS;
+  bool IsSplat;
   bool Float, Signed, Immediate, Void, Constant, Pointer;
   bool DefaultType, IsScalable, Predicate, PredicatePattern, PrefetchOp;
   unsigned Bitwidth, ElementBitwidth, NumVectors;
@@ -73,10 +74,10 @@
   SVEType() : SVEType(TypeSpec(), 'v') {}
 
   SVEType(TypeSpec TS, char CharMod)
-  : TS(TS), Float(false), Signed(true), Immediate(false), Void(false),
-Constant(false), Pointer(false), DefaultType(false), IsScalable(true),
-Predicate(false), PredicatePattern(false), PrefetchOp(false),
-Bitwidth(128), ElementBitwidth(~0U), NumVectors(1) {
+  : TS(TS), IsSplat(false), Float(false), Signed(true), Immediate(false),
+Void(false), Constant(false), Pointer(false), DefaultType(false),
+IsScalable(true), Predicate(false), PredicatePattern(false),
+PrefetchOp(false), Bitwidth(128), ElementBitwidth(~0U), NumVectors(1) {
 if (!TS.empty())
   applyTypespec();
 applyModifier(CharMod);
@@ -99,6 +100,7 @@
   bool isPredicatePattern() const { return PredicatePattern; }
   bool isPrefetchOp() const { return PrefetchOp; }
   bool isConstant() const { return Constant; }
+  bool isSplat() const { return IsSplat; }
   unsigned getElementSizeInBits() const { return ElementBitwidth; }
   unsigned getNumVectors() const { return NumVectors; }
 
@@ -210,17 +212,14 @@
 
   /// Return true if the intrinsic takes a splat operand.
   bool hasSplat() const {
-// These prototype modifiers are described in arm_sve.td.
-return Proto.find_first_of("ajfrKLR") != std::string::npos;
+return llvm::any_of(getTypes(), [](const SVEType &T) { return T.isSplat(); 
});
   }
 
   /// Return the parameter index of the splat operand.
   unsigned getSplatIdx() const {
-// These prototype modifiers are described in arm_sve.td.
-auto Idx = Proto.find_first_of("ajfrKLR");
-assert(Idx != std::string::npos && Idx > 0 &&
-   "Prototype has no splat operand");
-return Idx - 1;
+return std::distance(
+&Types[1], //Types.begin(),
+llvm::find_if(getTypes(), [](const SVEType &T) { return T.isSplat(); 
}));
   }
 
   /// Emits the intrinsic declaration to the ostream.
@@ -505,8 +504,10 @@
 Bitwidth = 16;
 ElementBitwidth = 1;
 break;
-  case 's':
   case 'a':
+IsSplat = true;
+LLVM_FALLTHROUGH;
+  case 's':
 Bitwidth = ElementBitwidth;
 NumVectors = 0;
 break;
@@ -578,6 +579,7 @@
 ElementBitwidth = 64;
 break;
   case 'j':
+IsSplat = true;
 ElementBitwidth = Bitwidth = 64;
 NumVectors = 0;
 break;


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -65,6 +65,7 @@
 
 class SVEType {
   TypeSpec TS;
+  bool IsSplat;
   bool Float, Signed, Immediate, Void, Constant, Pointer;
   bool DefaultType, IsScalable, Predicate, PredicatePattern, PrefetchOp;
   unsigned Bitwidth, ElementBitwidth, NumVectors;
@@ -73,10 +74,10 @@
   SVEType() : SVEType(TypeSpec(), 'v') {}
 
   SVEType(TypeSpec TS, char CharMod)
-  : TS(TS), Float(false), Signed(true), Immediate(false), Void(false),
-Constant(false), Pointer(false), DefaultType(false), IsScalable(true),
-Predicate(false), PredicatePattern(false), PrefetchOp(false),
-Bitwidth(128), ElementBitwidth(~0U), NumVectors(1) {
+  : TS(TS), IsSplat(false), Float(false), Signed(true), Immediate(false),
+Void(false), Constant(false), Pointer(false), DefaultType(false),
+IsScalable(true), Predicate(false), PredicatePattern(false),
+PrefetchOp(false), Bitwidth(128), ElementBitwidth(~0U), NumVectors(1) {
 if (!TS.empty())
   applyTypespec();
 applyModifier(CharMod);
@@ -99,6 +100,7 @@
   bool isPredicatePattern() const { return PredicatePattern; }
   bool isPrefetchOp() const { return PrefetchOp; }
   bool isConstant() const { return Constant; }
+  bool isSplat() const { return IsSplat; }
   unsigned getElementSizeInBits() const { return ElementBitwidth; }
   unsigned getNumVectors() const { return NumVectors; }
 
@@ -210,17 +212,14 @@
 
   /// Return true if the intrinsic takes a splat operand.
   bool hasSplat() const {
-// Thes

[clang] c577201 - [SveEmitter] Add builtins for bitcount operations

2020-04-28 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-04-28T13:53:54+01:00
New Revision: c57720125fa7596be2403e7810957655d04dfece

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

LOG: [SveEmitter] Add builtins for bitcount operations

This patch adds builtins for svcls, svclz and svcnt.

For merging (_m), zeroing (_z) and don't-care (_x) predication.

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cls.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_clz.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cnt.c

Modified: 
clang/include/clang/Basic/arm_sve.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index eaee860bd3c0..03aef14cc2d7 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -702,6 +702,19 @@ def SVWHILELS_U64 : SInst<"svwhilele_{d}[_{1}]", "Pnn", 
"PUcPUsPUiPUl", MergeNon
 def SVWHILELT_S32 : SInst<"svwhilelt_{d}[_{1}]", "Pkk", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilelt", [IsOverloadWhile]>;
 def SVWHILELT_S64 : SInst<"svwhilelt_{d}[_{1}]", "Pll", "PcPsPiPl", 
MergeNone, "aarch64_sve_whilelt", [IsOverloadWhile]>;
 
+
+// Counting bit
+
+multiclass SInstCLS flags=[]> {
+  def _M : SInst;
+  def _X : SInst;
+  def _Z : SInst;
+}
+
+defm SVCLS : SInstCLS<"svcls", "csil","aarch64_sve_cls">;
+defm SVCLZ : SInstCLS<"svclz", "csilUcUsUiUl","aarch64_sve_clz">;
+defm SVCNT : SInstCLS<"svcnt", "csilUcUsUiUlhfd", "aarch64_sve_cnt">;
+
 

 // Floating-point arithmetic
 

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cls.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cls.c
new file mode 100644
index ..e464ac5a2ff6
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cls.c
@@ -0,0 +1,116 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svuint8_t test_svcls_s8_z(svbool_t pg, svint8_t op)
+{
+  // CHECK-LABEL: test_svcls_s8_z
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.cls.nxv16i8( zeroinitializer,  %pg,  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svcls,_s8,_z,)(pg, op);
+}
+
+svuint16_t test_svcls_s16_z(svbool_t pg, svint16_t op)
+{
+  // CHECK-LABEL: test_svcls_s16_z
+  // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.cls.nxv8i16( zeroinitializer,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svcls,_s16,_z,)(pg, op);
+}
+
+svuint32_t test_svcls_s32_z(svbool_t pg, svint32_t op)
+{
+  // CHECK-LABEL: test_svcls_s32_z
+  // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.cls.nxv4i32( zeroinitializer,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svcls,_s32,_z,)(pg, op);
+}
+
+svuint64_t test_svcls_s64_z(svbool_t pg, svint64_t op)
+{
+  // CHECK-LABEL: test_svcls_s64_z
+  // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.cls.nxv2i64( zeroinitializer,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svcls,_s64,_z,)(pg, op);
+}
+
+svuint8_t test_svcls_s8_m(svuint8_t inactive, svbool_t pg, svint8_t op)
+{
+  // CHECK-LABEL: test_svcls_s8_m
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.cls.nxv16i8( %inactive,  
%pg,  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svcls,_s8,_m,)(inactive, pg, op);
+}
+
+svuint16_t test_svcls_s16_m(svuint16_t inactive, svbool_t pg, svint16_t op)
+{
+  // CHECK-LABEL: test_svcls_s16_m
+  // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.cls.nxv8i16( %inactive,  
%[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svcls,_s16,_m,)(inactive, pg, op);
+}
+
+svuint32_t test_svcls_s32_m(svuint32_t inactive, svbool_t pg, svint32_

[clang] 476ba81 - [SveEmitter] Add builtins for zero/sign extension and bit/byte reversal.

2020-04-28 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-04-28T14:06:51+01:00
New Revision: 476ba8127bfa4553bf5ce1654cd844803e8d6dea

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

LOG: [SveEmitter] Add builtins for zero/sign extension and bit/byte reversal.

This patch adds builtins for predicated unary builtins
svext[bhw] and svrev[bhw] and svrbit.

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_extb.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_exth.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_extw.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_rbit.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_revb.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_revh.c
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_revw.c

Modified: 
clang/include/clang/Basic/arm_sve.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 03aef14cc2d7..e2c01023e55d 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -715,6 +715,24 @@ defm SVCLS : SInstCLS<"svcls", "csil",
"aarch64_sve_cls">;
 defm SVCLZ : SInstCLS<"svclz", "csilUcUsUiUl","aarch64_sve_clz">;
 defm SVCNT : SInstCLS<"svcnt", "csilUcUsUiUlhfd", "aarch64_sve_cnt">;
 
+
+// Conversion
+
+defm SVEXTB_S : SInstZPZ<"svextb", "sil","aarch64_sve_sxtb">;
+defm SVEXTB_U : SInstZPZ<"svextb", "UsUiUl", "aarch64_sve_uxtb">;
+defm SVEXTH_S : SInstZPZ<"svexth", "il", "aarch64_sve_sxth">;
+defm SVEXTH_U : SInstZPZ<"svexth", "UiUl",   "aarch64_sve_uxth">;
+defm SVEXTW_S : SInstZPZ<"svextw", "l",  "aarch64_sve_sxtw">;
+defm SVEXTW_U : SInstZPZ<"svextw", "Ul", "aarch64_sve_uxtw">;
+
+
+// Reversal
+
+defm SVRBIT : SInstZPZ<"svrbit", "csilUcUsUiUl", "aarch64_sve_rbit">;
+defm SVREVB : SInstZPZ<"svrevb", "silUsUiUl","aarch64_sve_revb">;
+defm SVREVH : SInstZPZ<"svrevh", "ilUiUl",   "aarch64_sve_revh">;
+defm SVREVW : SInstZPZ<"svrevw", "lUl",  "aarch64_sve_revw">;
+
 

 // Floating-point arithmetic
 

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_extb.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_extb.c
new file mode 100644
index ..720b81a28a18
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_extb.c
@@ -0,0 +1,173 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -triple aarch64-none-linux-gnu 
-target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svint16_t test_svextb_s16_z(svbool_t pg, svint16_t op)
+{
+  // CHECK-LABEL: test_svextb_s16_z
+  // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.sxtb.nxv8i16( zeroinitializer,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svextb,_s16,_z,)(pg, op);
+}
+
+svint32_t test_svextb_s32_z(svbool_t pg, svint32_t op)
+{
+  // CHECK-LABEL: test_svextb_s32_z
+  // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv4i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.sxtb.nxv4i32( zeroinitializer,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svextb,_s32,_z,)(pg, op);
+}
+
+svint64_t test_svextb_s64_z(svbool_t pg, svint64_t op)
+{
+  // CHECK-LABEL: test_svextb_s64_z
+  // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv2i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.sxtb.nxv2i64( zeroinitializer,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svextb,_s64,_z,)(pg, op);
+}
+
+svuint16_t test_svextb_u16_z(svbool_t pg, svuint16_t op)
+{
+  // CHECK-LABEL: test_svextb_u16_z
+  // CHECK: %[[PG:.*]] = call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( %pg)
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.uxtb.nxv8i16( zeroinitializer,  %[[PG]],  %op)
+  // CHECK: ret  %[[INTRINSIC]]
+  return SVE_ACLE_FUNC(svextb,_u16,_z,)(pg, op);
+}
+
+svuint32_t test_svextb_u32_z(svbool_t pg, svuint32_t op)
+{

[clang] 44ad58b - [clang-format] Improved parser for C# properties

2020-04-28 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-04-28T14:11:09+01:00
New Revision: 44ad58b9915d29eb48be4f89368be6d30d174825

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

LOG: [clang-format] Improved parser for C# properties

Summary:
Added some examples of properties from Microsoft documentation as test cases.

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties

Configuration support will be added in a follow up patch to address whether 
automatic properties are formatted as

```
Type MyType { get; set }
```

or

```
Type MyType
{ get; set }
```

Reviewers: krasimir, MyDeveloperDay

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index fdae725d625b..4734ff16921b 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -13,6 +13,7 @@
 
//===--===//
 
 #include "UnwrappedLineParser.h"
+#include "FormatToken.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
@@ -1495,9 +1496,7 @@ bool UnwrappedLineParser::tryToParsePropertyAccessor() {
   if (FormatTok->Previous->isNot(tok::identifier))
 return false;
 
-  // Try to parse the property accessor braces and contents:
-  // `{ get; set; } = new MyType(defaultValue);`
-  //  ^
+  // See if we are inside a property accessor.
   //
   // Record the current tokenPosition so that we can advance and
   // reset the current token. `Next` is not set yet so we need
@@ -1505,7 +1504,11 @@ bool UnwrappedLineParser::tryToParsePropertyAccessor() {
   unsigned int StoredPosition = Tokens->getPosition();
   FormatToken *Tok = Tokens->getNextToken();
 
+  // A trivial property accessor is of the form:
+  // { [ACCESS_SPECIFIER] [get]; [ACCESS_SPECIFIER] [set] }
+  // Track these as they do not require line breaks to be introduced.
   bool HasGetOrSet = false;
+  bool IsTrivialPropertyAccessor = true;
   while (!eof()) {
 if (Tok->isOneOf(tok::semi, tok::kw_public, tok::kw_private,
  tok::kw_protected, Keywords.kw_internal, Keywords.kw_get,
@@ -1515,10 +1518,9 @@ bool UnwrappedLineParser::tryToParsePropertyAccessor() {
   Tok = Tokens->getNextToken();
   continue;
 }
-if (Tok->is(tok::r_brace))
-  break;
-Tokens->setPosition(StoredPosition);
-return false;
+if (Tok->isNot(tok::r_brace))
+  IsTrivialPropertyAccessor = false;
+break;
   }
 
   if (!HasGetOrSet) {
@@ -1526,33 +1528,51 @@ bool UnwrappedLineParser::tryToParsePropertyAccessor() {
 return false;
   }
 
+  // Try to parse the property accessor:
+  // 
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
   Tokens->setPosition(StoredPosition);
-  while (FormatTok->isNot(tok::r_brace)) {
-nextToken();
-  }
-
-  // Try to parse (optional) assignment to default value:
-  // `{ get; set; } = new MyType(defaultValue);`
-  //^^^
-  // There may be some very complicated expressions inside default value
-  // assignment, the simple parse block below will not handle them.
-  // The parse block below would need extending to handle opening parens etc.
-  StoredPosition = Tokens->getPosition();
-  Tok = Tokens->getNextToken();
-  bool NextTokenIsEqual = Tok->is(tok::equal);
-  Tokens->setPosition(StoredPosition);
-
-  if (NextTokenIsEqual) {
-do {
+  nextToken();
+  do {
+switch (FormatTok->Tok.getKind()) {
+case tok::r_brace:
   nextToken();
-  if (FormatTok->is(tok::semi))
+  if (FormatTok->is(tok::equal)) {
+while (!eof() && FormatTok->isNot(tok::semi))
+  nextToken();
+nextToken();
+  }
+  addUnwrappedLine();
+  return true;
+case tok::l_brace:
+  ++Line->Level;
+  parseBlock(/*MustBeDeclaration=*/true);
+  addUnwrappedLine();
+  --Line->Level;
+  break;
+case tok::equal:
+  if (FormatTok->is(TT_JsFatArrow)) {
+++Line->Level;
+do {
+  nextToken();
+} while (!eof() && FormatTok->isNot(tok::semi));
+nextToken();
+addUnwrappedLine();
+--Line->Level;
 break;
-} while (!eof());
-  }
+  }
+  nextToken();
+  break;
+default:
+  if (FormatTok->isOneOf(Keywords.kw_get, Keywords.kw_set) &&
+  !IsTrivialPropertyAccessor) {
+// Non-trivial get/set 

[clang] 55bcb96 - recommit c77a4078e01033aa2206c31a579d217c8a07569b with fix

2020-04-28 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-04-28T09:14:13-04:00
New Revision: 55bcb96f3154808bcb5afc3fb46d8e00bf1db847

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

LOG: recommit c77a4078e01033aa2206c31a579d217c8a07569b with fix

https://reviews.llvm.org/D77954 caused a regression about ambiguity of new 
operator
in file scope.

This patch recovered the previous behavior for comparison without a caller.

This is a workaround. For real fix we need D71227

https://reviews.llvm.org/D78970

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp
clang/test/SemaCUDA/function-overload.cu

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index a32bc0c84c70..1db854e789d7 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9374,16 +9374,22 @@ static Comparison compareEnableIfAttrs(const Sema &S, 
const FunctionDecl *Cand1,
   return Comparison::Equal;
 }
 
-static bool isBetterMultiversionCandidate(const OverloadCandidate &Cand1,
-  const OverloadCandidate &Cand2) {
+static Comparison
+isBetterMultiversionCandidate(const OverloadCandidate &Cand1,
+  const OverloadCandidate &Cand2) {
   if (!Cand1.Function || !Cand1.Function->isMultiVersion() || !Cand2.Function 
||
   !Cand2.Function->isMultiVersion())
-return false;
+return Comparison::Equal;
 
-  // If Cand1 is invalid, it cannot be a better match, if Cand2 is invalid, 
this
-  // is obviously better.
-  if (Cand1.Function->isInvalidDecl()) return false;
-  if (Cand2.Function->isInvalidDecl()) return true;
+  // If both are invalid, they are equal. If one of them is invalid, the other
+  // is better.
+  if (Cand1.Function->isInvalidDecl()) {
+if (Cand2.Function->isInvalidDecl())
+  return Comparison::Equal;
+return Comparison::Worse;
+  }
+  if (Cand2.Function->isInvalidDecl())
+return Comparison::Better;
 
   // If this is a cpu_dispatch/cpu_specific multiversion situation, prefer
   // cpu_dispatch, else arbitrarily based on the identifiers.
@@ -9393,16 +9399,18 @@ static bool isBetterMultiversionCandidate(const 
OverloadCandidate &Cand1,
   const auto *Cand2CPUSpec = Cand2.Function->getAttr();
 
   if (!Cand1CPUDisp && !Cand2CPUDisp && !Cand1CPUSpec && !Cand2CPUSpec)
-return false;
+return Comparison::Equal;
 
   if (Cand1CPUDisp && !Cand2CPUDisp)
-return true;
+return Comparison::Better;
   if (Cand2CPUDisp && !Cand1CPUDisp)
-return false;
+return Comparison::Worse;
 
   if (Cand1CPUSpec && Cand2CPUSpec) {
 if (Cand1CPUSpec->cpus_size() != Cand2CPUSpec->cpus_size())
-  return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size();
+  return Cand1CPUSpec->cpus_size() < Cand2CPUSpec->cpus_size()
+ ? Comparison::Better
+ : Comparison::Worse;
 
 std::pair
 FirstDiff = std::mismatch(
@@ -9415,7 +9423,9 @@ static bool isBetterMultiversionCandidate(const 
OverloadCandidate &Cand1,
 assert(FirstDiff.first != Cand1CPUSpec->cpus_end() &&
"Two 
diff erent cpu-specific versions should not have the same "
"identifier list, otherwise they'd be the same decl!");
-return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName();
+return (*FirstDiff.first)->getName() < (*FirstDiff.second)->getName()
+   ? Comparison::Better
+   : Comparison::Worse;
   }
   llvm_unreachable("No way to get here unless both had cpu_dispatch");
 }
@@ -9475,6 +9485,50 @@ bool clang::isBetterOverloadCandidate(
   else if (!Cand1.Viable)
 return false;
 
+  // [CUDA] A function with 'never' preference is marked not viable, therefore
+  // is never shown up here. The worst preference shown up here is 'wrong 
side',
+  // e.g. a host function called by a device host function in device
+  // compilation. This is valid AST as long as the host device function is not
+  // emitted, e.g. it is an inline function which is called only by a host
+  // function. A deferred diagnostic will be triggered if it is emitted.
+  // However a wrong-sided function is still a viable candidate here.
+  //
+  // If Cand1 can be emitted and Cand2 cannot be emitted in the current
+  // context, Cand1 is better than Cand2. If Cand1 can not be emitted and Cand2
+  // can be emitted, Cand1 is not better than Cand2. This rule should have
+  // precedence over other rules.
+  //
+  // If both Cand1 and Cand2 can be emitted, or neither can be emitted, then
+  // other rules should be used to determine which is better. This is because
+  // host/device based overloading resolution is mostly for determining
+  // viability of a function. If two functions are both viable, other factors
+  

[PATCH] D78885: [clangd] Fix remote index build without shared libs mode

2020-04-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 260606.
kbobyrev added a comment.

Don't create a separate directory for proto files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78885

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/FindGRPC.cmake
  llvm/cmake/modules/LLVMProcessSources.cmake


Index: llvm/cmake/modules/LLVMProcessSources.cmake
===
--- llvm/cmake/modules/LLVMProcessSources.cmake
+++ llvm/cmake/modules/LLVMProcessSources.cmake
@@ -57,10 +57,12 @@
 
 
 function(llvm_process_sources OUT_VAR)
-  cmake_parse_arguments(ARG "" "" "ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" 
${ARGN})
+  cmake_parse_arguments(ARG "DONT_CHECK_FILE_LIST" "" 
"ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" ${ARGN})
   set(sources ${ARG_UNPARSED_ARGUMENTS})
-  llvm_check_source_file_list( ${sources} )
-  
+  if (NOT ARG_DONT_CHECK_FILE_LIST)
+llvm_check_source_file_list(${sources})
+  endif()
+
   # This adds .td and .h files to the Visual Studio solution:
   add_td_sources(sources)
   find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}")
Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -45,6 +45,7 @@
   "${ProtoSourceAbsolutePath}"
   DEPENDS "${ProtoSourceAbsolutePath}")
 
-  add_library(${LibraryName} ${GeneratedProtoSource} ${GeneratedGRPCSource})
-  target_link_libraries(${LibraryName} grpc++ protobuf)
+  add_clang_library(${LibraryName} ${GeneratedProtoSource} 
${GeneratedGRPCSource}
+DONT_CHECK_FILE_LIST
+LINK_LIBS grpc++ protobuf)
 endfunction()
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -409,7 +409,7 @@
 #   )
 function(llvm_add_library name)
   cmake_parse_arguments(ARG
-
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB"
+
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB;DONT_CHECK_FILE_LIST"
 "OUTPUT_NAME;PLUGIN_TOOL;ENTITLEMENTS;BUNDLE_PATH"
 "ADDITIONAL_HEADERS;DEPENDS;LINK_COMPONENTS;LINK_LIBS;OBJLIBS"
 ${ARGN})
@@ -421,7 +421,11 @@
   if(ARG_OBJLIBS)
 set(ALL_FILES ${ARG_OBJLIBS})
   else()
-llvm_process_sources(ALL_FILES ${ARG_UNPARSED_ARGUMENTS} 
${ARG_ADDITIONAL_HEADERS})
+if (ARG_DONT_CHECK_FILE_LIST)
+  llvm_process_sources(ALL_FILES ${ARG_UNPARSED_ARGUMENTS} 
${ARG_ADDITIONAL_HEADERS} DONT_CHECK_FILE_LIST)
+else()
+  llvm_process_sources(ALL_FILES ${ARG_UNPARSED_ARGUMENTS} 
${ARG_ADDITIONAL_HEADERS})
+endif()
   endif()
 
   if(ARG_MODULE)
Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -5,14 +5,12 @@
 add_clang_executable(clangd-index-server
   Server.cpp
   )
-target_compile_definitions(clangd-index-server PRIVATE -D 
GOOGLE_PROTOBUF_NO_RTTI=1)
-clang_target_link_libraries(clangd-index-server
-  PRIVATE
-  clangDaemon
-  )
 target_link_libraries(clangd-index-server
   PRIVATE
-  RemoteIndexProtos
+  clangDaemon
 
+  RemoteIndexProtos
   clangdRemoteMarshalling
+
+  grpc++
   )
Index: clang-tools-extra/clangd/index/remote/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -18,6 +18,8 @@
 protobuf
 grpc++
 clangDaemon
+
+DONT_CHECK_FILE_LIST
 )
 
   add_subdirectory(marshalling)


Index: llvm/cmake/modules/LLVMProcessSources.cmake
===
--- llvm/cmake/modules/LLVMProcessSources.cmake
+++ llvm/cmake/modules/LLVMProcessSources.cmake
@@ -57,10 +57,12 @@
 
 
 function(llvm_process_sources OUT_VAR)
-  cmake_parse_arguments(ARG "" "" "ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" ${ARGN})
+  cmake_parse_arguments(ARG "DONT_CHECK_FILE_LIST" "" "ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" ${ARGN})
   set(sources ${ARG_UNPARSED_ARGUMENTS})
-  llvm_check_source_file_list( ${sources} )
-  
+  if (NOT ARG_DONT_CHECK_FILE_LIST)
+llvm_check_source_file_list(${sources})
+  endif()
+
   # This adds .td and .h files to the Visual Studio solution:
   add_td_sources(sources)
   find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}")
Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/mod

[PATCH] D78812: [SVE][CodeGen] Fix legalisation for scalable types

2020-04-28 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin marked 2 inline comments as done.
kmclaughlin added inline comments.



Comment at: llvm/test/CodeGen/AArch64/llvm-ir-to-intrinsic.ll:107
+  ret  %div
+}

efriedma wrote:
> Maybe also worth adding a testcase for ``, assuming that 
> doesn't expose anything really tricky.
Promotion is not possible for `` since this would result in a 
``, which is also illegal. Instead will need to widen a type 
such as ``, which needs some more work. For fixed width 
vectors, the compiler will scalarise cases such as this (e.g. from 1 x i32 to 
just i32), which isn't something we can do for scalable vectors because of the 
runtime scaling.
This has never had much priority because in practice the vectoriser won't pick 
a VF of 1, so I think we can add support for this at a later point. Currently, 
tests which use types such as this will trigger the assert added to 
FoldBUILD_VECTOR in D78636.


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

https://reviews.llvm.org/D78812



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


[PATCH] D78938: Fixing all comparisons for C++20 compilation.

2020-04-28 Thread Barry Revzin via Phabricator via cfe-commits
BRevzin added a comment.

In D78938#2007037 , @dblaikie wrote:

> (peanut gallery: I'd consider, while you're touching these all anyway, 
> changing them all to non-member (friended where required) as I believe that's 
> best practice - allows equal implicit conversions on either side, for 
> instance (even if some types have no implicit conversions - it at least 
> provides a nice consistency/examples that people are likely to copy from))


Hidden friend is probably the best way to write comparisons in C++17 and 
earlier, but I'm not sure that will hold in C++20 (even if LLVM isn't on C++20 
and won't be for I imagine quite some time). With reversed candidates, I think 
member functions might be the way to go there - you still get implicit 
conversions on either side (just not on both sides at the same time) and hidden 
friends... are kind of weird, to be honest.

Also, I didn't touch all of them - only the ones that break in C++20 (a lot of 
which just missing a `const`). A lot of comparison operators are already fine. 
I'm not sure it's worth changing them just to look the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938



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


[PATCH] D78979: OpenCL: Include builtin header by default

2020-04-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.



> 
> 
>> I am looping in @svenvh to discuss this further. Sven, do you think we 
>> should rename this flag due to current proposed change? Should it be moved 
>> out of `-cc1` too?
> 
> I would leave `-fdeclare-opencl-builtins` as it is, until it is complete and 
> taken out of its "experimental" status.  Then we can discuss if we want to 
> use TableGen instead of the header as a default.

Would it not become confusing since the builtins are going to be included by 
default? Should we rename the flag at least? Also ideally it should be 
documented in https://clang.llvm.org/docs/UsersManual.html#opencl-header


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

https://reviews.llvm.org/D78979



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


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

2020-04-28 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

My point is that all the changes in this patch are already in the upstream. If 
you want to re-land D69778 , you should rather 
re-open and update that patch instead? (and close this current one)


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D78885: [clangd] Fix remote index build without shared libs mode

2020-04-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/CMakeLists.txt:22
+
+DONT_CHECK_FILE_LIST
 )

would be nice to avoid specifying this here if it's not needed



Comment at: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt:8
   )
-target_compile_definitions(clangd-index-server PRIVATE -D 
GOOGLE_PROTOBUF_NO_RTTI=1)
-clang_target_link_libraries(clangd-index-server

why this removal?



Comment at: llvm/cmake/modules/AddLLVM.cmake:412
   cmake_parse_arguments(ARG
-
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB"
+
"MODULE;SHARED;STATIC;OBJECT;DISABLE_LLVM_LINK_LLVM_DYLIB;SONAME;NO_INSTALL_RPATH;COMPONENT_LIB;DONT_CHECK_FILE_LIST"
 "OUTPUT_NAME;PLUGIN_TOOL;ENTITLEMENTS;BUNDLE_PATH"

why do you need to parse this and then explicitly pass it through, rather than 
just letting it fall into ARG_UNPARSED_ARGUMENTS?



Comment at: llvm/cmake/modules/LLVMProcessSources.cmake:60
 function(llvm_process_sources OUT_VAR)
-  cmake_parse_arguments(ARG "" "" "ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" 
${ARGN})
+  cmake_parse_arguments(ARG "DONT_CHECK_FILE_LIST" "" 
"ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" ${ARGN})
   set(sources ${ARG_UNPARSED_ARGUMENTS})

This name could be better, I think.

What about PARTIAL_SOURCES_INTENDED?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78885



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


[PATCH] D79000: [clang-format] C# property accessor formatting can be controlled by config options

2020-04-28 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added reviewers: krasimir, MyDeveloperDay.
jbcoe added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Allow brace wrapping in C# property accessors to be controlled by configuration 
options.

Add new tests and revert old test results for MS style to their old state (as 
intended).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79000

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -245,11 +245,13 @@
"}");
 
   verifyFormat("[TestMethod]\n"
-   "public string Host { set; get; }");
+   "public string Host\n"
+   "{ set; get; }");
 
   verifyFormat("[TestMethod(\"start\", HelpText = \"Starts the server "
"listening on provided host\")]\n"
-   "public string Host { set; get; }");
+   "public string Host\n"
+   "{ set; get; }");
 
   verifyFormat(
   "[DllImport(\"Hello\", EntryPoint = \"hello_world\")]\n"
@@ -669,6 +671,32 @@
 set => veryLongNamedField = value;
   } = VeryLongNamedTypeIndeed.Create(DefaultFirstArgument, 
DefaultSecondArgument,
  DefaultThirdArgument);
+})",
+   Style);
+
+  // Brace wrapping and single-lining of accessor can be controlled by config.
+  Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterFunction = true;
+
+  verifyFormat(R"(//
+public class SaleItem {
+  public decimal Price
+  { get; set; }
+})",
+   Style);
+
+  verifyFormat(R"(//
+class TimePeriod {
+  public double Hours
+  {
+get {
+  return _seconds / 3600;
+}
+set {
+  _seconds = value * 3600;
+}
+  }
 })",
Style);
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1531,6 +1531,8 @@
   // Try to parse the property accessor:
   // 
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
   Tokens->setPosition(StoredPosition);
+  if (Style.BraceWrapping.AfterFunction == true)
+addUnwrappedLine();
   nextToken();
   do {
 switch (FormatTok->Tok.getKind()) {


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -245,11 +245,13 @@
"}");
 
   verifyFormat("[TestMethod]\n"
-   "public string Host { set; get; }");
+   "public string Host\n"
+   "{ set; get; }");
 
   verifyFormat("[TestMethod(\"start\", HelpText = \"Starts the server "
"listening on provided host\")]\n"
-   "public string Host { set; get; }");
+   "public string Host\n"
+   "{ set; get; }");
 
   verifyFormat(
   "[DllImport(\"Hello\", EntryPoint = \"hello_world\")]\n"
@@ -669,6 +671,32 @@
 set => veryLongNamedField = value;
   } = VeryLongNamedTypeIndeed.Create(DefaultFirstArgument, DefaultSecondArgument,
  DefaultThirdArgument);
+})",
+   Style);
+
+  // Brace wrapping and single-lining of accessor can be controlled by config.
+  Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterFunction = true;
+
+  verifyFormat(R"(//
+public class SaleItem {
+  public decimal Price
+  { get; set; }
+})",
+   Style);
+
+  verifyFormat(R"(//
+class TimePeriod {
+  public double Hours
+  {
+get {
+  return _seconds / 3600;
+}
+set {
+  _seconds = value * 3600;
+}
+  }
 })",
Style);
 }
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1531,6 +1531,8 @@
   // Try to parse the property accessor:
   // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
   Tokens->setPosition(StoredPosition);
+  if (Style.BraceWrapping.AfterFunction == true)
+addUnwrappedLine();
   nextToken();
   do {
 switch (FormatTok->Tok.getKind()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78915: [clang-format] Improved parser for C# properties

2020-04-28 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG44ad58b9915d: [clang-format] Improved parser for C# 
properties (authored by Jonathan Coe ).

Changed prior to commit:
  https://reviews.llvm.org/D78915?vs=260599&id=260613#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78915

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestCSharp.cpp

Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -613,6 +613,64 @@
   set => _name = value;
 })",
Style);
+
+  // Examples taken from
+  // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
+  verifyFormat(R"(
+// Expression body definitions
+public class SaleItem {
+  public decimal Price {
+get => _cost;
+set => _cost = value;
+  }
+})",
+   Style);
+
+  verifyFormat(R"(
+// Properties with backing fields
+class TimePeriod {
+  public double Hours {
+get { return _seconds / 3600; }
+set {
+  if (value < 0 || value > 24)
+throw new ArgumentOutOfRangeException(
+$"{nameof(value)} must be between 0 and 24.");
+  _seconds = value * 3600;
+}
+  }
+})",
+   Style);
+
+  verifyFormat(R"(
+// Auto-implemented properties
+public class SaleItem {
+  public decimal Price { get; set; }
+})",
+   Style);
+
+  // Add column limit to wrap long lines.
+  Style.ColumnLimit = 100;
+
+  // Examples with assignment to default value.
+  verifyFormat(R"(
+// Long assignment to default value
+class MyClass {
+  public override VeryLongNamedTypeIndeed VeryLongNamedValue { get; set } =
+  VeryLongNamedTypeIndeed.Create(DefaultFirstArgument, DefaultSecondArgument,
+ DefaultThirdArgument);
+})",
+   Style);
+
+  verifyFormat(R"(
+// Long assignment to default value with expression body
+class MyClass {
+  public override VeryLongNamedTypeIndeed VeryLongNamedValue {
+get => veryLongNamedField;
+set => veryLongNamedField = value;
+  } = VeryLongNamedTypeIndeed.Create(DefaultFirstArgument, DefaultSecondArgument,
+ DefaultThirdArgument);
+})",
+   Style);
 }
 
 TEST_F(FormatTestCSharp, CSharpSpaces) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "UnwrappedLineParser.h"
+#include "FormatToken.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
@@ -1495,9 +1496,7 @@
   if (FormatTok->Previous->isNot(tok::identifier))
 return false;
 
-  // Try to parse the property accessor braces and contents:
-  // `{ get; set; } = new MyType(defaultValue);`
-  //  ^
+  // See if we are inside a property accessor.
   //
   // Record the current tokenPosition so that we can advance and
   // reset the current token. `Next` is not set yet so we need
@@ -1505,7 +1504,11 @@
   unsigned int StoredPosition = Tokens->getPosition();
   FormatToken *Tok = Tokens->getNextToken();
 
+  // A trivial property accessor is of the form:
+  // { [ACCESS_SPECIFIER] [get]; [ACCESS_SPECIFIER] [set] }
+  // Track these as they do not require line breaks to be introduced.
   bool HasGetOrSet = false;
+  bool IsTrivialPropertyAccessor = true;
   while (!eof()) {
 if (Tok->isOneOf(tok::semi, tok::kw_public, tok::kw_private,
  tok::kw_protected, Keywords.kw_internal, Keywords.kw_get,
@@ -1515,10 +1518,9 @@
   Tok = Tokens->getNextToken();
   continue;
 }
-if (Tok->is(tok::r_brace))
-  break;
-Tokens->setPosition(StoredPosition);
-return false;
+if (Tok->isNot(tok::r_brace))
+  IsTrivialPropertyAccessor = false;
+break;
   }
 
   if (!HasGetOrSet) {
@@ -1526,33 +1528,51 @@
 return false;
   }
 
+  // Try to parse the property accessor:
+  // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
   Tokens->setPosition(StoredPosition);
-  while (FormatTok->isNot(tok::r_brace)) {
-nextToken();
-  }
-
-  // Try to parse (optional) assignment to default value:
-  // `{ get; set; } = new MyType(defaultValue);`
-  //^^^
-  // There may be some very complicated expressions inside default value
-  // assignment, the simple parse block below will not handle them.
-  // The parse block be

[PATCH] D78885: [clangd] Fix remote index build without shared libs mode

2020-04-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 260618.
kbobyrev marked 5 inline comments as done.
kbobyrev added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78885

Files:
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  llvm/cmake/modules/FindGRPC.cmake
  llvm/cmake/modules/LLVMProcessSources.cmake


Index: llvm/cmake/modules/LLVMProcessSources.cmake
===
--- llvm/cmake/modules/LLVMProcessSources.cmake
+++ llvm/cmake/modules/LLVMProcessSources.cmake
@@ -57,10 +57,12 @@
 
 
 function(llvm_process_sources OUT_VAR)
-  cmake_parse_arguments(ARG "" "" "ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" 
${ARGN})
+  cmake_parse_arguments(ARG "PARTIAL_SOURCES_INTENDED" "" 
"ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" ${ARGN})
   set(sources ${ARG_UNPARSED_ARGUMENTS})
-  llvm_check_source_file_list( ${sources} )
-  
+  if (NOT ARG_PARTIAL_SOURCES_INTENDED)
+llvm_check_source_file_list(${sources})
+  endif()
+
   # This adds .td and .h files to the Visual Studio solution:
   add_td_sources(sources)
   find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}")
Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -45,6 +45,7 @@
   "${ProtoSourceAbsolutePath}"
   DEPENDS "${ProtoSourceAbsolutePath}")
 
-  add_library(${LibraryName} ${GeneratedProtoSource} ${GeneratedGRPCSource})
-  target_link_libraries(${LibraryName} grpc++ protobuf)
+  add_clang_library(${LibraryName} ${GeneratedProtoSource} 
${GeneratedGRPCSource}
+PARTIAL_SOURCES_INTENDED
+LINK_LIBS grpc++ protobuf)
 endfunction()
Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -5,14 +5,12 @@
 add_clang_executable(clangd-index-server
   Server.cpp
   )
-target_compile_definitions(clangd-index-server PRIVATE -D 
GOOGLE_PROTOBUF_NO_RTTI=1)
-clang_target_link_libraries(clangd-index-server
-  PRIVATE
-  clangDaemon
-  )
 target_link_libraries(clangd-index-server
   PRIVATE
-  RemoteIndexProtos
+  clangDaemon
 
+  RemoteIndexProtos
   clangdRemoteMarshalling
+
+  grpc++
   )


Index: llvm/cmake/modules/LLVMProcessSources.cmake
===
--- llvm/cmake/modules/LLVMProcessSources.cmake
+++ llvm/cmake/modules/LLVMProcessSources.cmake
@@ -57,10 +57,12 @@
 
 
 function(llvm_process_sources OUT_VAR)
-  cmake_parse_arguments(ARG "" "" "ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" ${ARGN})
+  cmake_parse_arguments(ARG "PARTIAL_SOURCES_INTENDED" "" "ADDITIONAL_HEADERS;ADDITIONAL_HEADER_DIRS" ${ARGN})
   set(sources ${ARG_UNPARSED_ARGUMENTS})
-  llvm_check_source_file_list( ${sources} )
-  
+  if (NOT ARG_PARTIAL_SOURCES_INTENDED)
+llvm_check_source_file_list(${sources})
+  endif()
+
   # This adds .td and .h files to the Visual Studio solution:
   add_td_sources(sources)
   find_all_header_files(hdrs "${ARG_ADDITIONAL_HEADER_DIRS}")
Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -45,6 +45,7 @@
   "${ProtoSourceAbsolutePath}"
   DEPENDS "${ProtoSourceAbsolutePath}")
 
-  add_library(${LibraryName} ${GeneratedProtoSource} ${GeneratedGRPCSource})
-  target_link_libraries(${LibraryName} grpc++ protobuf)
+  add_clang_library(${LibraryName} ${GeneratedProtoSource} ${GeneratedGRPCSource}
+PARTIAL_SOURCES_INTENDED
+LINK_LIBS grpc++ protobuf)
 endfunction()
Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -5,14 +5,12 @@
 add_clang_executable(clangd-index-server
   Server.cpp
   )
-target_compile_definitions(clangd-index-server PRIVATE -D GOOGLE_PROTOBUF_NO_RTTI=1)
-clang_target_link_libraries(clangd-index-server
-  PRIVATE
-  clangDaemon
-  )
 target_link_libraries(clangd-index-server
   PRIVATE
-  RemoteIndexProtos
+  clangDaemon
 
+  RemoteIndexProtos
   clangdRemoteMarshalling
+
+  grpc++
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78979: OpenCL: Include builtin header by default

2020-04-28 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D78979#2007563 , @Anastasia wrote:

> > 
> > 
> >> I am looping in @svenvh to discuss this further. Sven, do you think we 
> >> should rename this flag due to current proposed change? Should it be moved 
> >> out of `-cc1` too?
> > 
> > I would leave `-fdeclare-opencl-builtins` as it is, until it is complete 
> > and taken out of its "experimental" status.  Then we can discuss if we want 
> > to use TableGen instead of the header as a default.
>
> Would it not become confusing since the builtins are going to be included by 
> default? Should we rename the flag at least? Also ideally it should be 
> documented in https://clang.llvm.org/docs/UsersManual.html#opencl-header


ah I guess if we leave it under `-cc1 ` we will have the command line interface 
as follows:

- Driver (without `-cc1`) adds OpenCL header by default that can be overridden 
by the flag added in this patch.
- Frontend (with `-cc1`) doesn't add the header by default but there are two 
flags `-fdeclare-opencl-builtins` or `-finclude-default-header` that allow to 
include the header.

Is my understanding correct? We should reflect this is the User Manual.


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

https://reviews.llvm.org/D78979



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


[PATCH] D78885: [clangd] Fix remote index build without shared libs mode

2020-04-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt:8
   )
-target_compile_definitions(clangd-index-server PRIVATE -D 
GOOGLE_PROTOBUF_NO_RTTI=1)
-clang_target_link_libraries(clangd-index-server

sammccall wrote:
> why this removal?
Discussed in the chat.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78885



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


[PATCH] D78985: [clang-tidy] NFC: Cleanup Python scripts

2020-04-28 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

It would be great to also run Flake9 and PyLint.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78985



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


[PATCH] D78995: [SveEmitter] NFCI: Describe splat operands like any other modifier

2020-04-28 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/utils/TableGen/SveEmitter.cpp:68
   TypeSpec TS;
+  bool IsSplat;
   bool Float, Signed, Immediate, Void, Constant, Pointer;

I was wondering if IsSplat belongs here or somewhere else. It doesn't sound 
like a type, like the other members do, but more a specific case of a vector? 
But saying this off the top of my head, haven't looked at the code and the 
context, but perhaps you can comment on this if this is where it should be or 
not.


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

https://reviews.llvm.org/D78995



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


[PATCH] D78985: [clang-tidy] NFC: Cleanup Python scripts

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

Remove python3 from shebang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78985

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py
  clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
  clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Index: clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
===
--- clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
+++ clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
@@ -1,14 +1,15 @@
 #!/usr/bin/env python
 #
-#===- run-clang-tidy.py - Parallel clang-tidy runner -*- python -*--===#
+#===- run-clang-tidy.py - Parallel clang-tidy runner *- python -*--===#
 #
 # 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
 #
-#======#
+#===---===#
 # FIXME: Integrate with clang-tidy-diff.py
 
+
 """
 Parallel clang-tidy runner
 ==
@@ -60,6 +61,7 @@
 else:
 import queue as queue
 
+
 def find_compilation_database(path):
   """Adjusts the directory until a compilation database is found."""
   result = './'
@@ -112,7 +114,7 @@
   """Merge all replacement files in a directory into a single file"""
   # The fixes suggested by clang-tidy >= 4.0.0 are given under
   # the top level key 'Diagnostics' in the output yaml files
-  mergekey="Diagnostics"
+  mergekey = "Diagnostics"
   merged=[]
   for replacefile in glob.iglob(os.path.join(tmpdir, '*.yaml')):
 content = yaml.safe_load(open(replacefile, 'r'))
@@ -125,7 +127,7 @@
 # include/clang/Tooling/ReplacementsYaml.h, but the value
 # is actually never used inside clang-apply-replacements,
 # so we set it to '' here.
-output = { 'MainSourceFile': '', mergekey: merged }
+output = {'MainSourceFile': '', mergekey: merged}
 with open(mergefile, 'w') as out:
   yaml.safe_dump(output, out)
   else:
@@ -324,11 +326,12 @@
 except:
   print('Error applying fixes.\n', file=sys.stderr)
   traceback.print_exc()
-  return_code=1
+  return_code = 1
 
   if tmpdir:
 shutil.rmtree(tmpdir)
   sys.exit(return_code)
 
+
 if __name__ == '__main__':
   main()
Index: clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -1,12 +1,12 @@
 #!/usr/bin/env python
 #
-#===- clang-tidy-diff.py - ClangTidy Diff Checker *- python -*--===#
+#===- clang-tidy-diff.py - ClangTidy Diff Checker ---*- python -*--===#
 #
 # 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
 #
-#======#
+#===---===#
 
 r"""
 ClangTidy Diff Checker
@@ -75,7 +75,7 @@
 sys.stderr.write('Failed: ' + str(e) + ': '.join(command) + '\n')
 finally:
   with lock:
-if (not timeout is None) and (not watchdog is None):
+if not (timeout is None or watchdog is None):
   if not watchdog.is_alive():
   sys.stderr.write('Terminated by timeout: ' +
' '.join(command) + '\n')
@@ -89,6 +89,7 @@
 t.daemon = True
 t.start()
 
+
 def merge_replacement_files(tmpdir, mergefile):
   """Merge all replacement files in a directory into a single file"""
   # The fixes suggested by clang-tidy >= 4.0.0 are given under
@@ -106,7 +107,7 @@
 # include/clang/Tooling/ReplacementsYaml.h, but the value
 # is actually never used inside clang-apply-replacements,
 # so we set it to '' here.
-output = { 'MainSourceFile': '', mergekey: merged }
+output = {'MainSourceFile': '', mergekey: merged}
 with open(mergefile, 'w') as out:
   yaml.safe_dump(output, out)
   else:
Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -1,12 +1,12 @@
 #!/usr/bin/env python
 #
-#===- rename_check.py - clang-tidy check renamer -*- python -*--===#
+#===- rename_check.py - clang-tidy check renamer *- python -*--===#
 #
 # Part of the LLVM Project, under the Apache Lice

[PATCH] D78985: [clang-tidy] NFC: Cleanup Python scripts

2020-04-28 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

In D78985#2007669 , @Eugene.Zelenko 
wrote:

> It would be great to also run Flake9 and PyLint.


Those were actually from pylint. That's a good idea, but I didn't fix all the 
warnings there and while I might get back to this in the future I don't think 
it's in the scope of this patch as this is a pretty trivial NFC cleanup.




Comment at: clang-tools-extra/clang-tidy/add_new_check.py:1
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #

hokein wrote:
> we should keep using `python` I think.
Oops, a leftover from testing, thanks for noticing!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78985



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


[PATCH] D78885: [clangd] Fix remote index build without shared libs mode

2020-04-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt:8
   )
-target_compile_definitions(clangd-index-server PRIVATE -D 
GOOGLE_PROTOBUF_NO_RTTI=1)
-clang_target_link_libraries(clangd-index-server

kbobyrev wrote:
> sammccall wrote:
> > why this removal?
> Discussed in the chat.
For the record: redundant with parent package (this is a cleanup-while-here)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78885



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


[PATCH] D78979: OpenCL: Include builtin header by default

2020-04-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D78979#2007643 , @Anastasia wrote:

> ah I guess if we leave it under `-cc1 ` we will have the command line 
> interface as follows:
>
> - Driver (without `-cc1`) adds OpenCL header by default that can be 
> overridden by the flag added in this patch.
> - Frontend (with `-cc1`) doesn't add the header by default but there are two 
> flags `-fdeclare-opencl-builtins` or `-finclude-default-header` that allow to 
> include the header.
>
>   Is my understanding correct? We should reflect this is the User Manual.


I think -finclude-default-header -fno-include-default-header better becomes 
both driver and -cc1 option since users are likely to use it with driver. It 
may also be used with other languages e.g. HIP.


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

https://reviews.llvm.org/D78979



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


[PATCH] D78573: [Clang][Sema] Capturing section type conflicts between #pragma clang section and section attributes

2020-04-28 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas marked 4 inline comments as done.
pratlucas added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:3008
+/// Insertion operator for diagnostics.
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,

rnk wrote:
> It seems like there is no need for this to be defined inline, since it is 
> presumably cold code.
The `inline`'s purpose here is just to allow the definition in the header file, 
avoiding multiple definition errors.



Comment at: clang/test/Sema/pragma-clang-section.c:28
+const int y __attribute__((section("myrodata.5"))) = 10; // expected-note 
{{declared here}}
+#pragma clang section data = "myrodata.5"// expected-error 
{{this causes a section type conflict with 'y'}}
+

rnk wrote:
> Please add a case like:
>   const int y __attribute__((section("myrodata.6"))) = 11;
> There should be no diagnostics in this case, and I expect myrodata.6 to 
> override the pragma, since it is more specific to the declaration.
I've added this case to the test.
The overriding behaviour is already checked by 
`clang/test/CodeGen/clang-sections-attribute.c`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78573



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


[PATCH] D78573: [Clang][Sema] Capturing section type conflicts between #pragma clang section and section attributes

2020-04-28 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 260630.
pratlucas added a comment.

Updateing test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78573

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/pragma-clang-section.c

Index: clang/test/Sema/pragma-clang-section.c
===
--- clang/test/Sema/pragma-clang-section.c
+++ clang/test/Sema/pragma-clang-section.c
@@ -22,4 +22,10 @@
 #pragma clang section bss = "myrodata.1"   // expected-error {{this causes a section type conflict with a prior #pragma section}}
 #pragma clang section text = "mybss.3" // expected-error {{this causes a section type conflict with a prior #pragma section}}
 
+#pragma clang section rodata = "myrodata.4"  // expected-note {{#pragma entered here}}
+int x __attribute__((section("myrodata.4")));// expected-error {{'x' causes a section type conflict with a prior #pragma section}}
+const int y __attribute__((section("myrodata.5"))) = 10; // expected-note {{declared here}}
+#pragma clang section data = "myrodata.5"// expected-error {{this causes a section type conflict with 'y'}}
+const int z __attribute__((section("myrodata.6"))) = 11;
+
 int a;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12754,7 +12754,7 @@
   if (GlobalStorage && var->isThisDeclarationADefinition() &&
   !inTemplateInstantiation()) {
 PragmaStack *Stack = nullptr;
-int SectionFlags = ASTContext::PSF_Implicit | ASTContext::PSF_Read;
+int SectionFlags = ASTContext::PSF_Read;
 if (var->getType().isConstQualified())
   Stack = &ConstSegStack;
 else if (!var->getInit()) {
@@ -12764,14 +12764,19 @@
   Stack = &DataSegStack;
   SectionFlags |= ASTContext::PSF_Write;
 }
-if (Stack->CurrentValue && !var->hasAttr())
+if (const SectionAttr *SA = var->getAttr()) {
+  if (SA->getSyntax() == AttributeCommonInfo::AS_Declspec)
+SectionFlags |= ASTContext::PSF_Implicit;
+  UnifySection(SA->getName(), SectionFlags, var);
+} else if (Stack->CurrentValue) {
+  SectionFlags |= ASTContext::PSF_Implicit;
+  auto SectionName = Stack->CurrentValue->getString();
   var->addAttr(SectionAttr::CreateImplicit(
-  Context, Stack->CurrentValue->getString(),
-  Stack->CurrentPragmaLocation, AttributeCommonInfo::AS_Pragma,
-  SectionAttr::Declspec_allocate));
-if (const SectionAttr *SA = var->getAttr())
-  if (UnifySection(SA->getName(), SectionFlags, var))
+  Context, SectionName, Stack->CurrentPragmaLocation,
+  AttributeCommonInfo::AS_Pragma, SectionAttr::Declspec_allocate));
+  if (UnifySection(SectionName, SectionFlags, var))
 var->dropAttr();
+}
 
 // Apply the init_seg attribute if this has an initializer.  If the
 // initializer turns out to not be dynamic, we'll end up ignoring this
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -471,42 +471,49 @@
 bool Sema::UnifySection(StringRef SectionName,
 int SectionFlags,
 DeclaratorDecl *Decl) {
-  auto Section = Context.SectionInfos.find(SectionName);
-  if (Section == Context.SectionInfos.end()) {
+  SourceLocation PragmaLocation;
+  if (auto A = Decl->getAttr())
+if (A->isImplicit())
+  PragmaLocation = A->getLocation();
+  auto SectionIt = Context.SectionInfos.find(SectionName);
+  if (SectionIt == Context.SectionInfos.end()) {
 Context.SectionInfos[SectionName] =
-ASTContext::SectionInfo(Decl, SourceLocation(), SectionFlags);
+ASTContext::SectionInfo(Decl, PragmaLocation, SectionFlags);
 return false;
   }
   // A pre-declared section takes precedence w/o diagnostic.
-  if (Section->second.SectionFlags == SectionFlags ||
-  !(Section->second.SectionFlags & ASTContext::PSF_Implicit))
+  const auto &Section = SectionIt->second;
+  if (Section.SectionFlags == SectionFlags ||
+  ((SectionFlags & ASTContext::PSF_Implicit) &&
+   !(Section.SectionFlags & ASTContext::PSF_Implicit)))
 return false;
-  auto OtherDecl = Section->second.Decl;
-  Diag(Decl->getLocation(), diag::err_section_conflict)
-  << Decl << OtherDecl;
-  Diag(OtherDecl->getLocation(), diag::note_declared_at)
-  << OtherDecl->getName();
-  if (auto A = Decl->getAttr())
-if (A->isImplicit())
-  Diag(A->getLocation(), diag::note_pragma_entered_here);
-  if (auto A = OtherDecl->getAttr())
-if (A->isImplicit())
-  Diag(A->getLocation(), diag::note_pragma_entered_here);
+  Diag(Decl->getLocation(), d

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

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

What is the practical difference? Either way the end result will be the same. 
And given that I get to wait ages for reviews of my PCH changes I find it more 
likely to get a review for a small patch rather than a large one.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D78995: [SveEmitter] NFCI: Describe splat operands like any other modifier

2020-04-28 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked an inline comment as done.
sdesmalen added a comment.

Thanks for having a look @SjoerdMeijer




Comment at: clang/utils/TableGen/SveEmitter.cpp:68
   TypeSpec TS;
+  bool IsSplat;
   bool Float, Signed, Immediate, Void, Constant, Pointer;

SjoerdMeijer wrote:
> I was wondering if IsSplat belongs here or somewhere else. It doesn't sound 
> like a type, like the other members do, but more a specific case of a vector? 
> But saying this off the top of my head, haven't looked at the code and the 
> context, but perhaps you can comment on this if this is where it should be or 
> not.
This is for type modifiers like `a` which is defined as:
  a: scalar of element type (splat to vector type)

which is used in the definition of the `_n` forms of builtins like:
  svuint16_t svadd_n_u16_z(svbool_t pg, svuint16_t op1, uint16_t op2)

Here `op2` is `uint16_t` instead of `svuint16_t`. This operand is conceptually 
splat to a SVE vector for the operation (that is what the instruction will do). 
This is also how we implement it in CGBuiltin, because there is only a LLVM IR 
intrinsic for the (vector, vector) form. In CodeGen we may map the (vector, 
vector) form back onto a (vector, imm) instruction if the value fits the 
immediate.

Because it is part of the modifier, I thought it made sense to add that 
information to SVEType so that `applyModifier` can set that property, avoiding 
the very opaque `Proto.find_first_of("ajfrKLR")` in `hasSplat` to determine 
this. Maybe it isn't strictly part of the type (although you can probably also 
argue it kind of is), but in any case I thought might make the code a bit more 
readable because now all such information can live in one place 
(`applyModifier`).


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

https://reviews.llvm.org/D78995



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


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

2020-04-28 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Once you do that, maybe you could send another message to the cfe-dev mailing 
list to ask for reviewers who have interest into optimizing PCH? I do, but I 
don't have the deep knowledge of this code.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D78985: [clang-tidy] NFC: Cleanup Python scripts

2020-04-28 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

In D78985#2007715 , @kbobyrev wrote:

> In D78985#2007669 , @Eugene.Zelenko 
> wrote:
>
> > It would be great to also run Flake9 and PyLint.
>
>
> Those were actually from pylint. That's a good idea, but I didn't fix all the 
> warnings there and while I might get back to this in the future I don't think 
> it's in the scope of this patch as this is a pretty trivial NFC cleanup.


If number of PyLint warnings (excluding identifiers naming) is not too big, it 
may make sense to clean-up in one commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78985



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


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

2020-04-28 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

To ease reviewers comprehension you have to propose patches that diff against 
the master. People sometimes apply the patches locally before accepting them.
This current patch is a subtraction after D69778 
 is applied locally on master. It seems a bit 
complicated.

I think it is better if you closed this, and applied all the changes you mean 
to do on D69778  and re-open. I think it is a 
good patch, it was already accepted, you only need to demonstrate that the edge 
cases where it was failing are solved.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D79008: [clang-format] insert space after C# keyword var in var (key, value)

2020-04-28 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe created this revision.
jbcoe added reviewers: krasimir, MyDeveloperDay.
jbcoe added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79008

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -698,6 +698,7 @@
   verifyFormat(R"(Result this[Index x] => Foo(x);)", Style);
 
   verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style);
+  verifyFormat(R"(var (key, value))", Style);
 
   // Not seen as a C-style cast.
   verifyFormat(R"(//
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3053,6 +3053,10 @@
 if (Left.is(TT_CSharpNullConditionalLSquare))
   return Style.SpacesInSquareBrackets;
 
+// space after var in `var (key, value)`
+if (Left.is(Keywords.kw_var) && Right.is(tok::l_paren))
+  return true;
+
 // space between keywords and paren e.g. "using ("
 if (Right.is(tok::l_paren))
   if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -698,6 +698,7 @@
   verifyFormat(R"(Result this[Index x] => Foo(x);)", Style);
 
   verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style);
+  verifyFormat(R"(var (key, value))", Style);
 
   // Not seen as a C-style cast.
   verifyFormat(R"(//
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3053,6 +3053,10 @@
 if (Left.is(TT_CSharpNullConditionalLSquare))
   return Style.SpacesInSquareBrackets;
 
+// space after var in `var (key, value)`
+if (Left.is(Keywords.kw_var) && Right.is(tok::l_paren))
+  return true;
+
 // space between keywords and paren e.g. "using ("
 if (Right.is(tok::l_paren))
   if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79009: [AST] Preserve the incomplete-type member expr.

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79009

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-recovery.cpp


Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -104,6 +104,16 @@
 // CHECK-NEXT:|   `-UnresolvedLookupExpr {{.*}} 'invalid'
 struct alignas(invalid()) Aligned {};
 
+struct Incomplete;
+Incomplete make_incomplete();
+// CHECK: FunctionDecl {{.*}} test2
+// CHECK-NEXT: `-CompoundStmt
+// CHECK-NEXT:  `-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:   `-UnresolvedLookupExpr {{.*}} 'make_incomplete'
+void test2() {
+  make_incomplete();
+}
+
 void InvalidInitalizer(int x) {
   struct Bar { Bar(); };
   // CHECK: `-VarDecl {{.*}} a1 'Bar'
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7219,8 +7219,11 @@
   //   the member function body.
   if (!BaseType->isDependentType() &&
   !isThisOutsideMemberFunctionBody(BaseType) &&
-  RequireCompleteType(OpLoc, BaseType, diag::err_incomplete_member_access))
+  RequireCompleteType(OpLoc, BaseType, 
diag::err_incomplete_member_access)) {
+if (Base->containsErrors())
+  return Base;
 return ExprError();
+  }
 
   // C++ [basic.lookup.classref]p2:
   //   If the id-expression in a class member access (5.2.5) is an


Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -104,6 +104,16 @@
 // CHECK-NEXT:|   `-UnresolvedLookupExpr {{.*}} 'invalid'
 struct alignas(invalid()) Aligned {};
 
+struct Incomplete;
+Incomplete make_incomplete();
+// CHECK: FunctionDecl {{.*}} test2
+// CHECK-NEXT: `-CompoundStmt
+// CHECK-NEXT:  `-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:   `-UnresolvedLookupExpr {{.*}} 'make_incomplete'
+void test2() {
+  make_incomplete();
+}
+
 void InvalidInitalizer(int x) {
   struct Bar { Bar(); };
   // CHECK: `-VarDecl {{.*}} a1 'Bar'
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7219,8 +7219,11 @@
   //   the member function body.
   if (!BaseType->isDependentType() &&
   !isThisOutsideMemberFunctionBody(BaseType) &&
-  RequireCompleteType(OpLoc, BaseType, diag::err_incomplete_member_access))
+  RequireCompleteType(OpLoc, BaseType, diag::err_incomplete_member_access)) {
+if (Base->containsErrors())
+  return Base;
 return ExprError();
+  }
 
   // C++ [basic.lookup.classref]p2:
   //   If the id-expression in a class member access (5.2.5) is an
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79012: [AST] Fix a crash on a dependent vector_size attribute

2020-04-28 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: erichkeane, aaron.ballman.
Herald added subscribers: ributzka, dexonsmith, jkorous.

Looks like this was just a copy & paste mistake from 
`getDependentSizedExtVectorType`.

rdar://60092165


Repository:
  rC Clang

https://reviews.llvm.org/D79012

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


Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -475,3 +475,12 @@
 #endif // __cplusplus >= 201103L
 }
 }
+
+namespace rdar60092165 {
+template  void f() {
+  typedef T first_type __attribute__((vector_size(sizeof(T) * 4)));
+  typedef T second_type __attribute__((vector_size(sizeof(T) * 4)));
+
+  second_type st;
+}
+}
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -3694,10 +3694,10 @@
   (void)CanonCheck;
   DependentVectorTypes.InsertNode(New, InsertPos);
 } else {
-  QualType CanonExtTy = getDependentSizedExtVectorType(CanonVecTy, 
SizeExpr,
-   SourceLocation());
+  QualType CanonTy = getDependentVectorType(CanonVecTy, SizeExpr,
+SourceLocation(), VecKind);
   New = new (*this, TypeAlignment) DependentVectorType(
-  *this, VecType, CanonExtTy, SizeExpr, AttrLoc, VecKind);
+  *this, VecType, CanonTy, SizeExpr, AttrLoc, VecKind);
 }
   }
 


Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -475,3 +475,12 @@
 #endif // __cplusplus >= 201103L
 }
 }
+
+namespace rdar60092165 {
+template  void f() {
+  typedef T first_type __attribute__((vector_size(sizeof(T) * 4)));
+  typedef T second_type __attribute__((vector_size(sizeof(T) * 4)));
+
+  second_type st;
+}
+}
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -3694,10 +3694,10 @@
   (void)CanonCheck;
   DependentVectorTypes.InsertNode(New, InsertPos);
 } else {
-  QualType CanonExtTy = getDependentSizedExtVectorType(CanonVecTy, SizeExpr,
-   SourceLocation());
+  QualType CanonTy = getDependentVectorType(CanonVecTy, SizeExpr,
+SourceLocation(), VecKind);
   New = new (*this, TypeAlignment) DependentVectorType(
-  *this, VecType, CanonExtTy, SizeExpr, AttrLoc, VecKind);
+  *this, VecType, CanonTy, SizeExpr, AttrLoc, VecKind);
 }
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73951: [Clang] [Driver]Add logic to search for flang frontend

2020-04-28 Thread Steve Scalpone via Phabricator via cfe-commits
sscalpone added a comment.

type in the commit message: //esle// the frontend name is hard-coded to 
"flang", use that to


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73951



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


[PATCH] D79008: [clang-format] insert space after C# keyword var in var (key, value)

2020-04-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM, thank you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79008



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


[PATCH] D78118: [analyzer] StdLibraryFunctionsChecker: Add option to display loaded summaries

2020-04-28 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 260647.
martong added a comment.

- Rebase to master
- Add the option to the lit test analyzer-config.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78118

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
  clang/test/Analysis/std-c-library-functions.c

Index: clang/test/Analysis/std-c-library-functions.c
===
--- clang/test/Analysis/std-c-library-functions.c
+++ clang/test/Analysis/std-c-library-functions.c
@@ -1,6 +1,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false \
 // RUN:   -triple i686-unknown-linux \
@@ -9,6 +10,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false \
 // RUN:   -triple x86_64-unknown-linux \
@@ -17,6 +19,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false \
 // RUN:   -triple armv7-a15-linux \
@@ -25,6 +28,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false \
 // RUN:   -triple thumbv7-a15-linux \
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
@@ -2,6 +2,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false \
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -3,6 +3,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -triple x86_64-unknown-linux-gnu \
@@ -13,6 +14,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -triple x86_64-unknown-linux-gnu \
Index: clang/test/Analysis/analyzer-config.c
===
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -11,6 +11,7 @@
 // CHECK-NEXT: alpha.security.MmapWriteExec:MmapProtExec = 0x04
 // CHECK-NEXT: alpha.security.MmapWriteExec:MmapProtRead = 0x01
 // CHECK-NEXT: alpha.security.taint.TaintPropagation:Config = ""
+// CHECK-NEXT: apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries = false
 // CHECK-NEXT: apply-fixits = false
 // CHECK-NEXT: avoid-suppressing-null-argument-paths = false
 // CHECK-NEXT: c++-allocator-inlining = true
@@ -106,4 +107,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats

[PATCH] D79000: [clang-format] C# property formatting can be controlled by config options

2020-04-28 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Do you think we need to support

  verifyFormat(R"(//
  public class SaleItem {
public decimal Price
{ 
  get; 
  set; 
 }
  })"Style);

Is that currently possible, and what if users actually want?

  public string Host { set; get; }

Do you think we need an option to support variations?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79000



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


[PATCH] D73951: [Clang] [Driver]Add logic to search for flang frontend

2020-04-28 Thread Steve Scalpone via Phabricator via cfe-commits
sscalpone added inline comments.



Comment at: clang/test/Driver/flang/flang-driver-2-frontend01.f90:1
+! Check wich name of flang frontend is invoked by the driver
+

typo //wich//



Comment at: clang/test/Driver/flang/flang-driver-2-frontend02.f90:1
+! Check wich name of flang frontend is invoked by the driver
+

Typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73951



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


[PATCH] D78938: Fixing all comparisons for C++20 compilation.

2020-04-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D78938#2007571 , @BRevzin wrote:

> In D78938#2007037 , @dblaikie wrote:
>
> > (peanut gallery: I'd consider, while you're touching these all anyway, 
> > changing them all to non-member (friended where required) as I believe 
> > that's best practice - allows equal implicit conversions on either side, 
> > for instance (even if some types have no implicit conversions - it at least 
> > provides a nice consistency/examples that people are likely to copy from))
>
>
> Hidden friend is probably the best way to write comparisons in C++17 and 
> earlier, but I'm not sure that will hold in C++20 (even if LLVM isn't on 
> C++20 and won't be for I imagine quite some time). With reversed candidates, 
> I think member functions might be the way to go there - you still get 
> implicit conversions on either side (just not on both sides at the same time) 
> and hidden friends... are kind of weird, to be honest.


Yeah, probably just experience with things the way they've been, but the 
symmetry is kind of nice without relying on deeper aspects of the newer 
features (& the benefit of the code being more suitable for C++17, where LLVM 
is currently).

> Also, I didn't touch all of them - only the ones that break in C++20 (a lot 
> of which just missing a `const`). A lot of comparison operators are already 
> fine. I'm not sure it's worth changing them just to look the same.

Yeah - just meant the ones you are touching, might be nice to move them in that 
direction.

Anyway, I'll leave it to you/other reviewers - no /super/ strong feelings here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78938



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


[PATCH] D78118: [analyzer] StdLibraryFunctionsChecker: Add option to display loaded summaries

2020-04-28 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 260651.
martong added a comment.

- Better description for the option in Checkers.td


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78118

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
  clang/test/Analysis/std-c-library-functions.c

Index: clang/test/Analysis/std-c-library-functions.c
===
--- clang/test/Analysis/std-c-library-functions.c
+++ clang/test/Analysis/std-c-library-functions.c
@@ -1,6 +1,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false \
 // RUN:   -triple i686-unknown-linux \
@@ -9,6 +10,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false \
 // RUN:   -triple x86_64-unknown-linux \
@@ -17,6 +19,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false \
 // RUN:   -triple armv7-a15-linux \
@@ -25,6 +28,7 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false \
 // RUN:   -triple thumbv7-a15-linux \
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
@@ -2,6 +2,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-config eagerly-assume=false \
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -3,6 +3,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -triple x86_64-unknown-linux-gnu \
@@ -13,6 +14,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries=true \
 // RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -triple x86_64-unknown-linux-gnu \
Index: clang/test/Analysis/analyzer-config.c
===
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -11,6 +11,7 @@
 // CHECK-NEXT: alpha.security.MmapWriteExec:MmapProtExec = 0x04
 // CHECK-NEXT: alpha.security.MmapWriteExec:MmapProtRead = 0x01
 // CHECK-NEXT: alpha.security.taint.TaintPropagation:Config = ""
+// CHECK-NEXT: apiModeling.StdCLibraryFunctions:DisplayLoadedSummaries = false
 // CHECK-NEXT: apply-fixits = false
 // CHECK-NEXT: avoid-suppressing-null-argument-paths = false
 // CHECK-NEXT: c++-allocator-inlining = true
@@ -106,4 +107,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: n

[PATCH] D78118: [analyzer] StdLibraryFunctionsChecker: Add option to display loaded summaries

2020-04-28 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D78118#1981592 , @Szelethus wrote:

> This is a great idea, but the tests just seem to, well, test the new 
> functionality?
>
> On a different issue, take a look at how certain help related frontend flags 
> (not `-analyzer-config` ones!) skip the analysis, like 
> `-analyzer-checker-help`, or `-analyzer-list-enabled-checkers`. If I were to 
> set `DisplayLoadedSummaries` to true, most probably I'd only be interested in 
> the capabilities of the checker, not the analysis itself. Though, I don't 
> have an out-of-the-box solution that could work here, unless we outright emit 
> an error in the checker registry function. That wouldn't be very nice, would 
> it? :^) So, for the time being, regard this as me thinking aloud.


This new config option will simply list the (found) functions that have a 
summary based check enabled. This can be different for each TU. If a function 
cannot be looked up in a TU then we will never use its summary.
On the other hand, yes, it would be a good idea to have an option to list all 
the configured summaries. This list would be the same for each TU. Do you mind 
if I'd do that rather in another patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78118



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


[PATCH] D78118: [analyzer] StdLibraryFunctionsChecker: Add option to display loaded summaries

2020-04-28 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:299
+  "DisplayLoadedSummaries",
+  "If set to true, the checker displays all loaded summaries.",
+  "false",

Szelethus wrote:
> I see what you mean, but "loaded" is a bit ambiguous unless you know how the 
> checker operates.
Yeah, okay, what about "the found summaries" or "applicable summaries" or "? 
This list can  be different for every TU. So I am adding "... for the 
translation unit".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78118



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


[clang] e770153 - [AArch64] Add support for -ffixed-x30

2020-04-28 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2020-04-28T08:48:28-07:00
New Revision: e770153865c53c4fd72a68f23acff33c24e42a08

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

LOG: [AArch64] Add support for -ffixed-x30

Add support for reserving LR in:

* the driver through `-ffixed-x30`
* cc1 through `-target-feature +reserve-x30`
* the backend through `-mattr=+reserve-x30`
* a subtarget feature `reserve-x30`

the same way we're doing for the other registers.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/aarch64-fixed-x-register.c
llvm/lib/Target/AArch64/AArch64.td
llvm/test/CodeGen/AArch64/arm64-platform-reg.ll

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 4c034d40aaf4..e71655bcbb97 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -409,6 +409,9 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
   if (Args.hasArg(options::OPT_ffixed_x28))
 Features.push_back("+reserve-x28");
 
+  if (Args.hasArg(options::OPT_ffixed_x30))
+Features.push_back("+reserve-x30");
+
   if (Args.hasArg(options::OPT_fcall_saved_x8))
 Features.push_back("+call-saved-x8");
 

diff  --git a/clang/test/Driver/aarch64-fixed-x-register.c 
b/clang/test/Driver/aarch64-fixed-x-register.c
index ed8e7c2013db..52f62e68ef59 100644
--- a/clang/test/Driver/aarch64-fixed-x-register.c
+++ b/clang/test/Driver/aarch64-fixed-x-register.c
@@ -94,6 +94,10 @@
 // RUN: FileCheck --check-prefix=CHECK-FIXED-X28 < %t %s
 // CHECK-FIXED-X28: "-target-feature" "+reserve-x28"
 
+// RUN: %clang -target aarch64-none-gnu -ffixed-x30 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FIXED-X30 < %t %s
+// CHECK-FIXED-X30: "-target-feature" "+reserve-x30"
+
 // Test multiple of reserve-x# options together.
 // RUN: %clang -target aarch64-none-gnu \
 // RUN: -ffixed-x1 \

diff  --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index d2ab0ff898aa..e99f69247a4e 100644
--- a/llvm/lib/Target/AArch64/AArch64.td
+++ b/llvm/lib/Target/AArch64/AArch64.td
@@ -142,7 +142,7 @@ def FeatureStrictAlign : SubtargetFeature<"strict-align",
   "Disallow all unaligned memory "
   "access">;
 
-foreach i = {1-7,9-15,18,20-28} in
+foreach i = {1-7,9-15,18,20-28,30} in
 def FeatureReserveX#i : SubtargetFeature<"reserve-x"#i, 
"ReserveXRegister["#i#"]", "true",
  "Reserve X"#i#", making it 
unavailable "
  "as a GPR">;

diff  --git a/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll 
b/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
index 42448fcce56c..89fc6457482f 100644
--- a/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
@@ -29,6 +29,7 @@
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x26 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X26
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x27 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X27
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x28 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X28
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x30 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X30
 
 ; Test multiple of reserve-x# options together.
 ; RUN: llc -mtriple=arm64-linux-gnu \
@@ -67,6 +68,7 @@
 ; RUN: -mattr=+reserve-x26 \
 ; RUN: -mattr=+reserve-x27 \
 ; RUN: -mattr=+reserve-x28 \
+; RUN: -mattr=+reserve-x30 \
 ; RUN: -o - %s | FileCheck %s \
 ; RUN: --check-prefix=CHECK-RESERVE \
 ; RUN: --check-prefix=CHECK-RESERVE-X1 \
@@ -92,7 +94,8 @@
 ; RUN: --check-prefix=CHECK-RESERVE-X25 \
 ; RUN: --check-prefix=CHECK-RESERVE-X26 \
 ; RUN: --check-prefix=CHECK-RESERVE-X27 \
-; RUN: --check-prefix=CHECK-RESERVE-X28
+; RUN: --check-prefix=CHECK-RESERVE-X28 \
+; RUN: --check-prefix=CHECK-RESERVE-X30
 
 ; x18 is reserved as a platform register on Darwin but not on other
 ; systems. Create loads of register pressure and make sure this is respected.
@@ -134,6 +137,7 @@ define void @keep_live() {
 ; CHECK-RESERVE-X26-NOT: ldr x26
 ; CHECK-RESERVE-X27-NOT: ldr x27
 ; CHECK-RESERVE-X28-NOT: ldr x28
+; CHECK-RESERVE-X30-NOT: ldr x30
 ; CHECK-RESERVE: Spill
 ; CHECK-RESERVE-NOT: ldr fp
 ; CHECK-RESERVE-X1-NOT: ldr x1,
@@ -160,6 +164,7 @@ define void @keep_live() {
 ; CHECK-RESERVE-X26-NOT: ldr x26
 ; CHECK-RESERVE-X27-NOT: ldr x27
 ; CHECK-RESERVE-X28-NOT: ldr x28
+; CHECK-RESERVE-X30-NOT: ldr x30
 ; CHECK-RESERVE: ret
   ret void
 }



__

Re: [PATCH] D77792: [analyzer] Extend constraint manager to be able to compare simple SymSymExprs

2020-04-28 Thread Denis Petrov via cfe-commits
Welcome to my another idea to improve RangeConstraintManager? 
https://reviews.llvm.org/D78933



Denys Petrov
Senior С++ Developer | Kharkiv, Ukraine


От: Balazs Benics via Phabricator 
Отправлено: 10 апреля 2020 г. 15:53
Кому: benicsbal...@gmail.com; noqnoq...@gmail.com; adam.bal...@ericsson.com; 
dabis.csab...@gmail.com; dkszelet...@gmail.com
Копия: richard.sza...@ericsson.com; xazax@gmail.com; 
peterszecs...@gmail.com; rekanikol...@gmail.com; a.sido...@samsung.com; 
mikhail.rama...@gmail.com; donat.n...@ericsson.com; daniel.kr...@ericsson.com; 
martongab...@gmail.com; Denis Petrov; cfe-commits@lists.llvm.org; 
mlek...@skidmore.edu; blitzrak...@gmail.com; shen...@google.com; 
1.in...@gmail.com
Тема: [PATCH] D77792: [analyzer] Extend constraint manager to be able to 
compare simple SymSymExprs

CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.  If you suspect potential phishing or spam email, report it to 
reports...@accesssoftek.com

steakhal updated this revision to Diff 256551.
steakhal added a comment.

- rewritten the `RangeSet::compare` function and checked the assumptions on 
WolframAlpha
- moved the `RangeSet::compare` function to a cpp file
- added comments to the `RangeSet::compare` function
- fixed the comment in `RangeConstraintManager::canReasonAbout` function
- introduced the `RangeSet::CompareResult::identical` enum value to be complete
- updated the `RangeConstraintManager::tryAssumeSymSymOp` accoding the 
`identical` CompareResult.
- omited testing the `[2,5] < [5,10]` testcase, since that is covered by `[0,5] 
< [5,10]`


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

https://reviews.llvm.org/D77792

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/test/Analysis/constraint-manager-sym-sym.c

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


[clang] 102b410 - [CMSE] Clear padding bits of struct/unions/fp16 passed by value

2020-04-28 Thread Momchil Velikov via cfe-commits

Author: Momchil Velikov
Date: 2020-04-28T17:05:58+01:00
New Revision: 102b4105e3fd568ed2c758ed7e6fd266a819d6db

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

LOG: [CMSE] Clear padding bits of struct/unions/fp16 passed by value

When passing a value of a struct/union type from secure to non-secure
state (that is returning from a CMSE entry function or passing an
argument to CMSE-non-secure call), there is a potential sensitive
information leak via the padding bits in the structure. It is not
possible in the general case to ensure those bits are cleared by using
Standard C/C++.

This patch makes the compiler emit code to clear such padding
bits. Since type information is lost in LLVM IR, the code generation
is done by Clang.

For each interesting record type, we build a bitmask, in which all the
bits, corresponding to user declared members, are set. Values of
record types are returned by coercing them to an integer. After the
coercion, the coerced value is masked (with bitwise AND) and then
returned by the function. In a similar manner, values of record types
are passed as arguments by coercing them to an array of integers, and
the coerced values themselves are masked.

For union types, we effectively clear only bits, which aren't part of
any member, since we don't know which is the currently active one.
The compiler will issue a warning, whenever a union is passed to
non-secure state.

Values of half-precision floating-point types are passed in the least
significant bits of a 32-bit register (GPR or FPR) with the most
significant bits unspecified. Since this is also a potential leak of
sensitive information, this patch also clears those unspecified bits.

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

Added: 
clang/test/CodeGen/cmse-clear-arg.c
clang/test/CodeGen/cmse-clear-fp16.c
clang/test/CodeGen/cmse-clear-return.c
clang/test/Sema/arm-cmse-no-diag.c

Modified: 
clang/include/clang/AST/Decl.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaStmt.cpp
clang/test/Sema/arm-cmse.c

Removed: 




diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 2af1189511a3..7db74e0803ce 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -3961,6 +3961,11 @@ class RecordDecl : public TagDecl {
 return cast_or_null(TagDecl::getDefinition());
   }
 
+  /// Returns whether this record is a union, or contains (at any nesting 
level)
+  /// a union member. This is used by CMSE to warn about possible information
+  /// leaks.
+  bool isOrContainsUnion() const;
+
   // Iterator access to field members. The field iterator only visits
   // the non-static data members of this class, ignoring any static
   // data members, functions, constructors, destructors, etc.

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 9c1b6c593857..c0316f5d7834 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3123,6 +3123,10 @@ def warn_weak_identifier_undeclared : Warning<
 def warn_attribute_cmse_entry_static : Warning<
   "'cmse_nonsecure_entry' cannot be applied to functions with internal 
linkage">,
   InGroup;
+def warn_cmse_nonsecure_union : Warning<
+  "passing union across security boundary via %select{parameter %1|return 
value}0 "
+  "may leak information">,
+  InGroup>;
 def err_attribute_weak_static : Error<
   "weak declaration cannot have internal linkage">;
 def err_attribute_selectany_non_extern_data : Error<

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 055b9c6d37ba..9c1b99d30e78 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -4410,6 +4410,21 @@ void RecordDecl::setCapturedRecord() {
   addAttr(CapturedRecordAttr::CreateImplicit(getASTContext()));
 }
 
+bool RecordDecl::isOrContainsUnion() const {
+  if (isUnion())
+return true;
+
+  if (const RecordDecl *Def = getDefinition()) {
+for (const FieldDecl *FD : Def->fields()) {
+  const RecordType *RT = FD->getType()->getAs();
+  if (RT && RT->getDecl()->isOrContainsUnion())
+return true;
+}
+  }
+
+  return false;
+}
+
 RecordDecl::field_iterator RecordDecl::field_begin() const {
   if (hasExternalLexicalStorage() && !hasLoadedFieldsFromExternalStorage())
 LoadFieldsFromExternalStorage();

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index e0e895f202c2..7672d95219fa 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/

[PATCH] D78118: [analyzer] StdLibraryFunctionsChecker: Add option to display loaded summaries

2020-04-28 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D78118#1988464 , @balazske wrote:

> The new option will simply list the (found) functions that have a summary 
> based check enabled. (The term "Loaded" may be misleading in the current 
> implementation, somebody can think if it is loaded from file?) A more 
> detailed output would be better (display the signature too, or maybe the 
> whole summary?). For simple purpose the current way may be enough but it may 
> be useful (probably for a non-checker-developer too) to see the summary 
> details.


Yes, "loaded" might not be the best, I changed it to "found". About the more 
detailed output: is there a way to dump nicely the signature of a function 
decl? I don't want to dump the AST of it because that might be overkill. Could 
I just dump the content of the buffer that relates to the SourceRange of the 
FunctionDecl (if that does not have a definition)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78118



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


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

2020-04-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

(updating the previous review has the advantage that reviewers can review the 
diff relative to the previous version of the patch, using Phabricator's 
"History" feature, so they can review the delta since the committed/reverted 
version)


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-28 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 260657.
baloghadamsoftware added a comment.

Getting the type of parameter regions has no crashes on the test suite.


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

https://reviews.llvm.org/D77229

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/test/Analysis/container-modeling.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/Analysis/iterator-modeling.cpp
  clang/test/Analysis/temporaries.cpp

Index: clang/test/Analysis/temporaries.cpp
===
--- clang/test/Analysis/temporaries.cpp
+++ clang/test/Analysis/temporaries.cpp
@@ -890,12 +890,9 @@
 public:
   ~C() {
 glob = 1;
-// FIXME: Why is destructor not inlined in C++17
 clang_analyzer_checkInlined(true);
 #ifdef TEMPORARY_DTORS
-#if __cplusplus < 201703L
-// expected-warning@-3{{TRUE}}
-#endif
+// expected-warning@-2{{TRUE}}
 #endif
   }
 };
@@ -914,16 +911,11 @@
   // temporaries returned from functions, so we took the wrong branch.
   coin && is(get()); // no-crash
   if (coin) {
-// FIXME: Why is destructor not inlined in C++17
 clang_analyzer_eval(glob);
 #ifdef TEMPORARY_DTORS
-#if __cplusplus < 201703L
-// expected-warning@-3{{TRUE}}
-#else
-// expected-warning@-5{{UNKNOWN}}
-#endif
+// expected-warning@-2{{TRUE}}
 #else
-// expected-warning@-8{{UNKNOWN}}
+// expected-warning@-4{{UNKNOWN}}
 #endif
   } else {
 // The destructor is not called on this branch.
Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1862,7 +1862,7 @@
 void clang_analyzer_printState();
 
 void print_state(std::vector &V) {
-  const auto i0 = V.cbegin();
+  auto i0 = V.cbegin();
   clang_analyzer_printState();
 
 // CHECK:  "checker_messages": [
@@ -1871,7 +1871,8 @@
 // CHECK-NEXT: "i0 : Valid ; Container == SymRegion{reg_$[[#]] & V>} ; Offset == conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]}"
 // CHECK-NEXT:   ]}
 
-  const auto i1 = V.cend();
+  ++i0;
+  auto i1 = V.cend();
   clang_analyzer_printState();
   
 // CHECK:  "checker_messages": [
@@ -1879,4 +1880,6 @@
 // CHECK-NEXT: "Iterator Positions :",
 // CHECK-NEXT: "i1 : Valid ; Container == SymRegion{reg_$[[#]] & V>} ; Offset == conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]}"
 // CHECK-NEXT:   ]}
+
+  --i1;
 }
Index: clang/test/Analysis/explain-svals.cpp
===
--- clang/test/Analysis/explain-svals.cpp
+++ clang/test/Analysis/explain-svals.cpp
@@ -93,6 +93,6 @@
 } // end of anonymous namespace
 
 void test_6() {
-  clang_analyzer_explain(conjure_S()); // expected-warning-re^lazily frozen compound value of temporary object constructed at statement 'conjure_S\(\)'$
+  clang_analyzer_explain(conjure_S()); // expected-warning-re^lazily frozen compound value of parameter 0 of function 'clang_analyzer_explain\(\)'$
   clang_analyzer_explain(conjure_S().z); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure_S\(\)'\) for field 'z' of temporary object constructed at statement 'conjure_S\(\)'$
 }
Index: clang/test/Analysis/container-modeling.cpp
===
--- clang/test/Analysis/container-modeling.cpp
+++ clang/test/Analysis/container-modeling.cpp
@@ -17,7 +17,7 @@
 void clang_analyzer_warnIfReached();
 
 void begin(const std::vector &V) {
-  V.begin();
+  const auto i0 = V.begin();
 
   clang_a

[PATCH] D79014: [clangd] Move non-clang base pieces into separate support/ lib.

2020-04-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kbobyrev.
Herald added subscribers: cfe-commits, usaxena95, kadircet, jfb, arphaman, 
jkorous, MaskRay, javed.absar, ilya-biryukov, mgorny.
Herald added a project: clang.
sammccall added a comment.

Of the pieces I was unsure about:

- I didn't move `Protocol` - it's not a perfect fit, though it may still end up 
here
- I moved `FSProvider` but not `FS`
- I didn't move `URI` - I suspect that will *probably* end up wherever 
`Protocol` does, though it may belong in support even if protocol doesn't.


This enforces layering, reduces a sprawling clangd/ directory, and makes life
easier for embedders.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79014

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Cancellation.cpp
  clang-tools-extra/clangd/Cancellation.h
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/Context.cpp
  clang-tools-extra/clangd/Context.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/DraftStore.cpp
  clang-tools-extra/clangd/DraftStore.h
  clang-tools-extra/clangd/FS.h
  clang-tools-extra/clangd/FSProvider.cpp
  clang-tools-extra/clangd/FSProvider.h
  clang-tools-extra/clangd/FileDistance.cpp
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/Format.cpp
  clang-tools-extra/clangd/Function.h
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/clangd/HeaderSourceSwitch.cpp
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/Logger.cpp
  clang-tools-extra/clangd/Logger.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Path.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/Shutdown.cpp
  clang-tools-extra/clangd/Shutdown.h
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/Threading.cpp
  clang-tools-extra/clangd/Threading.h
  clang-tools-extra/clangd/Trace.cpp
  clang-tools-extra/clangd/Trace.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/fuzzer/clangd-fuzzer.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundIndexLoader.cpp
  clang-tools-extra/clangd/index/BackgroundIndexLoader.h
  clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/clangd/index/BackgroundQueue.cpp
  clang-tools-extra/clangd/index/BackgroundRebuild.cpp
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
  clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/clangd/support/CMakeLists.txt
  clang-tools-extra/clangd/sup

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

2020-04-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Yeah, I was confused by all this too - @aganea's right - this review doesn't 
make sense to me, since it doesn't show a proposed change to LLVM, it shows a 
proposed change on top of another patch, that would necessarily be committed 
together/in a single commit (a proposed change on top of another change that's 
part of a series of independently valid changes are quite different - such a 
patch series is generally encouraged to ensure small/isolated changes). Things 
that are going to be committed in a single commit should be reviewed as such.

Reopening the previous review, or starting a new one (including this one - but 
updating it to include all the changes you're proposing to commit together/a 
diff relative to the current upstream trunk/tip-of-tree) & linking to the old 
one for context, sounds suitable.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74846



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


[PATCH] D79000: [clang-format] C# property formatting can be controlled by config options

2020-04-28 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

I'm curious why we don't go the opposite direction -- why are even those two 
styles needed separately?

  public int Style1 { get; set }
  // vs.
  public int Style2
  { get; set }

I'm sure there is a good reason; part of this is to make sure we document it so 
we may consistently do more updates and support more complicated cases in the 
same spirit.
IMO starting with some reasonable formatting, and later supporting different 
styles as needed, has been practical to keep clang-format from becoming harder 
to maintain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79000



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-28 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 260659.
baloghadamsoftware added a comment.

Wrong diff uploaded previously.


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

https://reviews.llvm.org/D77229

Files:
  clang/include/clang/StaticAnalyzer/Checkers/SValExplainer.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Regions.def
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/STLAlgorithmModeling.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
  clang/test/Analysis/container-modeling.cpp
  clang/test/Analysis/explain-svals.cpp
  clang/test/Analysis/iterator-modeling.cpp
  clang/test/Analysis/temporaries.cpp

Index: clang/test/Analysis/temporaries.cpp
===
--- clang/test/Analysis/temporaries.cpp
+++ clang/test/Analysis/temporaries.cpp
@@ -890,12 +890,9 @@
 public:
   ~C() {
 glob = 1;
-// FIXME: Why is destructor not inlined in C++17
 clang_analyzer_checkInlined(true);
 #ifdef TEMPORARY_DTORS
-#if __cplusplus < 201703L
-// expected-warning@-3{{TRUE}}
-#endif
+// expected-warning@-2{{TRUE}}
 #endif
   }
 };
@@ -914,16 +911,11 @@
   // temporaries returned from functions, so we took the wrong branch.
   coin && is(get()); // no-crash
   if (coin) {
-// FIXME: Why is destructor not inlined in C++17
 clang_analyzer_eval(glob);
 #ifdef TEMPORARY_DTORS
-#if __cplusplus < 201703L
-// expected-warning@-3{{TRUE}}
-#else
-// expected-warning@-5{{UNKNOWN}}
-#endif
+// expected-warning@-2{{TRUE}}
 #else
-// expected-warning@-8{{UNKNOWN}}
+// expected-warning@-4{{UNKNOWN}}
 #endif
   } else {
 // The destructor is not called on this branch.
Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -1862,7 +1862,7 @@
 void clang_analyzer_printState();
 
 void print_state(std::vector &V) {
-  const auto i0 = V.cbegin();
+  auto i0 = V.cbegin();
   clang_analyzer_printState();
 
 // CHECK:  "checker_messages": [
@@ -1871,7 +1871,8 @@
 // CHECK-NEXT: "i0 : Valid ; Container == SymRegion{reg_$[[#]] & V>} ; Offset == conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]}"
 // CHECK-NEXT:   ]}
 
-  const auto i1 = V.cend();
+  ++i0;
+  auto i1 = V.cend();
   clang_analyzer_printState();
   
 // CHECK:  "checker_messages": [
@@ -1879,4 +1880,6 @@
 // CHECK-NEXT: "Iterator Positions :",
 // CHECK-NEXT: "i1 : Valid ; Container == SymRegion{reg_$[[#]] & V>} ; Offset == conj_$[[#]]{long, LC[[#]], S[[#]], #[[#]]}"
 // CHECK-NEXT:   ]}
+
+  --i1;
 }
Index: clang/test/Analysis/explain-svals.cpp
===
--- clang/test/Analysis/explain-svals.cpp
+++ clang/test/Analysis/explain-svals.cpp
@@ -93,6 +93,6 @@
 } // end of anonymous namespace
 
 void test_6() {
-  clang_analyzer_explain(conjure_S()); // expected-warning-re^lazily frozen compound value of temporary object constructed at statement 'conjure_S\(\)'$
+  clang_analyzer_explain(conjure_S()); // expected-warning-re^lazily frozen compound value of parameter 0 of function 'clang_analyzer_explain\(\)'$
   clang_analyzer_explain(conjure_S().z); // expected-warning-re^value derived from \(symbol of type 'int' conjured at statement 'conjure_S\(\)'\) for field 'z' of temporary object constructed at statement 'conjure_S\(\)'$
 }
Index: clang/test/Analysis/container-modeling.cpp
===
--- clang/test/Analysis/container-modeling.cpp
+++ clang/test/Analysis/container-modeling.cpp
@@ -17,7 +17,7 @@
 void clang_analyzer_warnIfReached();
 
 void begin(const std::vector &V) {
-  V.begin();
+  const auto i0 = V.begin();
 
   clang_analyzer_denote(clang_analyzer_container_

[PATCH] D79014: [clangd] Move non-clang base pieces into separate support/ lib.

2020-04-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Of the pieces I was unsure about:

- I didn't move `Protocol` - it's not a perfect fit, though it may still end up 
here
- I moved `FSProvider` but not `FS`
- I didn't move `URI` - I suspect that will *probably* end up wherever 
`Protocol` does, though it may belong in support even if protocol doesn't.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79014



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


[PATCH] D77792: [analyzer] Extend constraint manager to be able to compare simple SymSymExprs

2020-04-28 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@steakhal 
What about unsigneds? Does it work for unsigned values as well?


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

https://reviews.llvm.org/D77792



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


[PATCH] D76369: [CMSE] Clear padding bits of struct/unions/fp16 passed by value

2020-04-28 Thread Momchil Velikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG102b4105e3fd: [CMSE] Clear padding bits of 
struct/unions/fp16 passed by value (authored by chill).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76369

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CodeGen/cmse-clear-arg.c
  clang/test/CodeGen/cmse-clear-fp16.c
  clang/test/CodeGen/cmse-clear-return.c
  clang/test/Sema/arm-cmse-no-diag.c
  clang/test/Sema/arm-cmse.c

Index: clang/test/Sema/arm-cmse.c
===
--- clang/test/Sema/arm-cmse.c
+++ clang/test/Sema/arm-cmse.c
@@ -28,3 +28,30 @@
 void fn1() __attribute__((cmse_nonsecure_entry(1)));  // expected-error {{'cmse_nonsecure_entry' attribute takes no arguments}}
 
 typedef void (*fn2_t)() __attribute__((cmse_nonsecure_call("abc"))); // expected-error {{'cmse_nonsecure_call' attribute takes no argument}}
+
+union U { unsigned n; char b[4]; } u;
+
+union U xyzzy() __attribute__((cmse_nonsecure_entry)) {
+  return u; // expected-warning {{passing union across security boundary via return value may leak information}}
+}
+
+void (*fn2)(int, union U) __attribute__((cmse_nonsecure_call));
+void (*fn3)() __attribute__ ((cmse_nonsecure_call));
+
+struct S {
+  int t;
+  union {
+char b[4];
+unsigned w;
+  };
+} s;
+
+void qux() {
+  fn2(1,
+  u); // expected-warning {{passing union across security boundary via parameter 1 may leak information}}
+
+  fn3(
+   u, // expected-warning {{passing union across security boundary via parameter 0 may leak information}}
+   1,
+   s); // expected-warning {{passing union across security boundary via parameter 2 may leak information}}
+}
Index: clang/test/Sema/arm-cmse-no-diag.c
===
--- /dev/null
+++ clang/test/Sema/arm-cmse-no-diag.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple thumbv8m.base-none-eabi -mcmse -verify -Wno-cmse-union-leak %s
+// expected-no-diagnostics
+
+union U { unsigned n; char b[4]; } u;
+
+void (*fn2)(int, union U) __attribute__((cmse_nonsecure_call));
+
+union U xyzzy() __attribute__((cmse_nonsecure_entry)) {
+  fn2(0, u);
+  return u;
+}
Index: clang/test/CodeGen/cmse-clear-return.c
===
--- /dev/null
+++ clang/test/CodeGen/cmse-clear-return.c
@@ -0,0 +1,265 @@
+// RUN: %clang_cc1 -triple thumbv8m.main   -O0 -mcmse -S -emit-llvm %s -o - | \
+// RUN:FileCheck %s --check-prefixes=CHECK,CHECK-LE,CHECK-LE-NOPT,CHECK-SOFT
+// RUN: %clang_cc1 -triple thumbebv8m.main -O0 -mcmse -S -emit-llvm %s -o - | \
+// RUN:FileCheck %s --check-prefixes=CHECK,CHECK-BE,CHECK-BE-NOPT,CHECK-SOFT
+// RUN: %clang_cc1 -triple thumbv8m.main   -O2 -mcmse -S -emit-llvm %s -o - | \
+// RUN:FileCheck %s --check-prefixes=CHECK,CHECK-LE,CHECK-LE-OPT,CHECK-SOFT
+// RUN: %clang_cc1 -triple thumbebv8m.main -O2 -mcmse -S -emit-llvm %s -o - | \
+// RUN:FileCheck %s --check-prefixes=CHECK,CHECK-BE,CHECK-BE-OPT,CHECK-SOFT
+// RUN: %clang_cc1 -triple thumbv8m.main   -O0 -mcmse -S -emit-llvm %s -o - \
+// RUN:-mfloat-abi hard | \
+// RUN:FileCheck %s --check-prefixes=CHECK,CHECK-LE,CHECK-LE-NOPT,CHECK-HARD
+
+
+//   :Memory layout| Mask
+// LE: ...1    | 0x0001/1
+// BE: 1...    | 0x8000/-2147483648
+typedef struct T0 {
+  int a : 1, : 31;
+} T0;
+
+T0 t0;
+__attribute__((cmse_nonsecure_entry)) T0 f0() { return t0; }
+// CHECK:define {{.*}} @f0()
+// CHECK-LE: %[[R:.*]] = and i32 %{{.*}}, 1
+// CHECK-BE: %[[R:.*]] = and i32 %{{.*}}, -2147483648
+// CHECK:ret i32 %[[R]]
+
+// LE: ..1.    0x0002/2
+// BE: .1..    0x4000/1073741824
+typedef struct T1 {
+  int : 1, a : 1, : 30;
+} T1;
+
+T1 t1;
+__attribute__((cmse_nonsecure_entry)) T1 f1() { return t1; }
+// CHECK:define {{.*}} @f1()
+// CHECK-LE: %[[R:.*]] = and i32 %{{.*}}, 2
+// CHECK-BE: %[[R:.*]] = and i32 %{{.*}}, 1073741824
+// CHECK:ret i32 %[[R]]
+
+// LE:  ...1   0x0100/256
+// BE:  1...   0x0080/8388608
+typedef struct T2 {
+  int : 8, a : 1, : 23;
+} T2;
+
+T2 t2;
+__attribute__((cmse_nonsecure_entry)) T2 f2() { return t2; }
+// CHECK:define {{.*}} @f2()
+// CHECK-LE: %[[R:.*]] = and i32 %{{.*}}, 256
+// CHECK-BE: %[[R:.*]] = and i32 %{{.*}}, 8388608
+// CHECK:ret i32 %[[R]]
+
+// LE:  .1..   0x0

[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-28 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 5 inline comments as done.
baloghadamsoftware added a comment.

Very slow progress, but lots of open questions. @NoQ, please try to answer them.




Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:614
+  SVB.makeLoc(MRMgr.getParamRegion(ICC->getInheritingConstructor(),
+   Idx, CalleeCtx));
+Bindings.push_back(std::make_pair(ParamLoc, ArgVal));

Is this the correct handling of this kind of calls?



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:2466
+  // FIXME: What to do with function parameters captured by a block?
+  //Searching the function call in the call stack may fail.
+  if (!BD || Index < BD->param_size()) {

What to do with function parameters captured by a block? I tried to search for 
the owner function backwards in the chain of stack frames, but I did not find 
it.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:2474
+  if (CMD->isOverloadedOperator())
+  ++Index;
+}

Here we have no `CallEvent` so no better came to my mind.



Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:204
+llvm_unreachable("Maybe we forgot something...");
+  }
+

This whole  branch should be moved to a separate function called e.g. 
`getArgExpr()`. But what to do with param `0` of `CXXNewExpr()`? It is the size 
parameter for which we do not have an `Expr`. For the greater indices we 
subtract `1` from the `Index`.



Comment at: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp:601-603
+if (LCtx->getAnalysis()->isLive(Loc,
+  PR->getOriginExpr()))
+  return true;

baloghadamsoftware wrote:
> NoQ wrote:
> > > I implemented the basic `isLive()` and `getBinding()` functions which 
> > > reduced the number of failing tests by `0`.
> > 
> > This line in particular is very incorrect. In fact, most of the time the 
> > result will be `false`.
> OK, but what should I check for liveness here? We do not have a `Decl`. We 
> could retrieve the `Expr` for the `Arg`, except for `CXXNewOperator` because 
> there the size argument cannot be retrieved.
Here could help the function `getArgExpr()` of `ParamRegion`, I suppose. We 
should put it into the place of `getOriginExpr()`. Is this correct?


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

https://reviews.llvm.org/D77229



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


[clang] 7443f86 - [clang-format] insert space after C# keyword var in var (key, value)

2020-04-28 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-04-28T17:31:40+01:00
New Revision: 7443f86eabbae0fdef90fe796c3956ed65238e99

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

LOG: [clang-format] insert space after C# keyword var in var (key, value)

Reviewers: krasimir, MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 3e441100a2f0..61386cef990a 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3053,6 +3053,10 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
 if (Left.is(TT_CSharpNullConditionalLSquare))
   return Style.SpacesInSquareBrackets;
 
+// space after var in `var (key, value)`
+if (Left.is(Keywords.kw_var) && Right.is(tok::l_paren))
+  return true;
+
 // space between keywords and paren e.g. "using ("
 if (Right.is(tok::l_paren))
   if (Left.isOneOf(tok::kw_using, Keywords.kw_async, Keywords.kw_when))

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 75112a786867..91962ef12631 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -698,6 +698,7 @@ TEST_F(FormatTestCSharp, CSharpSpaces) {
   verifyFormat(R"(Result this[Index x] => Foo(x);)", Style);
 
   verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style);
+  verifyFormat(R"(var (key, value))", Style);
 
   // Not seen as a C-style cast.
   verifyFormat(R"(//



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


[clang] 015bca3 - [clang-format] C# property formatting can be controlled by config options

2020-04-28 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-04-28T17:35:33+01:00
New Revision: 015bca3e67cbb88f74f01fb5ae4e46392bec6416

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

LOG: [clang-format] C# property formatting can be controlled by config options

Summary:
Allow brace wrapping in C# property accessors to be controlled by configuration 
options.

Add new tests and revert old test results for MS style to their old state (as 
intended).

`FormatStyle.BraceWrapping.AfterFunction = true;` will change automatic 
property formatting from

```
Type MyType { get; set }
```

to

```
Type MyType
{ get; set }
```

Reviewers: krasimir, MyDeveloperDay

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 4734ff16921b..e9e56e80814c 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1531,6 +1531,8 @@ bool UnwrappedLineParser::tryToParsePropertyAccessor() {
   // Try to parse the property accessor:
   // 
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
   Tokens->setPosition(StoredPosition);
+  if (Style.BraceWrapping.AfterFunction == true)
+addUnwrappedLine();
   nextToken();
   do {
 switch (FormatTok->Tok.getKind()) {

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 91962ef12631..550f5b493992 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -245,11 +245,13 @@ TEST_F(FormatTestCSharp, Attributes) {
"}");
 
   verifyFormat("[TestMethod]\n"
-   "public string Host { set; get; }");
+   "public string Host\n"
+   "{ set; get; }");
 
   verifyFormat("[TestMethod(\"start\", HelpText = \"Starts the server "
"listening on provided host\")]\n"
-   "public string Host { set; get; }");
+   "public string Host\n"
+   "{ set; get; }");
 
   verifyFormat(
   "[DllImport(\"Hello\", EntryPoint = \"hello_world\")]\n"
@@ -669,6 +671,32 @@ class MyClass {
 set => veryLongNamedField = value;
   } = VeryLongNamedTypeIndeed.Create(DefaultFirstArgument, 
DefaultSecondArgument,
  DefaultThirdArgument);
+})",
+   Style);
+
+  // Brace wrapping and single-lining of accessor can be controlled by config.
+  Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterFunction = true;
+
+  verifyFormat(R"(//
+public class SaleItem {
+  public decimal Price
+  { get; set; }
+})",
+   Style);
+
+  verifyFormat(R"(//
+class TimePeriod {
+  public double Hours
+  {
+get {
+  return _seconds / 3600;
+}
+set {
+  _seconds = value * 3600;
+}
+  }
 })",
Style);
 }



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


[PATCH] D79014: [clangd] Move non-clang base pieces into separate support/ lib.

2020-04-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 260665.
sammccall added a comment.

Avoid dep on clang header for thread stack size.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79014

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Cancellation.cpp
  clang-tools-extra/clangd/Cancellation.h
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/Compiler.cpp
  clang-tools-extra/clangd/Context.cpp
  clang-tools-extra/clangd/Context.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/DraftStore.cpp
  clang-tools-extra/clangd/DraftStore.h
  clang-tools-extra/clangd/FS.h
  clang-tools-extra/clangd/FSProvider.cpp
  clang-tools-extra/clangd/FSProvider.h
  clang-tools-extra/clangd/FileDistance.cpp
  clang-tools-extra/clangd/FindSymbols.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/Format.cpp
  clang-tools-extra/clangd/Function.h
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/clangd/HeaderSourceSwitch.cpp
  clang-tools-extra/clangd/Headers.cpp
  clang-tools-extra/clangd/Headers.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/IncludeFixer.cpp
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/Logger.cpp
  clang-tools-extra/clangd/Logger.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Path.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/Shutdown.cpp
  clang-tools-extra/clangd/Shutdown.h
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/Threading.cpp
  clang-tools-extra/clangd/Threading.h
  clang-tools-extra/clangd/Trace.cpp
  clang-tools-extra/clangd/Trace.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/fuzzer/clangd-fuzzer.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/BackgroundIndexLoader.cpp
  clang-tools-extra/clangd/index/BackgroundIndexLoader.h
  clang-tools-extra/clangd/index/BackgroundIndexStorage.cpp
  clang-tools-extra/clangd/index/BackgroundQueue.cpp
  clang-tools-extra/clangd/index/BackgroundRebuild.cpp
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/Index.cpp
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/Merge.cpp
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/YAMLSerialization.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp
  clang-tools-extra/clangd/index/remote/Client.cpp
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/index/remote/unimplemented/UnimplementedClient.cpp
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
  clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/refactor/tweaks/ObjCLocalizeStringLiteral.cpp
  clang-tools-extra/clangd/refactor/tweaks/RawStringLiteral.cpp
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/clangd/support/CMakeLists.txt
  clang-tools-extra/clangd/support/Cancellation.cpp
  clang-tools-extra/clangd/support/Cancellation.h
  clang-tools-extra/clangd/support/Context.cpp
  clang-tools-extra/clangd/support/Context.h
  clang-tools-extra/clangd/support/FSProvider.cpp
  clang-tools-extra/clangd/support/FSProvider.h
  clang-tools-extra/clangd/support/Function.h
  clang-tools-extra/clangd/support/Logger.cpp
  clang-tools-extra/clangd/support/Logger.h
  clang-tools-extra/clangd/support/Path.h
  clang-tools-extra/clangd/support/

  1   2   3   >