[PATCH] D74542: [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs.

2020-02-17 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa37734f643fb: [ASTImporter] Prevent the ASTImporter from 
creating multiple main FileIDs. (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74542

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


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5845,6 +5845,48 @@
   EXPECT_TRUE(isa(To->getReturnType()));
 }
 
+struct ImportSourceLocations : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportSourceLocations, PreserveFileIDTreeStructure) {
+  // Tests that the FileID tree structure (with the links being the include
+  // chains) is preserved while importing other files (which need to be
+  // added to this structure with fake include locations.
+
+  SourceLocation Location1;
+  {
+auto Pattern = varDecl(hasName("X"));
+Decl *FromTU = getTuDecl("int X;", Lang_C, "input0.c");
+auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
+
+Location1 = Import(FromD, Lang_C)->getLocation();
+  }
+  SourceLocation Location2;
+  {
+auto Pattern = varDecl(hasName("Y"));
+Decl *FromTU = getTuDecl("int Y;", Lang_C, "input1.c");
+auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
+
+Location2 = Import(FromD, Lang_C)->getLocation();
+  }
+
+  SourceManager  = ToAST->getSourceManager();
+  FileID FileID1 = ToSM.getFileID(Location1);
+  FileID FileID2 = ToSM.getFileID(Location2);
+
+  // Check that the imported files look like as if they were included from the
+  // start of the main file.
+  SourceLocation FileStart = ToSM.getLocForStartOfFile(ToSM.getMainFileID());
+  EXPECT_NE(FileID1, ToSM.getMainFileID());
+  EXPECT_NE(FileID2, ToSM.getMainFileID());
+  EXPECT_EQ(ToSM.getIncludeLoc(FileID1), FileStart);
+  EXPECT_EQ(ToSM.getIncludeLoc(FileID2), FileStart);
+
+  // Let the SourceManager check the order of the locations. The order should
+  // be the order in which the declarations are imported.
+  EXPECT_TRUE(ToSM.isBeforeInTranslationUnit(Location1, Location2));
+  EXPECT_FALSE(ToSM.isBeforeInTranslationUnit(Location2, Location1));
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
@@ -5903,5 +5945,8 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, LLDBLookupTest,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportSourceLocations,
+DefaultTestValuesForRunOptions, );
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -8479,6 +8479,15 @@
   if (!ToIncludeLoc)
 return ToIncludeLoc.takeError();
 
+  // Every FileID that is not the main FileID needs to have a valid include
+  // location so that the include chain points to the main FileID. When
+  // importing the main FileID (which has no include location), we need to
+  // create a fake include location in the main file to keep this property
+  // intact.
+  SourceLocation ToIncludeLocOrFakeLoc = *ToIncludeLoc;
+  if (FromID == FromSM.getMainFileID())
+ToIncludeLocOrFakeLoc = 
ToSM.getLocForStartOfFile(ToSM.getMainFileID());
+
   if (Cache->OrigEntry && Cache->OrigEntry->getDir()) {
 // FIXME: We probably want to use getVirtualFile(), so we don't hit the
 // disk again
@@ -8490,7 +8499,7 @@
 // point to a valid file and we get no Entry here. In this case try 
with
 // the memory buffer below.
 if (Entry)
-  ToID = ToSM.createFileID(*Entry, *ToIncludeLoc,
+  ToID = ToSM.createFileID(*Entry, ToIncludeLocOrFakeLoc,
FromSLoc.getFile().getFileCharacteristic());
   }
 }


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5845,6 +5845,48 @@
   EXPECT_TRUE(isa(To->getReturnType()));
 }
 
