[PATCH] D70850: [Clang-Tidy] Quick fix for bug in bugprone-macro-parentheses 43804

2019-12-01 Thread Balogh, Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG497a754adeca: [Clang-Tidy] Quick fix for bug in 
bugprone-macro-parentheses 43804 (authored by baloghadamsoftware).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70850

Files:
  clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
@@ -43,6 +43,7 @@
 #define GOOD30(args...)   std::cout << args;
 #define GOOD31(X) A*X=2
 #define GOOD32(X) std::vector
+#define GOOD33(x) if (!a__##x) a_##x = (#x)
 
 // These are allowed for now..
 #define MAYBE1*12.34
Index: clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
@@ -54,7 +54,7 @@
 /// Is given TokenKind a keyword?
 static bool isKeyword(const Token ) {
   // FIXME: better matching of keywords to avoid false positives.
-  return T.isOneOf(tok::kw_case, tok::kw_const, tok::kw_struct);
+  return T.isOneOf(tok::kw_if, tok::kw_case, tok::kw_const, tok::kw_struct);
 }
 
 /// Warning is written when one of these operators are not within parentheses.


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
@@ -43,6 +43,7 @@
 #define GOOD30(args...)   std::cout << args;
 #define GOOD31(X) A*X=2
 #define GOOD32(X) std::vector
+#define GOOD33(x) if (!a__##x) a_##x = (#x)
 
 // These are allowed for now..
 #define MAYBE1*12.34
Index: clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
@@ -54,7 +54,7 @@
 /// Is given TokenKind a keyword?
 static bool isKeyword(const Token ) {
   // FIXME: better matching of keywords to avoid false positives.
-  return T.isOneOf(tok::kw_case, tok::kw_const, tok::kw_struct);
+  return T.isOneOf(tok::kw_if, tok::kw_case, tok::kw_const, tok::kw_struct);
 }
 
 /// Warning is written when one of these operators are not within parentheses.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 497a754 - [Clang-Tidy] Quick fix for bug in bugprone-macro-parentheses 43804

2019-12-01 Thread Adam Balogh via cfe-commits

Author: Adam Balogh
Date: 2019-12-02T08:50:51+01:00
New Revision: 497a754adeca67196c12a936d09c12d6803f99de

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

LOG: [Clang-Tidy] Quick fix for bug in bugprone-macro-parentheses 43804

