[clang] 9bd6b77 - Don't print `&` as part of reference template arguments.

2020-04-15 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-04-15T00:07:12-07:00
New Revision: 9bd6b77ac66fddadc50ca99ca327f1b7f9b0d6e4

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

LOG: Don't print `&` as part of reference template arguments.

In passing, also generalize the mechanism used to allow Decl's printName
functions to override qualified name printing.

Added: 


Modified: 
clang/lib/AST/Decl.cpp
clang/lib/AST/TemplateBase.cpp
clang/test/CodeGenCXX/debug-info-template.cpp

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 1eb85472e3c7..8d98e1fc02e4 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1542,10 +1542,19 @@ void NamedDecl::printQualifiedName(raw_ostream &OS,
 return;
   }
   printNestedNameSpecifier(OS, P);
-  if (getDeclName() || isa(this))
+  if (getDeclName())
 OS << *this;
-  else
-OS << "(anonymous)";
+  else {
+// Give the printName override a chance to pick a 
diff erent name before we
+// fall back to "(anonymous)".
+SmallString<64> NameBuffer;
+llvm::raw_svector_ostream NameOS(NameBuffer);
+printName(NameOS);
+if (NameBuffer.empty())
+  OS << "(anonymous)";
+else
+  OS << NameBuffer;
+  }
 }
 
 void NamedDecl::printNestedNameSpecifier(raw_ostream &OS) const {

diff  --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index c12221376691..6a3d2b30e46e 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/lib/AST/TemplateBase.cpp
@@ -352,13 +352,9 @@ void TemplateArgument::print(const PrintingPolicy &Policy,
 
   case Declaration: {
 NamedDecl *ND = getAsDecl();
-Out << '&';
-if (ND->getDeclName()) {
-  // FIXME: distinguish between pointer and reference args?
-  ND->printQualifiedName(Out);
-} else {
-  Out << "(anonymous)";
-}
+if (!getParamTypeForDecl()->isReferenceType())
+  Out << '&';
+ND->printQualifiedName(Out);
 break;
   }
 

diff  --git a/clang/test/CodeGenCXX/debug-info-template.cpp 
b/clang/test/CodeGenCXX/debug-info-template.cpp
index 4b330a0b0a11..a07222ace150 100644
--- a/clang/test/CodeGenCXX/debug-info-template.cpp
+++ b/clang/test/CodeGenCXX/debug-info-template.cpp
@@ -129,9 +129,7 @@ struct NN {
 // CHECK: [[NNV]] = distinct !DIGlobalVariable(name: "nn"
 // CHECK-SAME: type: ![[NNT:[0-9]+]]
 
-// FIXME: these parameters should probably be rendered as 'glb' rather than
-// '&glb', since they're references, not pointers.
-// CHECK: ![[NNT]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: 
"NN",
+// CHECK: ![[NNT]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: 
"NN",
 // CHECK-SAME: templateParams: [[NNARGS:![0-9]*]]
 // CHECK-SAME: identifier:
 // CHECK: [[NNARGS]] = !{[[NNARG1:![0-9]*]], [[NNARG2:![0-9]*]], 
[[NNARG3:![0-9]*]]}



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


[clang] b09ee88 - Generalize our two different kinds of declaration argument for

2020-04-15 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-04-15T00:07:12-07:00
New Revision: b09ee8882010ff2a7d55e30c46c19533d0ab562d

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

LOG: Generalize our two different kinds of declaration argument for
attributes to support any kind of declaration.

In preparation for adding a third kind.

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index c586f9b9466a..e22e9063b305 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -174,12 +174,10 @@ class IdentifierArgument : 
Argument;
 class IntArgument : Argument;
 class StringArgument : Argument;
 class ExprArgument : Argument;
-class FunctionArgument : Argument;
-class NamedArgument : Argument;
+class DeclArgument
+: Argument {
+  DeclNode Kind = kind;
+}
 
 // An argument of a OMPDeclareVariantAttr that represents the `match`
 // clause of the declare variant by keeping the information (incl. nesting) in
@@ -956,7 +954,7 @@ def OSConsumesThis : InheritableAttr {
 
 def Cleanup : InheritableAttr {
   let Spellings = [GCC<"cleanup">];
-  let Args = [FunctionArgument<"FunctionDecl">];
+  let Args = [DeclArgument];
   let Subjects = SubjectList<[LocalVar]>;
   let Documentation = [Undocumented];
 }
@@ -2382,7 +2380,7 @@ def DiagnoseIf : InheritableAttr {
["error", "warning"],
["DT_Error", "DT_Warning"]>,
   BoolArgument<"ArgDependent", 0, /*fake*/ 1>,
-  NamedArgument<"Parent", 0, /*fake*/ 1>];
+  DeclArgument];
   let InheritEvenIfAlreadyPresent = 1;
   let LateParsed = 1;
   let AdditionalMembers = [{

diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 486799eb81ba..ca3bebd54c7c 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -339,7 +339,7 @@ namespace {
 }
 
 void writeDump(raw_ostream &OS) const override {
-  if (type == "FunctionDecl *" || type == "NamedDecl *") {
+  if (StringRef(type).endswith("Decl *")) {
 OS << "OS << \" \";\n";
 OS << "dumpBareDeclRef(SA->get" << getUpperName() << "());\n";
   } else if (type == "IdentifierInfo *") {
@@ -1290,10 +1290,9 @@ createArgument(const Record &Arg, StringRef Attr,
 Ptr = std::make_unique(Arg, Attr);
   else if (ArgName == "ExprArgument")
 Ptr = std::make_unique(Arg, Attr);
-  else if (ArgName == "FunctionArgument")
-Ptr = std::make_unique(Arg, Attr, "FunctionDecl *");
-  else if (ArgName == "NamedArgument")
-Ptr = std::make_unique(Arg, Attr, "NamedDecl *");
+  else if (ArgName == "DeclArgument")
+Ptr = std::make_unique(
+Arg, Attr, (Arg.getValueAsDef("Kind")->getName() + "Decl *").str());
   else if (ArgName == "IdentifierArgument")
 Ptr = std::make_unique(Arg, Attr, "IdentifierInfo *");
   else if (ArgName == "DefaultBoolArgument")



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


[clang-tools-extra] dffa9df - [clangd] Shard preamble symbols in dynamic index

2020-04-15 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-04-15T09:10:10+02:00
New Revision: dffa9dfbda56820c02e357ad34c24ce8759b4d26

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

LOG: [clangd] Shard preamble symbols in dynamic index

Summary:
This reduces memory usage by dynamic index from more than 400MB to 32MB
when all files in clang-tools-extra/clangd/*.cpp are active in clangd.

Reviewers: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/index/Background.cpp
clang-tools-extra/clangd/index/FileIndex.cpp
clang-tools-extra/clangd/index/FileIndex.h
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/unittests/FileIndexTests.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/Background.cpp 
b/clang-tools-extra/clangd/index/Background.cpp
index 1c26dd48093e..4c5719d0526c 100644
--- a/clang-tools-extra/clangd/index/Background.cpp
+++ b/clang-tools-extra/clangd/index/Background.cpp
@@ -61,51 +61,6 @@ namespace clang {
 namespace clangd {
 namespace {
 
-// Resolves URI to file paths with cache.
-class URIToFileCache {
-public:
-  URIToFileCache(llvm::StringRef HintPath) : HintPath(HintPath) {}
-
-  llvm::StringRef resolve(llvm::StringRef FileURI) {
-auto I = URIToPathCache.try_emplace(FileURI);
-if (I.second) {
-  auto Path = URI::resolve(FileURI, HintPath);
-  if (!Path) {
-elog("Failed to resolve URI {0}: {1}", FileURI, Path.takeError());
-assert(false && "Failed to resolve URI");
-return "";
-  }
-  I.first->second = *Path;
-}
-return I.first->second;
-  }
-
-private:
-  std::string HintPath;
-  llvm::StringMap URIToPathCache;
-};
-
-// We keep only the node "U" and its edges. Any node other than "U" will be
-// empty in the resultant graph.
-IncludeGraph getSubGraph(const URI &U, const IncludeGraph &FullGraph) {
-  IncludeGraph IG;
-
-  std::string FileURI = U.toString();
-  auto Entry = IG.try_emplace(FileURI).first;
-  auto &Node = Entry->getValue();
-  Node = FullGraph.lookup(Entry->getKey());
-  Node.URI = Entry->getKey();
-
-  // URIs inside nodes must point into the keys of the same IncludeGraph.
-  for (auto &Include : Node.DirectIncludes) {
-auto I = IG.try_emplace(Include).first;
-I->getValue().URI = I->getKey();
-Include = I->getKey();
-  }
-
-  return IG;
-}
-
 // We cannot use vfs->makeAbsolute because Cmd.FileName is either absolute or
 // relative to Cmd.Directory, which might not be the same as current working
 // directory.
@@ -219,108 +174,44 @@ void BackgroundIndex::update(
 llvm::StringRef MainFile, IndexFileIn Index,
 const llvm::StringMap &ShardVersionsSnapshot,
 bool HadErrors) {
-  // Partition symbols/references into files.
-  struct File {
-llvm::DenseSet Symbols;
-llvm::DenseSet Refs;
-llvm::DenseSet Relations;
-FileDigest Digest;
-  };
-  llvm::StringMap Files;
-  URIToFileCache URICache(MainFile);
+  llvm::StringMap FilesToUpdate;
   for (const auto &IndexIt : *Index.Sources) {
 const auto &IGN = IndexIt.getValue();
 // Note that sources do not contain any information regarding missing
 // headers, since we don't even know what absolute path they should fall 
in.
-const auto AbsPath = URICache.resolve(IGN.URI);
+auto AbsPath = llvm::cantFail(URI::resolve(IGN.URI, MainFile),
+  "Failed to resovle URI");
 const auto DigestIt = ShardVersionsSnapshot.find(AbsPath);
 // File has 
diff erent contents, or indexing was successful this time.
 if (DigestIt == ShardVersionsSnapshot.end() ||
 DigestIt->getValue().Digest != IGN.Digest ||
 (DigestIt->getValue().HadErrors && !HadErrors))
-  Files.try_emplace(AbsPath).first->getValue().Digest = IGN.Digest;
-  }
-  // This map is used to figure out where to store relations.
-  llvm::DenseMap SymbolIDToFile;
-  for (const auto &Sym : *Index.Symbols) {
-if (Sym.CanonicalDeclaration) {
-  auto DeclPath = URICache.resolve(Sym.CanonicalDeclaration.FileURI);
-  const auto FileIt = Files.find(DeclPath);
-  if (FileIt != Files.end()) {
-FileIt->second.Symbols.insert(&Sym);
-SymbolIDToFile[Sym.ID] = &FileIt->second;
-  }
-}
-// For symbols with 
diff erent declaration and definition locations, we store
-// the full symbol in both the header file and the implementation file, so
-// that merging can tell the preferred symbols (from canonical headers) 
from
-// other symbols (e.g. forward declarations).
-if (Sym.Definition &&
-Sym.Definition.File

[clang-tools-extra] 6d53897 - [clangd] Fix MSVC builds

2020-04-15 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-04-15T09:24:58+02:00
New Revision: 6d538975543475ce64e840b6b7c9915250bdac36

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

LOG: [clangd] Fix MSVC builds

Added: 


Modified: 
clang-tools-extra/clangd/index/FileIndex.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/FileIndex.cpp 
b/clang-tools-extra/clangd/index/FileIndex.cpp
index d644268b8da9..92a11cd06e56 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -190,7 +190,7 @@ FileShardedIndex::FileShardedIndex(IndexFileIn Input, 
PathRef HintPath)
   }
 }
 std::vector FileShardedIndex::getAllFiles() const {
-  return {Shards.keys().begin(), Shards.keys().end()};
+  return std::vector(Shards.keys().begin(), Shards.keys().end());
 }
 
 IndexFileIn FileShardedIndex::getShard(PathRef File) const {



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


[PATCH] D75364: [clang-format] Handle macros in function params and return value

2020-04-15 Thread Tamas Petz via Phabricator via cfe-commits
tamas.petz abandoned this revision.
tamas.petz added a comment.

In D75364#1966818 , @MyDeveloperDay 
wrote:

> In D75364#1966743 , @tamas.petz 
> wrote:
>
> > Wow, I have missed that configuration option.
> >  I will try it, I assume it should work.
> >
> > Looks like this change should be abandoned.
>
>
> To be honest, I forget what we've got too! ;-) I was just writing a reply 
> that said "how about adding an option with a list of type macros", I was 
> looking for an example of other places we do that, and stumbled on it.


: ) I am now abandoning this change.
Thank you all for you comments.


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

https://reviews.llvm.org/D75364



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


[PATCH] D78181: [clangd] Fix a crash for accessing a null field decl returned by findExplicitReferences.

2020-04-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78181

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1243,7 +1243,31 @@
 "5: targets = {Bar}\n"
 "6: targets = {bar}, decl\n"
 "7: targets = {foo()::Bar::Foo}\n"
-"8: targets = {foo()::Baz::Field}\n"}};
+"8: targets = {foo()::Baz::Field}\n"},
+  {R"cpp(
+   namespace foo {
+  struct $0^ForwardDecl;
+  template
+  void $2^crash(const $3^ForwardDecl&, $4^T &);
+  template
+  void $6^test($7^T $8^t) {
+$9^crash({.x = 1}, $10^t);
+  }
+   }
+)cpp",
+"0: targets = {foo::ForwardDecl}, decl\n"
+"1: targets = {T}, decl\n"
+"2: targets = {foo::crash}, decl\n"
+"3: targets = {foo::ForwardDecl}\n"
+"4: targets = {T}\n"
+"5: targets = {T}, decl\n"
+"6: targets = {foo::test}, decl\n"
+"7: targets = {T}\n"
+"8: targets = {t}, decl\n"
+"9: targets = {foo::crash}\n"
+"10: targets = {t}\n"
+  },
+};
 
   for (const auto &C : Cases) {
 llvm::StringRef ExpectedCode = C.first;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -699,6 +699,8 @@
   for (const DesignatedInitExpr::Designator &D : DIE->designators()) {
 if (!D.isFieldDesignator())
   continue;
+if (!D.getField())
+  continue;
 Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
 D.getFieldLoc(),
 /*IsDecl=*/false,


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1243,7 +1243,31 @@
 "5: targets = {Bar}\n"
 "6: targets = {bar}, decl\n"
 "7: targets = {foo()::Bar::Foo}\n"
-"8: targets = {foo()::Baz::Field}\n"}};
+"8: targets = {foo()::Baz::Field}\n"},
+  {R"cpp(
+   namespace foo {
+  struct $0^ForwardDecl;
+  template
+  void $2^crash(const $3^ForwardDecl&, $4^T &);
+  template
+  void $6^test($7^T $8^t) {
+$9^crash({.x = 1}, $10^t);
+  }
+   }
+)cpp",
+"0: targets = {foo::ForwardDecl}, decl\n"
+"1: targets = {T}, decl\n"
+"2: targets = {foo::crash}, decl\n"
+"3: targets = {foo::ForwardDecl}\n"
+"4: targets = {T}\n"
+"5: targets = {T}, decl\n"
+"6: targets = {foo::test}, decl\n"
+"7: targets = {T}\n"
+"8: targets = {t}, decl\n"
+"9: targets = {foo::crash}\n"
+"10: targets = {t}\n"
+  },
+};
 
   for (const auto &C : Cases) {
 llvm::StringRef ExpectedCode = C.first;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -699,6 +699,8 @@
   for (const DesignatedInitExpr::Designator &D : DIE->designators()) {
 if (!D.isFieldDesignator())
   continue;
+if (!D.getField())
+  continue;
 Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
 D.getFieldLoc(),
 /*IsDecl=*/false,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77732: [clangd] Shard preamble symbols in dynamic index

2020-04-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdffa9dfbda56: [clangd] Shard preamble symbols in dynamic 
index (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77732

Files:
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -116,9 +116,10 @@
 std::unique_ptr TestTU::index() const {
   auto AST = build();
   auto Idx = std::make_unique(/*UseDex=*/true);
-  Idx->updatePreamble(Filename, /*Version=*/"null", AST.getASTContext(),
-  AST.getPreprocessorPtr(), AST.getCanonicalIncludes());
-  Idx->updateMain(Filename, AST);
+  Idx->updatePreamble(testPath(Filename), /*Version=*/"null",
+  AST.getASTContext(), AST.getPreprocessorPtr(),
+  AST.getCanonicalIncludes());
+  Idx->updateMain(testPath(Filename), AST);
   return std::move(Idx);
 }
 
Index: clang-tools-extra/clangd/unittests/FileIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/FileIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/FileIndexTests.cpp
@@ -9,13 +9,19 @@
 #include "AST.h"
 #include "Annotations.h"
 #include "Compiler.h"
+#include "Headers.h"
 #include "ParsedAST.h"
 #include "SyncAPI.h"
 #include "TestFS.h"
 #include "TestTU.h"
+#include "URI.h"
 #include "index/CanonicalIncludes.h"
 #include "index/FileIndex.h"
 #include "index/Index.h"
+#include "index/Ref.h"
+#include "index/Relation.h"
+#include "index/Serialization.h"
+#include "index/Symbol.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/Utils.h"
 #include "clang/Index/IndexSymbol.h"
@@ -23,6 +29,7 @@
 #include "clang/Tooling/CompilationDatabase.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 
 using ::testing::_;
 using ::testing::AllOf;
@@ -151,8 +158,9 @@
   File.HeaderFilename = (Basename + ".h").str();
   File.HeaderCode = std::string(Code);
   auto AST = File.build();
-  M.updatePreamble(File.Filename, /*Version=*/"null", AST.getASTContext(),
-   AST.getPreprocessorPtr(), AST.getCanonicalIncludes());
+  M.updatePreamble(testPath(File.Filename), /*Version=*/"null",
+   AST.getASTContext(), AST.getPreprocessorPtr(),
+   AST.getCanonicalIncludes());
 }
 
 TEST(FileIndexTest, CustomizedURIScheme) {
@@ -393,8 +401,9 @@
   TU.HeaderCode = "class A {}; class B : public A {};";
   auto AST = TU.build();
   FileIndex Index;
-  Index.updatePreamble(TU.Filename, /*Version=*/"null", AST.getASTContext(),
-   AST.getPreprocessorPtr(), AST.getCanonicalIncludes());
+  Index.updatePreamble(testPath(TU.Filename), /*Version=*/"null",
+   AST.getASTContext(), AST.getPreprocessorPtr(),
+   AST.getCanonicalIncludes());
   SymbolID A = findSymbol(TU.headerSymbols(), "A").ID;
   uint32_t Results = 0;
   RelationsRequest Req;
@@ -477,6 +486,128 @@
AllOf(QName("2"), NumReferences(1u)),
AllOf(QName("3"), NumReferences(1u;
 }
+
+TEST(FileIndexTest, StalePreambleSymbolsDeleted) {
+  FileIndex M;
+  TestTU File;
+  File.HeaderFilename = "a.h";
+
+  File.Filename = "f1.cpp";
+  File.HeaderCode = "int a;";
+  auto AST = File.build();
+  M.updatePreamble(testPath(File.Filename), /*Version=*/"null",
+   AST.getASTContext(), AST.getPreprocessorPtr(),
+   AST.getCanonicalIncludes());
+  EXPECT_THAT(runFuzzyFind(M, ""), UnorderedElementsAre(QName("a")));
+
+  File.Filename = "f2.cpp";
+  File.HeaderCode = "int b;";
+  AST = File.build();
+  M.updatePreamble(testPath(File.Filename), /*Version=*/"null",
+   AST.getASTContext(), AST.getPreprocessorPtr(),
+   AST.getCanonicalIncludes());
+  EXPECT_THAT(runFuzzyFind(M, ""), UnorderedElementsAre(QName("b")));
+}
+
+TEST(FileShardedIndexTest, Sharding) {
+  auto AHeaderUri = URI::create(testPath("a.h")).toString();
+  auto BHeaderUri = URI::create(testPath("b.h")).toString();
+  auto BSourceUri = URI::create(testPath("b.cc")).toString();
+
+  auto Sym1 = symbol("1");
+  Sym1.CanonicalDeclaration.FileURI = AHeaderUri.c_str();
+
+  auto Sym2 = symbol("2");
+  Sym2.CanonicalDeclaration.FileURI = BHeaderUri.c_str();
+  Sym2.Definition.FileURI = BSourceUri.c_str();
+
+  IndexFileIn IF;
+  {
+SymbolSlab::Builder B;
+// Should be stored in only a.h
+

[clang-tools-extra] 2cd0be0 - [clangd] Fix MSVC compile error, attempt 2

2020-04-15 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-04-15T09:33:12+02:00
New Revision: 2cd0be02b9cbe4592dbf1ad3faef13970674b468

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

LOG: [clangd] Fix MSVC compile error, attempt 2

Added: 


Modified: 
clang-tools-extra/clangd/index/FileIndex.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/FileIndex.cpp 
b/clang-tools-extra/clangd/index/FileIndex.cpp
index 92a11cd06e56..91914be00148 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -190,7 +190,13 @@ FileShardedIndex::FileShardedIndex(IndexFileIn Input, 
PathRef HintPath)
   }
 }
 std::vector FileShardedIndex::getAllFiles() const {
-  return std::vector(Shards.keys().begin(), Shards.keys().end());
+  // It should be enough to construct a vector with {Shards.keys().begin(),
+  // Shards.keys().end()} but MSVC fails to compile that.
+  std::vector Result;
+  Result.reserve(Shards.size());
+  for (PathRef Key : Shards.keys())
+Result.push_back(Key);
+  return Result;
 }
 
 IndexFileIn FileShardedIndex::getShard(PathRef File) const {



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


[PATCH] D78126: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics

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



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:153
+#undef CHECKER_DEPENDENCY
+#undef GET_CHECKER_DEPENDENCIES
+  }

Probably too much of assert here (but it works)? (There is not a way to get the 
dependency data "dynamically", like //"Checker->isDependentOn(OtherChecker)"//?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78126



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


[PATCH] D74813: [RFC] Add hash of block contents to function block names

2020-04-15 Thread Alex Borcan via Phabricator via cfe-commits
alexbdv updated this revision to Diff 257616.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74813

Files:
  clang/lib/AST/Mangle.cpp


Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -36,11 +36,14 @@
 StringRef Outer,
 const BlockDecl *BD,
 raw_ostream &Out) {
-  unsigned discriminator = Context.getBlockId(BD, true);
-  if (discriminator == 0)
-Out << "__" << Outer << "_block_invoke";
-  else
-Out << "__" << Outer << "_block_invoke_" << discriminator+1;
+  Out << "__" << Outer << "_block_invoke__";
+
+  ArrayRef params = BD->parameters();
+  for(unsigned i = 0; i < params.size(); i++) {
+ParmVarDecl *param = params[i];
+Out << "_";
+Context.mangleTypeName(param->getType(), Out);
+  }
 }
 
 void MangleContext::anchor() { }


Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -36,11 +36,14 @@
 StringRef Outer,
 const BlockDecl *BD,
 raw_ostream &Out) {
-  unsigned discriminator = Context.getBlockId(BD, true);
-  if (discriminator == 0)
-Out << "__" << Outer << "_block_invoke";
-  else
-Out << "__" << Outer << "_block_invoke_" << discriminator+1;
+  Out << "__" << Outer << "_block_invoke__";
+
+  ArrayRef params = BD->parameters();
+  for(unsigned i = 0; i < params.size(); i++) {
+ParmVarDecl *param = params[i];
+Out << "_";
+Context.mangleTypeName(param->getType(), Out);
+  }
 }
 
 void MangleContext::anchor() { }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74813: [RFC] Add hash of block contents to function block names

2020-04-15 Thread Alex Borcan via Phabricator via cfe-commits
alexbdv added a comment.

@dexonsmith - I think that should work - like this ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74813



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


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

2020-04-15 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 257617.
ASDenysPetrov edited the summary of this revision.
ASDenysPetrov added a comment.
Herald added a subscriber: mgorny.

Improved Negate function in terms of handling `[MIN,A]U[B,MAX] => 
[MIN,-B]U[-A,MAX]` (previously was `[MIN,MIN]U[MIN+1,-B]U[-A,MAX]`).
Added unit test for Negate function.


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

https://reviews.llvm.org/D77802

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

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -0,0 +1,138 @@
+//===- unittests/StaticAnalyzer/RangeSetTest.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ento {
+namespace {
+
+// TestCase contains to lists of ranges
+// original one, has to be negated
+// expected one, has to be compared to negated original range
+template  struct TestCase {
+  RangeSet original;
+  RangeSet expected;
+
+  TestCase(BasicValueFactory &BVF, RangeSet::Factory &F,
+   const std::initializer_list &originalList,
+   const std::initializer_list &expectedList)
+  : original(createRangeSetFromList(BVF, F, originalList)),
+expected(createRangeSetFromList(BVF, F, expectedList)) {}
+
+private:
+  RangeSet createRangeSetFromList(BasicValueFactory &BVF, RangeSet::Factory &F,
+  const std::initializer_list &rangeList) {
+llvm::APSInt from(sizeof(T) * 8, std::is_unsigned::value);
+llvm::APSInt to = from;
+RangeSet rangeSet = F.getEmptySet();
+for (auto it = rangeList.begin(); it != rangeList.end(); it += 2) {
+  from = *it;
+  to = *(it + 1);
+  rangeSet = rangeSet.addRange(
+  F, RangeSet(F, BVF.getValue(from), BVF.getValue(to)));
+}
+return rangeSet;
+  }
+};
+
+class RangeSetTest : public testing::Test {
+protected:
+  // init block
+  DiagnosticsEngine Diag{new DiagnosticIDs, new DiagnosticOptions};
+  FileSystemOptions FileSystemOpts;
+  FileManager FileMgr{FileSystemOpts};
+  SourceManager SM{Diag, FileMgr};
+  LangOptions LOpts;
+  IdentifierTable idents;
+  SelectorTable sels;
+  Builtin::Context builtins;
+  ASTContext context{LOpts, SM, idents, sels, builtins};
+  llvm::BumpPtrAllocator alloc;
+  BasicValueFactory BVF{context, alloc};
+  RangeSet::Factory F;
+  // end init block
+
+  template  void checkNegate() {
+using type = T;
+
+// use next values of the range {MIN, A, B, MID, C, D, MAX}
+
+// MID is a value in the middle of the range
+// which unary minus does not affect on
+// e.g. int8/int32(0), uint8(128), uint32(2147483648)
+
+constexpr type MIN = std::numeric_limits::min();
+constexpr type MAX = std::numeric_limits::max();
+constexpr type MID = std::is_signed::value
+ ? 0
+ : ~(static_cast(-1) / static_cast(2));
+constexpr type A = MID - static_cast(42 + 42);
+constexpr type B = MID - static_cast(42);
+constexpr type C = -B;
+constexpr type D = -A;
+
+static_assert(MIN < A && A < B && B < MID && MID < C && C < D && D < MAX,
+  "Values shall be in an ascending order");
+
+// left {[x, y], [x, y]} is what shall be negated
+// right {[x, y], [x, y]}  is what shall be compared to a negation result
+TestCase cases[] = {
+{BVF, F, {MIN, A}, {MIN, MIN, D, MAX}},
+{BVF, F, {MIN, C}, {MIN, MIN, B, MAX}},
+{BVF, F, {MIN, MID}, {MIN, MIN, MID, MAX}},
+{BVF, F, {MIN, MAX}, {MIN, MAX}},
+{BVF, F, {A, D}, {A, D}},
+{BVF, F, {A, B}, {C, D}},
+{BVF, F, {MIN, A, D, MAX}, {MIN, A, D, MAX}},
+{BVF, F, {MIN, B, MID, D}, {MIN, MIN, A, MID, C, MAX}},
+{BVF, F, {MIN, MID, C, D}, {MIN, MIN, A, B, MID, MAX}},
+{BVF, F, {MIN, MID, C, MAX}, {MIN, B, MID, MAX}},
+{BVF, F, {A, MID, D, MAX}, {MIN + 1, A, MID, D}},
+{BVF, F, {A, A}, {D, D}},
+{BVF, F, {MID, MID}, {MID, MID}},
+{BVF, F, {MAX, MAX}, {MIN + 1, MIN + 1}},
+};
+
+for (const auto &c : cases) {
+  // negate original and check with expected
+  RangeSet negatedFromOriginal = c.original.Negate(BVF, F);
+  

[PATCH] D78181: [clangd] Fix a crash for accessing a null field decl returned by findExplicitReferences.

2020-04-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:702
   continue;
+if (!D.getField())
+  continue;

thanks for fixing this !

But I suppose we should rather return a result with empty `TargetDecl` as this 
is what API promises:

`  /// For dependent and unresolved references, Targets can also be empty.`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78181



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


[PATCH] D78126: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics

2020-04-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked an inline comment as done.
Szelethus added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:153
+#undef CHECKER_DEPENDENCY
+#undef GET_CHECKER_DEPENDENCIES
+  }

balazske wrote:
> Probably too much of assert here (but it works)? (There is not a way to get 
> the dependency data "dynamically", like 
> //"Checker->isDependentOn(OtherChecker)"//?)
Wow, you're totally correct, I didn't even consider that. Indeed, this doesn't 
work with plugins (or checkers from unit tests), but it should be doable, since 
`CheckerManager` owns `CheckerRegistry` (D75360). This is kind of ironic, 
considering how much I tend to block patches based on this :^)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78126



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


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

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

Reorganize test code to overcome testing infrastructure limitations


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665

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

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

[PATCH] D78126: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics

2020-04-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked an inline comment as done.
Szelethus added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:153
+#undef CHECKER_DEPENDENCY
+#undef GET_CHECKER_DEPENDENCIES
+  }

Szelethus wrote:
> balazske wrote:
> > Probably too much of assert here (but it works)? (There is not a way to get 
> > the dependency data "dynamically", like 
> > //"Checker->isDependentOn(OtherChecker)"//?)
> Wow, you're totally correct, I didn't even consider that. Indeed, this 
> doesn't work with plugins (or checkers from unit tests), but it should be 
> doable, since `CheckerManager` owns `CheckerRegistry` (D75360). This is kind 
> of ironic, considering how much I tend to block patches based on this :^)
Oh, to actually answer your question. The checker dependency information is 
stored in `CheckerRegistry` in this small struct:
```lang=cpp
  struct CheckerInfo {
enum class StateFromCmdLine {
  // This checker wasn't explicitly enabled or disabled.
  State_Unspecified,
  // This checker was explicitly disabled.
  State_Disabled,
  // This checker was explicitly enabled.
  State_Enabled
};

InitializationFunction Initialize = nullptr;
ShouldRegisterFunction ShouldRegister = nullptr;
StringRef FullName;
StringRef Desc;
StringRef DocumentationUri;
CmdLineOptionList CmdLineOptions;
bool IsHidden = false;
StateFromCmdLine State = StateFromCmdLine::State_Unspecified;

ConstCheckerInfoList Dependencies;
//...
  };
```
So the nice solution should make this info a bit more visible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78126



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


[PATCH] D76594: [clang][AST] Support AST files larger than 512M

2020-04-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 257633.
DmitryPolukhin added a comment.

Split BitOffset in DeclOffset in high/low parts; rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76594

Files:
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp

Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2422,12 +2422,12 @@
   SourceLocation Loc = D->getLocation();
   unsigned Index = ID - FirstDeclID;
   if (DeclOffsets.size() == Index)
-DeclOffsets.push_back(DeclOffset(Loc, Offset));
+DeclOffsets.emplace_back(Loc, Offset);
   else if (DeclOffsets.size() < Index) {
 // FIXME: Can/should this happen?
 DeclOffsets.resize(Index+1);
 DeclOffsets[Index].setLocation(Loc);
-DeclOffsets[Index].BitOffset = Offset;
+DeclOffsets[Index].setBitOffset(Offset);
   } else {
 llvm_unreachable("declarations should be emitted in ID order");
   }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1893,6 +1893,7 @@
   // Write out the source location entry table. We skip the first
   // entry, which is always the same dummy entry.
   std::vector SLocEntryOffsets;
+  uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo();
   RecordData PreloadSLocs;
   SLocEntryOffsets.reserve(SourceMgr.local_sloc_entry_size() - 1);
   for (unsigned I = 1, N = SourceMgr.local_sloc_entry_size();
@@ -1903,7 +1904,9 @@
 assert(&SourceMgr.getSLocEntry(FID) == SLoc);
 
 // Record the offset of this source-location entry.
-SLocEntryOffsets.push_back(Stream.GetCurrentBitNo());
+uint64_t Offset = Stream.GetCurrentBitNo() - SLocEntryOffsetsBase;
+assert((Offset >> 32) == 0 && "SLocEntry offset too large");
+SLocEntryOffsets.push_back(Offset);
 
 // Figure out which record code to use.
 unsigned Code;
@@ -2011,12 +2014,14 @@
   Abbrev->Add(BitCodeAbbrevOp(SOURCE_LOCATION_OFFSETS));
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // # of slocs
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // total size
+  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32)); // base offset
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // offsets
   unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
   {
 RecordData::value_type Record[] = {
 SOURCE_LOCATION_OFFSETS, SLocEntryOffsets.size(),
-SourceMgr.getNextLocalOffset() - 1 /* skip dummy */};
+SourceMgr.getNextLocalOffset() - 1 /* skip dummy */,
+SLocEntryOffsetsBase};
 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
   bytes(SLocEntryOffsets));
   }
@@ -2093,9 +2098,11 @@
 /// Writes the block containing the serialized form of the
 /// preprocessor.
 void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
+  uint64_t MacroOffsetsBase = Stream.GetCurrentBitNo();
+
   PreprocessingRecord *PPRec = PP.getPreprocessingRecord();
   if (PPRec)
-WritePreprocessorDetail(*PPRec);
+WritePreprocessorDetail(*PPRec, MacroOffsetsBase);
 
   RecordData Record;
   RecordData ModuleMacroRecord;
@@ -2156,7 +2163,8 @@
   // identifier they belong to.
   for (const IdentifierInfo *Name : MacroIdentifiers) {
 MacroDirective *MD = PP.getLocalMacroDirectiveHistory(Name);
-auto StartOffset = Stream.GetCurrentBitNo();
+uint64_t StartOffset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
+assert((StartOffset >> 32) == 0 && "Macro identifiers offset too large");
 
 // Emit the macro directives in reverse source order.
 for (; MD; MD = MD->getPrevious()) {
@@ -2229,14 +2237,12 @@
 
 // Record the local offset of this macro.
 unsigned Index = ID - FirstMacroID;
-if (Index == MacroOffsets.size())
-  MacroOffsets.push_back(Stream.GetCurrentBitNo());
-else {
-  if (Index > MacroOffsets.size())
-MacroOffsets.resize(Index + 1);
+if (Index >= MacroOffsets.size())
+  MacroOffsets.resize(Index + 1);
 
-  MacroOffsets[Index] = Stream.GetCurrentBitNo();
-}
+uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
+assert((Offset >> 32) == 0 && "Macro offset too large");
+MacroOffsets[Index] = Offset;
 
 AddIdentifierRef(Name, Record);
 AddSourceLocation(MI->getDefinitionLoc(), Record);
@@ -2287,17 +2293,20 @@
   Abbrev->Add(BitCodeAbbrevOp(MACRO_OFFSET)

[PATCH] D76594: [clang][AST] Support AST files larger than 512M

2020-04-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 257632.
DmitryPolukhin added a comment.

Split BitOffset in DeclOffset in high/low parts; rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76594

Files:
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp

Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2422,12 +2422,12 @@
   SourceLocation Loc = D->getLocation();
   unsigned Index = ID - FirstDeclID;
   if (DeclOffsets.size() == Index)
-DeclOffsets.push_back(DeclOffset(Loc, Offset));
+DeclOffsets.emplace_back(Loc, Offset);
   else if (DeclOffsets.size() < Index) {
 // FIXME: Can/should this happen?
 DeclOffsets.resize(Index+1);
 DeclOffsets[Index].setLocation(Loc);
-DeclOffsets[Index].BitOffset = Offset;
+DeclOffsets[Index].setBitOffset(Offset);
   } else {
 llvm_unreachable("declarations should be emitted in ID order");
   }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1893,6 +1893,7 @@
   // Write out the source location entry table. We skip the first
   // entry, which is always the same dummy entry.
   std::vector SLocEntryOffsets;
+  uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo();
   RecordData PreloadSLocs;
   SLocEntryOffsets.reserve(SourceMgr.local_sloc_entry_size() - 1);
   for (unsigned I = 1, N = SourceMgr.local_sloc_entry_size();
@@ -1903,7 +1904,9 @@
 assert(&SourceMgr.getSLocEntry(FID) == SLoc);
 
 // Record the offset of this source-location entry.
-SLocEntryOffsets.push_back(Stream.GetCurrentBitNo());
+uint64_t Offset = Stream.GetCurrentBitNo() - SLocEntryOffsetsBase;
+assert((Offset >> 32) == 0 && "SLocEntry offset too large");
+SLocEntryOffsets.push_back(Offset);
 
 // Figure out which record code to use.
 unsigned Code;
@@ -2011,12 +2014,14 @@
   Abbrev->Add(BitCodeAbbrevOp(SOURCE_LOCATION_OFFSETS));
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // # of slocs
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // total size
+  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32)); // base offset
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // offsets
   unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
   {
 RecordData::value_type Record[] = {
 SOURCE_LOCATION_OFFSETS, SLocEntryOffsets.size(),
-SourceMgr.getNextLocalOffset() - 1 /* skip dummy */};
+SourceMgr.getNextLocalOffset() - 1 /* skip dummy */,
+SLocEntryOffsetsBase};
 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
   bytes(SLocEntryOffsets));
   }
@@ -2093,9 +2098,11 @@
 /// Writes the block containing the serialized form of the
 /// preprocessor.
 void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
+  uint64_t MacroOffsetsBase = Stream.GetCurrentBitNo();
+
   PreprocessingRecord *PPRec = PP.getPreprocessingRecord();
   if (PPRec)
-WritePreprocessorDetail(*PPRec);
+WritePreprocessorDetail(*PPRec, MacroOffsetsBase);
 
   RecordData Record;
   RecordData ModuleMacroRecord;
@@ -2156,7 +2163,8 @@
   // identifier they belong to.
   for (const IdentifierInfo *Name : MacroIdentifiers) {
 MacroDirective *MD = PP.getLocalMacroDirectiveHistory(Name);
-auto StartOffset = Stream.GetCurrentBitNo();
+uint64_t StartOffset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
+assert((StartOffset >> 32) == 0 && "Macro identifiers offset too large");
 
 // Emit the macro directives in reverse source order.
 for (; MD; MD = MD->getPrevious()) {
@@ -2229,14 +2237,12 @@
 
 // Record the local offset of this macro.
 unsigned Index = ID - FirstMacroID;
-if (Index == MacroOffsets.size())
-  MacroOffsets.push_back(Stream.GetCurrentBitNo());
-else {
-  if (Index > MacroOffsets.size())
-MacroOffsets.resize(Index + 1);
+if (Index >= MacroOffsets.size())
+  MacroOffsets.resize(Index + 1);
 
-  MacroOffsets[Index] = Stream.GetCurrentBitNo();
-}
+uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
+assert((Offset >> 32) == 0 && "Macro offset too large");
+MacroOffsets[Index] = Offset;
 
 AddIdentifierRef(Name, Record);
 AddSourceLocation(MI->getDefinitionLoc(), Record);
@@ -2287,17 +2293,20 @@
   Abbrev->Add(BitCodeAbbrevOp(MACRO_OFFSET)

[PATCH] D78085: [AST] Fix recovery-expr crash on invalid aligned attr.

2020-04-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 257638.
hokein marked an inline comment as done.
hokein added a comment.

Use isAlignmentErrorDependent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78085

Files:
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/SemaCXX/invalid-aligned-attr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -481,6 +481,7 @@
 
 void writeAccessors(raw_ostream &OS) const override {
   OS << "  bool is" << getUpperName() << "Dependent() const;\n";
+  OS << "  bool is" << getUpperName() << "ErrorDependent() const;\n";
 
   OS << "  unsigned get" << getUpperName() << "(ASTContext &Ctx) const;\n";
 
@@ -511,6 +512,15 @@
  << "Type->getType()->isDependentType();\n";
   OS << "}\n";
 
+  OS << "bool " << getAttrName() << "Attr::is" << getUpperName()
+ << "ErrorDependent() const {\n";
+  OS << "  if (is" << getLowerName() << "Expr)\n";
+  OS << "return " << getLowerName() << "Expr && " << getLowerName()
+ << "Expr->containsErrors();\n";
+  OS << "  return " << getLowerName()
+ << "Type->getType()->containsErrors();\n";
+  OS << "}\n";
+
   // FIXME: Do not do the calculation here
   // FIXME: Handle types correctly
   // A null pointer means maximum alignment
Index: clang/test/SemaCXX/invalid-aligned-attr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-aligned-attr.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -frecovery-ast -verify %s
+// RUN: %clang_cc1 -verify %s
+
+struct alignas(invalid()) Foo {}; // expected-error {{use of undeclared identifier}}
+
+constexpr int k = alignof(Foo);
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -97,4 +97,9 @@
 void test(int x) {
   foo.abc;
   foo->func(x);
-}
\ No newline at end of file
+}
+
+// CHECK: |-AlignedAttr {{.*}} alignas
+// CHECK-NEXT:| `-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:|   `-UnresolvedLookupExpr {{.*}} 'invalid'
+struct alignas(invalid()) Aligned {};
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3884,6 +3884,7 @@
   AlignedAttr *LastAlignedAttr = nullptr;
   unsigned Align = 0;
   for (auto *I : D->specific_attrs()) {
+// FIXME: we should bail out if I is error dependent.
 if (I->isAlignmentDependent())
   return;
 if (I->isAlignas())
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2431,6 +2431,7 @@
   AlignedAttr *OldStrictestAlignAttr = nullptr;
   unsigned OldAlign = 0;
   for (auto *I : Old->specific_attrs()) {
+// FIXME: we should bail out if I is error dependent.
 // FIXME: We have no way of representing inherited dependent alignments
 // in a case like:
 //   template struct alignas(A) X;
@@ -2454,6 +2455,7 @@
   AlignedAttr *NewAlignasAttr = nullptr;
   unsigned NewAlign = 0;
   for (auto *I : New->specific_attrs()) {
+// FIXME: we should bail out if I is error dependent.
 if (I->isAlignmentDependent())
   return false;
 
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -396,8 +396,10 @@
   const AttrVec &V = getAttrs();
   ASTContext &Ctx = getASTContext();
   specific_attr_iterator I(V.begin()), E(V.end());
-  for (; I != E; ++I)
-Align = std::max(Align, I->getAlignment(Ctx));
+  for (; I != E; ++I) {
+if (!I->isAlignmentErrorDependent())
+  Align = std::max(Align, I->getAlignment(Ctx));
+  }
   return Align;
 }
 
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -71,6 +71,7 @@
   if (!D)
 return Deps;
   for (const auto *I : D->specific_attrs()) {
+// FIXME: should we propagate the error bit?
 if (I->isAlignmentDependent())
   return Deps | ExprDependence::ValueInstantiation;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76594: [clang][AST] Support AST files larger than 512M

2020-04-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 257635.
DmitryPolukhin added a comment.

Fix nit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76594

Files:
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp

Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2422,12 +2422,12 @@
   SourceLocation Loc = D->getLocation();
   unsigned Index = ID - FirstDeclID;
   if (DeclOffsets.size() == Index)
-DeclOffsets.push_back(DeclOffset(Loc, Offset));
+DeclOffsets.emplace_back(Loc, Offset);
   else if (DeclOffsets.size() < Index) {
 // FIXME: Can/should this happen?
 DeclOffsets.resize(Index+1);
 DeclOffsets[Index].setLocation(Loc);
-DeclOffsets[Index].BitOffset = Offset;
+DeclOffsets[Index].setBitOffset(Offset);
   } else {
 llvm_unreachable("declarations should be emitted in ID order");
   }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1893,6 +1893,7 @@
   // Write out the source location entry table. We skip the first
   // entry, which is always the same dummy entry.
   std::vector SLocEntryOffsets;
+  uint64_t SLocEntryOffsetsBase = Stream.GetCurrentBitNo();
   RecordData PreloadSLocs;
   SLocEntryOffsets.reserve(SourceMgr.local_sloc_entry_size() - 1);
   for (unsigned I = 1, N = SourceMgr.local_sloc_entry_size();
@@ -1903,7 +1904,9 @@
 assert(&SourceMgr.getSLocEntry(FID) == SLoc);
 
 // Record the offset of this source-location entry.
-SLocEntryOffsets.push_back(Stream.GetCurrentBitNo());
+uint64_t Offset = Stream.GetCurrentBitNo() - SLocEntryOffsetsBase;
+assert((Offset >> 32) == 0 && "SLocEntry offset too large");
+SLocEntryOffsets.push_back(Offset);
 
 // Figure out which record code to use.
 unsigned Code;
@@ -2011,12 +2014,14 @@
   Abbrev->Add(BitCodeAbbrevOp(SOURCE_LOCATION_OFFSETS));
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // # of slocs
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // total size
+  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 32)); // base offset
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // offsets
   unsigned SLocOffsetsAbbrev = Stream.EmitAbbrev(std::move(Abbrev));
   {
 RecordData::value_type Record[] = {
 SOURCE_LOCATION_OFFSETS, SLocEntryOffsets.size(),
-SourceMgr.getNextLocalOffset() - 1 /* skip dummy */};
+SourceMgr.getNextLocalOffset() - 1 /* skip dummy */,
+SLocEntryOffsetsBase};
 Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
   bytes(SLocEntryOffsets));
   }
@@ -2093,9 +2098,11 @@
 /// Writes the block containing the serialized form of the
 /// preprocessor.
 void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
+  uint64_t MacroOffsetsBase = Stream.GetCurrentBitNo();
+
   PreprocessingRecord *PPRec = PP.getPreprocessingRecord();
   if (PPRec)
-WritePreprocessorDetail(*PPRec);
+WritePreprocessorDetail(*PPRec, MacroOffsetsBase);
 
   RecordData Record;
   RecordData ModuleMacroRecord;
@@ -2156,7 +2163,8 @@
   // identifier they belong to.
   for (const IdentifierInfo *Name : MacroIdentifiers) {
 MacroDirective *MD = PP.getLocalMacroDirectiveHistory(Name);
-auto StartOffset = Stream.GetCurrentBitNo();
+uint64_t StartOffset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
+assert((StartOffset >> 32) == 0 && "Macro identifiers offset too large");
 
 // Emit the macro directives in reverse source order.
 for (; MD; MD = MD->getPrevious()) {
@@ -2229,14 +2237,12 @@
 
 // Record the local offset of this macro.
 unsigned Index = ID - FirstMacroID;
-if (Index == MacroOffsets.size())
-  MacroOffsets.push_back(Stream.GetCurrentBitNo());
-else {
-  if (Index > MacroOffsets.size())
-MacroOffsets.resize(Index + 1);
+if (Index >= MacroOffsets.size())
+  MacroOffsets.resize(Index + 1);
 
-  MacroOffsets[Index] = Stream.GetCurrentBitNo();
-}
+uint64_t Offset = Stream.GetCurrentBitNo() - MacroOffsetsBase;
+assert((Offset >> 32) == 0 && "Macro offset too large");
+MacroOffsets[Index] = Offset;
 
 AddIdentifierRef(Name, Record);
 AddSourceLocation(MI->getDefinitionLoc(), Record);
@@ -2287,17 +2293,20 @@
   Abbrev->Add(BitCodeAbbrevOp(MACRO_OFFSET));
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevO

[PATCH] D76594: [clang][AST] Support AST files larger than 512M

2020-04-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin marked an inline comment as done.
DmitryPolukhin added a comment.

@sammccall thank you for review!
I'll wait for one more day for additional feedback if any, and land this diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76594



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


[PATCH] D75726: [ConstExprPreter] Updated constant interpreter documentation

2020-04-15 Thread Nandor Licker via Phabricator via cfe-commits
nand updated this revision to Diff 257637.
nand marked 2 inline comments as done.
nand added a comment.

fixed typos


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75726

Files:
  clang/docs/ConstantInterpreter.rst

Index: clang/docs/ConstantInterpreter.rst
===
--- clang/docs/ConstantInterpreter.rst
+++ clang/docs/ConstantInterpreter.rst
@@ -8,129 +8,256 @@
 Introduction
 
 
-The constexpr interpreter aims to replace the existing tree evaluator in clang, improving performance on constructs which are executed inefficiently by the evaluator. The interpreter is activated using the following flags:
+The constexpr interpreter aims to replace the existing tree evaluator in
+clang, improving performance on constructs which are executed inefficiently
+by the evaluator. The interpreter is activated using the following flags:
 
-* ``-fexperimental-new-constant-interpreter`` enables the interpreter, emitting an error if an unsupported feature is encountered
+* ``-fexperimental-new-constant-interpreter`` enables the interpreter,
+emitting an error if an unsupported feature is encountered
 
 Bytecode Compilation
 
 
-Bytecode compilation is handled in ``ByteCodeStmtGen.h`` for statements and ``ByteCodeExprGen.h`` for expressions. The compiler has two different backends: one to generate bytecode for functions (``ByteCodeEmitter``) and one to directly evaluate expressions as they are compiled, without generating bytecode (``EvalEmitter``). All functions are compiled to bytecode, while toplevel expressions used in constant contexts are directly evaluated since the bytecode would never be reused. This mechanism aims to pave the way towards replacing the evaluator, improving its performance on functions and loops, while being just as fast on single-use toplevel expressions.
-
-The interpreter relies on stack-based, strongly-typed opcodes. The glue logic between the code generator, along with the enumeration and description of opcodes, can be found in ``Opcodes.td``. The opcodes are implemented as generic template methods in ``Interp.h`` and instantiated with the relevant primitive types by the interpreter loop or by the evaluating emitter.
+Bytecode compilation is handled in ``ByteCodeStmtGen.h`` for statements
+and ``ByteCodeExprGen.h`` for expressions. The compiler has two different
+backends: one to generate bytecode for functions (``ByteCodeEmitter``) and
+one to directly evaluate expressions as they are compiled, without
+generating bytecode (``EvalEmitter``). All functions are compiled to
+bytecode, while toplevel expressions used in constant contexts are directly
+evaluated since the bytecode would never be reused. This mechanism aims to
+pave the way towards replacing the evaluator, improving its performance on
+functions and loops, while being just as fast on single-use toplevel
+expressions.
+
+The interpreter relies on stack-based, strongly-typed opcodes. The glue
+logic between the code generator, along with the enumeration and
+description of opcodes, can be found in ``Opcodes.td``. The opcodes are
+implemented as generic template methods in ``Interp.h`` and instantiated
+with the relevant primitive types by the interpreter loop or by the
+evaluating emitter.
 
 Primitive Types
 ---
 
 * ``PT_{U|S}int{8|16|32|64}``
 
-  Signed or unsigned integers of a specific bit width, implemented using the ```Integral``` type.
+  Signed or unsigned integers of a specific bit width, implemented using
+  the ```Integral``` type.
 
 * ``PT_{U|S}intFP``
 
-  Signed or unsigned integers of an arbitrary, but fixed width used to implement
-  integral types which are required by the target, but are not supported by the host.
-  Under the hood, they rely on APValue. The ``Integral`` specialisation for these
-  types is required by opcodes to share an implementation with fixed integrals.
+  Signed or unsigned integers of an arbitrary, but fixed width used to
+  implement integral types which are required by the target, but are not
+  supported by the host. Under the hood, they rely on APValue. The
+  ``Integral`` specialisation for these types is required by opcodes to
+  share an implementation with fixed integrals.
 
 * ``PT_Bool``
 
-  Representation for boolean types, essentially a 1-bit unsigned ``Integral``.
+  Representation for boolean types, essentially a 1-bit unsigned
+  ``Integral``.
 
 * ``PT_RealFP``
 
-  Arbitrary, but fixed precision floating point numbers. Could be specialised in
-  the future similarly to integers in order to improve floating point performance.
+  Arbitrary, but fixed precision floating point numbers. Could be
+  specialised in the future similarly to integers in order to improve
+  floating point performance.
 
 * ``PT_Ptr``
 
-  Pointer type, defined in ``"Pointer.h"``.
+  Pointer type, defined in ``"Pointe

[PATCH] D78085: [AST] Fix recovery-expr crash on invalid aligned attr.

2020-04-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/AST/DeclBase.cpp:400
+  for (; I != E; ++I) {
+if (!I->isAlignmentDependent())
+  Align = std::max(Align, I->getAlignment(Ctx));

sammccall wrote:
> This doesn't seem great - previously if e.g. codegen ends up needing the 
> alignment of a dependent decl somehow, then an assert will catch that 
> programming error.
> Now it'll be silently swallowed. Seems better to check 
> isAlignmentErrorDependent() here (you'd need to add that function) and 
> continue to assert in other dependent cases.
ah, right. I think we should probably fix other similar places (where I added 
FIXMEs). We don't have problems at the moment -- because the recovery-expr is 
dependent, and they have been bailed out by isAlignmentDependent(). If we start 
capture the concrete type for recovery-expr, the `isAlignmentDependent` bailout 
will fail.


The `isAlignmentDependent` seems a bit confusing now, what does the `dependent` 
mean? if we generalize it, it could mean the attr depends on a template 
parameter (type, value, instantiation) or an error, in this sense 
`isAlignmentDependent` should cover the error-dependent case. I think here it 
only indicates the type-, value-, instantiation- dependent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78085



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


[PATCH] D78085: [AST] Fix recovery-expr crash on invalid aligned attr.

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



Comment at: clang/lib/AST/ComputeDependence.cpp:74
   for (const auto *I : D->specific_attrs()) {
+// FIXME: should we propagate the error bit?
 if (I->isAlignmentDependent())

maybe just do this unless it causes regressions?



Comment at: clang/lib/Sema/SemaDecl.cpp:2434
   for (auto *I : Old->specific_attrs()) {
+// FIXME: we should bail out if I is error dependent.
 // FIXME: We have no way of representing inherited dependent alignments

I actually don't think we should add this FIXME.
Currently error dependence implies dependence. If we break this invariant, 
there are going to be hundreds of places that check for dependence and need to 
be updated. We haven't annotated them all with fixmes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78085



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


[PATCH] D78085: [AST] Fix recovery-expr crash on invalid aligned attr.

2020-04-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

LG with comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78085



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


[PATCH] D78189: [analyzer] StdLibraryFunctionsChecker: Add statistics

2020-04-15 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: NoQ, Szelethus, balazske, steakhal.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, gamesh411, 
dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware, xazax.hun, whisperity.
Herald added a project: clang.
martong added a parent revision: D77641: [analyzer] StdLibraryFunctionsChecker: 
Associate summaries to FunctionDecls.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78189

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


Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -56,11 +56,22 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
+#include "llvm/ADT/Statistic.h"
 
 using namespace clang;
 using namespace clang::ento;
 
 namespace {
+
+#define DEBUG_TYPE "StdLibraryFunctionsChecker"
+STATISTIC(NumCall, "The # of calls handled by the checker");
+STATISTIC(NumFoundSummary, "The # of calls with associated summary");
+STATISTIC(NumArgConstraintViolated,
+  "The # of calls where an arg constraint is violated");
+STATISTIC(NumArgConstrained,
+  "The # of calls with applied argumentum constraints");
+STATISTIC(NumCaseApplied, "The # of calls with applied cases");
+
 class StdLibraryFunctionsChecker
 : public Checker {
   /// Below is a series of typedefs necessary to define function specs.
@@ -437,9 +448,11 @@
 
 void StdLibraryFunctionsChecker::checkPreCall(const CallEvent &Call,
   CheckerContext &C) const {
+  ++NumCall;
   Optional FoundSummary = findFunctionSummary(Call, C);
   if (!FoundSummary)
 return;
+  ++NumFoundSummary;
 
   const Summary &Summary = *FoundSummary;
   ProgramStateRef State = C.getState();
@@ -450,6 +463,7 @@
 ProgramStateRef FailureSt = VC->negate()->apply(NewState, Call, Summary);
 // The argument constraint is not satisfied.
 if (FailureSt && !SuccessSt) {
+  ++NumArgConstraintViolated;
   if (ExplodedNode *N = C.generateErrorNode(NewState))
 reportBug(Call, N, C);
   break;
@@ -462,8 +476,10 @@
   NewState = SuccessSt;
 }
   }
-  if (NewState && NewState != State)
+  if (NewState && NewState != State) {
+++NumArgConstrained;
 C.addTransition(NewState);
+  }
 }
 
 void StdLibraryFunctionsChecker::checkPostCall(const CallEvent &Call,
@@ -485,8 +501,10 @@
 break;
 }
 
-if (NewState && NewState != State)
+if (NewState && NewState != State) {
+  ++NumCaseApplied;
   C.addTransition(NewState);
+}
   }
 }
 


Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -56,11 +56,22 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
+#include "llvm/ADT/Statistic.h"
 
 using namespace clang;
 using namespace clang::ento;
 
 namespace {
+
+#define DEBUG_TYPE "StdLibraryFunctionsChecker"
+STATISTIC(NumCall, "The # of calls handled by the checker");
+STATISTIC(NumFoundSummary, "The # of calls with associated summary");
+STATISTIC(NumArgConstraintViolated,
+  "The # of calls where an arg constraint is violated");
+STATISTIC(NumArgConstrained,
+  "The # of calls with applied argumentum constraints");
+STATISTIC(NumCaseApplied, "The # of calls with applied cases");
+
 class StdLibraryFunctionsChecker
 : public Checker {
   /// Below is a series of typedefs necessary to define function specs.
@@ -437,9 +448,11 @@
 
 void StdLibraryFunctionsChecker::checkPreCall(const CallEvent &Call,
   CheckerContext &C) const {
+  ++NumCall;
   Optional FoundSummary = findFunctionSummary(Call, C);
   if (!FoundSummary)
 return;
+  ++NumFoundSummary;
 
   const Summary &Summary = *FoundSummary;
   ProgramStateRef State = C.getState();
@@ -450,6 +463,7 @@
 ProgramStateRef FailureSt = VC->negate()->apply(NewState, Call, Summary);
 // The argument constraint is not satisfied.
 if (FailureSt && !SuccessSt) {
+  ++NumArgConstraintViolated;
   if (ExplodedNode *N = C.generateErrorNode(NewState))
 reportBug(Call, N, C);
   break;
@@ -462,8 +476,10 @@
   NewState = SuccessSt;
 }
   }
-  if (NewState && NewState != State)
+  if (NewState && NewState != State) {
+++NumArg

[clang] b3387d1 - [ConstExprPreter] Updated constant interpreter documentation

2020-04-15 Thread Nandor Licker via cfe-commits

Author: Nandor Licker
Date: 2020-04-15T11:25:23+01:00
New Revision: b3387d1c30ae7da28b34378fb5d9bc29a213e991

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

LOG: [ConstExprPreter] Updated constant interpreter documentation

Summary:
Updated the documentation to better reflect features implemented on the
constexpr branch at https://github.com/nandor/llvm-project and extended
the TODO list with known missing features

Reviewers: rsmith, Bigcheese, dexonsmith, jfb

Subscribers: lebedev.ri, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/docs/ConstantInterpreter.rst

Removed: 




diff  --git a/clang/docs/ConstantInterpreter.rst 
b/clang/docs/ConstantInterpreter.rst
index a86161c8fa01..67a17c75607e 100644
--- a/clang/docs/ConstantInterpreter.rst
+++ b/clang/docs/ConstantInterpreter.rst
@@ -8,129 +8,256 @@ Constant Interpreter
 Introduction
 
 
-The constexpr interpreter aims to replace the existing tree evaluator in 
clang, improving performance on constructs which are executed inefficiently by 
the evaluator. The interpreter is activated using the following flags:
+The constexpr interpreter aims to replace the existing tree evaluator in
+clang, improving performance on constructs which are executed inefficiently
+by the evaluator. The interpreter is activated using the following flags:
 
-* ``-fexperimental-new-constant-interpreter`` enables the interpreter, 
emitting an error if an unsupported feature is encountered
+* ``-fexperimental-new-constant-interpreter`` enables the interpreter,
+emitting an error if an unsupported feature is encountered
 
 Bytecode Compilation
 
 
-Bytecode compilation is handled in ``ByteCodeStmtGen.h`` for statements and 
``ByteCodeExprGen.h`` for expressions. The compiler has two 
diff erent backends: one to generate bytecode for functions 
(``ByteCodeEmitter``) and one to directly evaluate expressions as they are 
compiled, without generating bytecode (``EvalEmitter``). All functions are 
compiled to bytecode, while toplevel expressions used in constant contexts are 
directly evaluated since the bytecode would never be reused. This mechanism 
aims to pave the way towards replacing the evaluator, improving its performance 
on functions and loops, while being just as fast on single-use toplevel 
expressions.
-
-The interpreter relies on stack-based, strongly-typed opcodes. The glue logic 
between the code generator, along with the enumeration and description of 
opcodes, can be found in ``Opcodes.td``. The opcodes are implemented as generic 
template methods in ``Interp.h`` and instantiated with the relevant primitive 
types by the interpreter loop or by the evaluating emitter.
+Bytecode compilation is handled in ``ByteCodeStmtGen.h`` for statements
+and ``ByteCodeExprGen.h`` for expressions. The compiler has two 
diff erent
+backends: one to generate bytecode for functions (``ByteCodeEmitter``) and
+one to directly evaluate expressions as they are compiled, without
+generating bytecode (``EvalEmitter``). All functions are compiled to
+bytecode, while toplevel expressions used in constant contexts are directly
+evaluated since the bytecode would never be reused. This mechanism aims to
+pave the way towards replacing the evaluator, improving its performance on
+functions and loops, while being just as fast on single-use toplevel
+expressions.
+
+The interpreter relies on stack-based, strongly-typed opcodes. The glue
+logic between the code generator, along with the enumeration and
+description of opcodes, can be found in ``Opcodes.td``. The opcodes are
+implemented as generic template methods in ``Interp.h`` and instantiated
+with the relevant primitive types by the interpreter loop or by the
+evaluating emitter.
 
 Primitive Types
 ---
 
 * ``PT_{U|S}int{8|16|32|64}``
 
-  Signed or unsigned integers of a specific bit width, implemented using the 
```Integral``` type.
+  Signed or unsigned integers of a specific bit width, implemented using
+  the ```Integral``` type.
 
 * ``PT_{U|S}intFP``
 
-  Signed or unsigned integers of an arbitrary, but fixed width used to 
implement
-  integral types which are required by the target, but are not supported by 
the host.
-  Under the hood, they rely on APValue. The ``Integral`` specialisation for 
these
-  types is required by opcodes to share an implementation with fixed integrals.
+  Signed or unsigned integers of an arbitrary, but fixed width used to
+  implement integral types which are required by the target, but are not
+  supported by the host. Under the hood, they rely on APValue. The
+  ``Integral`` specialisation for these types is required by opcodes to
+  share an implementation with fixed integ

[PATCH] D76929: [AArch64][SVE] Add SVE intrinsic for LD1RQ

2020-04-15 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 257657.
kmclaughlin marked an inline comment as done.
kmclaughlin added a comment.

Ensure LoadChain is always preserved in performLD1RQCombine


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

https://reviews.llvm.org/D76929

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

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-loads.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-loads.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-loads.ll
@@ -1,6 +1,179 @@
 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
 
 ;
+; LD1RQB
+;
+
+define  @ld1rqb_i8( %pred, i8* %addr) {
+; CHECK-LABEL: ld1rqb_i8:
+; CHECK: ld1rqb { z0.b }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv16i8( %pred, i8* %addr)
+  ret  %res
+}
+
+define  @ld1rqb_i8_imm( %pred, i8* %addr) {
+; CHECK-LABEL: ld1rqb_i8_imm:
+; CHECK: ld1rqb { z0.b }, p0/z, [x0, #16]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i8, i8* %addr, i8 16
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv16i8( %pred, i8* %ptr)
+  ret  %res
+}
+
+define  @ld1rqb_i8_imm_lower_bound( %pred, i8* %addr) {
+; CHECK-LABEL: ld1rqb_i8_imm_lower_bound:
+; CHECK: ld1rqb { z0.b }, p0/z, [x0, #-128]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i8, i8* %addr, i8 -128
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv16i8( %pred, i8* %ptr)
+  ret  %res
+}
+
+define  @ld1rqb_i8_imm_upper_bound( %pred, i8* %addr) {
+; CHECK-LABEL: ld1rqb_i8_imm_upper_bound:
+; CHECK: ld1rqb { z0.b }, p0/z, [x0, #112]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i8, i8* %addr, i8 112
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv16i8( %pred, i8* %ptr)
+  ret  %res
+}
+
+define  @ld1rqb_i8_imm_out_of_lower_bound( %pred, i8* %addr) {
+; CHECK-LABEL: ld1rqb_i8_imm_out_of_lower_bound:
+; CHECK: sub x8, x0, #129
+; CHECK-NEXT: ld1rqb { z0.b }, p0/z, [x8]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i8, i8* %addr, i64 -129
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv16i8( %pred, i8* %ptr)
+  ret  %res
+}
+
+define  @ld1rqb_i8_imm_out_of_upper_bound( %pred, i8* %addr) {
+; CHECK-LABEL: ld1rqb_i8_imm_out_of_upper_bound:
+; CHECK: add x8, x0, #113
+; CHECK-NEXT: ld1rqb { z0.b }, p0/z, [x8]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i8, i8* %addr, i64 113
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv16i8( %pred, i8* %ptr)
+  ret  %res
+}
+
+;
+; LD1RQH
+;
+
+define  @ld1rqh_i16( %pred, i16* %addr) {
+; CHECK-LABEL: ld1rqh_i16:
+; CHECK: ld1rqh { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv8i16( %pred, i16* %addr)
+  ret  %res
+}
+
+define  @ld1rqh_f16( %pred, half* %addr) {
+; CHECK-LABEL: ld1rqh_f16:
+; CHECK: ld1rqh { z0.h }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv8f16( %pred, half* %addr)
+  ret  %res
+}
+
+define  @ld1rqh_i16_imm( %pred, i16* %addr) {
+; CHECK-LABEL: ld1rqh_i16_imm:
+; CHECK: ld1rqh { z0.h }, p0/z, [x0, #-64]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i16, i16* %addr, i16 -32
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv8i16( %pred, i16* %ptr)
+  ret  %res
+}
+
+define  @ld1rqh_f16_imm( %pred, half* %addr) {
+; CHECK-LABEL: ld1rqh_f16_imm:
+; CHECK: ld1rqh { z0.h }, p0/z, [x0, #-16]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds half, half* %addr, i16 -8
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv8f16( %pred, half* %ptr)
+  ret  %res
+}
+
+;
+; LD1RQW
+;
+
+define  @ld1rqw_i32( %pred, i32* %addr) {
+; CHECK-LABEL: ld1rqw_i32:
+; CHECK: ld1rqw { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv4i32( %pred, i32* %addr)
+  ret  %res
+}
+
+define  @ld1rqw_f32( %pred, float* %addr) {
+; CHECK-LABEL: ld1rqw_f32:
+; CHECK: ld1rqw { z0.s }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv4f32( %pred, float* %addr)
+  ret  %res
+}
+
+define  @ld1rqw_i32_imm( %pred, i32* %addr) {
+; CHECK-LABEL: ld1rqw_i32_imm:
+; CHECK: ld1rqw { z0.s }, p0/z, [x0, #112]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds i32, i32* %addr, i32 28
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv4i32( %pred, i32* %ptr)
+  ret  %res
+}
+
+define  @ld1rqw_f32_imm( %pred, float* %addr) {
+; CHECK-LABEL: ld1rqw_f32_imm:
+; CHECK: ld1rqw { z0.s }, p0/z, [x0, #32]
+; CHECK-NEXT: ret
+  %ptr = getelementptr inbounds float, float* %addr, i32 8
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv4f32( %pred, float* %ptr)
+  ret  %res
+}
+
+;
+; LD1RQD
+;
+
+define  @ld1rqd_i64( %pred, i64* %addr) {
+; CHECK-LABEL: ld1rqd_i64:
+; CHECK: ld1rqd { z0.d }, p0/z, [x0]
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.ld1rq.nxv2i64( %pred, i64* %addr)
+  ret  %res
+}
+
+define  @ld1r

[PATCH] D77794: [clangd] Pull installed gRPC and introduce clangd-remote-(server|client)

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

Address the current round of comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77794

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/README.md
  clang-tools-extra/clangd/index/remote/client/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/client/Client.cpp
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- /dev/null
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -0,0 +1,49 @@
+# FIXME(kirillbobyrev): Allow using system installed gRPC.
+if (GRPC_INSTALL_PATH)
+  set(protobuf_MODULE_COMPATIBLE TRUE)
+  find_package(Protobuf CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
+  message(STATUS "Using protobuf ${protobuf_VERSION}")
+  find_package(gRPC CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
+  message(STATUS "Using gRPC ${gRPC_VERSION}")
+
+  include_directories(${Protobuf_INCLUDE_DIRS})
+
+  # gRPC CMake CONFIG gives the libraries slightly odd names, make them match
+  # the conventional system-installed names.
+  set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE)
+  add_library(protobuf ALIAS protobuf::libprotobuf)
+  set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
+  add_library(grpc++ ALIAS gRPC::grpc++)
+
+  set(GRPC_CPP_PLUGIN $)
+  set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
+else()
+  get_filename_component(GRPC_CPP_PLUGIN grpc_cpp_plugin ABSOLUTE)
+  get_filename_component(PROTOC protoc ABSOLUTE)
+endif()
+
+# Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.
+# Libraries that use these headers should adjust the include path.
+# FIXME(kirillbobyrev): Allow optional generation of prptos only and give
+# callers control over it via additional parameters.
+function(generate_grpc_protos ProtoFile LibraryName)
+  get_filename_component(ProtoSourceAbsolutePath "${CMAKE_CURRENT_SOURCE_DIR}/${ProtoFile}" ABSOLUTE)
+  get_filename_component(ProtoSourcePath ${ProtoSourceAbsolutePath} PATH)
+
+  set(GeneratedProtoSource "${CMAKE_CURRENT_BINARY_DIR}/Index.pb.cc")
+  set(GeneratedProtoHeader "${CMAKE_CURRENT_BINARY_DIR}/Index.pb.h")
+  set(GeneratedGRPCSource "${CMAKE_CURRENT_BINARY_DIR}/Index.grpc.pb.cc")
+  set(GeneratedGRPCHeader "${CMAKE_CURRENT_BINARY_DIR}/Index.grpc.pb.h")
+  add_custom_command(
+OUTPUT "${GeneratedProtoSource}" "${GeneratedProtoHeader}" "${GeneratedGRPCSource}" "${GeneratedGRPCHeader}"
+COMMAND ${PROTOC}
+ARGS --grpc_out="${CMAKE_CURRENT_BINARY_DIR}"
+  --cpp_out="${CMAKE_CURRENT_BINARY_DIR}"
+  --proto_path="${ProtoSourcePath}"
+  --plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}"
+  "${ProtoSourceAbsolutePath}"
+  DEPENDS "${ProtoSourceAbsolutePath}")
+
+  add_library(${LibraryName} ${GeneratedProtoSource} ${GeneratedProtoHeader} ${GeneratedGRPCSource} ${GeneratedGRPCHeader})
+  target_link_libraries(${LibraryName} grpc++ protobuf)
+endfunction()
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -375,6 +375,15 @@
   set(LLVM_WITH_Z3 1)
 endif()
 
+# FIXME(kirillbobyrev): Document this in the LLVM docs.
+option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
+# FIXME(kirillbobyrev): Check if it works with optimized tablegen CMake option.
+set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library installation.")
+
+if (CLANGD_ENABLE_REMOTE)
+  include(FindGRPC)
+endif()
+
 if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
   set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
 endif()
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -0,0 +1,103 @@
+//===--- Server.cpp - gRPC-based Remote Index Server  -===//
+//
+// 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 "index/Index.h"
+#include "index/Serialization.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/LineEditor/LineEditor.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Sig

[PATCH] D77794: [clangd] Pull installed gRPC and introduce clangd-remote-(server|client)

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

Trim dexp output in remote index README.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77794

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/README.md
  clang-tools-extra/clangd/index/remote/client/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/client/Client.cpp
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- /dev/null
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -0,0 +1,49 @@
+# FIXME(kirillbobyrev): Allow using system installed gRPC.
+if (GRPC_INSTALL_PATH)
+  set(protobuf_MODULE_COMPATIBLE TRUE)
+  find_package(Protobuf CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
+  message(STATUS "Using protobuf ${protobuf_VERSION}")
+  find_package(gRPC CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
+  message(STATUS "Using gRPC ${gRPC_VERSION}")
+
+  include_directories(${Protobuf_INCLUDE_DIRS})
+
+  # gRPC CMake CONFIG gives the libraries slightly odd names, make them match
+  # the conventional system-installed names.
+  set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE)
+  add_library(protobuf ALIAS protobuf::libprotobuf)
+  set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
+  add_library(grpc++ ALIAS gRPC::grpc++)
+
+  set(GRPC_CPP_PLUGIN $)
+  set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
+else()
+  get_filename_component(GRPC_CPP_PLUGIN grpc_cpp_plugin ABSOLUTE)
+  get_filename_component(PROTOC protoc ABSOLUTE)
+endif()
+
+# Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.
+# Libraries that use these headers should adjust the include path.
+# FIXME(kirillbobyrev): Allow optional generation of prptos only and give
+# callers control over it via additional parameters.
+function(generate_grpc_protos ProtoFile LibraryName)
+  get_filename_component(ProtoSourceAbsolutePath "${CMAKE_CURRENT_SOURCE_DIR}/${ProtoFile}" ABSOLUTE)
+  get_filename_component(ProtoSourcePath ${ProtoSourceAbsolutePath} PATH)
+
+  set(GeneratedProtoSource "${CMAKE_CURRENT_BINARY_DIR}/Index.pb.cc")
+  set(GeneratedProtoHeader "${CMAKE_CURRENT_BINARY_DIR}/Index.pb.h")
+  set(GeneratedGRPCSource "${CMAKE_CURRENT_BINARY_DIR}/Index.grpc.pb.cc")
+  set(GeneratedGRPCHeader "${CMAKE_CURRENT_BINARY_DIR}/Index.grpc.pb.h")
+  add_custom_command(
+OUTPUT "${GeneratedProtoSource}" "${GeneratedProtoHeader}" "${GeneratedGRPCSource}" "${GeneratedGRPCHeader}"
+COMMAND ${PROTOC}
+ARGS --grpc_out="${CMAKE_CURRENT_BINARY_DIR}"
+  --cpp_out="${CMAKE_CURRENT_BINARY_DIR}"
+  --proto_path="${ProtoSourcePath}"
+  --plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}"
+  "${ProtoSourceAbsolutePath}"
+  DEPENDS "${ProtoSourceAbsolutePath}")
+
+  add_library(${LibraryName} ${GeneratedProtoSource} ${GeneratedProtoHeader} ${GeneratedGRPCSource} ${GeneratedGRPCHeader})
+  target_link_libraries(${LibraryName} grpc++ protobuf)
+endfunction()
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -375,6 +375,15 @@
   set(LLVM_WITH_Z3 1)
 endif()
 
+# FIXME(kirillbobyrev): Document this in the LLVM docs.
+option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
+# FIXME(kirillbobyrev): Check if it works with optimized tablegen CMake option.
+set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library installation.")
+
+if (CLANGD_ENABLE_REMOTE)
+  include(FindGRPC)
+endif()
+
 if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
   set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
 endif()
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -0,0 +1,103 @@
+//===--- Server.cpp - gRPC-based Remote Index Server  -===//
+//
+// 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 "index/Index.h"
+#include "index/Serialization.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/LineEditor/LineEditor.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Signals.h"
+
+#include "grpcpp/grpcpp.h"
+#in

[PATCH] D77794: [clangd] Pull installed gRPC and introduce clangd-remote-(server|client)

2020-04-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev marked an inline comment as done.
kbobyrev added inline comments.



Comment at: clang-tools-extra/clangd/CMakeLists.txt:194
+
+  add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)
+  include_directories(${Protobuf_INCLUDE_DIRS})

sammccall wrote:
> these global side-effects are pretty scary, can we limit them somehow?
I'll be using `target_compile_definitions()` manually then. Not sure if it's 
much better (since users would have to manually add those defines), maybe if 
there are more protos in the future it'd be better to add function for setting 
up the target which will be linked against generated protobufs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77794



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


[PATCH] D75726: [ConstExprPreter] Updated constant interpreter documentation

2020-04-15 Thread Nandor Licker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb3387d1c30ae: [ConstExprPreter] Updated constant interpreter 
documentation (authored by nand).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75726

Files:
  clang/docs/ConstantInterpreter.rst

Index: clang/docs/ConstantInterpreter.rst
===
--- clang/docs/ConstantInterpreter.rst
+++ clang/docs/ConstantInterpreter.rst
@@ -8,129 +8,256 @@
 Introduction
 
 
-The constexpr interpreter aims to replace the existing tree evaluator in clang, improving performance on constructs which are executed inefficiently by the evaluator. The interpreter is activated using the following flags:
+The constexpr interpreter aims to replace the existing tree evaluator in
+clang, improving performance on constructs which are executed inefficiently
+by the evaluator. The interpreter is activated using the following flags:
 
-* ``-fexperimental-new-constant-interpreter`` enables the interpreter, emitting an error if an unsupported feature is encountered
+* ``-fexperimental-new-constant-interpreter`` enables the interpreter,
+emitting an error if an unsupported feature is encountered
 
 Bytecode Compilation
 
 
-Bytecode compilation is handled in ``ByteCodeStmtGen.h`` for statements and ``ByteCodeExprGen.h`` for expressions. The compiler has two different backends: one to generate bytecode for functions (``ByteCodeEmitter``) and one to directly evaluate expressions as they are compiled, without generating bytecode (``EvalEmitter``). All functions are compiled to bytecode, while toplevel expressions used in constant contexts are directly evaluated since the bytecode would never be reused. This mechanism aims to pave the way towards replacing the evaluator, improving its performance on functions and loops, while being just as fast on single-use toplevel expressions.
-
-The interpreter relies on stack-based, strongly-typed opcodes. The glue logic between the code generator, along with the enumeration and description of opcodes, can be found in ``Opcodes.td``. The opcodes are implemented as generic template methods in ``Interp.h`` and instantiated with the relevant primitive types by the interpreter loop or by the evaluating emitter.
+Bytecode compilation is handled in ``ByteCodeStmtGen.h`` for statements
+and ``ByteCodeExprGen.h`` for expressions. The compiler has two different
+backends: one to generate bytecode for functions (``ByteCodeEmitter``) and
+one to directly evaluate expressions as they are compiled, without
+generating bytecode (``EvalEmitter``). All functions are compiled to
+bytecode, while toplevel expressions used in constant contexts are directly
+evaluated since the bytecode would never be reused. This mechanism aims to
+pave the way towards replacing the evaluator, improving its performance on
+functions and loops, while being just as fast on single-use toplevel
+expressions.
+
+The interpreter relies on stack-based, strongly-typed opcodes. The glue
+logic between the code generator, along with the enumeration and
+description of opcodes, can be found in ``Opcodes.td``. The opcodes are
+implemented as generic template methods in ``Interp.h`` and instantiated
+with the relevant primitive types by the interpreter loop or by the
+evaluating emitter.
 
 Primitive Types
 ---
 
 * ``PT_{U|S}int{8|16|32|64}``
 
-  Signed or unsigned integers of a specific bit width, implemented using the ```Integral``` type.
+  Signed or unsigned integers of a specific bit width, implemented using
+  the ```Integral``` type.
 
 * ``PT_{U|S}intFP``
 
-  Signed or unsigned integers of an arbitrary, but fixed width used to implement
-  integral types which are required by the target, but are not supported by the host.
-  Under the hood, they rely on APValue. The ``Integral`` specialisation for these
-  types is required by opcodes to share an implementation with fixed integrals.
+  Signed or unsigned integers of an arbitrary, but fixed width used to
+  implement integral types which are required by the target, but are not
+  supported by the host. Under the hood, they rely on APValue. The
+  ``Integral`` specialisation for these types is required by opcodes to
+  share an implementation with fixed integrals.
 
 * ``PT_Bool``
 
-  Representation for boolean types, essentially a 1-bit unsigned ``Integral``.
+  Representation for boolean types, essentially a 1-bit unsigned
+  ``Integral``.
 
 * ``PT_RealFP``
 
-  Arbitrary, but fixed precision floating point numbers. Could be specialised in
-  the future similarly to integers in order to improve floating point performance.
+  Arbitrary, but fixed precision floating point numbers. Could be
+  specialised in the future similarly to integers in order to improve
+  floating point performance.
 
 * ``PT_Ptr``
 
-  Pointer 

[clang] 6f64dac - Upgrade calls to CreateShuffleVector to use the preferred form of passing an array of ints

2020-04-15 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-04-15T12:51:38+02:00
New Revision: 6f64daca8f3cbcf850ce7d502291017187e9fc08

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

LOG: Upgrade calls to CreateShuffleVector to use the preferred form of passing 
an array of ints

No functionality change intended.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprScalar.cpp
llvm/lib/CodeGen/InterleavedLoadCombinePass.cpp
llvm/lib/Target/X86/X86PartialReduction.cpp
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/lib/Transforms/Scalar/LowerMatrixIntrinsics.cpp
llvm/lib/Transforms/Scalar/SROA.cpp
llvm/lib/Transforms/Utils/LoopUtils.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 6e3a3dfe50bd..87f52102fff4 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5711,7 +5711,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   case NEON::BI__builtin_neon_vext_v:
   case NEON::BI__builtin_neon_vextq_v: {
 int CV = cast(Ops[2])->getSExtValue();
-SmallVector Indices;
+SmallVector Indices;
 for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i)
   Indices.push_back(i+CV);
 
@@ -5983,7 +5983,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
 Value *SV = nullptr;
 
 for (unsigned vi = 0; vi != 2; ++vi) {
-  SmallVector Indices;
+  SmallVector Indices;
   for (unsigned i = 0, e = VTy->getNumElements(); i != e; i += 2) {
 Indices.push_back(i+vi);
 Indices.push_back(i+e+vi);
@@ -6011,7 +6011,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
 Value *SV = nullptr;
 
 for (unsigned vi = 0; vi != 2; ++vi) {
-  SmallVector Indices;
+  SmallVector Indices;
   for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i)
 Indices.push_back(2*i+vi);
 
@@ -6029,7 +6029,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
 Value *SV = nullptr;
 
 for (unsigned vi = 0; vi != 2; ++vi) {
-  SmallVector Indices;
+  SmallVector Indices;
   for (unsigned i = 0, e = VTy->getNumElements(); i != e; i += 2) {
 Indices.push_back((i + vi*e) >> 1);
 Indices.push_back(((i + vi*e) >> 1)+e);
@@ -6120,7 +6120,7 @@ static Value *packTBLDVectorList(CodeGenFunction &CGF, 
ArrayRef Ops,
 TblOps.push_back(ExtOp);
 
   // Build a vector containing sequential number like (0, 1, 2, ..., 15)
-  SmallVector Indices;
+  SmallVector Indices;
   llvm::VectorType *TblTy = cast(Ops[0]->getType());
   for (unsigned i = 0, e = TblTy->getNumElements(); i != e; ++i) {
 Indices.push_back(2*i);
@@ -6957,7 +6957,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned 
BuiltinID,
 if (VTy->getElementType()->isIntegerTy(64)) {
   // Extract the other lane.
   Ops[1] = Builder.CreateBitCast(Ops[1], Ty);
-  uint32_t Lane = cast(Ops[2])->getZExtValue();
+  int Lane = cast(Ops[2])->getZExtValue();
   Value *SV = llvm::ConstantVector::get(ConstantInt::get(Int32Ty, 1-Lane));
   Ops[1] = Builder.CreateShuffleVector(Ops[1], Ops[1], SV);
   // Load the value as a one-element vector.
@@ -6967,9 +6967,8 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned 
BuiltinID,
   Value *Align = getAlignmentValue32(PtrOp0);
   Value *Ld = Builder.CreateCall(F, {Ops[0], Align});
   // Combine them.
-  uint32_t Indices[] = {1 - Lane, Lane};
-  SV = llvm::ConstantDataVector::get(getLLVMContext(), Indices);
-  return Builder.CreateShuffleVector(Ops[1], Ld, SV, "vld1q_lane");
+  int Indices[] = {1 - Lane, Lane};
+  return Builder.CreateShuffleVector(Ops[1], Ld, Indices, "vld1q_lane");
 }
 LLVM_FALLTHROUGH;
   case NEON::BI__builtin_neon_vld1_lane_v: {
@@ -7144,7 +7143,7 @@ static llvm::Value *ARMMVEVectorReinterpret(CGBuilderTy 
&Builder,
 static llvm::Value *VectorUnzip(CGBuilderTy &Builder, llvm::Value *V, bool 
Odd) {
   // Make a shufflevector that extracts every other element of a vector (evens
   // or odds, as desired).
-  SmallVector Indices;
+  SmallVector Indices;
   unsigned InputElements =
   cast(V->getType())->getNumElements();
   for (unsigned i = 0; i < InputElements; i += 2)
@@ -7157,7 +7156,7 @@ static llvm::Value *VectorZip(CGBuilderTy &Builder, 
llvm::Value *V0,
   llvm::Value *V1) {
   // Make a shufflevector that interleaves two vectors element by el

[PATCH] D78098: [CGExprAgg] Fix infinite loop in `findPeephole`

2020-04-15 Thread Ehud Katz via Phabricator via cfe-commits
ekatz updated this revision to Diff 257665.
ekatz edited the summary of this revision.
ekatz added a comment.

Simplify function using IgnoreParenNoopCasts.


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

https://reviews.llvm.org/D78098

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/test/CodeGen/atomic-struct-bug.cpp


Index: clang/test/CodeGen/atomic-struct-bug.cpp
===
--- /dev/null
+++ clang/test/CodeGen/atomic-struct-bug.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// PR45476
+
+// This test used to get into an infinite loop,
+// which, in turn, caused clang to never finish execution.
+
+struct s3 {
+  char a, b, c;
+};
+
+_Atomic struct s3 a;
+
+extern "C" void foo() {
+  // CHECK-LABEL: @foo
+  // CHECK: store atomic i32
+
+  a = s3{1, 2, 3};
+}
+
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -677,17 +677,13 @@
 
 /// Attempt to look through various unimportant expressions to find a
 /// cast of the given kind.
-static Expr *findPeephole(Expr *op, CastKind kind) {
-  while (true) {
-op = op->IgnoreParens();
-if (CastExpr *castE = dyn_cast(op)) {
-  if (castE->getCastKind() == kind)
-return castE->getSubExpr();
-  if (castE->getCastKind() == CK_NoOp)
-continue;
-}
-return nullptr;
+static Expr *findPeephole(Expr *op, CastKind kind, const ASTContext &ctx) {
+  op = op->IgnoreParenNoopCasts(ctx);
+  if (auto castE = dyn_cast(op)) {
+if (castE->getCastKind() == kind)
+  return castE->getSubExpr();
   }
+  return nullptr;
 }
 
 void AggExprEmitter::VisitCastExpr(CastExpr *E) {
@@ -776,7 +772,8 @@
   (isToAtomic ? CK_AtomicToNonAtomic : CK_NonAtomicToAtomic);
 
 // These two cases are reverses of each other; try to peephole them.
-if (Expr *op = findPeephole(E->getSubExpr(), peepholeTarget)) {
+if (Expr *op =
+findPeephole(E->getSubExpr(), peepholeTarget, CGF.getContext())) {
   assert(CGF.getContext().hasSameUnqualifiedType(op->getType(),
  E->getType()) &&
"peephole significantly changed types?");


Index: clang/test/CodeGen/atomic-struct-bug.cpp
===
--- /dev/null
+++ clang/test/CodeGen/atomic-struct-bug.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
+// PR45476
+
+// This test used to get into an infinite loop,
+// which, in turn, caused clang to never finish execution.
+
+struct s3 {
+  char a, b, c;
+};
+
+_Atomic struct s3 a;
+
+extern "C" void foo() {
+  // CHECK-LABEL: @foo
+  // CHECK: store atomic i32
+
+  a = s3{1, 2, 3};
+}
+
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -677,17 +677,13 @@
 
 /// Attempt to look through various unimportant expressions to find a
 /// cast of the given kind.
-static Expr *findPeephole(Expr *op, CastKind kind) {
-  while (true) {
-op = op->IgnoreParens();
-if (CastExpr *castE = dyn_cast(op)) {
-  if (castE->getCastKind() == kind)
-return castE->getSubExpr();
-  if (castE->getCastKind() == CK_NoOp)
-continue;
-}
-return nullptr;
+static Expr *findPeephole(Expr *op, CastKind kind, const ASTContext &ctx) {
+  op = op->IgnoreParenNoopCasts(ctx);
+  if (auto castE = dyn_cast(op)) {
+if (castE->getCastKind() == kind)
+  return castE->getSubExpr();
   }
+  return nullptr;
 }
 
 void AggExprEmitter::VisitCastExpr(CastExpr *E) {
@@ -776,7 +772,8 @@
   (isToAtomic ? CK_AtomicToNonAtomic : CK_NonAtomicToAtomic);
 
 // These two cases are reverses of each other; try to peephole them.
-if (Expr *op = findPeephole(E->getSubExpr(), peepholeTarget)) {
+if (Expr *op =
+findPeephole(E->getSubExpr(), peepholeTarget, CGF.getContext())) {
   assert(CGF.getContext().hasSameUnqualifiedType(op->getType(),
  E->getType()) &&
"peephole significantly changed types?");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77148: [analyzer] ApiModeling: Add buffer size arg constraint with multiplier involved

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



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:229-234
 BufferSizeConstraint(ArgNo BufArgN, ArgNo SizeArgN)
 : ValueConstraint(BufArgN), SizeArgN(SizeArgN) {}
 
+BufferSizeConstraint(ArgNo BufArgN, ArgNo SizeArgN, ArgNo SizeMulArgN)
+: ValueConstraint(BufArgN), SizeArgN(SizeArgN),
+  SizeMultiplierArgN(SizeMulArgN) {}

I don't know, these constructors don't look overly talkative.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1041
+   EvalCallAsPure)
+   .ArgConstraint(BufferSize(0, 1, 2))}},
 };

So this is supposed to mean that the 1st argument has the size of the argument 
of 2nd argument times the 3rd argument? Unlike the other summaries, this feels 
a bit cryptic. Something like this might look better:
```lang=c++
.ArgConstraint(0, BufferSize(/*BufSize*/1, /*BufSizeMultiplier*/))
.ArgConstraint(BufferSize(/*Buffer*/0, /*BufSize*/1, /*BufSizeMultiplier*/2))
.ArgConstraint(0, BufferSizeMul(1, 2))
```
WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77148



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


[PATCH] D78098: [CGExprAgg] Fix infinite loop in `findPeephole`

2020-04-15 Thread Ehud Katz via Phabricator via cfe-commits
ekatz marked an inline comment as done.
ekatz added inline comments.



Comment at: clang/lib/CodeGen/CGExprAgg.cpp:688
+
+op = castE;
   }

rjmccall wrote:
> ekatz wrote:
> > rjmccall wrote:
> > > ekatz wrote:
> > > > rjmccall wrote:
> > > > > I liked the structure of the old code better, in case we want to look 
> > > > > through other kinds of expressions.  Please just add `op = 
> > > > > castE->getSubExpr()` before the `continue`.
> > > > I see your point. I'll change that.
> > > > Though I must say that the old structure is a little strange with the 
> > > > `return nullptr` in the end of the loop...
> > > Oh, you know, there's also an `IgnoreParenNoopCasts` that we could just 
> > > use instead of this loop if we're willing to ignore other possible 
> > > expressions we might want to look through.
> > I am not familiar enough with clang's code to make the decision to remove 
> > this function.
> > Personally I wanted to fix the bug, and I guess this function is here for a 
> > reason..?
> I don't think there's anything here really worth keeping.  Please keep the 
> function around but replace its body with something like:
> 
> ```
> op = op->IgnoreParenNoopCasts();
> if (auto castE = dyn_cast(op)) {
>   if (castE->getCastKind() == kind)
> return castE->getSubExpr();
> }
> return nullptr;
> ```
Sorry, I, kinda, misunderstood you suggestion before.
This is a really good implementation, but as you said, this function should, 
and I quote from its description, "look through various unimportant 
expressions". So I guess it is better to leave it this way (with the loop), as 
it is already in the base code. What do you say?


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

https://reviews.llvm.org/D78098



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


[PATCH] D78098: [CGExprAgg] Fix infinite loop in `findPeephole`

2020-04-15 Thread Ehud Katz via Phabricator via cfe-commits
ekatz marked an inline comment as done.
ekatz added inline comments.



Comment at: clang/lib/CodeGen/CGExprAgg.cpp:688
+
+op = castE;
   }

ekatz wrote:
> rjmccall wrote:
> > ekatz wrote:
> > > rjmccall wrote:
> > > > ekatz wrote:
> > > > > rjmccall wrote:
> > > > > > I liked the structure of the old code better, in case we want to 
> > > > > > look through other kinds of expressions.  Please just add `op = 
> > > > > > castE->getSubExpr()` before the `continue`.
> > > > > I see your point. I'll change that.
> > > > > Though I must say that the old structure is a little strange with the 
> > > > > `return nullptr` in the end of the loop...
> > > > Oh, you know, there's also an `IgnoreParenNoopCasts` that we could just 
> > > > use instead of this loop if we're willing to ignore other possible 
> > > > expressions we might want to look through.
> > > I am not familiar enough with clang's code to make the decision to remove 
> > > this function.
> > > Personally I wanted to fix the bug, and I guess this function is here for 
> > > a reason..?
> > I don't think there's anything here really worth keeping.  Please keep the 
> > function around but replace its body with something like:
> > 
> > ```
> > op = op->IgnoreParenNoopCasts();
> > if (auto castE = dyn_cast(op)) {
> >   if (castE->getCastKind() == kind)
> > return castE->getSubExpr();
> > }
> > return nullptr;
> > ```
> Sorry, I, kinda, misunderstood you suggestion before.
> This is a really good implementation, but as you said, this function should, 
> and I quote from its description, "look through various unimportant 
> expressions". So I guess it is better to leave it this way (with the loop), 
> as it is already in the base code. What do you say?
I'll counter myself. (COVID-19 + Kids = TOTAL Tiredness)
This still gives us the opportunity to add "various unimportant expressions". 
I'll change to the suggested implementation.
Thanks! :)


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

https://reviews.llvm.org/D78098



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


[PATCH] D77794: [clangd] Pull installed gRPC and introduce clangd-remote-(server|client)

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

Fix protobuf & grpc_cpp_plugin settings in system-installed libs scenario and
confirm that everything works as expected with -DLLVM_OPTIMIZED_TABLEGEN=On.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77794

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/README.md
  clang-tools-extra/clangd/index/remote/client/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/client/Client.cpp
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/Server.cpp
  llvm/CMakeLists.txt
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- /dev/null
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -0,0 +1,48 @@
+if (GRPC_INSTALL_PATH)
+  set(protobuf_MODULE_COMPATIBLE TRUE)
+  find_package(Protobuf CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
+  message(STATUS "Using protobuf ${protobuf_VERSION}")
+  find_package(gRPC CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
+  message(STATUS "Using gRPC ${gRPC_VERSION}")
+
+  include_directories(${Protobuf_INCLUDE_DIRS})
+
+  # gRPC CMake CONFIG gives the libraries slightly odd names, make them match
+  # the conventional system-installed names.
+  set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE)
+  add_library(protobuf ALIAS protobuf::libprotobuf)
+  set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE)
+  add_library(grpc++ ALIAS gRPC::grpc++)
+
+  set(GRPC_CPP_PLUGIN $)
+  set(PROTOC ${Protobuf_PROTOC_EXECUTABLE})
+else()
+  find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin)
+  find_program(PROTOC protoc)
+endif()
+
+# Proto headers are generated in ${CMAKE_CURRENT_BINARY_DIR}.
+# Libraries that use these headers should adjust the include path.
+# FIXME(kirillbobyrev): Allow optional generation of prptos only and give
+# callers control over it via additional parameters.
+function(generate_grpc_protos ProtoFile LibraryName)
+  get_filename_component(ProtoSourceAbsolutePath "${CMAKE_CURRENT_SOURCE_DIR}/${ProtoFile}" ABSOLUTE)
+  get_filename_component(ProtoSourcePath ${ProtoSourceAbsolutePath} PATH)
+
+  set(GeneratedProtoSource "${CMAKE_CURRENT_BINARY_DIR}/Index.pb.cc")
+  set(GeneratedProtoHeader "${CMAKE_CURRENT_BINARY_DIR}/Index.pb.h")
+  set(GeneratedGRPCSource "${CMAKE_CURRENT_BINARY_DIR}/Index.grpc.pb.cc")
+  set(GeneratedGRPCHeader "${CMAKE_CURRENT_BINARY_DIR}/Index.grpc.pb.h")
+  add_custom_command(
+OUTPUT "${GeneratedProtoSource}" "${GeneratedProtoHeader}" "${GeneratedGRPCSource}" "${GeneratedGRPCHeader}"
+COMMAND ${PROTOC}
+ARGS --grpc_out="${CMAKE_CURRENT_BINARY_DIR}"
+  --cpp_out="${CMAKE_CURRENT_BINARY_DIR}"
+  --proto_path="${ProtoSourcePath}"
+  --plugin=protoc-gen-grpc="${GRPC_CPP_PLUGIN}"
+  "${ProtoSourceAbsolutePath}"
+  DEPENDS "${ProtoSourceAbsolutePath}")
+
+  add_library(${LibraryName} ${GeneratedProtoSource} ${GeneratedProtoHeader} ${GeneratedGRPCSource} ${GeneratedGRPCHeader})
+  target_link_libraries(${LibraryName} grpc++ protobuf)
+endfunction()
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -375,6 +375,14 @@
   set(LLVM_WITH_Z3 1)
 endif()
 
+# FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
+option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
+set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
+
+if (CLANGD_ENABLE_REMOTE)
+  include(FindGRPC)
+endif()
+
 if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
   set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
 endif()
Index: clang-tools-extra/clangd/index/remote/server/Server.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/server/Server.cpp
@@ -0,0 +1,103 @@
+//===--- Server.cpp - gRPC-based Remote Index Server  -===//
+//
+// 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 "index/Index.h"
+#include "index/Serialization.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/LineEditor/LineEditor.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Signals.h"
+
+#include "grpcpp/grpcpp.h"
+#include "grpcpp/health_check_ser

[PATCH] D78139: [clang-tidy] modernize-use-using: Fix broken fixit with 'template' keyword

2020-04-15 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang/lib/AST/NestedNameSpecifier.cpp:314
+InnerPolicy);
+} else if (const auto *SpecType =
+   dyn_cast(T)) {

Can this be renamed as it shadows the `SpecType` variable from line 305, maybe 
`DepSpecType`.



Comment at: clang/lib/AST/TypePrinter.cpp:1391-1392
 T->getQualifier()->print(OS, Policy);
+  OS << "template ";
   OS << T->getIdentifier()->getName();
   printTemplateArgumentList(OS, T->template_arguments(), Policy);

This can be merged to one statement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78139



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


[PATCH] D78068: [www] Turn 'Clang 10' boxes green in C++ status pages to reflect release

2020-04-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/www/cxx_dr_status.html:3
   "http://www.w3.org/TR/html4/strict.dtd";>
 
 

hubert.reinterpretcast wrote:
> hubert.reinterpretcast wrote:
> > rsmith wrote:
> > > Please heed this comment, and check in a matching change to 
> > > `make_cxx_dr_status` =)
> > Thanks for pointing this out (I didn't see the comment).
> @rsmith, I've posted D78172 to make the change.
Sorry about missing that comment as well!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78068



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


[PATCH] D77461: [WIP][clang-tidy] Remove false positive in AvoidNonConstGlobalVariables

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

LGTM! Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77461



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


[clang-tools-extra] f058673 - [dexp] NFC: Change positional argument format

2020-04-15 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-04-15T13:28:07+02:00
New Revision: f05867339737bb203b64a95e096fee509313122d

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

LOG: [dexp] NFC: Change positional argument format

Summary:
Before:

  USAGE: dexp [options] --index-path Path to the index

After:

  USAGE: dexp [options] 

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp 
b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index 9bdc88d7d886..ae49f9437211 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -26,8 +26,7 @@ namespace clang {
 namespace clangd {
 namespace {
 
-llvm::cl::opt IndexPath("index-path",
- llvm::cl::desc("Path to the index"),
+llvm::cl::opt IndexPath(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
 llvm::cl::opt



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


[PATCH] D77461: [WIP][clang-tidy] Remove false positive in AvoidNonConstGlobalVariables

2020-04-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77461



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


[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-04-15 Thread Ties Stuij via Phabricator via cfe-commits
stuij commandeered this revision.
stuij edited reviewers, added: LukeGeeson; removed: stuij.
stuij added a comment.

commandeering as I've got some changes to push


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

https://reviews.llvm.org/D76077



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


[PATCH] D78194: [ARM] Add __bf16 as new Bfloat16 C Type

2020-04-15 Thread Ties Stuij via Phabricator via cfe-commits
stuij created this revision.
Herald added subscribers: cfe-commits, danielkiss, arphaman, kristof.beyls.
Herald added a project: clang.

This patch upstreams support for a new storage only bfloat16 C type.
This type is used to implement primitive support for bfloat16 data, in
line with the Bfloat16 extension of the Armv8.6-a architecture, as
detailed here:

https://community.arm.com/developer/ip-products/processors/b/processors-ip-blog/posts/arm-architecture-developments-armv8-6-a

The bfloat type, and its properties is specified in the Arm C language
extension specification:

https://developer.arm.com/docs/ihi0055/d/procedure-call-standard-for-the-arm-64-bit-architecture

In detail this patch:

  introduces an opaque, storage-only C-type __bf16, which does not introduce a 
new LLVM IR type, but maps it to either i16 or half type.

This is part of a patch series, starting with command-line and Bfloat16
assembly support. The subsequent patches will upstream intrinsics
support for BFloat16, followed by Matrix Multiplication and the
remaining Virtualization features of the armv8.6-a architecture.

Based on work by:

- Luke Cheeseman
- Momchil Velikov
- labrinea
- Luke Geeson


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78194

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang-c/Index.h
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/ARM.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CodeGenTypeCache.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/arm-mangle-16bit-float.cpp
  clang/test/Sema/arm-bfloat.cpp
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -607,6 +607,7 @@
 TKIND(Elaborated);
 TKIND(Pipe);
 TKIND(Attributed);
+TKIND(Bfloat16);
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) TKIND(Id);
 #include "clang/Basic/OpenCLImageTypes.def"
 #undef IMAGE_TYPE
Index: clang/test/Sema/arm-bfloat.cpp
===
--- /dev/null
+++ clang/test/Sema/arm-bfloat.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple aarch64-arm-none-eabi -target-cpu cortex-a75 \
+// RUN: -target-feature +bf16 -target-feature +neon %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple arm-arm-none-eabi -target-cpu cortex-a53 \
+// RUN: -target-feature +bf16 -target-feature +neon %s
+
+void test(bool b) {
+  __bf16 bf16;
+
+  bf16 + bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 - bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 * bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+  bf16 / bf16; // expected-error {{invalid operands to binary expression ('__bf16' and '__bf16')}}
+
+  __fp16 fp16;
+
+  bf16 + fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 + bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 - fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 - bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 * fp16; // expected-error {{invalid operands to binary expression ('__bf16' and '__fp16')}}
+  fp16 * bf16; // expected-error {{invalid operands to binary expression ('__fp16' and '__bf16')}}
+  bf16 / fp16; // expected-error {{invalid operands to binary expres

[PATCH] D76077: [ARM] Add __bf16 as new Bfloat16 C Type

2020-04-15 Thread Ties Stuij via Phabricator via cfe-commits
stuij added a comment.

changes in the last patch: depend on bfloat IR type, and resolve some conflicts 
that crept in


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

https://reviews.llvm.org/D76077



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


[PATCH] D78089: [dexp] NFC: Change positional argument format

2020-04-15 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf05867339737: [dexp] NFC: Change positional argument format 
(authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78089

Files:
  clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp


Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -26,8 +26,7 @@
 namespace clangd {
 namespace {
 
-llvm::cl::opt IndexPath("index-path",
- llvm::cl::desc("Path to the index"),
+llvm::cl::opt IndexPath(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
 llvm::cl::opt


Index: clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
===
--- clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -26,8 +26,7 @@
 namespace clangd {
 namespace {
 
-llvm::cl::opt IndexPath("index-path",
- llvm::cl::desc("Path to the index"),
+llvm::cl::opt IndexPath(llvm::cl::desc(""),
  llvm::cl::Positional, llvm::cl::Required);
 
 llvm::cl::opt
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78020: clang/AMDGPU: Assume denormals are enabled for the default target.

2020-04-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 257676.
arsenm added a comment.

Fix comment


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

https://reviews.llvm.org/D78020

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/cl-denorms-are-zero.cl
  clang/test/Driver/cuda-flush-denormals-to-zero.cu


Index: clang/test/Driver/cuda-flush-denormals-to-zero.cu
===
--- clang/test/Driver/cuda-flush-denormals-to-zero.cu
+++ clang/test/Driver/cuda-flush-denormals-to-zero.cu
@@ -22,6 +22,8 @@
 // RUN: %clang -x hip -no-canonical-prefixes -### -target x86_64-linux-gnu -c 
-march=haswell --cuda-gpu-arch=gfx803 -nocudainc -nogpulib %s 2>&1 | FileCheck 
-check-prefix=FTZ %s
 // RUN: %clang -x hip -no-canonical-prefixes -### -target x86_64-linux-gnu -c 
-march=haswell --cuda-gpu-arch=gfx900 -nocudainc -nogpulib %s 2>&1 | FileCheck 
-check-prefix=NOFTZ %s
 
+// Test no subtarget, which should get the denormal setting of the default 
gfx803
+// RUN: %clang -x hip -no-canonical-prefixes -### -target x86_64-linux-gnu -c 
-march=haswell -nocudainc -nogpulib %s 2>&1 | FileCheck -check-prefix=FTZ %s
 
 // Test multiple offload archs with different defaults.
 // RUN: %clang -x hip -no-canonical-prefixes -### -target x86_64-linux-gnu -c 
-march=haswell --cuda-gpu-arch=gfx803 --cuda-gpu-arch=gfx900 -nocudainc 
-nogpulib %s 2>&1 | FileCheck -check-prefix=MIXED-DEFAULT-MODE %s
Index: clang/test/Driver/cl-denorms-are-zero.cl
===
--- clang/test/Driver/cl-denorms-are-zero.cl
+++ clang/test/Driver/cl-denorms-are-zero.cl
@@ -1,20 +1,24 @@
 // Slow FMAF and slow f32 denormals
-// RUN: %clang -### -target amdgcn--amdhsa -c -mcpu=pitcairn %s 2>&1 | 
FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+// RUN: %clang -### -target amdgcn--amdhsa -nogpulib -c -mcpu=pitcairn %s 2>&1 
| FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 // RUN: %clang -### -cl-denorms-are-zero -o - -target amdgcn--amdhsa -c 
-mcpu=pitcairn %s 2>&1 | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 
 // Fast FMAF, but slow f32 denormals
-// RUN: %clang -### -target amdgcn--amdhsa -c -mcpu=tahiti %s 2>&1 | FileCheck 
-check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+// RUN: %clang -### -target amdgcn--amdhsa -nogpulib -c -mcpu=tahiti %s 2>&1 | 
FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 // RUN: %clang -### -cl-denorms-are-zero -o - -target amdgcn--amdhsa -c 
-mcpu=tahiti %s 2>&1 | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 
 // Fast F32 denormals, but slow FMAF
-// RUN: %clang -### -target amdgcn--amdhsa -c -mcpu=fiji %s 2>&1 | FileCheck 
-check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+// RUN: %clang -### -target amdgcn--amdhsa -nogpulib -c -mcpu=fiji %s 2>&1 | 
FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 // RUN: %clang -### -cl-denorms-are-zero -o - -target amdgcn--amdhsa -c 
-mcpu=fiji %s 2>&1 | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 
 // Fast F32 denormals and fast FMAF
-// RUN: %clang -### -target amdgcn--amdhsa -c -mcpu=gfx900 %s 2>&1 | FileCheck 
-check-prefixes=AMDGCN,AMDGCN-DENORM %s
-// RUN: %clang -### -cl-denorms-are-zero -o - -target amdgcn--amdhsa -c 
-mcpu=gfx900 %s 2>&1 | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+// RUN: %clang -### -target amdgcn--amdhsa -nogpulib -c -mcpu=gfx900 %s 2>&1 | 
FileCheck -check-prefixes=AMDGCN,AMDGCN-DENORM %s
+// RUN: %clang -### -cl-denorms-are-zero -o - -target amdgcn--amdhsa -nogpulib 
-c -mcpu=gfx900 %s 2>&1 | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+
+// Default target is artificial, but should assume a conservative default.
+// RUN: %clang -### -target amdgcn--amdhsa -nogpulib -c %s 2>&1 | FileCheck 
-check-prefixes=AMDGCN,AMDGCN-DENORM %s
+// RUN: %clang -### -cl-denorms-are-zero -o - -target amdgcn--amdhsa -nogpulib 
-c %s 2>&1 | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 
 // AMDGCN-FLUSH: "-fdenormal-fp-math-f32=preserve-sign,preserve-sign"
 
 // This should be omitted and default to ieee
-// AMDGCN-DENORM-NOT: "-fdenormal-fp-math-f32"
+// AMDGCN-DENORM-NOT: denormal-fp-math
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -262,6 +262,11 @@
 
 bool AMDGPUToolChain::getDefaultDenormsAreZeroForTarget(
 llvm::AMDGPU::GPUKind Kind) {
+
+  // Assume nothing without a specific target.
+  if (Kind == llvm::AMDGPU::GK_NONE)
+return false;
+
   const unsigned ArchAttr = llvm::AMDGPU::getArchAttrAMDGCN(Kind);
 
   // Default to enabling f32 denormals by default on subtargets where fma is


Index: clang/test/Driver/cuda-flush-denormals-to-zero.cu
===
--- clang/test/Driver/cuda-flush-denormals-to-zero.cu
+++ clang/test/Driver/cuda-flush-denormals-to-zero.cu
@@ -22,6 +22,8 @@
 // RUN: %clang -x hip -no-canonical-p

[PATCH] D77658: [analyzer] StdLibraryFunctionsChecker: Add sanity checks for constraints

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

The idea is noble with the addition of `validate` functions, assert in debug 
builds and just move on in release. However, I'd expect it to be integrated 
into the signature matching function.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:234-236
+  // The signature of a function we want to describe with a summary. This is a
+  // concessive signature, meaning there may be irrelevant types in the
+  // signature which we do not check against a function with concrete types.

It might be worth putting a `TODO` here to not forget the constness methods :^)



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:697
 if (auto *FD = dyn_cast(D)) {
-  if (S.matchesSignature(FD)) {
+  if (S.Sign.matches(FD) && S.validate(FD)) {
 auto Res = Map.insert({FD->getCanonicalDecl(), S});

This looks a bit odd, we're checking whether the function matches, and than we 
validate right after? Shouldn't we just not match the `FD` if it isn't valid?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77658



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


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

2020-04-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 257681.
arsenm added a comment.

Check triple for support. Report 2.0 for -amdhsa and -amdpal with flat support, 
but 1.2 for clover/-mesa3d. Also require targets to explicitly set a value to 
define, rather than defaulting.


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

https://reviews.llvm.org/D77923

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Preprocessor/predefined-macros.c


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -183,10 +183,21 @@
 // CHECK-AMDGCN-GFX6: #define __IMAGE_SUPPORT__ 1
 // CHECK-AMDGCN-GFX6: #define __OPENCL_VERSION__ 120{{$}}
 
+// No set OS or mesa3d, assume CL1.2
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple amdgcn-unknown-unknown 
-target-cpu gfx700 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMDGCN-GFX7
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple amdgcn-unknown-mesa3d 
-target-cpu gfx700 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMDGCN-GFX7
 // CHECK-AMDGCN-GFX7: #define __IMAGE_SUPPORT__ 1
-// CHECK-AMDGCN-GFX7: #define __OPENCL_VERSION__ 200{{$}}
+// CHECK-AMDGCN-GFX7: #define __OPENCL_VERSION__ 120{{$}}
+
+// Assume CL2.0 support for HSA and PAL
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple amdgcn-unknown-amdhsa 
-target-cpu gfx700 \
+// RUN:   | FileCheck -match-full-lines %s 
--check-prefix=CHECK-AMDGCN-AMDHSAPAL
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple amdgcn-unknown-amdpal 
-target-cpu gfx700 \
+// RUN:   | FileCheck -match-full-lines %s 
--check-prefix=CHECK-AMDGCN-AMDHSAPAL
+// CHECK-AMDGCN-AMDHSAPAL: #define __IMAGE_SUPPORT__ 1
+// CHECK-AMDGCN-AMDHSAPAL: #define __OPENCL_VERSION__ 200{{$}}
 
 
 // RUN: %clang_cc1 %s -E -dM -o - -x hip -triple amdgcn-amd-amdhsa \
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -450,8 +450,10 @@
   }
 }
 
-Builder.defineMacro("__OPENCL_VERSION__",
-Twine(TI.getMaxOpenCLSupportedVersion()));
+if (TI.getMaxOpenCLSupportedVersion() != 0) {
+  Builder.defineMacro("__OPENCL_VERSION__",
+  Twine(TI.getMaxOpenCLSupportedVersion()));
+}
 
 Builder.defineMacro("CL_VERSION_1_0", "100");
 Builder.defineMacro("CL_VERSION_1_1", "110");
Index: clang/lib/Basic/Targets/AMDGPU.cpp
===
--- clang/lib/Basic/Targets/AMDGPU.cpp
+++ clang/lib/Basic/Targets/AMDGPU.cpp
@@ -306,7 +306,13 @@
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
 
   SupportsOpenCLImages = true;
-  MaxOpenCLSupportedVersion =  hasFlatAddressSpace() ? 200 : 120;
+
+  // CL2.0 features require flat instruction support. ROCm supports CL2.0, but
+  // Clover does not.
+  const bool SupportsCL2 = hasFlatAddressSpace() &&
+(Triple.getOS() == llvm::Triple::AMDHSA ||
+ Triple.getOS() == llvm::Triple::AMDPAL);
+  MaxOpenCLSupportedVersion =  SupportsCL2 ? 200 : 120;
 }
 
 void AMDGPUTargetInfo::adjust(LangOptions &Opts) {
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -215,7 +215,10 @@
   unsigned MaxOpenCLWorkGroupSize;
 
   bool SupportsOpenCLImages = false;
-  unsigned MaxOpenCLSupportedVersion = 100;
+
+  /// Maximum supported device OpenCL version, corresponding to the values
+  /// expected for __OPENCL_VERSION__. If 0, the macro is not defined.
+  unsigned MaxOpenCLSupportedVersion = 0;
 
   // TargetInfo Constructor.  Default initializes all fields.
   TargetInfo(const llvm::Triple &T);


Index: clang/test/Preprocessor/predefined-macros.c
===
--- clang/test/Preprocessor/predefined-macros.c
+++ clang/test/Preprocessor/predefined-macros.c
@@ -183,10 +183,21 @@
 // CHECK-AMDGCN-GFX6: #define __IMAGE_SUPPORT__ 1
 // CHECK-AMDGCN-GFX6: #define __OPENCL_VERSION__ 120{{$}}
 
+// No set OS or mesa3d, assume CL1.2
 // RUN: %clang_cc1 %s -E -dM -o - -x cl -triple amdgcn-unknown-unknown -target-cpu gfx700 \
 // RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMDGCN-GFX7
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -triple amdgcn-unknown-mesa3d -target-cpu gfx700 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-AMDGCN-GFX7
 // CHECK-AMDGCN-GFX7: #define __IMAGE_SUPPORT__ 1
-// CHECK-AMDGCN-GFX7: #define __OPENCL_VERSION__ 200{{$}}
+// CHECK-AMDGCN-GFX7: #define __OPENCL_VERSION__ 120{{$}}
+
+// Assume CL2.0 support for HSA and PAL
+// RUN: %clang_cc1 %s -E -d

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

2020-04-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 257684.
arsenm added a comment.

Attach correct diff


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

https://reviews.llvm.org/D77923

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Preprocessor/predefined-macros.c
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp

Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -72,36 +72,36 @@
   {{"oland"}, {"gfx601"},  GK_GFX601,  FEATURE_NONE},
   {{"pitcairn"},  {"gfx601"},  GK_GFX601,  FEATURE_NONE},
   {{"verde"}, {"gfx601"},  GK_GFX601,  FEATURE_NONE},
-  {{"gfx700"},{"gfx700"},  GK_GFX700,  FEATURE_NONE},
-  {{"kaveri"},{"gfx700"},  GK_GFX700,  FEATURE_NONE},
-  {{"gfx701"},{"gfx701"},  GK_GFX701,  FEATURE_FAST_FMA_F32},
-  {{"hawaii"},{"gfx701"},  GK_GFX701,  FEATURE_FAST_FMA_F32},
-  {{"gfx702"},{"gfx702"},  GK_GFX702,  FEATURE_FAST_FMA_F32},
-  {{"gfx703"},{"gfx703"},  GK_GFX703,  FEATURE_NONE},
-  {{"kabini"},{"gfx703"},  GK_GFX703,  FEATURE_NONE},
-  {{"mullins"},   {"gfx703"},  GK_GFX703,  FEATURE_NONE},
-  {{"gfx704"},{"gfx704"},  GK_GFX704,  FEATURE_NONE},
-  {{"bonaire"},   {"gfx704"},  GK_GFX704,  FEATURE_NONE},
-  {{"gfx801"},{"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"carrizo"},   {"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx802"},{"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32},
-  {{"iceland"},   {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32},
-  {{"tonga"}, {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32},
-  {{"gfx803"},{"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"fiji"},  {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"polaris10"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"polaris11"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32},
-  {{"gfx810"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32},
-  {{"stoney"},{"gfx810"},  GK_GFX810,  FEATURE_FAST_DENORMAL_F32},
-  {{"gfx900"},{"gfx900"},  GK_GFX900,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx902"},{"gfx902"},  GK_GFX902,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx904"},{"gfx904"},  GK_GFX904,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx906"},{"gfx906"},  GK_GFX906,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx908"},{"gfx908"},  GK_GFX908,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx909"},{"gfx909"},  GK_GFX909,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
-  {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
-  {{"gfx1012"},   {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+  {{"gfx700"},{"gfx700"},  GK_GFX700,  FEATURE_FLAT_ADDRESS_SPACE},
+  {{"kaveri"},{"gfx700"},  GK_GFX700,  FEATURE_FLAT_ADDRESS_SPACE},
+  {{"gfx701"},{"gfx701"},  GK_GFX701,  FEATURE_FAST_FMA_F32|FEATURE_FLAT_ADDRESS_SPACE},
+  {{"hawaii"},{"gfx701"},  GK_GFX701,  FEATURE_FAST_FMA_F32|FEATURE_FLAT_ADDRESS_SPACE},
+  {{"gfx702"},{"gfx702"},  GK_GFX702,  FEATURE_FAST_FMA_F32|FEATURE_FLAT_ADDRESS_SPACE},
+  {{"gfx703"},{"gfx703"},  GK_GFX703,  FEATURE_FLAT_ADDRESS_SPACE},
+  {{"kabini"},{"gfx703"},  GK_GFX703,  FEATURE_FLAT_ADDRESS_SPACE},
+  {{"mullins"},   {"gfx703"},  GK_GFX703,  FEATURE_FLAT_ADDRESS_SPACE},
+  {{"gfx704"},{"gfx704"},  GK_GFX704,  FEATURE_FLAT_ADDRESS_SPACE},
+  {{"bonaire"},   {"gfx704"},  GK_GFX704,  FEATURE_FLAT_ADDRESS_SPACE},
+  {{"gfx801"},{"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_FLAT_ADDRESS_SPACE},
+  {{"carrizo"},   {"gfx801"},  GK_GFX801,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_FLAT_ADDRESS_SPACE},
+  {{"gfx802"},{"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32|FEATURE_FLAT_ADDRESS_SPACE},
+  {{"iceland"},   {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32|FEATURE_FLAT_ADDRESS_SPACE},
+  {{"tonga"}, {"gfx802"},  GK_GFX802,  FEATURE_FAST_DENORMAL_F32|FEATURE_FLAT_ADDRESS_SPACE},
+  {{"gfx803"},{"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_FLAT_ADDRESS_SPACE},
+  {{"fiji"},  {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_FLAT_ADDRESS_SPACE},
+  {{"polaris10"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_FLAT_ADDRESS_SPACE},
+  {{"polaris11"}, {"gfx803"},  GK_GFX803,  FEATURE_FAST_DENORMAL_F32|FEATURE_FLAT_ADDRESS_SPACE},
+  {{"gfx810"},{"gfx810"},  GK_GFX810,  FEATU

[PATCH] D78020: clang/AMDGPU: Assume denormals are enabled for the default target.

2020-04-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


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

https://reviews.llvm.org/D78020



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


[PATCH] D77809: [Analyzer] Include typedef statements in CFG build.

2020-04-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added reviewers: NoQ, xazax.hun.
Szelethus added a subscriber: NoQ.
Szelethus added a comment.
Herald added a subscriber: rnkovacs.

Adding @NoQ and @xazax.hun , I don't have much experience building CFGs.




Comment at: clang/lib/Analysis/CFG.cpp:2855
+
   VarDecl *VD = dyn_cast(DS->getSingleDecl());
 

How about `using`? How about some other shenanigans that obscure the size of 
the VLA? Can't we just retrieve the size from `VariableArrayType::getSizeExpr` 
after seeing this `VarDecl`, and add that to the block?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77809



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


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

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

The tests are getting better, thanks Endre!




Comment at: clang/test/Analysis/ctu-on-demand-parsing.c:5
+// RUN: cp "%S/Inputs/ctu-other.c" "%t/ctu-other.c"
+// RUN: echo '[{"directory":"%t","command":"gcc -c -std=c89 -Wno-visibility 
ctu-other.c","file":"ctu-other.c"}]' | sed -e 's/\\//g' > 
%t/compile_commands.json
+// RUN: cd "%t" && %clang_extdef_map ctu-other.c > externalDefMap.txt

Why do we need the `-Wno-visibility` flag?



Comment at: clang/test/Analysis/ctu-on-demand-parsing.c:6
+// RUN: echo '[{"directory":"%t","command":"gcc -c -std=c89 -Wno-visibility 
ctu-other.c","file":"ctu-other.c"}]' | sed -e 's/\\//g' > 
%t/compile_commands.json
+// RUN: cd "%t" && %clang_extdef_map ctu-other.c > externalDefMap.txt
+// RUN: cd "%t" && %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only 
-std=c89 -analyze \

If we execute `clang_extdef_map` then we don't need 
`Inputs/ctu-other.c[pp].externalDefMap.on-the-fly.txt` files. Do we?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


[PATCH] D77062: [analyzer] Added check for unacceptable equality operation between Loc and NonLoc types

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

In D77062#1977613 , @ASDenysPetrov 
wrote:

> I've investigated graph.dot of the sample. F11723847: tmp63ucwe5i.html 
> 


This is the exploded graph for which code? The t37503.cpp file you uploaded 
earlier doesn't have the functions/variables found here, nor does the test case 
included in this patch.


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

https://reviews.llvm.org/D77062



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


[PATCH] D78126: [analyzer][NFC] Don't allow dependency checkers to emit diagnostics

2020-04-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:153
+#undef CHECKER_DEPENDENCY
+#undef GET_CHECKER_DEPENDENCIES
+  }

Szelethus wrote:
> Szelethus wrote:
> > balazske wrote:
> > > Probably too much of assert here (but it works)? (There is not a way to 
> > > get the dependency data "dynamically", like 
> > > //"Checker->isDependentOn(OtherChecker)"//?)
> > Wow, you're totally correct, I didn't even consider that. Indeed, this 
> > doesn't work with plugins (or checkers from unit tests), but it should be 
> > doable, since `CheckerManager` owns `CheckerRegistry` (D75360). This is 
> > kind of ironic, considering how much I tend to block patches based on this 
> > :^)
> Oh, to actually answer your question. The checker dependency information is 
> stored in `CheckerRegistry` in this small struct:
> ```lang=cpp
>   struct CheckerInfo {
> enum class StateFromCmdLine {
>   // This checker wasn't explicitly enabled or disabled.
>   State_Unspecified,
>   // This checker was explicitly disabled.
>   State_Disabled,
>   // This checker was explicitly enabled.
>   State_Enabled
> };
> 
> InitializationFunction Initialize = nullptr;
> ShouldRegisterFunction ShouldRegister = nullptr;
> StringRef FullName;
> StringRef Desc;
> StringRef DocumentationUri;
> CmdLineOptionList CmdLineOptions;
> bool IsHidden = false;
> StateFromCmdLine State = StateFromCmdLine::State_Unspecified;
> 
> ConstCheckerInfoList Dependencies;
> //...
>   };
> ```
> So the nice solution should make this info a bit more visible.
I have no serious bad feelings with the macro solution, but if you can come  up 
with a better structure then that would be so cool! :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78126



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


[PATCH] D78125: [AVR] Use the correct address space for non-prototyped function calls

2020-04-15 Thread Ayke via Phabricator via cfe-commits
aykevl updated this revision to Diff 257687.
aykevl marked an inline comment as done.
aykevl added a comment.

- added comment explaining the test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78125

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGen/address-space-avr.c


Index: clang/test/CodeGen/address-space-avr.c
===
--- /dev/null
+++ clang/test/CodeGen/address-space-avr.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm < %s | FileCheck %s
+
+// Test that function declarations in nonzero address spaces without prototype
+// are called correctly.
+
+// CHECK: define void @bar() addrspace(1)
+// CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to 
void (i16) addrspace(1)*)(i16 3)
+// CHECK: declare void @foo(...) addrspace(1)
+void foo();
+void bar(void) {
+   foo(3);
+}
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -5048,7 +5048,8 @@
   // to the function type.
   if (isa(FnType) || Chain) {
 llvm::Type *CalleeTy = getTypes().GetFunctionType(FnInfo);
-CalleeTy = CalleeTy->getPointerTo();
+int AS = Callee.getFunctionPointer()->getType()->getPointerAddressSpace();
+CalleeTy = CalleeTy->getPointerTo(AS);
 
 llvm::Value *CalleePtr = Callee.getFunctionPointer();
 CalleePtr = Builder.CreateBitCast(CalleePtr, CalleeTy, "callee.knr.cast");


Index: clang/test/CodeGen/address-space-avr.c
===
--- /dev/null
+++ clang/test/CodeGen/address-space-avr.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm < %s | FileCheck %s
+
+// Test that function declarations in nonzero address spaces without prototype
+// are called correctly.
+
+// CHECK: define void @bar() addrspace(1)
+// CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to void (i16) addrspace(1)*)(i16 3)
+// CHECK: declare void @foo(...) addrspace(1)
+void foo();
+void bar(void) {
+	foo(3);
+}
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -5048,7 +5048,8 @@
   // to the function type.
   if (isa(FnType) || Chain) {
 llvm::Type *CalleeTy = getTypes().GetFunctionType(FnInfo);
-CalleeTy = CalleeTy->getPointerTo();
+int AS = Callee.getFunctionPointer()->getType()->getPointerAddressSpace();
+CalleeTy = CalleeTy->getPointerTo(AS);
 
 llvm::Value *CalleePtr = Callee.getFunctionPointer();
 CalleePtr = Builder.CreateBitCast(CalleePtr, CalleeTy, "callee.knr.cast");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76929: [AArch64][SVE] Add SVE intrinsic for LD1RQ

2020-04-15 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:11622
+  if (VT.isFloatingPoint())
+Load = DAG.getNode(ISD::BITCAST, DL, VT, Load);
+

I'd expect this to then use `Load.getValue(0)` ?


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

https://reviews.llvm.org/D76929



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


[clang] 3a61245 - clang/AMDGPU: Assume denormals are enabled for the default target.

2020-04-15 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-04-15T09:17:26-04:00
New Revision: 3a612450508b314b7a6f4db142d0c619031d760e

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

LOG: clang/AMDGPU: Assume denormals are enabled for the default target.

Since the default logic was based on having fast denormal/fma
features, and the default target has no features, we assumed flushing
by default. This fixes incorrectly assuming flushing in builds for
"generic" IR libraries.

The handling for no specified --cuda-gpu-arch in HIP is kind of
broken. Somewhere else forces a default target of gfx803, which does
not enable denormal handling by default. We don't see this default
switching here, so you'll end up with a different denormal mode
depending on whether you explicitly requested gfx803, or used it by
default.

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/test/Driver/cl-denorms-are-zero.cl
clang/test/Driver/cuda-flush-denormals-to-zero.cu

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 2a796f28403f..e8c0b824ace1 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -262,6 +262,11 @@ AMDGPUToolChain::TranslateArgs(const DerivedArgList &Args, 
StringRef BoundArch,
 
 bool AMDGPUToolChain::getDefaultDenormsAreZeroForTarget(
 llvm::AMDGPU::GPUKind Kind) {
+
+  // Assume nothing without a specific target.
+  if (Kind == llvm::AMDGPU::GK_NONE)
+return false;
+
   const unsigned ArchAttr = llvm::AMDGPU::getArchAttrAMDGCN(Kind);
 
   // Default to enabling f32 denormals by default on subtargets where fma is

diff  --git a/clang/test/Driver/cl-denorms-are-zero.cl 
b/clang/test/Driver/cl-denorms-are-zero.cl
index 7774c0d60da8..e3fd095e5831 100644
--- a/clang/test/Driver/cl-denorms-are-zero.cl
+++ b/clang/test/Driver/cl-denorms-are-zero.cl
@@ -1,20 +1,24 @@
 // Slow FMAF and slow f32 denormals
-// RUN: %clang -### -target amdgcn--amdhsa -c -mcpu=pitcairn %s 2>&1 | 
FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+// RUN: %clang -### -target amdgcn--amdhsa -nogpulib -c -mcpu=pitcairn %s 2>&1 
| FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 // RUN: %clang -### -cl-denorms-are-zero -o - -target amdgcn--amdhsa -c 
-mcpu=pitcairn %s 2>&1 | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 
 // Fast FMAF, but slow f32 denormals
-// RUN: %clang -### -target amdgcn--amdhsa -c -mcpu=tahiti %s 2>&1 | FileCheck 
-check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+// RUN: %clang -### -target amdgcn--amdhsa -nogpulib -c -mcpu=tahiti %s 2>&1 | 
FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 // RUN: %clang -### -cl-denorms-are-zero -o - -target amdgcn--amdhsa -c 
-mcpu=tahiti %s 2>&1 | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 
 // Fast F32 denormals, but slow FMAF
-// RUN: %clang -### -target amdgcn--amdhsa -c -mcpu=fiji %s 2>&1 | FileCheck 
-check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+// RUN: %clang -### -target amdgcn--amdhsa -nogpulib -c -mcpu=fiji %s 2>&1 | 
FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 // RUN: %clang -### -cl-denorms-are-zero -o - -target amdgcn--amdhsa -c 
-mcpu=fiji %s 2>&1 | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 
 // Fast F32 denormals and fast FMAF
-// RUN: %clang -### -target amdgcn--amdhsa -c -mcpu=gfx900 %s 2>&1 | FileCheck 
-check-prefixes=AMDGCN,AMDGCN-DENORM %s
-// RUN: %clang -### -cl-denorms-are-zero -o - -target amdgcn--amdhsa -c 
-mcpu=gfx900 %s 2>&1 | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+// RUN: %clang -### -target amdgcn--amdhsa -nogpulib -c -mcpu=gfx900 %s 2>&1 | 
FileCheck -check-prefixes=AMDGCN,AMDGCN-DENORM %s
+// RUN: %clang -### -cl-denorms-are-zero -o - -target amdgcn--amdhsa -nogpulib 
-c -mcpu=gfx900 %s 2>&1 | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
+
+// Default target is artificial, but should assume a conservative default.
+// RUN: %clang -### -target amdgcn--amdhsa -nogpulib -c %s 2>&1 | FileCheck 
-check-prefixes=AMDGCN,AMDGCN-DENORM %s
+// RUN: %clang -### -cl-denorms-are-zero -o - -target amdgcn--amdhsa -nogpulib 
-c %s 2>&1 | FileCheck -check-prefixes=AMDGCN,AMDGCN-FLUSH %s
 
 // AMDGCN-FLUSH: "-fdenormal-fp-math-f32=preserve-sign,preserve-sign"
 
 // This should be omitted and default to ieee
-// AMDGCN-DENORM-NOT: "-fdenormal-fp-math-f32"
+// AMDGCN-DENORM-NOT: denormal-fp-math

diff  --git a/clang/test/Driver/cuda-flush-denormals-to-zero.cu 
b/clang/test/Driver/cuda-flush-denormals-to-zero.cu
index a515b5f8ca07..4a7b88823771 100644
--- a/clang/test/Driver/cuda-flush-denormals-to-zero.cu
+++ b/clang/test/Driver/cuda-flush-denormals-to-zero.cu
@@ -22,6 +22,8 @@
 // RUN: %clang -x hip -no-canonical-prefixes -### -target x86_64-linux-gnu -c 
-march=haswell --cuda-gpu-arch=gfx803 -nocudain

[PATCH] D78198: [Format] Work around current vim bugs in clang-format.py

2020-04-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Do line/col to byte conversions on the python side rather than relying on vim.
Its calculations are off when text annotations are present:

- https://github.com/vim/vim/issues/5930
- https://github.com/vim/vim/issues/3718 (fixed, but vim 8.1 is still common)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78198

Files:
  clang/tools/clang-format/clang-format.py


Index: clang/tools/clang-format/clang-format.py
===
--- clang/tools/clang-format/clang-format.py
+++ clang/tools/clang-format/clang-format.py
@@ -71,7 +71,7 @@
   encoding = vim.eval("&encoding")
   buf = get_buffer(encoding)
   # Join the buffer into a single string with a terminating newline
-  text = '\n'.join(buf) + '\n'
+  text = ('\n'.join(buf) + '\n').encode(encoding)
 
   # Determine range to format.
   if vim.eval('exists("l:lines")') == '1':
@@ -90,9 +90,14 @@
 lines = ['-lines', '%s:%s' % (vim.current.range.start + 1,
   vim.current.range.end + 1)]
 
-  # Determine the cursor position.
-  cursor = int(vim.eval('line2byte(line("."))+col(".")')) - 2
-  if cursor < 0:
+  # Convert cursor (line, col) to bytes.
+  # Don't use line2byte: https://github.com/vim/vim/issues/5930
+  _, cursor_line, cursor_col, _ = vim.eval('getpos(".")') # 1-based
+  cursor_byte = 0
+  for line in text.split(b'\n')[:int(cursor_line) - 1]:
+cursor_byte += len(line) + 1
+  cursor_byte += int(cursor_col) - 1
+  if cursor_byte < 0:
 print('Couldn\'t determine cursor position. Is your file empty?')
 return
 
@@ -104,7 +109,7 @@
 startupinfo.wShowWindow = subprocess.SW_HIDE
 
   # Call formatter.
-  command = [binary, '-cursor', str(cursor)]
+  command = [binary, '-cursor', str(cursor_byte)]
   if lines != ['-lines', 'all']:
 command += lines
   if style:
@@ -116,7 +121,7 @@
   p = subprocess.Popen(command,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
stdin=subprocess.PIPE, startupinfo=startupinfo)
-  stdout, stderr = p.communicate(input=text.encode(encoding))
+  stdout, stderr = p.communicate(input=text)
 
   # If successful, replace buffer contents.
   if stderr:
@@ -128,18 +133,24 @@
 'Please report to bugs.llvm.org.'
 )
   else:
-lines = stdout.decode(encoding).split('\n')
-output = json.loads(lines[0])
+header, content = stdout.split(b'\n', 1)
+header = json.loads(header)
 # Strip off the trailing newline (added above).
 # This maintains trailing empty lines present in the buffer if
 # the -lines specification requests them to remain unchanged.
-lines = lines[1:-1]
+lines = content.decode(encoding).split('\n')[:-1]
 sequence = difflib.SequenceMatcher(None, buf, lines)
 for op in reversed(sequence.get_opcodes()):
   if op[0] != 'equal':
 vim.current.buffer[op[1]:op[2]] = lines[op[3]:op[4]]
-if output.get('IncompleteFormat'):
+if header.get('IncompleteFormat'):
   print('clang-format: incomplete (syntax errors)')
-vim.command('goto %d' % (output['Cursor'] + 1))
+# Convert cursor bytes to (line, col)
+# Don't use goto: https://github.com/vim/vim/issues/5930
+cursor_byte = int(header['Cursor'])
+prefix = content[0:cursor_byte]
+cursor_line = 1 + prefix.count(b'\n')
+cursor_column = 1 + len(prefix.rsplit(b'\n', 1)[-1])
+vim.command('call cursor(%d, %d)' % (cursor_line, cursor_column))
 
 main()


Index: clang/tools/clang-format/clang-format.py
===
--- clang/tools/clang-format/clang-format.py
+++ clang/tools/clang-format/clang-format.py
@@ -71,7 +71,7 @@
   encoding = vim.eval("&encoding")
   buf = get_buffer(encoding)
   # Join the buffer into a single string with a terminating newline
-  text = '\n'.join(buf) + '\n'
+  text = ('\n'.join(buf) + '\n').encode(encoding)
 
   # Determine range to format.
   if vim.eval('exists("l:lines")') == '1':
@@ -90,9 +90,14 @@
 lines = ['-lines', '%s:%s' % (vim.current.range.start + 1,
   vim.current.range.end + 1)]
 
-  # Determine the cursor position.
-  cursor = int(vim.eval('line2byte(line("."))+col(".")')) - 2
-  if cursor < 0:
+  # Convert cursor (line, col) to bytes.
+  # Don't use line2byte: https://github.com/vim/vim/issues/5930
+  _, cursor_line, cursor_col, _ = vim.eval('getpos(".")') # 1-based
+  cursor_byte = 0
+  for line in text.split(b'\n')[:int(cursor_line) - 1]:
+cursor_byte += len(line) + 1
+  cursor_byte += int(cursor_col) - 1
+  if cursor_byte < 0:
 print('Couldn\'t determine cursor position. Is your file empty?')
 return
 
@@ -104,7 +109,7 @@
 startupinfo.wShowWindow = subprocess.SW_HIDE
 
   # Call formatter.
-  command = [binary, '-cursor', str(cursor)]
+  comma

[PATCH] D77062: [analyzer] Added check for unacceptable equality operation between Loc and NonLoc types

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

@Szelethus

> This is the exploded graph for which code? The t37503.cpp file you uploaded 
> earlier doesn't have the functions/variables found here, nor does the test 
> case included in this patch.

This //html //corresponds to the test case in the patch. You can find it below 
in clang/test/Analysis/string.c. However `t37503.cpp` also contains the same 
snippet just with other names and it wouldn't change the graph.


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

https://reviews.llvm.org/D77062



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


[PATCH] D76957: HIP: Merge builtin library handling

2020-04-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 257694.
arsenm added a comment.

Update for new library structure


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

https://reviews.llvm.org/D76957

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-device-libs.hip
  clang/test/Driver/rocm-device-libs.cl

Index: clang/test/Driver/rocm-device-libs.cl
===
--- clang/test/Driver/rocm-device-libs.cl
+++ clang/test/Driver/rocm-device-libs.cl
@@ -121,6 +121,21 @@
 
 
 
+// Test --hip-device-lib-path format
+// RUN: %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx900 \
+// RUN:   --hip-device-lib-path=%S/Inputs/rocm-device-libs/amdgcn/bitcode \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX900-DEFAULT,GFX900,WAVE64 %s
+
+// Test environment variable HIP_DEVICE_LIB_PATH
+// RUN: env HIP_DEVICE_LIB_PATH=%S/Inputs/rocm-device-libs/amdgcn/bitcode %clang -### -target amdgcn-amd-amdhsa \
+// RUN:   -x cl -mcpu=gfx900 \
+// RUN:   %S/opencl.cl \
+// RUN: 2>&1 | FileCheck -dump-input-on-failure --check-prefixes=COMMON,COMMON-DEFAULT,GFX900-DEFAULT,GFX900,WAVE64 %s
+
+
+
 // COMMON: "-triple" "amdgcn-amd-amdhsa"
 // COMMON-SAME: "-mlink-builtin-bitcode" "{{.*}}/amdgcn/bitcode/opencl.bc"
 // COMMON-SAME: "-mlink-builtin-bitcode" "{{.*}}/amdgcn/bitcode/ocml.bc"
Index: clang/test/Driver/hip-device-libs.hip
===
--- clang/test/Driver/hip-device-libs.hip
+++ clang/test/Driver/hip-device-libs.hip
@@ -7,16 +7,16 @@
 
 // Test subtarget with flushing on by default.
 // RUN: %clang -### -target x86_64-linux-gnu \
-// RUN:   --cuda-gpu-arch=gfx803 \
-// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib   \
+// RUN:  --cuda-gpu-arch=gfx803 \
+// RUN:  --rocm-path=%S/Inputs/rocm-device-libs   \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,FLUSHD
 
 
 // Test subtarget with flushing off by ddefault.
 // RUN: %clang -### -target x86_64-linux-gnu \
-// RUN:   --cuda-gpu-arch=gfx900 \
-// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:  --cuda-gpu-arch=gfx900 \
+// RUN:  --rocm-path=%S/Inputs/rocm-device-libs \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD
 
@@ -25,7 +25,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -fcuda-flush-denormals-to-zero \
-// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,FLUSHD
 
@@ -34,7 +34,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx803 \
 // RUN:   -fno-cuda-flush-denormals-to-zero \
-// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD
 
@@ -43,7 +43,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -fno-cuda-flush-denormals-to-zero \
-// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD
 
@@ -52,7 +52,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx803 \
 // RUN:   -fcuda-flush-denormals-to-zero \
-// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,FLUSHD
 
@@ -61,7 +61,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx803 \
 // RUN:   -fcuda-flush-denormals-to-zero -fno-cuda-flush-denormals-to-zero \
-// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD
 
@@ -69,7 +69,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -fcuda-flush-denormals-to-zero -fno-cuda-flush-denormals-to-zero \
-// RUN:   --hip-device-lib-path=%S/Inputs/hip_dev_lib   \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs   \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
 // RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD
 
@@ -77,7 +77,7 @@
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --cuda-gpu-arch=gfx900 \
 // RUN:   -fno-cuda-flush-denormals-to-zero -fcuda-flush-denormals-to-zero \
-// RUN:   --hip-device-lib-path=%S/Inputs/

[PATCH] D77885: AMDGPU: Search for new ROCm bitcode library structure

2020-04-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


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

https://reviews.llvm.org/D77885



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


[PATCH] D78100: [AST] Suppress the spammy "attempt to use a deleted fucntion" diagnostic.

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



Comment at: clang/lib/Sema/SemaDecl.cpp:11985-11986
   });
   if (Res.isInvalid()) {
 VDecl->setInvalidDecl();
   } else if (Res.get() != Args[Idx]) {

rsmith wrote:
> Should we attach a `RecoveryExpr` initializer in this case?
I think so, will address in a separate patch.



Comment at: clang/lib/Sema/SemaDecl.cpp:12268
 /// of sanity.
 void Sema::ActOnInitializerError(Decl *D) {
   // Our main concern here is re-establishing invariants like "a

sammccall wrote:
> rsmith wrote:
> > Should we attach a `RecoveryExpr` initializer in this case too?
> Now we're really slipping into a different set of use-cases for 
> RecoveryExpr... 
> I assume we're talking about a RecoveryExpr that has no children, at least in 
> the short term, as parsing failures don't return the likely subexpressions 
> found. So it's a pure error marker in the form of an AST node. Quite a lot of 
> ExprError()s could become these...
> 
> Actually there's another virtue here: even without subexpressions, the 
> RecoveryExpr can capture the token range. So VarDecl::getSourceRange() will 
> include the malformed initializer, so tools can at least attribute these 
> tokens to the right part of the AST.
yeah, I'm not sure how much benefit we can get from the recovery-expr in this 
case, if the initializer is failed to parse, we don't have any ast nodes.



Comment at: clang/test/CXX/class.access/p4.cpp:1
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions 
-fsyntax-only -verify -std=c++98 %s
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions 
-fsyntax-only -verify -std=c++11 %s
-// RUN: %clang_cc1 -triple %itanium_abi_triple -fcxx-exceptions -fexceptions 
-fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-compatibility-version=19 
-fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++98 %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-compatibility-version=19 
-fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
-// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-compatibility-version=19 
-fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -frecovery-ast -triple %itanium_abi_triple -fcxx-exceptions 
-fexceptions -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -frecovery-ast -triple %itanium_abi_triple -fcxx-exceptions 
-fexceptions -fsyntax-only -verify -std=c++11 %s

sammccall wrote:
> rsmith wrote:
> > I'm not really happy about improving our quality of diagnostics only under 
> > `-frecovery-ast`. Do we really need that flag? The way I see it, we can 
> > divide the users of Clang up into:
> > 
> >  * We want valid code (eg, as a compiler): if we hit an error, it doesn't 
> > matter too much whether we build `RecoveryExpr`s or not, since we're on a 
> > path to bailing out anyway. If `RecoveryExpr`s allow us to improve our 
> > diagnostics, we should build them. (Exception: if we want valid code or to 
> > get a simple pass/fail as early as possible, maybe not.)
> >  * We want to accept invalid code (eg, tooling): if we hit an error, we 
> > probably want to retain as much information as we reasonably can about the 
> > non-erroneous parts of the program.
> > 
> > So I think at least the default should be to build `RecoveryExpr`s, and 
> > maybe we can remove the flag entirely?
> Agree that want to flip the default to true, and maybe eventually get rid of 
> it. But:
>  - we're still fighting quite a lot of new crash-on-invalids, and can't fix 
> them all in one big patch. We plan to find more by rolling this out to a 
> subset of google-internal IDE users (where we have good monitoring), the flag 
> is needed for this.
>  - we expect this to be stable for C++ long before it can be enabled for C, 
> because that requires making the C codepaths safe handle (at least 
> error-)dependence. So there'll be a similar testing/improvement period later.
> 
> However I don't like adding -frecovery-ast to big existing tests, we lose 
> coverage of today's production behavior. I think we may need to create new 
> tests to show the effect of these changes, and clean them up after flipping 
> the default.
yeah, it is not perfect, given that we are at intermediate stage. We plan to 
enable the flag for C++ by default (we did it once, but failed with many 
crashes), this means we'd eventually focus on '-frecovery-ast' only (at least 
C++), it seems not too harmful to add the -frecovery-ast flag to exiting tests 
at the moment. But it is not great.. 

Another way is to adjust existing tests to support both, but this seems 
non-trivial, maybe creating new tests for '-frecovery-ast' is a best way to go.

life can be easier if the flag is turned on by default. Currently, I have to 
maintain a local patch with a long tail of adjusted 

[PATCH] D78020: clang/AMDGPU: Assume denormals are enabled for the default target.

2020-04-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

3a612450508b314b7a6f4db142d0c619031d760e 



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

https://reviews.llvm.org/D78020



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


[PATCH] D78100: [AST] Suppress the spammy "attempt to use a deleted fucntion" diagnostic.

2020-04-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 257689.
hokein marked 4 inline comments as done.
hokein added a comment.

address comments:

- don't modify the existing tests
- add new tests for -frecovery-ast only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78100

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/recovery-default-init.cpp


Index: clang/test/SemaCXX/recovery-default-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/recovery-default-init.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -fsyntax-only -frecovery-ast -verify -std=c++11
+
+// NOTE: the test can be merged into existing tests once -frecovery-ast is on
+// by default.
+
+struct Foo { // expected-note {{candidate constructor (the implicit copy 
constructor) not viable}}
+  Foo(int); // expected-note {{candidate constructor not viable}}
+  ~Foo() = delete;
+};
+
+void test() {
+  // we expect the "attempt to use a deleted function" diagnostic is 
suppressed.
+  Foo foo; // expected-error {{no matching constructor for initialization of}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15003,6 +15003,10 @@
 
 void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) {
   if (VD->isInvalidDecl()) return;
+  // If initializing the variable failed, don't also diagnose problems with
+  // the desctructor, they're likely related.
+  if (VD->getInit() && VD->getInit()->containsErrors())
+return;
 
   CXXRecordDecl *ClassDecl = cast(Record->getDecl());
   if (ClassDecl->isInvalidDecl()) return;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12554,12 +12554,17 @@
 InitializationSequence InitSeq(*this, Entity, Kind, None);
 ExprResult Init = InitSeq.Perform(*this, Entity, Kind, None);
 
-// If default-init fails, leave var uninitialized but valid, for recovery.
-
 if (Init.get()) {
   Var->setInit(MaybeCreateExprWithCleanups(Init.get()));
   // This is important for template substitution.
   Var->setInitStyle(VarDecl::CallInit);
+} else if (Init.isInvalid()) {
+  // If default-init fails, attach a recovery-expr initializer to track
+  // that initialization was attempted and failed.
+  auto RecoveryExpr =
+  CreateRecoveryExpr(Var->getLocation(), Var->getEndLoc(), {});
+  if (RecoveryExpr.get())
+Var->setInit(RecoveryExpr.get());
 }
 
 CheckCompleteVariableDeclaration(Var);


Index: clang/test/SemaCXX/recovery-default-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/recovery-default-init.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -fsyntax-only -frecovery-ast -verify -std=c++11
+
+// NOTE: the test can be merged into existing tests once -frecovery-ast is on
+// by default.
+
+struct Foo { // expected-note {{candidate constructor (the implicit copy constructor) not viable}}
+  Foo(int); // expected-note {{candidate constructor not viable}}
+  ~Foo() = delete;
+};
+
+void test() {
+  // we expect the "attempt to use a deleted function" diagnostic is suppressed.
+  Foo foo; // expected-error {{no matching constructor for initialization of}}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15003,6 +15003,10 @@
 
 void Sema::FinalizeVarWithDestructor(VarDecl *VD, const RecordType *Record) {
   if (VD->isInvalidDecl()) return;
+  // If initializing the variable failed, don't also diagnose problems with
+  // the desctructor, they're likely related.
+  if (VD->getInit() && VD->getInit()->containsErrors())
+return;
 
   CXXRecordDecl *ClassDecl = cast(Record->getDecl());
   if (ClassDecl->isInvalidDecl()) return;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12554,12 +12554,17 @@
 InitializationSequence InitSeq(*this, Entity, Kind, None);
 ExprResult Init = InitSeq.Perform(*this, Entity, Kind, None);
 
-// If default-init fails, leave var uninitialized but valid, for recovery.
-
 if (Init.get()) {
   Var->setInit(MaybeCreateExprWithCleanups(Init.get()));
   // This is important for template substitution.
   Var->setInitStyle(VarDecl::CallInit);
+} else if (Init.isInvalid()) {
+  // If default-init fails, attach a recovery-expr initializer to track
+  // that initialization was attempted and failed.
+  auto RecoveryExpr =
+  CreateRecoveryExpr(Var->getLocat

[clang-tools-extra] cb1ee34 - [clang-tidy] Optional inheritance of file configs from parent directories 

2020-04-15 Thread Dmitry Polukhin via cfe-commits

Author: Dmitry Polukhin
Date: 2020-04-15T06:41:31-07:00
New Revision: cb1ee34e9d32fce84613827693a8ed3aff1d36cf

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

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

Summary:
Without this patch clang-tidy stops finding file configs on the nearest
.clang-tidy file. In some cases it is not very convenient because it
results in common parts duplication into every child .clang-tidy file.
This diff adds optional config inheritance from the parent directories
config files.

Test Plan:

Added test cases in existing config test.

Reviewers: alexfh, gribozavr2, klimek, hokein

Subscribers: njames93, arphaman, xazax.hun, aheejin, cfe-commits

Tags: #clang, #clang-tools-extra

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

Added: 

clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy

clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy

clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy

Modified: 
clang-tools-extra/clang-tidy/ClangTidy.cpp
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/docs/clang-tidy/index.rst
clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 05594f191a5f..367fa3dda5cf 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -328,7 +328,9 @@ static void setStaticAnalyzerCheckerOpts(const 
ClangTidyOptions &Opts,
 StringRef OptName(Opt.first);
 if (!OptName.startswith(AnalyzerPrefix))
   continue;
-AnalyzerOptions->Config[OptName.substr(AnalyzerPrefix.size())] = 
Opt.second;
+// Analyzer options are always local options so we can ignore priority.
+AnalyzerOptions->Config[OptName.substr(AnalyzerPrefix.size())] =
+Opt.second.Value;
   }
 }
 

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index aadf372cda1a..7ddf054a21a9 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -72,19 +72,20 @@ llvm::Expected
 ClangTidyCheck::OptionsView::get(StringRef LocalName) const {
   const auto &Iter = CheckOptions.find(NamePrefix + LocalName.str());
   if (Iter != CheckOptions.end())
-return Iter->second;
+return Iter->second.Value;
   return llvm::make_error((NamePrefix + LocalName).str());
 }
 
 llvm::Expected
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
-  auto Iter = CheckOptions.find(NamePrefix + LocalName.str());
-  if (Iter != CheckOptions.end())
-return Iter->second;
-  // Fallback to global setting, if present.
-  Iter = CheckOptions.find(LocalName.str());
-  if (Iter != CheckOptions.end())
-return Iter->second;
+  auto IterLocal = CheckOptions.find(NamePrefix + LocalName.str());
+  auto IterGlobal = CheckOptions.find(LocalName.str());
+  if (IterLocal != CheckOptions.end() &&
+  (IterGlobal == CheckOptions.end() ||
+   IterLocal->second.Priority >= IterGlobal->second.Priority))
+return IterLocal->second.Value;
+  if (IterGlobal != CheckOptions.end())
+return IterGlobal->second.Value;
   return llvm::make_error((NamePrefix + LocalName).str());
 }
 
@@ -123,17 +124,15 @@ bool ClangTidyCheck::OptionsView::get(StringRef 
LocalName,
 template <>
 llvm::Expected
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const 
{
-  llvm::Expected ValueOr = get(LocalName);
-  bool IsGlobal = false;
-  if (!ValueOr) {
-llvm::consumeError(ValueOr.takeError());
-ValueOr = getLocalOrGlobal(LocalName);
-IsGlobal = true;
-  }
-  if (!ValueOr)
-return ValueOr.takeError();
-  return getAsBool(*ValueOr, IsGlobal ? llvm::Twine(LocalName)
-  : (NamePrefix + LocalName));
+  auto IterLocal = CheckOptions.find(NamePrefix + LocalName.str());
+  auto IterGlobal = CheckOptions.find(LocalName.str());
+  if (IterLocal != CheckOptions.end() &&
+  (IterGlobal == CheckOptions.end() ||
+   IterLocal->second.Priority >= IterGlobal->second.Priority))
+return getAsBool(IterLocal->second.Value, NamePrefix + LocalName);
+  if (IterGlobal != CheckOptions.end())
+return getAsBool(IterGlobal->second.Value, llvm::Twine(LocalN

[clang] 316b49d - Pass shufflevector indices as int instead of unsigned.

2020-04-15 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-04-15T15:52:49+02:00
New Revision: 316b49d37336258e11f16b5822d078c6407cd34f

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

LOG: Pass shufflevector indices as int instead of unsigned.

No functionality change intended.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Target/X86/X86InterleavedAccess.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 87f52102fff4..f4832ef4afb2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -11747,7 +11747,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
 // Splat the 8-bits of immediate 4 times to help the loop wrap around.
 Imm = (Imm & 0xff) * 0x01010101;
 
-uint32_t Indices[16];
+int Indices[16];
 for (unsigned l = 0; l != NumElts; l += NumLaneElts) {
   for (unsigned i = 0; i != NumLaneElts; ++i) {
 unsigned Index = Imm % NumLaneElts;

diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index e2997df3cc51..d61b79725d5e 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -912,7 +912,7 @@ static Value *UpgradeX86PSLLDQIntrinsics(IRBuilder<> 
&Builder,
   // If shift is less than 16, emit a shuffle to move the bytes. Otherwise,
   // we'll just return the zero vector.
   if (Shift < 16) {
-uint32_t Idxs[64];
+int Idxs[64];
 // 256/512-bit version is split into 2/4 16-byte lanes.
 for (unsigned l = 0; l != NumElts; l += 16)
   for (unsigned i = 0; i != 16; ++i) {
@@ -946,7 +946,7 @@ static Value *UpgradeX86PSRLDQIntrinsics(IRBuilder<> 
&Builder, Value *Op,
   // If shift is less than 16, emit a shuffle to move the bytes. Otherwise,
   // we'll just return the zero vector.
   if (Shift < 16) {
-uint32_t Idxs[64];
+int Idxs[64];
 // 256/512-bit version is split into 2/4 16-byte lanes.
 for (unsigned l = 0; l != NumElts; l += 16)
   for (unsigned i = 0; i != 16; ++i) {
@@ -972,7 +972,7 @@ static Value *getX86MaskVec(IRBuilder<> &Builder, Value 
*Mask,
   // If we have less than 8 elements, then the starting mask was an i8 and
   // we need to extract down to the right number of elements.
   if (NumElts < 8) {
-uint32_t Indices[4];
+int Indices[4];
 for (unsigned i = 0; i != NumElts; ++i)
   Indices[i] = i;
 Mask = Builder.CreateShuffleVector(Mask, Mask,
@@ -1041,7 +1041,7 @@ static Value *UpgradeX86ALIGNIntrinsics(IRBuilder<> 
&Builder, Value *Op0,
 Op0 = llvm::Constant::getNullValue(Op0->getType());
   }
 
-  uint32_t Indices[64];
+  int Indices[64];
   // 256-bit palignr operates on 128-bit lanes so we need to handle that
   for (unsigned l = 0; l < NumElts; l += 16) {
 for (unsigned i = 0; i != 16; ++i) {
@@ -1352,7 +1352,7 @@ static Value *ApplyX86MaskOn1BitsVec(IRBuilder<> 
&Builder, Value *Vec,
   }
 
   if (NumElts < 8) {
-uint32_t Indices[8];
+int Indices[8];
 for (unsigned i = 0; i != NumElts; ++i)
   Indices[i] = i;
 for (unsigned i = NumElts; i != 8; ++i)
@@ -1878,7 +1878,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function 
*NewFn) {
   unsigned NumElts = CI->getType()->getScalarSizeInBits();
   Value *LHS = getX86MaskVec(Builder, CI->getArgOperand(0), NumElts);
   Value *RHS = getX86MaskVec(Builder, CI->getArgOperand(1), NumElts);
-  uint32_t Indices[64];
+  int Indices[64];
   for (unsigned i = 0; i != NumElts; ++i)
 Indices[i] = i;
 
@@ -2127,8 +2127,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function 
*NewFn) {
   unsigned NumDstElts = DstTy->getNumElements();
   if (NumDstElts < SrcTy->getNumElements()) {
 assert(NumDstElts == 2 && "Unexpected vector size");
-uint32_t ShuffleMask[2] = { 0, 1 };
-Rep = Builder.CreateShuffleVector(Rep, Rep, ShuffleMask);
+Rep = Builder.CreateShuffleVector(Rep, Rep, ArrayRef{0, 1});
   }
 
   bool IsPS2PD = SrcTy->getElementType()->isFloatTy();
@@ -2159,8 +2158,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function 
*NewFn) {
   unsigned NumDstElts = DstTy->getNumElements();
   if (NumDstElts != SrcTy->getNumElements()) {
 assert(NumDstElts == 4 && "Unexpected vector size");
-uint32_t ShuffleMask[4] = {0, 1, 2, 3};
-Rep = Builder.CreateShuffleVector(Rep, Rep, ShuffleMask);
+Rep = Builder.CreateShuffleVector(Rep, Rep, ArrayRef{0, 1, 2, 3});
   }
   Rep = Builder.CreateBitCast(
   Rep, VectorType::get(Type::getHalfTy(C), NumDstElts));
@@ -2310,7 +2308,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function 
*NewFn) {
   unsigned NumDstElts = DstTy->getNumElements();
 
   // Extrac

[PATCH] D77809: [Analyzer] Include typedef statements in CFG build.

2020-04-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun requested changes to this revision.
xazax.hun added a comment.
This revision now requires changes to proceed.

I am not an expert when it comes to VLAs but I do see some problems here.

First of all, we do not want to include typedef statements in the CFG as they 
are noops in terms of the execution. We definitely want to include the 
evaluation of array size expressions for VLAs. In case the evaluation of that 
expression is not included in the CFG that is definitely a bug but the name of 
the revision should reflect this.

My questions so far:

- Where is the size expression actually evaluated? Is it evaluated at the point 
of the typedef or at the point of the variable definition? It is possible to 
construct code that behaves differently in those cases. In case the behavior is 
the latter the currently produced CFG is wrong.
- You mentioned that type aliases are not handled. Why? Is there any technical 
reason for that? Is it a language restriction? Does it behave differently? I 
think, unless it is really hard to support it well, I would prefer to introduce 
full support in one patch. Otherwise rewriting a code to use type aliases 
instead of typedefs would change the behavior of the analyzer on that code 
which is quite surprising for the users.

I think this needs more testing, i.e. what about more complex size expressions 
and multiple typedefs/type aliases? Can we have multidimensional VLAs?




Comment at: clang/lib/Analysis/CFG.cpp:2843
+
+  if (const auto *TDD = dyn_cast(DS->getSingleDecl())) {
+// If we encounter a VLA in typedef, then process its size expressions.

Can't we have the same situation with type aliases? In that case, maybe we 
should check for `TypedefNameDecl` instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77809



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


[PATCH] D78204: [AArch64][SVE] Remove LD1/ST1 dependency on llvm.masked.load/store

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

The SVE masked load and store intrinsics introduced in D76688 
 rely on
common llvm.masked.load/store nodes. This patch creates new ISD nodes
for LD1(S) & ST1 to remove this dependency.

Additionally, this adds support for sign & zero extending
loads and truncating stores.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78204

Files:
  llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-ld1.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-ldst1.ll
  llvm/test/CodeGen/AArch64/sve-intrinsics-st1.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-st1.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-st1.ll
@@ -0,0 +1,367 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; ST1B
+;
+
+define void @st1b_i8( %data,  %pred, i8* %addr) {
+; CHECK-LABEL: st1b_i8:
+; CHECK: st1b { z0.b }, p0, [x0]
+; CHECK-NEXT: ret
+  call void @llvm.aarch64.sve.st1.nxv16i8( %data,
+   %pred,
+  i8* %addr)
+  ret void
+}
+
+define void @st1b_h( %data,  %pred, i8* %addr) {
+; CHECK-LABEL: st1b_h:
+; CHECK: st1b { z0.h }, p0, [x0]
+; CHECK-NEXT: ret
+  %trunc = trunc  %data to 
+  call void @llvm.aarch64.sve.st1.nxv8i8( %trunc,
+  %pred,
+ i8* %addr)
+  ret void
+}
+
+define void @st1b_s( %data,  %pred, i8* %addr) {
+; CHECK-LABEL: st1b_s:
+; CHECK: st1b { z0.s }, p0, [x0]
+; CHECK-NEXT: ret
+  %trunc = trunc  %data to 
+  call void @llvm.aarch64.sve.st1.nxv4i8( %trunc,
+  %pred,
+ i8* %addr)
+  ret void
+}
+
+define void @st1b_d( %data,  %pred, i8* %addr) {
+; CHECK-LABEL: st1b_d:
+; CHECK: st1b { z0.d }, p0, [x0]
+; CHECK-NEXT: ret
+  %trunc = trunc  %data to 
+  call void @llvm.aarch64.sve.st1.nxv2i8( %trunc,
+  %pred,
+ i8* %addr)
+  ret void
+}
+
+define void @st1b_upper_bound( %data,  %pg, i8* %a) {
+; CHECK-LABEL: st1b_upper_bound:
+; CHECK: st1b { z0.b }, p0, [x0, #7, mul vl]
+; CHECK-NEXT: ret
+  %base_scalable = bitcast i8* %a to *
+  %base = getelementptr , * %base_scalable, i64 7
+  %base_scalar = bitcast * %base to i8*
+  call void @llvm.aarch64.sve.st1.nxv16i8( %data,  %pg, i8* %base_scalar)
+  ret void
+}
+
+define void @st1b_inbound( %data,  %pg, i8* %a) {
+; CHECK-LABEL: st1b_inbound:
+; CHECK: st1b { z0.b }, p0, [x0, #1, mul vl]
+; CHECK-NEXT: ret
+  %base_scalable = bitcast i8* %a to *
+  %base = getelementptr , * %base_scalable, i64 1
+  %base_scalar = bitcast * %base to i8*
+  call void @llvm.aarch64.sve.st1.nxv16i8( %data,  %pg, i8* %base_scalar)
+  ret void
+}
+
+define void @st1b_lower_bound( %data,  %pg, i8* %a) {
+; CHECK-LABEL: st1b_lower_bound:
+; CHECK: st1b { z0.b }, p0, [x0, #-8, mul vl]
+; CHECK-NEXT: ret
+  %base_scalable = bitcast i8* %a to *
+  %base = getelementptr , * %base_scalable, i64 -8
+  %base_scalar = bitcast * %base to i8*
+  call void @llvm.aarch64.sve.st1.nxv16i8( %data,  %pg, i8* %base_scalar)
+  ret void
+}
+
+define void @st1b_out_of_upper_bound( %data,  %pg, i8* %a) {
+; CHECK-LABEL: st1b_out_of_upper_bound:
+; CHECK: rdvl x[[OFFSET:[0-9]+]], #8
+; CHECK: add x[[BASE:[0-9]+]], x0, x[[OFFSET]]
+; CHECK: st1b { z0.b }, p0, [x[[BASE]]]
+; CHECK-NEXT: ret
+  %base_scalable = bitcast i8* %a to *
+  %base = getelementptr , * %base_scalable, i64 8
+  %base_scalar = bitcast * %base to i8*
+  call void @llvm.aarch64.sve.st1.nxv16i8( %data,  %pg, i8* %base_scalar)
+  ret void
+}
+
+define void @st1b_out_of_lower_bound( %data,  %pg, i8* %a) {
+; CHECK-LABEL: st1b_out_of_lower_bound:
+; CHECK: rdvl x[[OFFSET:[0-9]+]], #-9
+; CHECK: add x[[BASE:[0-9]+]], x0, x[[OFFSET]]
+; CHECK: st1b { z0.b }, p0, [x[[BASE]]]
+; CHECK-NEXT: ret
+  %base_scalable = bitcast i8* %a to *
+  %base = getelementptr , * %base_scalable, i64 -9
+  %base_scalar = bitcast * %base to i8*
+  call void @llvm.aarch64.sve.st1.nxv16i8( %data,  %pg, i8* %base_scalar)
+  ret void
+}
+
+define void @st1b_s_inbound( %data,  %pg, i8* %a) {
+; CHECK-LABEL: st1b_s_inbound:
+; CHECK: st1b { z0.s }, p0, [x0, #7, mul vl]
+; CHECK-NEXT: ret
+  %base_scalable = bitcast i8* %a to *
+  %base = getelementptr , * %base_scalable, i64 7
+  %base_scalar = bitcast * %base to i8*
+  %trunc = trunc  %data to 
+  call void @llvm.aarch

[PATCH] D78198: [Format] Work around current vim bugs in clang-format.py

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

thanks for tracing it down! looks good, I assume you have test it locally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78198



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


[PATCH] D77068: [XCore] fix crash on unused inline in EmitTargetMetadata

2020-04-15 Thread Nigel Perks via Phabricator via cfe-commits
nigelp-xmos added a comment.

Ping.

Just a polite ping to keep it alive. I hope that's all right. Not urgent at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77068



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-04-15 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 257704.
mibintc added a comment.

Lost power in Monday's storm, back online today.  I made the changes requested 
by @rjmccall.  Look OK?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76384

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/LangOptions.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Basic/LangOptions.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaPseudoObject.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp

Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -918,11 +918,16 @@
 
 void ASTStmtWriter::VisitBinaryOperator(BinaryOperator *E) {
   VisitExpr(E);
+  bool HasFPFeatures = E->hasStoredFPFeatures();
+  // Write this first for easy access when deserializing, as they affect the
+  // size of the UnaryOperator.
+  Record.push_back(HasFPFeatures);
+  Record.push_back(E->getOpcode()); // FIXME: stable encoding
   Record.AddStmt(E->getLHS());
   Record.AddStmt(E->getRHS());
-  Record.push_back(E->getOpcode()); // FIXME: stable encoding
   Record.AddSourceLocation(E->getOperatorLoc());
-  Record.push_back(E->getFPFeatures().getInt());
+  if (HasFPFeatures)
+Record.push_back(E->getStoredFPFeatures().getAsOpaqueInt());
   Code = serialization::EXPR_BINARY_OPERATOR;
 }
 
@@ -1513,7 +1518,7 @@
 void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
   VisitCallExpr(E);
   Record.push_back(E->getOperator());
-  Record.push_back(E->getFPFeatures().getInt());
+  Record.push_back(E->getFPFeatures().getAsOpaqueInt());
   Record.AddSourceRange(E->Range);
   Code = serialization::EXPR_CXX_OPERATOR_CALL;
 }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -3905,7 +3905,7 @@
 
 /// Write an FP_PRAGMA_OPTIONS block for the given FPOptions.
 void ASTWriter::WriteFPPragmaOptions(const FPOptions &Opts) {
-  RecordData::value_type Record[] = {Opts.getInt()};
+  RecordData::value_type Record[] = {Opts.getAsOpaqueInt()};
   Stream.EmitRecord(FP_PRAGMA_OPTIONS, Record);
 }
 
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -1050,12 +1050,16 @@
 }
 
 void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
+  bool hasFP_Features;
+  BinaryOperator::Opcode opc;
   VisitExpr(E);
+  E->setHasStoredFPFeatures(hasFP_Features = Record.readInt());
+  E->setOpcode(opc = (BinaryOperator::Opcode)Record.readInt());
   E->setLHS(Record.readSubExpr());
   E->setRHS(Record.readSubExpr());
-  E->setOpcode((BinaryOperator::Opcode)Record.readInt());
   E->setOperatorLoc(readSourceLocation());
-  E->setFPFeatures(FPOptions(Record.readInt()));
+  if (hasFP_Features)
+E->setStoredFPFeatures(FPOptions(Record.readInt()));
 }
 
 void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
@@ -2937,11 +2941,13 @@
   break;
 
 case EXPR_BINARY_OPERATOR:
-  S = new (Context) BinaryOperator(Empty);
+  S = BinaryOperator::CreateEmpty(Context,
+  Record[ASTStmtReader::NumExprFields]);
   break;
 
 case EXPR_COMPOUND_ASSIGN_OPERATOR:
-  S = new (Context) CompoundAssignOperator(Empty);
+  S = CompoundAssignOperator::CreateEmpty(
+  Context, Record[ASTStmtReader::NumExprFields]);
   break;
 
 case EXPR_CONDITIONAL_OPERATOR:
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -10267,8 +10267,12 @@
   RHS.get() == E->getRHS())
 return E;
 
+  if (E->isCompoundAssignmentOp())
+// FPFeatures has already been established from trailing storage
+return getDerived().RebuildBinaryOperator(
+E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
   Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
-  getSema().FPFeatures = E->getFPFeatures();
+  getSema().FPFeatures = E->getFPFeatures(getSema().ge

[PATCH] D78163: [AVR][NFC] Move preprocessor tests to Preprocessor directory

2020-04-15 Thread Ayke via Phabricator via cfe-commits
aykevl added a comment.

Honestly I don't know the convention but I agree with @rjmccall that the 
convention appears to be to not use a separate subdirectory (I don't see any 
other arch-specific subdirectories). So, should the files be moved to 
clang/test/Preprocessor/avr-*.c (e.g. clang/test/Preprocessor/avr-attiny104.c) 
while keeping `REQUIRES: avr-registered-target`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78163



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


[PATCH] D78099: [analyzer][RetainCount] Tie diagnostics to osx.cocoa.RetainCount rather then RetainCountBase, for the most part

2020-04-15 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp:1500
+RefCountBug::KIND);
+  // TODO: Ideally, we should have a checker for each of these bug types.
+  INIT_BUGTYPE(UseAfterRelease)

So, this is an intermediate patch before we reach that? That is the reason why 
we must use unique_ptrs and lazily init them?



Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp:1508
+  INIT_BUGTYPE(LeakWithinFunction)
+  INIT_BUGTYPE(LeakAtReturn)
 }

Perhaps `#undef INIT_BUGTYPE` would be useful here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78099



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


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

2020-04-15 Thread Dmitry Polukhin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcb1ee34e9d32: [clang-tidy] Optional inheritance of file 
configs from parent directories  (authored by DmitryPolukhin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184

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

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -87,7 +87,7 @@
   ExtraArgsBefore: ['arg-before3', 'arg-before4']
   )");
   ASSERT_TRUE(!!Options2);
-  ClangTidyOptions Options = Options1->mergeWith(*Options2);
+  ClangTidyOptions Options = Options1->mergeWith(*Options2, 0);
   EXPECT_EQ("check1,check2,check3,check4", *Options.Checks);
   EXPECT_EQ("filter2", *Options.HeaderFilterRegex);
   EXPECT_EQ("user2", *Options.User);
Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -7,6 +7,26 @@
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s -check-prefix=CHECK-CHILD2
 // CHECK-CHILD2: Checks: {{.*}}from-parent
 // CHECK-CHILD2: HeaderFilterRegex: parent
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/3/- -- | FileCheck %s -check-prefix=CHECK-CHILD3
+// CHECK-CHILD3: Checks: {{.*}}from-parent,from-child3
+// CHECK-CHILD3: HeaderFilterRegex: child3
 // RUN: clang-tidy -dump-config -checks='from-command-line' -header-filter='from command line' %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=CHECK-COMMAND-LINE
 // CHECK-COMMAND-LINE: Checks: {{.*}}from-parent,from-command-line
 // CHECK-COMMAND-LINE: HeaderFilterRegex: from command line
+
+// For this test we have to use names of the real checks because otherwise values are ignored.
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD4
+// CHECK-CHILD4: Checks: {{.*}}modernize-loop-convert,modernize-use-using,llvm-qualified-auto
+// CHECK-CHILD4: - key: llvm-qualified-auto.AddConstToQualified
+// CHECK-CHILD4-NEXT: value: '1
+// CHECK-CHILD4: - key: modernize-loop-convert.MaxCopySize
+// CHECK-CHILD4-NEXT: value: '20'
+// CHECK-CHILD4: - key: modernize-loop-convert.MinConfidence
+// CHECK-CHILD4-NEXT: value: reasonable
+// CHECK-CHILD4: - key: modernize-use-using.IgnoreMacros
+// CHECK-CHILD4-NEXT: value: '0'
+
+// RUN: clang-tidy --explain-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-EXPLAIN
+// CHECK-EXPLAIN: 'llvm-qualified-auto' is enabled in the {{.*}}/Inputs/config-files/4/44/.clang-tidy.
+// CHECK-EXPLAIN: 'modernize-loop-convert' is enabled in the {{.*}}/Inputs/config-files/4/.clang-tidy.
+// CHECK-EXPLAIN: 'modernize-use-using' is enabled in the {{.*}}/Inputs/config-files/4/.clang-tidy.
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy
@@ -0,0 +1,9 @@
+InheritParentConfig: true
+Checks: 'llvm-qualified-auto'
+CheckOptions:
+  - key: modernize-loop-convert.MaxCopySize
+value:   '20'
+  - key: llvm-qualified-auto.AddConstToQualified
+value:   '1'
+  - key: IgnoreMacros
+value:   '0'
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy
@@ -0,0 +1,8 @@
+Checks: '-*,modernize-loop-convert,modernize-use-using'
+CheckOptions:
+  - key: modernize-loop-convert.MaxCopySize
+value:   '10'
+  - key: modernize-loop-convert.MinConfidence
+value:   reasonable

[clang] 17198df - [AST] Fix recovery-expr crash on invalid aligned attr.

2020-04-15 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-04-15T16:15:20+02:00
New Revision: 17198dfaff53a897edfc8d440a91cb9430982dcf

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

LOG: [AST] Fix recovery-expr crash on invalid aligned attr.

Summary:
crash stack:

```
lang: tools/clang/include/clang/AST/AttrImpl.inc:1490: unsigned int 
clang::AlignedAttr::getAlignment(clang::ASTContext &) const: Assertion 
`!isAlignmentDependent()' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: ./bin/clang -cc1 -std=c++1y -ast-dump -frecovery-ast 
-fcxx-exceptions /tmp/t4.cpp
1.  /tmp/t4.cpp:3:31: current parser token ';'
 #0 0x02530cff llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
llvm-project/llvm/lib/Support/Unix/Signals.inc:564:13
 #1 0x0252ee30 llvm::sys::RunSignalHandlers() 
llvm-project/llvm/lib/Support/Signals.cpp:69:18
 #2 0x0253126c SignalHandler(int) 
llvm-project/llvm/lib/Support/Unix/Signals.inc:396:3
 #3 0x7f86964d0520 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x13520)
 #4 0x7f8695f9ff61 raise 
/build/glibc-oCLvUT/glibc-2.29/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x7f8695f8b535 abort /build/glibc-oCLvUT/glibc-2.29/stdlib/abort.c:81:7
 #6 0x7f8695f8b40f _nl_load_domain 
/build/glibc-oCLvUT/glibc-2.29/intl/loadmsgcat.c:1177:9
 #7 0x7f8695f98b92 (/lib/x86_64-linux-gnu/libc.so.6+0x32b92)
 #8 0x04503d9f llvm::APInt::getZExtValue() const 
llvm-project/llvm/include/llvm/ADT/APInt.h:1623:5
 #9 0x04503d9f clang::AlignedAttr::getAlignment(clang::ASTContext&) 
const llvm-project/build/tools/clang/include/clang/AST/AttrImpl.inc:1492:0
```

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

Added: 
clang/test/SemaCXX/invalid-aligned-attr.cpp

Modified: 
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/DeclBase.cpp
clang/test/AST/ast-dump-recovery.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/lib/AST/ComputeDependence.cpp 
b/clang/lib/AST/ComputeDependence.cpp
index 3a326f62a2ec..0f0f79ea1857 100644
--- a/clang/lib/AST/ComputeDependence.cpp
+++ b/clang/lib/AST/ComputeDependence.cpp
@@ -71,8 +71,10 @@ ExprDependence 
clang::computeDependence(UnaryExprOrTypeTraitExpr *E) {
   if (!D)
 return Deps;
   for (const auto *I : D->specific_attrs()) {
+if (I->isAlignmentErrorDependent())
+  Deps |= ExprDependence::Error;
 if (I->isAlignmentDependent())
-  return Deps | ExprDependence::ValueInstantiation;
+  Deps |= ExprDependence::ValueInstantiation;
   }
   return Deps;
 }

diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 0eb88e07f9bc..c1f5043b0840 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -396,8 +396,10 @@ unsigned Decl::getMaxAlignment() const {
   const AttrVec &V = getAttrs();
   ASTContext &Ctx = getASTContext();
   specific_attr_iterator I(V.begin()), E(V.end());
-  for (; I != E; ++I)
-Align = std::max(Align, I->getAlignment(Ctx));
+  for (; I != E; ++I) {
+if (!I->isAlignmentErrorDependent())
+  Align = std::max(Align, I->getAlignment(Ctx));
+  }
   return Align;
 }
 

diff  --git a/clang/test/AST/ast-dump-recovery.cpp 
b/clang/test/AST/ast-dump-recovery.cpp
index 9ccfc5a106f8..248470a5093c 100644
--- a/clang/test/AST/ast-dump-recovery.cpp
+++ b/clang/test/AST/ast-dump-recovery.cpp
@@ -97,4 +97,9 @@ struct Foo {} foo;
 void test(int x) {
   foo.abc;
   foo->func(x);
-}
\ No newline at end of file
+}
+
+// CHECK: |-AlignedAttr {{.*}} alignas
+// CHECK-NEXT:| `-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:|   `-UnresolvedLookupExpr {{.*}} 'invalid'
+struct alignas(invalid()) Aligned {};

diff  --git a/clang/test/SemaCXX/invalid-aligned-attr.cpp 
b/clang/test/SemaCXX/invalid-aligned-attr.cpp
new file mode 100644
index ..5807536359a1
--- /dev/null
+++ b/clang/test/SemaCXX/invalid-aligned-attr.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -frecovery-ast -verify %s
+// RUN: %clang_cc1 -verify %s
+
+struct alignas(invalid()) Foo {}; // expected-error {{use of undeclared 
identifier}}
+
+constexpr int k = alignof(Foo);

diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index ca3bebd54c7c..2b1719599785 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -481,6 +481,7 @@ namespace {
 
 void writeAccessors(raw_ostream &OS) const override {
   OS << "  bool is" << getUpperName() << "Dependent() const;\n";
+  OS << "  bool is" << getUpperName() << "ErrorDependent() const;\n"

[PATCH] D77866: [analyzer][CallAndMessage] Add checker options for each bug category

2020-04-15 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Looks good to me!




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:194
+   const ProgramPointTag *Tag = nullptr) {
+// Say this 3 times fast.
+State = State ? State : getState();

I like joke :D But there are people who may not, so, the code would be more pro 
without it. 



Comment at: clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp:66
+  // convert these to actual checkers.
+  enum CheckKind {
+CK_FunctionPointer,

So, we are not going to have subcheckers, rather options, okay. Perhaps the 
comment would be more appropriate to be in `Checkers.td`? (If we can put 
comments there.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77866



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


[PATCH] D77866: [analyzer][CallAndMessage] Add checker options for each bug category

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

In D77866#1983685 , @martong wrote:

> Looks good to me!


Just take care of the failures you have with harbourmaster, there seem to be 
CSA failures with the bot!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77866



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


[PATCH] D78085: [AST] Fix recovery-expr crash on invalid aligned attr.

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

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78085

Files:
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/DeclBase.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/SemaCXX/invalid-aligned-attr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -481,6 +481,7 @@
 
 void writeAccessors(raw_ostream &OS) const override {
   OS << "  bool is" << getUpperName() << "Dependent() const;\n";
+  OS << "  bool is" << getUpperName() << "ErrorDependent() const;\n";
 
   OS << "  unsigned get" << getUpperName() << "(ASTContext &Ctx) const;\n";
 
@@ -511,6 +512,15 @@
  << "Type->getType()->isDependentType();\n";
   OS << "}\n";
 
+  OS << "bool " << getAttrName() << "Attr::is" << getUpperName()
+ << "ErrorDependent() const {\n";
+  OS << "  if (is" << getLowerName() << "Expr)\n";
+  OS << "return " << getLowerName() << "Expr && " << getLowerName()
+ << "Expr->containsErrors();\n";
+  OS << "  return " << getLowerName()
+ << "Type->getType()->containsErrors();\n";
+  OS << "}\n";
+
   // FIXME: Do not do the calculation here
   // FIXME: Handle types correctly
   // A null pointer means maximum alignment
Index: clang/test/SemaCXX/invalid-aligned-attr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-aligned-attr.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -frecovery-ast -verify %s
+// RUN: %clang_cc1 -verify %s
+
+struct alignas(invalid()) Foo {}; // expected-error {{use of undeclared 
identifier}}
+
+constexpr int k = alignof(Foo);
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -97,4 +97,9 @@
 void test(int x) {
   foo.abc;
   foo->func(x);
-}
\ No newline at end of file
+}
+
+// CHECK: |-AlignedAttr {{.*}} alignas
+// CHECK-NEXT:| `-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:|   `-UnresolvedLookupExpr {{.*}} 'invalid'
+struct alignas(invalid()) Aligned {};
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -396,8 +396,10 @@
   const AttrVec &V = getAttrs();
   ASTContext &Ctx = getASTContext();
   specific_attr_iterator I(V.begin()), E(V.end());
-  for (; I != E; ++I)
-Align = std::max(Align, I->getAlignment(Ctx));
+  for (; I != E; ++I) {
+if (!I->isAlignmentErrorDependent())
+  Align = std::max(Align, I->getAlignment(Ctx));
+  }
   return Align;
 }
 
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -71,8 +71,10 @@
   if (!D)
 return Deps;
   for (const auto *I : D->specific_attrs()) {
+if (I->isAlignmentErrorDependent())
+  Deps |= ExprDependence::Error;
 if (I->isAlignmentDependent())
-  return Deps | ExprDependence::ValueInstantiation;
+  Deps |= ExprDependence::ValueInstantiation;
   }
   return Deps;
 }


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -481,6 +481,7 @@
 
 void writeAccessors(raw_ostream &OS) const override {
   OS << "  bool is" << getUpperName() << "Dependent() const;\n";
+  OS << "  bool is" << getUpperName() << "ErrorDependent() const;\n";
 
   OS << "  unsigned get" << getUpperName() << "(ASTContext &Ctx) const;\n";
 
@@ -511,6 +512,15 @@
  << "Type->getType()->isDependentType();\n";
   OS << "}\n";
 
+  OS << "bool " << getAttrName() << "Attr::is" << getUpperName()
+ << "ErrorDependent() const {\n";
+  OS << "  if (is" << getLowerName() << "Expr)\n";
+  OS << "return " << getLowerName() << "Expr && " << getLowerName()
+ << "Expr->containsErrors();\n";
+  OS << "  return " << getLowerName()
+ << "Type->getType()->containsErrors();\n";
+  OS << "}\n";
+
   // FIXME: Do not do the calculation here
   // FIXME: Handle types correctly
   // A null pointer means maximum alignment
Index: clang/test/SemaCXX/invalid-aligned-attr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-aligned-attr.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -frecovery-ast -verify %s
+// RUN: %clang_cc1 -verify %s
+
+struct ali

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

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

In D77229#1980665 , @NoQ wrote:

> Aha, ok, sounds like i thought that it's not worth it to inline the 
> constructor for an argument when the call itself is not inlined, therefore i 
> didn't model the construction context for this call. See also D49443#1193290 
> . Your example shows that i was 
> wrong to give up and this is something we should totally implement.
>
> The proper solution is to model the target region in `ExprEngine` as a 
> parameter region based on the `ParmVarDecl` that //would have been used if 
> the function was inlined//, instead of the dummy temporary. Then it'll be 
> kept alive as an object under construction.
>
> The most annoying part is to make sure that you're using the same 
> `FunctionDecl` consistently everywhere. If this turns out to be too annoying, 
> we could also replace `VarRegion{ParmVarDecl}` with a new sort of region that 
> doesn't include a specific `ParmVarDecl` but merely a parameter index (and 
> maybe a type or a call site expr), so that not to bother with redeclarations; 
> this is the right thing to do anyway.


I am trying to understand where I have to implement this but I have some 
problems. The first is that when a function is not inlined it does not have a 
`StackFrameContext`. What to use instead? I usually try to use the caller's 
stack frame but it seems to be incorrect and causes assertions. Or should we 
create a stack frame for non-inlined functions as well?

Where are the parameter regions created? In `case 
ConstructionContext::ArgumentKind` of function 
`ExprEngine::handleConstructionContext()`? Or in 
`CallEvent::getParameterLocation()`? Or somewhere else? I tried to look at 
D49443 , especially the diff where you gave up 
regions for parameters of non-inlined functions but there you only had changes 
in `CallEvent`.

For using the same `FunctionDecl`: would it help if we always use the "first" 
`Decl` in the chain?


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

https://reviews.llvm.org/D77229



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


[PATCH] D78122: [analyzer][Nullability] Don't emit under the checker name NullabilityBase

2020-04-15 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong 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/D78122/new/

https://reviews.llvm.org/D78122



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


[PATCH] D78085: [AST] Fix recovery-expr crash on invalid aligned attr.

2020-04-15 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG17198dfaff53: [AST] Fix recovery-expr crash on invalid 
aligned attr. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78085

Files:
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/DeclBase.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/SemaCXX/invalid-aligned-attr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -481,6 +481,7 @@
 
 void writeAccessors(raw_ostream &OS) const override {
   OS << "  bool is" << getUpperName() << "Dependent() const;\n";
+  OS << "  bool is" << getUpperName() << "ErrorDependent() const;\n";
 
   OS << "  unsigned get" << getUpperName() << "(ASTContext &Ctx) const;\n";
 
@@ -511,6 +512,15 @@
  << "Type->getType()->isDependentType();\n";
   OS << "}\n";
 
+  OS << "bool " << getAttrName() << "Attr::is" << getUpperName()
+ << "ErrorDependent() const {\n";
+  OS << "  if (is" << getLowerName() << "Expr)\n";
+  OS << "return " << getLowerName() << "Expr && " << getLowerName()
+ << "Expr->containsErrors();\n";
+  OS << "  return " << getLowerName()
+ << "Type->getType()->containsErrors();\n";
+  OS << "}\n";
+
   // FIXME: Do not do the calculation here
   // FIXME: Handle types correctly
   // A null pointer means maximum alignment
Index: clang/test/SemaCXX/invalid-aligned-attr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-aligned-attr.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -frecovery-ast -verify %s
+// RUN: %clang_cc1 -verify %s
+
+struct alignas(invalid()) Foo {}; // expected-error {{use of undeclared 
identifier}}
+
+constexpr int k = alignof(Foo);
Index: clang/test/AST/ast-dump-recovery.cpp
===
--- clang/test/AST/ast-dump-recovery.cpp
+++ clang/test/AST/ast-dump-recovery.cpp
@@ -97,4 +97,9 @@
 void test(int x) {
   foo.abc;
   foo->func(x);
-}
\ No newline at end of file
+}
+
+// CHECK: |-AlignedAttr {{.*}} alignas
+// CHECK-NEXT:| `-RecoveryExpr {{.*}} contains-errors
+// CHECK-NEXT:|   `-UnresolvedLookupExpr {{.*}} 'invalid'
+struct alignas(invalid()) Aligned {};
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -396,8 +396,10 @@
   const AttrVec &V = getAttrs();
   ASTContext &Ctx = getASTContext();
   specific_attr_iterator I(V.begin()), E(V.end());
-  for (; I != E; ++I)
-Align = std::max(Align, I->getAlignment(Ctx));
+  for (; I != E; ++I) {
+if (!I->isAlignmentErrorDependent())
+  Align = std::max(Align, I->getAlignment(Ctx));
+  }
   return Align;
 }
 
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -71,8 +71,10 @@
   if (!D)
 return Deps;
   for (const auto *I : D->specific_attrs()) {
+if (I->isAlignmentErrorDependent())
+  Deps |= ExprDependence::Error;
 if (I->isAlignmentDependent())
-  return Deps | ExprDependence::ValueInstantiation;
+  Deps |= ExprDependence::ValueInstantiation;
   }
   return Deps;
 }


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -481,6 +481,7 @@
 
 void writeAccessors(raw_ostream &OS) const override {
   OS << "  bool is" << getUpperName() << "Dependent() const;\n";
+  OS << "  bool is" << getUpperName() << "ErrorDependent() const;\n";
 
   OS << "  unsigned get" << getUpperName() << "(ASTContext &Ctx) const;\n";
 
@@ -511,6 +512,15 @@
  << "Type->getType()->isDependentType();\n";
   OS << "}\n";
 
+  OS << "bool " << getAttrName() << "Attr::is" << getUpperName()
+ << "ErrorDependent() const {\n";
+  OS << "  if (is" << getLowerName() << "Expr)\n";
+  OS << "return " << getLowerName() << "Expr && " << getLowerName()
+ << "Expr->containsErrors();\n";
+  OS << "  return " << getLowerName()
+ << "Type->getType()->containsErrors();\n";
+  OS << "}\n";
+
   // FIXME: Do not do the calculation here
   // FIXME: Handle types correctly
   // A null pointer means maximum alignment
Index: clang/test/SemaCXX/invalid-aligned-attr.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-aligned-attr.cpp
@@ -0,0 +1

[PATCH] D77885: AMDGPU: Search for new ROCm bitcode library structure

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

If we really want to do this, device lib change and hipcc change need to be 
ready. Since once this is committed without corresponding device lib and hipcc 
change, HIP will break.

On ROCM, device lib is currently installed at /opt/rocm/lib with extension 
.amdgcn.bc. This change requires device libs to be installed to 
/opt/rocm/amdgcn/bitcode and with extension .bc (drop amdgcn in extension). 
Also -device-lib-path option needs to point to /opt/rocm/amdgcn/bitcode or 
dropped.

On Windows, device lib Makefiles need to be changed to drop amdgcn in extension.

Another issue: is /opt/rocm/amdgcn/bitcode the right installation path for 
device lib? Shouldn't it be /opt/rocm/lib/amdgcn/bitcode or 
/opt/rocm/lib/amdgcn ?


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

https://reviews.llvm.org/D77885



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


[clang] a73a81d - [www] Update make_cxx_dr_status for v10; regenerate cxx_dr_status.html

2020-04-15 Thread Hubert Tong via cfe-commits

Author: Hubert Tong
Date: 2020-04-15T10:45:00-04:00
New Revision: a73a81dce5bcae4f14004c09ee1844d7572d4f1e

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

LOG: [www] Update make_cxx_dr_status for v10; regenerate cxx_dr_status.html

Summary: Update `latest_release` to reflect the release of Clang 10.

Reviewed By: rsmith

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

Added: 


Modified: 
clang/www/cxx_dr_status.html
clang/www/make_cxx_dr_status

Removed: 




diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 2e1683c9989f..3f0102889c67 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -2645,7 +2645,7 @@ C++ defect report implementation 
status
 https://wg21.link/cwg434";>434
 NAD
 Unclear suppression of standard conversions while binding reference to 
lvalue
-Superseded by 2352
+Superseded by 2352
   
   
 https://wg21.link/cwg435";>435
@@ -3527,7 +3527,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg581";>581
-DR
+DRWP
 Can a templated constructor be explicitly instantiated or 
specialized?
 Unknown
   
@@ -4133,7 +4133,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg682";>682
-tentatively ready
+DRWP
 Missing description of lookup of template aliases
 Unknown
   
@@ -9537,11 +9537,11 @@ C++ defect report implementation 
status
 User-defined literals and extended integer types
 Not resolved
   
-  
+  
 https://wg21.link/cwg1621";>1621
-drafting
+DRWP
 Member initializers in anonymous unions
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1622";>1622
@@ -11243,7 +11243,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg1905";>1905
-MAD
+NAD
 Dependent types and injected-class-names
 Unknown
   
@@ -11435,13 +11435,13 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg1937";>1937
-DR
+DRWP
 Incomplete specification of function pointer from lambda
 Unknown
   
   
 https://wg21.link/cwg1938";>1938
-DR
+DRWP
 Should hosted/freestanding be implementation-defined?
 Unknown
   
@@ -11933,7 +11933,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2020";>2020
-DR
+DRWP
 Inadequate description of odr-use of implicitly-invoked functions
 Unknown
   
@@ -12119,7 +12119,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2051";>2051
-DR
+DRWP
 Simplifying alias rules
 Unknown
   
@@ -12129,11 +12129,11 @@ C++ defect report implementation 
status
 Template argument deduction vs overloaded operators
 Unknown
   
-  
+  
 https://wg21.link/cwg2053";>2053
-drafting
+DR
 auto in non-generic lambdas
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg2054";>2054
@@ -12311,7 +12311,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2083";>2083
-DR
+DRWP
 Incorrect cases of odr-use
 Partial
   
@@ -12431,7 +12431,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2103";>2103
-DR
+DRWP
 Lvalue-to-rvalue conversion is irrelevant in odr-use of a 
reference
 Yes
   
@@ -12567,11 +12567,11 @@ C++ defect report implementation 
status
 Copy elision and comma operator
 Extension
   
-  
+  
 https://wg21.link/cwg2126";>2126
-drafting
+DRWP
 Lifetime-extended temporaries in constant expressions
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg2127";>2127
@@ -12833,7 +12833,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2170";>2170
-DR
+DRWP
 Unclear definition of odr-use for arrays
 Clang 9
   
@@ -13055,7 +13055,7 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2207";>2207
-tentatively ready
+DRWP
 Alignment of allocation function return value
 Unknown
   
@@ -13349,13 +13349,13 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2256";>2256
-DR
+DRWP
 Lifetime of trivially-destructible objects
 Unknown
   
   
 https://wg21.link/cwg2257";>2257
-DR
+DRWP
 Lifetime extension of references vs exceptions
 Unknown
   
@@ -13409,13 +13409,13 @@ C++ defect report implementation 
status
   
   
 https://wg21.link/cwg2266";>2266
-DR
+DRWP
 Has dependent type vs is type-dependent
 Unknown
   
   
 https://wg21.link/cwg2267";>2267
-DR
+DRWP
 Copy-initialization of temporary in reference 
direct-initialization
 Unknown
   
@@ -13481,

[PATCH] D78099: [analyzer][RetainCount] Tie diagnostics to osx.cocoa.RetainCount rather then RetainCountBase, for the most part

2020-04-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus marked an inline comment as done.
Szelethus added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp:1500
+RefCountBug::KIND);
+  // TODO: Ideally, we should have a checker for each of these bug types.
+  INIT_BUGTYPE(UseAfterRelease)

martong wrote:
> So, this is an intermediate patch before we reach that? That is the reason 
> why we must use unique_ptrs and lazily init them?
I lack the knowledge required to do that myself, unfortunately, and I'm no 
client of this checker, I'm not even sure what I would want to see it do.

We need unique pointers because `BugType` has no default constructor, and we 
receive the checker name //after// adding the checker object to 
`CheckerManager` (this happens in `registerRetainCountBase`). Other checkers 
use unique pointers for this type as well.

The lazy init, as opposed to simple initializing happens so that the checker 
name associated with the bug report doesn't depend on the registration order of 
`RetainCount` and `OSObjectRetainCount` (I guess I could've explained this in 
the code as well, huh). Right now, it only depends on which checker is enabled, 
which is bad enough, but addressing this TODO will fix that in an instant.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78099



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


[PATCH] D78181: [clangd] Fix a crash for accessing a null field decl returned by findExplicitReferences.

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

emit empty decl and simplify the testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78181

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1273,7 +1273,20 @@
 "5: targets = {Bar}\n"
 "6: targets = {bar}, decl\n"
 "7: targets = {foo()::Bar::Foo}\n"
-"8: targets = {foo()::Baz::Field}\n"}};
+"8: targets = {foo()::Baz::Field}\n"},
+  {R"cpp(
+   template
+   void crash(T);
+   template
+   void foo() {
+ $0^crash({.$1^x = $2^T()});
+   }
+)cpp",
+"0: targets = {crash}\n"
+"1: targets = {}\n"
+"2: targets = {T}\n"
+  },
+};
 
   for (const auto &C : Cases) {
 llvm::StringRef ExpectedCode = C.first;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -714,10 +714,12 @@
   for (const DesignatedInitExpr::Designator &D : DIE->designators()) {
 if (!D.isFieldDesignator())
   continue;
-Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
-D.getFieldLoc(),
-/*IsDecl=*/false,
-{D.getField()}});
+
+llvm::SmallVector Targets;
+if (D.getField())
+  Targets.push_back(D.getField());
+Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(), D.getFieldLoc(),
+/*IsDecl=*/false, std::move(Targets)});
   }
 }
   };


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -1273,7 +1273,20 @@
 "5: targets = {Bar}\n"
 "6: targets = {bar}, decl\n"
 "7: targets = {foo()::Bar::Foo}\n"
-"8: targets = {foo()::Baz::Field}\n"}};
+"8: targets = {foo()::Baz::Field}\n"},
+  {R"cpp(
+   template
+   void crash(T);
+   template
+   void foo() {
+ $0^crash({.$1^x = $2^T()});
+   }
+)cpp",
+"0: targets = {crash}\n"
+"1: targets = {}\n"
+"2: targets = {T}\n"
+  },
+};
 
   for (const auto &C : Cases) {
 llvm::StringRef ExpectedCode = C.first;
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -714,10 +714,12 @@
   for (const DesignatedInitExpr::Designator &D : DIE->designators()) {
 if (!D.isFieldDesignator())
   continue;
-Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
-D.getFieldLoc(),
-/*IsDecl=*/false,
-{D.getField()}});
+
+llvm::SmallVector Targets;
+if (D.getField())
+  Targets.push_back(D.getField());
+Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(), D.getFieldLoc(),
+/*IsDecl=*/false, std::move(Targets)});
   }
 }
   };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77721: [ASTImporter] Add support for importing fixed point literals

2020-04-15 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

Looks good! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77721



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


[PATCH] D76932: [AIX] emit .extern and .weak directive linkage

2020-04-15 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:441
+  case GlobalValue::ExternalWeakLinkage:
+if (TM.getTargetTriple().isOSBinFormatXCOFF()) {
+  OutStreamer->emitSymbolAttribute(GVSym, MCSA_Weak);

Maybe an assert on isOSBinFormatXCOFF is better?
If not, could we remove the else and llvm_unreachable to let it fall through? 
Will it have warnings?
Or we could just only remove `else` here.



Comment at: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1496
+
+MCSymbol *Name = getSymbol(&F);
+if (TM.getTargetTriple().isOSBinFormatXCOFF() && !F.isIntrinsic()) {

This block of code and D78045 will have conflict. One of us will need to rebase.



Comment at: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp:1641
 
   // External global variables are already handled.
+  if (GV->isDeclaration()) {

This comment does not apply any more.



Comment at: llvm/test/CodeGen/PowerPC/aix-extern-weak.ll:10
+; RUN: llvm-readobj  --symbols %t.o | FileCheck --check-prefix=CHECKSYM %s
+
+@foo_ext_weak_p = global void (...)* bitcast (void ()* @foo_ext_weak_ref to 
void (...)*)

Do we care to check the 64 bit object generation error here and for other test 
cases that are applicable?



Comment at: llvm/test/CodeGen/PowerPC/aix-extern-weak.ll:29
+; COMMON-NEXT:.globl   .main
+; COMMON-NEXT:   .align4
+; COMMON-NEXT:   .csect main[DS]

Could we align the assembly output in aix-extern-weak.ll, aix-extern.ll, 
aix-weak.ll?



Comment at: llvm/test/CodeGen/PowerPC/aix-extern-weak.ll:48
+; COMMON-NEXT:.weak   b_w[UA]
+; COMMON-NEXT:.weak   foo_ext_weak_ref[DS]
+; COMMON-NEXT:.weak   .foo_ext_weak

If the plan is not emit function entry point if it's not necessary, let's 
CHECK-NOT that. 



Comment at: llvm/test/CodeGen/PowerPC/aix-extern.ll:14
+
+; Function Attrs: noinline nounwind optnone
+define void @foo() #0 {

jasonliu wrote:
> nit: Function Attrs and `#0` could be removed
This comment is not addressed. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76932



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


[PATCH] D78120: [analyzer][StreamChecker] Don't make StreamTestChecker depend on StreamChecker for the time being

2020-04-15 Thread Balázs Kéri via Phabricator via cfe-commits
balazske accepted this revision.
balazske added a comment.
This revision is now accepted and ready to land.

LGTM
But a better approach can be to make a new kind of dependency. (Or split the 
StreamChecker.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78120



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


[PATCH] D77866: [analyzer][CallAndMessage] Add checker options for each bug category

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

In D77866#1983690 , @martong wrote:

> In D77866#1983685 , @martong wrote:
>
> > Looks good to me!
>
>
> Just take care of the failures you have with harbourmaster, there seem to be 
> CSA failures with the bot!


That should go away after fixing D75430#inline-708353 
. Sharp eyes though, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77866



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


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

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

In D77229#1983693 , 
@baloghadamsoftware wrote:

> I am trying to understand where I have to implement this but I have some 
> problems. The first is that when a function is not inlined it does not have a 
> `StackFrameContext`. What to use instead? I usually try to use the caller's 
> stack frame but it seems to be incorrect and causes assertions. Or should we 
> create a stack frame for non-inlined functions as well?


Even if the function is inlined, we need the stack frame context before it's 
actually created (in fact, it's needed even before we construct the arguments). 
The whole point of D49443  was to learn how to 
pro-actively create stack frame contexts and lifetime-extend it back in time so 
that they were live until the call starts (where they actually become live). 
This part doesn't really change in your case.

> For using the same `FunctionDecl`: would it help if we always use the "first" 
> `Decl` in the chain?

The word you're looking for is "canonical decl". The difficulty is not finding 
such decl but it's making sure it's used consistently, otherwise you won't be 
able to look up the parameter.


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

https://reviews.llvm.org/D77229



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


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

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

LGTM. The objective of the change is to simplify offline compilation. We want 
to avoid asking users to add -D if a proper macro can be inferred from triple 
and cpu. Ideally, users only need to specify triple and cpu with clang driver. 
In case users want to override the default macros for the triple, they can 
always override them by -D or -U in command line.

The question is whether the default value of the macro is proper. To me this 
change maintained the old behavior for spir and other targets and the default 
value seems fine for amdgcn.


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

https://reviews.llvm.org/D77923



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


[PATCH] D78172: [www] Update make_cxx_dr_status for v10; regenerate cxx_dr_status.html

2020-04-15 Thread Hubert Tong via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa73a81dce5bc: [www] Update make_cxx_dr_status for v10; 
regenerate cxx_dr_status.html (authored by hubert.reinterpretcast).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78172

Files:
  clang/www/cxx_dr_status.html
  clang/www/make_cxx_dr_status

Index: clang/www/make_cxx_dr_status
===
--- clang/www/make_cxx_dr_status
+++ clang/www/make_cxx_dr_status
@@ -93,7 +93,7 @@
 Available in Clang?
   '''
 
-latest_release = 9
+latest_release = 10
 
 def availability(issue):
   status = status_map.get(issue, 'unknown')
Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -2645,7 +2645,7 @@
 https://wg21.link/cwg434";>434
 NAD
 Unclear suppression of standard conversions while binding reference to lvalue
-Superseded by 2352
+Superseded by 2352
   
   
 https://wg21.link/cwg435";>435
@@ -3527,7 +3527,7 @@
   
   
 https://wg21.link/cwg581";>581
-DR
+DRWP
 Can a templated constructor be explicitly instantiated or specialized?
 Unknown
   
@@ -4133,7 +4133,7 @@
   
   
 https://wg21.link/cwg682";>682
-tentatively ready
+DRWP
 Missing description of lookup of template aliases
 Unknown
   
@@ -9537,11 +9537,11 @@
 User-defined literals and extended integer types
 Not resolved
   
-  
+  
 https://wg21.link/cwg1621";>1621
-drafting
+DRWP
 Member initializers in anonymous unions
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg1622";>1622
@@ -11243,7 +11243,7 @@
   
   
 https://wg21.link/cwg1905";>1905
-MAD
+NAD
 Dependent types and injected-class-names
 Unknown
   
@@ -11435,13 +11435,13 @@
   
   
 https://wg21.link/cwg1937";>1937
-DR
+DRWP
 Incomplete specification of function pointer from lambda
 Unknown
   
   
 https://wg21.link/cwg1938";>1938
-DR
+DRWP
 Should hosted/freestanding be implementation-defined?
 Unknown
   
@@ -11933,7 +11933,7 @@
   
   
 https://wg21.link/cwg2020";>2020
-DR
+DRWP
 Inadequate description of odr-use of implicitly-invoked functions
 Unknown
   
@@ -12119,7 +12119,7 @@
   
   
 https://wg21.link/cwg2051";>2051
-DR
+DRWP
 Simplifying alias rules
 Unknown
   
@@ -12129,11 +12129,11 @@
 Template argument deduction vs overloaded operators
 Unknown
   
-  
+  
 https://wg21.link/cwg2053";>2053
-drafting
+DR
 auto in non-generic lambdas
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg2054";>2054
@@ -12311,7 +12311,7 @@
   
   
 https://wg21.link/cwg2083";>2083
-DR
+DRWP
 Incorrect cases of odr-use
 Partial
   
@@ -12431,7 +12431,7 @@
   
   
 https://wg21.link/cwg2103";>2103
-DR
+DRWP
 Lvalue-to-rvalue conversion is irrelevant in odr-use of a reference
 Yes
   
@@ -12567,11 +12567,11 @@
 Copy elision and comma operator
 Extension
   
-  
+  
 https://wg21.link/cwg2126";>2126
-drafting
+DRWP
 Lifetime-extended temporaries in constant expressions
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg2127";>2127
@@ -12833,7 +12833,7 @@
   
   
 https://wg21.link/cwg2170";>2170
-DR
+DRWP
 Unclear definition of odr-use for arrays
 Clang 9
   
@@ -13055,7 +13055,7 @@
   
   
 https://wg21.link/cwg2207";>2207
-tentatively ready
+DRWP
 Alignment of allocation function return value
 Unknown
   
@@ -13349,13 +13349,13 @@
   
   
 https://wg21.link/cwg2256";>2256
-DR
+DRWP
 Lifetime of trivially-destructible objects
 Unknown
   
   
 https://wg21.link/cwg2257";>2257
-DR
+DRWP
 Lifetime extension of references vs exceptions
 Unknown
   
@@ -13409,13 +13409,13 @@
   
   
 https://wg21.link/cwg2266";>2266
-DR
+DRWP
 Has dependent type vs is type-dependent
 Unknown
   
   
 https://wg21.link/cwg2267";>2267
-DR
+DRWP
 Copy-initialization of temporary in reference direct-initialization
 Unknown
   
@@ -13481,7 +13481,7 @@
   
   
 https://wg21.link/cwg2278";>2278
-DR
+DRWP
 Copy elision in constant expressions reconsidered
 Unknown
   
@@ -13491,11 +13491,11 @@
 Multiple attribute-specifiers in one attribute-list
 Unknown
   
-  
+  
 https://wg21.link/cwg2280";>2280
-review
+DRWP
 Matching a usual deallocation function with placement new
-Not resolved
+Unknown
   
   
 https://wg21.link/cwg2281";>2281
@@ -13503,11 +13503,11 @@
 Consistency of aligned operator delete replacement
 Not resolved
   
-  
+  
 https://wg21.link/cwg2282";>2282
-drafting
+ 

[PATCH] D71775: [ThreadPool] On Windows, extend usage to all CPU sockets and all NUMA groups

2020-04-15 Thread John Brawn via Phabricator via cfe-commits
john.brawn added a comment.
Herald added subscribers: frgossen, grosul1.
Herald added a reviewer: MaskRay.

With this patch the Threading.PhysicalConcurrency unit test fails when run with 
an affinity less than the number of physical cpus. I've raised 
https://bugs.llvm.org/show_bug.cgi?id=45556.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71775



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


[clang] 789215d - [ASTImporter] Add support for importing fixed point literals

2020-04-15 Thread via cfe-commits

Author: Vince Bridgers
Date: 2020-04-15T10:36:44-05:00
New Revision: 789215dc0db174c9fdd273436fdd60d8289a9fc0

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

LOG: [ASTImporter] Add support for importing fixed point literals

Summary:
This patch adds support for importing fixed point literals, following
up to https://reviews.llvm.org/D46915 specifically for importing AST.

Reviewers: martong, leonardchan, ebevhan, a.sidorin, shafik

Reviewed By: martong

Subscribers: balazske, rnkovacs, teemperor, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/AST/ASTImporter.cpp
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/unittests/AST/ASTImporterFixtures.h
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 070c38295ba7..ce702bc44edd 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2271,6 +2271,10 @@ extern const internal::VariadicDynCastAllOfMatcher
 extern const internal::VariadicDynCastAllOfMatcher
 imaginaryLiteral;
 
+/// Matches fixed point literals
+extern const internal::VariadicDynCastAllOfMatcher
+fixedPointLiteral;
+
 /// Matches user defined literal operator call.
 ///
 /// Example match: "foo"_suffix

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 73622f22bcec..3a499c7f0dff 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -588,6 +588,7 @@ namespace clang {
 ExpectedStmt VisitIntegerLiteral(IntegerLiteral *E);
 ExpectedStmt VisitFloatingLiteral(FloatingLiteral *E);
 ExpectedStmt VisitImaginaryLiteral(ImaginaryLiteral *E);
+ExpectedStmt VisitFixedPointLiteral(FixedPointLiteral *E);
 ExpectedStmt VisitCharacterLiteral(CharacterLiteral *E);
 ExpectedStmt VisitStringLiteral(StringLiteral *E);
 ExpectedStmt VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
@@ -6503,6 +6504,20 @@ ExpectedStmt 
ASTNodeImporter::VisitImaginaryLiteral(ImaginaryLiteral *E) {
   *ToSubExprOrErr, *ToTypeOrErr);
 }
 
+ExpectedStmt ASTNodeImporter::VisitFixedPointLiteral(FixedPointLiteral *E) {
+  auto ToTypeOrErr = import(E->getType());
+  if (!ToTypeOrErr)
+return ToTypeOrErr.takeError();
+
+  ExpectedSLoc ToLocationOrErr = import(E->getLocation());
+  if (!ToLocationOrErr)
+return ToLocationOrErr.takeError();
+
+  return new (Importer.getToContext()) FixedPointLiteral(
+  Importer.getToContext(), E->getValue(), *ToTypeOrErr, *ToLocationOrErr,
+  Importer.getToContext().getFixedPointScale(*ToTypeOrErr));
+}
+
 ExpectedStmt ASTNodeImporter::VisitCharacterLiteral(CharacterLiteral *E) {
   ExpectedType ToTypeOrErr = import(E->getType());
   if (!ToTypeOrErr)

diff  --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index c20e8422be46..40bd439f79fa 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -804,6 +804,8 @@ const internal::VariadicDynCastAllOfMatcher
 integerLiteral;
 const internal::VariadicDynCastAllOfMatcher 
floatLiteral;
 const internal::VariadicDynCastAllOfMatcher 
imaginaryLiteral;
+const internal::VariadicDynCastAllOfMatcher
+fixedPointLiteral;
 const internal::VariadicDynCastAllOfMatcher
 userDefinedLiteral;
 const internal::VariadicDynCastAllOfMatcher

diff  --git a/clang/unittests/AST/ASTImporterFixtures.h 
b/clang/unittests/AST/ASTImporterFixtures.h
index 34cef16712d7..05d789ffcaf6 100644
--- a/clang/unittests/AST/ASTImporterFixtures.h
+++ b/clang/unittests/AST/ASTImporterFixtures.h
@@ -66,10 +66,13 @@ class CompilerOptionSpecificTest : public ::testing::Test {
   }
 };
 
-const auto DefaultTestValuesForRunOptions = ::testing::Values(
+const auto DefaultTestArrayForRunOptions = std::array{
 ArgVector(), ArgVector{"-fdelayed-template-parsing"},
 ArgVector{"-fms-compatibility"},
-ArgVector{"-fdelayed-template-parsing", "-fms-compatibility"});
+ArgVector{"-fdelayed-template-parsing", "-fms-compatibility"}};
+
+const auto DefaultTestValuesForRunOptions =
+::testing::ValuesIn(DefaultTestArrayForRunOptions);
 
 // This class provides generic methods to write tests which can check internal
 // attributes of AST nodes like getPreviousDecl(), isVirtual(), etc. Also,

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index ea4a49a1c5cb..9f35a86e2937 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -255,6 +255,7 @@ static co

[PATCH] D78000: [ASTImporter] Fix handling of not defined FromRecord in ImportContext(...)

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

Looks okay to me (other than the redundant import code that I have a comment 
about).

> Also this seems to be testable via a Clang unit test, so I think this patch 
> should have one.

Yeah, would be nice to have a Clang unit test. I believe we have the 
infrastructure for that in place. E.g. in `LLDBLookupTest` we have an lldb 
specific setup, that could be a good starting point.




Comment at: clang/lib/AST/ASTImporter.cpp:8173
+  // If a RecordDecl has base classes they won't be imported and we will
+  // be missing anything that we inherit from those bases.
+  if (FromRecord->hasExternalLexicalStorage() &&

teemperor wrote:
> I'm not sure how it can be that ASTImporter::CompleteDecl starts but never 
> finishes the decl as it does both things at once unconditionally?
> ```
> lang=c++
>   TD->startDefinition();
>   TD->setCompleteDefinition(true);
> ```
> 
> FWIW, this whole comment could just be `Ask the external source if this is 
> actually a complete record that just hasn't been completed yet` or something 
> like this. I think if we reach this point then it makes a complete sense to 
> ask the external source for more info. The explanation about the base classes 
> seems to be just a smaller detail of the whole picture here.
> Ask the external source if this is actually a complete record that just 
> hasn't been completed yet

FWIW this seems to be a recurring pattern, so maybe it would be worth to do 
this not just with `RecordDecl`s but with other kind of decls. E.g. an 
`EnumDecl` could have an external source and not  completed, couldn't it?



Comment at: clang/lib/AST/ASTImporter.cpp:8179
+
+  if (FromRecord->isCompleteDefinition())
+if (Error Err = ASTNodeImporter(*this).ImportDefinition(

We could merge this `if` with the `else if` at line 8164, because their body is 
exactly the same.
But to do that, we should move the external storage query and type completion 
above the enclosing `if` (above line 8162 and just after line 8161).


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

https://reviews.llvm.org/D78000



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


[PATCH] D78213: [libclang]: visit BindingDecl in DecompositionDecl

2020-04-15 Thread Milian Wolff via Phabricator via cfe-commits
milianw created this revision.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.
milianw added reviewers: nik, yvvan.

This makes the BindingDecl accessible to consumers of libclang
as CXCursor_UnexposedDecl where previously these AST nodes were
not visited at all from the libclang API.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78213

Files:
  clang/test/Index/cxx17-structured-binding.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CursorVisitor.h


Index: clang/tools/libclang/CursorVisitor.h
===
--- clang/tools/libclang/CursorVisitor.h
+++ clang/tools/libclang/CursorVisitor.h
@@ -241,6 +241,7 @@
   bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
   bool VisitStaticAssertDecl(StaticAssertDecl *D);
   bool VisitFriendDecl(FriendDecl *D);
+  bool VisitDecompositionDecl(DecompositionDecl *D);
 
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1294,6 +1294,14 @@
   return false;
 }
 
+bool CursorVisitor::VisitDecompositionDecl(DecompositionDecl *D) {
+  for (auto *B : D->bindings()) {
+if (Visit(MakeCXCursor(B, TU, RegionOfInterest)))
+  return true;
+  }
+  return VisitVarDecl(D);
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Name.getName().getNameKind()) {
   case clang::DeclarationName::Identifier:
Index: clang/test/Index/cxx17-structured-binding.cpp
===
--- /dev/null
+++ clang/test/Index/cxx17-structured-binding.cpp
@@ -0,0 +1,25 @@
+// Test is line- and column-sensitive; see below.
+int main() {
+  int a[2] = {1, 2};
+  auto [x, y] = a;
+}
+
+// RUN: c-index-test -test-load-source all -std=c++17 %s | FileCheck 
-check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx17-structured-binding.cpp:2:5: FunctionDecl=main:2:5 
(Definition) Extent=[2:1 - 5:2]
+// CHECK-LOAD: cxx17-structured-binding.cpp:2:12: CompoundStmt= Extent=[2:12 - 
5:2]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:3: DeclStmt= Extent=[3:3 - 3:21]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:7: VarDecl=a:3:7 (Definition) 
Extent=[3:3 - 3:20]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:9: IntegerLiteral= Extent=[3:9 - 
3:10]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:14: InitListExpr= Extent=[3:14 - 
3:20]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:15: IntegerLiteral= Extent=[3:15 
- 3:16]
+// CHECK-LOAD: cxx17-structured-binding.cpp:3:18: IntegerLiteral= Extent=[3:18 
- 3:19]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:3: DeclStmt= Extent=[4:3 - 4:19]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:8: UnexposedDecl=[x, y]:4:8 
(Definition) Extent=[4:3 - 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:9: UnexposedDecl=x:4:9 
(Definition) Extent=[4:9 - 4:10]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:12: UnexposedDecl=y:4:12 
(Definition) Extent=[4:12 - 4:13]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: UnexposedExpr= Extent=[4:17 
- 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: DeclRefExpr=a:3:7 
Extent=[4:17 - 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: UnexposedExpr= Extent=[4:17 
- 4:9]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: ArraySubscriptExpr= 
Extent=[4:17 - 4:9]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: UnexposedExpr=a:3:7 
Extent=[4:17 - 4:18]
+// CHECK-LOAD: cxx17-structured-binding.cpp:4:17: DeclRefExpr=a:3:7 
Extent=[4:17 - 4:18]


Index: clang/tools/libclang/CursorVisitor.h
===
--- clang/tools/libclang/CursorVisitor.h
+++ clang/tools/libclang/CursorVisitor.h
@@ -241,6 +241,7 @@
   bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
   bool VisitStaticAssertDecl(StaticAssertDecl *D);
   bool VisitFriendDecl(FriendDecl *D);
+  bool VisitDecompositionDecl(DecompositionDecl *D);
 
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1294,6 +1294,14 @@
   return false;
 }
 
+bool CursorVisitor::VisitDecompositionDecl(DecompositionDecl *D) {
+  for (auto *B : D->bindings()) {
+if (Visit(MakeCXCursor(B, TU, RegionOfInterest)))
+  return true;
+  }
+  return VisitVarDecl(D);
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Name.getName().getNameKind()) {
   case clang::DeclarationName::Identifier:
Index: clang/test/Index/cxx17-structured-binding.cpp
===
--- /dev/null
+++ clang/test/Index/cxx17-structu

[PATCH] D78214: [libclang]: visit C++17 if init statements

2020-04-15 Thread Milian Wolff via Phabricator via cfe-commits
milianw created this revision.
milianw added reviewers: nik, yvvan.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

This makes the previously unaccessible AST nodes for C++17 "if with
init statements" accessible to consumers of libclang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78214

Files:
  clang/test/Index/cxx17-if-with-initializer.cpp
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2669,6 +2669,7 @@
   AddStmt(If->getElse());
   AddStmt(If->getThen());
   AddStmt(If->getCond());
+  AddStmt(If->getInit());
   AddDecl(If->getConditionVariable());
 }
 void EnqueueVisitor::VisitInitListExpr(const InitListExpr *IE) {
Index: clang/test/Index/cxx17-if-with-initializer.cpp
===
--- /dev/null
+++ clang/test/Index/cxx17-if-with-initializer.cpp
@@ -0,0 +1,17 @@
+// Test is line- and column-sensitive; see below.
+
+void foo() {
+  if (bool bar = true; bar) {
+  }
+}
+
+// RUN: c-index-test -test-load-source all -std=c++17 %s | FileCheck 
-check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:6: FunctionDecl=foo:3:6 
(Definition) Extent=[3:1 - 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:12: CompoundStmt= Extent=[3:12 
- 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:3: IfStmt= Extent=[4:3 - 5:4]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:7: DeclStmt= Extent=[4:7 - 4:23]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:12: VarDecl=bar:4:12 
(Definition) Extent=[4:7 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:18: CXXBoolLiteralExpr= 
Extent=[4:18 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: UnexposedExpr=bar:4:12 
Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: DeclRefExpr=bar:4:12 
Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:29: CompoundStmt= Extent=[4:29 
- 5:4]


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2669,6 +2669,7 @@
   AddStmt(If->getElse());
   AddStmt(If->getThen());
   AddStmt(If->getCond());
+  AddStmt(If->getInit());
   AddDecl(If->getConditionVariable());
 }
 void EnqueueVisitor::VisitInitListExpr(const InitListExpr *IE) {
Index: clang/test/Index/cxx17-if-with-initializer.cpp
===
--- /dev/null
+++ clang/test/Index/cxx17-if-with-initializer.cpp
@@ -0,0 +1,17 @@
+// Test is line- and column-sensitive; see below.
+
+void foo() {
+  if (bool bar = true; bar) {
+  }
+}
+
+// RUN: c-index-test -test-load-source all -std=c++17 %s | FileCheck -check-prefix=CHECK-LOAD %s
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:6: FunctionDecl=foo:3:6 (Definition) Extent=[3:1 - 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:3:12: CompoundStmt= Extent=[3:12 - 6:2]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:3: IfStmt= Extent=[4:3 - 5:4]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:7: DeclStmt= Extent=[4:7 - 4:23]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:12: VarDecl=bar:4:12 (Definition) Extent=[4:7 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:18: CXXBoolLiteralExpr= Extent=[4:18 - 4:22]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: UnexposedExpr=bar:4:12 Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:24: DeclRefExpr=bar:4:12 Extent=[4:24 - 4:27]
+// CHECK-LOAD: cxx17-if-with-initializer.cpp:4:29: CompoundStmt= Extent=[4:29 - 5:4]
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-04-15 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Breaks Windows due to slashiness in the test: 
http://45.33.8.238/win/12984/step_8.txt

Please take a look, and revert if it takes a while to investigate.

(I'd find the diag easier to read without the "the": just "is disabled in")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184



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


  1   2   3   >