+struct ImportSourceLocations : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportSourceLocations, PreserveFileIDTreeStructure) {
+  // Tests that the FileID tree structure (with the links being the include
+  // chains) is preserved while importing other files (which need to be
+  // added to this structure with fake include locations.
+
+  SourceLocation Location1;
+  {
+auto Pattern = varDecl(hasName("X"));
+Decl *FromTU = getTuDecl("int X;", Lang_C, "input0.c");
+auto *FromD = 

[clang] a37734f - [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs.

2020-02-17 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2020-02-18T08:37:26+01:00
New Revision: a37734f643fbac04ce6d7f2f6b1c8dcd3c4d5e0e

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

LOG: [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs.

Summary:
When importing the main FileID the ASTImporter currently gives it no include 
location. This means
that any SourceLocations produced for this FileID look to Clang as if they are 
coming from the
main FileID (as the main FileID has no include location).

Clang seems to expect that there is only one main FileID in one translation 
unit (which makes sense
during normal compilation), so this behavior leads to several problems when 
producing diagnostics,
one being that when calling `SourceManager::isBeforeInTranslationUnit` on two 
SourceLocations
that come from two different ASTContext instances, Clang fails to sort the 
SourceLocations as
the include chains of the FileIDs don't end up in a single FileID. This causes 
that Clang crashes
with "Unsortable locations found" in this function.

This patch gives any imported main FileIDs the main FileID of the To ASTContext 
as its include
location. This allows Clang to sort all imported SourceLocations as now all 
include chains point
to the main FileID of the To ASTContext. The exact include location is 
currently set to the start
of the To main file (just because that should always be a valid SourceLocation).

Reviewers: martong, a_sidorin, a.sidorin, shafik, balazske

Reviewed By: martong, a_sidorin, shafik

Subscribers: balazske, rnkovacs, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 8710ef06aa51..5ce9d5cd16ac 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -8479,6 +8479,15 @@ Expected ASTImporter::Import(FileID FromID, bool 
IsBuiltin) {
   if (!ToIncludeLoc)
 return ToIncludeLoc.takeError();
 
+  // Every FileID that is not the main FileID needs to have a valid include
+  // location so that the include chain points to the main FileID. When
+  // importing the main FileID (which has no include location), we need to
+  // create a fake include location in the main file to keep this property
+  // intact.
+  SourceLocation ToIncludeLocOrFakeLoc = *ToIncludeLoc;
+  if (FromID == FromSM.getMainFileID())
+ToIncludeLocOrFakeLoc = 
ToSM.getLocForStartOfFile(ToSM.getMainFileID());
+
   if (Cache->OrigEntry && Cache->OrigEntry->getDir()) {
 // FIXME: We probably want to use getVirtualFile(), so we don't hit the
 // disk again
@@ -8490,7 +8499,7 @@ Expected ASTImporter::Import(FileID FromID, bool 
IsBuiltin) {
 // point to a valid file and we get no Entry here. In this case try 
with
 // the memory buffer below.
 if (Entry)
-  ToID = ToSM.createFileID(*Entry, *ToIncludeLoc,
+  ToID = ToSM.createFileID(*Entry, ToIncludeLocOrFakeLoc,
FromSLoc.getFile().getFileCharacteristic());
   }
 }

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 3e8f804374f4..6c1d87823562 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -5845,6 +5845,48 @@ TEST_P(ImportAutoFunctions, ReturnWithTypeInSwitch) {
   EXPECT_TRUE(isa(To->getReturnType()));
 }
 
+struct ImportSourceLocations : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportSourceLocations, PreserveFileIDTreeStructure) {
+  // Tests that the FileID tree structure (with the links being the include
+  // chains) is preserved while importing other files (which need to be
+  // added to this structure with fake include locations.
+
+  SourceLocation Location1;
+  {
+auto Pattern = varDecl(hasName("X"));
+Decl *FromTU = getTuDecl("int X;", Lang_C, "input0.c");
+auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
+
+Location1 = Import(FromD, Lang_C)->getLocation();
+  }
+  SourceLocation Location2;
+  {
+auto Pattern = varDecl(hasName("Y"));
+Decl *FromTU = getTuDecl("int Y;", Lang_C, "input1.c");
+auto *FromD = FirstDeclMatcher().match(FromTU, Pattern);
+
+Location2 = Import(FromD, Lang_C)->getLocation();
+  }
+
+  SourceManager  = ToAST->getSourceManager();
+  FileID FileID1 = ToSM.getFileID(Location1);
+  FileID FileID2 = ToSM.getFileID(Location2);
+
+  // Check that the imported files look like as if they were included from the
+  // start of the main file.
+  SourceLocation FileStart = 

[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

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



Comment at: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp:114-117
+  const auto MacroIt = llvm::find_if(
+  PP.macros(), [&](const auto ) { return K.first->getName() == Macro; });
+  if (MacroIt == PP.macro_end())
+return llvm::None;

martong wrote:
> martong wrote:
> > Szelethus wrote:
> > > NoQ wrote:
> > > > martong wrote:
> > > > > Szelethus wrote:
> > > > > > This seems a bit clunky even for the `Preprocessor` -- how about
> > > > > > 
> > > > > > ```lang=c++
> > > > > > const auto *MacroII = PP.getIdentifierInfo(Macro);
> > > > > > if (!MacroII)
> > > > > >   return;
> > > > > > const MacroInfo *MI = PP.getMacroInfo(MacroII);
> > > > > > assert(MI);
> > > > > > ```
> > > > > Ok, but we cannot assert on `MI`, because there may be cases when the 
> > > > > macro is not defined in a TU. In that case we should just return with 
> > > > > None.
> > > > What exactly happens when the macro is `#undef`-ined and redefined? We 
> > > > get the last redefinition that's valid at the end of the translation 
> > > > unit, right? Can we check whether there are multiple definitions and 
> > > > guard against that?
> > > Ugh, now that you say it that is a valid concern. I had to deal with that 
> > > back in the day: https://reviews.llvm.org/D52794?id=171962#inline-476352
> > Solving this does not seem easy in my opinion. To handle `#undef`s we 
> > should build an infrastructure where summaries can reference callable 
> > objects. This is necessary, because in `evalCall` the value of `EOF` would 
> > depend on the souce location of the call expression of the function with 
> > the summary. Not impossible to solve, but certainly introduces complexity. 
> > Do you think that the redefinition of EOF is so common? I mean maybe it is 
> > too much hassle for a very rare edge case (?).
> The standard library (libc or libc++) should define EOF consitently in 
> stdio.h.
> Now, if the application redefines the value of EOF then the code could be 
> broken, or at least it would not be compatible with libc. Consider the 
> following code that is perfectly legit if we don't redefine EOF, but if we do:
> ```
> #include 
> #include 
> #define EOF -2 // Here be dragons !!!
> int main(void)
> {
> FILE* fp = fopen("test.txt", "r");
> int c;
> while ((c = fgetc(fp)) != EOF) { // BOOM: Infinite loop !!!
>putchar(c);
> }
> fclose(fp);
> }
> ```
> So, redefinition of EOF (or any standard macro) results in broken code.
> And this is also a warning:
> ```
> ) clang eof-inf.c
> eof-inf.c:3:9: warning: 'EOF' macro redefined [-Wmacro-redefined]
> #define EOF -2 // Here be dragons !!!
> ^
> /usr/include/x86_64-linux-gnu/bits/libio.h:66:10: note: previous definition 
> is here
> # define EOF (-1)
>  ^
> 1 warning generated.
> ```
It should be possible to get the list of all macro definitions (of a macro). We 
can select the first item, or one that is inside a system header (by the 
SourceLocation).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74473



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


[PATCH] D74467: [analyzer] Teach scan-build how to rebuild index.html without analyzing.

2020-02-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ reopened this revision.
NoQ marked 2 inline comments as done.
NoQ added a comment.
This revision is now accepted and ready to land.

Reverted due to a lot of buildbot failures, eg. 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/62758/steps/test-check-all/logs/stdio

  $ 
"/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm-project/clang/tools/scan-build/bin/scan-build"
 
"--use-analyzer=/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/build/bin/clang"
 "--generate-index-only" 
"/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/build/tools/clang/test/Analysis/scan-build/rebuild_index/Output/rebuild_index.test.tmp.output_dir"
  # command output:
  scan-build: Analysis run complete.
  scan-build: 3 bugs found.
  scan-build: Run 'scan-view 
/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/build/tools/clang/test/Analysis/scan-build/rebuild_index/Output/rebuild_index.test.tmp.output_dir'
 to examine bug reports.
  
  $ ":" "RUN: at line 16"
  $ "ls" 
"/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/build/tools/clang/test/Analysis/scan-build/rebuild_index/Output/rebuild_index.test.tmp.output_dir"
  $ 
"/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/build/bin/FileCheck"
 "-check-prefix" "CHECK-FILES" 
"/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm-project/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test"
  # command stderr:
  
/home/buildslave/ps4-buildslave4/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/llvm-project/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test:19:19:
 error: CHECK-FILES-NEXT: expected string not found in input
  CHECK-FILES-NEXT: report-1.html
^
  :2:1: note: scanning from here
  report-2.html
  ^
  
  error: command failed with exit status: 1

Weird, all three bugs found but `report-1` is not present, is it just that `ls` 
doesn't sort the output or is it about our deduplication removing a different 
duplicate?..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74467



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


[clang] 21efb06 - Revert "[analyzer] Teach scan-build how to rebuild index.html without analyzing."

2020-02-17 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-02-18T09:48:29+03:00
New Revision: 21efb06f0ae2eb999f566d989997256d6cb12206

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

LOG: Revert "[analyzer] Teach scan-build how to rebuild index.html without 
analyzing."

This reverts commit a807a068e6ae58c6b53ad9b0b2004ea0ed0a939f.

Buildbot failures :)

Added: 


Modified: 
clang/tools/scan-build/bin/scan-build

Removed: 
clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test
clang/test/Analysis/scan-build/rebuild_index/report-1.html
clang/test/Analysis/scan-build/rebuild_index/report-2.html
clang/test/Analysis/scan-build/rebuild_index/report-3.html
clang/test/Analysis/scan-build/rebuild_index/subdirectory/report-4.html



diff  --git a/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test 
b/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test
deleted file mode 100644
index db8acb03f99b..
--- a/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test
+++ /dev/null
@@ -1,44 +0,0 @@
-// FIXME: Actually, "perl".
-REQUIRES: shell
-
-// FIXME: Should ideally work on Windows.
-UNSUPPORTED: system-windows
-
-RUN: rm -rf %t.output_dir && mkdir %t.output_dir
-RUN: cp %S/report-1.html %t.output_dir
-RUN: cp %S/report-2.html %t.output_dir
-RUN: cp %S/report-3.html %t.output_dir
-RUN: mkdir %t.output_dir/subdirectory
-RUN: cp %S/subdirectory/report-4.html %t.output_dir/subdirectory
-
-RUN: %scan-build --generate-index-only %t.output_dir
-
-RUN: ls %t.output_dir | FileCheck -check-prefix CHECK-FILES %s
-
-CHECK-FILES:  index.html
-CHECK-FILES-NEXT: report-1.html
-CHECK-FILES-NEXT: report-2.html
-
-// report-3.html is a duplicate of report-1.html so it's not present.
-CHECK-FILES-NOT:  report-3.html
-CHECK-FILES-NEXT: scanview.css
-CHECK-FILES-NEXT: sorttable.js
-CHECK-FILES-NEXT: subdirectory
-
-RUN: ls %t.output_dir/subdirectory | FileCheck -check-prefix CHECK-SUB %s
-
-CHECK-SUB: report-4.html
-
-RUN: cat %t.output_dir/index.html | FileCheck -check-prefix CHECK-INDEX %s
-
-CHECK-INDEX:  cat1
-CHECK-INDEX-NEXT: bug1
-CHECK-INDEX-NEXT: cat2
-CHECK-INDEX-NEXT: bug2
-CHECK-INDEX-NEXT: cat4
-CHECK-INDEX-NEXT: bug4
-
-CHECK-INDEX: report-1.html#EndPath
-CHECK-INDEX: report-2.html#EndPath
-CHECK-INDEX-NOT: report-3.html#EndPath
-CHECK-INDEX: subdirectory/report-4.html#EndPath

diff  --git a/clang/test/Analysis/scan-build/rebuild_index/report-1.html 
b/clang/test/Analysis/scan-build/rebuild_index/report-1.html
deleted file mode 100644
index ba446ae51ff9..
--- a/clang/test/Analysis/scan-build/rebuild_index/report-1.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-

diff  --git a/clang/test/Analysis/scan-build/rebuild_index/report-2.html 
b/clang/test/Analysis/scan-build/rebuild_index/report-2.html
deleted file mode 100644
index c26e6e4d4b8e..
--- a/clang/test/Analysis/scan-build/rebuild_index/report-2.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-

diff  --git a/clang/test/Analysis/scan-build/rebuild_index/report-3.html 
b/clang/test/Analysis/scan-build/rebuild_index/report-3.html
deleted file mode 100644
index ba446ae51ff9..
--- a/clang/test/Analysis/scan-build/rebuild_index/report-3.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-

diff  --git 
a/clang/test/Analysis/scan-build/rebuild_index/subdirectory/report-4.html 
b/clang/test/Analysis/scan-build/rebuild_index/subdirectory/report-4.html
deleted file mode 100644
index 63c7e28c2d16..
--- a/clang/test/Analysis/scan-build/rebuild_index/subdirectory/report-4.html
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-

diff  --git a/clang/tools/scan-build/bin/scan-build 
b/clang/tools/scan-build/bin/scan-build
index 5ec89774ef71..1574b10f2054 100755
--- a/clang/tools/scan-build/bin/scan-build
+++ b/clang/tools/scan-build/bin/scan-build
@@ -72,9 +72,8 @@ my %Options = (
   MaxLoop => 0,
   PluginsToLoad => [],
   AnalyzerDiscoveryMethod => undef,
-  OverrideCompiler => 0, # The flag corresponding to the 
--override-compiler command line option.
-  ForceAnalyzeDebugCode => 0,
-  GenerateIndex => 0 # Skip the analysis, only generate index.html.
+  OverrideCompiler => 0,  # The flag corresponding to the 
--override-compiler command line option.
+  ForceAnalyzeDebugCode => 0
 );
 lock_keys(%Options);
 
@@ -947,41 +946,6 @@ ENDTEXT
   return $Num;
 }
 
-sub Finalize {
-  my $BaseDir = shift;
-  my $ExitStatus = shift;
-
-  Diag "Analysis run complete.\n";
-  if (defined $Options{OutputFormat}) {
-if ($Options{OutputFormat} =~ /plist/ ||
-$Options{OutputFormat} =~ /sarif/) {
-  Diag "Analysis results (" .
-($Options{OutputFormat} =~ /plist/ ? "plist" : "sarif") .
-" files) deposited in 

[PATCH] D74467: [analyzer] Teach scan-build how to rebuild index.html without analyzing.

2020-02-17 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa807a068e6ae: [analyzer] Teach scan-build how to rebuild 
index.html without analyzing. (authored by dergachev.a).

Changed prior to commit:
  https://reviews.llvm.org/D74467?vs=244084=245084#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74467

Files:
  clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test
  clang/test/Analysis/scan-build/rebuild_index/report-1.html
  clang/test/Analysis/scan-build/rebuild_index/report-2.html
  clang/test/Analysis/scan-build/rebuild_index/report-3.html
  clang/test/Analysis/scan-build/rebuild_index/subdirectory/report-4.html
  clang/tools/scan-build/bin/scan-build

Index: clang/tools/scan-build/bin/scan-build
===
--- clang/tools/scan-build/bin/scan-build
+++ clang/tools/scan-build/bin/scan-build
@@ -72,8 +72,9 @@
   MaxLoop => 0,
   PluginsToLoad => [],
   AnalyzerDiscoveryMethod => undef,
-  OverrideCompiler => 0,  # The flag corresponding to the --override-compiler command line option.
-  ForceAnalyzeDebugCode => 0
+  OverrideCompiler => 0, # The flag corresponding to the --override-compiler command line option.
+  ForceAnalyzeDebugCode => 0,
+  GenerateIndex => 0 # Skip the analysis, only generate index.html.
 );
 lock_keys(%Options);
 
@@ -946,6 +947,41 @@
   return $Num;
 }
 
+sub Finalize {
+  my $BaseDir = shift;
+  my $ExitStatus = shift;
+
+  Diag "Analysis run complete.\n";
+  if (defined $Options{OutputFormat}) {
+if ($Options{OutputFormat} =~ /plist/ ||
+$Options{OutputFormat} =~ /sarif/) {
+  Diag "Analysis results (" .
+($Options{OutputFormat} =~ /plist/ ? "plist" : "sarif") .
+" files) deposited in '$Options{OutputDir}'\n";
+}
+if ($Options{OutputFormat} =~ /html/) {
+  # Postprocess the HTML directory.
+  my $NumBugs = Postprocess($Options{OutputDir}, $BaseDir,
+$Options{AnalyzerStats}, $Options{KeepEmpty});
+
+  if ($Options{ViewResults} and -r "$Options{OutputDir}/index.html") {
+Diag "Viewing analysis results in '$Options{OutputDir}' using scan-view.\n";
+my $ScanView = Cwd::realpath("$RealBin/scan-view");
+if (! -x $ScanView) { $ScanView = "scan-view"; }
+if (! -x $ScanView) { $ScanView = Cwd::realpath("$RealBin/../../scan-view/bin/scan-view"); }
+exec $ScanView, "$Options{OutputDir}";
+  }
+
+  if ($Options{ExitStatusFoundBugs}) {
+exit 1 if ($NumBugs > 0);
+exit $ExitStatus;
+  }
+}
+  }
+
+  exit $ExitStatus;
+}
+
 ####
 # RunBuildCommand - Run the build command.
 ####
@@ -1259,6 +1295,12 @@
 
View analysis results in a web browser when the build completes.
 
+ --generate-index-only 
+
+   Do not perform the analysis, but only regenerate the index.html file
+   from existing report.html files. Useful for making a custom Static Analyzer
+   integration into a build system that isn't otherwise supported by scan-build.
+
 ADVANCED OPTIONS:
 
  -no-failure-reports
@@ -1550,6 +1592,10 @@
 }
 
 if ($arg eq "-o") {
+  if (defined($Options{OutputDir})) {
+DieDiag("Only one of '-o' or '--generate-index-only' can be specified.\n");
+  }
+
   shift @$Args;
 
   if (!@$Args) {
@@ -1565,6 +1611,27 @@
   next;
 }
 
+if ($arg eq "--generate-index-only") {
+  if (defined($Options{OutputDir})) {
+DieDiag("Only one of '-o' or '--generate-index-only' can be specified.\n");
+  }
+
+  shift @$Args;
+
+  if (!@$Args) {
+DieDiag("'--generate-index-only' option requires a target directory name.\n");
+  }
+
+  # Construct an absolute path.  Uses the current working directory
+  # as a base if the original path was not absolute.
+  my $OutDir = shift @$Args;
+  mkpath($OutDir) unless (-e $OutDir);  # abs_path wants existing dir
+  $Options{OutputDir} = abs_path($OutDir);
+  $Options{GenerateIndex} = 1;
+
+  next;
+}
+
 if ($arg =~ /^--html-title(=(.+))?$/) {
   shift @$Args;
 
@@ -1815,11 +1882,6 @@
 ProcessArgs(\@ARGV);
 # All arguments are now shifted from @ARGV. The rest is a build command, if any.
 
-if (!@ARGV and !$RequestDisplayHelp) {
-  ErrorDiag("No build command specified.\n\n");
-  $ForceDisplayHelp = 1;
-}
-
 my $ClangNotFoundErrMsg = FindClang();
 
 if ($ForceDisplayHelp || $RequestDisplayHelp) {
@@ -1827,6 +1889,24 @@
   exit $ForceDisplayHelp;
 }
 
+$CmdArgs = HtmlEscape(join(' ', map(ShellEscape($_), @ARGV)));
+
+# Make sure to use "" to handle paths with spaces.
+$ClangVersion = HtmlEscape(`"$Clang" --version`);
+
+if ($Options{GenerateIndex}) {
+  

[PATCH] D73629: [analyzer] vfork checker: allow execve after vfork

2020-02-17 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5a11233a2fa5: [analyzer] VforkChecker: allow execve after 
vfork. (authored by dergachev.a).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73629

Files:
  clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/vfork.c


Index: clang/test/Analysis/vfork.c
===
--- clang/test/Analysis/vfork.c
+++ clang/test/Analysis/vfork.c
@@ -6,7 +6,7 @@
 void foo();
 
 // Ensure that child process is properly checked.
-int f1(int x) {
+int f1(int x, int y) {
   pid_t pid = vfork(); // expected-warning{{Call to function 'vfork' is 
insecure}}
   if (pid != 0)
 return 0;
@@ -16,7 +16,29 @@
 // Ensure that modifying pid is ok.
 pid = 1; // no-warning
 // Ensure that calling whitelisted routines is ok.
-execl("", "", 0); // no-warning
+switch (y) {
+case 0:
+  execl("", "", 0); // no-warning
+  break;
+case 1:
+  execle("", "", 0); // no-warning
+  break;
+case 2:
+  execlp("", "", 0); // no-warning
+  break;
+case 3:
+  execv("", NULL); // no-warning
+  break;
+case 4:
+  execve("", NULL, NULL); // no-warning
+  break;
+case 5:
+  execvp("", NULL); // no-warning
+  break;
+case 6:
+  execvpe("", NULL, NULL); // no-warning
+  break;
+}
 _exit(1); // no-warning
 break;
   case 1:
Index: clang/test/Analysis/Inputs/system-header-simulator.h
===
--- clang/test/Analysis/Inputs/system-header-simulator.h
+++ clang/test/Analysis/Inputs/system-header-simulator.h
@@ -98,6 +98,12 @@
 pid_t fork(void);
 pid_t vfork(void);
 int execl(const char *path, const char *arg, ...);
+int execle(const char *path, const char *arg, ...);
+int execlp(const char *file, const char *arg, ...);
+int execv(const char *path, char *const argv[]);
+int execve(const char *path, char *const argv[], char *const envp[]);
+int execvp(const char *file, char *const argv[]);
+int execvpe(const char *file, char *const argv[], char *const envp[]);
 
 void exit(int status) __attribute__ ((__noreturn__));
 void _exit(int status) __attribute__ ((__noreturn__));
Index: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
@@ -98,12 +98,13 @@
   if (VforkWhitelist.empty()) {
 // According to manpage.
 const char *ids[] = {
-  "_exit",
   "_Exit",
+  "_exit",
   "execl",
-  "execlp",
   "execle",
+  "execlp",
   "execv",
+  "execve",
   "execvp",
   "execvpe",
   nullptr


Index: clang/test/Analysis/vfork.c
===
--- clang/test/Analysis/vfork.c
+++ clang/test/Analysis/vfork.c
@@ -6,7 +6,7 @@
 void foo();
 
 // Ensure that child process is properly checked.
-int f1(int x) {
+int f1(int x, int y) {
   pid_t pid = vfork(); // expected-warning{{Call to function 'vfork' is insecure}}
   if (pid != 0)
 return 0;
@@ -16,7 +16,29 @@
 // Ensure that modifying pid is ok.
 pid = 1; // no-warning
 // Ensure that calling whitelisted routines is ok.
-execl("", "", 0); // no-warning
+switch (y) {
+case 0:
+  execl("", "", 0); // no-warning
+  break;
+case 1:
+  execle("", "", 0); // no-warning
+  break;
+case 2:
+  execlp("", "", 0); // no-warning
+  break;
+case 3:
+  execv("", NULL); // no-warning
+  break;
+case 4:
+  execve("", NULL, NULL); // no-warning
+  break;
+case 5:
+  execvp("", NULL); // no-warning
+  break;
+case 6:
+  execvpe("", NULL, NULL); // no-warning
+  break;
+}
 _exit(1); // no-warning
 break;
   case 1:
Index: clang/test/Analysis/Inputs/system-header-simulator.h
===
--- clang/test/Analysis/Inputs/system-header-simulator.h
+++ clang/test/Analysis/Inputs/system-header-simulator.h
@@ -98,6 +98,12 @@
 pid_t fork(void);
 pid_t vfork(void);
 int execl(const char *path, const char *arg, ...);
+int execle(const char *path, const char *arg, ...);
+int execlp(const char *file, const char *arg, ...);
+int execv(const char *path, char *const argv[]);
+int execve(const char *path, char *const argv[], char *const envp[]);
+int execvp(const char *file, char *const argv[]);
+int execvpe(const char *file, char *const argv[], char *const envp[]);
 
 void exit(int status) __attribute__ ((__noreturn__));
 void _exit(int status) __attribute__ ((__noreturn__));
Index: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp

[PATCH] D74467: [analyzer] Teach scan-build how to rebuild index.html without analyzing.

2020-02-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked 6 inline comments as done.
NoQ added inline comments.



Comment at: clang/tools/scan-build/bin/scan-build:953
+  my $ExitStatus = shift;
+
+  if (defined $Options{OutputFormat}) {

Charusso wrote:
> May inject `Diag "Analysis run complete.\n";` here?
Indeed!



Comment at: clang/tools/scan-build/bin/scan-build:976
+
+  if ($Options{ExitStatusFoundBugs}) {
+exit 1 if ($NumBugs > 0);

Charusso wrote:
> If we stick to printing information to the user: `Diag "No bugs found.\n"`?.
We already kind of have it when it says "deleting output directory because it 
contains no reports".



Comment at: clang/tools/scan-build/bin/scan-build:1303
+   from existing report.html files. Useful for making a custom Static Analyzer
+   integration into a build system that isn't otherwise supported by 
scan-build.
+

Charusso wrote:
> What about `--index-only`?
Renamed to `--generate-index-only` :)



Comment at: clang/tools/scan-build/bin/scan-build:1618
+DieDiag("Only one of '-o' or '--generate-index' can be specified.\n");
+  }
+

Charusso wrote:
> I may smash this duplicated error-handling above in one if-stmt, given that 
> the options are correlate with each other.
Dunno, i'd rather keep the structure. The function is huge, i'd rather keep it 
well-structured, and "each option is handled in exactly once if-statement" is 
good for it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D74467



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


[clang] 5a11233 - [analyzer] VforkChecker: allow execve after vfork.

2020-02-17 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-02-18T09:19:29+03:00
New Revision: 5a11233a2fa58a734dbed23e2232f55cdf4b3321

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

LOG: [analyzer] VforkChecker: allow execve after vfork.

In the path-sensitive vfork() checker that keeps a list of operations
allowed after a successful vfork(), unforget to include execve() in the list.

Patch by Jan Včelák!

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
clang/test/Analysis/Inputs/system-header-simulator.h
clang/test/Analysis/vfork.c

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
index 6724eead5072..077a34810db7 100644
--- a/clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
@@ -98,12 +98,13 @@ bool VforkChecker::isCallWhitelisted(const IdentifierInfo 
*II,
   if (VforkWhitelist.empty()) {
 // According to manpage.
 const char *ids[] = {
-  "_exit",
   "_Exit",
+  "_exit",
   "execl",
-  "execlp",
   "execle",
+  "execlp",
   "execv",
+  "execve",
   "execvp",
   "execvpe",
   nullptr

diff  --git a/clang/test/Analysis/Inputs/system-header-simulator.h 
b/clang/test/Analysis/Inputs/system-header-simulator.h
index 8542387d4277..afbaeddd88a8 100644
--- a/clang/test/Analysis/Inputs/system-header-simulator.h
+++ b/clang/test/Analysis/Inputs/system-header-simulator.h
@@ -98,6 +98,12 @@ typedef int pid_t;
 pid_t fork(void);
 pid_t vfork(void);
 int execl(const char *path, const char *arg, ...);
+int execle(const char *path, const char *arg, ...);
+int execlp(const char *file, const char *arg, ...);
+int execv(const char *path, char *const argv[]);
+int execve(const char *path, char *const argv[], char *const envp[]);
+int execvp(const char *file, char *const argv[]);
+int execvpe(const char *file, char *const argv[], char *const envp[]);
 
 void exit(int status) __attribute__ ((__noreturn__));
 void _exit(int status) __attribute__ ((__noreturn__));

diff  --git a/clang/test/Analysis/vfork.c b/clang/test/Analysis/vfork.c
index da1b5da40665..8552b5fd0256 100644
--- a/clang/test/Analysis/vfork.c
+++ b/clang/test/Analysis/vfork.c
@@ -6,7 +6,7 @@
 void foo();
 
 // Ensure that child process is properly checked.
-int f1(int x) {
+int f1(int x, int y) {
   pid_t pid = vfork(); // expected-warning{{Call to function 'vfork' is 
insecure}}
   if (pid != 0)
 return 0;
@@ -16,7 +16,29 @@ int f1(int x) {
 // Ensure that modifying pid is ok.
 pid = 1; // no-warning
 // Ensure that calling whitelisted routines is ok.
-execl("", "", 0); // no-warning
+switch (y) {
+case 0:
+  execl("", "", 0); // no-warning
+  break;
+case 1:
+  execle("", "", 0); // no-warning
+  break;
+case 2:
+  execlp("", "", 0); // no-warning
+  break;
+case 3:
+  execv("", NULL); // no-warning
+  break;
+case 4:
+  execve("", NULL, NULL); // no-warning
+  break;
+case 5:
+  execvp("", NULL); // no-warning
+  break;
+case 6:
+  execvpe("", NULL, NULL); // no-warning
+  break;
+}
 _exit(1); // no-warning
 break;
   case 1:



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


[clang] a807a06 - [analyzer] Teach scan-build how to rebuild index.html without analyzing.

2020-02-17 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2020-02-18T09:19:29+03:00
New Revision: a807a068e6ae58c6b53ad9b0b2004ea0ed0a939f

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

LOG: [analyzer] Teach scan-build how to rebuild index.html without analyzing.

This is useful for performing custom build system integration that works by 
appending '--analyze --analyzer-output html' to all clang build commands.
For such users there is now still a way to have the fancy index.html file
in the output.

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

Added: 
clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test
clang/test/Analysis/scan-build/rebuild_index/report-1.html
clang/test/Analysis/scan-build/rebuild_index/report-2.html
clang/test/Analysis/scan-build/rebuild_index/report-3.html
clang/test/Analysis/scan-build/rebuild_index/subdirectory/report-4.html

Modified: 
clang/tools/scan-build/bin/scan-build

Removed: 




diff  --git a/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test 
b/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test
new file mode 100644
index ..db8acb03f99b
--- /dev/null
+++ b/clang/test/Analysis/scan-build/rebuild_index/rebuild_index.test
@@ -0,0 +1,44 @@
+// FIXME: Actually, "perl".
+REQUIRES: shell
+
+// FIXME: Should ideally work on Windows.
+UNSUPPORTED: system-windows
+
+RUN: rm -rf %t.output_dir && mkdir %t.output_dir
+RUN: cp %S/report-1.html %t.output_dir
+RUN: cp %S/report-2.html %t.output_dir
+RUN: cp %S/report-3.html %t.output_dir
+RUN: mkdir %t.output_dir/subdirectory
+RUN: cp %S/subdirectory/report-4.html %t.output_dir/subdirectory
+
+RUN: %scan-build --generate-index-only %t.output_dir
+
+RUN: ls %t.output_dir | FileCheck -check-prefix CHECK-FILES %s
+
+CHECK-FILES:  index.html
+CHECK-FILES-NEXT: report-1.html
+CHECK-FILES-NEXT: report-2.html
+
+// report-3.html is a duplicate of report-1.html so it's not present.
+CHECK-FILES-NOT:  report-3.html
+CHECK-FILES-NEXT: scanview.css
+CHECK-FILES-NEXT: sorttable.js
+CHECK-FILES-NEXT: subdirectory
+
+RUN: ls %t.output_dir/subdirectory | FileCheck -check-prefix CHECK-SUB %s
+
+CHECK-SUB: report-4.html
+
+RUN: cat %t.output_dir/index.html | FileCheck -check-prefix CHECK-INDEX %s
+
+CHECK-INDEX:  cat1
+CHECK-INDEX-NEXT: bug1
+CHECK-INDEX-NEXT: cat2
+CHECK-INDEX-NEXT: bug2
+CHECK-INDEX-NEXT: cat4
+CHECK-INDEX-NEXT: bug4
+
+CHECK-INDEX: report-1.html#EndPath
+CHECK-INDEX: report-2.html#EndPath
+CHECK-INDEX-NOT: report-3.html#EndPath
+CHECK-INDEX: subdirectory/report-4.html#EndPath

diff  --git a/clang/test/Analysis/scan-build/rebuild_index/report-1.html 
b/clang/test/Analysis/scan-build/rebuild_index/report-1.html
new file mode 100644
index ..ba446ae51ff9
--- /dev/null
+++ b/clang/test/Analysis/scan-build/rebuild_index/report-1.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+

diff  --git a/clang/test/Analysis/scan-build/rebuild_index/report-2.html 
b/clang/test/Analysis/scan-build/rebuild_index/report-2.html
new file mode 100644
index ..c26e6e4d4b8e
--- /dev/null
+++ b/clang/test/Analysis/scan-build/rebuild_index/report-2.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+

diff  --git a/clang/test/Analysis/scan-build/rebuild_index/report-3.html 
b/clang/test/Analysis/scan-build/rebuild_index/report-3.html
new file mode 100644
index ..ba446ae51ff9
--- /dev/null
+++ b/clang/test/Analysis/scan-build/rebuild_index/report-3.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+

diff  --git 
a/clang/test/Analysis/scan-build/rebuild_index/subdirectory/report-4.html 
b/clang/test/Analysis/scan-build/rebuild_index/subdirectory/report-4.html
new file mode 100644
index ..63c7e28c2d16
--- /dev/null
+++ b/clang/test/Analysis/scan-build/rebuild_index/subdirectory/report-4.html
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+

diff  --git a/clang/tools/scan-build/bin/scan-build 
b/clang/tools/scan-build/bin/scan-build
index 1574b10f2054..5ec89774ef71 100755
--- a/clang/tools/scan-build/bin/scan-build
+++ b/clang/tools/scan-build/bin/scan-build
@@ -72,8 +72,9 @@ my %Options = (
   MaxLoop => 0,
   PluginsToLoad => [],
   AnalyzerDiscoveryMethod => undef,
-  OverrideCompiler => 0,  # The flag corresponding to the 
--override-compiler command line option.
-  ForceAnalyzeDebugCode => 0
+  OverrideCompiler => 0, # The flag corresponding to the 
--override-compiler command line option.
+  ForceAnalyzeDebugCode => 0,
+  GenerateIndex => 0 # Skip the analysis, only generate index.html.
 );
 lock_keys(%Options);
 
@@ -946,6 +947,41 @@ ENDTEXT
   return $Num;
 }
 
+sub Finalize {
+  my $BaseDir = shift;
+  my $ExitStatus = shift;
+
+  Diag "Analysis run complete.\n";
+  if (defined $Options{OutputFormat}) {
+if ($Options{OutputFormat} =~ /plist/ ||
+

[PATCH] D73629: [analyzer] vfork checker: allow execve after vfork

2020-02-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thank you!! I'll commit.


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

https://reviews.llvm.org/D73629



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


[PATCH] D74643: [Parse] Consider attributes in `TryParsePtrOperatorSeq`.

2020-02-17 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74643



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


[PATCH] D73835: [IRBuilder] Virtualize IRBuilder

2020-02-17 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added inline comments.



Comment at: llvm/include/llvm/IR/IRBuilder.h:137
+
+  Value *Insert(Value *V, const Twine& = "") const {
+if (Instruction *I = dyn_cast(V))

I experienced a tiny regression after applying this patch, and I think this 
line might be the reason why. I tried addressing the issue in D74754, please 
give that a review when you get a chance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73835



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


Buildbot numbers for the week of 02/2/2020 - 02/8/2020

2020-02-17 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 02/2/2020 - 02/8/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername|  was_red
--+--
 reverse-iteration| 116:45:05
 clang-with-thin-lto-ubuntu   | 110:40:57
 llvm-clang-win-x-armv7l  | 61:21:44
 clang-x64-windows-msvc   | 45:40:46
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 39:10:25
 llvm-clang-win-x-aarch64 | 33:51:59
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 32:17:44
 clang-cmake-thumbv7-full-sh  | 25:38:26
 sanitizer-x86_64-linux-android   | 25:09:44
 ppc64le-lld-multistage-test  | 24:45:44
 clang-cmake-aarch64-full | 24:33:09
 clang-cmake-aarch64-quick| 24:30:34
 clang-cmake-aarch64-global-isel  | 24:17:05
 clang-cmake-aarch64-lld  | 24:05:32
 clang-ppc64le-linux-multistage   | 18:32:43
 polly-arm-linux  | 18:30:45
 sanitizer-ppc64be-linux  | 16:20:01
 sanitizer-x86_64-linux   | 15:26:47
 sanitizer-ppc64le-linux  | 13:56:34
 clang-ppc64be-linux-lnt  | 13:18:35
 clang-ppc64le-rhel   | 12:28:27
 lld-x86_64-win7  | 12:17:22
 llvm-clang-x86_64-expensive-checks-win   | 12:13:28
 clang-ppc64le-linux  | 12:11:52
 lld-x86_64-darwin13  | 12:08:48
 clang-ppc64be-linux-multistage   | 12:04:18
 clang-ppc64le-linux-lnt  | 12:03:17
 clang-ppc64be-linux  | 11:55:47
 clang-with-lto-ubuntu| 11:08:45
 lldb-x64-windows-ninja   | 08:03:42
 lldb-aarch64-ubuntu  | 07:41:57
 lldb-x86_64-debian   | 07:35:49
 clang-cmake-armv7-selfhost-neon  | 07:01:37
 sanitizer-x86_64-linux-bootstrap | 06:26:04
 sanitizer-x86_64-linux-bootstrap-ubsan   | 06:23:17
 clang-native-arm-lnt-perf| 06:08:04
 clang-cmake-armv7-selfhost   | 06:05:20
 clang-cmake-armv8-lld| 05:58:53
 clang-cmake-armv7-quick  | 05:23:27
 clang-cmake-x86_64-avx2-linux| 05:19:46
 clang-cmake-x86_64-sde-avx512-linux  | 05:18:56
 sanitizer-x86_64-linux-bootstrap-msan| 05:17:23
 clang-cmake-armv7-global-isel| 05:08:51
 clang-hexagon-elf| 04:59:52
 clang-s390x-linux| 04:36:31
 sanitizer-x86_64-linux-fast  | 04:26:46
 sanitizer-x86_64-linux-fuzzer| 04:11:08
 clang-atom-d525-fedora-rel   | 04:04:15
 sanitizer-x86_64-linux-autoconf  | 03:42:54
 clang-cmake-armv7-lnt| 03:38:48
 clang-s390x-linux-lnt| 03:38:10
 lld-perf-testsuite   | 03:24:34
 sanitizer-windows| 03:21:59
 clang-cuda-build | 03:18:27
 clang-aarch64-linux-build-cache  | 03:13:44
 clang-x86_64-linux-abi-test  | 03:11:16
 clang-armv7-linux-build-cache| 03:06:18
 lld-x86_64-ubuntu-fast   | 02:44:13
 openmp-clang-x86_64-linux-debian | 01:45:07
 llvm-clang-x86_64-win-fast   | 01:29:34
 openmp-gcc-x86_64-linux-debian   | 01:15:43
 llvm-clang-x86_64-expensive-checks-ubuntu| 01:04:50
 clang-x86_64-debian-new-pass-manager-fast| 00:51:16
 llvm-clang-x86_64-expensive-checks-debian| 00:50:55
 clang-x86_64-debian-fast | 00:50:05
 lldb-sphinx-docs | 00:19:42
(66 rows)


"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green):
   buildername   | builds | changes
| 

Buildbot numbers for the last week of 02/9/2020 - 02/15/2020

2020-02-17 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 02/9/2020 - 02/15/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername   |  was_red
-+--
 sanitizer-x86_64-linux-fast | 121:01:29
 sanitizer-x86_64-linux-bootstrap-ubsan  | 120:52:32
 clang-ppc64be-linux-multistage  | 119:10:07
 sanitizer-x86_64-linux-bootstrap| 98:22:07
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast  | 87:34:15
 clang-hexagon-elf   | 67:57:24
 clang-tools-sphinx-docs | 65:04:11
 aosp-O3-polly-before-vectorizer-unprofitable| 61:32:18
 clang-cmake-x86_64-avx2-linux   | 56:14:48
 clang-cmake-x86_64-sde-avx512-linux | 54:18:03
 clang-cmake-armv7-lnt   | 32:17:16
 sanitizer-ppc64be-linux | 28:03:30
 sanitizer-x86_64-linux-bootstrap-msan   | 25:46:50
 clang-x64-windows-msvc  | 23:51:57
 sanitizer-x86_64-linux  | 23:37:39
 clang-ppc64le-linux-multistage  | 16:55:27
 clang-ppc64le-linux | 15:41:57
 clang-ppc64be-linux | 15:00:50
 clang-ppc64be-linux-lnt | 14:43:17
 lldb-x64-windows-ninja  | 14:13:39
 clang-with-lto-ubuntu   | 14:11:36
 sanitizer-x86_64-linux-autoconf | 12:58:45
 clang-ppc64le-rhel  | 12:22:46
 sanitizer-ppc64le-linux | 10:42:35
 clang-ppc64le-linux-lnt | 10:36:01
 llvm-clang-win-x-armv7l | 08:38:58
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions | 08:26:30
 sanitizer-x86_64-linux-android  | 07:38:56
 clang-cmake-thumbv7-full-sh | 07:35:21
 clang-cmake-aarch64-full| 07:16:25
 clang-s390x-linux-multistage| 07:11:46
 llvm-clang-x86_64-expensive-checks-win  | 07:05:56
 llvm-clang-win-x-aarch64| 06:39:21
 llvm-clang-x86_64-win-fast  | 06:34:18
 lld-x86_64-win7 | 06:15:18
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast| 06:13:21
 clang-s390x-linux   | 06:09:16
 clang-s390x-linux-lnt   | 06:04:07
 ppc64le-lld-multistage-test | 05:57:55
 sanitizer-windows   | 04:59:31
 clang-with-thin-lto-ubuntu  | 04:41:04
 clang-cmake-aarch64-lld | 04:38:50
 openmp-clang-x86_64-linux-debian| 03:29:21
 reverse-iteration   | 02:51:19
 sanitizer-x86_64-linux-fuzzer   | 02:29:42
 clang-cuda-build| 02:22:32
 clang-x86_64-debian-fast| 02:15:50
 clang-x86_64-debian-new-pass-manager-fast   | 02:15:47
 clang-atom-d525-fedora-rel  | 02:15:47
 llvm-clang-x86_64-expensive-checks-debian   | 02:15:46
 lld-x86_64-ubuntu-fast  | 02:15:42
 llvm-clang-x86_64-expensive-checks-ubuntu   | 02:15:41
 clang-x86_64-linux-abi-test | 02:13:23
 lld-x86_64-darwin13 | 02:10:11
 libcxx-libcxxabi-libunwind-armv8-linux  | 01:55:48
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions   | 01:52:39
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions | 01:51:59
 clang-cmake-armv7-global-isel   | 01:46:06
 polly-arm-linux | 01:40:22
 clang-cmake-aarch64-quick   | 01:27:09
 clang-cmake-aarch64-global-isel | 01:26:36
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a  | 01:22:23
 

Buildbot numbers for the week of 01/26/2020 - 02/01/2020

2020-02-17 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 01/26/2020 - 02/01/2020.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
  buildername  | was_red
---+-
 aosp-O3-polly-before-vectorizer-unprofitable  | 89:06:59
 clang-with-thin-lto-ubuntu| 60:01:43
 clang-with-lto-ubuntu | 55:03:00
 llvm-clang-win-x-aarch64  | 54:35:34
 clang-cmake-aarch64-full  | 32:12:35
 clang-ppc64be-linux-lnt   | 29:04:07
 clang-ppc64be-linux-multistage| 29:03:15
 clang-s390x-linux | 29:00:26
 clang-ppc64be-linux   | 28:29:06
 clang-s390x-linux-multistage  | 27:20:45
 clang-s390x-linux-lnt | 27:00:10
 clang-cmake-aarch64-lld   | 24:22:43
 sanitizer-x86_64-linux-android| 23:58:56
 clang-cmake-aarch64-global-isel   | 23:14:52
 libcxx-libcxxabi-libunwind-armv7-linux-noexceptions   | 23:13:41
 lldb-x64-windows-ninja| 22:30:32
 clang-cmake-aarch64-quick | 21:11:16
 clang-cuda-build  | 20:12:25
 libcxx-libcxxabi-x86_64-linux-debian  | 20:11:13
 libcxx-libcxxabi-singlethreaded-x86_64-linux-debian   | 20:10:30
 libcxx-libcxxabi-x86_64-linux-debian-noexceptions | 20:10:19
 libcxx-libcxxabi-libunwind-x86_64-linux-debian| 20:09:50
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan | 20:07:52
 libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan| 20:06:56
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu| 20:06:53
 libcxx-libcxxabi-x86_64-linux-ubuntu-msan | 20:06:52
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit| 20:06:14
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a| 20:04:57
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan | 20:01:38
 libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions | 19:55:11
 libcxx-libcxxabi-libunwind-armv8-linux| 19:55:10
 libcxx-libcxxabi-libunwind-armv8-linux-noexceptions   | 19:54:46
 libcxx-libcxxabi-libunwind-aarch64-linux  | 19:54:05
 libcxx-libcxxabi-libunwind-armv7-linux| 14:33:33
 llvm-clang-x86_64-expensive-checks-debian | 13:24:48
 clang-x64-windows-msvc| 12:23:41
 clang-cmake-x86_64-avx2-linux | 12:09:34
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast  | 11:51:01
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast| 11:40:24
 clang-cmake-thumbv7-full-sh   | 11:09:32
 clang-cmake-x86_64-sde-avx512-linux   | 10:49:18
 llvm-clang-x86_64-expensive-checks-ubuntu | 09:30:54
 sanitizer-ppc64le-linux   | 08:50:11
 clang-cmake-armv7-selfhost-neon   | 07:38:02
 llvm-clang-x86_64-expensive-checks-win| 07:20:03
 clang-cmake-armv7-selfhost| 05:36:55
 sanitizer-x86_64-linux| 05:06:47
 polly-arm-linux   | 05:05:13
 clang-ppc64le-linux-multistage| 04:39:24
 sanitizer-ppc64be-linux   | 04:32:19
 sanitizer-x86_64-linux-fast   | 04:24:56
 sanitizer-x86_64-linux-fuzzer | 04:20:20
 clang-aarch64-linux-build-cache   | 04:10:28
 ppc64le-lld-multistage-test   | 04:04:07
 clang-armv7-linux-build-cache | 04:02:59
 clang-ppc64le-rhel| 03:58:09
 clang-ppc64le-linux   | 03:29:32
 clang-cmake-armv8-lld | 03:26:24
 clang-ppc64le-linux-lnt   | 02:54:08
 clang-cmake-armv7-global-isel | 02:52:15
 clang-hexagon-elf | 02:46:41
 clang-cmake-armv7-lnt | 02:25:57
 lld-x86_64-darwin13   | 02:25:46
 sanitizer-x86_64-linux-bootstrap  | 02:22:21
 

[PATCH] D74643: [Parse] Consider attributes in `TryParsePtrOperatorSeq`.

2020-02-17 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale marked an inline comment as done.
michele.scandale added a comment.

Assuming this is fine, I would need someone landing this change on my behalf 
since I do not have commit rights. Thanks!




Comment at: clang/lib/Parse/ParseTentative.cpp:780
+  if (!SkipUntil(tok::r_square) || Tok.isNot(tok::r_square))
+return false;
+  ConsumeBracket();

rjmccall wrote:
> Okay, great.  The check for adjacent squares at the end makes sure this 
> doesn't catch an ObjC message send, in case this is ever used in a context 
> where there's attribute/expression ambiguity; that might be worth a comment.  
> Otherwise LGTM.
Comment added. Let me know if the wording is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74643



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


[PATCH] D74643: [Parse] Consider attributes in `TryParsePtrOperatorSeq`.

2020-02-17 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale updated this revision to Diff 245073.
michele.scandale added a comment.

Add comment about ObjC message send being rejected + rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74643

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseTentative.cpp
  clang/test/CXX/dcl.decl/p4-0x.cpp

Index: clang/test/CXX/dcl.decl/p4-0x.cpp
===
--- clang/test/CXX/dcl.decl/p4-0x.cpp
+++ clang/test/CXX/dcl.decl/p4-0x.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 struct X {
   void f() &;
@@ -7,3 +6,11 @@
 };
 
 void (X::*pmf)() & = ::f;
+
+void fn() {
+  void (*[[attr]] fn_ptr)() =  // expected-warning{{unknown attribute 'attr' ignored}}
+  void (*[[attrA]] *[[attrB]] fn_ptr_ptr)() = _ptr; // expected-warning{{unknown attribute 'attrA' ignored}} expected-warning{{unknown attribute 'attrB' ignored}}
+
+  void (&[[attr]] fn_lref)() = fn; // expected-warning{{unknown attribute 'attr' ignored}}
+  void (&&[[attr]] fn_rref)() = fn; // expected-warning{{unknown attribute 'attr' ignored}}
+}
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -186,21 +186,8 @@
 ConsumeToken();
 
 // Skip attributes.
-while (Tok.isOneOf(tok::l_square, tok::kw___attribute, tok::kw___declspec,
-   tok::kw_alignas)) {
-  if (Tok.is(tok::l_square)) {
-ConsumeBracket();
-if (!SkipUntil(tok::r_square))
-  return TPResult::Error;
-  } else {
-ConsumeToken();
-if (Tok.isNot(tok::l_paren))
-  return TPResult::Error;
-ConsumeParen();
-if (!SkipUntil(tok::r_paren))
-  return TPResult::Error;
-  }
-}
+if (!TrySkipAttributes())
+  return TPResult::Error;
 
 if (TryAnnotateOptionalCXXScopeToken())
   return TPResult::Error;
@@ -781,6 +768,32 @@
   return CAK_NotAttributeSpecifier;
 }
 
+bool Parser::TrySkipAttributes() {
+  while (Tok.isOneOf(tok::l_square, tok::kw___attribute, tok::kw___declspec,
+ tok::kw_alignas)) {
+if (Tok.is(tok::l_square)) {
+  ConsumeBracket();
+  if (Tok.isNot(tok::l_square))
+return false;
+  ConsumeBracket();
+  if (!SkipUntil(tok::r_square) || Tok.isNot(tok::r_square))
+return false;
+  // Note that explicitly checking for `[[` and `]]` allows to fail as
+  // expected in the case of the Objective-C message send syntax.
+  ConsumeBracket();
+} else {
+  ConsumeToken();
+  if (Tok.isNot(tok::l_paren))
+return false;
+  ConsumeParen();
+  if (!SkipUntil(tok::r_paren))
+return false;
+}
+  }
+
+  return true;
+}
+
 Parser::TPResult Parser::TryParsePtrOperatorSeq() {
   while (true) {
 if (TryAnnotateOptionalCXXScopeToken(true))
@@ -790,6 +803,11 @@
 (Tok.is(tok::annot_cxxscope) && NextToken().is(tok::star))) {
   // ptr-operator
   ConsumeAnyToken();
+
+  // Skip attributes.
+  if (!TrySkipAttributes())
+return TPResult::Error;
+
   while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict,
  tok::kw__Nonnull, tok::kw__Nullable,
  tok::kw__Null_unspecified))
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -2441,6 +2441,10 @@
   TPResult TryParseBracketDeclarator();
   TPResult TryConsumeDeclarationSpecifier();
 
+  /// Try to skip a possibly empty sequence of 'attribute-specifier' without of
+  /// full validation of the syntactic structure of attributes.
+  bool TrySkipAttributes();
+
 public:
   TypeResult ParseTypeName(SourceRange *Range = nullptr,
DeclaratorContext Context
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74643: [Parse] Consider attributes in `TryParsePtrOperatorSeq`.

2020-02-17 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Parse/ParseTentative.cpp:780
+  if (!SkipUntil(tok::r_square) || Tok.isNot(tok::r_square))
+return false;
+  ConsumeBracket();

Okay, great.  The check for adjacent squares at the end makes sure this doesn't 
catch an ObjC message send, in case this is ever used in a context where 
there's attribute/expression ambiguity; that might be worth a comment.  
Otherwise LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74643



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


[PATCH] D74643: [Parse] Consider attributes in `TryParsePtrOperatorSeq`.

2020-02-17 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale marked an inline comment as done.
michele.scandale added inline comments.



Comment at: clang/lib/Parse/ParseTentative.cpp:798
+if (Tok.is(tok::l_square)) {
+  ConsumeBracket();
+  if (!SkipUntil(tok::r_square))

rjmccall wrote:
> Do you want to check for double-brackets here?
The copy of the code I was replicating here wasn't doing that. But it makes 
sense to check at least that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74643



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


[PATCH] D74643: [Parse] Consider attributes in `TryParsePtrOperatorSeq`.

2020-02-17 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale updated this revision to Diff 245068.
michele.scandale added a comment.

Check for double brackets for C++11 style attributes, and outline the loop to 
skip attributes in `TrySkipAttributes` to fix also the other use in 
`TryConsumeDeclarationSpecifier`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74643

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseTentative.cpp
  clang/test/CXX/dcl.decl/p4-0x.cpp

Index: clang/test/CXX/dcl.decl/p4-0x.cpp
===
--- clang/test/CXX/dcl.decl/p4-0x.cpp
+++ clang/test/CXX/dcl.decl/p4-0x.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 struct X {
   void f() &;
@@ -7,3 +6,11 @@
 };
 
 void (X::*pmf)() & = ::f;
+
+void fn() {
+  void (*[[attr]] fn_ptr)() =  // expected-warning{{unknown attribute 'attr' ignored}}
+  void (*[[attrA]] *[[attrB]] fn_ptr_ptr)() = _ptr; // expected-warning{{unknown attribute 'attrA' ignored}} expected-warning{{unknown attribute 'attrB' ignored}}
+
+  void (&[[attr]] fn_lref)() = fn; // expected-warning{{unknown attribute 'attr' ignored}}
+  void (&&[[attr]] fn_rref)() = fn; // expected-warning{{unknown attribute 'attr' ignored}}
+}
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -186,21 +186,8 @@
 ConsumeToken();
 
 // Skip attributes.
-while (Tok.isOneOf(tok::l_square, tok::kw___attribute, tok::kw___declspec,
-   tok::kw_alignas)) {
-  if (Tok.is(tok::l_square)) {
-ConsumeBracket();
-if (!SkipUntil(tok::r_square))
-  return TPResult::Error;
-  } else {
-ConsumeToken();
-if (Tok.isNot(tok::l_paren))
-  return TPResult::Error;
-ConsumeParen();
-if (!SkipUntil(tok::r_paren))
-  return TPResult::Error;
-  }
-}
+if (!TrySkipAttributes())
+  return TPResult::Error;
 
 if (TryAnnotateOptionalCXXScopeToken())
   return TPResult::Error;
@@ -781,6 +768,30 @@
   return CAK_NotAttributeSpecifier;
 }
 
+bool Parser::TrySkipAttributes() {
+  while (Tok.isOneOf(tok::l_square, tok::kw___attribute, tok::kw___declspec,
+ tok::kw_alignas)) {
+if (Tok.is(tok::l_square)) {
+  ConsumeBracket();
+  if (Tok.isNot(tok::l_square))
+return false;
+  ConsumeBracket();
+  if (!SkipUntil(tok::r_square) || Tok.isNot(tok::r_square))
+return false;
+  ConsumeBracket();
+} else {
+  ConsumeToken();
+  if (Tok.isNot(tok::l_paren))
+return false;
+  ConsumeParen();
+  if (!SkipUntil(tok::r_paren))
+return false;
+}
+  }
+
+  return true;
+}
+
 Parser::TPResult Parser::TryParsePtrOperatorSeq() {
   while (true) {
 if (TryAnnotateOptionalCXXScopeToken(true))
@@ -790,6 +801,11 @@
 (Tok.is(tok::annot_cxxscope) && NextToken().is(tok::star))) {
   // ptr-operator
   ConsumeAnyToken();
+
+  // Skip attributes.
+  if (!TrySkipAttributes())
+return TPResult::Error;
+
   while (Tok.isOneOf(tok::kw_const, tok::kw_volatile, tok::kw_restrict,
  tok::kw__Nonnull, tok::kw__Nullable,
  tok::kw__Null_unspecified))
Index: clang/include/clang/Parse/Parser.h
===
--- clang/include/clang/Parse/Parser.h
+++ clang/include/clang/Parse/Parser.h
@@ -2441,6 +2441,10 @@
   TPResult TryParseBracketDeclarator();
   TPResult TryConsumeDeclarationSpecifier();
 
+  /// Try to skip a possibly empty sequence of 'attribute-specifier' without of
+  /// full validation of the syntactic structure of attributes.
+  bool TrySkipAttributes();
+
 public:
   TypeResult ParseTypeName(SourceRange *Range = nullptr,
DeclaratorContext Context
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 466f884 - [NFC] Remove trailing space

2020-02-17 Thread Jim Lin via cfe-commits

Author: Jim Lin
Date: 2020-02-18T10:49:13+08:00
New Revision: 466f8843f526b03c8944a46af5ebb374133b5389

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

LOG: [NFC] Remove trailing space

sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h,td}

Added: 


Modified: 
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/FileManager.cpp
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/CodeGen/CGObjCRuntime.cpp
clang/lib/Index/IndexDecl.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseTemplate.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaObjCProperty.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateVariadic.cpp
clang/lib/Serialization/ModuleManager.cpp
llvm/include/llvm-c/Core.h
llvm/lib/Analysis/AliasSetTracker.cpp
llvm/lib/Analysis/GuardUtils.cpp
llvm/lib/Analysis/Loads.cpp
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/lib/Analysis/TargetLibraryInfo.cpp
llvm/lib/Analysis/TargetTransformInfo.cpp
llvm/lib/Analysis/VectorUtils.cpp
llvm/lib/AsmParser/LLParser.cpp
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/GCRootLowering.cpp
llvm/lib/CodeGen/StackMaps.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/CodeGen/ValueTypes.cpp
llvm/lib/IR/Constants.cpp
llvm/lib/IR/Core.cpp
llvm/lib/IR/DiagnosticInfo.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/MC/XCOFFObjectWriter.cpp
llvm/lib/Support/Host.cpp

Removed: 




diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 931a1141b1b4..58e7e16d6817 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -663,7 +663,7 @@ bool 
CXXRecordDecl::lambdaIsDefaultConstructibleAndAssignable() const {
   // C++17 [expr.prim.lambda]p21:
   //   The closure type associated with a lambda-expression has no default
   //   constructor and a deleted copy assignment operator.
-  if (getLambdaCaptureDefault() != LCD_None || 
+  if (getLambdaCaptureDefault() != LCD_None ||
   getLambdaData().NumCaptures != 0)
 return false;
   return getASTContext().getLangOpts().CPlusPlus2a;
@@ -2152,7 +2152,7 @@ CXXMethodDecl 
*CXXMethodDecl::getDevirtualizedMethod(const Expr *Base,
 return DevirtualizedMethod;
 
   // Similarly, if the class itself or its destructor is marked 'final',
-  // the class can't be derived from and we can therefore devirtualize the 
+  // the class can't be derived from and we can therefore devirtualize the
   // member function call.
   if (BestDynamicDecl->isEffectivelyFinal())
 return DevirtualizedMethod;

diff  --git a/clang/lib/AST/JSONNodeDumper.cpp 
b/clang/lib/AST/JSONNodeDumper.cpp
index c30b07137edc..637b61e90a90 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -997,7 +997,7 @@ void JSONNodeDumper::VisitObjCPropertyDecl(const 
ObjCPropertyDecl *D) {
   case ObjCPropertyDecl::Required: JOS.attribute("control", "required"); break;
   case ObjCPropertyDecl::Optional: JOS.attribute("control", "optional"); break;
   }
-  
+
   ObjCPropertyDecl::PropertyAttributeKind Attrs = D->getPropertyAttributes();
   if (Attrs != ObjCPropertyDecl::OBJC_PR_noattr) {
 if (Attrs & ObjCPropertyDecl::OBJC_PR_getter)

diff  --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 14ddc13ce561..76c5fe2e5402 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -1387,7 +1387,7 @@ void StmtProfiler::VisitRequiresExpr(const RequiresExpr 
*S) {
   ID.AddInteger(concepts::Requirement::RK_Nested);
   auto *NestedReq = cast(Req);
   ID.AddBoolean(NestedReq->isSubstitutionFailure());
-  if (!NestedReq->isSubstitutionFailure())  
+  if (!NestedReq->isSubstitutionFailure())
 Visit(NestedReq->getConstraintExpr());
 }
   }

diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index e4d019aedb7c..ac8af8fcaf4a 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -513,7 +513,7 @@ FileManager::getStatValue(StringRef Path, llvm::vfs::Status 
,
   StatCache.get(), *FS);
 }
 
-std::error_code 
+std::error_code
 FileManager::getNoncachedStatValue(StringRef Path,
llvm::vfs::Status ) {
   SmallString<128> FilePath(Path);

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 48e26459e94f..6c71cf793c0f 100644
--- 

[PATCH] D71314: Emit a warning if a variable is uninitialized in indirect ASM goto destination.

2020-02-17 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 245063.
void added a comment.

Variable can't be 'const'


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

https://reviews.llvm.org/D71314

Files:
  clang/lib/Analysis/UninitializedValues.cpp
  clang/test/Analysis/uninit-asm-goto.cpp

Index: clang/test/Analysis/uninit-asm-goto.cpp
===
--- clang/test/Analysis/uninit-asm-goto.cpp
+++ clang/test/Analysis/uninit-asm-goto.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -std=c++11 -Wuninitialized -verify %s
-// expected-no-diagnostics
 
+// test1: Expect no diagnostics
 int test1(int x) {
 int y;
 asm goto("# %0 %1 %2" : "=r"(y) : "r"(x) : : err);
@@ -8,3 +8,52 @@
   err:
 return -1;
 }
+
+int test2(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  if (x < 42)
+asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) : "r"(x) :: indirect_1, indirect_2);
+  else
+asm volatile goto("testl %0, %1; testl %2, %3; jne %l5" : "+S"(x), "+D"(y) : "r"(x), "r"(y) :: indirect_1, indirect_2);
+  return x + y;
+indirect_1:
+  return -42;
+indirect_2:
+  return y; // expected-note {{uninitialized use occurs here}}
+}
+
+int test3(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  asm goto("xorl %1, %0; jmp %l2" : "="(y) : "r"(x) : : fail);
+normal:
+  y += x;
+  return y;
+  if (x) {
+fail:
+return y; // expected-note {{uninitialized use occurs here}}
+  }
+  return 0;
+}
+
+int test4(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  goto forward;
+backward:
+  return y; // expected-note {{uninitialized use occurs here}}
+forward:
+  asm goto("# %0 %1 %2" : "=r"(y) : "r"(x) : : backward);
+  return y;
+}
+
+// test5: Expect no diagnostics
+int test5(int x) {
+  int y;
+  asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) : "r"(x) :: indirect, fallthrough);
+fallthrough:
+  return y;
+indirect:
+  return -2;
+}
Index: clang/lib/Analysis/UninitializedValues.cpp
===
--- clang/lib/Analysis/UninitializedValues.cpp
+++ clang/lib/Analysis/UninitializedValues.cpp
@@ -576,6 +576,28 @@
   continue;
 }
 
+if (AtPredExit == MayUninitialized) {
+  // If the predecessor's terminator is an "asm goto" that initializes
+  // the variable, then it won't be counted as "initialized" on the
+  // non-fallthrough paths.
+  CFGTerminator term = Pred->getTerminator();
+  if (const auto *as = dyn_cast_or_null(term.getStmt())) {
+const CFGBlock *fallthrough = *Pred->succ_begin();
+if (as->isAsmGoto() &&
+llvm::any_of(as->outputs(), [&](const Expr *output) {
+return vd == findVar(output).getDecl() &&
+llvm::any_of(as->labels(),
+ [&](const AddrLabelExpr *label) {
+  return label->getLabel()->getStmt() == B->Label &&
+  B != fallthrough;
+});
+})) {
+  Use.setUninitAfterDecl();
+  continue;
+}
+  }
+}
+
 unsigned  = SuccsVisited[Pred->getBlockID()];
 if (!SV) {
   // When visiting the first successor of a block, mark all NULL
@@ -767,8 +789,9 @@
 return;
 
   for (const auto  : as->outputs())
-if (const VarDecl *VD = findVar(o).getDecl())
-  vals[VD] = Initialized;
+if (const auto *VD = findVar(o).getDecl())
+  if (vals[VD] != Initialized)
+vals[VD] = MayUninitialized;
 }
 
 void TransferFunctions::VisitObjCMessageExpr(ObjCMessageExpr *ME) {
@@ -809,7 +832,7 @@
   tf.Visit(const_cast(cs->getStmt()));
   }
   CFGTerminator terminator = block->getTerminator();
-  if (GCCAsmStmt *as = dyn_cast_or_null(terminator.getStmt()))
+  if (auto *as = dyn_cast_or_null(terminator.getStmt()))
 if (as->isAsmGoto())
   tf.Visit(as);
   return vals.updateValueVectorWithScratch(block);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72825: Remove unused option that gcc ignored

2020-02-17 Thread Jim Lin via Phabricator via cfe-commits
Jim added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72825



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


RE: [PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-17 Thread Liu, Yaxun (Sam) via cfe-commits
[AMD Official Use Only - Internal Distribution Only]

It seems to be caused by some commit hash before 
20c5968e0953d978be4d9d1062801e8758c393b5.

Sam

-Original Message-
From: Jacques Pienaar via Phabricator  
Sent: Monday, February 17, 2020 10:58 AM
To: Liu, Yaxun (Sam) ; t...@google.com; rjmcc...@gmail.com; 
rich...@metafoo.co.uk; jdoerf...@anl.gov; a.bat...@hotmail.com
Cc: jpien...@google.com; mask...@google.com; michael.hl...@gmail.com; 
mariya.podchishcha...@intel.com; alexey.ba...@intel.com; 
zhang.guans...@gmail.com; her...@google.com; r...@google.com; 
cfe-commits@lists.llvm.org; mlek...@skidmore.edu; blitzrak...@gmail.com; 
shen...@google.com
Subject: [PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a 
post-parsing AST travese

[CAUTION: External Email]

jpienaar added a comment.

This seems to result in triggering clang/lib/CodeGen/CGExpr.cpp:2626 when 
compiling mlir/lib/Transforms/AffineDataCopyGeneration.cpp with clang build 
with assertions on (clean build at e8e078c 

 just before this change, broken at this, assert triggering at build fix 
commit).

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbuildkite.com%2Fmlir%2Fmlir-core%2Fbuilds%2F2792%23a54fb239-718b-4f0b-a309-f83e46ceb252data=02%7C01%7Cyaxun.liu%40amd.com%7C929d8d11429a4c4072e108d7b3db6042%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175627129064872sdata=nma5u9l5h6tkzQEX0hVfYe6VJQBXubt%2FCOF%2BWyWSujM%3Dreserved=0


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD70172%2Fnew%2Fdata=02%7C01%7Cyaxun.liu%40amd.com%7C929d8d11429a4c4072e108d7b3db6042%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175627129064872sdata=yGGqSBdf6zVYW7IDFW57UEagQAyvaOfn2a8xu%2BaIr9o%3Dreserved=0

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD70172data=02%7C01%7Cyaxun.liu%40amd.com%7C929d8d11429a4c4072e108d7b3db6042%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175627129064872sdata=sbHpgiR9tKyv0%2F4ZnuhUX%2BFaIHdtwoHTyOJxX1%2F46mg%3Dreserved=0


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


[PATCH] D71903: [Coroutines][6/6] Clang schedules new passes

2020-02-17 Thread Brian Gesiak via Phabricator via cfe-commits
modocache updated this revision to Diff 245054.
modocache removed a reviewer: wenlei.
modocache removed subscribers: wenlei, hiraditya.
modocache removed a project: LLVM.
modocache added a comment.

Rebase on top of the latest version of D71902 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71903

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp

Index: clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
===
--- /dev/null
+++ clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
@@ -0,0 +1,57 @@
+// Tests that coroutine passes are added to and run by the new pass manager
+// pipeline, at -O0 and above.
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null \
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts \
+// RUN:   -O0 %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -o /dev/null \
+// RUN:   -fexperimental-new-pass-manager -fdebug-pass-manager -fcoroutines-ts \
+// RUN:   -O1 %s 2>&1 | FileCheck %s
+//
+// CHECK: Starting llvm::Module pass manager run.
+// CHECK: Running pass:{{.*}}CoroEarlyPass
+//
+// The first coro-split pass enqueues a second run of the entire CGSCC pipeline.
+// CHECK: Starting CGSCC pass manager run.
+// CHECK: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on (_Z3foov)
+// CHECK: Finished CGSCC pass manager run.
+//
+// The second coro-split pass splits coroutine 'foo' into funclets
+// 'foo.resume', 'foo.destroy', and 'foo.cleanup'.
+// CHECK: Starting CGSCC pass manager run.
+// CHECK: Running pass: CoroSplitPass on (_Z3foov)
+// CHECK: Running pass:{{.*}}CoroElidePass{{.*}} on (_Z3foov)
+// CHECK: Finished CGSCC pass manager run.
+//
+// CHECK: Running pass:{{.*}}CoroCleanupPass
+// CHECK: Finished llvm::Module pass manager run.
+
+namespace std {
+namespace experimental {
+
+struct handle {};
+
+struct awaitable {
+  bool await_ready() { return true; }
+  void await_suspend(handle) {}
+  bool await_resume() { return true; }
+};
+
+template  struct coroutine_handle {
+  static handle from_address(void *address) { return {}; }
+};
+
+template  struct coroutine_traits {
+  struct promise_type {
+awaitable initial_suspend() { return {}; }
+awaitable final_suspend() { return {}; }
+void return_void() {}
+T get_return_object() { return T(); }
+void unhandled_exception() {}
+  };
+};
+} // namespace experimental
+} // namespace std
+
+void foo() { co_return; }
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -49,6 +49,10 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetOptions.h"
 #include "llvm/Transforms/Coroutines.h"
+#include "llvm/Transforms/Coroutines/CoroCleanup.h"
+#include "llvm/Transforms/Coroutines/CoroEarly.h"
+#include "llvm/Transforms/Coroutines/CoroElide.h"
+#include "llvm/Transforms/Coroutines/CoroSplit.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/IPO/AlwaysInliner.h"
 #include "llvm/Transforms/IPO/LowerTypeTests.h"
@@ -957,6 +961,22 @@
   }
 }
 
+static void addCoroutinePassesAtO0(ModulePassManager ,
+   const LangOptions ,
+   const CodeGenOptions ) {
+  if (!LangOpts.Coroutines)
+return;
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroEarlyPass()));
+
+  CGSCCPassManager CGPM(CodeGenOpts.DebugPassManager);
+  CGPM.addPass(CoroSplitPass());
+  CGPM.addPass(createCGSCCToFunctionPassAdaptor(CoroElidePass()));
+  MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM)));
+
+  MPM.addPass(createModuleToFunctionPassAdaptor(CoroCleanupPass()));
+}
+
 static void addSanitizersAtO0(ModulePassManager ,
   const Triple ,
   const LangOptions ,
@@ -1076,6 +1096,7 @@
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
   PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
   PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+  PTO.Coroutines = LangOpts.Coroutines;
 
   PassInstrumentationCallbacks PIC;
   StandardInstrumentations SI;
@@ -1279,6 +1300,7 @@
 }
 
 if (CodeGenOpts.OptimizationLevel == 0) {
+  addCoroutinePassesAtO0(MPM, LangOpts, CodeGenOpts);
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74562: [OpenMP][OMPIRBuilder] Introducing the `OMPBuilderCBHelpers` helper class

2020-02-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM assuming the comment below is addressed.




Comment at: clang/lib/CodeGen/CodeGenFunction.h:354
+
+FinilizationBlock = CGF.getJumpDestInCurrentScope();
+  }

fghanim wrote:
> jdoerfert wrote:
> > Don't we have to set/reset the `CGF.ReturnBlock` ? If not, why do we need 
> > `FinilizationBlock` here?
> Yes, and we still do for outlined regions (check `OutlinedRegionBodyRAII` 
> ctor above). 
> 
> This is for inlined regions, and those shouldn't change the 
> `CGF.ReturnBlock`. It should re-use the `CGF.ReturnBlock` for the enclosing 
> outlined region.
> The only reason I kept it, is because `CGF.getJumpDestInCurrentScope()` was 
> updating a counter that seemed to me to relate to `EHStack`, and I didn't 
> want to remove it without investigating first.
I see. Maybe remove the `FinilizationBlock` member though. Call 
`getJumpDestInCurrentScope` and add a comment (TODO) that explains this, e.g., 
says it has to be investigated further.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74562



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


[PATCH] D74673: CGBuiltin: Remove uses of deprecated CreateCall overloads

2020-02-17 Thread Nicolai Hähnle via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbf197304a66a: CGBuiltin: Remove uses of deprecated 
CreateCall overloads (authored by nhaehnle).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74673

Files:
  clang/lib/CodeGen/CGBuiltin.cpp


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -13303,7 +13303,7 @@
 llvm::Value *Src2 = EmitScalarExpr(E->getArg(2));
 
 // FIXME-GFX10: How should 32 bit mask be handled?
-Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_icmp,
+Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_icmp,
   { Builder.getInt64Ty(), Src0->getType() });
 return Builder.CreateCall(F, { Src0, Src1, Src2 });
   }
@@ -13314,7 +13314,7 @@
 llvm::Value *Src2 = EmitScalarExpr(E->getArg(2));
 
 // FIXME-GFX10: How should 32 bit mask be handled?
-Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_fcmp,
+Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_fcmp,
   { Builder.getInt64Ty(), Src0->getType() });
 return Builder.CreateCall(F, { Src0, Src1, Src2 });
   }


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -13303,7 +13303,7 @@
 llvm::Value *Src2 = EmitScalarExpr(E->getArg(2));
 
 // FIXME-GFX10: How should 32 bit mask be handled?
-Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_icmp,
+Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_icmp,
   { Builder.getInt64Ty(), Src0->getType() });
 return Builder.CreateCall(F, { Src0, Src1, Src2 });
   }
@@ -13314,7 +13314,7 @@
 llvm::Value *Src2 = EmitScalarExpr(E->getArg(2));
 
 // FIXME-GFX10: How should 32 bit mask be handled?
-Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_fcmp,
+Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_fcmp,
   { Builder.getInt64Ty(), Src0->getType() });
 return Builder.CreateCall(F, { Src0, Src1, Src2 });
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-02-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Thanks, I think this approach is really improving the existing code.




Comment at: clang/include/clang/AST/GlobalDecl.h:40
+  Stub = 1,
+};
+

The attribute here is `CUDAGlobalAttr`; should this be named in terms of CUDA, 
or is the CUDA model sufficiently different  from HIP that the same 
implementation concept doesn't apply?



Comment at: clang/include/clang/AST/GlobalDecl.h:52
+assert((!D || !isa(D)) && "Use other ctor with ctor 
decls!");
+assert((!D || !isa(D)) && "Use other ctor with dtor 
decls!");
 

This function exists primarily to be used as a common initializer for all the 
constructors that don't require any of the extra fields.  (This file predates 
LLVM's adoption of C++14, which allows constructors to delegate to other 
constructors.)  That's why it asserts that it's not used with constructors or 
destructors.  So, two questions:

- Is there a reason this function now needs to tolerate null declarations?
- There's some subtle implicit behavior here, in that references to kernels 
default to `HIPKernelKind::Kernel`.  Is that reasonable, or should there be a 
third assertion that this function isn't used with kernel declarations?



Comment at: clang/include/clang/AST/GlobalDecl.h:131
 
+  operator bool() const { return getAsOpaquePtr(); }
+

`explicit`, please.



Comment at: clang/include/clang/AST/GlobalDecl.h:162
+   getDecl()) &&
+   !cast(getDecl())->hasAttr() &&
!isa(getDecl()) &&

The indentation here seems odd.



Comment at: clang/lib/AST/ItaniumMangle.cpp:401
 : Context(C), Out(Out_), Structor(getStructor(D)), StructorType(Type),
   SeqID(0), AbiTagsRoot(AbiTags) { }
 

Does passing down a `GlobalDecl` everywhere allow us to remove these 
constructors, i.e. to eliminate the `Structor` and `StructorType` fields?



Comment at: clang/lib/AST/ItaniumMangle.cpp:645
+void CXXNameMangler::mangle(GlobalDecl GD) {
+  const NamedDecl *D = dyn_cast(GD.getDecl());
   //  ::= _Z 

This can just be `cast`, except actually I don't think you need a cast here at 
all given the code below.



Comment at: clang/lib/AST/ItaniumMangle.cpp:818
 
-  return nullptr;
+  return GlobalDecl::getFromOpaquePtr(nullptr);
 }

There's a default constructor.



Comment at: clang/lib/AST/ItaniumMangle.cpp:1597
+  else if (auto *DD = dyn_cast(DC))
+DCGD = GlobalDecl(DD, Dtor_Complete);
+  else

The relevant wording from the Itanium spec here is:

> For entities in constructors and destructors, the mangling of the complete 
> object constructor or destructor is used as the base function name, i.e. the 
> C1 or D1 version.

But you might consider pulling this out as a helper function, something like:

```
static GlobalDecl getParentOfLocalEntity(const DeclContext *DC);
```



Comment at: clang/lib/AST/ItaniumMangle.cpp:1599
+  else
+DCGD = GlobalDecl(dyn_cast(DC));
+  mangleFunctionEncoding(DCGD);

This can still be `cast`.



Comment at: clang/lib/AST/ItaniumMangle.cpp:1899
   = Template.getAsOverloadedTemplate()) {
-mangleUnqualifiedName(nullptr, (*Overloaded->begin())->getDeclName(),
+mangleUnqualifiedName(static_cast(nullptr), 
(*Overloaded->begin())->getDeclName(),
   UnknownArity, nullptr);

You can just pass `GlobalDecl()` here.



Comment at: clang/lib/AST/ItaniumMangle.cpp:4986
   assert(!isa(D) && !isa(D) &&
  "Invalid mangleName() call on 'structor decl!");
 

The second assertion can just be removed now, since the GD should be carrying 
the right information.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1028
 else
-  MC.mangleName(ND, Out);
+  MC.mangleName(GD, Out);
   } else {

Let's see if we can make this breakdown no longer necessary, since 
`MangleContext::mangleName` should be capable of doing the right thing starting 
straight from a GD.  In fact, maybe we can remove most of the specialized 
mangling methods (like  `mangleCXXCtor` and `mangleCXXDtor`) from 
`MangleContext` completely?

Unrelatedly: there's an `Out` declared in the outermost scope, but a bunch of 
these scopes declare their own `Out`; could you just fix that while you're 
editing this function?



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:1041
+  llvm::raw_svector_ostream Out(Buffer);
+  Out << "__device_stub__" << II->getName();
 } else {

Is this the best way of handling this, or should `shouldMangleDeclName` return 
true for kernels (or at least stubs?) even in C?  Honest question.



[clang] bf19730 - CGBuiltin: Remove uses of deprecated CreateCall overloads

2020-02-17 Thread Nicolai Hähnle via cfe-commits

Author: Nicolai Hähnle
Date: 2020-02-18T00:24:09+01:00
New Revision: bf197304a66aac3cde967539b40c018cede66761

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

LOG: CGBuiltin: Remove uses of deprecated CreateCall overloads

Reviewers: t.p.northover

Subscribers: cfe-commits, llvm-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index af9be3a1c128..eb87180ee900 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -13303,7 +13303,7 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
 llvm::Value *Src2 = EmitScalarExpr(E->getArg(2));
 
 // FIXME-GFX10: How should 32 bit mask be handled?
-Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_icmp,
+Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_icmp,
   { Builder.getInt64Ty(), Src0->getType() });
 return Builder.CreateCall(F, { Src0, Src1, Src2 });
   }
@@ -13314,7 +13314,7 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
 llvm::Value *Src2 = EmitScalarExpr(E->getArg(2));
 
 // FIXME-GFX10: How should 32 bit mask be handled?
-Value *F = CGM.getIntrinsic(Intrinsic::amdgcn_fcmp,
+Function *F = CGM.getIntrinsic(Intrinsic::amdgcn_fcmp,
   { Builder.getInt64Ty(), Src0->getType() });
 return Builder.CreateCall(F, { Src0, Src1, Src2 });
   }



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Yancheng Zheng via Phabricator via cfe-commits
AnakinZheng updated this revision to Diff 245036.
AnakinZheng added a comment.

Implement @sammccall 's suggestion and add test.


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

https://reviews.llvm.org/D74731

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -57,6 +57,14 @@
   EXPECT_EQ(lspLength("¥"), 1UL);
   // astral
   EXPECT_EQ(lspLength(""), 2UL);
+  // Extended ASCII
+  const char extendedASCIIStr[2] = {static_cast(160U), '\0'};
+  EXPECT_EQ(lspLength(extendedASCIIStr), 1UL);
+  // Invalid UTF16
+  const char invalidUTF16[6] = {
+  static_cast(0xFF), static_cast(0xFF), 
static_cast(0xFF),
+  static_cast(0xFF), static_cast(0xFF), '\0'};
+  EXPECT_EQ(lspLength(invalidUTF16), 2UL);
 
   WithContextValue UTF8(kCurrentOffsetEncoding, OffsetEncoding::UTF8);
   EXPECT_EQ(lspLength(""), 0UL);
@@ -66,6 +74,10 @@
   EXPECT_EQ(lspLength("¥"), 2UL);
   // astral
   EXPECT_EQ(lspLength(""), 4UL);
+  // Extended ASCII
+  EXPECT_EQ(lspLength(extendedASCIIStr), 1UL);
+  // Invalid UTF16
+  EXPECT_EQ(lspLength(invalidUTF16), 5UL);
 
   WithContextValue UTF32(kCurrentOffsetEncoding, OffsetEncoding::UTF32);
   EXPECT_EQ(lspLength(""), 0UL);
@@ -75,6 +87,10 @@
   EXPECT_EQ(lspLength("¥"), 1UL);
   // astral
   EXPECT_EQ(lspLength(""), 1UL);
+  // Extended ASCII
+  EXPECT_EQ(lspLength(extendedASCIIStr), 1UL);
+  // Invalid UTF16
+  EXPECT_EQ(lspLength(invalidUTF16), 1UL);
 }
 
 // The = →  below are ASCII (1 byte), BMP (3 bytes), and astral (4 bytes).
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -67,15 +67,20 @@
 }
 // This convenient property of UTF-8 holds for all non-ASCII characters.
 size_t UTF8Length = llvm::countLeadingOnes(C);
-// 0xxx is ASCII, handled above. 10xxx is a trailing byte, invalid here.
-// 1xxx is not valid UTF-8 at all. Assert because it's probably our 
bug.
-assert((UTF8Length >= 2 && UTF8Length <= 4) &&
-   "Invalid UTF-8, or transcoding bug?");
 I += UTF8Length; // Skip over all trailing bytes.
-// A codepoint takes two UTF-16 code unit if it's astral (outside BMP).
-// Astral codepoints are encoded as 4 bytes in UTF-8 (0xxx ...)
-if (CB(UTF8Length, UTF8Length == 4 ? 2 : 1))
-  return true;
+// 0xxx is ASCII, handled above. 10xxx is a trailing byte, invalid here.
+// 1xxx is not valid UTF-8 at all. Log it because it's probably our 
bug.
+if(UTF8Length == 1 || UTF8Length > 4) {
+  vlog("File contains invalid UTF-8, or transcoding bug? UTF8Length = {0}, 
string = {1}", UTF8Length, U8);
+  // If UTF8 length is 1, treat as one UTF8, if above 4, treat as one UTF16
+  if (CB(UTF8Length, UTF8Length == 1 ? 1 : 2))
+return true;
+} else {
+  // A codepoint takes two UTF-16 code unit if it's astral (outside BMP).
+  // Astral codepoints are encoded as 4 bytes in UTF-8 (0xxx ...)
+  if (CB(UTF8Length, UTF8Length == 4 ? 2 : 1))
+return true;
+}
   }
   return false;
 }


Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -57,6 +57,14 @@
   EXPECT_EQ(lspLength("¥"), 1UL);
   // astral
   EXPECT_EQ(lspLength(""), 2UL);
+  // Extended ASCII
+  const char extendedASCIIStr[2] = {static_cast(160U), '\0'};
+  EXPECT_EQ(lspLength(extendedASCIIStr), 1UL);
+  // Invalid UTF16
+  const char invalidUTF16[6] = {
+  static_cast(0xFF), static_cast(0xFF), static_cast(0xFF),
+  static_cast(0xFF), static_cast(0xFF), '\0'};
+  EXPECT_EQ(lspLength(invalidUTF16), 2UL);
 
   WithContextValue UTF8(kCurrentOffsetEncoding, OffsetEncoding::UTF8);
   EXPECT_EQ(lspLength(""), 0UL);
@@ -66,6 +74,10 @@
   EXPECT_EQ(lspLength("¥"), 2UL);
   // astral
   EXPECT_EQ(lspLength(""), 4UL);
+  // Extended ASCII
+  EXPECT_EQ(lspLength(extendedASCIIStr), 1UL);
+  // Invalid UTF16
+  EXPECT_EQ(lspLength(invalidUTF16), 5UL);
 
   WithContextValue UTF32(kCurrentOffsetEncoding, OffsetEncoding::UTF32);
   EXPECT_EQ(lspLength(""), 0UL);
@@ -75,6 +87,10 @@
   EXPECT_EQ(lspLength("¥"), 1UL);
   // astral
   EXPECT_EQ(lspLength(""), 1UL);
+  // Extended ASCII
+  EXPECT_EQ(lspLength(extendedASCIIStr), 1UL);
+  // Invalid UTF16
+  EXPECT_EQ(lspLength(invalidUTF16), 1UL);
 }
 
 // The = →  below are ASCII (1 byte), BMP (3 bytes), and astral (4 bytes).
Index: clang-tools-extra/clangd/SourceCode.cpp

[PATCH] D74669: [clang-tidy] New check: misc-no-include-cpp

2020-02-17 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 245031.
jroelofs added a comment.

Make the diagnostics more accurate.


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

https://reviews.llvm.org/D74669

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.hpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.c
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cc
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cxx
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
@@ -0,0 +1,21 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-include %t -- -- -isystem %S/Inputs/Headers -fmodules
+
+// CHECK-MESSAGES: [[@LINE+4]]:11: warning: suspicious #include of file with .cpp extension
+// CHECK-MESSAGES: [[@LINE+3]]:11: note: did you mean to include 'a'?
+// CHECK-MESSAGES: [[@LINE+2]]:11: note: did you mean to include 'a.h'?
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'a.hpp'?
+#include "a.cpp"
+
+#include "b.h"
+
+// CHECK-MESSAGES: [[@LINE+1]]:10: warning: suspicious #import of file with .c extension
+#import "c.c"
+
+// CHECK-MESSAGES: [[@LINE+1]]:16: warning: suspicious #include_next of file with .c extension
+#include_next 
+
+// CHECK-MESSAGES: [[@LINE+1]]:13: warning: suspicious #include of file with .cc extension
+# include  
+
+// CHECK-MESSAGES: [[@LINE+1]]:14: warning: suspicious #include of file with .cxx extension
+#  include  
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
@@ -0,0 +1,39 @@
+//===--- SuspiciousIncludeCheck.h - clang-tidy --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+/// Warns on inclusion of files whose names suggest that they're implementation
+/// files, instead of headers. E.g:
+///
+/// #include "foo.cpp"  // warning
+/// #include "bar.c"// warning
+/// #include "baz.h"// no diagnostic
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-include.html
+class SuspiciousIncludeCheck : public ClangTidyCheck {
+public:
+  SuspiciousIncludeCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerPPCallbacks(const SourceManager , Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+};
+
+} // namespace bugprone
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
@@ -0,0 +1,75 @@
+//===--- SuspiciousIncludeCheck.cpp - clang-tidy --===//
+//
+// 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 "SuspiciousIncludeCheck.h"
+#include "clang/AST/ASTContext.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+namespace {
+class SuspiciousIncludePPCallbacks : public PPCallbacks {
+public:
+  explicit SuspiciousIncludePPCallbacks(ClangTidyCheck ,
+const SourceManager ,
+Preprocessor *PP)
+  : Check(Check), PP(PP) {}
+
+  void InclusionDirective(SourceLocation HashLoc, const Token ,
+  StringRef FileName, bool IsAngled,
+

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-17 Thread Ruyman via Phabricator via cfe-commits
Ruyk added a subscriber: Naghasan.
Ruyk added a comment.

@Naghasan please take a look


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Yancheng Zheng via Phabricator via cfe-commits
AnakinZheng marked an inline comment as done.
AnakinZheng added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:62
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))

kadircet wrote:
> AnakinZheng wrote:
> > kadircet wrote:
> > > AnakinZheng wrote:
> > > > kadircet wrote:
> > > > > `C` is one byte long, it is not possible for it to ever satisfy 
> > > > > `C&0x100`.
> > > > Updated the patch, now it should be correct.
> > > sorry but this is still the same since `C` is an `unsigned char` it is 
> > > always guaranteed to be less than or equal to 255.
> > > 
> > > As @sammccall explained above, we should rather re-arrange the logic to 
> > > get rid of the assertion below, e.g. when `UTF8Length` is less than 2 or 
> > > more than 4 we can choose to interpret it as ascii, instead of asserting, 
> > > while commenting the reason for this choice.
> > It's unsigned short in the new patch. Ok, I'll try @sammccall 's suggestion.
> > It's unsigned short in the new patch.
> 
> Sorry I missed that change, but still `U8[I]` is a one byte element(it is of 
> type `char`), you can't get away by just casting it to `unsigned short`.
Yup, just aware of that, @sammccall 's suggestion looks reasonable, 
implementing now.


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

https://reviews.llvm.org/D74731



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:62
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))