Applying parentheses for statement leads to compilation error. Bug
[[ 43804 | https://bugs.llvm.org/show_bug.cgi?id=43804 ]] is a
compilation error suggested by a wrong fix of this checker. This
patch is a quick fix for this issue.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
index 7ca5c1e3454b..8d4366b51a3e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MacroParenthesesCheck.cpp
@@ -54,7 +54,7 @@ static bool isSurroundedRight(const Token ) {
 /// Is given TokenKind a keyword?
 static bool isKeyword(const Token ) {
   // FIXME: better matching of keywords to avoid false positives.
-  return T.isOneOf(tok::kw_case, tok::kw_const, tok::kw_struct);
+  return T.isOneOf(tok::kw_if, tok::kw_case, tok::kw_const, tok::kw_struct);
 }
 
 /// Warning is written when one of these operators are not within parentheses.

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
index 2cc45e83b203..8d128352e789 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp
@@ -43,6 +43,7 @@
 #define GOOD30(args...)   std::cout << args;
 #define GOOD31(X) A*X=2
 #define GOOD32(X) std::vector
+#define GOOD33(x) if (!a__##x) a_##x = (#x)
 
 // These are allowed for now..
 #define MAYBE1*12.34



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


[PATCH] D70850: [Clang-Tidy] Quick fix for bug in bugprone-macro-parentheses 43804

2019-12-01 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware added a comment.

In D70850#1764469 , @aaron.ballman 
wrote:

> LGTM, but we may have other things to test (or bugs to fix) here.


Oh yes, this check seems a bit incomplete, more statements are missing, but 
this particular issue was a showstopper in our internal CI loop. (We had to 
disable this check because of this.)


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70850



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


[PATCH] D69878: Consoldiate internal denormal flushing controls

2019-12-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm marked an inline comment as done.
arsenm added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:1775
-if (getLangOpts().OpenCL)
-  FuncAttrs.addAttribute("denorms-are-zero",
- llvm::toStringRef(CodeGenOpts.FlushDenorm));

Anastasia wrote:
> arsenm wrote:
> > Anastasia wrote:
> > > so where would `denorms-are-zero` be emitted now (in case some out of 
> > > tree implementations rely on this)?
> > Rely on in what sense? Do you have a concrete use of this?
> Since it has been emitted before in the module potentially some LLVM 
> implementations could be using that attribute?
I'm disinclined to leave things around just in case some unknown user might 
have been using them. We've dropped attributes like this before (I think the 
less-precise-fp-mad one for disuse). This also isn't needed for correctness, so 
it should be pretty safe to drop


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

https://reviews.llvm.org/D69878



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


[Diffusion] rG825235c140e7: Revert "[Sema] Use the canonical type in function isVector"

2019-12-01 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

The test is failing because `float16x4_t` is defined as a vector of `__fp16` in 
arm_neon.h and Sema promotes vectors of `__fp16` to vectors of float  since 
`__fp16` is a storage-only type. The test used to pass because of a bug in 
function `isVector`, which was fixed in the commit that was reverted.

  typedef __fp16 float16_t;
  typedef __attribute__((neon_vector_type(4))) float16_t float16x4_t;

For example,  in `vneg_f16`, `__p0` is promoted to a vector of float before 
it's negated.

  __ai float16x4_t vneg_f16(float16x4_t __p0) {
float16x4_t __ret;
__ret = -__p0;
return __ret;
  }

Is it correct to use `__fp16` for the element type of `float16x4_t`?


BRANCHES
  master

Users:
  ahatanak (Author)

https://reviews.llvm.org/rG825235c140e7



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


[PATCH] D69785: [OpenMP] Introduce the OpenMP-IR-Builder

2019-12-01 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

In D69785#1763317 , @jdoerfert wrote:

> I'm confused. Was this a review? I'm waiting for a decision here so we can 
> move on and improve on this instead of me modifying it inp-lace two comments 
> at a time.


Explicitly marked as accepted. Patch has looked good for a while and even has 
other people building on it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69785



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


[clang] ae54845 - Revert "[clang][modules] Add support for merging lifetime-extended temporaries"

2019-12-01 Thread via cfe-commits

Author: Tyker
Date: 2019-12-01T22:38:31+01:00
New Revision: ae5484540f15bcbcb0de9558e66b0217ab8473ed

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

LOG: Revert "[clang][modules] Add support for merging lifetime-extended 
temporaries"

This reverts commit a3cbe1a202df6ec8e23bd55e14db254e4bc33021.

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Serialization/ASTReader.h
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/a.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/b.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/c.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/module.modulemap
clang/test/Modules/merge-lifetime-extended-temporary.cpp



diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 0f2018fb9e8c..63d67bd3f55b 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3041,9 +3041,7 @@ class NamespaceAliasDecl : public NamedDecl,
 
 /// Implicit declaration of a temporary that was materialized by
 /// a MaterializeTemporaryExpr and lifetime-extended by a declaration
-class LifetimeExtendedTemporaryDecl final
-: public Decl,
-  public Mergeable {
+class LifetimeExtendedTemporaryDecl final : public Decl {
   friend class MaterializeTemporaryExpr;
   friend class ASTDeclReader;
 

diff  --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index d293ea190aa4..0ff5a614a864 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -346,8 +346,6 @@ class TextNodeDumper
   void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
   void VisitBlockDecl(const BlockDecl *D);
   void VisitConceptDecl(const ConceptDecl *D);
-  void
-  VisitLifetimeExtendedTemporaryDecl(const LifetimeExtendedTemporaryDecl *D);
 };
 
 } // namespace clang

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index b6dae68b3413..f0b5e9933823 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -551,14 +551,6 @@ class ASTReader
   llvm::DenseMap>
 AnonymousDeclarationsForMerging;
 
-  /// Key used to identify LifetimeExtendedTemporaryDecl for merging,
-  /// containing the lifetime-extending declaration and the mangling number.
-  using LETemporaryKey = std::pair;
-
-  /// Map of already deserialiazed temporaries.
-  llvm::DenseMap
-  LETemporaryForMerging;
-
   struct FileDeclsInfo {
 ModuleFile *Mod = nullptr;
 ArrayRef Decls;

diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index 561c76a45cbc..0ff95213118f 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1338,17 +1338,6 @@ void TextNodeDumper::VisitFunctionDecl(const 
FunctionDecl *D) {
 OS << " <>>";
 }
 
-void TextNodeDumper::VisitLifetimeExtendedTemporaryDecl(
-const LifetimeExtendedTemporaryDecl *D) {
-  OS << " extended by ";
-  dumpBareDeclRef(D->getExtendingDecl());
-  OS << " mangling ";
-  {
-ColorScope Color(OS, ShowColors, ValueColor);
-OS << D->getManglingNumber();
-  }
-}
-
 void TextNodeDumper::VisitFieldDecl(const FieldDecl *D) {
   dumpName(D);
   dumpType(D->getType());

diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 3f7a1ed7fd5c..8991a39a7067 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -424,8 +424,6 @@ namespace clang {
 template
 void mergeMergeable(Mergeable *D);
 
-void mergeMergeable(LifetimeExtendedTemporaryDecl *D);
-
 void mergeTemplatePattern(RedeclarableTemplateDecl *D,
   RedeclarableTemplateDecl *Existing,
   DeclID DsID, bool IsKeyDecl);
@@ -2360,7 +2358,6 @@ void ASTDeclReader::VisitLifetimeExtendedTemporaryDecl(
   if (Record.readInt())
 D->Value = new (D->getASTContext()) APValue(Record.readAPValue());
   D->ManglingNumber = Record.readInt();
-  mergeMergeable(D);
 }
 
 std::pair
@@ -2558,25 +2555,6 @@ static bool allowODRLikeMergeInC(NamedDecl *ND) {
   return false;
 }
 
-/// Attempts to merge LifetimeExtendedTemporaryDecl with
-/// identical class definitions from two 
diff erent modules.
-void ASTDeclReader::mergeMergeable(LifetimeExtendedTemporaryDecl *D) {
-  // If modules are not available, there is no reason to perform this merge.
-  if 

[clang] a3cbe1a - [clang][modules] Add support for merging lifetime-extended temporaries

2019-12-01 Thread via cfe-commits

Author: Tyker
Date: 2019-12-01T21:28:48+01:00
New Revision: a3cbe1a202df6ec8e23bd55e14db254e4bc33021

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

LOG: [clang][modules] Add support for merging lifetime-extended temporaries

Summary: Add support for merging lifetime-extended temporaries

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: xbolva00, cfe-commits

Tags: #clang

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

Added: 
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/a.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/b.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/c.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/module.modulemap
clang/test/Modules/merge-lifetime-extended-temporary.cpp

Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Serialization/ASTReader.h
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 63d67bd3f55b..0f2018fb9e8c 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3041,7 +3041,9 @@ class NamespaceAliasDecl : public NamedDecl,
 
 /// Implicit declaration of a temporary that was materialized by
 /// a MaterializeTemporaryExpr and lifetime-extended by a declaration
-class LifetimeExtendedTemporaryDecl final : public Decl {
+class LifetimeExtendedTemporaryDecl final
+: public Decl,
+  public Mergeable {
   friend class MaterializeTemporaryExpr;
   friend class ASTDeclReader;
 

diff  --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index 0ff5a614a864..d293ea190aa4 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -346,6 +346,8 @@ class TextNodeDumper
   void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
   void VisitBlockDecl(const BlockDecl *D);
   void VisitConceptDecl(const ConceptDecl *D);
+  void
+  VisitLifetimeExtendedTemporaryDecl(const LifetimeExtendedTemporaryDecl *D);
 };
 
 } // namespace clang

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index f0b5e9933823..b6dae68b3413 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -551,6 +551,14 @@ class ASTReader
   llvm::DenseMap>
 AnonymousDeclarationsForMerging;
 
+  /// Key used to identify LifetimeExtendedTemporaryDecl for merging,
+  /// containing the lifetime-extending declaration and the mangling number.
+  using LETemporaryKey = std::pair;
+
+  /// Map of already deserialiazed temporaries.
+  llvm::DenseMap
+  LETemporaryForMerging;
+
   struct FileDeclsInfo {
 ModuleFile *Mod = nullptr;
 ArrayRef Decls;

diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index 0ff95213118f..561c76a45cbc 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1338,6 +1338,17 @@ void TextNodeDumper::VisitFunctionDecl(const 
FunctionDecl *D) {
 OS << " <>>";
 }
 
+void TextNodeDumper::VisitLifetimeExtendedTemporaryDecl(
+const LifetimeExtendedTemporaryDecl *D) {
+  OS << " extended by ";
+  dumpBareDeclRef(D->getExtendingDecl());
+  OS << " mangling ";
+  {
+ColorScope Color(OS, ShowColors, ValueColor);
+OS << D->getManglingNumber();
+  }
+}
+
 void TextNodeDumper::VisitFieldDecl(const FieldDecl *D) {
   dumpName(D);
   dumpType(D->getType());

diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 8991a39a7067..3f7a1ed7fd5c 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -424,6 +424,8 @@ namespace clang {
 template
 void mergeMergeable(Mergeable *D);
 
+void mergeMergeable(LifetimeExtendedTemporaryDecl *D);
+
 void mergeTemplatePattern(RedeclarableTemplateDecl *D,
   RedeclarableTemplateDecl *Existing,
   DeclID DsID, bool IsKeyDecl);
@@ -2358,6 +2360,7 @@ void ASTDeclReader::VisitLifetimeExtendedTemporaryDecl(
   if (Record.readInt())
 D->Value = new (D->getASTContext()) APValue(Record.readAPValue());
   D->ManglingNumber = Record.readInt();
+  mergeMergeable(D);
 }
 
 std::pair
@@ -2555,6 +2558,25 @@ static bool allowODRLikeMergeInC(NamedDecl *ND) {
   return false;
 }
 
+/// Attempts to merge LifetimeExtendedTemporaryDecl with
+/// identical class definitions from two 
diff erent modules.
+void 

[PATCH] D65694: Properly instantiate a decltype in argument's default initializer

2019-12-01 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

Friendly ping.


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

https://reviews.llvm.org/D65694



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


[PATCH] D63276: [AST] Add FunctionDecl::getParametersSourceRange()

2019-12-01 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

Thanks for updating the patch!


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

https://reviews.llvm.org/D63276



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


[PATCH] D70878: [analyzer] Add support for namespaces to GenericTaintChecker

2019-12-01 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 created this revision.
boga95 added reviewers: NoQ, Szelethus.
boga95 added a project: clang.
Herald added subscribers: cfe-commits, Charusso, donat.nagy, mikhail.ramalho, 
a.sidorin, szepet, baloghadamsoftware.

Now the user can define a `Scope` for every configured function:

- Functions without `Scope` match for every function regardless of the 
namespace.
- Functions with `Scope` will match if the full name of the function is start 
with the `Scope`.
- Multiple functions can exist with the same name.

I also added support for member functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70878

Files:
  clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
  clang/test/Analysis/Inputs/taint-generic-config.yaml
  clang/test/Analysis/taint-generic.cpp

Index: clang/test/Analysis/taint-generic.cpp
===
--- /dev/null
+++ clang/test/Analysis/taint-generic.cpp
@@ -0,0 +1,126 @@
+// RUN: %clang_analyze_cc1  -analyzer-checker=alpha.security.taint,core,alpha.security.ArrayBoundV2 -analyzer-config alpha.security.taint.TaintPropagation:Config=%S/Inputs/taint-generic-config.yaml -Wno-format-security -verify -std=c++11 %s
+
+#define BUFSIZE 10
+int Buffer[BUFSIZE];
+
+int scanf(const char*, ...);
+int mySource1();
+int mySource3();
+
+bool isOutOfRange2(const int*);
+
+void mySink2(int);
+
+// Test configuration
+namespace myNamespace {
+  void scanf(const char*, ...);
+  void myScanf(const char*, ...);
+  int mySource3();
+
+  bool isOutOfRange(const int*);
+  bool isOutOfRange2(const int*);
+
+  void mySink(int, int, int);
+  void mySink2(int);
+}
+
+namespace myAnotherNamespace {
+  int mySource3();
+
+  bool isOutOfRange2(const int*);
+
+  void mySink2(int);
+}
+
+void testConfigurationNamespacePropagation1() {
+  int x;
+  // The built-in functions should be matched only for functions in
+  // the global namespace
+  myNamespace::scanf("%d", );
+  Buffer[x] = 1; // no-warning
+
+  scanf("%d", );
+  Buffer[x] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void testConfigurationNamespacePropagation2() {
+  int x = mySource3();
+  Buffer[x] = 1; // no-warning
+
+  int y = myNamespace::mySource3();
+  Buffer[y] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void testConfigurationNamespacePropagation3() {
+  int x = myAnotherNamespace::mySource3();
+  Buffer[x] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void testConfigurationNamespacePropagation4() {
+  int x;
+  // Configured functions without scope should match for all function.
+  myNamespace::myScanf("%d", );
+  Buffer[x] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void testConfigurationNamespaceFilter1() {
+  int x = mySource1();
+  if (myNamespace::isOutOfRange2())
+return;
+  Buffer[x] = 1; // no-warning
+
+  int y = mySource1();
+  if (isOutOfRange2())
+return;
+  Buffer[y] = 1; // expected-warning {{Out of bound memory access }}
+}
+
+void testConfigurationNamespaceFilter2() {
+  int x = mySource1();
+  if (myAnotherNamespace::isOutOfRange2())
+return;
+  Buffer[x] = 1; // no-warning
+}
+
+void testConfigurationNamespaceFilter3() {
+  int x = mySource1();
+  if (myNamespace::isOutOfRange())
+return;
+  Buffer[x] = 1; // no-warning
+}
+
+void testConfigurationNamespaceSink1() {
+  int x = mySource1();
+  mySink2(x); // no-warning
+
+  int y = mySource1();
+  myNamespace::mySink2(y);
+  // expected-warning@-1 {{Untrusted data is passed to a user-defined sink}}
+}
+
+void testConfigurationNamespaceSink2() {
+  int x = mySource1();
+  myAnotherNamespace::mySink2(x);
+  // expected-warning@-1 {{Untrusted data is passed to a user-defined sink}}
+}
+
+void testConfigurationNamespaceSink3() {
+  int x = mySource1();
+  myNamespace::mySink(x, 0, 1);
+  // expected-warning@-1 {{Untrusted data is passed to a user-defined sink}}
+}
+
+struct Foo {
+void scanf(const char*, int*);
+void myMemberScanf(const char*, int*);
+};
+
+void testConfigurationMemberFunc() {
+  int x;
+  Foo foo;
+  foo.scanf("%d", );
+  Buffer[x] = 1; // no-warning
+
+  foo.myMemberScanf("%d", );
+  Buffer[x] = 1; // expected-warning {{Out of bound memory access }}
+}
Index: clang/test/Analysis/Inputs/taint-generic-config.yaml
===
--- clang/test/Analysis/Inputs/taint-generic-config.yaml
+++ clang/test/Analysis/Inputs/taint-generic-config.yaml
@@ -9,12 +9,29 @@
   - Name: mySource2
 DstArgs:  [0]
 
+  # int x = myNamespace::mySource3(); // x is tainted
+  - Name: mySource3
+Scope:"myNamespace::"
+DstArgs:  [-1]
+
+  # int x = myAnotherNamespace::mySource3(); // x is tainted
+  - Name: mySource3
+Scope:"myAnotherNamespace::"
+DstArgs:  [-1]
+
   # int x, y;
   # myScanf("%d %d", , ); // x and y are tainted
   - Name:  myScanf
 VariadicType:  Dst
 VariadicIndex: 1
 
+  # int x, y;
+  # 

[PATCH] D70876: [clang-tidy] Add spuriously-wake-up-functions check

2019-12-01 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

I don't think that //misc// module should be used when checks belong to //cert//




Comment at: 
clang-tools-extra/clang-tidy/misc/SpuriouslyWakeUpFunctionsCheck.cpp:77
+const MatchFinder::MatchResult ) {
+
+  const auto *MatchedWait = Result.Nodes.getNodeAs("wait");

Unnecessary empty line.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:97
 
+- New alias :doc:`cert-con36-c
+  ` to

Please move into aliases section (in alphabetical order). Same below.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:192
 
+- New :doc:`misc-spuriously-wake-up-functions
+  ` check.

Please use alphabetical order.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:195
+
+  Finds ``cnd_wait`` or ``wait`` function calls when the function is not
+  invoked from a loop that checks whether a condition predicate holds or the

Please synchronize with first statement in documentation.



Comment at: 
clang-tools-extra/test/clang-tidy/misc-spuriously-wake-up-functions.cpp:1
+// RUN: %check_clang_tidy %s misc-spuriously-wake-up-functions %t -- -- -I 
%S/../../../libcxx/include/
+

What will happen if libcxx is not part build/source tree?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70876



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


[PATCH] D70520: [WebAssembly] Add new `export_name` clang attribute for controlling wasm export names

2019-12-01 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 231620.
sbc100 added a comment.

- rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70520

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/wasm-export-name.c
  lld/test/wasm/export-name.ll
  lld/wasm/InputChunks.h
  lld/wasm/Writer.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/MC/MCSymbolWasm.h
  llvm/include/llvm/Object/Wasm.h
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Object/WasmObjectFile.cpp
  llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
  llvm/test/CodeGen/WebAssembly/export-name.ll
  llvm/test/MC/WebAssembly/export-name.s

Index: llvm/test/MC/WebAssembly/export-name.s
===
--- /dev/null
+++ llvm/test/MC/WebAssembly/export-name.s
@@ -0,0 +1,26 @@
+# RUN: llvm-mc -triple=wasm32-unknown-unknown < %s | FileCheck %s
+# Check that it also comiled to object for format.
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o - < %s | obj2yaml | FileCheck -check-prefix=CHECK-OBJ %s
+
+foo:
+.globl foo
+.functype foo () -> ()
+.export_name foo, bar
+end_function
+
+# CHECK: .export_name foo, bar
+
+# CHECK-OBJ:- Type:EXPORT
+# CHECK-OBJ-NEXT: Exports:
+# CHECK-OBJ-NEXT:   - Name:bar
+# CHECK-OBJ-NEXT: Kind:FUNCTION
+# CHECK-OBJ-NEXT: Index:   0
+
+# CHECK-OBJ:  Name:linking
+# CHECK-OBJ-NEXT: Version: 2
+# CHECK-OBJ-NEXT: SymbolTable:
+# CHECK-OBJ-NEXT:   - Index:   0
+# CHECK-OBJ-NEXT: Kind:FUNCTION
+# CHECK-OBJ-NEXT: Name:foo
+# CHECK-OBJ-NEXT: Flags:   [ EXPORTED ]
+# CHECK-OBJ-NEXT: Function:0
Index: llvm/test/CodeGen/WebAssembly/export-name.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/export-name.ll
@@ -0,0 +1,17 @@
+; RUN: llc < %s -asm-verbose=false -wasm-keep-registers | FileCheck %s
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+define void @test() #0 {
+  ret void
+}
+
+declare void @test2() #1
+
+
+attributes #0 = { "wasm-export-name"="foo" }
+attributes #1 = { "wasm-export-name"="bar" }
+
+; CHECK: .export_name test, foo
+; CHECK: .export_name test2, bar
Index: llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -96,8 +96,11 @@
   }
 
   for (const auto  : M) {
+if (F.isIntrinsic())
+  continue;
+
 // Emit function type info for all undefined functions
-if (F.isDeclarationForLinker() && !F.isIntrinsic()) {
+if (F.isDeclarationForLinker()) {
   SmallVector Results;
   SmallVector Params;
   computeSignatureVTs(F.getFunctionType(), F, TM, Params, Results);
@@ -130,6 +133,13 @@
 getTargetStreamer()->emitImportName(Sym, Name);
   }
 }
+
+if (F.hasFnAttribute("wasm-export-name")) {
+  auto *Sym = cast(getSymbol());
+  StringRef Name = F.getFnAttribute("wasm-export-name").getValueAsString();
+  Sym->setExportName(Name);
+  getTargetStreamer()->emitExportName(Sym, Name);
+}
   }
 
   for (const auto  : M.globals()) {
Index: llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
===
--- llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
+++ llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
@@ -48,6 +48,9 @@
   /// .import_name
   virtual void emitImportName(const MCSymbolWasm *Sym,
   StringRef ImportName) = 0;
+  /// .export_name
+  virtual void emitExportName(const MCSymbolWasm *Sym,
+  StringRef ExportName) = 0;
 
 protected:
   void emitValueType(wasm::ValType Type);
@@ -68,6 +71,7 @@
   void emitEventType(const MCSymbolWasm *Sym) override;
   void emitImportModule(const MCSymbolWasm *Sym, StringRef ImportModule) override;
   void emitImportName(const MCSymbolWasm *Sym, StringRef ImportName) override;
+  void emitExportName(const MCSymbolWasm *Sym, StringRef ExportName) override;
 };
 
 /// This part is for Wasm object output
@@ -85,6 +89,8 @@
 StringRef ImportModule) override {}
   void emitImportName(const MCSymbolWasm *Sym,
   StringRef 

[PATCH] D70877: [WebAssebmly][MC] Support .import_name/.import_field asm directives

2019-12-01 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: llvm-commits, cfe-commits, aheejin, hiraditya, 
jgravelle-google, dschuff.
Herald added projects: clang, LLVM.

Convert the MC test to use asm rather than bitcode.

This is a precursor to https://reviews.llvm.org/D70520.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70877

Files:
  clang/include/clang/Basic/AttrDocs.td
  lld/test/wasm/import-name.ll
  lld/test/wasm/import-names.ll
  llvm/include/llvm/MC/MCSymbolWasm.h
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
  llvm/test/MC/WebAssembly/import-module.ll
  llvm/test/MC/WebAssembly/import-module.s

Index: llvm/test/MC/WebAssembly/import-module.s
===
--- /dev/null
+++ llvm/test/MC/WebAssembly/import-module.s
@@ -0,0 +1,33 @@
+# RUN: llvm-mc -triple=wasm32 < %s | FileCheck %s -check-prefix=CHECK-ASM
+# RUN: llvm-mc -triple=wasm32 -filetype=obj -o - < %s | obj2yaml | FileCheck %s
+
+test:
+  .functype test () -> ()
+  call  foo
+  call  plain
+  end_function
+
+  .functype foo () -> ()
+  .functype plain () -> ()
+  .import_module  foo, bar
+  .import_name  foo, qux
+
+# CHECK-ASM: .import_module  foo, bar
+# CHECK-ASM: .import_name  foo, qux
+
+# CHECK:- Type:IMPORT
+# CHECK-NEXT: Imports:
+# CHECK:- Module:  bar
+# CHECK-NEXT: Field:   qux
+# CHECK-NEXT: Kind:FUNCTION
+
+# CHECK:- Module:  env
+# CHECK-NEXT: Field:   plain
+# CHECK-NEXT: Kind:FUNCTION
+
+# CHECK:- Type:CUSTOM
+# CHECK:  Name:foo
+# CHECK-NEXT: Flags:   [ UNDEFINED, EXPLICIT_NAME ]
+
+# CHECK:  Name:plain
+# CHECK-NEXT: Flags:   [ UNDEFINED ]
Index: llvm/test/MC/WebAssembly/import-module.ll
===
--- llvm/test/MC/WebAssembly/import-module.ll
+++ /dev/null
@@ -1,31 +0,0 @@
-; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
-
-target triple = "wasm32-unknown-unknown"
-
-define void @test() {
-  call void @foo()
-  call void @plain()
-  ret void
-}
-
-declare void @foo() #0
-declare void @plain()
-
-attributes #0 = { "wasm-import-module"="bar" "wasm-import-name"="qux" }
-
-; CHECK:- Type:IMPORT
-; CHECK-NEXT: Imports:
-; CHECK:- Module:  bar
-; CHECK-NEXT: Field:   qux
-; CHECK-NEXT: Kind:FUNCTION
-
-; CHECK:- Module:  env
-; CHECK-NEXT: Field:   plain
-; CHECK-NEXT: Kind:FUNCTION
-
-; CHECK:- Type:CUSTOM
-; CHECK:  Name:foo
-; CHECK-NEXT: Flags:   [ UNDEFINED, EXPLICIT_NAME ]
-
-; CHECK:  Name:plain
-; CHECK-NEXT: Flags:   [ UNDEFINED ]
Index: llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
===
--- llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
+++ llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
@@ -712,6 +712,30 @@
   return expect(AsmToken::EndOfStatement, "EOL");
 }
 
+if (DirectiveID.getString() == ".import_module") {
+  auto SymName = expectIdent();
+  if (SymName.empty())
+return true;
+  if (expect(AsmToken::Comma, ","))
+return true;
+  auto ImportModule = expectIdent();
+  auto WasmSym = cast(Ctx.getOrCreateSymbol(SymName));
+  WasmSym->setImportModule(ImportModule);
+  TOut.emitImportModule(WasmSym, ImportModule);
+}
+
+if (DirectiveID.getString() == ".import_name") {
+  auto SymName = expectIdent();
+  if (SymName.empty())
+return true;
+  if (expect(AsmToken::Comma, ","))
+return true;
+  auto ImportName = expectIdent();
+  auto WasmSym = cast(Ctx.getOrCreateSymbol(SymName));
+  WasmSym->setImportName(ImportName);
+  TOut.emitImportName(WasmSym, ImportName);
+}
+
 if (DirectiveID.getString() == ".eventtype") {
   auto SymName = expectIdent();
   if (SymName.empty())
Index: llvm/lib/MC/WasmObjectWriter.cpp
===
--- llvm/lib/MC/WasmObjectWriter.cpp
+++ llvm/lib/MC/WasmObjectWriter.cpp
@@ -1452,7 +1452,7 @@
 Flags |= wasm::WASM_SYMBOL_EXPORTED;
   }
 }
-if (WS.getName() != WS.getImportName())
+if (WS.hasImportName())
   Flags |= wasm::WASM_SYMBOL_EXPLICIT_NAME;
 
 wasm::WasmSymbolInfo Info;
Index: llvm/include/llvm/MC/MCSymbolWasm.h
===
--- llvm/include/llvm/MC/MCSymbolWasm.h
+++ llvm/include/llvm/MC/MCSymbolWasm.h
@@ -78,6 +78,7 @@
   }
   void 

[PATCH] D70520: [WebAssembly] Add new `export_name` clang attribute for controlling wasm export names

2019-12-01 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

In D70520#1754500 , @sunfish wrote:

> It appears this doesn't handle exporting an imported function yet, which is 
> fine for now, but it would be good to issue a warning, because wasm itself is 
> capable of representing this:
>
>   void aaa(void) __attribute__((import_module("imp"), import_name("foo"), 
> export_name("bar")));
>


Yes, although this is supported at the bitcode level I think the internal APIs 
would need some refactoring to support this in BinaryFormat and lld.  
Thankfully I don't think the actual binary format would need to change.




Comment at: lld/wasm/Writer.cpp:523
+  StringRef exportName = f->function->getExportName();
+  if (!exportName.empty()) {
+name = exportName;

sunfish wrote:
> For wasm exports, it's valid to have empty strings. In fact, I may even have 
> a usecase which wants an empty-string export. It'd be good to use 
> `Optional<>` for export names, rather than special-casing the empty string.
> 
> (wasm-ld does often special-case the empty string in symbol names, but wasm 
> export strings aren't ordinary symbol names, so it'd be good to follow wasm's 
> rules for them.)
This is a fairly widespread problem within the current codebase that applies to 
both import and export names.  If its OK with you I'll do this as a followup 
and at tests for empty string imports and exports.  I imagine it will require 
fairly widespread by simple changes.   


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70520



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


[PATCH] D70520: [WebAssembly] Add new `export_name` clang attribute for controlling wasm export names

2019-12-01 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 231618.
sbc100 marked an inline comment as done.
sbc100 added a comment.

- Add support for asm parsing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70520

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/wasm-export-name.c
  lld/test/wasm/export-name.ll
  lld/test/wasm/import-name.ll
  lld/test/wasm/import-names.ll
  lld/wasm/InputChunks.h
  lld/wasm/Writer.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/MC/MCSymbolWasm.h
  llvm/include/llvm/Object/Wasm.h
  llvm/lib/MC/WasmObjectWriter.cpp
  llvm/lib/Object/WasmObjectFile.cpp
  llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.cpp
  llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyTargetStreamer.h
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
  llvm/test/CodeGen/WebAssembly/export-name.ll
  llvm/test/MC/WebAssembly/export-name.s
  llvm/test/MC/WebAssembly/import-module.ll
  llvm/test/MC/WebAssembly/import-module.s

Index: llvm/test/MC/WebAssembly/import-module.s
===
--- /dev/null
+++ llvm/test/MC/WebAssembly/import-module.s
@@ -0,0 +1,33 @@
+# RUN: llvm-mc -triple=wasm32 < %s | FileCheck %s -check-prefix=CHECK-ASM
+# RUN: llvm-mc -triple=wasm32 -filetype=obj -o - < %s | obj2yaml | FileCheck %s
+
+test:
+  .functype test () -> ()
+  call  foo
+  call  plain
+  end_function
+
+  .functype foo () -> ()
+  .functype plain () -> ()
+  .import_module  foo, bar
+  .import_name  foo, qux
+
+# CHECK-ASM: .import_module  foo, bar
+# CHECK-ASM: .import_name  foo, qux
+
+# CHECK:- Type:IMPORT
+# CHECK-NEXT: Imports:
+# CHECK:- Module:  bar
+# CHECK-NEXT: Field:   qux
+# CHECK-NEXT: Kind:FUNCTION
+
+# CHECK:- Module:  env
+# CHECK-NEXT: Field:   plain
+# CHECK-NEXT: Kind:FUNCTION
+
+# CHECK:- Type:CUSTOM
+# CHECK:  Name:foo
+# CHECK-NEXT: Flags:   [ UNDEFINED, EXPLICIT_NAME ]
+
+# CHECK:  Name:plain
+# CHECK-NEXT: Flags:   [ UNDEFINED ]
Index: llvm/test/MC/WebAssembly/import-module.ll
===
--- llvm/test/MC/WebAssembly/import-module.ll
+++ /dev/null
@@ -1,31 +0,0 @@
-; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
-
-target triple = "wasm32-unknown-unknown"
-
-define void @test() {
-  call void @foo()
-  call void @plain()
-  ret void
-}
-
-declare void @foo() #0
-declare void @plain()
-
-attributes #0 = { "wasm-import-module"="bar" "wasm-import-name"="qux" }
-
-; CHECK:- Type:IMPORT
-; CHECK-NEXT: Imports:
-; CHECK:- Module:  bar
-; CHECK-NEXT: Field:   qux
-; CHECK-NEXT: Kind:FUNCTION
-
-; CHECK:- Module:  env
-; CHECK-NEXT: Field:   plain
-; CHECK-NEXT: Kind:FUNCTION
-
-; CHECK:- Type:CUSTOM
-; CHECK:  Name:foo
-; CHECK-NEXT: Flags:   [ UNDEFINED, EXPLICIT_NAME ]
-
-; CHECK:  Name:plain
-; CHECK-NEXT: Flags:   [ UNDEFINED ]
Index: llvm/test/MC/WebAssembly/export-name.s
===
--- /dev/null
+++ llvm/test/MC/WebAssembly/export-name.s
@@ -0,0 +1,26 @@
+# RUN: llvm-mc -triple=wasm32-unknown-unknown < %s | FileCheck %s
+# Check that it also comiled to object for format.
+# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o - < %s | obj2yaml | FileCheck -check-prefix=CHECK-OBJ %s
+
+foo:
+.globl foo
+.functype foo () -> ()
+.export_name foo, bar
+end_function
+
+# CHECK: .export_name foo, bar
+
+# CHECK-OBJ:- Type:EXPORT
+# CHECK-OBJ-NEXT: Exports:
+# CHECK-OBJ-NEXT:   - Name:bar
+# CHECK-OBJ-NEXT: Kind:FUNCTION
+# CHECK-OBJ-NEXT: Index:   0
+
+# CHECK-OBJ:  Name:linking
+# CHECK-OBJ-NEXT: Version: 2
+# CHECK-OBJ-NEXT: SymbolTable:
+# CHECK-OBJ-NEXT:   - Index:   0
+# CHECK-OBJ-NEXT: Kind:FUNCTION
+# CHECK-OBJ-NEXT: Name:foo
+# CHECK-OBJ-NEXT: Flags:   [ EXPORTED ]
+# CHECK-OBJ-NEXT: Function:0
Index: llvm/test/CodeGen/WebAssembly/export-name.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/export-name.ll
@@ -0,0 +1,17 @@
+; RUN: llc < %s -asm-verbose=false 

[PATCH] D70876: Add spuriously-wake-up-functions check

2019-12-01 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis created this revision.
abelkocsis added reviewers: aaron.ballman, alexfh, hokein, jfb.
abelkocsis added projects: clang-tools-extra, clang.
Herald added subscribers: cfe-commits, mgehre, dexonsmith, mgorny.

According to 
https://wiki.sei.cmu.edu/confluence/display/cplusplus/CON54-CPP.+Wrap+functions+that+can+spuriously+wake+up+in+a+loop
and
https://wiki.sei.cmu.edu/confluence/display/c/CON36-C.+Wrap+functions+that+can+spuriously+wake+up+in+a+loop
misc-spuriously-wake-up-functions check is created. The check finds 
``cnd_wait`` or `wait` function calls in an ``IfStmt`` and  warns the user to
replace it with a ``WhileStmt`` or use it with a lambda parameter.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D70876

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/SpuriouslyWakeUpFunctionsCheck.cpp
  clang-tools-extra/clang-tidy/misc/SpuriouslyWakeUpFunctionsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con36-c.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con54-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-spuriously-wake-up-functions.rst
  clang-tools-extra/test/clang-tidy/misc-spuriously-wake-up-functions.cpp

Index: clang-tools-extra/test/clang-tidy/misc-spuriously-wake-up-functions.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/misc-spuriously-wake-up-functions.cpp
@@ -0,0 +1,50 @@
+// RUN: %check_clang_tidy %s misc-spuriously-wake-up-functions %t -- -- -I %S/../../../libcxx/include/
+
+#include "chrono"
+#include "condition_variable"
+#include "mutex"
+
+struct Node1 {
+  void *Node1;
+  struct Node1 *next;
+};
+
+static Node1 list;
+static std::mutex m;
+static std::condition_variable condition;
+
+void consume_list_element(std::condition_variable ) {
+  std::unique_lock lk(m);
+
+  if (list.next == nullptr) {
+condition.wait(lk);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'wait' should be placed inside a while statement or used with a condition parameter [misc-spuriously-wake-up-functions]
+  }
+
+  while (list.next == nullptr) {
+condition.wait(lk);
+  }
+
+  if (list.next == nullptr) {
+while (list.next == nullptr) {
+  condition.wait(lk);
+}
+  }
+  using durtype = std::chrono::duration;
+  durtype dur = std::chrono::duration();
+  if (list.next == nullptr) {
+condition.wait_for(lk, dur);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'wait_for' should be placed inside a while statement or used with a condition parameter [misc-spuriously-wake-up-functions]
+  }
+  if (list.next == nullptr) {
+condition.wait_for(lk, dur, [] { return 1; });
+  }
+  auto now = std::chrono::system_clock::now();
+  if (list.next == nullptr) {
+condition.wait_until(lk, now + dur);
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'wait_until' should be placed inside a while statement or used with a condition parameter [misc-spuriously-wake-up-functions]
+  }
+  if (list.next == nullptr) {
+condition.wait_until(lk, now + dur, [] { return 1; });
+  }
+}
Index: clang-tools-extra/docs/clang-tidy/checks/misc-spuriously-wake-up-functions.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc-spuriously-wake-up-functions.rst
@@ -0,0 +1,27 @@
+.. title:: clang-tidy - misc-spuriously-wake-up-functions
+
+misc-spuriously-wake-up-functions
+=
+
+Finds ``cnd_wait`` or ``wait`` function calls in an ``IfStmt`` and tries to 
+replace it with ``WhileStmt``.
+
+.. code-block: c++
+
+if (condition_predicate) {
+condition.wait(lk);
+}
+
+.. code-block: c
+
+if (condition_predicate) {
+if (thrd_success != cnd_wait(, )) {
+}
+}
+
+This check corresponds to the CERT C++ Coding Standard rule
+`CON54-CPP. Wrap functions that can spuriously wake up in a loop
+`_.
+and CERT C Coding Standard rule
+`CON36-C. Wrap functions that can spuriously wake up in a loop
+`_.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -84,6 +84,8 @@
bugprone-unused-return-value
bugprone-use-after-move
bugprone-virtual-near-miss
+   cert-con36-c (redirects to misc-spuriously-wake-up-functions) 
+   cert-con54-cpp (redirects to misc-spuriously-wake-up-functions) 
cert-dcl03-c 

[PATCH] D68923: Don't warn about missing declarations for partial template specializations

2019-12-01 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added a comment.

@rsmith, could you please have a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68923



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


[PATCH] D69620: Add AIX assembler support

2019-12-01 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.

LGTM with minor change request to a comment. Thanks.




Comment at: clang/lib/Driver/ToolChains/AIX.cpp:68
+  if (Inputs.size() != 1)
+llvm_unreachable("Invalid number of input files.");
+  const InputInfo  = Inputs[0];

stevewan wrote:
> hubert.reinterpretcast wrote:
> > `llvm_unreachable` is not the right solution if this can be reached by 
> > "user error". We should produce a proper error message.
> One risky condition I can think of is the user passes in multiple assembly 
> sources to the driver, which may lead to multiple assembler inputs. To verify 
> how the driver handles such a case, I added a new test into `aix-as.c` below, 
> whose results suggested that this is okay because the driver would invoke 
> `as` for each and every input files respectively. Looking into the code, the 
> driver would construct an action list for each input files individually, 
> which again matches the behaviour we observed in the testing results. That 
> said, I believe the `llvm_unreachable` here is indeed not reachable by "user 
> errors" like this, and if it triggers, it's likly an internal error. 
Thanks. Can we indicate that we are expecting the driver to invoke `as` 
separately for each assembler source file in the comment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69620



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


[PATCH] D63276: [AST] Add FunctionDecl::getParametersSourceRange()

2019-12-01 Thread Nicolas Manichon via Phabricator via cfe-commits
nicolas updated this revision to Diff 231615.
nicolas added a comment.

Update the comment


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

https://reviews.llvm.org/D63276

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/Type.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaType.cpp
  clang/unittests/AST/SourceLocationTest.cpp

Index: clang/unittests/AST/SourceLocationTest.cpp
===
--- clang/unittests/AST/SourceLocationTest.cpp
+++ clang/unittests/AST/SourceLocationTest.cpp
@@ -648,6 +648,112 @@
   Language::Lang_CXX11));
 }
 
+class FunctionDeclParametersRangeVerifier : public RangeVerifier {
+protected:
+  SourceRange getRange(const FunctionDecl ) override {
+return Function.getParametersSourceRange();
+  }
+};
+
+TEST(FunctionDeclParameters, FunctionDeclOnlyVariadic) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(1, 8, 1, 8);
+  EXPECT_TRUE(Verifier.match("void f(...);\n", functionDecl()));
+}
+
+TEST(FunctionDeclParameters, FunctionDeclVariadic) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(1, 8, 1, 15);
+  EXPECT_TRUE(Verifier.match("void f(int a, ...);\n", functionDecl()));
+}
+
+TEST(FunctionDeclParameters, FunctionDeclMacroVariadic) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(2, 8, 1, 18);
+  EXPECT_TRUE(Verifier.match("#define VARIADIC ...\n"
+ "void f(int a, VARIADIC);\n",
+ functionDecl()));
+}
+
+TEST(FunctionDeclParameters, FunctionDeclMacroParams) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(1, 16, 2, 20);
+  EXPECT_TRUE(Verifier.match("#define PARAMS int a, int b\n"
+ "void f(PARAMS, int c);",
+ functionDecl()));
+}
+
+TEST(FunctionDeclParameters, FunctionDeclSingleParameter) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(1, 8, 1, 12);
+  EXPECT_TRUE(Verifier.match("void f(int a);\n", functionDecl()));
+}
+
+TEST(FunctionDeclParameters, MemberFunctionDecl) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(2, 8, 2, 12);
+  EXPECT_TRUE(Verifier.match("class A{\n"
+ "void f(int a);\n"
+ "};",
+ functionDecl()));
+}
+
+TEST(FunctionDeclParameters, MemberFunctionDeclVariadic) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(2, 8, 2, 15);
+  EXPECT_TRUE(Verifier.match("class A{\n"
+ "void f(int a, ...);\n"
+ "};",
+ functionDecl()));
+}
+
+TEST(FunctionDeclParameters, StaticFunctionDecl) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(2, 15, 2, 19);
+  EXPECT_TRUE(Verifier.match("class A{\n"
+ "static void f(int a);\n"
+ "};",
+ functionDecl()));
+}
+
+TEST(FunctionDeclParameters, FunctionDeclMultipleParameters) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(1, 8, 1, 28);
+  EXPECT_TRUE(
+  Verifier.match("void f(int a, int b, char *c);\n", functionDecl()));
+}
+
+TEST(FunctionDeclParameters, FunctionDeclWithDefaultValue) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(1, 8, 1, 16);
+  EXPECT_TRUE(Verifier.match("void f(int a = 5);\n", functionDecl()));
+}
+
+TEST(FunctionDeclParameters, FunctionDeclWithVolatile) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(1, 8, 1, 22);
+  EXPECT_TRUE(Verifier.match("void f(volatile int *i);", functionDecl()));
+}
+
+TEST(FunctionDeclParameters, FunctionDeclWithConstParam) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(1, 8, 1, 19);
+  EXPECT_TRUE(Verifier.match("void f(const int *i);", functionDecl()));
+}
+
+TEST(FunctionDeclParameters, FunctionDeclWithConstVolatileParam) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(1, 8, 1, 28);
+  EXPECT_TRUE(Verifier.match("void f(const volatile int *i);", functionDecl()));
+}
+
+TEST(FunctionDeclParameters, FunctionDeclWithParamAttribute) {
+  FunctionDeclParametersRangeVerifier Verifier;
+  Verifier.expectRange(1, 8, 1, 36);
+  EXPECT_TRUE(Verifier.match("void f(__attribute__((unused)) int a) {}",
+ functionDecl()));
+}
+
 TEST(CXXMethodDecl, CXXMethodDeclWithThrowSpecification) {
   RangeVerifier Verifier;
   Verifier.expectRange(2, 1, 2, 16);
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -4810,6 +4810,7 @@
 FunctionProtoType::ExtProtoInfo EPI;
 EPI.ExtInfo = EI;
 

[PATCH] D63276: [AST] Add FunctionDecl::getParametersSourceRange()

2019-12-01 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 aside from a minor commenting request.




Comment at: clang/include/clang/AST/Decl.h:2400
+  /// Attempt to compute an informative source range covering the
+  /// function parameters, excluding the parentheses. The source range is
+  /// invalid if there are no parameters.

You should make the comment clear that this will include the ellipsis (which is 
sort of a parameter, sort of not).


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

https://reviews.llvm.org/D63276



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


[PATCH] D60455: [SYCL] Add sycl_kernel attribute for accelerated code outlining

2019-12-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM with some testing requests.




Comment at: clang/test/SemaSYCL/kernel-attribute.cpp:4-5
+
+__attribute((sycl_kernel)) void foo() {
+}

aaron.ballman wrote:
> Missing some tests:
> * test that both attributes can be applied to whatever subjects they 
> appertain to
> * test that neither attribute can be applied to an incorrect subject
> * test that the attributes do not accept arguments
> * test that the attribute is ignored when SYCL is not enabled
> 
> Are there situations where the attribute does not make sense, such as member 
> functions, virtual functions, etc? If so, those are good test cases (and 
> diagnostics) to add as well.
Still missing a test that the attribute is ignored when SYCL is not enabled.



Comment at: clang/test/SemaSYCL/kernel-attribute.cpp:6
+
+__attribute__((sycl_kernel(1))) void foo(); // expected-warning 
{{'sycl_kernel' attribute only applies to function templates}}
+[[clang::sycl_kernel(1)]] void foo2(); // expected-warning {{'sycl_kernel' 
attribute only applies to function templates}}