AnakinZheng wrote:
> kadircet wrote:
> > AnakinZheng wrote:
> > > kadircet wrote:
> > > > `C` is one byte long, it is not possible for it to ever satisfy 
> > > > `C&0x100`.
> > > Updated the patch, now it should be correct.
> > sorry but this is still the same since `C` is an `unsigned char` it is 
> > always guaranteed to be less than or equal to 255.
> > 
> > As @sammccall explained above, we should rather re-arrange the logic to get 
> > rid of the assertion below, e.g. when `UTF8Length` is less than 2 or more 
> > than 4 we can choose to interpret it as ascii, instead of asserting, while 
> > commenting the reason for this choice.
> It's unsigned short in the new patch. Ok, I'll try @sammccall 's suggestion.
> It's unsigned short in the new patch.

Sorry I missed that change, but still `U8[I]` is a one byte element(it is of 
type `char`), you can't get away by just casting it to `unsigned short`.


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

https://reviews.llvm.org/D74731



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


[PATCH] D73629: [analyzer] vfork checker: allow execve after vfork

2020-02-17 Thread Jan Včelák via Phabricator via cfe-commits
janvcelak updated this revision to Diff 245025.
janvcelak added a comment.

I'm attaching updated version with tests.


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

https://reviews.llvm.org/D73629

Files:
  clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/vfork.c


Index: clang/test/Analysis/vfork.c
===
--- clang/test/Analysis/vfork.c
+++ clang/test/Analysis/vfork.c
@@ -6,7 +6,7 @@
 void foo();
 
 // Ensure that child process is properly checked.
-int f1(int x) {
+int f1(int x, int y) {
   pid_t pid = vfork(); // expected-warning{{Call to function 'vfork' is 
insecure}}
   if (pid != 0)
 return 0;
@@ -16,7 +16,29 @@
 // Ensure that modifying pid is ok.
 pid = 1; // no-warning
 // Ensure that calling whitelisted routines is ok.
-execl("", "", 0); // no-warning
+switch (y) {
+case 0:
+  execl("", "", 0); // no-warning
+  break;
+case 1:
+  execle("", "", 0); // no-warning
+  break;
+case 2:
+  execlp("", "", 0); // no-warning
+  break;
+case 3:
+  execv("", NULL); // no-warning
+  break;
+case 4:
+  execve("", NULL, NULL); // no-warning
+  break;
+case 5:
+  execvp("", NULL); // no-warning
+  break;
+case 6:
+  execvpe("", NULL, NULL); // no-warning
+  break;
+}
 _exit(1); // no-warning
 break;
   case 1:
Index: clang/test/Analysis/Inputs/system-header-simulator.h
===
--- clang/test/Analysis/Inputs/system-header-simulator.h
+++ clang/test/Analysis/Inputs/system-header-simulator.h
@@ -98,6 +98,12 @@
 pid_t fork(void);
 pid_t vfork(void);
 int execl(const char *path, const char *arg, ...);
+int execle(const char *path, const char *arg, ...);
+int execlp(const char *file, const char *arg, ...);
+int execv(const char *path, char *const argv[]);
+int execve(const char *path, char *const argv[], char *const envp[]);
+int execvp(const char *file, char *const argv[]);
+int execvpe(const char *file, char *const argv[], char *const envp[]);
 
 void exit(int status) __attribute__ ((__noreturn__));
 void _exit(int status) __attribute__ ((__noreturn__));
Index: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
@@ -98,12 +98,13 @@
   if (VforkWhitelist.empty()) {
 // According to manpage.
 const char *ids[] = {
-  "_exit",
   "_Exit",
+  "_exit",
   "execl",
-  "execlp",
   "execle",
+  "execlp",
   "execv",
+  "execve",
   "execvp",
   "execvpe",
   nullptr


Index: clang/test/Analysis/vfork.c
===
--- clang/test/Analysis/vfork.c
+++ clang/test/Analysis/vfork.c
@@ -6,7 +6,7 @@
 void foo();
 
 // Ensure that child process is properly checked.
-int f1(int x) {
+int f1(int x, int y) {
   pid_t pid = vfork(); // expected-warning{{Call to function 'vfork' is insecure}}
   if (pid != 0)
 return 0;
@@ -16,7 +16,29 @@
 // Ensure that modifying pid is ok.
 pid = 1; // no-warning
 // Ensure that calling whitelisted routines is ok.
-execl("", "", 0); // no-warning
+switch (y) {
+case 0:
+  execl("", "", 0); // no-warning
+  break;
+case 1:
+  execle("", "", 0); // no-warning
+  break;
+case 2:
+  execlp("", "", 0); // no-warning
+  break;
+case 3:
+  execv("", NULL); // no-warning
+  break;
+case 4:
+  execve("", NULL, NULL); // no-warning
+  break;
+case 5:
+  execvp("", NULL); // no-warning
+  break;
+case 6:
+  execvpe("", NULL, NULL); // no-warning
+  break;
+}
 _exit(1); // no-warning
 break;
   case 1:
Index: clang/test/Analysis/Inputs/system-header-simulator.h
===
--- clang/test/Analysis/Inputs/system-header-simulator.h
+++ clang/test/Analysis/Inputs/system-header-simulator.h
@@ -98,6 +98,12 @@
 pid_t fork(void);
 pid_t vfork(void);
 int execl(const char *path, const char *arg, ...);
+int execle(const char *path, const char *arg, ...);
+int execlp(const char *file, const char *arg, ...);
+int execv(const char *path, char *const argv[]);
+int execve(const char *path, char *const argv[], char *const envp[]);
+int execvp(const char *file, char *const argv[]);
+int execvpe(const char *file, char *const argv[], char *const envp[]);
 
 void exit(int status) __attribute__ ((__noreturn__));
 void _exit(int status) __attribute__ ((__noreturn__));
Index: clang/lib/StaticAnalyzer/Checkers/VforkChecker.cpp
===
--- 

[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Yancheng Zheng via Phabricator via cfe-commits
AnakinZheng marked an inline comment as done.
AnakinZheng added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:62
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))

kadircet wrote:
> AnakinZheng wrote:
> > kadircet wrote:
> > > `C` is one byte long, it is not possible for it to ever satisfy `C&0x100`.
> > Updated the patch, now it should be correct.
> sorry but this is still the same since `C` is an `unsigned char` it is always 
> guaranteed to be less than or equal to 255.
> 
> As @sammccall explained above, we should rather re-arrange the logic to get 
> rid of the assertion below, e.g. when `UTF8Length` is less than 2 or more 
> than 4 we can choose to interpret it as ascii, instead of asserting, while 
> commenting the reason for this choice.
It's unsigned short in the new patch. Ok, I'll try @sammccall 's suggestion.


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

https://reviews.llvm.org/D74731



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:62
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))

AnakinZheng wrote:
> kadircet wrote:
> > `C` is one byte long, it is not possible for it to ever satisfy `C&0x100`.
> Updated the patch, now it should be correct.
sorry but this is still the same since `C` is an `unsigned char` it is always 
guaranteed to be less than or equal to 255.

As @sammccall explained above, we should rather re-arrange the logic to get rid 
of the assertion below, e.g. when `UTF8Length` is less than 2 or more than 4 we 
can choose to interpret it as ascii, instead of asserting, while commenting the 
reason for this choice.


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

https://reviews.llvm.org/D74731



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Specifically, we can't change the return value for any valid utf-8 string (see 
tests).

Instead, where we currently assert length is between 2 and 4, you could change 
that to an if and treat it (arbitrarily) as a one-utf-8-byte, 
one-utf-16-code-unit character.

This new behavior should have a test.


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

https://reviews.llvm.org/D74731



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


[PATCH] D74692: [clang-tidy] Make bugprone-use-after-move ignore std::move for const values

2020-02-17 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

In D74692#1879039 , @mboehme wrote:

> Even if no move actually happens, the code is still wrong


IMHO, it's not wrong, but it's inefficient. And will be reported by 
performance-move-const-arg.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74692



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Yancheng Zheng via Phabricator via cfe-commits
AnakinZheng marked an inline comment as done.
AnakinZheng added a comment.

Update patch.




Comment at: clang-tools-extra/clangd/SourceCode.cpp:62
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))

kadircet wrote:
> `C` is one byte long, it is not possible for it to ever satisfy `C&0x100`.
Updated the patch, now it should be correct.


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

https://reviews.llvm.org/D74731



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Yancheng Zheng via Phabricator via cfe-commits
AnakinZheng updated this revision to Diff 245021.
AnakinZheng added a comment.

Fix the previous stupid mistake.


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

https://reviews.llvm.org/D74731