This test should be on a templated function (we already demonstrated it only 
applies to templated functions, so the check for the argument is not what is 
failing).



Comment at: clang/test/SemaSYCL/kernel-attribute.cpp:7
+__attribute__((sycl_kernel(1))) void foo(); // expected-warning 
{{'sycl_kernel' attribute only applies to function templates}}
+[[clang::sycl_kernel(1)]] void foo2(); // expected-warning {{'sycl_kernel' 
attribute only applies to function templates}}
+

Same here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D70638: [Diagnostic] add a warning which warns about misleading indentation

2019-12-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseStmt.cpp:1369-1370
 /*ShouldEnter=*/ConstexprCondition && *ConstexprCondition);
-ElseStmt = ParseStatement();
+if (Tok.is(tok::kw_if))
+  ElseStmt = ParseIfStatement(nullptr, ElseLoc);
+else

This looks incorrect to me. Consider a case like:
```
if (0) {
} else [[gsl::suppress("foo")]] if (1) {
}
```
I'm a little uneasy calling anything but `ParseStatement()` here as that is 
what needs to be parsed at this stage.


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

https://reviews.llvm.org/D70638



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


[PATCH] D70868: [libunwind] Emit dependent libraries only when detected by CMake

2019-12-01 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG35bc5276ca31: [libunwind] Emit dependent libraries only when 
detected by CMake (authored by mgorny).
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70868

Files:
  libunwind/CMakeLists.txt
  libunwind/src/AddressSpace.hpp
  libunwind/src/RWMutex.hpp


Index: libunwind/src/RWMutex.hpp
===
--- libunwind/src/RWMutex.hpp
+++ libunwind/src/RWMutex.hpp
@@ -17,7 +17,7 @@
 #include 
 #elif !defined(_LIBUNWIND_HAS_NO_THREADS)
 #include 
-#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && 
defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBUNWIND_LINK_PTHREAD_LIB)
 #pragma comment(lib, "pthread")
 #endif
 #endif
Index: libunwind/src/AddressSpace.hpp
===
--- libunwind/src/AddressSpace.hpp
+++ libunwind/src/AddressSpace.hpp
@@ -27,7 +27,7 @@
 
 #if _LIBUNWIND_USE_DLADDR
 #include 
-#if defined(__unix__) && defined(__ELF__) && 
defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBUNWIND_LINK_DL_LIB)
 #pragma comment(lib, "dl")
 #endif
 #endif
Index: libunwind/CMakeLists.txt
===
--- libunwind/CMakeLists.txt
+++ libunwind/CMakeLists.txt
@@ -352,7 +352,12 @@
 endif()
 
 if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
-  add_definitions(-D_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+  if (LIBUNWIND_HAS_DL_LIB)
+add_definitions(-D_LIBUNWIND_LINK_DL_LIB)
+  endif()
+  if (LIBUNWIND_HAS_PTHREAD_LIB)
+add_definitions(-D_LIBUNWIND_LINK_PTHREAD_LIB)
+  endif()
 endif()
 
 
#===


Index: libunwind/src/RWMutex.hpp
===
--- libunwind/src/RWMutex.hpp
+++ libunwind/src/RWMutex.hpp
@@ -17,7 +17,7 @@
 #include 
 #elif !defined(_LIBUNWIND_HAS_NO_THREADS)
 #include 
-#if defined(__unix__) && !defined(__ANDROID__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBUNWIND_LINK_PTHREAD_LIB)
 #pragma comment(lib, "pthread")
 #endif
 #endif
Index: libunwind/src/AddressSpace.hpp
===
--- libunwind/src/AddressSpace.hpp
+++ libunwind/src/AddressSpace.hpp
@@ -27,7 +27,7 @@
 
 #if _LIBUNWIND_USE_DLADDR
 #include 
-#if defined(__unix__) && defined(__ELF__) && defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+#if defined(__ELF__) && defined(_LIBUNWIND_LINK_DL_LIB)
 #pragma comment(lib, "dl")
 #endif
 #endif
Index: libunwind/CMakeLists.txt
===
--- libunwind/CMakeLists.txt
+++ libunwind/CMakeLists.txt
@@ -352,7 +352,12 @@
 endif()
 
 if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
-  add_definitions(-D_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+  if (LIBUNWIND_HAS_DL_LIB)
+add_definitions(-D_LIBUNWIND_LINK_DL_LIB)
+  endif()
+  if (LIBUNWIND_HAS_PTHREAD_LIB)
+add_definitions(-D_LIBUNWIND_LINK_PTHREAD_LIB)
+  endif()
 endif()
 
 #===
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70823: [clang-tidy] Adding cert-pos34-c check

2019-12-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/cert/PutenvWithAutoCheck.cpp:27
+  hasAutomaticStorageDuration(),
+  unless(hasDescendant(callExpr(callee(functionDecl(hasAnyName(
+  "::alloc", "::malloc", "::realloc", "::calloc")))

I don't know that this is sufficient for the check, and I sort of think this 
may need to be implemented by the static analyzer rather than clang-tidy. The 
initialization of the variable is going to be control flow sensitive. Consider 
something like:
```
void foo(void) {
  char *buffer = "huttah!";
  if (rand() % 2 == 0) {
buffer = malloc(5);
strcpy(buffer, "woot");
  }
  putenv(buffer);
}

void bar(void) {
  char *buffer = malloc(5);
  strcpy(buffer, "woot");

  if (rand() % 2 == 0) {
free(buffer);
buffer = "blah blah blah";
  }
  putenv(buffer);
}
```



Comment at: clang-tools-extra/docs/clang-tidy/checks/cert-pos34-c.rst:4
+cert-pos34-c
+=
+

Underlining looks incorrect here.



Comment at: clang-tools-extra/docs/clang-tidy/checks/cert-pos34-c.rst:6
+
+Finds calls of ``putenv`` function with automatic variable as the argument.
+

Finds calls to the ``putenv`` function which pass  a pointer to an automatic 
variable as the argument.



Comment at: clang-tools-extra/docs/clang-tidy/checks/cert-pos34-c.rst:23
+
+This check corresponds to the CERT Standard rule 
+`POS34-C. Do not call putenv() with a pointer to an automatic variable as the 
argument.

CERT Standard -> CERT C Coding Standard


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

https://reviews.llvm.org/D70823



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


[PATCH] D68101: [MC][ELF] Prevent globals with an explicit section from being mergeable

2019-12-01 Thread ben via Phabricator via cfe-commits
bd1976llvm added a comment.

In D68101#1689622 , @SjoerdMeijer 
wrote:

> Just to make sure I haven't missed anything, I would like to take this patch 
> and run some numbers, for which I need a little bit of time.


Hi @SjoerdMeijer. Did you have a chance to run the numbers? I am keen to get a 
fix in for at least the SHF_MERGE issue as we have customers who have hit this 
case. If you haven't had time I will work on a lower risk patch (lower risk of 
performance impact). Thanks.


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

https://reviews.llvm.org/D68101



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


[PATCH] D70868: [libunwind] Emit dependent libraries only when detected by CMake

2019-12-01 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

I'll look into it a bit later. I've focused on libunwind since it's breaking 
NetBSD buildbot.


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

https://reviews.llvm.org/D70868



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


[PATCH] D70850: [Clang-Tidy] Quick fix for bug in bugprone-macro-parentheses 43804

2019-12-01 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, but we may have other things to test (or bugs to fix) here.




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-macro-parentheses.cpp:46
 #define GOOD32(X) std::vector
+#define GOOD33(x) if (!a__##x) a_##x = (#x)
 

I'm surprised that `do { /* whatever */ } while (0)` is not tested as being 
good -- that's a very common idiom.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70850



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


[PATCH] D69758: [Gnu toolchain] Look at standard GCC paths for libstdcxx by default

2019-12-01 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@kristina can we land this patch ? Thanks


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

https://reviews.llvm.org/D69758



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


[clang] 486d1a5 - Revert "[clang][modules] Add support for merging lifetime-extended temporaries"

2019-12-01 Thread via cfe-commits

Author: Tyker
Date: 2019-12-01T11:58:14+01:00
New Revision: 486d1a535896aa4f48f0ecaf451ea35dbd4f137b

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

LOG: Revert "[clang][modules] Add support for merging lifetime-extended 
temporaries"

This reverts commit 85c74384778909789389b9012a75cfcca7964a28.

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Serialization/ASTReader.h
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/a.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/b.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/c.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/module.modulemap
clang/test/Modules/merge-lifetime-extended-temporary.cpp



diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 0f2018fb9e8c..63d67bd3f55b 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3041,9 +3041,7 @@ class NamespaceAliasDecl : public NamedDecl,
 
 /// Implicit declaration of a temporary that was materialized by
 /// a MaterializeTemporaryExpr and lifetime-extended by a declaration
-class LifetimeExtendedTemporaryDecl final
-: public Decl,
-  public Mergeable {
+class LifetimeExtendedTemporaryDecl final : public Decl {
   friend class MaterializeTemporaryExpr;
   friend class ASTDeclReader;
 

diff  --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index d293ea190aa4..0ff5a614a864 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -346,8 +346,6 @@ class TextNodeDumper
   void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
   void VisitBlockDecl(const BlockDecl *D);
   void VisitConceptDecl(const ConceptDecl *D);
-  void
-  VisitLifetimeExtendedTemporaryDecl(const LifetimeExtendedTemporaryDecl *D);
 };
 
 } // namespace clang

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index b6dae68b3413..f0b5e9933823 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -551,14 +551,6 @@ class ASTReader
   llvm::DenseMap>
 AnonymousDeclarationsForMerging;
 
-  /// Key used to identify LifetimeExtendedTemporaryDecl for merging,
-  /// containing the lifetime-extending declaration and the mangling number.
-  using LETemporaryKey = std::pair;
-
-  /// Map of already deserialiazed temporaries.
-  llvm::DenseMap
-  LETemporaryForMerging;
-
   struct FileDeclsInfo {
 ModuleFile *Mod = nullptr;
 ArrayRef Decls;

diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index 561c76a45cbc..0ff95213118f 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1338,17 +1338,6 @@ void TextNodeDumper::VisitFunctionDecl(const 
FunctionDecl *D) {
 OS << " <>>";
 }
 
-void TextNodeDumper::VisitLifetimeExtendedTemporaryDecl(
-const LifetimeExtendedTemporaryDecl *D) {
-  OS << " extended by ";
-  dumpBareDeclRef(D->getExtendingDecl());
-  OS << " mangling ";
-  {
-ColorScope Color(OS, ShowColors, ValueColor);
-OS << D->getManglingNumber();
-  }
-}
-
 void TextNodeDumper::VisitFieldDecl(const FieldDecl *D) {
   dumpName(D);
   dumpType(D->getType());

diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 3f7a1ed7fd5c..8991a39a7067 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -424,8 +424,6 @@ namespace clang {
 template
 void mergeMergeable(Mergeable *D);
 
-void mergeMergeable(LifetimeExtendedTemporaryDecl *D);
-
 void mergeTemplatePattern(RedeclarableTemplateDecl *D,
   RedeclarableTemplateDecl *Existing,
   DeclID DsID, bool IsKeyDecl);
@@ -2360,7 +2358,6 @@ void ASTDeclReader::VisitLifetimeExtendedTemporaryDecl(
   if (Record.readInt())
 D->Value = new (D->getASTContext()) APValue(Record.readAPValue());
   D->ManglingNumber = Record.readInt();
-  mergeMergeable(D);
 }
 
 std::pair
@@ -2558,25 +2555,6 @@ static bool allowODRLikeMergeInC(NamedDecl *ND) {
   return false;
 }
 
-/// Attempts to merge LifetimeExtendedTemporaryDecl with
-/// identical class definitions from two 
diff erent modules.
-void ASTDeclReader::mergeMergeable(LifetimeExtendedTemporaryDecl *D) {
-  // If modules are not available, there is no reason to perform this merge.
-  if 

[clang] 85c7438 - [clang][modules] Add support for merging lifetime-extended temporaries

2019-12-01 Thread via cfe-commits

Author: Tyker
Date: 2019-11-30T23:09:11+01:00
New Revision: 85c74384778909789389b9012a75cfcca7964a28

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

LOG: [clang][modules] Add support for merging lifetime-extended temporaries

Summary: Add support for merging lifetime-extended temporaries

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: xbolva00, cfe-commits

Tags: #clang

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

Added: 
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/a.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/b.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/c.h
clang/test/Modules/Inputs/merge-lifetime-extended-temporary/module.modulemap
clang/test/Modules/merge-lifetime-extended-temporary.cpp

Modified: 
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Serialization/ASTReader.h
clang/lib/AST/TextNodeDumper.cpp
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 63d67bd3f55b..0f2018fb9e8c 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3041,7 +3041,9 @@ class NamespaceAliasDecl : public NamedDecl,
 
 /// Implicit declaration of a temporary that was materialized by
 /// a MaterializeTemporaryExpr and lifetime-extended by a declaration
-class LifetimeExtendedTemporaryDecl final : public Decl {
+class LifetimeExtendedTemporaryDecl final
+: public Decl,
+  public Mergeable {
   friend class MaterializeTemporaryExpr;
   friend class ASTDeclReader;
 

diff  --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index 0ff5a614a864..d293ea190aa4 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -346,6 +346,8 @@ class TextNodeDumper
   void VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D);
   void VisitBlockDecl(const BlockDecl *D);
   void VisitConceptDecl(const ConceptDecl *D);
+  void
+  VisitLifetimeExtendedTemporaryDecl(const LifetimeExtendedTemporaryDecl *D);
 };
 
 } // namespace clang

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index f0b5e9933823..b6dae68b3413 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -551,6 +551,14 @@ class ASTReader
   llvm::DenseMap>
 AnonymousDeclarationsForMerging;
 
+  /// Key used to identify LifetimeExtendedTemporaryDecl for merging,
+  /// containing the lifetime-extending declaration and the mangling number.
+  using LETemporaryKey = std::pair;
+
+  /// Map of already deserialiazed temporaries.
+  llvm::DenseMap
+  LETemporaryForMerging;
+
   struct FileDeclsInfo {
 ModuleFile *Mod = nullptr;
 ArrayRef Decls;

diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index 0ff95213118f..561c76a45cbc 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1338,6 +1338,17 @@ void TextNodeDumper::VisitFunctionDecl(const 
FunctionDecl *D) {
 OS << " <>>";
 }
 
+void TextNodeDumper::VisitLifetimeExtendedTemporaryDecl(
+const LifetimeExtendedTemporaryDecl *D) {
+  OS << " extended by ";
+  dumpBareDeclRef(D->getExtendingDecl());
+  OS << " mangling ";
+  {
+ColorScope Color(OS, ShowColors, ValueColor);
+OS << D->getManglingNumber();
+  }
+}
+
 void TextNodeDumper::VisitFieldDecl(const FieldDecl *D) {
   dumpName(D);
   dumpType(D->getType());

diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 8991a39a7067..3f7a1ed7fd5c 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -424,6 +424,8 @@ namespace clang {
 template
 void mergeMergeable(Mergeable *D);
 
+void mergeMergeable(LifetimeExtendedTemporaryDecl *D);
+
 void mergeTemplatePattern(RedeclarableTemplateDecl *D,
   RedeclarableTemplateDecl *Existing,
   DeclID DsID, bool IsKeyDecl);
@@ -2358,6 +2360,7 @@ void ASTDeclReader::VisitLifetimeExtendedTemporaryDecl(
   if (Record.readInt())
 D->Value = new (D->getASTContext()) APValue(Record.readAPValue());
   D->ManglingNumber = Record.readInt();
+  mergeMergeable(D);
 }
 
 std::pair
@@ -2555,6 +2558,25 @@ static bool allowODRLikeMergeInC(NamedDecl *ND) {
   return false;
 }
 
+/// Attempts to merge LifetimeExtendedTemporaryDecl with
+/// identical class definitions from two 
diff erent modules.
+void