Files:
  clang-tools-extra/clangd/SourceCode.cpp


Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -58,8 +58,8 @@
   // A codepoint takes two UTF-16 code unit if it's astral (outside BMP).
   // Astral codepoints are encoded as 4 bytes in UTF-8, starting with 0xxx.
   for (size_t I = 0; I < U8.size();) {
-unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
+unsigned short C = static_cast(U8[I]);
+if (LLVM_LIKELY(C <= 255)) { // ASCII or extended ASCII character.
   if (CB(1, 1))
 return true;
   ++I;


Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -58,8 +58,8 @@
   // A codepoint takes two UTF-16 code unit if it's astral (outside BMP).
   // Astral codepoints are encoded as 4 bytes in UTF-8, starting with 0xxx.
   for (size_t I = 0; I < U8.size();) {
-unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
+unsigned short C = static_cast(U8[I]);
+if (LLVM_LIKELY(C <= 255)) { // ASCII or extended ASCII character.
   if (CB(1, 1))
 return true;
   ++I;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74361: [Clang] Uninitialize attribute on global variables

2020-02-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I'm not sure if it's a good idea to be re-using the existing attribute like 
this.  It's not that unreasonable, I guess, but I'd like to hear JF's thoughts.

I think you do need to update the documentation to mention the impact on 
globals.  For normal targets (i.e. ones with loaders), I assume this guarantees 
a zero pattern.  Except maybe not for thread-locals?  Do we have any targets 
where we can actually optimize thread-locals by suppressing initialization?

This will need to impact static analysis and the AST, I think.  Local variables 
can't be redeclared, but global variables can, so disallowing initializers 
syntactically when the attribute is present doesn't necessarily stop other 
declarations from defining the variable.  Also, you need to make the attribute 
mark something as a definition, the same way that e.g. the alias attribute 
does.  Also, this probably ought to disable the default-initialization of 
non-trivial types in C++, in case that's not already done.




Comment at: clang/test/Sema/attr-uninitialized.c:9
   int im_bad __attribute((uninitialized("zero")));  // expected-error 
{{'uninitialized' attribute takes no arguments}}
-  static int im_baaad __attribute((uninitialized)); // expected-warning 
{{'uninitialized' attribute only applies to local variables}}
 }
 

In general, you shouldn't remove the existing test lines; just modify them to 
not report a diagnostic.



Comment at: clang/test/Sema/attr-uninitialized.c:12
+void answer_right_now() __attribute((uninitialized)) {}
// expected-warning {{'uninitialized' attribute only applies to variables}}
+void just_to_tell_you_once_again(__attribute((uninitialized)) int whos_bad) {}
 

This should still be diagnosed; it doesn't make any sense to apply this to 
parameters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74361



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Yeah I think there must be some confusion about what this code is doing. It's 
specifically iterating over the unicode codepoints of what are supposed to be 
UTF-8-encoded input bytes.

The input turns out sometimes not to be UTF-8 (e.g. the file on disk is 
ISO-8859-1 and clang thinks it's UTF-8 and just loads the bytes). We can't give 
any sort of right answer in these cases - we don't know the actual encoding and 
we can't even always detect these cases!

What we can do is strengthen the contract: instead of UB, assert in practice, 
we can say returns some garbage value but doesn't crash.


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

https://reviews.llvm.org/D74731



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


RE: [PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-17 Thread Liu, Yaxun (Sam) via cfe-commits
[AMD Official Use Only - Internal Distribution Only]

I am taking a look. Thanks.

Sam

-Original Message-
From: Jacques Pienaar via Phabricator  
Sent: Monday, February 17, 2020 10:58 AM
To: Liu, Yaxun (Sam) ; t...@google.com; rjmcc...@gmail.com; 
rich...@metafoo.co.uk; jdoerf...@anl.gov; a.bat...@hotmail.com
Cc: jpien...@google.com; mask...@google.com; michael.hl...@gmail.com; 
mariya.podchishcha...@intel.com; alexey.ba...@intel.com; 
zhang.guans...@gmail.com; her...@google.com; r...@google.com; 
cfe-commits@lists.llvm.org; mlek...@skidmore.edu; blitzrak...@gmail.com; 
shen...@google.com
Subject: [PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a 
post-parsing AST travese

[CAUTION: External Email]

jpienaar added a comment.

This seems to result in triggering clang/lib/CodeGen/CGExpr.cpp:2626 when 
compiling mlir/lib/Transforms/AffineDataCopyGeneration.cpp with clang build 
with assertions on (clean build at e8e078c 

 just before this change, broken at this, assert triggering at build fix 
commit).

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbuildkite.com%2Fmlir%2Fmlir-core%2Fbuilds%2F2792%23a54fb239-718b-4f0b-a309-f83e46ceb252data=02%7C01%7Cyaxun.liu%40amd.com%7C929d8d11429a4c4072e108d7b3db6042%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175627129064872sdata=nma5u9l5h6tkzQEX0hVfYe6VJQBXubt%2FCOF%2BWyWSujM%3Dreserved=0


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD70172%2Fnew%2Fdata=02%7C01%7Cyaxun.liu%40amd.com%7C929d8d11429a4c4072e108d7b3db6042%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175627129064872sdata=yGGqSBdf6zVYW7IDFW57UEagQAyvaOfn2a8xu%2BaIr9o%3Dreserved=0

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Freviews.llvm.org%2FD70172data=02%7C01%7Cyaxun.liu%40amd.com%7C929d8d11429a4c4072e108d7b3db6042%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637175627129064872sdata=sbHpgiR9tKyv0%2F4ZnuhUX%2BFaIHdtwoHTyOJxX1%2F46mg%3Dreserved=0


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


[PATCH] D74724: [AArch64][SVE] CodeGen of ACLE Builtin Types

2020-02-17 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CodeGenTypes.cpp:559
 #include "clang/Basic/AArch64SVEACLETypes.def"
-{
-  unsigned DiagID = CGM.getDiags().getCustomDiagID(
-  DiagnosticsEngine::Error,
-  "cannot yet generate code for SVE type '%0'");
-  auto *BT = cast(Ty);
-  auto Name = BT->getName(CGM.getContext().getPrintingPolicy());
-  CGM.getDiags().Report(DiagID) << Name;
-  // Return something safe.
-  ResultType = llvm::IntegerType::get(getLLVMContext(), 32);
-  break;
+  ResultType = getSVEType(getContext(), getLLVMContext(),
+  cast(Ty)->getKind());

Is there a reason to make getSVEType a separate function, as opposed to just 
writing out the cases inline?

Also, we can probably get rid of the "cannot yet generate code for SVE type" 
error?



Comment at: llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp:230
+  uint64_t ElementSize =
+  DL->getTypeAllocSize(AI.getAllocatedType()).getKnownMinSize();
   uint64_t Size =

Please submit this separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74724



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


[PATCH] D74735: [analyzer] Add support for CXXInheritedCtorInitExpr.

2020-02-17 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, rnkovacs, Szelethus, 
baloghadamsoftware, Charusso.
Herald added subscribers: cfe-commits, martong, dkrupp, donat.nagy, 
mikhail.ramalho, a.sidorin, szepet, kristof.beyls.
Herald added a project: clang.

`CXXInheritedCtorInitExpr` shows up when code looks roughly like this:

  struct A {
A(int x) { ... }
  };
  
  struct B {
using A::A;  // !!
  };

The AST for the autogenerated constructor for `B` looks like this:

  `-CXXConstructorDecl implicit used A 'void (int)' inline
|-ParmVarDecl implicit 'int'
|-CXXCtorInitializer 'A'
| `-CXXInheritedCtorInitExpr 'A'  // !!
`-CompoundStmt

So far we've been dropping coverage every time we've encountered 
`CXXInheritedCtorInitExpr`. This patch attempts to add some support for it.

The AST is rather annoying to work with. `CXXInheritedCtorInitExpr` is not 
related to `CXXConstructExpr`, so it requires a new `CallEvent` sub-class in 
order to capture its semantics properly.

There are also no argument expressions, even though the inherited constructor 
for `A` takes one argument `x`. The current patch takes argument expressions 
from the topmost `CXXConstructExpr`, which also requires a different location 
context to access. As far as i can see, the result of such substitution is 
always correct, i.e., the resulting argument `SVal` obtained from the 
Environment this way will always be `evalBinOp`-equal to the correct argument 
value. I'm still not sure it's a great long-term solution; it might be better 
to outright forbid calling `getArgExpr()` and `getNumArgs()` on a 
`CXXInheritedConstructorCall`.

Another piece of work that needs to be done (probably in follow-up patches) is 
supporting argument constructors in the `CXXInheritedCtorInitExpr`; the last 
test shows that it's not quite working. It's also going to be very annoying 
because the construct-expressions for such arguments are also not present in 
the AST. So this is going to be yet another kind of `CallEvent`s that don't 
correspond to any `Expr` (the previous such case being destructors that aren't 
invoked manually).


Repository:
  rC Clang

https://reviews.llvm.org/D74735

Files:
  clang/include/clang/Analysis/ConstructionContext.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  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/SymbolManager.cpp
  clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp

Index: clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp
===
--- /dev/null
+++ clang/test/Analysis/cxx-inherited-ctor-init-expr.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(bool);
+
+namespace basic_tests {
+struct A {
+  int x;
+  A(int x): x(x) {}
+};
+
+struct B : A {
+  using A::A;
+};
+
+struct C : B {
+  using B::B;
+};
+
+void test_B() {
+  B b(1);
+  clang_analyzer_eval(b.x == 1); // expected-warning{{TRUE}}
+}
+
+void test_C() {
+  C c(2);
+  clang_analyzer_eval(c.x == 2); // expected-warning{{TRUE}}
+}
+} // namespace basic_tests
+
+namespace arguments_with_constructors {
+struct S {
+  int x, y;
+  S(int x, int y): x(x), y(y) {}
+  ~S() {}
+};
+
+struct A {
+  S s;
+  int z;
+  A(S s, int z) : s(s), z(z) {}
+};
+
+struct B : A {
+  using A::A;
+};
+
+void test_B() {
+  B b(S(1, 2), 3);
+  // FIXME: There should be no execution path on which this is false.
+  clang_analyzer_eval(b.s.x == 1); // expected-warning{{TRUE}}
+   // expected-warning@-1{{FALSE}}
+
+  // FIXME: There should be no execution path on which this is false.
+  clang_analyzer_eval(b.s.y == 2); // expected-warning{{TRUE}}
+   // expected-warning@-1{{FALSE}}
+
+  clang_analyzer_eval(b.z == 3); // expected-warning{{TRUE}}
+}
+} // namespace arguments_with_constructors
Index: clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -542,6 +542,11 @@
 if (!Loc)
   return true;
 
+// Anonymous parameters of an inheriting constructor are live for the entire
+// duration of the constructor.
+if (isa(Loc))
+  return true;
+
 if (LCtx->getAnalysis()->isLive(Loc, VR->getDecl()))
   return true;
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -668,8 +668,8 @@

[PATCH] D72857: [SYCL] Driver option to enable SYCL mode and select SYCL version

2020-02-17 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72857



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


[PATCH] D74643: [Parse] Consider attributes in `TryParsePtrOperatorSeq`.

2020-02-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Parse/ParseTentative.cpp:798
+if (Tok.is(tok::l_square)) {
+  ConsumeBracket();
+  if (!SkipUntil(tok::r_square))

Do you want to check for double-brackets here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74643



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


[PATCH] D74387: [SYCL] Do not diagnose use of __float128

2020-02-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D74387#1874612 , @Fznamznon wrote:

> > In D74387#1869845 , @rjmccall 
> > wrote:
> > 
> >> The right approach here is probably what we do in ObjC ARC when we see 
> >> types that are illegal in ARC: in system headers, we allow the code but 
> >> add a special `UnavailableAttr` to the declaration so that it can't be 
> >> directly used.
> >>
> >> That is straightforward enough that I think you should just do it instead 
> >> of leaving this as technical debt.
> > 
> > 
> > I haven't considered something like this, because I'm not familiar with 
> > ObjC at all... I will give it a try, thanks.
>
> Hi @rjmccall , I assume, I took a look at this. 
>  Let's imagine, I will try to diagnose `__float128` type using already 
> implemented functionality. It seems like I need to call something like
>
>   S.DelayedDiagnostics.add(
>   sema::DelayedDiagnostic::makeForbiddenType(loc,  
>   diag::err_type_unsupported, type, "__float128"));
>   `
>
> right?
>  I suppose, then this diagnostic will be saved and emitted inside function 
> named `handleDelayedForbiddenType`.
>  Here it checks that this forbidden type is actually allowed and emits a 
> diagnostic if it's not.


This isn't quite right.  The goal here is to delay the diagnostic *twice*.  The 
first delay is between the point where we parse/process the type (i.e. 
SemaType) and the point where we've fully processed the declaration that the 
type is part of (i.e. SemaDecl).  That's the point where we call 
`handleDelayedForbiddenType`, and you're right that it's too early to know 
whether the declaration is really device code.  However, you're missing 
something important about how `handleDelayedForbiddenType` works: it's never 
really trying to suppress the diagnostic completely, but just to delay it for 
certain declarations until the point that the declaration is actually used, 
under the hope that in fact it will never be used and everything will work out. 
 For ARC, we chose to delay for all declarations in system headers, under the 
assumption that (1) system headers will never introduce functions that have to 
be emitted eagerly, and (2) we always want to warn people about problematic 
code in their own headers.  Those choices don't really fit SYCL's use case, and 
you should change the logic in `isForbiddenTypeAllowed` to delay your 
diagnostic for essentially all declarations (except kernels?), since 
effectively all non-kernel code in device mode is lazily emitted.  But if you 
do that, it should combine well with CUDA/OMP deferred diagnostics:

- If `foo` uses `__float128` (whether in its signature or internally), that is 
invalid in device mode, but the diagnostic will be delayed by the 
forbidden-type mechanism, meaning that it will become an `unavailable` 
attribute on `foo`.
- If `bar` uses `foo`, that use is invalid in device mode (because of the 
`unavailable` attribute), but the diagnostic will be delayed via the standard 
CUDA/OMP mechanism because we don't know yet whether `bar` should be emitted as 
a device function.
- If `kernel` uses `bar`, that will trigger the emission of the delayed 
diagnostics of `bar`, including the use-of-`unavailable`-function diagnostic 
where it uses `foo`.  It should be straightforward to specialize this 
diagnostic so that it reports the error by actually diagnosing the use of 
`__float128` at the original location (which is recorded in the `unavailable` 
attribute) and then just adding a note about how `foo` is used by `bar`.

> It seems that the second problem is the same problem which prevented me from 
> implementing diagnosing of `__float128` type through CUDA/OMP deferred 
> diagnostics (I mentioned my attempt in the last comment 
> https://reviews.llvm.org/D74387#1870014). I still need to find best place for 
> diagnostic issuing. It seems that there are so many places where type can 
> actually be introduced to resulting LLVM IR module, and in some of them I 
> need to check some additional conditions to do not prevent `__float128` usage 
> when it actually doesn't introduce forbidden type to resulting LLVM IR module.

The key thing here is that all uses should be associated with some top-level 
declaration that's either eagerly-emitted in device mode or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74387



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


[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.cpp:62
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))

`C` is one byte long, it is not possible for it to ever satisfy `C&0x100`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74731



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


[PATCH] D74734: [AArch64][SVE] Add the SVE dupq_lane intrinsic

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

Implements the @llvm.aarch64.sve.dupq.lane intrinsic.

As specified in the ACLE, the behaviour of:

  svdupq_lane_u64(data, index)

...is identical to:

  svtbl(data, svadd_x(svptrue_b64(),
   svand_x(svptrue_b64(), svindex_u64(0, 1), 1),
   index * 2))

If the index is in the range [0,3], the operation is equivalent
to a single DUP (.q) instruction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74734

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

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -297,6 +297,179 @@
 }
 
 ;
+; DUPQ
+;
+
+define  @dupq_i8( %a) {
+; CHECK-LABEL: dupq_i8:
+; CHECK: mov z0.q, q0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %a, i64 0)
+  ret  %out
+}
+
+define  @dupq_i16( %a) {
+; CHECK-LABEL: dupq_i16:
+; CHECK: mov z0.q, z0.q[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv8i16( %a, i64 1)
+  ret  %out
+}
+
+define  @dupq_i32( %a) {
+; CHECK-LABEL: dupq_i32:
+; CHECK: mov z0.q, z0.q[2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv4i32( %a, i64 2)
+  ret  %out
+}
+
+define  @dupq_i64( %a) {
+; CHECK-LABEL: dupq_i64:
+; CHECK: mov z0.q, z0.q[3]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv2i64( %a, i64 3)
+  ret  %out
+}
+
+define  @dupq_f16( %a) {
+; CHECK-LABEL: dupq_f16:
+; CHECK: mov z0.q, q0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv8f16( %a, i64 0)
+  ret  %out
+}
+
+define  @dupq_f32( %a) {
+; CHECK-LABEL: dupq_f32:
+; CHECK: mov z0.q, z0.q[1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv4f32( %a, i64 1)
+  ret  %out
+}
+
+define  @dupq_f64( %a) {
+; CHECK-LABEL: dupq_f64:
+; CHECK: mov z0.q, z0.q[2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv2f64( %a, i64 2)
+  ret  %out
+}
+
+;
+; DUPQ_LANE
+;
+
+define  @dupq_lane_i8( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_i8:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK-NEXT: tbl   z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv16i8( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_i16( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_i16:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK: tbl z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv8i16( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_i32( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_i32:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK: tbl z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv4i32( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_i64( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_i64:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   [[Z4:z[0-9]+]].d, [[Z2]].d, [[Z3]].d
+; CHECK: tbl z0.d, { z0.d }, [[Z4]].d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.dupq.lane.nxv2i64( %a, i64 %idx)
+  ret  %out
+}
+
+; NOTE: Identical operation to dupq_lane_i8 (i.e. element type is irrelevant).
+define  @dupq_lane_f16( %a, i64 %idx) {
+; CHECK-LABEL: dupq_lane_f16:
+; CHECK-DAG:  index [[Z1:z[0-9]+]].d, #0, #1
+; CHECK-DAG:  and   [[Z2:z[0-9]+]].d, [[Z1]].d, #0x1
+; CHECK-DAG:  add   [[X1:x[0-9]+]], x0, x0
+; CHECK-DAG:  mov   [[Z3:z[0-9]+]].d, [[X1]]
+; CHECK:  add   

[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-17 Thread Jacques Pienaar via Phabricator via cfe-commits
jpienaar added a comment.

This seems to result in triggering clang/lib/CodeGen/CGExpr.cpp:2626 when 
compiling mlir/lib/Transforms/AffineDataCopyGeneration.cpp with clang build 
with assertions on (clean build at e8e078c 
 just 
before this change, broken at this, assert triggering at build fix commit).

https://buildkite.com/mlir/mlir-core/builds/2792#a54fb239-718b-4f0b-a309-f83e46ceb252


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


[PATCH] D74562: [OpenMP][OMPIRBuilder] Introducing the `OMPBuilderCBHelpers` helper class

2020-02-17 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

Regarding the third comment (which was removed for some reason), This new 
update should fix that




Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:3134
 
 // TODO: Replace with a generic helper function for emitting body
 auto BodyGenCB = [MasterRegionBodyStmt, this](InsertPointTy AllocaIP,

jdoerfert wrote:
> These TODOs are now obsolete ;)
We need to split our patches to keep them small :p



Comment at: clang/lib/CodeGen/CodeGenFunction.h:354
+
+FinilizationBlock = CGF.getJumpDestInCurrentScope();
+  }

jdoerfert wrote:
> Don't we have to set/reset the `CGF.ReturnBlock` ? If not, why do we need 
> `FinilizationBlock` here?
Yes, and we still do for outlined regions (check `OutlinedRegionBodyRAII` ctor 
above). 

This is for inlined regions, and those shouldn't change the `CGF.ReturnBlock`. 
It should re-use the `CGF.ReturnBlock` for the enclosing outlined region.
The only reason I kept it, is because `CGF.getJumpDestInCurrentScope()` was 
updating a counter that seemed to me to relate to `EHStack`, and I didn't want 
to remove it without investigating first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74562



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


[PATCH] D74542: [ASTImporter] Prevent the ASTImporter from creating multiple main FileIDs.

2020-02-17 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

In D74542#1878732 , @balazske wrote:

> In D74542#1878576 , @teemperor wrote:
>
> > @balazske Do you see any problems with this patch?
>
>
> I have no opinion against the change. Probably sorting order of imported 
> source locations makes not much sense (specially if recursive imports happen) 
> and I can not tell what is the consequence of this, maybe no problem (there 
> was something that triggered this crash, does this way of sorting order give 
> some usable results?).


Before this patch we would get a Clang crash in 
`SourceManager::isBeforeInTranslationUnit` when emitting diagnostics that cover 
multiple (main) files. With this patch we get a normal diagnostic. The order of 
the `note:` messages is in the order in which they were encountered by LLDB but 
that is fine as long as the order is deterministic (I also don't see a very 
logical order in which they should be ordered and we're fine as long as the 
order is deterministic).


Repository:
  rC Clang

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

https://reviews.llvm.org/D74542



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


[PATCH] D74562: [OpenMP][OMPIRBuilder] Introducing the `OMPBuilderCBHelpers` helper class

2020-02-17 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim updated this revision to Diff 245014.
fghanim marked 2 inline comments as done.
fghanim added a comment.

Fixed bug where variables where still being allocated in original function 
entry block


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74562

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/cancel_codegen.cpp

Index: clang/test/OpenMP/cancel_codegen.cpp
===
--- clang/test/OpenMP/cancel_codegen.cpp
+++ clang/test/OpenMP/cancel_codegen.cpp
@@ -192,9 +192,7 @@
 // IRBUILDER: [[CMP:%.+]] = icmp eq i32 [[RES]], 0
 // IRBUILDER: br i1 [[CMP]], label %[[CONTINUE:[^,].+]], label %[[EXIT:.+]]
 // IRBUILDER: [[EXIT]]
-// IRBUILDER: br label %[[EXIT2:.+]]
-// IRBUILDER: [[EXIT2]]
-// IRBUILDER: br label %[[RETURN]]
+// IRBUILDER: br label %[[RETURN:.+]]
 // IRBUILDER: [[CONTINUE]]
 // IRBUILDER: br label %[[ELSE:.+]]
 
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -36,6 +36,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Transforms/Utils/SanitizerStats.h"
@@ -255,6 +256,110 @@
 unsigned Index;
   };
 
+  // Helper class for the OpenMP IR Builder. Allows reusability of code used for
+  // region body, and finalization codegen callbacks. This will class will also
+  // contain privatization functions used by the privatization call backs
+  struct OMPBuilderCBHelpers {
+
+using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
+
+/// Emit the Finalization for an OMP region
+/// \param CGF	The Codegen function this belongs to
+/// \param IP	Insertion point for generating the finalization code.
+static void FinalizeOMPRegion(CodeGenFunction , InsertPointTy IP) {
+  CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
+  assert(IP.getBlock()->end() != IP.getPoint() &&
+ "OpenMP IR Builder should cause terminated block!");
+
+  llvm::BasicBlock *IPBB = IP.getBlock();
+  llvm::BasicBlock *DestBB = IPBB->getUniqueSuccessor();
+  assert(DestBB && "Finalization block should have one successor!");
+
+  // erase and replace with cleanup branch.
+  IPBB->getTerminator()->eraseFromParent();
+  CGF.Builder.SetInsertPoint(IPBB);
+  CodeGenFunction::JumpDest Dest = CGF.getJumpDestInCurrentScope(DestBB);
+  CGF.EmitBranchThroughCleanup(Dest);
+}
+
+/// Emit the body of an OMP region
+/// \param CGF	The Codegen function this belongs to
+/// \param RegionBodyStmt	The body statement for the OpenMP region being
+/// 			 generated
+/// \param CodeGenIP	Insertion point for generating the body code.
+/// \param FiniBB	The finalization basic block
+static void EmitOMPRegionBody(CodeGenFunction ,
+  const Stmt *RegionBodyStmt,
+  InsertPointTy CodeGenIP,
+  llvm::BasicBlock ) {
+  llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
+  if (llvm::Instruction *CodeGenIPBBTI = CodeGenIPBB->getTerminator())
+CodeGenIPBBTI->eraseFromParent();
+
+  CGF.Builder.SetInsertPoint(CodeGenIPBB);
+
+  CGF.EmitStmt(RegionBodyStmt);
+
+  if (CGF.Builder.saveIP().isSet())
+CGF.Builder.CreateBr();
+}
+
+/// RAII for preserving necessary info during Outlined region body codegen.
+class OutlinedRegionBodyRAII {
+
+  llvm::AssertingVH OldAllocaIP;
+  CodeGenFunction::JumpDest OldReturnBlock;
+  CodeGenFunction 
+
+public:
+  OutlinedRegionBodyRAII(CodeGenFunction , InsertPointTy ,
+ llvm::BasicBlock )
+  : CGF(cgf) {
+assert(AllocaIP.isSet() &&
+   "Must specify Insertion point for allocas of outlined function");
+OldAllocaIP = CGF.AllocaInsertPt;
+CGF.AllocaInsertPt = &*AllocaIP.getPoint();
+
+OldReturnBlock = CGF.ReturnBlock;
+CGF.ReturnBlock = CGF.getJumpDestInCurrentScope();
+  }
+
+  ~OutlinedRegionBodyRAII() {
+CGF.AllocaInsertPt = OldAllocaIP;
+CGF.ReturnBlock = OldReturnBlock;
+  }
+};
+
+/// RAII for preserving necessary info during inlined region body codegen.
+class InlinedRegionBodyRAII {
+
+  llvm::AssertingVH OldAllocaIP;
+  CodeGenFunction::JumpDest FinilizationBlock;
+  CodeGenFunction 
+
+public:
+  InlinedRegionBodyRAII(CodeGenFunction , InsertPointTy ,
+llvm::BasicBlock )
+  : CGF(cgf) {
+// Alloca insertion block should be in the entry block of the 

[PATCH] D73835: [IRBuilder] Virtualize IRBuilder

2020-02-17 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

This broke the LLVM_ENABLE_MODULES build because it introduces a cyclic 
dependency between LLVM_IR and LLVM_intrinsic_gen:

  FAILED: 
tools/lld/lib/ReaderWriter/MachO/CMakeFiles/lldMachO.dir/MachONormalizedFileBinaryReader.cpp.o
 
  
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
  -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Itools/lld/lib/ReaderWriter/MachO 
-I/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO 
-I/Users/teemperor/1llvm/llvm-project/lld/include -Itools/lld/include 
-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include/libxml2
 -Iinclude -I/Users/teemperor/1llvm/llvm-project/llvm/include 
-I/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO/. -fPIC 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -fmodules 
-fmodules-cache-path=/Users/teemperor/1llvm/rel/module.cache -fcxx-modules 
-Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -O3  
-isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
-fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT 
tools/lld/lib/ReaderWriter/MachO/CMakeFiles/lldMachO.dir/MachONormalizedFileBinaryReader.cpp.o
 -MF 
tools/lld/lib/ReaderWriter/MachO/CMakeFiles/lldMachO.dir/MachONormalizedFileBinaryReader.cpp.o.d
 -o 
tools/lld/lib/ReaderWriter/MachO/CMakeFiles/lldMachO.dir/MachONormalizedFileBinaryReader.cpp.o
 -c 
/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
  While building module 'LLVM_Object' imported from 
/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp:36:
  While building module 'LLVM_IR' imported from 
/Users/teemperor/1llvm/llvm-project/llvm/include/llvm/Object/IRSymtab.h:29:
  While building module 'LLVM_intrinsic_gen' imported from 
/Users/teemperor/1llvm/llvm-project/llvm/include/llvm/IR/IRBuilderFolder.h:18:
  In file included from :1:
  /Users/teemperor/1llvm/llvm-project/llvm/include/llvm/IR/Argument.h:19:10: 
fatal error: cyclic dependency in module 'LLVM_IR': LLVM_IR -> 
LLVM_intrinsic_gen -> LLVM_IR
  #include "llvm/IR/Value.h"
   ^
  While building module 'LLVM_Object' imported from 
/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp:36:
  While building module 'LLVM_IR' imported from 
/Users/teemperor/1llvm/llvm-project/llvm/include/llvm/Object/IRSymtab.h:29:
  In file included from :13:
  
/Users/teemperor/1llvm/llvm-project/llvm/include/llvm/IR/IRBuilderFolder.h:18:10:
 fatal error: could not build module 'LLVM_intrinsic_gen'
  #include "llvm/IR/InstrTypes.h"
   ^~
  While building module 'LLVM_Object' imported from 
/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp:36:
  In file included from :4:
  
/Users/teemperor/1llvm/llvm-project/llvm/include/llvm/Object/IRSymtab.h:29:10: 
fatal error: could not build module 'LLVM_IR'
  #include "llvm/IR/GlobalValue.h"
   ^~~
  
/Users/teemperor/1llvm/llvm-project/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp:36:10:
 fatal error: could not build module 'LLVM_Object'
  #include "llvm/Object/MachO.h"
   ^
  4 errors generated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73835



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


[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1468
   }
-  S.DeviceDeferredDiags.erase(It);
 

Fznamznon wrote:
> This particular change causes duplication of deferred diagnostics.
> Consider the following example (please correct me if I'm doing something 
> wrong, I'm not an expert in OpenMP):
> 
> ```
> int foobar1() { throw 1; } // error is expected here
> 
> // let's try to use foobar1 in the code where exceptions aren't allowed
> #pragma omp declare target
> int (*B)() = 
> #pragma omp end declare target
> 
> // and in some other place let's use foobar1 in device code again
> #pragma omp declare target
> int a = foobar1();
> #pragma omp end declare target
> 
> ```
> Then diagnostic for `foobar1`  will be duplicated for each use of `foobar1` 
> under `target` directive.
> I first experienced this behavior not with OpenMP, so I suppose reproducer 
> can be done for each programming model which uses deferred diagnostics.
The change is intentional so that each call chain causing the diagnostic can be 
identified. The drawback is that it is more verbose.

I can change this behavior so that the diagnostic will be emitted only for the 
first call chain that causes the diagnostic, if less verbose diagnostics is 
preferred.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


[PATCH] D74732: [ARM,CDE] Cosmetic changes, additonal driver tests

2020-02-17 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: SjoerdMeijer, simon_tatham, dmgreen.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

This is a follow-up patch addressing post-commit comments in
https://reviews.llvm.org/D74044:

- Add more Clang driver tests (-march=armv8.1m.main and 
-march=armv8.1m.main+mve.fp)
- Clang-format a chunk in ARMAsmParser.cpp
- Add a missing copyright header to ARMInstrCDE.td


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74732

Files:
  clang/test/Driver/arm-cde.c
  llvm/lib/Target/ARM/ARMInstrCDE.td
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Index: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
===
--- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
+++ llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
@@ -8136,15 +8136,36 @@
 break;
   }
 
-  case ARM::CDE_CX1: case ARM::CDE_CX1A: case ARM::CDE_CX1D: case ARM::CDE_CX1DA:
-  case ARM::CDE_CX2: case ARM::CDE_CX2A: case ARM::CDE_CX2D: case ARM::CDE_CX2DA:
-  case ARM::CDE_CX3: case ARM::CDE_CX3A: case ARM::CDE_CX3D: case ARM::CDE_CX3DA:
-  case ARM::CDE_VCX1_vec:  case ARM::CDE_VCX1_fpsp:  case ARM::CDE_VCX1_fpdp:
-  case ARM::CDE_VCX1A_vec: case ARM::CDE_VCX1A_fpsp: case ARM::CDE_VCX1A_fpdp:
-  case ARM::CDE_VCX2_vec:  case ARM::CDE_VCX2_fpsp:  case ARM::CDE_VCX2_fpdp:
-  case ARM::CDE_VCX2A_vec: case ARM::CDE_VCX2A_fpsp: case ARM::CDE_VCX2A_fpdp:
-  case ARM::CDE_VCX3_vec:  case ARM::CDE_VCX3_fpsp:  case ARM::CDE_VCX3_fpdp:
-  case ARM::CDE_VCX3A_vec: case ARM::CDE_VCX3A_fpsp: case ARM::CDE_VCX3A_fpdp: {
+  case ARM::CDE_CX1:
+  case ARM::CDE_CX1A:
+  case ARM::CDE_CX1D:
+  case ARM::CDE_CX1DA:
+  case ARM::CDE_CX2:
+  case ARM::CDE_CX2A:
+  case ARM::CDE_CX2D:
+  case ARM::CDE_CX2DA:
+  case ARM::CDE_CX3:
+  case ARM::CDE_CX3A:
+  case ARM::CDE_CX3D:
+  case ARM::CDE_CX3DA:
+  case ARM::CDE_VCX1_vec:
+  case ARM::CDE_VCX1_fpsp:
+  case ARM::CDE_VCX1_fpdp:
+  case ARM::CDE_VCX1A_vec:
+  case ARM::CDE_VCX1A_fpsp:
+  case ARM::CDE_VCX1A_fpdp:
+  case ARM::CDE_VCX2_vec:
+  case ARM::CDE_VCX2_fpsp:
+  case ARM::CDE_VCX2_fpdp:
+  case ARM::CDE_VCX2A_vec:
+  case ARM::CDE_VCX2A_fpsp:
+  case ARM::CDE_VCX2A_fpdp:
+  case ARM::CDE_VCX3_vec:
+  case ARM::CDE_VCX3_fpsp:
+  case ARM::CDE_VCX3_fpdp:
+  case ARM::CDE_VCX3A_vec:
+  case ARM::CDE_VCX3A_fpsp:
+  case ARM::CDE_VCX3A_fpdp: {
 assert(Inst.getOperand(1).isImm() &&
"CDE operand 1 must be a coprocessor ID");
 int64_t Coproc = Inst.getOperand(1).getImm();
@@ -8157,17 +8178,48 @@
 break;
   }
 
-  case ARM::t2CDP: case ARM::t2CDP2:
-  case ARM::t2LDC2L_OFFSET: case ARM::t2LDC2L_OPTION: case ARM::t2LDC2L_POST: case ARM::t2LDC2L_PRE:
-  case ARM::t2LDC2_OFFSET: case ARM::t2LDC2_OPTION: case ARM::t2LDC2_POST: case ARM::t2LDC2_PRE:
-  case ARM::t2LDCL_OFFSET: case ARM::t2LDCL_OPTION: case ARM::t2LDCL_POST: case ARM::t2LDCL_PRE:
-  case ARM::t2LDC_OFFSET: case ARM::t2LDC_OPTION: case ARM::t2LDC_POST: case ARM::t2LDC_PRE:
-  case ARM::t2MCR: case ARM::t2MCR2: case ARM::t2MCRR: case ARM::t2MCRR2:
-  case ARM::t2MRC: case ARM::t2MRC2: case ARM::t2MRRC: case ARM::t2MRRC2:
-  case ARM::t2STC2L_OFFSET: case ARM::t2STC2L_OPTION: case ARM::t2STC2L_POST: case ARM::t2STC2L_PRE:
-  case ARM::t2STC2_OFFSET: case ARM::t2STC2_OPTION: case ARM::t2STC2_POST: case ARM::t2STC2_PRE:
-  case ARM::t2STCL_OFFSET: case ARM::t2STCL_OPTION: case ARM::t2STCL_POST: case ARM::t2STCL_PRE:
-  case ARM::t2STC_OFFSET: case ARM::t2STC_OPTION: case ARM::t2STC_POST: case ARM::t2STC_PRE: {
+  case ARM::t2CDP:
+  case ARM::t2CDP2:
+  case ARM::t2LDC2L_OFFSET:
+  case ARM::t2LDC2L_OPTION:
+  case ARM::t2LDC2L_POST:
+  case ARM::t2LDC2L_PRE:
+  case ARM::t2LDC2_OFFSET:
+  case ARM::t2LDC2_OPTION:
+  case ARM::t2LDC2_POST:
+  case ARM::t2LDC2_PRE:
+  case ARM::t2LDCL_OFFSET:
+  case ARM::t2LDCL_OPTION:
+  case ARM::t2LDCL_POST:
+  case ARM::t2LDCL_PRE:
+  case ARM::t2LDC_OFFSET:
+  case ARM::t2LDC_OPTION:
+  case ARM::t2LDC_POST:
+  case ARM::t2LDC_PRE:
+  case ARM::t2MCR:
+  case ARM::t2MCR2:
+  case ARM::t2MCRR:
+  case ARM::t2MCRR2:
+  case ARM::t2MRC:
+  case ARM::t2MRC2:
+  case ARM::t2MRRC:
+  case ARM::t2MRRC2:
+  case ARM::t2STC2L_OFFSET:
+  case ARM::t2STC2L_OPTION:
+  case ARM::t2STC2L_POST:
+  case ARM::t2STC2L_PRE:
+  case ARM::t2STC2_OFFSET:
+  case ARM::t2STC2_OPTION:
+  case ARM::t2STC2_POST:
+  case ARM::t2STC2_PRE:
+  case ARM::t2STCL_OFFSET:
+  case ARM::t2STCL_OPTION:
+  case ARM::t2STCL_POST:
+  case ARM::t2STCL_PRE:
+  case ARM::t2STC_OFFSET:
+  case ARM::t2STC_OPTION:
+  case ARM::t2STC_POST:
+  case ARM::t2STC_PRE: {
 unsigned Opcode = Inst.getOpcode();
 // Inst.getOperand indexes operands in the (oops ...) and (iops ...) dags,
 // CopInd is the index of the coprocessor operand.
@@ -8176,11 +8228,13 @@
   CopInd = 2;
 else if (Opcode == ARM::t2MRC || Opcode == ARM::t2MRC2)
   CopInd = 1;
-

[PATCH] D74731: [Clangd] Fixed assertion when processing extended ASCII characters.

2020-02-17 Thread Yancheng Zheng via Phabricator via cfe-commits
AnakinZheng created this revision.
AnakinZheng added reviewers: kadircet, sammccall.
AnakinZheng added a project: clang.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.

Previously this piece of code asserts when processing extended ASCII. Proposing 
a fix to extend the ascii handling code to take extended ascii as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74731

Files:
  clang-tools-extra/clangd/SourceCode.cpp


Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -59,7 +59,7 @@
   // Astral codepoints are encoded as 4 bytes in UTF-8, starting with 0xxx.
   for (size_t I = 0; I < U8.size();) {
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))
 return true;
   ++I;


Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -59,7 +59,7 @@
   // Astral codepoints are encoded as 4 bytes in UTF-8, starting with 0xxx.
   for (size_t I = 0; I < U8.size();) {
 unsigned char C = static_cast(U8[I]);
-if (LLVM_LIKELY(!(C & 0x80))) { // ASCII character.
+if (LLVM_LIKELY(!(C & 0x100))) { // ASCII or extended ASCII character.
   if (CB(1, 1))
 return true;
   ++I;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73835: [IRBuilder] Virtualize IRBuilder

2020-02-17 Thread Nikita Popov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3eaa53e80543: Reapply [IRBuilder] Virtualize 
IRBuilder (authored by nikic).

Changed prior to commit:
  https://reviews.llvm.org/D73835?vs=244871=245004#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73835

Files:
  clang/lib/CodeGen/CGBuilder.h
  llvm/include/llvm/Analysis/TargetFolder.h
  llvm/include/llvm/IR/ConstantFolder.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/IRBuilderFolder.h
  llvm/include/llvm/IR/NoFolder.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  polly/include/polly/CodeGen/IRBuilder.h

Index: polly/include/polly/CodeGen/IRBuilder.h
===
--- polly/include/polly/CodeGen/IRBuilder.h
+++ polly/include/polly/CodeGen/IRBuilder.h
@@ -131,15 +131,14 @@
 ///
 /// This is used to add additional items such as e.g. the llvm.loop.parallel
 /// metadata.
-class IRInserter : protected llvm::IRBuilderDefaultInserter {
+class IRInserter final : public llvm::IRBuilderDefaultInserter {
 public:
   IRInserter() = default;
   IRInserter(class ScopAnnotator ) : Annotator() {}
 
-protected:
   void InsertHelper(llvm::Instruction *I, const llvm::Twine ,
 llvm::BasicBlock *BB,
-llvm::BasicBlock::iterator InsertPt) const {
+llvm::BasicBlock::iterator InsertPt) const override {
 llvm::IRBuilderDefaultInserter::InsertHelper(I, Name, BB, InsertPt);
 if (Annotator)
   Annotator->annotate(I);
Index: llvm/lib/Transforms/Scalar/SROA.cpp
===
--- llvm/lib/Transforms/Scalar/SROA.cpp
+++ llvm/lib/Transforms/Scalar/SROA.cpp
@@ -129,7 +129,7 @@
 
 /// A custom IRBuilder inserter which prefixes all names, but only in
 /// Assert builds.
-class IRBuilderPrefixedInserter : public IRBuilderDefaultInserter {
+class IRBuilderPrefixedInserter final : public IRBuilderDefaultInserter {
   std::string Prefix;
 
   const Twine getNameWithPrefix(const Twine ) const {
@@ -139,9 +139,8 @@
 public:
   void SetNamePrefix(const Twine ) { Prefix = P.str(); }
 
-protected:
   void InsertHelper(Instruction *I, const Twine , BasicBlock *BB,
-BasicBlock::iterator InsertPt) const {
+BasicBlock::iterator InsertPt) const override {
 IRBuilderDefaultInserter::InsertHelper(I, getNameWithPrefix(Name), BB,
InsertPt);
   }
@@ -2368,7 +2367,8 @@
 Instruction *OldUserI = cast(OldUse->getUser());
 IRB.SetInsertPoint(OldUserI);
 IRB.SetCurrentDebugLocation(OldUserI->getDebugLoc());
-IRB.SetNamePrefix(Twine(NewAI.getName()) + "." + Twine(BeginOffset) + ".");
+IRB.getInserter().SetNamePrefix(
+Twine(NewAI.getName()) + "." + Twine(BeginOffset) + ".");
 
 CanSROA &= visit(cast(OldUse->getUser()));
 if (VecTy || IntTy)
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -24,6 +24,7 @@
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Operator.h"
+#include "llvm/IR/NoFolder.h"
 #include "llvm/IR/Statepoint.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/Value.h"
@@ -784,3 +785,9 @@
   Function *Fn = Intrinsic::getDeclaration(M, ID, Types);
   return createCallHelper(Fn, Args, this, Name, FMFSource);
 }
+
+IRBuilderDefaultInserter::~IRBuilderDefaultInserter() {}
+IRBuilderCallbackInserter::~IRBuilderCallbackInserter() {}
+IRBuilderFolder::~IRBuilderFolder() {}
+void ConstantFolder::anchor() {}
+void NoFolder::anchor() {}
Index: llvm/lib/Analysis/ConstantFolding.cpp
===
--- llvm/lib/Analysis/ConstantFolding.cpp
+++ llvm/lib/Analysis/ConstantFolding.cpp
@@ -23,6 +23,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Analysis/TargetFolder.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/Analysis/VectorUtils.h"
@@ -2660,3 +2661,5 @@
 
   return false;
 }
+
+void TargetFolder::anchor() {}
Index: llvm/include/llvm/IR/NoFolder.h
===
--- llvm/include/llvm/IR/NoFolder.h
+++ llvm/include/llvm/IR/NoFolder.h
@@ -26,11 +26,14 @@
 #include "llvm/IR/InstrTypes.h"
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/Instructions.h"
+#include "llvm/IR/IRBuilderFolder.h"
 
 namespace llvm {
 
 /// NoFolder - Create "constants" (actually, instructions) with no folding.
-class NoFolder {
+class NoFolder final : public IRBuilderFolder {
+  virtual void anchor();
+
 public:
   explicit NoFolder() = default;
 
@@ 

[PATCH] D72231: [Sema] Adds the pointer-to-int-cast diagnostic

2020-02-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D72231#1878528 , @nathanchance 
wrote:

> There appear to a be semantic difference between GCC and clang with the 
> current version of this patch which results in a lot of additional warnings 
> in the Linux kernel: https://godbolt.org/z/eHFJd8


Warning about casting to an enum seems clearly correct and in scope for this 
warning.  Warning about casting to `_Bool` seems clearly incorrect and should 
not be warned about at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72231



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


[PATCH] D74116: [Sema][C++] Strawman patch to propagate conversion type in order to specialize the diagnostics

2020-02-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:3880
+ToType, From->getType(), From, Action);
+// assert(Diagnosed && "failed to diagnose bad conversion");
+(void)Diagnosed;

Anastasia wrote:
> rjmccall wrote:
> > This assertion seems important; can we make it work?
> Currently DiagnoseAssignmentResult returns true only for `Incompatible` , 
> However we can change it to return true for all `Incompatibel*` in C++ mode. 
> So yes it should be doable.
Okay.  My guess is it should return true whenever we emit an error rather than 
a warning (ignoring the effects of things like `-Werror`, of course).


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

https://reviews.llvm.org/D74116



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


[PATCH] D74044: [ARM] Add initial support for Custom Datapath Extension (CDE)

2020-02-17 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

@SjoerdMeijer, thanks for the heads up. Will fix in a followup patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74044



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


[PATCH] D74669: [clang-tidy] New check: misc-no-include-cpp

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



Comment at: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp:59
+Optional File = PP->LookupFile(
+HashLoc /* FIXME: lies */, (FileName + RE).str(), IsAngled, 
nullptr,
+nullptr, CurDir, nullptr, nullptr, nullptr, nullptr, nullptr);

njames93 wrote:
> jroelofs wrote:
> > FIXME: is this a reasonable `SourceLocation` to give to `LookupFile`?
> Main thing is to make sure that the same location is used for the warnings 
> and the notes.
> I personally found this the most pleasing diagnostics
> 
> ```
> SourceLocation DiagLoc = FilenameRange.getBegin().getLocWithOffset(1);
> ```
> 
> ```
> /home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-suspicious-include.cpp.tmp.cpp:7:11:
>  warning: suspicious #include of file with .cpp extension 
> [bugprone-suspicious-include]
> #include "a.cpp"
>   ^
> /home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-suspicious-include.cpp.tmp.cpp:7:11:
>  note: did you mean to include 'a'?
> /home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-suspicious-include.cpp.tmp.cpp:7:11:
>  note: did you mean to include 'a.h'?
> /home/nathan/src/llvm-project/build/Release/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-suspicious-include.cpp.tmp.cpp:7:11:
>  note: did you mean to include 'a.hpp'?
> ```
I don't have much experience with modules to lean on for intuition on what this 
check should do with them. I've added a test to codify what the pass currently 
does in that case, but if there's something better it should be trying when 
searching for suggestions, let's make it do that instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669



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


[PATCH] D74669: [clang-tidy] New check: misc-no-include-cpp

2020-02-17 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 244994.
jroelofs added a comment.

Implement review feedback re: DiagLoc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.hpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.c
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cc
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cxx
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
@@ -0,0 +1,21 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-include %t -- -- -isystem %S/Inputs/Headers -fmodules
+
+// CHECK-MESSAGES: [[@LINE+4]]:11: warning: suspicious #include of file with .cpp extension
+// CHECK-MESSAGES: [[@LINE+3]]:11: note: did you mean to include 'a'?
+// CHECK-MESSAGES: [[@LINE+2]]:11: note: did you mean to include 'a.h'?
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'a.hpp'?
+#include "a.cpp"
+
+#include "b.h"
+
+// CHECK-MESSAGES: [[@LINE+1]]:10: warning: suspicious #include of file with .c extension
+#import "c.c"
+
+// CHECK-MESSAGES: [[@LINE+1]]:16: warning: suspicious #include of file with .c extension
+#include_next 
+
+// CHECK-MESSAGES: [[@LINE+1]]:13: warning: suspicious #include of file with .cc extension
+# include  
+
+// CHECK-MESSAGES: [[@LINE+1]]:14: warning: suspicious #include of file with .cxx extension
+#  include  
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
@@ -0,0 +1,39 @@
+//===--- SuspiciousIncludeCheck.h - clang-tidy --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+/// Warns on inclusion of files whose names suggest that they're implementation
+/// files, instead of headers. E.g:
+///
+/// #include "foo.cpp"  // warning
+/// #include "bar.c"// warning
+/// #include "baz.h"// no diagnostic
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-suspicious-include.html
+class SuspiciousIncludeCheck : public ClangTidyCheck {
+public:
+  SuspiciousIncludeCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerPPCallbacks(const SourceManager , Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override;
+};
+
+} // namespace bugprone
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SUSPICIOUSINCLUDECHECK_H
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
@@ -0,0 +1,75 @@
+//===--- SuspiciousIncludeCheck.cpp - clang-tidy --===//
+//
+// 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 "SuspiciousIncludeCheck.h"
+#include "clang/AST/ASTContext.h"
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+namespace {
+class SuspiciousIncludePPCallbacks : public PPCallbacks {
+public:
+  explicit SuspiciousIncludePPCallbacks(ClangTidyCheck ,
+const SourceManager ,
+Preprocessor *PP)
+  : Check(Check), PP(PP) {}
+
+  void InclusionDirective(SourceLocation HashLoc, const Token ,
+  StringRef 

[PATCH] D74620: [ARM,MVE] Add vector-scalar intrinsics

2020-02-17 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: llvm/lib/Target/ARM/ARMInstrMVE.td:4566
+  0b0, VTI.Unsigned>;
+  defvar unpred_op = !if(VTI.Unsigned, unpred_op_u, unpred_op_s);
+  defm : MVE_vec_scalar_int_pat_m(NAME), VTI,

dmgreen wrote:
> I find all these if's at different levels a little hard to follow. It looks 
> OK, but is it possible to rearrange things to not need it here?
I meant trying to remove this `defvar unpred_op = !if(` line. I think it's 
always going to be a bit difficult to follow whatever we do here though (or we 
end up repeating ourselves a lot), so you can ignore this one :)


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

https://reviews.llvm.org/D74620



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


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

2020-02-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 244988.
yaxunl added a comment.
Herald added a subscriber: kerbowa.

Revised by John's comments. Introduced HIPKernelType for GlobalDecl so that we 
can use GlobalDecl to
represent stub and kernel during host compilation. Revised mangler so that 
GlobalDecl carrying
pertinent information can be passed through.


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

https://reviews.llvm.org/D68578

Files:
  clang/include/clang/AST/GlobalDecl.h
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Mangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/CodeGen/CGCUDARuntime.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  clang/test/CodeGenCUDA/kernel-stub-name.cu
  clang/test/CodeGenCUDA/unnamed-types.cu

Index: clang/test/CodeGenCUDA/unnamed-types.cu
===
--- clang/test/CodeGenCUDA/unnamed-types.cu
+++ clang/test/CodeGenCUDA/unnamed-types.cu
@@ -36,4 +36,4 @@
   }(p);
 }
 // HOST: @__hip_register_globals
-// HOST: __hipRegisterFunction{{.*}}@_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
+// HOST: __hipRegisterFunction{{.*}}@_Z17__device_stub__k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
Index: clang/test/CodeGenCUDA/kernel-stub-name.cu
===
--- clang/test/CodeGenCUDA/kernel-stub-name.cu
+++ clang/test/CodeGenCUDA/kernel-stub-name.cu
@@ -6,15 +6,50 @@
 
 #include "Inputs/cuda.h"
 
+extern "C" __global__ void ckernel() {}
+
+namespace ns {
+__global__ void nskernel() {}
+} // namespace ns
+
 template
 __global__ void kernelfunc() {}
 
+__global__ void kernel_decl();
+
+// Device side kernel names
+
+// CHECK: @[[CKERN:[0-9]*]] = {{.*}} c"ckernel\00"
+// CHECK: @[[NSKERN:[0-9]*]] = {{.*}} c"_ZN2ns8nskernelEv\00"
+// CHECK: @[[TKERN:[0-9]*]] = {{.*}} c"_Z10kernelfuncIiEvv\00"
+
+// Non-template kernel stub functions
+
+// CHECK: define{{.*}}@[[CSTUB:__device_stub__ckernel]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[CSTUB]]
+// CHECK: define{{.*}}@[[NSSTUB:_ZN2ns23__device_stub__nskernelEv]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[NSSTUB]]
+
 // CHECK-LABEL: define{{.*}}@_Z8hostfuncv()
-// CHECK: call void @[[STUB:_Z10kernelfuncIiEvv.stub]]()
-void hostfunc(void) { kernelfunc<<<1, 1>>>(); }
+// CHECK: call void @[[CSTUB]]()
+// CHECK: call void @[[NSSTUB]]()
+// CHECK: call void @[[TSTUB:_Z25__device_stub__kernelfuncIiEvv]]()
+// CHECK: call void @[[DSTUB:_Z26__device_stub__kernel_declv]]()
+void hostfunc(void) {
+  ckernel<<<1, 1>>>();
+  ns::nskernel<<<1, 1>>>();
+  kernelfunc<<<1, 1>>>();
+  kernel_decl<<<1, 1>>>();
+}
+
+// Template kernel stub functions
+
+// CHECK: define{{.*}}@[[TSTUB]]
+// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[TSTUB]]
 
-// CHECK: define{{.*}}@[[STUB]]
-// CHECK: call{{.*}}@hipLaunchByPtr{{.*}}@[[STUB]]
+// CHECK: declare{{.*}}@[[DSTUB]]
 
 // CHECK-LABEL: define{{.*}}@__hip_register_globals
-// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[STUB]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[CSTUB]]{{.*}}@[[CKERN]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[NSSTUB]]{{.*}}@[[NSKERN]]
+// CHECK: call{{.*}}@__hipRegisterFunction{{.*}}@[[TSTUB]]{{.*}}@[[TKERN]]
Index: clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
===
--- clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
+++ clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
@@ -13,19 +13,19 @@
 // HOST-NOT: %struct.T.coerce
 
 // CHECK: define amdgpu_kernel void  @_Z7kernel1Pi(i32 addrspace(1)* %x.coerce)
-// HOST: define void @_Z7kernel1Pi.stub(i32* %x)
+// HOST: define void @_Z22__device_stub__kernel1Pi(i32* %x)
 __global__ void kernel1(int *x) {
   x[0]++;
 }
 
 // CHECK: define amdgpu_kernel void  @_Z7kernel2Ri(i32 addrspace(1)* dereferenceable(4) %x.coerce)
-// HOST: define void @_Z7kernel2Ri.stub(i32* dereferenceable(4) %x)
+// HOST: define void @_Z22__device_stub__kernel2Ri(i32* dereferenceable(4) %x)
 __global__ void kernel2(int ) {
   x++;
 }
 
 // CHECK: define amdgpu_kernel void  @_Z7kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
-// HOST: define void @_Z7kernel3PU3AS2iPU3AS1i.stub(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
+// HOST: define void @_Z22__device_stub__kernel3PU3AS2iPU3AS1i(i32 addrspace(2)* %x, i32 addrspace(1)* %y)
 __global__ void kernel3(__attribute__((address_space(2))) int *x,
 __attribute__((address_space(1))) int *y) {
   y[0] = x[0];
@@ -43,7 +43,7 @@
 // `by-val` struct will be coerced into a similar struct with all generic
 // pointers lowerd into global ones.
 // CHECK: define amdgpu_kernel void @_Z7kernel41S(%struct.S.coerce %s.coerce)
-// HOST: define void @_Z7kernel41S.stub(i32* %s.coerce0, float* %s.coerce1)
+// HOST: define void 

[PATCH] D74044: [ARM] Add initial support for Custom Datapath Extension (CDE)

2020-02-17 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/test/Driver/arm-cde.c:12
+
+// RUN: %clang -target arm-none-none-eabi -march=armv8m.main+cdecp0+cdecp3 %s 
-### -c 2>&1 | FileCheck %s --check-prefix=CHECK-CDE1
+// CHECK-CDE1: "-triple" "thumbv8m.main-none-none-eabi"

Probably good to add a test for v8.1-M too, and also with MVE



Comment at: llvm/lib/Target/ARM/ARMInstrCDE.td:1
+// Immediate operand of arbitrary bit width
+class BitWidthImmOperand

This file needs the copyright header



Comment at: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp:8161
+  case ARM::t2CDP: case ARM::t2CDP2:
+  case ARM::t2LDC2L_OFFSET: case ARM::t2LDC2L_OPTION: case ARM::t2LDC2L_POST: 
case ARM::t2LDC2L_PRE:
+  case ARM::t2LDC2_OFFSET: case ARM::t2LDC2_OPTION: case ARM::t2LDC2_POST: 
case ARM::t2LDC2_PRE:

clang-format this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74044



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


[PATCH] D74724: [AArch64][SVE] CodeGen of ACLE Builtin Types

2020-02-17 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: rsandifo-arm, rovka, rjmccall, efriedma.
Herald added subscribers: llvm-commits, psnobl, rkruppe, hiraditya, 
kristof.beyls, tschuett.
Herald added projects: clang, LLVM.

This patch adds codegen support for the ACLE builtin types added in:

  https://reviews.llvm.org/D62960

so that the ACLE builtin types are emitted as corresponding scalable
vector types in LLVM.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74724

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/test/CodeGen/aarch64-sve.c
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Index: llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
===
--- llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -226,7 +226,8 @@
   if (FrameIndices.find() != FrameIndices.end())
 return FrameIndices[];
 
-  uint64_t ElementSize = DL->getTypeAllocSize(AI.getAllocatedType());
+  uint64_t ElementSize =
+  DL->getTypeAllocSize(AI.getAllocatedType()).getKnownMinSize();
   uint64_t Size =
   ElementSize * cast(AI.getArraySize())->getZExtValue();
 
Index: clang/test/CodeGen/aarch64-sve.c
===
--- clang/test/CodeGen/aarch64-sve.c
+++ clang/test/CodeGen/aarch64-sve.c
@@ -1,9 +1,51 @@
 // RUN: not %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
-// RUN:  -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s
+// RUN:  -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s -check-prefix=CHECK-DEBUG
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
+// RUN:  -emit-llvm -o - %s 2>&1 | FileCheck %s -check-prefix=CHECK
 
-// Placeholder test for SVE types
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt8_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt16_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt32_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt64_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint8_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint16_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint32_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint64_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVFloat16_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVFloat32_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVFloat64_t'
+// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVBool_t'
 
-// CHECK: cannot yet generate code for SVE type '__SVInt8_t'
-// CHECK: cannot yet generate debug info for SVE type '__SVInt8_t'
+// CHECK: @ptr = common global * null, align 8
+// CHECK: %s8 = alloca , align 16
+// CHECK: %s16 = alloca , align 16
+// CHECK: %s32 = alloca , align 16
+// CHECK: %s64 = alloca , align 16
+// CHECK: %u8 = alloca , align 16
+// CHECK: %u16 = alloca , align 16
+// CHECK: %u32 = alloca , align 16
+// CHECK: %u64 = alloca , align 16
+// CHECK: %f16 = alloca , align 16
+// CHECK: %f32 = alloca , align 16
+// CHECK: %f64 = alloca , align 16
+// CHECK: %b8 = alloca , align 2
 
 __SVInt8_t *ptr;
+
+void test_locals(void) {
+  __SVInt8_t s8;
+  __SVInt16_t s16;
+  __SVInt32_t s32;
+  __SVInt64_t s64;
+
+  __SVUint8_t u8;
+  __SVUint16_t u16;
+  __SVUint32_t u32;
+  __SVUint64_t u64;
+
+  __SVFloat16_t f16;
+  __SVFloat32_t f32;
+  __SVFloat64_t f64;
+
+  __SVBool_t b8;
+}
Index: clang/lib/CodeGen/CodeGenTypes.cpp
===
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -377,6 +377,48 @@
   return ResultType;
 }
 
+static llvm::Type *getSVEType(ASTContext , llvm::LLVMContext ,
+  BuiltinType::Kind K) {
+  switch (K) {
+  case BuiltinType::SveInt8:
+  case BuiltinType::SveUint8:
+return llvm::VectorType::get(llvm::IntegerType::get(LLVMCtx, 8),
+ {16, true});
+  case BuiltinType::SveInt16:
+  case BuiltinType::SveUint16:
+return llvm::VectorType::get(llvm::IntegerType::get(LLVMCtx, 16),
+ {8, true});
+  case BuiltinType::SveInt32:
+  case BuiltinType::SveUint32:
+return llvm::VectorType::get(llvm::IntegerType::get(LLVMCtx, 32),
+ {4, true});
+  case BuiltinType::SveInt64:
+  case BuiltinType::SveUint64:
+return llvm::VectorType::get(llvm::IntegerType::get(LLVMCtx, 64),
+ {2, true});
+  case BuiltinType::SveFloat16:
+return llvm::VectorType::get(
+getTypeForFormat(LLVMCtx, Ctx.getFloatTypeSemantics(Ctx.HalfTy),
+ /* UseNativeHalf = */ true),
+{8, true});
+  case 

[clang-tools-extra] 351ed50 - Reland "[clang-tools-extra] fix the check for if '-latomic' is necessary""

2020-02-17 Thread Luís Marques via cfe-commits

Author: Gokturk Yuksek
Date: 2020-02-17T16:53:29Z
New Revision: 351ed50dcb2a67a88213ef67469f70bd5e2b4a60

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

LOG: Reland "[clang-tools-extra] fix the check for if '-latomic' is necessary""

The buildbot failures on MSVC should have been fixed by f128f442a3d.

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index e3eccb50a496..fc5a07e69e9d 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -30,7 +30,7 @@ if(CLANG_BUILT_STANDALONE)
 endif()
 
 set(CLANGD_ATOMIC_LIB "")
-if(NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
+if(NOT HAVE_CXX_ATOMICS_WITHOUT_LIB OR NOT HAVE_CXX_ATOMICS64_WITHOUT_LIB)
   list(APPEND CLANGD_ATOMIC_LIB "atomic")
 endif()
 



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


[PATCH] D74337: [ARM,MVE] Add the vmovnbq,vmovntq intrinsic family.

2020-02-17 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74337



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


[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

2020-02-17 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

+ @rjmccall


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71227



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


[PATCH] D74337: [ARM,MVE] Add the vmovnbq,vmovntq intrinsic family.

2020-02-17 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 244984.
simon_tatham added a comment.

Test on the clang side in both endiannesses.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74337

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vmovn.c
  clang/utils/TableGen/MveEmitter.cpp
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck --check-prefix=LE %s
+; RUN: llc -mtriple=thumbebv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck --check-prefix=BE %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovnbq_s16(<16 x i8> %a, <8 x i16> %b) {
+; LE-LABEL: test_vmovnbq_s16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnb.i16 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovnbq_s16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q2, q1
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovnb.i16 q1, q2
+; BE-NEXT:vrev64.8 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> 
+  %1 = tail call <8 x i16> @llvm.arm.mve.vreinterpretq.v8i16.v16i8(<16 x i8> %0)
+  %2 = shufflevector <8 x i16> %b, <8 x i16> %1, <16 x i32> 
+  %3 = trunc <16 x i16> %2 to <16 x i8>
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovnbq_s32(<8 x i16> %a, <4 x i32> %b) {
+; LE-LABEL: test_vmovnbq_s32:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnb.i32 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovnbq_s32:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.32 q2, q1
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovnb.i32 q1, q2
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> 
+  %1 = tail call <4 x i32> @llvm.arm.mve.vreinterpretq.v4i32.v8i16(<8 x i16> %0)
+  %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <8 x i32> 
+  %3 = trunc <8 x i32> %2 to <8 x i16>
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovnbq_u16(<16 x i8> %a, <8 x i16> %b) {
+; LE-LABEL: test_vmovnbq_u16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnb.i16 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovnbq_u16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q2, q1
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovnb.i16 q1, q2
+; BE-NEXT:vrev64.8 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> 
+  %1 = tail call <8 x i16> @llvm.arm.mve.vreinterpretq.v8i16.v16i8(<16 x i8> %0)
+  %2 = shufflevector <8 x i16> %b, <8 x i16> %1, <16 x i32> 
+  %3 = trunc <16 x i16> %2 to <16 x i8>
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovnbq_u32(<8 x i16> %a, <4 x i32> %b) {
+; LE-LABEL: test_vmovnbq_u32:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnb.i32 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovnbq_u32:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.32 q2, q1
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovnb.i32 q1, q2
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> 
+  %1 = tail call <4 x i32> @llvm.arm.mve.vreinterpretq.v4i32.v8i16(<8 x i16> %0)
+  %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <8 x i32> 
+  %3 = trunc <8 x i32> %2 to <8 x i16>
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovntq_s16(<16 x i8> %a, <8 x i16> %b) {
+; LE-LABEL: test_vmovntq_s16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnt.i16 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovntq_s16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q2, q1
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovnt.i16 q1, q2
+; BE-NEXT:vrev64.8 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vreinterpretq.v8i16.v16i8(<16 x i8> %a)
+  %1 = shufflevector <8 x i16> %0, <8 x i16> %b, <16 x i32> 
+  %2 = trunc <16 x i16> %1 to <16 x i8>
+  ret <16 x i8> %2
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovntq_s32(<8 x i16> %a, <4 x i32> %b) {
+; LE-LABEL: test_vmovntq_s32:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnt.i32 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovntq_s32:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.32 q2, q1
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovnt.i32 q1, q2
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vreinterpretq.v4i32.v8i16(<8 x i16> %a)
+  %1 = 

[PATCH] D60225: [clang-format] [PR19056] Add support for indenting class members and methods one level under the modifiers

2020-02-17 Thread Denis Rouzaud via Phabricator via cfe-commits
3nids added a comment.

Hi there, is there anything we can do to help this to go through?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60225



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


[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

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



Comment at: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp:114-117
+  const auto MacroIt = llvm::find_if(
+  PP.macros(), [&](const auto ) { return K.first->getName() == Macro; });
+  if (MacroIt == PP.macro_end())
+return llvm::None;

martong wrote:
> Szelethus wrote:
> > NoQ wrote:
> > > martong wrote:
> > > > Szelethus wrote:
> > > > > This seems a bit clunky even for the `Preprocessor` -- how about
> > > > > 
> > > > > ```lang=c++
> > > > > const auto *MacroII = PP.getIdentifierInfo(Macro);
> > > > > if (!MacroII)
> > > > >   return;
> > > > > const MacroInfo *MI = PP.getMacroInfo(MacroII);
> > > > > assert(MI);
> > > > > ```
> > > > Ok, but we cannot assert on `MI`, because there may be cases when the 
> > > > macro is not defined in a TU. In that case we should just return with 
> > > > None.
> > > What exactly happens when the macro is `#undef`-ined and redefined? We 
> > > get the last redefinition that's valid at the end of the translation 
> > > unit, right? Can we check whether there are multiple definitions and 
> > > guard against that?
> > Ugh, now that you say it that is a valid concern. I had to deal with that 
> > back in the day: https://reviews.llvm.org/D52794?id=171962#inline-476352
> Solving this does not seem easy in my opinion. To handle `#undef`s we should 
> build an infrastructure where summaries can reference callable objects. This 
> is necessary, because in `evalCall` the value of `EOF` would depend on the 
> souce location of the call expression of the function with the summary. Not 
> impossible to solve, but certainly introduces complexity. Do you think that 
> the redefinition of EOF is so common? I mean maybe it is too much hassle for 
> a very rare edge case (?).
The standard library (libc or libc++) should define EOF consitently in stdio.h.
Now, if the application redefines the value of EOF then the code could be 
broken, or at least it would not be compatible with libc. Consider the 
following code that is perfectly legit if we don't redefine EOF, but if we do:
```
#include 
#include 
#define EOF -2 // Here be dragons !!!
int main(void)
{
FILE* fp = fopen("test.txt", "r");
int c;
while ((c = fgetc(fp)) != EOF) { // BOOM: Infinite loop !!!
   putchar(c);
}
fclose(fp);
}
```
So, redefinition of EOF (or any standard macro) results in broken code.
And this is also a warning:
```
) clang eof-inf.c
eof-inf.c:3:9: warning: 'EOF' macro redefined [-Wmacro-redefined]
#define EOF -2 // Here be dragons !!!
^
/usr/include/x86_64-linux-gnu/bits/libio.h:66:10: note: previous definition is 
here
# define EOF (-1)
 ^
1 warning generated.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74473



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


[PATCH] D74721: [ARM,MVE] Add vbrsrq intrinsics family

2020-02-17 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki created this revision.
miyuki added reviewers: simon_tatham, dmgreen, ostannard, MarkMurrayARM.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.
miyuki added a parent revision: D74620: [ARM,MVE] Add vector-scalar intrinsics.

This patch adds a new MVE intrinsics family, `vbrsrq`: vector bit
reverse and shift right. The intrinsics are compiled into the VBRSR
instruction. Two new LLVM IR intrinsics were also added: arm.mve.vbrsr
and arm.mve.vbrsr.predicated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74721

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vbrsrq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vbrsrq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vbrsrq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vbrsrq.ll
@@ -0,0 +1,89 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+declare <8 x half> @llvm.arm.mve.vbrsr.v8f16(<8 x half>, i32)
+declare <4 x i32> @llvm.arm.mve.vbrsr.v4i32(<4 x i32>, i32)
+declare <16 x i8> @llvm.arm.mve.vbrsr.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, i32, <16 x i1>)
+declare <8 x i16> @llvm.arm.mve.vbrsr.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, i32, <8 x i1>)
+declare <4 x float> @llvm.arm.mve.vbrsr.predicated.v4f32.v4i1(<4 x float>, <4 x float>, i32, <4 x i1>)
+declare <8 x half> @llvm.arm.mve.vbrsr.predicated.v8f16.v8i1(<8 x half>, <8 x half>, i32, <8 x i1>)
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32)
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32)
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32)
+
+define arm_aapcs_vfpcc <4 x i32> @test_vbrsrq_n_u32(<4 x i32> %a, i32 %b) {
+; CHECK-LABEL: test_vbrsrq_n_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vbrsr.32 q0, q0, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call <4 x i32> @llvm.arm.mve.vbrsr.v4i32(<4 x i32> %a, i32 %b)
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x half> @test_vbrsrq_n_f16(<8 x half> %a, i32 %b) {
+; CHECK-LABEL: test_vbrsrq_n_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vbrsr.16 q0, q0, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = call <8 x half> @llvm.arm.mve.vbrsr.v8f16(<8 x half> %a, i32 %b)
+  ret <8 x half> %0
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vbrsrq_m_n_s8(<16 x i8> %inactive, <16 x i8> %a, i32 %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vbrsrq_m_n_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vbrsrt.8 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = call <16 x i8> @llvm.arm.mve.vbrsr.predicated.v16i8.v16i1(<16 x i8> %inactive, <16 x i8> %a, i32 %b, <16 x i1> %1)
+  ret <16 x i8> %2
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vbrsrq_m_n_f32(<4 x float> %inactive, <4 x float> %a, i32 %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vbrsrq_m_n_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vbrsrt.32 q0, q1, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = call <4 x float> @llvm.arm.mve.vbrsr.predicated.v4f32.v4i1(<4 x float> %inactive, <4 x float> %a, i32 %b, <4 x i1> %1)
+  ret <4 x float> %2
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vbrsrq_x_n_u16(<8 x i16> %a, i32 %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vbrsrq_x_n_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vbrsrt.16 q0, q0, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = call <8 x i16> @llvm.arm.mve.vbrsr.predicated.v8i16.v8i1(<8 x i16> undef, <8 x i16> %a, i32 %b, <8 x i1> %1)
+  ret <8 x i16> %2
+}
+
+define arm_aapcs_vfpcc <8 x half> @test_vbrsrq_x_n_f16(<8 x half> %a, i32 %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vbrsrq_x_n_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r1
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vbrsrt.16 q0, q0, r0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = call <8 x half> @llvm.arm.mve.vbrsr.predicated.v8f16.v8i1(<8 x half> undef, <8 x half> %a, i32 %b, <8 x i1> %1)
+  ret <8 x half> %2
+}
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -4760,6 +4760,20 @@
 def MVE_VBRSR16 : MVE_VBRSR<"vbrsr", "16", 0b01>;
 def MVE_VBRSR32 : MVE_VBRSR<"vbrsr", "32", 0b10>;
 

[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-17 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1468
   }
-  S.DeviceDeferredDiags.erase(It);
 

This particular change causes duplication of deferred diagnostics.
Consider the following example (please correct me if I'm doing something wrong, 
I'm not an expert in OpenMP):

```
int foobar1() { throw 1; } // error is expected here

// let's try to use foobar1 in the code where exceptions aren't allowed
#pragma omp declare target
int (*B)() = 
#pragma omp end declare target

// and in some other place let's use foobar1 in device code again
#pragma omp declare target
int a = foobar1();
#pragma omp end declare target

```
Then diagnostic for `foobar1`  will be duplicated for each use of `foobar1` 
under `target` directive.
I first experienced this behavior not with OpenMP, so I suppose reproducer can 
be done for each programming model which uses deferred diagnostics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


[PATCH] D74720: [ASTImporter] Improved variable template redecl chain handling.

2020-02-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, teemperor, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74720

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

Index: clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
===
--- clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
+++ clang/unittests/AST/ASTImporterGenericRedeclTest.cpp
@@ -74,6 +74,21 @@
   }
 };
 
+struct VariableTemplate {
+  using DeclTy = VarTemplateDecl;
+  static constexpr auto *Prototype = "template  extern T X;";
+  static constexpr auto *Definition =
+  R"(
+  template  T X;
+  template <> int X;
+  )";
+  // There is no matcher for varTemplateDecl so use a work-around.
+  BindableMatcher getPattern() {
+return namedDecl(hasName("X"), unless(isImplicit()),
+ has(templateTypeParmDecl()));
+  }
+};
+
 struct FunctionTemplateSpec {
   using DeclTy = FunctionDecl;
   static constexpr auto *Prototype =
@@ -427,6 +442,9 @@
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, ClassTemplate, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
+RedeclChain, VariableTemplate, ,
+PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(
 RedeclChain, FunctionTemplateSpec, ,
 PrototypeShouldBeImportedAsAPrototypeWhenThereIsNoDefinition)
@@ -446,6 +464,8 @@
 DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 DefinitionShouldBeImportedAsADefinition)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, VariableTemplate, ,
+DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
 DefinitionShouldBeImportedAsADefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
@@ -463,6 +483,8 @@
 ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypeAfterImportedPrototype)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, VariableTemplate, ,
+ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
 ImportPrototypeAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
@@ -480,6 +502,8 @@
 ImportDefinitionAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportDefinitionAfterImportedPrototype)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, VariableTemplate, ,
+ImportDefinitionAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
 ImportDefinitionAfterImportedPrototype)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
@@ -497,6 +521,8 @@
 ImportPrototypeAfterImportedDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypeAfterImportedDefinition)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, VariableTemplate, ,
+ImportPrototypeAfterImportedDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
 ImportPrototypeAfterImportedDefinition)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
@@ -513,6 +539,8 @@
 ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,
 ImportPrototypes)
+ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, VariableTemplate, ,
+ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplateSpec, ,
 ImportPrototypes)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, FunctionTemplateSpec, ,
@@ -529,6 +557,8 @@
 ImportDefinitions)
 ASTIMPORTER_INSTANTIATE_TYPED_TEST_CASE(RedeclChain, ClassTemplate, ,

[PATCH] D74473: [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax

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



Comment at: clang/lib/StaticAnalyzer/Core/CheckerHelpers.cpp:114-117
+  const auto MacroIt = llvm::find_if(
+  PP.macros(), [&](const auto ) { return K.first->getName() == Macro; });
+  if (MacroIt == PP.macro_end())
+return llvm::None;

Szelethus wrote:
> NoQ wrote:
> > martong wrote:
> > > Szelethus wrote:
> > > > This seems a bit clunky even for the `Preprocessor` -- how about
> > > > 
> > > > ```lang=c++
> > > > const auto *MacroII = PP.getIdentifierInfo(Macro);
> > > > if (!MacroII)
> > > >   return;
> > > > const MacroInfo *MI = PP.getMacroInfo(MacroII);
> > > > assert(MI);
> > > > ```
> > > Ok, but we cannot assert on `MI`, because there may be cases when the 
> > > macro is not defined in a TU. In that case we should just return with 
> > > None.
> > What exactly happens when the macro is `#undef`-ined and redefined? We get 
> > the last redefinition that's valid at the end of the translation unit, 
> > right? Can we check whether there are multiple definitions and guard 
> > against that?
> Ugh, now that you say it that is a valid concern. I had to deal with that 
> back in the day: https://reviews.llvm.org/D52794?id=171962#inline-476352
Solving this does not seem easy in my opinion. To handle `#undef`s we should 
build an infrastructure where summaries can reference callable objects. This is 
necessary, because in `evalCall` the value of `EOF` would depend on the souce 
location of the call expression of the function with the summary. Not 
impossible to solve, but certainly introduces complexity. Do you think that the 
redefinition of EOF is so common? I mean maybe it is too much hassle for a very 
rare edge case (?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74473



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


[PATCH] D74571: [OpenMP][CUDA] Add CUDA 10.2 support

2020-02-17 Thread Kelvin Li via Phabricator via cfe-commits
kkwli0 added a comment.

Summary

- In order to avoid the bug in PR44587 
, one needs to build with >9.0.
- With CUDA toolkit 10.2, building the trunk will fail because 10.0.0 does not 
support it yet.


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

https://reviews.llvm.org/D74571



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


[PATCH] D74337: [ARM,MVE] Add the vmovnbq,vmovntq intrinsic family.

2020-02-17 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham marked an inline comment as done.
simon_tatham added inline comments.



Comment at: clang/test/CodeGen/arm-mve-intrinsics/vmovn.c:10
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> 
undef, <16 x i32> 
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x i16>
+// CHECK-NEXT:[[TMP2:%.*]] = shufflevector <8 x i16> [[B:%.*]], <8 x i16> 
[[TMP1]], <16 x i32> 

dmgreen wrote:
> These would be vreinterpret's in bigendian?
Yes – they're constructed by the `vreinterpret` record in the clang-side 
tablegen. Good point; perhaps I should expand the clang test to include a check 
of the BE output too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74337



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


[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf8b0cd58dbd: [clang][Index] Visit the default parameter 
arguements in libindex. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexDecl.cpp
  clang/unittests/Index/IndexTests.cpp


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -90,6 +90,12 @@
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
+const NamedDecl *Parent) {
+  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
+  !Parm->hasUnparsedDefaultArg())
+IndexCtx.indexBody(Parm->getDefaultArg(), Parent);
+};
 if (IndexCtx.shouldIndexFunctionLocalSymbols()) {
   if (const ParmVarDecl *Parm = dyn_cast(D)) {
 auto *DC = Parm->getDeclContext();
@@ -106,7 +112,8 @@
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 if (IndexCtx.shouldIndexParametersInDeclarations() ||
 FD->isThisDeclarationADefinition()) {
-  for (auto PI : FD->parameters()) {
+  for (const auto *PI : FD->parameters()) {
+IndexDefaultParmeterArgument(PI, D);
 IndexCtx.handleDecl(PI);
   }
 }
@@ -116,9 +123,7 @@
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isThisDeclarationADefinition()) {
   for (const auto *PV : FD->parameters()) {
-if (PV->hasDefaultArg() && !PV->hasUninstantiatedDefaultArg() &&
-!PV->hasUnparsedDefaultArg())
-  IndexCtx.indexBody(PV->getDefaultArg(), D);
+IndexDefaultParmeterArgument(PV, D);
   }
 }
   }
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -943,6 +943,11 @@
   int x = [[MACRO]]([[MACRO]](1));
 }
   )cpp",
+
+  R"cpp(
+int [[v^ar]] = 0;
+void foo(int s = [[var]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -90,6 +90,12 @@
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
+const NamedDecl *Parent) {
+  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
+ 

[PATCH] D74689: [clang-tidy] Better custom class support for performance-inefficient-vector-operation

2020-02-17 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D74689#1879065 , @hokein wrote:

> Thanks for the patch. May I know the motivation of this patch? Personally, 
> I'd be conservative of exposing too many options.


I was using custom classes with a different naming convention which was not 
being picked up by this check. Right now this check is only good for classes 
that mimick the stl conventions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74689



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


[PATCH] D74337: [ARM,MVE] Add the vmovnbq,vmovntq intrinsic family.

2020-02-17 Thread Dave Green via Phabricator via cfe-commits
dmgreen added inline comments.



Comment at: clang/test/CodeGen/arm-mve-intrinsics/vmovn.c:10
+// CHECK-NEXT:[[TMP0:%.*]] = shufflevector <16 x i8> [[A:%.*]], <16 x i8> 
undef, <16 x i32> 
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x i16>
+// CHECK-NEXT:[[TMP2:%.*]] = shufflevector <8 x i16> [[B:%.*]], <8 x i16> 
[[TMP1]], <16 x i32> 

These would be vreinterpret's in bigendian?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74337



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


[clang-tools-extra] af8b0cd - [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-02-17T16:45:04+01:00
New Revision: af8b0cd58dbda773a0cbbb2a9c67559fc6a59d1d

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

LOG: [clang][Index] Visit the default parameter arguements in libindex.

Summary:
We are missing the default parmeter arguments when IndexFunctionLocals
is true.

Fixes https://github.com/clangd/clangd/issues/285.

Reviewers: kadircet

Subscribers: kristof.beyls, ilya-biryukov, jkorous, arphaman, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/unittests/XRefsTests.cpp
clang/lib/Index/IndexDecl.cpp
clang/unittests/Index/IndexTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp 
b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
index 226213979b8b..b75c218d143f 100644
--- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -943,6 +943,11 @@ TEST(FindReferences, WithinAST) {
   int x = [[MACRO]]([[MACRO]](1));
 }
   )cpp",
+
+  R"cpp(
+int [[v^ar]] = 0;
+void foo(int s = [[var]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);

diff  --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp
index c59b1372e399..2002c695a9b1 100644
--- a/clang/lib/Index/IndexDecl.cpp
+++ b/clang/lib/Index/IndexDecl.cpp
@@ -90,6 +90,12 @@ class IndexingDeclVisitor : public 
ConstDeclVisitor {
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
+const NamedDecl *Parent) {
+  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
+  !Parm->hasUnparsedDefaultArg())
+IndexCtx.indexBody(Parm->getDefaultArg(), Parent);
+};
 if (IndexCtx.shouldIndexFunctionLocalSymbols()) {
   if (const ParmVarDecl *Parm = dyn_cast(D)) {
 auto *DC = Parm->getDeclContext();
@@ -106,7 +112,8 @@ class IndexingDeclVisitor : public 
ConstDeclVisitor {
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 if (IndexCtx.shouldIndexParametersInDeclarations() ||
 FD->isThisDeclarationADefinition()) {
-  for (auto PI : FD->parameters()) {
+  for (const auto *PI : FD->parameters()) {
+IndexDefaultParmeterArgument(PI, D);
 IndexCtx.handleDecl(PI);
   }
 }
@@ -116,9 +123,7 @@ class IndexingDeclVisitor : public 
ConstDeclVisitor {
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isThisDeclarationADefinition()) {
   for (const auto *PV : FD->parameters()) {
-if (PV->hasDefaultArg() && !PV->hasUninstantiatedDefaultArg() &&
-!PV->hasUnparsedDefaultArg())
-  IndexCtx.indexBody(PV->getDefaultArg(), D);
+IndexDefaultParmeterArgument(PV, D);
   }
 }
   }

diff  --git a/clang/unittests/Index/IndexTests.cpp 
b/clang/unittests/Index/IndexTests.cpp
index 068b30ebfa8a..52744e101f92 100644
--- a/clang/unittests/Index/IndexTests.cpp
+++ b/clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@ TEST(IndexTest, InjecatedNameClass) {
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang



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


[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D74610#1879054 , @kadircet wrote:

> LGTM,
>
> just wondering though if you've tried the solution we discussed offline 
> regarding updating `indexTypeSourceInfo` instead of this call site, could you 
> mention the results in here?
>  So that the next soul that touches these lines has an idea about what's 
> expecting them?


It seemed breaking a few existing tests...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610



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


[PATCH] D74044: [ARM] Add initial support for Custom Datapath Extension (CDE)

2020-02-17 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdd4d09376209: [ARM] Add initial support for Custom Datapath 
Extension (CDE) (authored by miyuki).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74044

Files:
  clang/test/Driver/arm-cde.c
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMInstrCDE.td
  llvm/lib/Target/ARM/ARMInstrInfo.td
  llvm/lib/Target/ARM/ARMPredicates.td
  llvm/lib/Target/ARM/ARMRegisterInfo.td
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h
  llvm/test/MC/ARM/cde-fp-vec.s
  llvm/test/MC/ARM/cde-integer.s
  llvm/test/MC/ARM/cde-vec-pred.s
  llvm/test/MC/Disassembler/ARM/cde-fp-vec.txt
  llvm/test/MC/Disassembler/ARM/cde-integer.txt
  llvm/test/MC/Disassembler/ARM/cde-vec-pred.txt

Index: llvm/test/MC/Disassembler/ARM/cde-vec-pred.txt
===
--- /dev/null
+++ llvm/test/MC/Disassembler/ARM/cde-vec-pred.txt
@@ -0,0 +1,19 @@
+# RUN: llvm-mc -disassemble -triple=thumbv8m.main -mattr=+mve -mattr=+cdecp0 -mattr=+cdecp1 < %s | FileCheck %s
+
+# CHECK: vptete.i8 eq, q0, q0
+[0x41,0xfe,0x00,0xef]
+# CHECK-NEXT: vcx1t p0, q1, #1234
+[0x29,0xec,0xd2,0x20]
+# CHECK-NEXT: vcx1ae p1, q5, #4095
+[0x2f,0xfd,0xff,0xa1]
+# CHECK-NEXT: vcx2t p1, q0, q6, #123
+[0x3e,0xed,0xdc,0x01]
+# CHECK-NEXT: vcx2ae p1, q3, q7, #127
+[0x3f,0xfd,0xde,0x61]
+
+# CHECK-NEXT: vpte.i8 eq, q0, q0
+[0x41,0xfe,0x00,0x8f]
+# CHECK-NEXT: vcx3at p1, q3, q7, q6, #15
+[0xbe,0xfd,0x5c,0x61]
+# CHECK-NEXT: vcx3e p0, q0, q2, q0, #12
+[0xa4,0xed,0x40,0x00]
Index: llvm/test/MC/Disassembler/ARM/cde-integer.txt
===
--- /dev/null
+++ llvm/test/MC/Disassembler/ARM/cde-integer.txt
@@ -0,0 +1,137 @@
+# RUN: not llvm-mc -disassemble -triple=thumbv8m.main -mattr=+cdecp0 -mattr=+cdecp1 < %s 2>%t | FileCheck %s
+# RUN: FileCheck <%t --check-prefix=ERROR %s
+
+# GCP instructions
+
+# CHECK: mrc p3, #1, r3, c15, c15, #5
+[0x3f,0xee,0xbf,0x33]
+# CHECK-NEXT: mcr2 p3, #2, r2, c7, c11, #7
+[0x47,0xfe,0xfb,0x23]
+
+# Predication
+
+# CHECK: itte eq
+[0x06,0xbf]
+itte eq
+# CHECK-NEXT: cx1aeq p0, r3, #8191
+[0x3f,0xfe,0xbf,0x30]
+# CHECK-NEXT: cx2aeq p0, r2, r3, #123
+[0x43,0xfe,0xbb,0x20]
+# CHECK-NEXT: cx3ane p0, r1, r5, r7, #63
+[0xf5,0xfe,0xb1,0x70]
+# CHECK-NEXT: itte eq
+[0x06,0xbf]
+# CHECK-NEXT: cx1daeq p0, r0, r1, #8191
+[0x3f,0xfe,0xff,0x00]
+# CHECK-NEXT: cx2daeq p0, r0, r1, r3, #123
+[0x43,0xfe,0xfb,0x00]
+# CHECK-NEXT: cx3dane p0, r0, r1, r5, r7, #63
+[0xf5,0xfe,0xf0,0x70]
+
+# CX1
+
+# CHECK-NEXT: cx1	p0, r3, #8191
+[0x3f,0xee,0xbf,0x30]
+# CHECK-NEXT: cx1a	p1, r2, #0
+[0x00,0xfe,0x00,0x21]
+# CHECK-NEXT: cx1d p0, r4, r5, #1234
+[0x09,0xee,0xd2,0x40]
+# CHECK-NEXT: cx1da	p1, r2, r3, #1234
+[0x09,0xfe,0xd2,0x21]
+# CHECK-NEXT: cx1	p0, apsr_nzcv, #8191
+[0x3f,0xee,0xbf,0xf0]
+
+# ERROR: [[@LINE+2]]:{{[0-9]+}}: warning: potentially undefined instruction encoding
+# CHECK-NEXT: cx1 p0, sp, #8191
+[0x3f,0xee,0xbf,0xd0]
+# ERROR: [[@LINE+2]]:{{[0-9]+}}: warning: potentially undefined instruction encoding
+# CHECK-NEXT: cx1d p0, r12, sp, #1234
+[0x09,0xee,0xd2,0xc0]
+# ERROR: [[@LINE+2]]:{{[0-9]+}}: warning: potentially undefined instruction encoding
+# CHECK-NEXT: cx1d p0, r2, r3, #1234
+[0x09,0xee,0xd2,0x30]
+
+# CX2
+
+# CHECK-NEXT: cx2	p0, r3, r7, #0
+[0x47,0xee,0x00,0x30]
+# CHECK-NEXT: cx2a	p0, r1, r4, #511
+[0x74,0xfe,0xbf,0x10]
+# CHECK-NEXT: cx2d	p0, r2, r3, r1, #123
+[0x41,0xee,0xfb,0x20]
+# CHECK-NEXT: cx2da p0, r2, r3, r7, #123
+[0x47,0xfe,0xfb,0x20]
+# CHECK-NEXT: cx2da p1, r10, r11, apsr_nzcv, #123
+[0x4f,0xfe,0xfb,0xa1]
+
+# ERROR: [[@LINE+2]]:{{[0-9]+}}: warning: potentially undefined instruction encoding
+# CHECK-NEXT: cx2a	p0, r1, sp, #511
+[0x7d,0xfe,0xbf,0x10]
+# ERROR: [[@LINE+1]]:{{[0-9]+}}: warning: invalid instruction encoding
+[0x4f,0xfe,0xfb,0xe1]
+
+# CX3
+
+# CHECK-NEXT: cx3 p0, r1, r2, r3, #0
+[0x82,0xee,0x01,0x30]
+# CHECK-NEXT: cx3a p0, r1, r5, r7, #63
+[0xf5,0xfe,0xb1,0x70]
+# CHECK-NEXT: cx3d p1, r0, r1, r7, r1, #12
+[0x97,0xee,0xc0,0x11]
+# CHECK-NEXT: cx3da p0, r8, r9, r2, r3, #12
+[0x92,0xfe,0xc8,0x30]
+# CHECK-NEXT: cx3	p1, apsr_nzcv, r7, apsr_nzcv, #12
+[0x97,0xee,0x8f,0xf1]
+# CHECK-NEXT: cx3d	p0, r8, r9, apsr_nzcv, apsr_nzcv, #12
+[0x9f,0xee,0xc8,0xf0]
+
+# ERROR: [[@LINE+2]]:{{[0-9]+}}: warning: potentially undefined instruction encoding
+# CHECK-NEXT: cx3 p0, r1, r2, sp, #0
+[0x82,0xee,0x01,0xd0]
+# ERROR: [[@LINE+1]]:{{[0-9]+}}: warning: invalid instruction encoding
+[0x9f,0xee,0xce,0xf0]
+
+# VCX1
+
+# ERROR: [[@LINE+1]]:{{[0-9]+}}: warning: invalid 

[PATCH] D74336: [ARM,MVE] Add the vmovlbq,vmovltq intrinsic family.

2020-02-17 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.

Nice one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74336



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


[clang] dd4d093 - [ARM] Add initial support for Custom Datapath Extension (CDE)

2020-02-17 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-02-17T15:39:16Z
New Revision: dd4d09376209cdc5615097a5be92105f55d06f5d

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

LOG: [ARM] Add initial support for Custom Datapath Extension (CDE)

Summary:
This patch adds assembly-level support for a new Arm M-profile
architecture extension, Custom Datapath Extension (CDE).

A brief description of the extension is available at
https://developer.arm.com/architectures/instruction-sets/custom-instructions

The latest specification for CDE is currently a beta release and is
available at
https://static.docs.arm.com/ddi0607/aa/DDI0607A_a_armv8m_arm_supplement_cde.pdf

CDE allows chip vendors to add custom CPU instructions.  The CDE
instructions re-use the same encoding space as existing coprocessor
instructions (such as MRC, MCR, CDP etc.). Each coprocessor in range
cp0-cp7 can be configured as either general purpose (GCP) or custom
datapath (CDEv1).  This configuration is defined by the CPU vendor and
is provided to LLVM using 8 subtarget features: cdecp0 ... cdecp7.

The semantics of CDE instructions are implementation-defined, but the
instructions are guaranteed to be pure (that is, they are stateless,
they do not access memory or any registers except their explicit
inputs/outputs).

CDE requires the CPU to support at least Armv8.0-M mainline
architecture. CDE includes 3 sets of instructions:
* Instructions that operate on general purpose registers and NZCV
  flags
* Instructions that operate on the S or D register file (require
  either FP or MVE extension)
* Instructions that operate on the Q register file, require MVE

The user-facing names that can be specified on the command line are
the same as the 8 subtarget feature names. For example:

$ clang -target arm-none-none-eabi -march=armv8m.main+cdecp0+cdecp3

tells the compiler that the coprocessors 0 and 3 are configured as
CDEv1 and the remaining coprocessors are configured as GCP (which is
the default).

Reviewers: simon_tatham, ostannard, dmgreen, eli.friedman

Reviewed By: simon_tatham

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/Driver/arm-cde.c
llvm/lib/Target/ARM/ARMInstrCDE.td
llvm/test/MC/ARM/cde-fp-vec.s
llvm/test/MC/ARM/cde-integer.s
llvm/test/MC/ARM/cde-vec-pred.s
llvm/test/MC/Disassembler/ARM/cde-fp-vec.txt
llvm/test/MC/Disassembler/ARM/cde-integer.txt
llvm/test/MC/Disassembler/ARM/cde-vec-pred.txt

Modified: 
llvm/include/llvm/Support/ARMTargetParser.def
llvm/include/llvm/Support/ARMTargetParser.h
llvm/lib/Target/ARM/ARM.td
llvm/lib/Target/ARM/ARMInstrInfo.td
llvm/lib/Target/ARM/ARMPredicates.td
llvm/lib/Target/ARM/ARMRegisterInfo.td
llvm/lib/Target/ARM/ARMSubtarget.h
llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h

Removed: 




diff  --git a/clang/test/Driver/arm-cde.c b/clang/test/Driver/arm-cde.c
new file mode 100644
index ..696bee46cc34
--- /dev/null
+++ b/clang/test/Driver/arm-cde.c
@@ -0,0 +1,24 @@
+// RUN: %clang -target arm-none-none-eabi -march=armv8m.main %s -### -c 2>&1 | 
FileCheck %s --check-prefix=CHECK-NOCDE
+// CHECK-NOCDE: "-triple" "thumbv8m.main-none-none-eabi"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp0"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp1"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp2"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp3"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp4"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp5"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp6"
+// CHECK-NOCDE-NOT: "-target-feature" "+cdecp7"
+
+// RUN: %clang -target arm-none-none-eabi -march=armv8m.main+cdecp0+cdecp3 %s 
-### -c 2>&1 | FileCheck %s --check-prefix=CHECK-CDE1
+// CHECK-CDE1: "-triple" "thumbv8m.main-none-none-eabi"
+// CHECK-CDE1-DAG: "-target-feature" "+cdecp0"
+// CHECK-CDE1-DAG: "-target-feature" "+cdecp3"
+
+// RUN: %clang -target arm-none-none-eabi -march=armv8m.main+cdecp0+cdecp3 %s 
-### -c 2>&1 | FileCheck %s --check-prefix=CHECK-CDE2
+// CHECK-CDE2: "-triple" "thumbv8m.main-none-none-eabi"
+// CHECK-CDE2-NOT: "-target-feature" "+cdecp1"
+// CHECK-CDE2-NOT: "-target-feature" "+cdecp2"
+// CHECK-CDE2-NOT: "-target-feature" "+cdecp4"
+// CHECK-CDE2-NOT: "-target-feature" "+cdecp5"
+// CHECK-CDE2-NOT: "-target-feature" "+cdecp6"
+// CHECK-CDE2-NOT: "-target-feature" "+cdecp7"

diff  --git a/llvm/include/llvm/Support/ARMTargetParser.def 
b/llvm/include/llvm/Support/ARMTargetParser.def
index 7f03d9a1320a..c3d8c894db85 100644
--- 

[PATCH] D74689: [clang-tidy] Better custom class support for performance-inefficient-vector-operation

2020-02-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the patch. May I know the motivation of this patch? Personally, I'd 
be conservative of exposing too many options.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74689



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


[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

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

LGTM,

just wondering though if you've tried the solution we discussed offline 
regarding updating `indexTypeSourceInfo` instead of this call site, could you 
mention the results in here?
So that the next soul that touches these lines has an idea about what's 
expecting them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610



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


[PATCH] D74692: [clang-tidy] Make bugprone-use-after-move ignore std::move for const values

2020-02-17 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

I've added some individual comments above, but I'd question whether it's really 
necessary to make this change? Even if no move actually happens, the code is 
still wrong (it shouldn't be using std::move in the first place), and it's 
likely the author actually intended for a move to happen, so we should warn 
that that would cause a use-after-move.




Comment at: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp:408
+   unless(anyOf(inDecltypeOrTemplateArg(),
+hasType(qualType(isConstQualified())
   .bind("call-move");

Is this in the right place? It looks as if it's applying to the std::move, not 
its argument?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp:137
+  // CHECK-NOTES-NOT: [[@LINE-1]]:3: warning: 'a' used after it was moved
+  // CHECK-NOTES-NOT: [[@LINE-3]]:15: note: move occurred here
+}

Generally, I would avoid CHECK-NOTES-NOT if possible. Just leave off the 
comments entirely; the test will fail if there were any unexpected diagnostics, 
and the test is more resilient this way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74692



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


[PATCH] D74337: [ARM,MVE] Add the vmovnbq,vmovntq intrinsic family.

2020-02-17 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 244970.
simon_tatham added a comment.

Added tests to make sure the isel rules work in both big- and little-endian.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74337

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vmovn.c
  clang/utils/TableGen/MveEmitter.cpp
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovn.ll
@@ -0,0 +1,170 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck --check-prefix=LE %s
+; RUN: llc -mtriple=thumbebv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck --check-prefix=BE %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovnbq_s16(<16 x i8> %a, <8 x i16> %b) {
+; LE-LABEL: test_vmovnbq_s16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnb.i16 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovnbq_s16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q2, q1
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovnb.i16 q1, q2
+; BE-NEXT:vrev64.8 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> 
+  %1 = tail call <8 x i16> @llvm.arm.mve.vreinterpretq.v8i16.v16i8(<16 x i8> %0)
+  %2 = shufflevector <8 x i16> %b, <8 x i16> %1, <16 x i32> 
+  %3 = trunc <16 x i16> %2 to <16 x i8>
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovnbq_s32(<8 x i16> %a, <4 x i32> %b) {
+; LE-LABEL: test_vmovnbq_s32:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnb.i32 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovnbq_s32:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.32 q2, q1
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovnb.i32 q1, q2
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> 
+  %1 = tail call <4 x i32> @llvm.arm.mve.vreinterpretq.v4i32.v8i16(<8 x i16> %0)
+  %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <8 x i32> 
+  %3 = trunc <8 x i32> %2 to <8 x i16>
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovnbq_u16(<16 x i8> %a, <8 x i16> %b) {
+; LE-LABEL: test_vmovnbq_u16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnb.i16 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovnbq_u16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q2, q1
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovnb.i16 q1, q2
+; BE-NEXT:vrev64.8 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <16 x i32> 
+  %1 = tail call <8 x i16> @llvm.arm.mve.vreinterpretq.v8i16.v16i8(<16 x i8> %0)
+  %2 = shufflevector <8 x i16> %b, <8 x i16> %1, <16 x i32> 
+  %3 = trunc <16 x i16> %2 to <16 x i8>
+  ret <16 x i8> %3
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovnbq_u32(<8 x i16> %a, <4 x i32> %b) {
+; LE-LABEL: test_vmovnbq_u32:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnb.i32 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovnbq_u32:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.32 q2, q1
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovnb.i32 q1, q2
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <8 x i32> 
+  %1 = tail call <4 x i32> @llvm.arm.mve.vreinterpretq.v4i32.v8i16(<8 x i16> %0)
+  %2 = shufflevector <4 x i32> %b, <4 x i32> %1, <8 x i32> 
+  %3 = trunc <8 x i32> %2 to <8 x i16>
+  ret <8 x i16> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmovntq_s16(<16 x i8> %a, <8 x i16> %b) {
+; LE-LABEL: test_vmovntq_s16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnt.i16 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovntq_s16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q2, q1
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovnt.i16 q1, q2
+; BE-NEXT:vrev64.8 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vreinterpretq.v8i16.v16i8(<16 x i8> %a)
+  %1 = shufflevector <8 x i16> %0, <8 x i16> %b, <16 x i32> 
+  %2 = trunc <16 x i16> %1 to <16 x i8>
+  ret <16 x i8> %2
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovntq_s32(<8 x i16> %a, <4 x i32> %b) {
+; LE-LABEL: test_vmovntq_s32:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovnt.i32 q0, q1
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovntq_s32:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.32 q2, q1
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovnt.i32 q1, q2
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> 

[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Looking the source code closely,  we also have another code path of indexing 
the `ParmVarDecl` in `clang/lib/Index/IndexTypeSourceInfo.cpp`,  it was called 
via `IndexCtx.indexTypeSourceInfo` in `handleDeclarator`.

In summary:

1. default arguments will be visited if this is a non-definition decl, 
regardless the shouldIndexFunctionLocatl -- this is done in IndexTypeSourceInfo
2. default arguments will be visited if this is a definition decl and 
shouldIndexFunctionLocal is fasle -- this is done in IndexDecl.
3. default arguments will not be visited if this is a definition decl and 
shouldIndexFunctionLocal is true

This patch fixes 3).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610



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


[PATCH] D74610: [clang][Index] Visit the default parameter arguements in libindex.

2020-02-17 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 244968.
hokein added a comment.

remove an accident change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74610

Files:
  clang-tools-extra/clangd/unittests/XRefsTests.cpp
  clang/lib/Index/IndexDecl.cpp
  clang/unittests/Index/IndexTests.cpp


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -90,6 +90,12 @@
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
+const NamedDecl *Parent) {
+  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
+  !Parm->hasUnparsedDefaultArg())
+IndexCtx.indexBody(Parm->getDefaultArg(), Parent);
+};
 if (IndexCtx.shouldIndexFunctionLocalSymbols()) {
   if (const ParmVarDecl *Parm = dyn_cast(D)) {
 auto *DC = Parm->getDeclContext();
@@ -106,7 +112,8 @@
   } else if (const FunctionDecl *FD = dyn_cast(D)) {
 if (IndexCtx.shouldIndexParametersInDeclarations() ||
 FD->isThisDeclarationADefinition()) {
-  for (auto PI : FD->parameters()) {
+  for (const auto *PI : FD->parameters()) {
+IndexDefaultParmeterArgument(PI, D);
 IndexCtx.handleDecl(PI);
   }
 }
@@ -116,9 +123,7 @@
   if (const auto *FD = dyn_cast(D)) {
 if (FD->isThisDeclarationADefinition()) {
   for (const auto *PV : FD->parameters()) {
-if (PV->hasDefaultArg() && !PV->hasUninstantiatedDefaultArg() &&
-!PV->hasUnparsedDefaultArg())
-  IndexCtx.indexBody(PV->getDefaultArg(), D);
+IndexDefaultParmeterArgument(PV, D);
   }
 }
   }
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -943,6 +943,11 @@
   int x = [[MACRO]]([[MACRO]](1));
 }
   )cpp",
+
+  R"cpp(
+int [[v^ar]] = 0;
+void foo(int s = [[var]]);
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -319,6 +319,21 @@
  WrittenAt(Position(4, 14);
 }
 
+TEST(IndexTest, VisitDefaultArgs) {
+  std::string Code = R"cpp(
+int var = 0;
+void f(int s = var) {}
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  Opts.IndexFunctionLocals = true;
+  Opts.IndexParametersInDeclarations = true;
+  tooling::runToolOnCode(std::make_unique(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("var"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 20);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -90,6 +90,12 @@
  Parent->getLexicalDeclContext(),
  /*isBase=*/false, isIBType);
 IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
+auto IndexDefaultParmeterArgument = [&](const ParmVarDecl *Parm,
+const NamedDecl *Parent) {
+  if (Parm->hasDefaultArg() && !Parm->hasUninstantiatedDefaultArg() &&
+  !Parm->hasUnparsedDefaultArg())
+IndexCtx.indexBody(Parm->getDefaultArg(), Parent);
+

[PATCH] D74336: [ARM,MVE] Add the vmovlbq,vmovltq intrinsic family.

2020-02-17 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham updated this revision to Diff 244969.
simon_tatham added a comment.

Made the new isel patterns work in big-endian as well as little. Depends on the 
extra preparatory patch D74716 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74336

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-mve-intrinsics/vmovl.c
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
  llvm/test/CodeGen/Thumb2/mve-shuffleext.ll

Index: llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
===
--- llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
+++ llvm/test/CodeGen/Thumb2/mve-shuffleext.ll
@@ -15,8 +15,7 @@
 define arm_aapcs_vfpcc <4 x i32> @sext_1357(<8 x i16> %src) {
 ; CHECK-LABEL: sext_1357:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev32.16 q0, q0
-; CHECK-NEXT:vmovlb.s16 q0, q0
+; CHECK-NEXT:vmovlt.s16 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <8 x i16> %src, <8 x i16> undef, <4 x i32> 
@@ -38,8 +37,7 @@
 define arm_aapcs_vfpcc <4 x i32> @zext_1357(<8 x i16> %src) {
 ; CHECK-LABEL: zext_1357:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev32.16 q0, q0
-; CHECK-NEXT:vmovlb.u16 q0, q0
+; CHECK-NEXT:vmovlt.u16 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <8 x i16> %src, <8 x i16> undef, <4 x i32> 
@@ -61,8 +59,7 @@
 define arm_aapcs_vfpcc <8 x i16> @sext_13579111315(<16 x i8> %src) {
 ; CHECK-LABEL: sext_13579111315:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev16.8 q0, q0
-; CHECK-NEXT:vmovlb.s8 q0, q0
+; CHECK-NEXT:vmovlt.s8 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <16 x i8> %src, <16 x i8> undef, <8 x i32> 
@@ -84,8 +81,7 @@
 define arm_aapcs_vfpcc <8 x i16> @zext_13579111315(<16 x i8> %src) {
 ; CHECK-LABEL: zext_13579111315:
 ; CHECK:   @ %bb.0: @ %entry
-; CHECK-NEXT:vrev16.8 q0, q0
-; CHECK-NEXT:vmovlb.u8 q0, q0
+; CHECK-NEXT:vmovlt.u8 q0, q0
 ; CHECK-NEXT:bx lr
 entry:
   %strided.vec = shufflevector <16 x i8> %src, <16 x i8> undef, <8 x i32> 
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmovl.ll
@@ -0,0 +1,147 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck --check-prefix=LE %s
+; RUN: llc -mtriple=thumbebv8.1m.main -mattr=+mve -verify-machineinstrs -o - %s | FileCheck --check-prefix=BE %s
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovlbq_s8(<16 x i8> %a) {
+; LE-LABEL: test_vmovlbq_s8:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovlb.s8 q0, q0
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovlbq_s8:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovlb.s8 q1, q1
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <8 x i32> 
+  %1 = sext <8 x i8> %0 to <8 x i16>
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmovlbq_s16(<8 x i16> %a) {
+; LE-LABEL: test_vmovlbq_s16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovlb.s16 q0, q0
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovlbq_s16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovlb.s16 q1, q1
+; BE-NEXT:vrev64.32 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <4 x i32> 
+  %1 = sext <4 x i16> %0 to <4 x i32>
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovlbq_u8(<16 x i8> %a) {
+; LE-LABEL: test_vmovlbq_u8:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovlb.u8 q0, q0
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovlbq_u8:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.8 q1, q0
+; BE-NEXT:vmovlb.u8 q1, q1
+; BE-NEXT:vrev64.16 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <16 x i8> %a, <16 x i8> undef, <8 x i32> 
+  %1 = zext <8 x i8> %0 to <8 x i16>
+  ret <8 x i16> %1
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmovlbq_u16(<8 x i16> %a) {
+; LE-LABEL: test_vmovlbq_u16:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:vmovlb.u16 q0, q0
+; LE-NEXT:bx lr
+;
+; BE-LABEL: test_vmovlbq_u16:
+; BE:   @ %bb.0: @ %entry
+; BE-NEXT:vrev64.16 q1, q0
+; BE-NEXT:vmovlb.u16 q1, q1
+; BE-NEXT:vrev64.32 q0, q1
+; BE-NEXT:bx lr
+entry:
+  %0 = shufflevector <8 x i16> %a, <8 x i16> undef, <4 x i32> 
+  %1 = zext <4 x i16> %0 to <4 x i32>
+  ret <4 x i32> %1
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vmovltq_s8(<16 x i8> %a) {
+; LE-LABEL: test_vmovltq_s8:
+; LE:   @ %bb.0: @ %entry
+; LE-NEXT:

[PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-17 Thread Sam Elliott via Phabricator via cfe-commits
lenary accepted this revision.
lenary added a comment.
This revision is now accepted and ready to land.

In D74704#1878944 , @jrtc27 wrote:

> This isn't a new problem. The Linux and FreeBSD toolchains already support 
> -fuse-ld=lld properly, it's just the bare metal one that didn't. People also 
> generally don't include -fuse-ld=lld in CFLAGS, only LDFLAGS, and there's no 
> need to include -mno-relax in LDFLAGS, so I suspect you wouldn't catch many 
> issues. These days (https://reviews.llvm.org/D71820), LLD will give you an 
> informative error (rather than silently mis-linking) if you forget -mno-relax.


Ah, ok, I see how these parts fit together now.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704



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


[PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-17 Thread James Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D74704#1878921 , @lenary wrote:

> I am worried about the interaction between `-fuse-ld=lld` and linker 
> relaxation (which is not supported by LLD, as I understand it)
>
> 1. clang could ignore `-fuse-ld=lld` when linker relaxation is enabled
> 2. clang could ignore (disable) linker relaxation if `-fuse-ld=lld` is used
>
>   At the very least, a warning of some kind should be emitted if linker 
> relaxation is combined with `-fuse-ld=lld`.


This isn't a new problem. The Linux and FreeBSD toolchains already support 
-fuse-ld=lld properly, it's just the bare metal one that didn't. People also 
generally don't include -fuse-ld=lld in CFLAGS, only LDFLAGS, and there's no 
need to include -mno-relax in LDFLAGS, so I suspect you wouldn't catch many 
issues. These days (https://reviews.llvm.org/D71820), LLD will give you an 
informative error (rather than silently mis-linking) if you forget -mno-relax.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704



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


[clang-tools-extra] 5fc5c7d - Strength reduce vectors into arrays. NFCI.

2020-02-17 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-02-17T15:37:35+01:00
New Revision: 5fc5c7db38672c8962879b6fdce68393181c5e08

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

LOG: Strength reduce vectors into arrays. NFCI.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Tooling/ArgumentsAdjusters.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
llvm/lib/Target/Mips/MicroMipsSizeReduction.cpp
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp
mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp
mlir/lib/Dialect/StandardOps/Ops.cpp
mlir/lib/Dialect/VectorOps/VectorOps.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
index cd094219c50b..e00043841b99 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
@@ -16,12 +16,10 @@ namespace clang {
 namespace tidy {
 namespace modernize {
 
-static const llvm::SmallVector DeprecatedTypes = {
-{"::std::ios_base::io_state"},
-{"::std::ios_base::open_mode"},
-{"::std::ios_base::seek_dir"},
-{"::std::ios_base::streamoff"},
-{"::std::ios_base::streampos"}};
+static constexpr std::array DeprecatedTypes = {
+"::std::ios_base::io_state", "::std::ios_base::open_mode",
+"::std::ios_base::seek_dir", "::std::ios_base::streamoff",
+"::std::ios_base::streampos"};
 
 static const llvm::StringMap ReplacementTypes = {
 {"io_state", "iostate"},

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 77f48b92eb01..af9be3a1c128 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3962,19 +3962,17 @@ RValue CodeGenFunction::EmitBuiltinExpr(const 
GlobalDecl GD, unsigned BuiltinID,
 
   // Create a vector of the arguments, as well as a constant value to
   // express to the runtime the number of variadic arguments.
-  std::vector Args = {
-  Queue,  Flags, Range,
-  Kernel, Block, ConstantInt::get(IntTy, NumArgs - 4),
-  ElemPtr};
-  std::vector ArgTys = {
+  llvm::Value *const Args[] = {Queue,  Flags,
+   Range,  Kernel,
+   Block,  ConstantInt::get(IntTy, NumArgs - 
4),
+   ElemPtr};
+  llvm::Type *const ArgTys[] = {
   QueueTy,  IntTy, RangeTy,   GenericVoidPtrTy,
   GenericVoidPtrTy, IntTy, ElemPtr->getType()};
 
-  llvm::FunctionType *FTy = llvm::FunctionType::get(
-  Int32Ty, llvm::ArrayRef(ArgTys), false);
-  auto Call =
-  RValue::get(Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name),
- llvm::ArrayRef(Args)));
+  llvm::FunctionType *FTy = llvm::FunctionType::get(Int32Ty, ArgTys, 
false);
+  auto Call = RValue::get(
+  Builder.CreateCall(CGM.CreateRuntimeFunction(FTy, Name), Args));
   if (TmpSize)
 EmitLifetimeEnd(TmpSize, TmpPtr);
   return Call;

diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 2652c05d844f..c356657541fa 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1527,7 +1527,7 @@ static void findRISCVBareMetalMultilibs(const Driver ,
   };
   // currently only support the set of multilibs like riscv-gnu-toolchain does.
   // TODO: support MULTILIB_REUSE
-  SmallVector RISCVMultilibSet = {
+  constexpr RiscvMultilib RISCVMultilibSet[] = {
   {"rv32i", "ilp32"}, {"rv32im", "ilp32"}, {"rv32iac", "ilp32"},
   {"rv32imac", "ilp32"},  {"rv32imafc", "ilp32f"}, {"rv64imac", "lp64"},
   {"rv64imafdc", "lp64d"}};

diff  --git a/clang/lib/Tooling/ArgumentsAdjusters.cpp 
b/clang/lib/Tooling/ArgumentsAdjusters.cpp
index a609e4ed2469..5869377a03c9 100644
--- a/clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ b/clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -26,7 +26,7 @@ ArgumentsAdjuster getClangSyntaxOnlyAdjuster() {
   return [](const CommandLineArguments , StringRef /*unused*/) {
 CommandLineArguments AdjustedArgs;
 bool HasSyntaxOnly = false;
-const std::vector OutputCommands = {
+constexpr llvm::StringRef 

  1   2   >