[PATCH] D52173: Python bindings TypeError in reparse method

2018-10-09 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.
Herald added a subscriber: arphaman.

I am sorry but I am not the right reviewer for that. Sorry!


Repository:
  rC Clang

https://reviews.llvm.org/D52173



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


[PATCH] D52973: Add type_info predefined decl

2018-10-09 Thread Matt Asplund via Phabricator via cfe-commits
mwasplund added a comment.

In https://reviews.llvm.org/D52973#1259909, @rsmith wrote:

> Generally this looks good, but it needs an accompanying test.


I was looking into that and trying to read up on the documentation for adding 
tests. I think I understand the crazy comment RUN test invocation, but got lost 
in the directory structure. Is there documentation on naming and placing 
regression tests? At first glance it seems arbitrary to me if the file is 
something like p6.cpp (which don't appear to be sequential) or my-test-name.cpp.


Repository:
  rC Clang

https://reviews.llvm.org/D52973



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


[PATCH] D46027: [clang-tidy] Fix PR35824

2018-10-09 Thread Alexander Zaitsev via Phabricator via cfe-commits
ZaMaZaN4iK added a comment.
Herald added a subscriber: Szelethus.

What is the status of the PR?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D46027



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


[PATCH] D53042: [X86] Remove FeatureRTM from Skylake processor list

2018-10-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:169
 setFeatureEnabledImpl(Features, "mpx", true);
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);

thiagomacieira wrote:
> craig.topper wrote:
> > craig.topper wrote:
> > > lebedev.ri wrote:
> > > > > high-end desktop and server chips (I can't find any SKX without).
> > > > 
> > > > Are you sure you didn't want to move it into an else of this `if()` ?
> > > > This commit leaves it disabled for all processors, but can be 
> > > > re-enabled for specific builds with -mrtm.
> > > 
> > > So I think this was intended.
> > It's also consistent with gcc based on grepping for _RTM_ in their 
> > predefined macro output. https://godbolt.org/z/dtfrQU They don't infer it 
> > from -mcpu=skylake-avx512, but do when adding -mrtm
> I'm sure I didn't want to :-) Do you want me to do that? And do you want me 
> to do it for IcelakeServer too?
> 
> This matches GCC's behaviour:
> 
> ```
> $ gcc -march=skylake-avx512 -dM -E -xc /dev/null | grep -c RTM
> 0
> ```
> I'm sure I didn't want to :-) Do you want me to do that?

Not really, just looked weird.


https://reviews.llvm.org/D53042



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


[PATCH] D53046: [Sema] Fix an error-on-valid with friends and templates

2018-10-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 168939.
erik.pilkington added a comment.

Merge the common pointers rather than trying to use the previous one. Thanks!


https://reviews.llvm.org/D53046

Files:
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/friend-template-redecl.cpp

Index: clang/test/SemaCXX/friend-template-redecl.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/friend-template-redecl.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++17 -verify -emit-llvm-only %s
+
+// expected-no-diagnostics
+
+template  void bar(const T &t) { foo(t); }
+
+template 
+struct HasFriend {
+  template 
+  friend void foo(const HasFriend &m) noexcept(false);
+};
+
+template 
+void foo(const HasFriend &m) noexcept(false) {}
+
+void f() {
+  HasFriend x;
+  foo(x);
+  bar(x);
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10022,11 +10022,17 @@
 if (FunctionTemplateDecl *OldTemplateDecl =
 dyn_cast(OldDecl)) {
   auto *OldFD = OldTemplateDecl->getTemplatedDecl();
-  NewFD->setPreviousDeclaration(OldFD);
-  adjustDeclContextForDeclaratorDecl(NewFD, OldFD);
   FunctionTemplateDecl *NewTemplateDecl
 = NewFD->getDescribedFunctionTemplate();
   assert(NewTemplateDecl && "Template/non-template mismatch");
+
+  // The call to MergeFunctionDecl above may have created some state in
+  // NewTemplateDecl that needs to be merged with OldTemplateDecl before we
+  // can add it as a redeclaration.
+  NewTemplateDecl->mergePrevDecl(OldTemplateDecl);
+
+  NewFD->setPreviousDeclaration(OldFD);
+  adjustDeclContextForDeclaratorDecl(NewFD, OldFD);
   if (NewFD->isCXXClassMember()) {
 NewFD->setAccess(OldTemplateDecl->getAccess());
 NewTemplateDecl->setAccess(OldTemplateDecl->getAccess());
Index: clang/lib/AST/DeclTemplate.cpp
===
--- clang/lib/AST/DeclTemplate.cpp
+++ clang/lib/AST/DeclTemplate.cpp
@@ -300,6 +300,42 @@
   return llvm::makeArrayRef(CommonPtr->InjectedArgs, Params->size());
 }
 
+void FunctionTemplateDecl::mergePrevDecl(FunctionTemplateDecl *Prev) {
+  using Base = RedeclarableTemplateDecl;
+
+  // If we haven't created a common pointer yet, then it can just be created
+  // with the usual method.
+  if (!Base::Common)
+return;
+
+  Common *ThisCommon = static_cast(Base::Common);
+  Common *PrevCommon = nullptr;
+  SmallVector PreviousDecls;
+  for (; Prev; Prev = Prev->getPreviousDecl()) {
+if (Prev->Base::Common) {
+  PrevCommon = static_cast(Prev->Base::Common);
+  break;
+}
+PreviousDecls.push_back(Prev);
+  }
+
+  // If the previous redecl chain hasn't created a common pointer yet, then just
+  // use this common pointer.
+  if (!PrevCommon) {
+for (auto *D : PreviousDecls)
+  D->Base::Common = ThisCommon;
+return;
+  }
+
+  // Ensure we don't leak any important state.
+  assert(ThisCommon->Specializations.size() == 0 &&
+ !ThisCommon->InstantiatedFromMember.getPointer() &&
+ !ThisCommon->InstantiatedFromMember.getInt() &&
+ "Can't merge incompatible declarations!");
+
+  Base::Common = PrevCommon;
+}
+
 //===--===//
 // ClassTemplateDecl Implementation
 //===--===//
Index: clang/include/clang/AST/DeclTemplate.h
===
--- clang/include/clang/AST/DeclTemplate.h
+++ clang/include/clang/AST/DeclTemplate.h
@@ -1093,6 +1093,9 @@
   /// template.
   ArrayRef getInjectedTemplateArgs();
 
+  /// Merge our RedeclarableTemplateDecl::Common with \param Prev.
+  void mergePrevDecl(FunctionTemplateDecl *Prev);
+
   /// Create a function template node.
   static FunctionTemplateDecl *Create(ASTContext &C, DeclContext *DC,
   SourceLocation L,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53060: [clang-move] Remove clang:: qualifier

2018-10-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added a reviewer: hokein.
Herald added subscribers: cfe-commits, ioeric.

The use sites are enclosed by `namespace clang`, so clang:: is not
necessary. Many unqualified names have already been used, e.g. SourceManager 
SourceLocation LangOptions. This change makes the code terser and more 
consistent.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53060

Files:
  clang-move/ClangMove.cpp

Index: clang-move/ClangMove.cpp
===
--- clang-move/ClangMove.cpp
+++ clang-move/ClangMove.cpp
@@ -128,18 +128,17 @@
  AbsoluteFilePath;
 }
 
-class FindAllIncludes : public clang::PPCallbacks {
+class FindAllIncludes : public PPCallbacks {
 public:
   explicit FindAllIncludes(SourceManager *SM, ClangMoveTool *const MoveTool)
   : SM(*SM), MoveTool(MoveTool) {}
 
-  void InclusionDirective(clang::SourceLocation HashLoc,
-  const clang::Token & /*IncludeTok*/,
+  void InclusionDirective(SourceLocation HashLoc, const Token & /*IncludeTok*/,
   StringRef FileName, bool IsAngled,
-  clang::CharSourceRange FilenameRange,
-  const clang::FileEntry * /*File*/,
-  StringRef SearchPath, StringRef /*RelativePath*/,
-  const clang::Module * /*Imported*/,
+  CharSourceRange FilenameRange,
+  const FileEntry * /*File*/, StringRef SearchPath,
+  StringRef /*RelativePath*/,
+  const Module * /*Imported*/,
   SrcMgr::CharacteristicKind /*FileType*/) override {
 if (const auto *FileEntry = SM.getFileEntryForID(SM.getFileID(HashLoc)))
   MoveTool->addIncludes(FileName, IsAngled, SearchPath,
@@ -165,9 +164,9 @@
   : MoveTool(MoveTool) {}
 
   void run(const MatchFinder::MatchResult &Result) override {
-const auto *FD = Result.Nodes.getNodeAs("function");
+const auto *FD = Result.Nodes.getNodeAs("function");
 assert(FD);
-const clang::NamedDecl *D = FD;
+const NamedDecl *D = FD;
 if (const auto *FTD = FD->getDescribedFunctionTemplate())
   D = FTD;
 MoveDeclFromOldFileToNewFile(MoveTool, D);
@@ -183,7 +182,7 @@
   : MoveTool(MoveTool) {}
 
   void run(const MatchFinder::MatchResult &Result) override {
-const auto *VD = Result.Nodes.getNodeAs("var");
+const auto *VD = Result.Nodes.getNodeAs("var");
 assert(VD);
 MoveDeclFromOldFileToNewFile(MoveTool, VD);
   }
@@ -198,10 +197,10 @@
   : MoveTool(MoveTool) {}
 
   void run(const MatchFinder::MatchResult &Result) override {
-if (const auto *TD = Result.Nodes.getNodeAs("typedef"))
+if (const auto *TD = Result.Nodes.getNodeAs("typedef"))
   MoveDeclFromOldFileToNewFile(MoveTool, TD);
 else if (const auto *TAD =
- Result.Nodes.getNodeAs("type_alias")) {
+ Result.Nodes.getNodeAs("type_alias")) {
   const NamedDecl * D = TAD;
   if (const auto * TD = TAD->getDescribedAliasTemplate())
 D = TD;
@@ -219,7 +218,7 @@
   : MoveTool(MoveTool) {}
 
   void run(const MatchFinder::MatchResult &Result) override {
-const auto *ED = Result.Nodes.getNodeAs("enum");
+const auto *ED = Result.Nodes.getNodeAs("enum");
 assert(ED);
 MoveDeclFromOldFileToNewFile(MoveTool, ED);
   }
@@ -233,21 +232,19 @@
   explicit ClassDeclarationMatch(ClangMoveTool *MoveTool)
   : MoveTool(MoveTool) {}
   void run(const MatchFinder::MatchResult &Result) override {
-clang::SourceManager* SM = &Result.Context->getSourceManager();
-if (const auto *CMD =
-Result.Nodes.getNodeAs("class_method"))
+SourceManager *SM = &Result.Context->getSourceManager();
+if (const auto *CMD = Result.Nodes.getNodeAs("class_method"))
   MatchClassMethod(CMD, SM);
-else if (const auto *VD = Result.Nodes.getNodeAs(
-   "class_static_var_decl"))
+else if (const auto *VD =
+ Result.Nodes.getNodeAs("class_static_var_decl"))
   MatchClassStaticVariable(VD, SM);
-else if (const auto *CD = Result.Nodes.getNodeAs(
-   "moved_class"))
+else if (const auto *CD =
+ Result.Nodes.getNodeAs("moved_class"))
   MatchClassDeclaration(CD, SM);
   }
 
 private:
-  void MatchClassMethod(const clang::CXXMethodDecl* CMD,
-clang::SourceManager* SM) {
+  void MatchClassMethod(const CXXMethodDecl *CMD, SourceManager *SM) {
 // Skip inline class methods. isInline() ast matcher doesn't ignore this
 // case.
 if (!CMD->isInlined()) {
@@ -262,13 +259,11 @@
 }
   }
 
-  void MatchClassStaticVariable(const clang::NamedDecl *VD,
-clang::SourceManager* SM) {
+  void MatchClassStaticVariable(const NamedDecl *VD, SourceManager *SM) {
 MoveDeclFromOldFileToNew

[PATCH] D53042: [X86] Remove FeatureRTM from Skylake processor list

2018-10-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D53042



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


[PATCH] D52949: [Diagnostics] Implement -Wsizeof-pointer-div

2018-10-09 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Can you add tests with arrays?
The error message doesn't really say what to do instead. What's wrong? What's 
correct instead?
In C++17 and later we should suggest using `std::size` for some cases instead.


https://reviews.llvm.org/D52949



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


[PATCH] D53046: [Sema] Fix an error-on-valid with friends and templates

2018-10-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D53046#1259945, @erik.pilkington wrote:

> In https://reviews.llvm.org/D53046#1259933, @rjmccall wrote:
>
> > The linking does actually happen in this test case, right?  Can we just do 
> > something when linking them to unify their `Common` structures?
>
>
> Yep, that would work too I think. We can't properly merge in the general 
> case, because we could have to decide between more than one identical 
> instantiations of different template redecls, but in this case the only 
> ordering problem is with the injected template arguments, which I believe we 
> can merge (by just discarding the new arguments, if a previous redeclaration 
> already has some). It would definitely be less intrusive, but its a more 
> complicated invariant. Do you think that is a better solution? I could go 
> either way.


Well, we're really still in the middle of creating the new declaration, so I'm 
not too worried about the invariants.  And yeah, we can safely discard the new 
arguments because IIUC this is just a cache.


Repository:
  rC Clang

https://reviews.llvm.org/D53046



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


[PATCH] D53046: [Sema] Fix an error-on-valid with friends and templates

2018-10-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

In https://reviews.llvm.org/D53046#1259933, @rjmccall wrote:

> The linking does actually happen in this test case, right?  Can we just do 
> something when linking them to unify their `Common` structures?


Yep, that would work too I think. We can't properly merge in the general case, 
because we could have to decide between more than one identical instantiations 
of different template redecls, but in this case the only ordering problem is 
with the injected template arguments, which I believe we can merge (by just 
discarding the new arguments, if a previous redeclaration already has some). It 
would definitely be less intrusive, but its a more complicated invariant. Do 
you think that is a better solution? I could go either way.


Repository:
  rC Clang

https://reviews.llvm.org/D53046



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


[PATCH] D53042: [X86] Remove FeatureRTM from Skylake processor list

2018-10-09 Thread Thiago Macieira via Phabricator via cfe-commits
thiagomacieira updated this revision to Diff 168936.
thiagomacieira added a comment.

Added test update


https://reviews.llvm.org/D53042

Files:
  lib/Basic/Targets/X86.cpp
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -670,7 +670,6 @@
 // CHECK_SKL_M32: #define __PRFCHW__ 1
 // CHECK_SKL_M32: #define __RDRND__ 1
 // CHECK_SKL_M32: #define __RDSEED__ 1
-// CHECK_SKL_M32: #define __RTM__ 1
 // CHECK_SKL_M32: #define __SGX__ 1
 // CHECK_SKL_M32: #define __SSE2__ 1
 // CHECK_SKL_M32: #define __SSE3__ 1
@@ -706,7 +705,6 @@
 // CHECK_SKL_M64: #define __PRFCHW__ 1
 // CHECK_SKL_M64: #define __RDRND__ 1
 // CHECK_SKL_M64: #define __RDSEED__ 1
-// CHECK_SKL_M64: #define __RTM__ 1
 // CHECK_SKL_M64: #define __SGX__ 1
 // CHECK_SKL_M64: #define __SSE2_MATH__ 1
 // CHECK_SKL_M64: #define __SSE2__ 1
@@ -747,7 +745,6 @@
 // CHECK_KNL_M32: #define __PREFETCHWT1__ 1
 // CHECK_KNL_M32: #define __PRFCHW__ 1
 // CHECK_KNL_M32: #define __RDRND__ 1
-// CHECK_KNL_M32: #define __RTM__ 1
 // CHECK_KNL_M32: #define __SSE2__ 1
 // CHECK_KNL_M32: #define __SSE3__ 1
 // CHECK_KNL_M32: #define __SSE4_1__ 1
@@ -785,7 +782,6 @@
 // CHECK_KNL_M64: #define __PREFETCHWT1__ 1
 // CHECK_KNL_M64: #define __PRFCHW__ 1
 // CHECK_KNL_M64: #define __RDRND__ 1
-// CHECK_KNL_M64: #define __RTM__ 1
 // CHECK_KNL_M64: #define __SSE2_MATH__ 1
 // CHECK_KNL_M64: #define __SSE2__ 1
 // CHECK_KNL_M64: #define __SSE3__ 1
@@ -827,7 +823,6 @@
 // CHECK_KNM_M32: #define __PREFETCHWT1__ 1
 // CHECK_KNM_M32: #define __PRFCHW__ 1
 // CHECK_KNM_M32: #define __RDRND__ 1
-// CHECK_KNM_M32: #define __RTM__ 1
 // CHECK_KNM_M32: #define __SSE2__ 1
 // CHECK_KNM_M32: #define __SSE3__ 1
 // CHECK_KNM_M32: #define __SSE4_1__ 1
@@ -863,7 +858,6 @@
 // CHECK_KNM_M64: #define __PREFETCHWT1__ 1
 // CHECK_KNM_M64: #define __PRFCHW__ 1
 // CHECK_KNM_M64: #define __RDRND__ 1
-// CHECK_KNM_M64: #define __RTM__ 1
 // CHECK_KNM_M64: #define __SSE2_MATH__ 1
 // CHECK_KNM_M64: #define __SSE2__ 1
 // CHECK_KNM_M64: #define __SSE3__ 1
@@ -907,7 +901,6 @@
 // CHECK_SKX_M32: #define __PRFCHW__ 1
 // CHECK_SKX_M32: #define __RDRND__ 1
 // CHECK_SKX_M32: #define __RDSEED__ 1
-// CHECK_SKX_M32: #define __RTM__ 1
 // CHECK_SKX_M32-NOT: #define __SGX__ 1
 // CHECK_SKX_M32: #define __SSE2__ 1
 // CHECK_SKX_M32: #define __SSE3__ 1
@@ -954,7 +947,6 @@
 // CHECK_SKX_M64: #define __PRFCHW__ 1
 // CHECK_SKX_M64: #define __RDRND__ 1
 // CHECK_SKX_M64: #define __RDSEED__ 1
-// CHECK_SKX_M64: #define __RTM__ 1
 // CHECK_SKX_M64-NOT: #define __SGX__ 1
 // CHECK_SKX_M64: #define __SSE2_MATH__ 1
 // CHECK_SKX_M64: #define __SSE2__ 1
@@ -1006,7 +998,6 @@
 // CHECK_CNL_M32: #define __PRFCHW__ 1
 // CHECK_CNL_M32: #define __RDRND__ 1
 // CHECK_CNL_M32: #define __RDSEED__ 1
-// CHECK_CNL_M32: #define __RTM__ 1
 // CHECK_CNL_M32: #define __SGX__ 1
 // CHECK_CNL_M32: #define __SHA__ 1
 // CHECK_CNL_M32: #define __SSE2__ 1
@@ -1056,7 +1047,6 @@
 // CHECK_CNL_M64: #define __PRFCHW__ 1
 // CHECK_CNL_M64: #define __RDRND__ 1
 // CHECK_CNL_M64: #define __RDSEED__ 1
-// CHECK_CNL_M64: #define __RTM__ 1
 // CHECK_CNL_M64: #define __SGX__ 1
 // CHECK_CNL_M64: #define __SHA__ 1
 // CHECK_CNL_M64: #define __SSE2__ 1
@@ -1113,7 +1103,6 @@
 // CHECK_ICL_M32: #define __RDPID__ 1
 // CHECK_ICL_M32: #define __RDRND__ 1
 // CHECK_ICL_M32: #define __RDSEED__ 1
-// CHECK_ICL_M32: #define __RTM__ 1
 // CHECK_ICL_M32: #define __SGX__ 1
 // CHECK_ICL_M32: #define __SHA__ 1
 // CHECK_ICL_M32: #define __SSE2__ 1
@@ -1172,7 +1161,6 @@
 // CHECK_ICL_M64: #define __RDPID__ 1
 // CHECK_ICL_M64: #define __RDRND__ 1
 // CHECK_ICL_M64: #define __RDSEED__ 1
-// CHECK_ICL_M64: #define __RTM__ 1
 // CHECK_ICL_M64: #define __SGX__ 1
 // CHECK_ICL_M64: #define __SHA__ 1
 // CHECK_ICL_M64: #define __SSE2__ 1
@@ -1233,7 +1221,6 @@
 // CHECK_ICX_M32: #define __RDPID__ 1
 // CHECK_ICX_M32: #define __RDRND__ 1
 // CHECK_ICX_M32: #define __RDSEED__ 1
-// CHECK_ICX_M32: #define __RTM__ 1
 // CHECK_ICX_M32: #define __SGX__ 1
 // CHECK_ICX_M32: #define __SHA__ 1
 // CHECK_ICX_M32: #define __SSE2__ 1
@@ -1293,7 +1280,6 @@
 // CHECK_ICX_M64: #define __RDPID__ 1
 // CHECK_ICX_M64: #define __RDRND__ 1
 // CHECK_ICX_M64: #define __RDSEED__ 1
-// CHECK_ICX_M64: #define __RTM__ 1
 // CHECK_ICX_M64: #define __SGX__ 1
 // CHECK_ICX_M64: #define __SHA__ 1
 // CHECK_ICX_M64: #define __SSE2__ 1
Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -169,7 +169,6 @@
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);
 setFeatureEnabledImpl(Features, "clflushopt", true);
-setFeatureEnabledImpl(Features, "rtm", true);
 setFeatureEnabledImpl(Features, "aes

[PATCH] D50616: [Fixed Point Arithmetic] FixedPointCast

2018-10-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D50616#1259769, @leonardchan wrote:

> @ebevhan @rjmccall Seeing that the saturation intrinsic in 
> https://reviews.llvm.org/D52286 should be put on hold for now, would it be 
> fine to submit this patch as is? Then if the intrinsic is finished, come back 
> to this and update this patch to use the intrinsic?


Okay, but please un-target-hook it.


Repository:
  rC Clang

https://reviews.llvm.org/D50616



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


[PATCH] D53046: [Sema] Fix an error-on-valid with friends and templates

2018-10-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The linking does actually happen in this test case, right?  Can we just do 
something when linking them to unify their `Common` structures?


Repository:
  rC Clang

https://reviews.llvm.org/D53046



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


[PATCH] D52924: Make __builtin_object_size use the EM_IgnoreSideEffects evaluation mode.

2018-10-09 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344110: ExprConstant: Make __builtin_object_size use 
EM_IgnoreSideEffects. (authored by jyknight, committed by ).
Herald added a subscriber: kristina.

Changed prior to commit:
  https://reviews.llvm.org/D52924?vs=168435&id=168935#toc

Repository:
  rC Clang

https://reviews.llvm.org/D52924

Files:
  lib/AST/ExprConstant.cpp


Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -759,18 +759,6 @@
   /// context we try to fold them immediately since the optimizer never
   /// gets a chance to look at it.
   EM_PotentialConstantExpressionUnevaluated,
-
-  /// Evaluate as a constant expression. In certain scenarios, if:
-  /// - we find a MemberExpr with a base that can't be evaluated, or
-  /// - we find a variable initialized with a call to a function that has
-  ///   the alloc_size attribute on it
-  /// then we may consider evaluation to have succeeded.
-  ///
-  /// In either case, the LValue returned shall have an invalid base; in 
the
-  /// former, the base will be the invalid MemberExpr, in the latter, the
-  /// base will be either the alloc_size CallExpr or a CastExpr wrapping
-  /// said CallExpr.
-  EM_OffsetFold,
 } EvalMode;
 
 /// Are we checking whether the expression is a potential constant
@@ -874,7 +862,6 @@
   case EM_PotentialConstantExpression:
   case EM_ConstantExpressionUnevaluated:
   case EM_PotentialConstantExpressionUnevaluated:
-  case EM_OffsetFold:
 HasActiveDiagnostic = false;
 return OptionalDiagnostic();
   }
@@ -966,7 +953,6 @@
   case EM_ConstantExpression:
   case EM_ConstantExpressionUnevaluated:
   case EM_ConstantFold:
-  case EM_OffsetFold:
 return false;
   }
   llvm_unreachable("Missed EvalMode case");
@@ -985,7 +971,6 @@
   case EM_EvaluateForOverflow:
   case EM_IgnoreSideEffects:
   case EM_ConstantFold:
-  case EM_OffsetFold:
 return true;
 
   case EM_PotentialConstantExpression:
@@ -1021,7 +1006,6 @@
   case EM_ConstantExpressionUnevaluated:
   case EM_ConstantFold:
   case EM_IgnoreSideEffects:
-  case EM_OffsetFold:
 return false;
   }
   llvm_unreachable("Missed EvalMode case");
@@ -1093,18 +1077,18 @@
 }
   };
 
-  /// RAII object used to treat the current evaluation as the correct pointer
-  /// offset fold for the current EvalMode
-  struct FoldOffsetRAII {
+  /// RAII object used to set the current evaluation mode to ignore
+  /// side-effects.
+  struct IgnoreSideEffectsRAII {
 EvalInfo &Info;
 EvalInfo::EvaluationMode OldMode;
-explicit FoldOffsetRAII(EvalInfo &Info)
+explicit IgnoreSideEffectsRAII(EvalInfo &Info)
 : Info(Info), OldMode(Info.EvalMode) {
   if (!Info.checkingPotentialConstantExpression())
-Info.EvalMode = EvalInfo::EM_OffsetFold;
+Info.EvalMode = EvalInfo::EM_IgnoreSideEffects;
 }
 
-~FoldOffsetRAII() { Info.EvalMode = OldMode; }
+~IgnoreSideEffectsRAII() { Info.EvalMode = OldMode; }
   };
 
   /// RAII object used to optionally suppress diagnostics and side-effects from
@@ -8049,7 +8033,7 @@
 // If there are any, but we can determine the pointed-to object anyway, 
then
 // ignore the side-effects.
 SpeculativeEvaluationRAII SpeculativeEval(Info);
-FoldOffsetRAII Fold(Info);
+IgnoreSideEffectsRAII Fold(Info);
 
 if (E->isGLValue()) {
   // It's possible for us to be given GLValues if we're called via
@@ -8117,7 +8101,6 @@
 case EvalInfo::EM_ConstantFold:
 case EvalInfo::EM_EvaluateForOverflow:
 case EvalInfo::EM_IgnoreSideEffects:
-case EvalInfo::EM_OffsetFold:
   // Leave it to IR generation.
   return Error(E);
 case EvalInfo::EM_ConstantExpressionUnevaluated:


Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -759,18 +759,6 @@
   /// context we try to fold them immediately since the optimizer never
   /// gets a chance to look at it.
   EM_PotentialConstantExpressionUnevaluated,
-
-  /// Evaluate as a constant expression. In certain scenarios, if:
-  /// - we find a MemberExpr with a base that can't be evaluated, or
-  /// - we find a variable initialized with a call to a function that has
-  ///   the alloc_size attribute on it
-  /// then we may consider evaluation to have succeeded.
-  ///
-  /// In either case, the LValue returned shall have an invalid base; in the
-  /// former, the base will be the invalid MemberExpr, in the latter, the
-  /// base will be either the alloc_size CallExpr or a CastExpr wrapping
-  /// said CallExpr.
-

r344110 - ExprConstant: Make __builtin_object_size use EM_IgnoreSideEffects.

2018-10-09 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Tue Oct  9 19:53:43 2018
New Revision: 344110

URL: http://llvm.org/viewvc/llvm-project?rev=344110&view=rev
Log:
ExprConstant: Make __builtin_object_size use EM_IgnoreSideEffects.

And, since EM_OffsetFold is now unused, remove it.

While builtin_object_size intends to ignore the presence of
side-effects in its argument, the EM_OffsetFold mode was NOT
configured to ignore side-effects. Rather it was effectively identical
to EM_ConstantFold -- its explanatory comment
notwithstanding.

However, currently, keepEvaluatingAfterSideEffect() is not always
honored -- sometimes evaluation continues despite it returning
false. Therefore, since the b_o_s code was only checking the return
value from evaluation, and not additionally checking the
HasSideEffects flag, side-effects _were_ in many cases actually being
ignored.

This change is a prerequisite cleanup towards fixing that issue.

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

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=344110&r1=344109&r2=344110&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Oct  9 19:53:43 2018
@@ -759,18 +759,6 @@ namespace {
   /// context we try to fold them immediately since the optimizer never
   /// gets a chance to look at it.
   EM_PotentialConstantExpressionUnevaluated,
-
-  /// Evaluate as a constant expression. In certain scenarios, if:
-  /// - we find a MemberExpr with a base that can't be evaluated, or
-  /// - we find a variable initialized with a call to a function that has
-  ///   the alloc_size attribute on it
-  /// then we may consider evaluation to have succeeded.
-  ///
-  /// In either case, the LValue returned shall have an invalid base; in 
the
-  /// former, the base will be the invalid MemberExpr, in the latter, the
-  /// base will be either the alloc_size CallExpr or a CastExpr wrapping
-  /// said CallExpr.
-  EM_OffsetFold,
 } EvalMode;
 
 /// Are we checking whether the expression is a potential constant
@@ -874,7 +862,6 @@ namespace {
   case EM_PotentialConstantExpression:
   case EM_ConstantExpressionUnevaluated:
   case EM_PotentialConstantExpressionUnevaluated:
-  case EM_OffsetFold:
 HasActiveDiagnostic = false;
 return OptionalDiagnostic();
   }
@@ -966,7 +953,6 @@ namespace {
   case EM_ConstantExpression:
   case EM_ConstantExpressionUnevaluated:
   case EM_ConstantFold:
-  case EM_OffsetFold:
 return false;
   }
   llvm_unreachable("Missed EvalMode case");
@@ -985,7 +971,6 @@ namespace {
   case EM_EvaluateForOverflow:
   case EM_IgnoreSideEffects:
   case EM_ConstantFold:
-  case EM_OffsetFold:
 return true;
 
   case EM_PotentialConstantExpression:
@@ -1021,7 +1006,6 @@ namespace {
   case EM_ConstantExpressionUnevaluated:
   case EM_ConstantFold:
   case EM_IgnoreSideEffects:
-  case EM_OffsetFold:
 return false;
   }
   llvm_unreachable("Missed EvalMode case");
@@ -1093,18 +1077,18 @@ namespace {
 }
   };
 
-  /// RAII object used to treat the current evaluation as the correct pointer
-  /// offset fold for the current EvalMode
-  struct FoldOffsetRAII {
+  /// RAII object used to set the current evaluation mode to ignore
+  /// side-effects.
+  struct IgnoreSideEffectsRAII {
 EvalInfo &Info;
 EvalInfo::EvaluationMode OldMode;
-explicit FoldOffsetRAII(EvalInfo &Info)
+explicit IgnoreSideEffectsRAII(EvalInfo &Info)
 : Info(Info), OldMode(Info.EvalMode) {
   if (!Info.checkingPotentialConstantExpression())
-Info.EvalMode = EvalInfo::EM_OffsetFold;
+Info.EvalMode = EvalInfo::EM_IgnoreSideEffects;
 }
 
-~FoldOffsetRAII() { Info.EvalMode = OldMode; }
+~IgnoreSideEffectsRAII() { Info.EvalMode = OldMode; }
   };
 
   /// RAII object used to optionally suppress diagnostics and side-effects from
@@ -8049,7 +8033,7 @@ static bool tryEvaluateBuiltinObjectSize
 // If there are any, but we can determine the pointed-to object anyway, 
then
 // ignore the side-effects.
 SpeculativeEvaluationRAII SpeculativeEval(Info);
-FoldOffsetRAII Fold(Info);
+IgnoreSideEffectsRAII Fold(Info);
 
 if (E->isGLValue()) {
   // It's possible for us to be given GLValues if we're called via
@@ -8117,7 +8101,6 @@ bool IntExprEvaluator::VisitBuiltinCallE
 case EvalInfo::EM_ConstantFold:
 case EvalInfo::EM_EvaluateForOverflow:
 case EvalInfo::EM_IgnoreSideEffects:
-case EvalInfo::EM_OffsetFold:
   // Leave it to IR generation.
   return Error(E);
 case EvalInfo::EM_ConstantExpressionUnevaluated:


_

[PATCH] D52973: Add type_info predefined decl

2018-10-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Generally this looks good, but it needs an accompanying test.




Comment at: include/clang/AST/ASTContext.h:1129-1130
 
+  /// Retrieve the declaration for the type_info class type.
+  RecordDecl *getTypeInfoClassDecl() const;
+

Please indicate somewhere that this is the non-standard MSVC `::type_info` 
type, not the standard `std::type_info` type.



Comment at: lib/Sema/SemaDecl.cpp:1464
   if (NewM == OldM)
 return false;

Somewhere up here we're calling `getOwningModule()` but should be calling 
`getOwningModuleForLinkage()`. (Please upload patches with full context as 
described at https://llvm.org/docs/Phabricator.html)



Comment at: lib/Sema/SemaDecl.cpp:1467-1470
+  // FIXME: The Modules TS does not specify how to handle inplicit types
+  // For now we will simply ignore the implicit global types
+  if (Old->isImplicit())
+return false;

Rather than doing this, please change `ASTContext::buildImplicitRecord` to 
`setModuleOwnershipKind(Decl::ModuleOwnershipKind::Unowned)` on the created 
declaration.


Repository:
  rC Clang

https://reviews.llvm.org/D52973



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


[PATCH] D53042: [X86] Remove FeatureRTM from Skylake processor list

2018-10-09 Thread Thiago Macieira via Phabricator via cfe-commits
thiagomacieira added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:169
 setFeatureEnabledImpl(Features, "mpx", true);
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);

craig.topper wrote:
> craig.topper wrote:
> > lebedev.ri wrote:
> > > > high-end desktop and server chips (I can't find any SKX without).
> > > 
> > > Are you sure you didn't want to move it into an else of this `if()` ?
> > > This commit leaves it disabled for all processors, but can be re-enabled 
> > > for specific builds with -mrtm.
> > 
> > So I think this was intended.
> It's also consistent with gcc based on grepping for _RTM_ in their predefined 
> macro output. https://godbolt.org/z/dtfrQU They don't infer it from 
> -mcpu=skylake-avx512, but do when adding -mrtm
I'm sure I didn't want to :-) Do you want me to do that? And do you want me to 
do it for IcelakeServer too?

This matches GCC's behaviour:

```
$ gcc -march=skylake-avx512 -dM -E -xc /dev/null | grep -c RTM
0
```


Repository:
  rC Clang

https://reviews.llvm.org/D53042



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


[PATCH] D53042: [X86] Remove FeatureRTM from Skylake processor list

2018-10-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper requested changes to this revision.
craig.topper added a comment.
This revision now requires changes to proceed.

But there is definitely at least one test that needs to be updated. 
@thiagomacieira, can update them or would you like me to?




Comment at: lib/Basic/Targets/X86.cpp:169
 setFeatureEnabledImpl(Features, "mpx", true);
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);

craig.topper wrote:
> lebedev.ri wrote:
> > > high-end desktop and server chips (I can't find any SKX without).
> > 
> > Are you sure you didn't want to move it into an else of this `if()` ?
> > This commit leaves it disabled for all processors, but can be re-enabled 
> > for specific builds with -mrtm.
> 
> So I think this was intended.
It's also consistent with gcc based on grepping for _RTM_ in their predefined 
macro output. https://godbolt.org/z/dtfrQU They don't infer it from 
-mcpu=skylake-avx512, but do when adding -mrtm


Repository:
  rC Clang

https://reviews.llvm.org/D53042



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


[PATCH] D53048: [Basic] Split out -Wimplicit-int-conversion and -Wimplicit-float-conversion from -Wconversion

2018-10-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344101: [Basic] Split out -Wimplicit-int-conversion and 
-Wimplicit-float-conversion… (authored by epilk, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D53048?vs=168912&id=168924#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D53048

Files:
  cfe/trunk/include/clang/Basic/DiagnosticGroups.td
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/test/Sema/implicit-int-conversion.c


Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -59,6 +59,8 @@
UndefinedBoolConversion]>;
 def IntConversion : DiagGroup<"int-conversion">;
 def EnumConversion : DiagGroup<"enum-conversion">;
+def ImplicitIntConversion : DiagGroup<"implicit-int-conversion">;
+def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion">;
 
 def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
 def FloatZeroConversion : DiagGroup<"float-zero-conversion">;
@@ -709,6 +711,8 @@
 FloatConversion,
 Shorten64To32,
 IntConversion,
+ImplicitIntConversion,
+ImplicitFloatConversion,
 LiteralConversion,
 NonLiteralNullConversion, // (1-1)->pointer (etc)
 NullConversion, // NULL->non-pointer
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3181,10 +3181,10 @@
   "implicit conversion from %0 to %1 is not permitted in C++">;
 def warn_impcast_float_precision : Warning<
   "implicit conversion loses floating-point precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_float_result_precision : Warning<
   "implicit conversion when assigning computation result loses floating-point 
precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_double_promotion : Warning<
   "implicit conversion increases floating-point precision: %0 to %1">,
   InGroup, DefaultIgnore;
@@ -3196,10 +3196,10 @@
   InGroup, DefaultIgnore;
 def warn_impcast_integer_precision : Warning<
   "implicit conversion loses integer precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_high_order_zero_bits : Warning<
   "higher order bits are zeroes after implicit conversion">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_nonnegative_result : Warning<
   "the resulting value is always non-negative after implicit conversion">,
   InGroup, DefaultIgnore;
Index: cfe/trunk/test/Sema/implicit-int-conversion.c
===
--- cfe/trunk/test/Sema/implicit-int-conversion.c
+++ cfe/trunk/test/Sema/implicit-int-conversion.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-int-conversion 
-DSMALL=char -DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-conversion 
-DSMALL=char -DBIG=int
+// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-float-conversion 
-DSMALL=float -DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-float-conversion 
-DSMALL=float -DBIG=double
+
+void f() {
+  SMALL a;
+  BIG b = 0;
+  a = b;
+#ifndef NO_DIAG
+  // expected-warning@-2 {{implicit conversion}}
+#else
+  // expected-no-diagnostics
+#endif
+}


Index: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td
@@ -59,6 +59,8 @@
UndefinedBoolConversion]>;
 def IntConversion : DiagGroup<"int-conversion">;
 def EnumConversion : DiagGroup<"enum-conversion">;
+def ImplicitIntConversion : DiagGroup<"implicit-int-conversion">;
+def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion">;
 
 def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
 def FloatZeroConversion : DiagGroup<"float-zero-conversion">;
@@ -709,6 +711,8 @@
 FloatConversion,
 Shorten64To32,
 IntConversion,
+ImplicitIntConversion,
+ImplicitFloatConversion,
 LiteralConversion,
 NonLiteralNullConversion, // 

r344101 - [Basic] Split out -Wimplicit-int-conversion and -Wimplicit-float-conversion from -Wconversion

2018-10-09 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Tue Oct  9 17:40:50 2018
New Revision: 344101

URL: http://llvm.org/viewvc/llvm-project?rev=344101&view=rev
Log:
[Basic] Split out -Wimplicit-int-conversion and -Wimplicit-float-conversion 
from -Wconversion

These two diagnostics are noisy, so its reasonable for users to opt-out of them
when -Wconversion is enabled.

rdar://45058981

Differential revision: https://reviews.llvm.org/D53048

Added:
cfe/trunk/test/Sema/implicit-int-conversion.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=344101&r1=344100&r2=344101&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Oct  9 17:40:50 2018
@@ -59,6 +59,8 @@ def BoolConversion : DiagGroup<"bool-con
UndefinedBoolConversion]>;
 def IntConversion : DiagGroup<"int-conversion">;
 def EnumConversion : DiagGroup<"enum-conversion">;
+def ImplicitIntConversion : DiagGroup<"implicit-int-conversion">;
+def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion">;
 
 def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
 def FloatZeroConversion : DiagGroup<"float-zero-conversion">;
@@ -709,6 +711,8 @@ def Conversion : DiagGroup<"conversion",
 FloatConversion,
 Shorten64To32,
 IntConversion,
+ImplicitIntConversion,
+ImplicitFloatConversion,
 LiteralConversion,
 NonLiteralNullConversion, // (1-1)->pointer (etc)
 NullConversion, // NULL->non-pointer

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=344101&r1=344100&r2=344101&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct  9 17:40:50 
2018
@@ -3181,10 +3181,10 @@ def err_impcast_complex_scalar : Error<
   "implicit conversion from %0 to %1 is not permitted in C++">;
 def warn_impcast_float_precision : Warning<
   "implicit conversion loses floating-point precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_float_result_precision : Warning<
   "implicit conversion when assigning computation result loses floating-point 
precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_double_promotion : Warning<
   "implicit conversion increases floating-point precision: %0 to %1">,
   InGroup, DefaultIgnore;
@@ -3196,10 +3196,10 @@ def warn_impcast_integer_sign_conditiona
   InGroup, DefaultIgnore;
 def warn_impcast_integer_precision : Warning<
   "implicit conversion loses integer precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_high_order_zero_bits : Warning<
   "higher order bits are zeroes after implicit conversion">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_nonnegative_result : Warning<
   "the resulting value is always non-negative after implicit conversion">,
   InGroup, DefaultIgnore;

Added: cfe/trunk/test/Sema/implicit-int-conversion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/implicit-int-conversion.c?rev=344101&view=auto
==
--- cfe/trunk/test/Sema/implicit-int-conversion.c (added)
+++ cfe/trunk/test/Sema/implicit-int-conversion.c Tue Oct  9 17:40:50 2018
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-int-conversion 
-DSMALL=char -DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-conversion 
-DSMALL=char -DBIG=int
+// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-float-conversion 
-DSMALL=float -DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-float-conversion 
-DSMALL=float -DBIG=double
+
+void f() {
+  SMALL a;
+  BIG b = 0;
+  a = b;
+#ifndef NO_DIAG
+  // expected-warning@-2 {{implicit conversion}}
+#else
+  // expected-no-diagnostics
+#endif
+}


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


[PATCH] D53042: [X86] Remove FeatureRTM from Skylake processor list

2018-10-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:169
 setFeatureEnabledImpl(Features, "mpx", true);
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);

lebedev.ri wrote:
> > high-end desktop and server chips (I can't find any SKX without).
> 
> Are you sure you didn't want to move it into an else of this `if()` ?
> This commit leaves it disabled for all processors, but can be re-enabled for 
> specific builds with -mrtm.

So I think this was intended.


Repository:
  rC Clang

https://reviews.llvm.org/D53042



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


[PATCH] D52703: Allow ifunc resolvers to accept arguments

2018-10-09 Thread Ed Maste via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC344100: clang: Allow ifunc resolvers to accept arguments 
(authored by emaste, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D52703

Files:
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/CodeGen/CodeGenModule.cpp
  test/Sema/attr-ifunc.c


Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2889,8 +2889,6 @@
   "%select{alias|ifunc}0 definition is part of a cycle">;
 def err_ifunc_resolver_return : Error<
   "ifunc resolver function must return a pointer">;
-def err_ifunc_resolver_params : Error<
-  "ifunc resolver function must have no parameters">;
 def warn_attribute_wrong_decl_type_str : Warning<
   "%0 attribute only applies to %1">, InGroup;
 def err_attribute_wrong_decl_type_str : Error<
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -3428,7 +3428,7 @@
   let Content = [{
 ``__attribute__((ifunc("resolver")))`` is used to mark that the address of a 
declaration should be resolved at runtime by calling a resolver function.
 
-The symbol name of the resolver function is given in quotes.  A function with 
this name (after mangling) must be defined in the current translation unit; it 
may be ``static``.  The resolver function should take no arguments and return a 
pointer.
+The symbol name of the resolver function is given in quotes.  A function with 
this name (after mangling) must be defined in the current translation unit; it 
may be ``static``.  The resolver function should return a pointer.
 
 The ``ifunc`` attribute may only be used on a function declaration.  A 
function declaration with an ``ifunc`` attribute is considered to be a 
definition of the declared entity.  The entity must not have weak linkage; for 
example, in C++, it cannot be applied to a declaration if a definition at that 
location would be considered inline.
 
Index: test/Sema/attr-ifunc.c
===
--- test/Sema/attr-ifunc.c
+++ test/Sema/attr-ifunc.c
@@ -27,10 +27,6 @@
 void f4() __attribute__((ifunc("f4_ifunc")));
 //expected-error@-1 {{ifunc resolver function must return a pointer}}
 
-void* f5_ifunc(int i) { return 0; }
-void f5() __attribute__((ifunc("f5_ifunc")));
-//expected-error@-1 {{ifunc resolver function must have no parameters}}
-
 #else
 void f1a() __asm("f1");
 void f1a() {}
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -322,8 +322,6 @@
   assert(FTy);
   if (!FTy->getReturnType()->isPointerTy())
 Diags.Report(Location, diag::err_ifunc_resolver_return);
-  if (FTy->getNumParams())
-Diags.Report(Location, diag::err_ifunc_resolver_params);
 }
 
 llvm::Constant *Aliasee = Alias->getIndirectSymbol();


Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2889,8 +2889,6 @@
   "%select{alias|ifunc}0 definition is part of a cycle">;
 def err_ifunc_resolver_return : Error<
   "ifunc resolver function must return a pointer">;
-def err_ifunc_resolver_params : Error<
-  "ifunc resolver function must have no parameters">;
 def warn_attribute_wrong_decl_type_str : Warning<
   "%0 attribute only applies to %1">, InGroup;
 def err_attribute_wrong_decl_type_str : Error<
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -3428,7 +3428,7 @@
   let Content = [{
 ``__attribute__((ifunc("resolver")))`` is used to mark that the address of a declaration should be resolved at runtime by calling a resolver function.
 
-The symbol name of the resolver function is given in quotes.  A function with this name (after mangling) must be defined in the current translation unit; it may be ``static``.  The resolver function should take no arguments and return a pointer.
+The symbol name of the resolver function is given in quotes.  A function with this name (after mangling) must be defined in the current translation unit; it may be ``static``.  The resolver function should return a pointer.
 
 The ``ifunc`` attribute may only be used on a function declaration.  A function declaration with an ``ifunc`` attribute is considered to be a definition of the declared entity.  The entity must not have weak linkage; for example, in C++, it cannot be applied to a declaration if a definition at that location w

r344100 - clang: Allow ifunc resolvers to accept arguments

2018-10-09 Thread Ed Maste via cfe-commits
Author: emaste
Date: Tue Oct  9 17:34:17 2018
New Revision: 344100

URL: http://llvm.org/viewvc/llvm-project?rev=344100&view=rev
Log:
clang: Allow ifunc resolvers to accept arguments

When ifunc support was added to Clang (r265917) it did not allow
resolvers to take function arguments.  This was based on GCC's
documentation, which states resolvers return a pointer and take no
arguments.

However, GCC actually allows resolvers to take arguments, and glibc (on
non-x86 platforms) and FreeBSD (on x86 and arm64) pass some CPU
identification information as arguments to ifunc resolvers.  I believe
GCC's documentation is simply incorrect / out-of-date.

FreeBSD already removed the prohibition in their in-tree Clang copy.

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

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/Sema/attr-ifunc.c

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=344100&r1=344099&r2=344100&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Oct  9 17:34:17 2018
@@ -3428,7 +3428,7 @@ def IFuncDocs : Documentation {
   let Content = [{
 ``__attribute__((ifunc("resolver")))`` is used to mark that the address of a 
declaration should be resolved at runtime by calling a resolver function.
 
-The symbol name of the resolver function is given in quotes.  A function with 
this name (after mangling) must be defined in the current translation unit; it 
may be ``static``.  The resolver function should take no arguments and return a 
pointer.
+The symbol name of the resolver function is given in quotes.  A function with 
this name (after mangling) must be defined in the current translation unit; it 
may be ``static``.  The resolver function should return a pointer.
 
 The ``ifunc`` attribute may only be used on a function declaration.  A 
function declaration with an ``ifunc`` attribute is considered to be a 
definition of the declared entity.  The entity must not have weak linkage; for 
example, in C++, it cannot be applied to a declaration if a definition at that 
location would be considered inline.
 

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=344100&r1=344099&r2=344100&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Oct  9 17:34:17 
2018
@@ -2889,8 +2889,6 @@ def err_cyclic_alias : Error<
   "%select{alias|ifunc}0 definition is part of a cycle">;
 def err_ifunc_resolver_return : Error<
   "ifunc resolver function must return a pointer">;
-def err_ifunc_resolver_params : Error<
-  "ifunc resolver function must have no parameters">;
 def warn_attribute_wrong_decl_type_str : Warning<
   "%0 attribute only applies to %1">, InGroup;
 def err_attribute_wrong_decl_type_str : Error<

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=344100&r1=344099&r2=344100&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Oct  9 17:34:17 2018
@@ -322,8 +322,6 @@ void CodeGenModule::checkAliases() {
   assert(FTy);
   if (!FTy->getReturnType()->isPointerTy())
 Diags.Report(Location, diag::err_ifunc_resolver_return);
-  if (FTy->getNumParams())
-Diags.Report(Location, diag::err_ifunc_resolver_params);
 }
 
 llvm::Constant *Aliasee = Alias->getIndirectSymbol();

Modified: cfe/trunk/test/Sema/attr-ifunc.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-ifunc.c?rev=344100&r1=344099&r2=344100&view=diff
==
--- cfe/trunk/test/Sema/attr-ifunc.c (original)
+++ cfe/trunk/test/Sema/attr-ifunc.c Tue Oct  9 17:34:17 2018
@@ -27,10 +27,6 @@ void f4_ifunc() {}
 void f4() __attribute__((ifunc("f4_ifunc")));
 //expected-error@-1 {{ifunc resolver function must return a pointer}}
 
-void* f5_ifunc(int i) { return 0; }
-void f5() __attribute__((ifunc("f5_ifunc")));
-//expected-error@-1 {{ifunc resolver function must have no parameters}}
-
 #else
 void f1a() __asm("f1");
 void f1a() {}


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


[PATCH] D52949: [Diagnostics] Implement -Wsizeof-pointer-div

2018-10-09 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

ping


https://reviews.llvm.org/D52949



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


[PATCH] D46441: [clang][CodeGenCXX] Noalias attr for 'this' parameter

2018-10-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

I wonder if we should have a `-fno-strict-something` flag for this. I suppose 
there's no more effective way to find out than to try this and see what happens.




Comment at: lib/CodeGen/CGCall.cpp:2052
+//
+// We intentionally threat this behaviour as undefined by marking 
'this'
+// with noalias attribute and have recommended the Standard to be

thread -> treat


https://reviews.llvm.org/D46441



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


[PATCH] D52610: [Esan] Port cache frag to FreeBSD

2018-10-09 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added inline comments.



Comment at: lib/CodeGen/BackendUtil.cpp:323
 Opts.ToolType = EfficiencySanitizerOptions::ESAN_CacheFrag;
-  else if (LangOpts.Sanitize.has(SanitizerKind::EfficiencyWorkingSet))
+  else if (T.getOS() == Triple::Linux &&
+LangOpts.Sanitize.has(SanitizerKind::EfficiencyWorkingSet))

Is it possible to port it to FreeBSD and skip some conditions in generic code?


Repository:
  rC Clang

https://reviews.llvm.org/D52610



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


[PATCH] D51109: [Driver][cc1][cc1as] Call OptTable::PrintHelp with explicit " [options] file..."

2018-10-09 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344098: [Driver][cc1][cc1as] Call OptTable::PrintHelp with 
explicit " [options] file..." (authored by MaskRay, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D51109

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  cfe/trunk/tools/driver/cc1as_main.cpp


Index: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -183,7 +183,7 @@
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -68,6 +68,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -1433,7 +1434,8 @@
   if (!ShowHidden)
 ExcludedFlagsBitmask |= HelpHidden;
 
-  getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
+  std::string Usage = llvm::formatv("{0} [options] file...", Name).str();
+  getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(),
   IncludedFlagsBitmask, ExcludedFlagsBitmask,
   /*ShowAllAliases=*/false);
 }
Index: cfe/trunk/tools/driver/cc1as_main.cpp
===
--- cfe/trunk/tools/driver/cc1as_main.cpp
+++ cfe/trunk/tools/driver/cc1as_main.cpp
@@ -534,7 +534,8 @@
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;


Index: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -183,7 +183,7 @@
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);
Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -68,6 +68,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -1433,7 +1434,8 @@
   if (!ShowHidden)
 ExcludedFlagsBitmask |= HelpHidden;
 
-  getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
+  std::string Usage = llvm::formatv("{0} [options] file...", Name).str();
+  getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(),
   IncludedFlagsBitmask, ExcludedFlagsBitmask,
   /*ShowAllAliases=*/false);
 }
Index: cfe/trunk/tools/driver/cc1as_main.cpp
===
--- cfe/trunk/tools/driver/cc1as_main.cpp
+++ cfe/trunk/tools/driver/cc1as_main.cpp
@@ -534,7 +534,8 @@
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;
___
cf

r344098 - [Driver][cc1][cc1as] Call OptTable::PrintHelp with explicit " [options] file..."

2018-10-09 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Tue Oct  9 17:15:33 2018
New Revision: 344098

URL: http://llvm.org/viewvc/llvm-project?rev=344098&view=rev
Log:
[Driver][cc1][cc1as] Call OptTable::PrintHelp with explicit " [options] file..."

Summary: This is to accommodate a change in llvm/lib/Option/OptTable.cpp D51009

Reviewers: rupprecht, alexshap, jhenderson

Reviewed By: rupprecht

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=344098&r1=344097&r2=344098&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Oct  9 17:15:33 2018
@@ -68,6 +68,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -1433,7 +1434,8 @@ void Driver::PrintHelp(bool ShowHidden)
   if (!ShowHidden)
 ExcludedFlagsBitmask |= HelpHidden;
 
-  getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
+  std::string Usage = llvm::formatv("{0} [options] file...", Name).str();
+  getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(),
   IncludedFlagsBitmask, ExcludedFlagsBitmask,
   /*ShowAllAliases=*/false);
 }

Modified: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=344098&r1=344097&r2=344098&view=diff
==
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp Tue Oct  9 
17:15:33 2018
@@ -183,7 +183,7 @@ bool ExecuteCompilerInvocation(CompilerI
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=344098&r1=344097&r2=344098&view=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Tue Oct  9 17:15:33 2018
@@ -534,7 +534,8 @@ int cc1as_main(ArrayRef Ar
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;


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


[PATCH] D50616: [Fixed Point Arithmetic] FixedPointCast

2018-10-09 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

@ebevhan @rjmccall Seeing that the saturation intrinsic in 
https://reviews.llvm.org/D52286 should be put on hold for now, would it be fine 
to submit this patch as is? Then if the intrinsic is finished, come back to 
this and update this patch to use the intrinsic?


Repository:
  rC Clang

https://reviews.llvm.org/D50616



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


[PATCH] D51109: [Driver][cc1][cc1as] Call OptTable::PrintHelp with explicit " [options] file..."

2018-10-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 168913.
MaskRay retitled this revision from "[cc1][cc1as] Call OptTable::PrintHelp with 
explicit " [options] file..."" to "[Driver][cc1][cc1as] Call 
OptTable::PrintHelp with explicit " [options] file..."".
MaskRay added a comment.

Another reference in driver


Repository:
  rC Clang

https://reviews.llvm.org/D51109

Files:
  lib/Driver/Driver.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  tools/driver/cc1as_main.cpp


Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -534,7 +534,8 @@
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -183,7 +183,7 @@
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -68,6 +68,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -1433,7 +1434,8 @@
   if (!ShowHidden)
 ExcludedFlagsBitmask |= HelpHidden;
 
-  getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
+  std::string Usage = llvm::formatv("{0} [options] file...", Name).str();
+  getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(),
   IncludedFlagsBitmask, ExcludedFlagsBitmask,
   /*ShowAllAliases=*/false);
 }


Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -534,7 +534,8 @@
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -183,7 +183,7 @@
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -68,6 +68,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -1433,7 +1434,8 @@
   if (!ShowHidden)
 ExcludedFlagsBitmask |= HelpHidden;
 
-  getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(),
+  std::string Usage = llvm::formatv("{0} [options] file...", Name).str();
+  getOpts().PrintHelp(llvm::outs(), Usage.c_str(), DriverTitle.c_str(),
   IncludedFlagsBitmask, ExcludedFlagsBitmask,
   /*ShowAllAliases=*/false);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53048: [Basic] Split out -Wimplicit-int-conversion and -Wimplicit-float-conversion from -Wconversion

2018-10-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 168912.
erik.pilkington added a comment.

Actually run the tests!


https://reviews.llvm.org/D53048

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Sema/implicit-int-conversion.c


Index: clang/test/Sema/implicit-int-conversion.c
===
--- /dev/null
+++ clang/test/Sema/implicit-int-conversion.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-int-conversion 
-DSMALL=char -DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-conversion 
-DSMALL=char -DBIG=int
+// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-float-conversion 
-DSMALL=float -DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-float-conversion 
-DSMALL=float -DBIG=double
+
+void f() {
+  SMALL a;
+  BIG b = 0;
+  a = b;
+#ifndef NO_DIAG
+  // expected-warning@-2 {{implicit conversion}}
+#else
+  // expected-no-diagnostics
+#endif
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3183,10 +3183,10 @@
   "implicit conversion from %0 to %1 is not permitted in C++">;
 def warn_impcast_float_precision : Warning<
   "implicit conversion loses floating-point precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_float_result_precision : Warning<
   "implicit conversion when assigning computation result loses floating-point 
precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_double_promotion : Warning<
   "implicit conversion increases floating-point precision: %0 to %1">,
   InGroup, DefaultIgnore;
@@ -3198,10 +3198,10 @@
   InGroup, DefaultIgnore;
 def warn_impcast_integer_precision : Warning<
   "implicit conversion loses integer precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_high_order_zero_bits : Warning<
   "higher order bits are zeroes after implicit conversion">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_nonnegative_result : Warning<
   "the resulting value is always non-negative after implicit conversion">,
   InGroup, DefaultIgnore;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -59,6 +59,8 @@
UndefinedBoolConversion]>;
 def IntConversion : DiagGroup<"int-conversion">;
 def EnumConversion : DiagGroup<"enum-conversion">;
+def ImplicitIntConversion : DiagGroup<"implicit-int-conversion">;
+def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion">;
 
 def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
 def FloatZeroConversion : DiagGroup<"float-zero-conversion">;
@@ -709,6 +711,8 @@
 FloatConversion,
 Shorten64To32,
 IntConversion,
+ImplicitIntConversion,
+ImplicitFloatConversion,
 LiteralConversion,
 NonLiteralNullConversion, // (1-1)->pointer (etc)
 NullConversion, // NULL->non-pointer


Index: clang/test/Sema/implicit-int-conversion.c
===
--- /dev/null
+++ clang/test/Sema/implicit-int-conversion.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-int-conversion -DSMALL=char -DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-int-conversion -DSMALL=char -DBIG=int
+// RUN: %clang_cc1 %s -verify -Wconversion -Wno-implicit-float-conversion -DSMALL=float -DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 %s -verify -Wno-conversion -Wimplicit-float-conversion -DSMALL=float -DBIG=double
+
+void f() {
+  SMALL a;
+  BIG b = 0;
+  a = b;
+#ifndef NO_DIAG
+  // expected-warning@-2 {{implicit conversion}}
+#else
+  // expected-no-diagnostics
+#endif
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3183,10 +3183,10 @@
   "implicit conversion from %0 to %1 is not permitted in C++">;
 def warn_impcast_float_precision : Warning<
   "implicit conversion loses floating-point precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_float_result_precision : Warning<
   "implicit conversion when assigning computation result loses floating-point precision:

[PATCH] D53048: [Basic] Split out -Wimplicit-int-conversion and -Wimplicit-float-conversion from -Wconversion

2018-10-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: clang/test/Sema/implicit-int-conversion.c:1-4
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-int-conversion -DSMALL=char 
-DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-int-conversion -DSMALL=char 
-DBIG=int
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-float-conversion -DSMALL=float 
-DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-float-conversion -DSMALL=float 
-DBIG=double

dexonsmith wrote:
> Are these RUN lines missing `-verify`?
Yep, also %s! Good catch.


https://reviews.llvm.org/D53048



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


[PATCH] D53048: [Basic] Split out -Wimplicit-int-conversion and -Wimplicit-float-conversion from -Wconversion

2018-10-09 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/test/Sema/implicit-int-conversion.c:1-4
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-int-conversion -DSMALL=char 
-DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-int-conversion -DSMALL=char 
-DBIG=int
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-float-conversion -DSMALL=float 
-DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-float-conversion -DSMALL=float 
-DBIG=double

Are these RUN lines missing `-verify`?


Repository:
  rC Clang

https://reviews.llvm.org/D53048



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


[PATCH] D51109: [cc1][cc1as] Call OptTable::PrintHelp with explicit " [options] file..."

2018-10-09 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 168898.
MaskRay retitled this revision from "[cc1][cc1as] Call OptTable::PrintHelp with 
explicit " [options] "" to "[cc1][cc1as] Call OptTable::PrintHelp with 
explicit " [options] file..."".
MaskRay removed a reviewer: clang.
MaskRay removed subscribers: sdardis, atanasyan.
MaskRay added a comment.

Refresh the commit and update title


Repository:
  rC Clang

https://reviews.llvm.org/D51109

Files:
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  tools/driver/cc1as_main.cpp


Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -534,7 +534,8 @@
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -183,7 +183,7 @@
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);


Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -534,7 +534,8 @@
 
   if (Asm.ShowHelp) {
 std::unique_ptr Opts(driver::createDriverOptTable());
-Opts->PrintHelp(llvm::outs(), "clang -cc1as", "Clang Integrated Assembler",
+Opts->PrintHelp(llvm::outs(), "clang -cc1as [options] file...",
+"Clang Integrated Assembler",
 /*Include=*/driver::options::CC1AsOption, /*Exclude=*/0,
 /*ShowAllAliases=*/false);
 return 0;
Index: lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -183,7 +183,7 @@
   // Honor -help.
   if (Clang->getFrontendOpts().ShowHelp) {
 std::unique_ptr Opts = driver::createDriverOptTable();
-Opts->PrintHelp(llvm::outs(), "clang -cc1",
+Opts->PrintHelp(llvm::outs(), "clang -cc1 [options] file...",
 "LLVM 'Clang' Compiler: http://clang.llvm.org";,
 /*Include=*/driver::options::CC1Option,
 /*Exclude=*/0, /*ShowAllAliases=*/false);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52727: [clang-tidy] White List Option for performance-unnecessary-value-param, performance-unnecessary-copy-initialization and performance-for-range-copy

2018-10-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

LG other than the `hasCanonicalType()` vs `hasType()` question.


https://reviews.llvm.org/D52727



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


[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-10-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D52998#1258962, @eandrews wrote:

> Yes. I understand. At the moment, exception handling flags are generated 
> based on `BENCHMARK_ENABLE_EXCEPTIONS`  in `utils/benchmark/CMakeLists.txt` . 
>  However, `_HAS_EXCEPTIONS` is not defined based on this (code below). The 
> warnings are a result of this mismatch.
>
>   if (NOT BENCHMARK_ENABLE_EXCEPTIONS)
>   add_cxx_compiler_flag(-EHs-)
>   add_cxx_compiler_flag(-EHa-)
> endif()
>
>
> I think it makes most sense to add definition for `_HAS_EXCEPTIONS=0 `here as 
> opposed to modifying `llvm/CMakeLists.txt`.


Then i'd recommend/suggest to submit this upstream 
 first.

> Please correct me if I'm wrong. I'm not too familiar with CMake. @kbobyrev 
> Please let me know what you think as well since you had suggested 
> `llvm/CMakeLists.txt`.


https://reviews.llvm.org/D52998



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


[PATCH] D51866: [analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: 
lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp:519
+
+if (FirstAccess->getBeginLoc() < FirstGuard->getBeginLoc())
+  return true;

george.karpenkov wrote:
> Szelethus wrote:
> > xazax.hun wrote:
> > > I am not sure if this is a reliable way to check if the access is before 
> > > the guard.
> > > 
> > > Consider:
> > > ```
> > > switch(x): {
> > >case 2: guard; access; break;
> > >case 1: access break;
> > > }
> > > ```
> > > 
> > > Here, we have no particular ordering between the access in case 1 and the 
> > > guard in case 2 at runtime. But relying on the source locations we might 
> > > come to the false conclusion that there is. Loops, gotos can cause 
> > > similar problems.
> > > I do understand that this might not be too easy to solve without 
> > > traversing the cfg and we might not want to do that but I think we should 
> > > at least add a test/todo. 
> > > I am not sure if this is a reliable way to check if the access is before 
> > > the guard.
> > I'm 100% sure it isn't. Using the CFG instead of matchers sounds like a 
> > great and difficult to implement (at least to me, as I never touched them) 
> > idea. It should get rid of the false negatives, at least in part.
> > > [...]  I think we should at least add a test/todo.
> > There are some :)
> > Using the CFG instead of matchers sounds like a great and difficult to 
> > implement
> 
> That would also require building a dataflow framework, which we do not have 
> (yet)
Too bad :/ Makes me understand though why it would be valuable to implement it.


https://reviews.llvm.org/D51866



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


[PATCH] D51866: [analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus updated this revision to Diff 168885.
Szelethus added a comment.

Added new guards as recommended by @xazax.hun


https://reviews.llvm.org/D51866

Files:
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
  test/Analysis/cxx-uninitialized-object-unguarded-access.cpp

Index: test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
===
--- /dev/null
+++ test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
@@ -0,0 +1,397 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:IgnoreGuardedFields=true \
+// RUN:   -std=c++11 -verify  %s
+
+//===--===//
+// Helper functions for tests.
+//===--===//
+void halt() __attribute__((__noreturn__));
+void assert(int b) {
+  if (!b)
+halt();
+}
+
+int rand();
+
+//===--===//
+// Tests for fields properly guarded by asserts.
+//===--===//
+
+class NoUnguardedFieldsTest {
+public:
+  enum Kind {
+V,
+A
+  };
+
+private:
+  int Volume, Area;
+  Kind K;
+
+public:
+  NoUnguardedFieldsTest(Kind K) : K(K) {
+switch (K) {
+case V:
+  Volume = 0;
+  break;
+case A:
+  Area = 0;
+  break;
+}
+  }
+
+  void operator-() {
+assert(K == Kind::A);
+(void)Area;
+  }
+
+  void operator+() {
+assert(K == Kind::V);
+(void)Volume;
+  }
+};
+
+void fNoUnguardedFieldsTest() {
+  NoUnguardedFieldsTest T1(NoUnguardedFieldsTest::Kind::A);
+  NoUnguardedFieldsTest T2(NoUnguardedFieldsTest::Kind::V);
+}
+
+class NoUnguardedFieldsWithUndefMethodTest {
+public:
+  enum Kind {
+V,
+A
+  };
+
+private:
+  int Volume, Area;
+  Kind K;
+
+public:
+  NoUnguardedFieldsWithUndefMethodTest(Kind K) : K(K) {
+switch (K) {
+case V:
+  Volume = 0;
+  break;
+case A:
+  Area = 0;
+  break;
+}
+  }
+
+  void operator-() {
+assert(K == Kind::A);
+(void)Area;
+  }
+
+  void operator+() {
+assert(K == Kind::V);
+(void)Volume;
+  }
+
+  // We're checking method definitions for guards, so this is a no-crash test
+  // whether we handle methods without definitions.
+  void methodWithoutDefinition();
+};
+
+void fNoUnguardedFieldsWithUndefMethodTest() {
+  NoUnguardedFieldsWithUndefMethodTest
+  T1(NoUnguardedFieldsWithUndefMethodTest::Kind::A);
+  NoUnguardedFieldsWithUndefMethodTest
+  T2(NoUnguardedFieldsWithUndefMethodTest::Kind::V);
+}
+
+class UnguardedFieldThroughMethodTest {
+public:
+  enum Kind {
+V,
+A
+  };
+
+private:
+  int Volume, Area; // expected-note {{uninitialized field 'this->Volume'}}
+  Kind K;
+
+public:
+  UnguardedFieldThroughMethodTest(Kind K) : K(K) {
+switch (K) {
+case V:
+  Volume = 0;
+  break;
+case A:
+  Area = 0; // expected-warning {{1 uninitialized field}}
+  break;
+}
+  }
+
+  void operator-() {
+assert(K == Kind::A);
+(void)Area;
+  }
+
+  void operator+() {
+(void)Volume;
+  }
+};
+
+void fUnguardedFieldThroughMethodTest() {
+  UnguardedFieldThroughMethodTest T1(UnguardedFieldThroughMethodTest::Kind::A);
+}
+
+class UnguardedPublicFieldsTest {
+public:
+  enum Kind {
+V,
+A
+  };
+
+public:
+  // Note that fields are public.
+  int Volume, Area; // expected-note {{uninitialized field 'this->Volume'}}
+  Kind K;
+
+public:
+  UnguardedPublicFieldsTest(Kind K) : K(K) {
+switch (K) {
+case V:
+  Volume = 0;
+  break;
+case A:
+  Area = 0; // expected-warning {{1 uninitialized field}}
+  break;
+}
+  }
+
+  void operator-() {
+assert(K == Kind::A);
+(void)Area;
+  }
+
+  void operator+() {
+assert(K == Kind::V);
+(void)Volume;
+  }
+};
+
+void fUnguardedPublicFieldsTest() {
+  UnguardedPublicFieldsTest T1(UnguardedPublicFieldsTest::Kind::A);
+}
+
+//===--===//
+// Highlights of some false negatives due to syntactic checking.
+//===--===//
+
+class UnguardedFalseNegativeTest1 {
+public:
+  enum Kind {
+V,
+A
+  };
+
+private:
+  int Volume, Area;
+  Kind K;
+
+public:
+  UnguardedFalseNegativeTest1(Kind K) : K(K) {
+switch (K) {
+case V:
+  Volume = 0;
+  break;
+case A:
+  Area = 0;
+  break;
+}
+  }
+
+  void operator-() {
+if (rand())
+  assert(K == Kind::A);
+(void)Area;
+  }
+
+  void operator+() {
+if (rand())
+  assert(

[PATCH] D53048: [Basic] Split out -Wimplicit-int-conversion and -Wimplicit-float-conversion from -Wconversion

2018-10-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, aaron.ballman.
Herald added a subscriber: dexonsmith.

These two diagnostics are noisy, so its reasonable for users to opt-out of them 
when -Wconversion is enabled.

Fixes rdar://45058981

Thanks for taking a look!


Repository:
  rC Clang

https://reviews.llvm.org/D53048

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/Sema/implicit-int-conversion.c


Index: clang/test/Sema/implicit-int-conversion.c
===
--- /dev/null
+++ clang/test/Sema/implicit-int-conversion.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-int-conversion -DSMALL=char 
-DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-int-conversion -DSMALL=char 
-DBIG=int
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-float-conversion -DSMALL=float 
-DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-float-conversion -DSMALL=float 
-DBIG=double
+
+void f() {
+  SMALL a;
+  BIG b = 0;
+  a = b;
+#ifndef NO_DIAG
+  // expected-warning@-2 {{implicit conversion}}
+#else
+  // expected-no-diagnostics
+#endif
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3183,10 +3183,10 @@
   "implicit conversion from %0 to %1 is not permitted in C++">;
 def warn_impcast_float_precision : Warning<
   "implicit conversion loses floating-point precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_float_result_precision : Warning<
   "implicit conversion when assigning computation result loses floating-point 
precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_double_promotion : Warning<
   "implicit conversion increases floating-point precision: %0 to %1">,
   InGroup, DefaultIgnore;
@@ -3198,10 +3198,10 @@
   InGroup, DefaultIgnore;
 def warn_impcast_integer_precision : Warning<
   "implicit conversion loses integer precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_high_order_zero_bits : Warning<
   "higher order bits are zeroes after implicit conversion">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_nonnegative_result : Warning<
   "the resulting value is always non-negative after implicit conversion">,
   InGroup, DefaultIgnore;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -59,6 +59,8 @@
UndefinedBoolConversion]>;
 def IntConversion : DiagGroup<"int-conversion">;
 def EnumConversion : DiagGroup<"enum-conversion">;
+def ImplicitIntConversion : DiagGroup<"implicit-int-conversion">;
+def ImplicitFloatConversion : DiagGroup<"implicit-float-conversion">;
 
 def FloatOverflowConversion : DiagGroup<"float-overflow-conversion">;
 def FloatZeroConversion : DiagGroup<"float-zero-conversion">;
@@ -709,6 +711,8 @@
 FloatConversion,
 Shorten64To32,
 IntConversion,
+ImplicitIntConversion,
+ImplicitFloatConversion,
 LiteralConversion,
 NonLiteralNullConversion, // (1-1)->pointer (etc)
 NullConversion, // NULL->non-pointer


Index: clang/test/Sema/implicit-int-conversion.c
===
--- /dev/null
+++ clang/test/Sema/implicit-int-conversion.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-int-conversion -DSMALL=char -DBIG=int -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-int-conversion -DSMALL=char -DBIG=int
+// RUN: %clang_cc1 -Wconversion -Wno-implicit-float-conversion -DSMALL=float -DBIG=double -DNO_DIAG
+// RUN: %clang_cc1 -Wno-conversion -Wimplicit-float-conversion -DSMALL=float -DBIG=double
+
+void f() {
+  SMALL a;
+  BIG b = 0;
+  a = b;
+#ifndef NO_DIAG
+  // expected-warning@-2 {{implicit conversion}}
+#else
+  // expected-no-diagnostics
+#endif
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3183,10 +3183,10 @@
   "implicit conversion from %0 to %1 is not permitted in C++">;
 def warn_impcast_float_precision : Warning<
   "implicit conversion loses floating-point precision: %0 to %1">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_impcast_flo

[PATCH] D53046: [Sema] Fix an error-on-valid with friends and templates

2018-10-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:10015
 // merged.
 if (MergeFunctionDecl(NewFD, OldDecl, S, MergeTypeWithPrevious)) {
   NewFD->setInvalidDecl();

The problem is here, MergeFunctionDecl() needs the injected template args, 
but...



Comment at: clang/lib/Sema/SemaDecl.cpp:10026
   auto *OldFD = OldTemplateDecl->getTemplatedDecl();
   NewFD->setPreviousDeclaration(OldFD);
   adjustDeclContextForDeclaratorDecl(NewFD, OldFD);

... we don't link the two declarations until here!


Repository:
  rC Clang

https://reviews.llvm.org/D53046



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


[PATCH] D53046: [Sema] Fix an error-on-valid with friends and templates

2018-10-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rsmith, rjmccall.
Herald added a subscriber: dexonsmith.

Clang used to error out on the attached testcase, due to multiple definitions 
of `foo`. The problem is that multiple FunctionTemplateDecl::Common 
pointers are created for the two FunctionTemplateDeclarations `foo` in the 
redeclaration chain, each with their own copy of the instantiation of `f`.

This patch fixes the problem by using the previous function template in a call 
to `FuntionTemplateDecl::getInjectedTemplateArgs()` (this was the call that 
caused the Common pointer to be allocated in the redeclaration). Most of this 
patch is just boilerplate to get the function template declaration down the 
stack to where it's needed.

Fixes rdar://44810129

Thanks for taking a look!
Erik


Repository:
  rC Clang

https://reviews.llvm.org/D53046

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/friend-template-redecl.cpp

Index: clang/test/SemaCXX/friend-template-redecl.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/friend-template-redecl.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++17 -verify -emit-llvm-only %s
+
+// expected-no-diagnostics
+
+template  void bar(const T &t) { foo(t); }
+
+template 
+struct HasFriend {
+  template 
+  friend void foo(const HasFriend &m) noexcept(false);
+};
+
+template 
+void foo(const HasFriend &m) noexcept(false) {}
+
+void f() {
+  HasFriend x;
+  foo(x);
+  bar(x);
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3575,7 +3575,8 @@
 }
 
 void Sema::InstantiateExceptionSpec(SourceLocation PointOfInstantiation,
-FunctionDecl *Decl) {
+FunctionDecl *Decl,
+FunctionDecl *OldDecl) {
   const FunctionProtoType *Proto = Decl->getType()->castAs();
   if (Proto->getExceptionSpecType() != EST_Uninstantiated)
 return;
@@ -3601,8 +3602,9 @@
   Sema::ContextRAII savedContext(*this, Decl);
   LocalInstantiationScope Scope(*this);
 
-  MultiLevelTemplateArgumentList TemplateArgs =
-getTemplateInstantiationArgs(Decl, nullptr, /*RelativeToPrimary*/true);
+  MultiLevelTemplateArgumentList TemplateArgs = getTemplateInstantiationArgs(
+  Decl, nullptr, /*RelativeToPrimary*/ true, nullptr,
+  !OldDecl ? nullptr : OldDecl->getDescribedFunctionTemplate());
 
   FunctionDecl *Template = Proto->getExceptionSpecTemplate();
   if (addInstantiatedParametersToScope(*this, Decl, Template, Scope,
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -51,11 +51,16 @@
 /// instantiating the definition of the given declaration, \p D. This is
 /// used to determine the proper set of template instantiation arguments for
 /// friend function template specializations.
+///
+/// \param PrevFunTmpl If non-NULL, D is a pattern declaration of a function
+/// template that hasn't yet been attached to the redeclaration chain of
+/// PrevFunTmpl's pattern.
 MultiLevelTemplateArgumentList
 Sema::getTemplateInstantiationArgs(NamedDecl *D,
const TemplateArgumentList *Innermost,
bool RelativeToPrimary,
-   const FunctionDecl *Pattern) {
+   const FunctionDecl *Pattern,
+   FunctionTemplateDecl *PrevFunTmpl) {
   // Accumulate the set of template argument lists in this structure.
   MultiLevelTemplateArgumentList Result;
 
@@ -151,6 +156,16 @@
 
   } else if (FunctionTemplateDecl *FunTmpl
= Function->getDescribedFunctionTemplate()) {
+if (PrevFunTmpl) {
+  // FunTmpl hasn't been linked into the same redecl chain as
+  // PrevFunTmpl yet, so we can't retreive it's injected template
+  // arguments just yet; use PrevFunTmpl's instead.
+  //
+  // Note that we don't need to verify that FunTmpl is the function
+  // template that is a redeclaration of PrevFunTmpl because only one
+  // function template decl can appear in this search.
+  FunTmpl = PrevFunTmpl;
+}
 // Add the "injected" template arguments.
 Result.addOuterTemplateArguments(FunTmpl->getInjectedTemplateArgs());
   }
Index: clang/lib/Sema/SemaExceptionSpec.cpp
===
--- clang/

[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

> What's more, given that clang-output has no real documentation to speak of, 
> how will users even *know* to update their scripts?

The release notes will tell them.

But your comment also raises a different point: If there is so little 
clang-query documentation, what justification is there for relying on current 
behavior?

Also, what scripts are you referring to that rely on clang-query? Do we know of 
any that are expected to work long-term without maintenance (unlikely, as the 
AST itself is not stable), or is this concern imagined?

> can you expound on your concerns?

After this patch, the user writes

  set dump-output true

or `false`.

and after the follow-up (https://reviews.llvm.org/D52859) they write

  set matcher-output true

After more features I have in the pipeline they will write other similar 
commands.

With my command-design, if a user wants to enable dump output in addition to 
what they have, they just

  set dump-output true

In your design, they have to recall/find out what options are currently 
enabled, and add them in a comma separated list. That is not user-friendly.

> wonder whether set blah-output options are mutually exclusive or not.

These options are obviously and clearly toggles. There is definitely no reason 
to think that they are mutually exclusive any more than there is reason to 
think `set output dump` is mutually exclusive with `set bind-root false`.

And even if someone did wonder that, they would just try it and learn that they 
are toggles.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D52905: [analyzer] fix accessing GDM data from shared libraries

2018-10-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

> there's a way to run clang-tidy over all of clang+llvm automatically

cmake should generate compile_commands.json by default, and then you could just 
point clang-tidy at that.


Repository:
  rC Clang

https://reviews.llvm.org/D52905



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


[PATCH] D53042: [X86] Remove FeatureRTM from Skylake processor list

2018-10-09 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: lib/Basic/Targets/X86.cpp:169
 setFeatureEnabledImpl(Features, "mpx", true);
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);

> high-end desktop and server chips (I can't find any SKX without).

Are you sure you didn't want to move it into an else of this `if()` ?


Repository:
  rC Clang

https://reviews.llvm.org/D53042



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


[PATCH] D53042: [X86] Remove FeatureRTM from Skylake processor list

2018-10-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D53042



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


[PATCH] D53042: [X86] Remove FeatureRTM from Skylake processor list

2018-10-09 Thread Thiago Macieira via Phabricator via cfe-commits
thiagomacieira created this revision.
thiagomacieira added reviewers: erichkeane, craig.topper.
Herald added a subscriber: cfe-commits.
craig.topper retitled this revision from "Remove FeatureRTM from Skylake 
processor list" to "[X86] Remove FeatureRTM from Skylake processor list".

There are a LOT of Skylakes and later without TSX-NI. Examples:

- SKL: 
https://ark.intel.com/products/136863/Intel-Core-i3-8121U-Processor-4M-Cache-up-to-3-20-GHz-
- KBL: 
https://ark.intel.com/products/97540/Intel-Core-i7-7560U-Processor-4M-Cache-up-to-3-80-GHz-
- KBL-R: 
https://ark.intel.com/products/149091/Intel-Core-i7-8565U-Processor-8M-Cache-up-to-4-60-GHz-
- CNL: 
https://ark.intel.com/products/136863/Intel-Core-i3-8121U-Processor-4M-Cache-up-to-3_20-GHz

This feature seems to be present only on high-end desktop and server
chips (I can't find any SKX without). This commit leaves it disabled
for all processors, but can be re-enabled for specific builds with
-mrtm.

Matches https://reviews.llvm.org/D53041


Repository:
  rC Clang

https://reviews.llvm.org/D53042

Files:
  lib/Basic/Targets/X86.cpp


Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -169,7 +169,6 @@
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);
 setFeatureEnabledImpl(Features, "clflushopt", true);
-setFeatureEnabledImpl(Features, "rtm", true);
 setFeatureEnabledImpl(Features, "aes", true);
 LLVM_FALLTHROUGH;
   case CK_Broadwell:


Index: lib/Basic/Targets/X86.cpp
===
--- lib/Basic/Targets/X86.cpp
+++ lib/Basic/Targets/X86.cpp
@@ -169,7 +169,6 @@
 if (Kind != CK_SkylakeServer) // SKX inherits all SKL features, except SGX
   setFeatureEnabledImpl(Features, "sgx", true);
 setFeatureEnabledImpl(Features, "clflushopt", true);
-setFeatureEnabledImpl(Features, "rtm", true);
 setFeatureEnabledImpl(Features, "aes", true);
 LLVM_FALLTHROUGH;
   case CK_Broadwell:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53024: [analyzer][www] Add more open projects

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

Thanks!

I admit that the difficulty was mostly chosen at random, so that could be 
brought closer to the actual difficulty of the project.




Comment at: www/analyzer/open_projects.html:86-87
+the opposite direction - integers to pointers - are completely unsupported.
+Pointer-to-pointer casts are a mess; modeling them with https://clang.llvm.org/doxygen/classclang_1_1ento_1_1ElementRegion.html";>
+ElementRegion  is a disaster and we are suffering a lot from 
this
+hack, but coming up with a significantly better solution is very hard, as

NoQ wrote:
> I'll try to be more, emm, positive on the website :]
Oh, right, sorry, I tried to "positivitize" most of these, but apparently 
missed this one O:)


Repository:
  rC Clang

https://reviews.llvm.org/D53024



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


[PATCH] D52990: [MinGW] Fix passing a sanitizer lib name as dependent lib

2018-10-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D52990



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Hi  ymandel,

welcome to the LLVM community and thank you very much for working on that check!
If you have any questions or other issues don't hesitate to ask ;)




Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:25
+
+// Finds the location of the relevant "const" token in `Def`.
+llvm::Optional findConstToRemove(

s/"const"/`const`



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:26
+// Finds the location of the relevant "const" token in `Def`.
+llvm::Optional findConstToRemove(
+const FunctionDecl *Def, const MatchFinder::MatchResult &Result) {

Please use a `static` function instead of a anonymous namespace. These are only 
used for local classes.



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:37
+  if (FileRange.isInvalid())
+return {};
+

Please return `None` instead, same below



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:60
+  const auto *Def = Result.Nodes.getNodeAs("func");
+  if (!Def->getReturnType().isLocalConstQualified()) {
+return;

Please ellide the braces



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:64
+
+  // Fix the definition.
+  llvm::Optional Loc = findConstToRemove(Def, Result);

I feel that this comment doesn't add value. Could you please either make it 
more expressive or remove it?



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:65
+  // Fix the definition.
+  llvm::Optional Loc = findConstToRemove(Def, Result);
+  if (!Loc)

This check does not produce diagnostics if something in the lexing went wrong.
I think even if its not possible to do transformation the warning could still 
be emitted (at functionDecl location). What do you think?



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:71
+  diag(*Loc,
+   "avoid marking return types as ``const`` for values, as it often  "
+   "disables optimizations and causes unnecessary copies")

please shorten that warning a bit and use 'const'.

Maybe `'const'-qualified return values hinder compiler optimizations` or 
something in this direction?



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:79
+   Decl = Decl->getPreviousDecl()) {
+if (const llvm::Optional PrevLoc =
+findConstToRemove(Decl, Result)) {

The `const` is not common in llvm-code. Please use it only for references and 
pointers.

What do you think about emitting a `note` if this transformation can not be 
done? It is relevant for the user as he might need to do manual fix-up. It 
would complicate the code as there can only be one(?) diagnostic at the same 
time (90% sure only tbh).



Comment at: docs/clang-tidy/checks/list.rst:12
abseil-redundant-strcat-calls
-   abseil-string-find-startswith
abseil-str-cat-append

spurious change



Comment at: docs/clang-tidy/checks/readability-const-value-return.rst:19
+Note that this does not apply to returning pointers or references to const
+values.  These are fine:
+

please remove the double space



Comment at: test/clang-tidy/Inputs/readability-const-value-return/macro-def.h:1
+#ifndef MACRO_DEF_H
+#define MACRO_DEF_H

You can define these macros directly in the test-case, or do you intend 
something special? Self-contained tests are prefered.



Comment at: test/clang-tidy/readability-const-value-return.cpp:4
+
+#include "macro-def.h"
+

Please add tests, were the `const` is hidden behind typedefs/using. 

I feel that there should be more test that try to break the lexing part as well.
E.g. `const /** I am a comment */ /* weird*/ int function();` be creative here 
;)

Could you please add a test-case `int ** const * multiple_ptr();` and `int 
*const & pointer_ref();`



Comment at: test/clang-tidy/readability-const-value-return.cpp:53
+  const Strukt* const p7();
+  // CHECK-FIXES: const Strukt* p7();
+

Missing warning?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[PATCH] D53038: [Hexagon] Use GetLinkerPath method instead of hard-coded linker name.

2018-10-09 Thread Sid Manning via Phabricator via cfe-commits
sidneym created this revision.
sidneym added reviewers: shankare, ruiu, kparzysz, bcain.
Herald added a subscriber: cfe-commits.

Use GetLinkerPath method instead of hard-coding linker name.

Change should allow -fuse-ld to work on the Hexagon target.


Repository:
  rC Clang

https://reviews.llvm.org/D53038

Files:
  lib/Driver/ToolChains/Hexagon.cpp
  lib/Driver/ToolChains/Hexagon.h


Index: lib/Driver/ToolChains/Hexagon.h
===
--- lib/Driver/ToolChains/Hexagon.h
+++ lib/Driver/ToolChains/Hexagon.h
@@ -81,6 +81,9 @@
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+
+  const char *getDefaultLinker() const override { return "hexagon-link"; }
+
   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const 
override;
 
   StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
Index: lib/Driver/ToolChains/Hexagon.cpp
===
--- lib/Driver/ToolChains/Hexagon.cpp
+++ lib/Driver/ToolChains/Hexagon.cpp
@@ -369,9 +369,8 @@
   constructHexagonLinkArgs(C, JA, HTC, Output, Inputs, Args, CmdArgs,
LinkingOutput);
 
-  std::string Linker = HTC.GetProgramPath("hexagon-link");
-  C.addCommand(llvm::make_unique(JA, *this, 
Args.MakeArgString(Linker),
-  CmdArgs, Inputs));
+  const char *Exec = Args.MakeArgString(HTC.GetLinkerPath());
+  C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 // Hexagon tools end.
 


Index: lib/Driver/ToolChains/Hexagon.h
===
--- lib/Driver/ToolChains/Hexagon.h
+++ lib/Driver/ToolChains/Hexagon.h
@@ -81,6 +81,9 @@
   void addLibStdCxxIncludePaths(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
+
+  const char *getDefaultLinker() const override { return "hexagon-link"; }
+
   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
 
   StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
Index: lib/Driver/ToolChains/Hexagon.cpp
===
--- lib/Driver/ToolChains/Hexagon.cpp
+++ lib/Driver/ToolChains/Hexagon.cpp
@@ -369,9 +369,8 @@
   constructHexagonLinkArgs(C, JA, HTC, Output, Inputs, Args, CmdArgs,
LinkingOutput);
 
-  std::string Linker = HTC.GetProgramPath("hexagon-link");
-  C.addCommand(llvm::make_unique(JA, *this, Args.MakeArgString(Linker),
-  CmdArgs, Inputs));
+  const char *Exec = Args.MakeArgString(HTC.GetLinkerPath());
+  C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs, Inputs));
 }
 // Hexagon tools end.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52924: Make __builtin_object_size use the EM_IgnoreSideEffects evaluation mode.

2018-10-09 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv accepted this revision.
george.burgess.iv added a comment.

Thanks!


https://reviews.llvm.org/D52924



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


[PATCH] D52857: Deprecate 'set output foo' API of clang-query

2018-10-09 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D52857#1258893, @steveire wrote:

> - The scripts will continue to work at least until `set output` is removed, 
> which is not going to happen soon.


Certainly, but given that deprecation implies eventual removal, people are 
still being asked to update their scripts. What's more, given that clang-output 
has no real documentation to speak of, how will users even *know* to update 
their scripts? Rather than invent ways to address these concerns, I'm much more 
in favor of making the feature work using a backwards compatible syntax. Then 
no one has to update their scripts to get identical functionality.

> - A comma-delimited list of options means that if I have `foo, bar, bat`  
> enabled and want to add `bang`, I need to `set output foo, bar, bat, bang`. 
> Or alternatively if I want to remove `bat`, I need to write out all the 
> others. I don't think that's suitable.

Correct -- if you want different output because new options are available, you 
need to opt into it. I'm not certain what the issue is with that; can you 
expound on your concerns? From what I'm seeing in the patch, it looks like you 
want user to write:

  set dump-output
  set diag-output
  match foo(bar(baz()))

and I'm asking for it to instead be:

  set output dump, diag
  match foo(bar(baz()))

Functionally, I believe these are equivalent. However, I think the latter is 
more clear for users as it implies a set of output options rather than leaving 
you to wonder whether `set blah-output` options are mutually exclusive or not.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52857



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


[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Whoa thanks! Will have a closer look again.




Comment at: www/analyzer/open_projects.html:33
+
+Handle aggregate construction.
+Aggregates are object that can be brace-initialized without calling a

I'll try to list other constructor kinds that i have in mind.



Comment at: www/analyzer/open_projects.html:76
+still suppress false positives, but will not prevent us from inlining the 
+ethods, and therefore will not cause other false positives. Verifying this
+hypothesis would be a wonderful accomplishment. Previous understanding of

Typo: methods.



Comment at: www/analyzer/open_projects.html:86-87
+the opposite direction - integers to pointers - are completely unsupported.
+Pointer-to-pointer casts are a mess; modeling them with https://clang.llvm.org/doxygen/classclang_1_1ento_1_1ElementRegion.html";>
+ElementRegion  is a disaster and we are suffering a lot from 
this
+hack, but coming up with a significantly better solution is very hard, as

I'll try to be more, emm, positive on the website :]



Comment at: www/analyzer/open_projects.html:234
+  Because LLVM doesn't have branches, unfinished checkers first land in
+  alpha, and are only moved out once they are production-ready. Howeever, over
+  the years many checkers got stuck in alpha, and their developtment have

Typo: However.



Comment at: www/analyzer/open_projects.html:235
+  alpha, and are only moved out once they are production-ready. Howeever, over
+  the years many checkers got stuck in alpha, and their developtment have
+  stalled.

Typo: Development.



Comment at: www/analyzer/open_projects.html:262
+same time, until the return value of pthread_mutex_destroy was checked by a
+branch in the code).
+(Difficulty: Easy)

Something is unfinished here.


Repository:
  rC Clang

https://reviews.llvm.org/D53024



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


[PATCH] D52983: [analyzer] Support Reinitializes attribute in MisusedMovedObject check

2018-10-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D52983#1258499, @xazax.hun wrote:

> In https://reviews.llvm.org/D52983#1258466, @NoQ wrote:
>
> > Yay, these look useful. Is there also an attribute for methods that should 
> > never be called on a 'moved-from' object?
>
>
> I do not know about such attribute, but once contracts are implemented and 
> wide-spread, a precondition on a method/function is a strong suggestion that 
> it should not be used on a moved-from object.


Well, that actually sounds like a pretty good heuristic, as long as we know 
that a moved-from object cannot reliably satisfy these contracts. In other 
words, it'll probably be fine for most library classes, but my concern is that 
the more contracts do we document this way, the more false positives would we 
have, which is not a healthy correlation. Like, for example, if we add a 
contract "the object is in a consistent state" to all methods of an STL object, 
eg. something like `this->_length == strlen(this->_buf)` for `std::string` 
methods, it might be a valid contract, but all moved-from objects would 
trivially satisfy it (because they are guaranteed to be in a consistent albeit 
unspecified state), so we won't be able to all any method at all.


Repository:
  rL LLVM

https://reviews.llvm.org/D52983



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


[PATCH] D52939: ExprConstant: Propagate correct return values from constant evaluation.

2018-10-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:12-32
 // Constant expression evaluation produces four main results:
 //
 //  * A success/failure flag indicating whether constant folding was 
successful.
 //This is the 'bool' return value used by most of the code in this file. A
 //'false' return value indicates that constant folding has failed, and any
 //appropriate diagnostic has already been produced.
 //

Is this comment still correct?



Comment at: clang/lib/AST/ExprConstant.cpp:682
 enum EvaluationMode {
-  /// Evaluate as a constant expression. Stop if we find that the 
expression
-  /// is not a constant expression.
+  /* The various EvaluationMode kinds vary in terms of what sorts of
+   * expressions they accept.

Nit: LLVM style avoids `/*...*/` comments even for long comment blocks like 
this (https://llvm.org/docs/CodingStandards.html#comment-formatting).



Comment at: clang/lib/AST/ExprConstant.cpp:686-687
+ Key for the following table:
+ * D = Diagnostic notes (about non-constexpr, but still evaluable
+   constructs) are OK (keepEvaluatingAfterNote)
+ * S = Failure to evaluate which only occurs in expressions used for

I think talking about diagnostic notes here distracts from the purpose, which 
is that this column indicates that we accept constructs that are not permitted 
by the language mode's constant expression rules.



Comment at: clang/lib/AST/ExprConstant.cpp:688-690
+ * S = Failure to evaluate which only occurs in expressions used for
+   side-effect are okay.  (keepEvaluatingAfterSideEffect)
+ * F = Failure to evaluate is okay. (keepEvaluatingAfterFailure)

"is okay" here is misleading, I think. The point of `keepEvaluatingAfter[...]` 
is that it's safe to stop evaluating if they return false, because later 
evaluations can't affect the overall result.



Comment at: clang/lib/AST/ExprConstant.cpp:692
+ * E = Eagerly evaluate certain builtins to a value which would 
normally
+   defer until after optimizations.
+

defer -> be deferred?



Comment at: clang/lib/AST/ExprConstant.cpp:706-707
+
+ TODO: Fix EM_ConstantExpression and EM_PotentialConstantExpression to
+ also eagerly evaluate. (and then delete
+ EM_PotentialConstantExpressionUnevaluated as a duplicate)

Allowing `EM_ConstantExpression` to evaluate expressions that `EM_ConstantFold` 
cannot evaluate would violate our invariants. We rely on being able to check up 
front that an expression is a constant expression and then later just ask for 
its value, and for the later query to always succeed and return the same value 
as the earlier one. (This is one of the reasons why I suggested in D52854 that 
we add an explicit AST representation for constant expressions.)



Comment at: clang/lib/AST/ExprConstant.cpp:711
+
+  /// Evaluate as a constant expression, as per C++11-and-later constexpr
+  /// rules. Stop if we find that the expression is not a constant

This is not the intent. The evaluator uses the rules of the current language 
mode. However, it doesn't enforce the C and C++98 syntactic restrictions on 
what can appear in a constant expression, because it turns out to be cleaner to 
check those separately rather than to interleave them with evaluation.

We should probably document this as evaluating following the evaluation (but 
not syntactic) constant expression rules of the current language mode.



Comment at: clang/lib/AST/ExprConstant.cpp:720-722
+  /// Like EM_ConstantFold, but eagerly attempt to evaluate some builtins
+  /// that'd otherwise fail constant evaluation to defer until after
+  /// optimization.  This affects __builtin_object_size (and in the future

This sentence is a little hard to read.



Comment at: clang/lib/AST/ExprConstant.cpp:891
 /// expression.
 ///
 OptionalDiagnostic CCEDiag(SourceLocation Loc, diag::kind DiagId

Nit: delete line



Comment at: clang/lib/AST/ExprConstant.cpp:952
+/// with diagnostics.
+bool keepEvaluatingAfterNote() {
   switch (EvalMode) {

"Note" is beside the point here. We should be talking about non-constant 
expressions; that's what matters.



Comment at: clang/lib/AST/ExprConstant.cpp:1227-1230
+diagnosePointerArithmetic(Info, E, N);
+setInvalid();
+if (!Info.keepEvaluatingAfterNote())
+  return false;

I would strongly prefer to keep the emission of the diagnostic and the 
corresponding `return false` adjacent whenever possible, so I'd prefer that we 
add a `bool` return value to `diagnoseP

[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 3 inline comments as done.
ymandel added a comment.

Thanks for the review. I've addressed the comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[PATCH] D52924: Make __builtin_object_size use the EM_IgnoreSideEffects evaluation mode.

2018-10-09 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks, looks like this has been largely redundant since r294800 removed the 
only interesting thing that `EM_OffsetFold` did.


https://reviews.llvm.org/D52924



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


[PATCH] D52905: [analyzer] fix accessing GDM data from shared libraries

2018-10-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D52905#1259249, @NoQ wrote:

> > where `isStaticLocal` is defined as:
>
> You can send this one as well if you like! It's weird that we don't already 
> have it.


Or actually maybe it can be implemented as `allOf(hasStaticStorageDuration(), 
unless(hasGlobalStorage()))`.


Repository:
  rC Clang

https://reviews.llvm.org/D52905



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


[PATCH] D52906: [analyzer] allow plugins built as shared libraries to receive events

2018-10-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Yup, this one looks great as well. I'll commit. Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D52906



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 168858.
ymandel added a comment.

Add missing const.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ConstValueReturnCheck.cpp
  clang-tidy/readability/ConstValueReturnCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-const-value-return.rst
  test/clang-tidy/Inputs/readability-const-value-return/
  test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
  test/clang-tidy/readability-const-value-return.cpp

Index: test/clang-tidy/readability-const-value-return.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-const-value-return.cpp
@@ -0,0 +1,139 @@
+// RUN: %check_clang_tidy %s readability-const-value-return %t -- -- \
+// RUN:   -I %S/Inputs/readability-const-value-return
+
+#include "macro-def.h"
+
+//  p# = positive test
+//  n# = negative test
+
+const int p1() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const`` for values, as it often disables optimizations and causes unnecessary copies
+// CHECK-FIXES: int p1() {
+  return 1;
+}
+
+const int p15();
+// CHECK-FIXES: int p15();
+
+template  class Klazz {};
+class Clazz {
+ public:
+  Clazz *const p2() {
+// CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``
+// CHECK-FIXES: Clazz *p2() {
+return this;
+  }
+
+  Clazz *const p3();
+  // CHECK-FIXES: Clazz *p3();
+
+  const int p4() const {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``c
+// CHECK-FIXES: int p4() const {
+return 4;
+  }
+
+  const Klazz* const p5() const;
+  // CHECK-FIXES: const Klazz* p5() const;
+
+  const Clazz operator++(int x) {  //  p12
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz operator++(int x) {
+  }
+
+  struct Strukt {
+int i;
+  };
+
+  const Strukt p6() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Strukt p6() {}
+
+  const Strukt* const p7();
+  // CHECK-FIXES: const Strukt* p7();
+
+  static const int p8() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static int p8() {}
+
+  static const Strukt p9() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static Strukt p9() {}
+
+  int n0() const { return 0; }
+  const Klazz& n11(const Klazz) const;
+};
+
+Clazz *const Clazz::p3() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *Clazz::p3() {
+  return this;
+}
+
+const Klazz* const Clazz::p5() const {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* Clazz::p5() const {}
+
+const Clazz::Strukt* const Clazz::p7() {}
+// CHECK-MESSAGES: [[@LINE-1]]:22: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Clazz::Strukt* Clazz::p7() {}
+
+Clazz *const p10();
+// CHECK-FIXES: Clazz *p10();
+
+Clazz *const p10() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *p10() {
+  return new Clazz();
+}
+
+const Clazz bar;
+const Clazz *const p11() {
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: avoid marking return types as ``co
+  // CHECK-FIXES: const Clazz *p11() {
+  return &bar;
+}
+
+const Klazz p12() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: Klazz p12() {}
+
+const Klazz* const p13() {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* p13() {}
+
+const auto p14() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``cons
+// CHECK-FIXES: auto p14() {
+  const int i = 0;
+  return i;
+}
+
+//another decl at top.
+const int p15();
+// CHECK-FIXES: int p15();
+const int p15() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: int p15() {
+  return 0;
+}
+
+const int n1 = 1;
+const Clazz n2 = Clazz();
+const Clazz* n3 = new Clazz();
+Clazz *const n4 = new Clazz();
+const Clazz *const n5 = new Clazz();
+constexpr int n6 = 6;
+constexpr int n7() { return 8; }
+const int eight = 8;
+constexpr const int* n8() { return &eight; }
+Klazz n9();
+const Klazz* n10();
+const Klazz& Clazz::n11(const Klazz) const {}
+const int n14();
+
+#define CONSTINT const int
+CONSTINT n12() {}
+
+// DEFFF in header.
+DEFFF n13() {}
Index: test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
===
--- /dev/null
+++ test/clang-tidy/I

[PATCH] D52905: [analyzer] fix accessing GDM data from shared libraries

2018-10-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> where `isStaticLocal` is defined as:

You can send this one as well if you like! It's weird that we don't already 
have it.


Repository:
  rC Clang

https://reviews.llvm.org/D52905



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


[PATCH] D52905: [analyzer] fix accessing GDM data from shared libraries

2018-10-09 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Cool, thanks! I'll commit.


Repository:
  rC Clang

https://reviews.llvm.org/D52905



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 168857.
ymandel marked 2 inline comments as done.
ymandel added a comment.

Dropped unneeded clang qualifier.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ConstValueReturnCheck.cpp
  clang-tidy/readability/ConstValueReturnCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-const-value-return.rst
  test/clang-tidy/Inputs/readability-const-value-return/
  test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
  test/clang-tidy/readability-const-value-return.cpp

Index: test/clang-tidy/readability-const-value-return.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-const-value-return.cpp
@@ -0,0 +1,139 @@
+// RUN: %check_clang_tidy %s readability-const-value-return %t -- -- \
+// RUN:   -I %S/Inputs/readability-const-value-return
+
+#include "macro-def.h"
+
+//  p# = positive test
+//  n# = negative test
+
+const int p1() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const`` for values, as it often disables optimizations and causes unnecessary copies
+// CHECK-FIXES: int p1() {
+  return 1;
+}
+
+const int p15();
+// CHECK-FIXES: int p15();
+
+template  class Klazz {};
+class Clazz {
+ public:
+  Clazz *const p2() {
+// CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``
+// CHECK-FIXES: Clazz *p2() {
+return this;
+  }
+
+  Clazz *const p3();
+  // CHECK-FIXES: Clazz *p3();
+
+  const int p4() const {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``c
+// CHECK-FIXES: int p4() const {
+return 4;
+  }
+
+  const Klazz* const p5() const;
+  // CHECK-FIXES: const Klazz* p5() const;
+
+  const Clazz operator++(int x) {  //  p12
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz operator++(int x) {
+  }
+
+  struct Strukt {
+int i;
+  };
+
+  const Strukt p6() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Strukt p6() {}
+
+  const Strukt* const p7();
+  // CHECK-FIXES: const Strukt* p7();
+
+  static const int p8() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static int p8() {}
+
+  static const Strukt p9() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static Strukt p9() {}
+
+  int n0() const { return 0; }
+  const Klazz& n11(const Klazz) const;
+};
+
+Clazz *const Clazz::p3() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *Clazz::p3() {
+  return this;
+}
+
+const Klazz* const Clazz::p5() const {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* Clazz::p5() const {}
+
+const Clazz::Strukt* const Clazz::p7() {}
+// CHECK-MESSAGES: [[@LINE-1]]:22: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Clazz::Strukt* Clazz::p7() {}
+
+Clazz *const p10();
+// CHECK-FIXES: Clazz *p10();
+
+Clazz *const p10() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *p10() {
+  return new Clazz();
+}
+
+const Clazz bar;
+const Clazz *const p11() {
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: avoid marking return types as ``co
+  // CHECK-FIXES: const Clazz *p11() {
+  return &bar;
+}
+
+const Klazz p12() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: Klazz p12() {}
+
+const Klazz* const p13() {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* p13() {}
+
+const auto p14() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``cons
+// CHECK-FIXES: auto p14() {
+  const int i = 0;
+  return i;
+}
+
+//another decl at top.
+const int p15();
+// CHECK-FIXES: int p15();
+const int p15() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: int p15() {
+  return 0;
+}
+
+const int n1 = 1;
+const Clazz n2 = Clazz();
+const Clazz* n3 = new Clazz();
+Clazz *const n4 = new Clazz();
+const Clazz *const n5 = new Clazz();
+constexpr int n6 = 6;
+constexpr int n7() { return 8; }
+const int eight = 8;
+constexpr const int* n8() { return &eight; }
+Klazz n9();
+const Klazz* n10();
+const Klazz& Clazz::n11(const Klazz) const {}
+const int n14();
+
+#define CONSTINT const int
+CONSTINT n12() {}
+
+// DEFFF in header.
+DEFFF n13() {}
Index: test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
==

[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 168856.
ymandel added a comment.

Minor changes addressing comments.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ConstValueReturnCheck.cpp
  clang-tidy/readability/ConstValueReturnCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-const-value-return.rst
  test/clang-tidy/Inputs/readability-const-value-return/
  test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
  test/clang-tidy/readability-const-value-return.cpp

Index: test/clang-tidy/readability-const-value-return.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-const-value-return.cpp
@@ -0,0 +1,139 @@
+// RUN: %check_clang_tidy %s readability-const-value-return %t -- -- \
+// RUN:   -I %S/Inputs/readability-const-value-return
+
+#include "macro-def.h"
+
+//  p# = positive test
+//  n# = negative test
+
+const int p1() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const`` for values, as it often disables optimizations and causes unnecessary copies
+// CHECK-FIXES: int p1() {
+  return 1;
+}
+
+const int p15();
+// CHECK-FIXES: int p15();
+
+template  class Klazz {};
+class Clazz {
+ public:
+  Clazz *const p2() {
+// CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``
+// CHECK-FIXES: Clazz *p2() {
+return this;
+  }
+
+  Clazz *const p3();
+  // CHECK-FIXES: Clazz *p3();
+
+  const int p4() const {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``c
+// CHECK-FIXES: int p4() const {
+return 4;
+  }
+
+  const Klazz* const p5() const;
+  // CHECK-FIXES: const Klazz* p5() const;
+
+  const Clazz operator++(int x) {  //  p12
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz operator++(int x) {
+  }
+
+  struct Strukt {
+int i;
+  };
+
+  const Strukt p6() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Strukt p6() {}
+
+  const Strukt* const p7();
+  // CHECK-FIXES: const Strukt* p7();
+
+  static const int p8() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static int p8() {}
+
+  static const Strukt p9() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static Strukt p9() {}
+
+  int n0() const { return 0; }
+  const Klazz& n11(const Klazz) const;
+};
+
+Clazz *const Clazz::p3() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *Clazz::p3() {
+  return this;
+}
+
+const Klazz* const Clazz::p5() const {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* Clazz::p5() const {}
+
+const Clazz::Strukt* const Clazz::p7() {}
+// CHECK-MESSAGES: [[@LINE-1]]:22: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Clazz::Strukt* Clazz::p7() {}
+
+Clazz *const p10();
+// CHECK-FIXES: Clazz *p10();
+
+Clazz *const p10() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *p10() {
+  return new Clazz();
+}
+
+const Clazz bar;
+const Clazz *const p11() {
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: avoid marking return types as ``co
+  // CHECK-FIXES: const Clazz *p11() {
+  return &bar;
+}
+
+const Klazz p12() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: Klazz p12() {}
+
+const Klazz* const p13() {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* p13() {}
+
+const auto p14() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``cons
+// CHECK-FIXES: auto p14() {
+  const int i = 0;
+  return i;
+}
+
+//another decl at top.
+const int p15();
+// CHECK-FIXES: int p15();
+const int p15() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: int p15() {
+  return 0;
+}
+
+const int n1 = 1;
+const Clazz n2 = Clazz();
+const Clazz* n3 = new Clazz();
+Clazz *const n4 = new Clazz();
+const Clazz *const n5 = new Clazz();
+constexpr int n6 = 6;
+constexpr int n7() { return 8; }
+const int eight = 8;
+constexpr const int* n8() { return &eight; }
+Klazz n9();
+const Klazz* n10();
+const Klazz& Clazz::n11(const Klazz) const {}
+const int n14();
+
+#define CONSTINT const int
+CONSTINT n12() {}
+
+// DEFFF in header.
+DEFFF n13() {}
Index: test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
===
--- /dev/null
+++ t

[PATCH] D52673: [HIP] Remove disabled irif library

2018-10-09 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 updated this revision to Diff 168855.
ashi1 marked an inline comment as done.
ashi1 added a comment.

I've moved the hip.amdgcn.bc to the top of the libs. Updated test as well.


https://reviews.llvm.org/D52673

Files:
  lib/Driver/ToolChains/HIP.cpp
  test/Driver/hip-device-libs.hip


Index: test/Driver/hip-device-libs.hip
===
--- test/Driver/hip-device-libs.hip
+++ test/Driver/hip-device-libs.hip
@@ -21,8 +21,9 @@


 // COM: [[LLVM_LINK:"*.llvm-link"]]
-// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" 
"{{.*}}irif.amdgcn.bc"
+// COM-SAME: "{{.*}}hip.amdgcn.bc" "{{.*}}opencl.amdgcn.bc"
+// COM-SAME: "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc"
 // FLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_on.amdgcn.bc"
 // NOFLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_off.amdgcn.bc"
 // COM-SAME: {{.*}} "-o" "{{.*}}-gfx900-linked-{{.*bc}}"

Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -81,16 +81,16 @@
 else
   FlushDenormalControlBC = "oclc_daz_opt_off.amdgcn.bc";

-BCLibs.append({"opencl.amdgcn.bc",
-   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "irif.amdgcn.bc",
+BCLibs.append({"hip.amdgcn.bc", "opencl.amdgcn.bc",
+   "ocml.amdgcn.bc", "ockl.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
FlushDenormalControlBC,
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
"oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);

   // Add an intermediate output file.
   CmdArgs.push_back("-o");
   std::string TmpName =


Index: test/Driver/hip-device-libs.hip
===
--- test/Driver/hip-device-libs.hip
+++ test/Driver/hip-device-libs.hip
@@ -21,8 +21,9 @@


 // COM: [[LLVM_LINK:"*.llvm-link"]]
-// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" "{{.*}}irif.amdgcn.bc"
+// COM-SAME: "{{.*}}hip.amdgcn.bc" "{{.*}}opencl.amdgcn.bc"
+// COM-SAME: "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc"
 // FLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_on.amdgcn.bc"
 // NOFLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_off.amdgcn.bc"
 // COM-SAME: {{.*}} "-o" "{{.*}}-gfx900-linked-{{.*bc}}"

Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -81,16 +81,16 @@
 else
   FlushDenormalControlBC = "oclc_daz_opt_off.amdgcn.bc";

-BCLibs.append({"opencl.amdgcn.bc",
-   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "irif.amdgcn.bc",
+BCLibs.append({"hip.amdgcn.bc", "opencl.amdgcn.bc",
+   "ocml.amdgcn.bc", "ockl.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
FlushDenormalControlBC,
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
"oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);

   // Add an intermediate output file.
   CmdArgs.push_back("-o");
   std::string TmpName =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D52703: Allow ifunc resolvers to accept arguments

2018-10-09 Thread Eric Christopher via cfe-commits
SGTM.

On Tue, Oct 9, 2018, 7:57 AM James Y Knight via Phabricator <
revi...@reviews.llvm.org> wrote:

> jyknight accepted this revision.
> jyknight added a comment.
> This revision is now accepted and ready to land.
>
> Given that there's no technical reason for the compiler to prohibit this
> (it was just clang trying to diagnose a probable user-error, which turns
> out to not be as probable as ), this seems like the right solution to me.
>
>
> https://reviews.llvm.org/D52703
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53034: [clangd] Remove no-op crash handler, we never set a crash context.

2018-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: ioeric, ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay.

I think this was just copied from somewhere with the belief that it actually
did some crash handling.

Of course the question arises: *should* we set one? I don't think so:

- clangd used to crash a lot, now it's pretty stable, because we found and 
fixed the crashes. I think the long-term effects of crashing hard are good.
- the implementation can't do any magic, it just uses longjmp to return without 
running any destructors by default. This is unsafe in general (e.g. mutexes 
won't unlock) and will certainly end up leaking memory. Whatever UB caused the 
crash may still stomp all over global state, etc.

I think there's an argument for isolating the background indexer (autoindex)
because it's not directly under the user's control, the crash surface is larger,
and it doesn't particularly need to interact with the rest of clangd.
But there, fork() and communicate through the FS is safer.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53034

Files:
  clangd/ClangdUnit.cpp


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -31,7 +31,6 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -141,10 +140,6 @@
   if (!Clang)
 return llvm::None;
 
-  // Recover resources if we crash before exiting this method.
-  llvm::CrashRecoveryContextCleanupRegistrar CICleanup(
-  Clang.get());
-
   auto Action = llvm::make_unique();
   const FrontendInputFile &MainInput = Clang->getFrontendOpts().Inputs[0];
   if (!Action->BeginSourceFile(*Clang, MainInput)) {


Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -31,7 +31,6 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -141,10 +140,6 @@
   if (!Clang)
 return llvm::None;
 
-  // Recover resources if we crash before exiting this method.
-  llvm::CrashRecoveryContextCleanupRegistrar CICleanup(
-  Clang.get());
-
   auto Action = llvm::make_unique();
   const FrontendInputFile &MainInput = Clang->getFrontendOpts().Inputs[0];
   if (!Action->BeginSourceFile(*Clang, MainInput)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53013: [MinGW] Support MinGW style library names for default library pragmas

2018-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

If relying on logic in lld, this one can be discarded.


Repository:
  rC Clang

https://reviews.llvm.org/D53013



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


[PATCH] D52990: [MinGW] Allow using ubsan

2018-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 168848.
mstorsjo added a comment.

Relying on a linker pragma in sanitizers and mingw lib name logic in lld.


https://reviews.llvm.org/D52990

Files:
  lib/CodeGen/TargetInfo.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -17,9 +17,11 @@
 // RUN: %clang -target i386-pc-win32 -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN32
 // RUN: %clang -target i386-pc-win32 -fsanitize=undefined -x c++ %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN32 --check-prefix=CHECK-UNDEFINED-WIN-CXX
 // RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN64
+// RUN: %clang -target x86_64-w64-mingw32 -fsanitize=undefined %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN64-MINGW
 // RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined -x c++ %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN 
--check-prefix=CHECK-UNDEFINED-WIN64 --check-prefix=CHECK-UNDEFINED-WIN-CXX
 // CHECK-UNDEFINED-WIN32: "--dependent-lib={{[^"]*}}ubsan_standalone-i386.lib"
 // CHECK-UNDEFINED-WIN64: 
"--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib"
+// CHECK-UNDEFINED-WIN64-MINGW: 
"--dependent-lib={{[^"]*}}libclang_rt.ubsan_standalone-x86_64.a"
 // CHECK-UNDEFINED-WIN-CXX: 
"--dependent-lib={{[^"]*}}ubsan_standalone_cxx{{[^"]*}}.lib"
 // CHECK-UNDEFINED-WIN-SAME: 
"-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){18}"}}
 
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -2337,7 +2337,7 @@
   bool Quote = (Lib.find(" ") != StringRef::npos);
   std::string ArgStr = Quote ? "\"" : "";
   ArgStr += Lib;
-  if (!Lib.endswith_lower(".lib"))
+  if (!Lib.endswith_lower(".lib") && !Lib.endswith_lower(".a"))
 ArgStr += ".lib";
   ArgStr += Quote ? "\"" : "";
   return ArgStr;


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -17,9 +17,11 @@
 // RUN: %clang -target i386-pc-win32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN32
 // RUN: %clang -target i386-pc-win32 -fsanitize=undefined -x c++ %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN32 --check-prefix=CHECK-UNDEFINED-WIN-CXX
 // RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN64
+// RUN: %clang -target x86_64-w64-mingw32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN64-MINGW
 // RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined -x c++ %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN64 --check-prefix=CHECK-UNDEFINED-WIN-CXX
 // CHECK-UNDEFINED-WIN32: "--dependent-lib={{[^"]*}}ubsan_standalone-i386.lib"
 // CHECK-UNDEFINED-WIN64: "--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib"
+// CHECK-UNDEFINED-WIN64-MINGW: "--dependent-lib={{[^"]*}}libclang_rt.ubsan_standalone-x86_64.a"
 // CHECK-UNDEFINED-WIN-CXX: "--dependent-lib={{[^"]*}}ubsan_standalone_cxx{{[^"]*}}.lib"
 // CHECK-UNDEFINED-WIN-SAME: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){18}"}}
 
Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -2337,7 +2337,7 @@
   bool Quote = (Lib.find(" ") != StringRef::npos);
   std::string ArgStr = Quote ? "\"" : "";
   ArgStr += Lib;
-  if (!Lib.endswith_lower(".lib"))
+  if (!Lib.endswith_lower(".lib") && !Lib.endswith_lower(".a"))
 ArgStr += ".lib";
   ArgStr += Quote ? "\"" : "";
   return ArgStr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53032: [clangd] Minimal implementation of automatic static index, behind a flag.

2018-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ioeric.
Herald added subscribers: cfe-commits, jfb, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov, mgorny.

See tinyurl.com/clangd-automatic-index for design and goals.

Lots of limitations to keep this patch smallish, TODOs everywhere:

- no serialization to disk
- no changes to dynamic index, which now has a much simpler job
- no partitioning of symbols by file to avoid duplication of header symbols
- no reindexing of edited files
- only a single worker thread
- compilation database is slurped synchronously (doesn't scale)
- uses memindex, rebuilds after every file (should be dex, periodically)

Still needs tests, but should be ready for review of the basic shape.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53032

Files:
  clangd/CMakeLists.txt
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/Compiler.cpp
  clangd/Compiler.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/index/Background.cpp
  clangd/index/Background.h
  clangd/tool/ClangdMain.cpp

Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -167,6 +167,14 @@
 "eventually. Don't rely on it."),
 llvm::cl::init(""), llvm::cl::Hidden);
 
+static llvm::cl::opt AutoIndex(
+"auto-index",
+llvm::cl::desc(
+"Build a full index for the codebase containing edited files. "
+"Indexing will occur in the background. "
+"This option is still experimental, as the indexing is inefficient."),
+llvm::cl::init(false), llvm::cl::Hidden);
+
 enum CompileArgsFrom { LSPCompileArgs, FilesystemCompileArgs };
 static llvm::cl::opt CompileArgsFrom(
 "compile_args_from", llvm::cl::desc("The source of compile commands"),
@@ -316,9 +324,10 @@
   CCOpts.AllScopes = AllScopesCompletion;
 
   // Initialize and run ClangdLSPServer.
-  ClangdLSPServer LSPServer(
-  Out, CCOpts, CompileCommandsDirPath,
-  /*ShouldUseInMemoryCDB=*/CompileArgsFrom == LSPCompileArgs, Opts);
+  ClangdLSPServer LSPServer(Out, CCOpts, CompileCommandsDirPath,
+/*ShouldUseInMemoryCDB=*/CompileArgsFrom ==
+LSPCompileArgs,
+AutoIndex, Opts);
   constexpr int NoShutdownRequestErrorCode = 1;
   llvm::set_thread_name("clangd.main");
   // Change stdin to binary to not lose \r\n on windows.
Index: clangd/index/Background.h
===
--- /dev/null
+++ clangd/index/Background.h
@@ -0,0 +1,73 @@
+//===--- Background.h - Build an index in a background thread *- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUND_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUND_H
+
+#include "Context.h"
+#include "FSProvider.h"
+#include "index/Index.h"
+#include "index/FileIndex.h"
+#include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/Support/SHA1.h"
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+// Builds an in-memory index by by running the static indexer action over
+// all commands in a compilation database. Indexing happens in the background.
+// TODO: it should also persist its state on disk for fast start.
+class BackgroundIndex : public SwapIndex {
+public:
+  // TODO: FileSystemProvider is not const-correct.
+  // TODO: resource-dir injection should be hoisted somewhere common.
+  BackgroundIndex(Context BackgroundContext,
+  StringRef ResourceDir, FileSystemProvider *);
+  ~BackgroundIndex(); // Blocks while the current task finishes.
+
+  // Index all TUs described in the compilation database.
+  // The indexing happens in a background thread, so after enqueueing files
+  // for indexing their symbols will be available sometime later.
+  void enqueueAll(llvm::StringRef Directory,
+  const tooling::CompilationDatabase &);
+
+  // Cause background threads to stop after ther current task, any remaining
+  // tasks will be discarded.
+  void stop();
+
+private:
+  // configuration
+  std::string ResourceDir;
+  FileSystemProvider *FSProvider;
+  Context BackgroundContext;
+
+  // index state
+  llvm::Error index(tooling::CompileCommand);
+  FileSymbols IndexedSymbols; // Index contents.
+  using Hash = decltype(llvm::SHA1::hash({}));
+  llvm::StringMap FileHash; // Digest of indexed file.
+
+  // queue management
+  using Task = std::function; // TODO: use multiple worker threads.
+  void run(); // Main loop executed by Thread. Runs tasks from Queue.
+  void enqueueLocked(tooling::C

r344070 - PR39231: fix null dereference when diagnosing deduction failure due to

2018-10-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Oct  9 11:49:22 2018
New Revision: 344070

URL: http://llvm.org/viewvc/llvm-project?rev=344070&view=rev
Log:
PR39231: fix null dereference when diagnosing deduction failure due to
conflicting values for a non-type pack.

Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=344070&r1=344069&r2=344070&view=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Oct  9 11:49:22 2018
@@ -9984,7 +9984,7 @@ static void DiagnoseBadDeduction(Sema &S
   DeductionFailure.getFirstArg()->getNonTypeTemplateArgumentType();
   QualType T2 =
   DeductionFailure.getSecondArg()->getNonTypeTemplateArgumentType();
-  if (!S.Context.hasSameType(T1, T2)) {
+  if (!T1.isNull() && !T2.isNull() && !S.Context.hasSameType(T1, T2)) {
 S.Diag(Templated->getLocation(),
diag::note_ovl_candidate_inconsistent_deduction_types)
   << ParamD->getDeclName() << *DeductionFailure.getFirstArg() << T1

Modified: cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp?rev=344070&r1=344069&r2=344070&view=diff
==
--- cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp (original)
+++ cfe/trunk/test/SemaTemplate/temp_arg_pack.cpp Tue Oct  9 11:49:22 2018
@@ -6,3 +6,19 @@ namespace deduce_pack_non_pack {
   template  void g(C>); // expected-note {{candidate template 
ignored: deduced type 'C>' of 1st parameter does not 
match adjusted type 'C>' of argument [with T = bool]}}
   void h(C> &x) { g(x); } // expected-error {{no matching 
function}}
 }
+
+namespace pr39231 {
+  template struct integer_sequence {};
+
+  template 
+  int operator^(integer_sequence a, // expected-note {{deduced 
conflicting values for parameter 'A' (<1, 2, 3> vs. <4, 5, 6>)}}
+integer_sequence b);
+
+  int v = integer_sequence{} ^ integer_sequence{}; 
// expected-error {{invalid operands}}
+
+  template 
+  integer_sequence operator+(integer_sequence a,
+  integer_sequence b);
+  integer_sequence w =
+  integer_sequence{} + integer_sequence{};
+}


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


[PATCH] D51484: [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extension

2018-10-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

It would be good to test your `CIndex` changes in `test/Index/opencl-types.cl`.




Comment at: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl:26
+ char4 c4, event_t e, struct st ss) {
+  intel_sub_group_avc_mce_payload_t payload_mce = 0; // No zero initializer 
for mce types
+  // expected-error@-1 {{initializing 'intel_sub_group_avc_mce_payload_t' with 
an expression of incompatible type 'int'}}

AlexeySachkov wrote:
> Anastasia wrote:
> > Would it make sense to add a check for non-zero constant?
> > 
> > Also can you assign variables of intel_sub_group_avc_mce_payload_t type 
> > from the same type? Any other restrictions on assignment (i.e. w integer 
> > literals) and operations over these types?
> > Also can you assign variables of intel_sub_group_avc_mce_payload_t type 
> > from the same type?
> 
> Yes, such assignment is allowed.
> 
> > Any other restrictions on assignment (i.e. w integer literals)
> 
> All of these types can only be initialized using call to a special built-ins 
> or using predefined macros like `CLK_AVC_REF_RESULT_INITIALIZE_INTEL`. Any 
> other assignment should lead to an error. 
> 
> I found that I'm able to assign variable of type 
> `intel_sub_group_avc_imc_payload_t` to variable of type 
> `intel_sub_group_avc_mce_payload_t`, so I will update the patch when I 
> implement such diagnostic message.
> 
> > and operations over these types?
> Variables of these types can only be used as return values or arguments for 
> built-in functions described in the specification. All other operations are 
> restricted
W/o the spec change it's really difficult to review properly. So are you 
testing 2 groups of types:
1. Init by zero in `bar`?
2. Init by builtin function in `foo`?




Comment at: test/SemaOpenCL/intel-subgroup-avc-ext-types.cl:34
+  // expected-error@-1 {{initializing 'intel_sub_group_avc_mce_payload_t' with 
an expression of incompatible type 'int'}}
+  intel_sub_group_avc_ime_payload_t payload_ime = b;
+  // expected-error@-1 {{initializing 'intel_sub_group_avc_ime_payload_t' with 
an expression of incompatible type 'bool'}}

I am not sure it makes sense to iterate through all different types. You don't 
enumerate all of them and we don't do exhaustive testing in Clang tests anyway. 
I would just check integer literal and one other builtin type.


https://reviews.llvm.org/D51484



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


[PATCH] D52673: [HIP] Remove disabled irif library

2018-10-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Driver/ToolChains/HIP.cpp:85
   C.addTempFile(C.getArgs().MakeArgString(TmpName));
   CmdArgs.push_back(OutputFileName);
   SmallString<128> ExecPath(C.getDriver().Dir);

maybe we should put hip.amdgcn.bc at the beginning. In the future, it may 
depend on other bc's.


Repository:
  rC Clang

https://reviews.llvm.org/D52673



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


[PATCH] D52673: [HIP] Remove disabled irif library

2018-10-09 Thread Aaron Enye Shi via Phabricator via cfe-commits
ashi1 updated this revision to Diff 168836.
ashi1 added a comment.

The device libraries has been updated, and the hip.amdgcn.bc library is now 
available there.


Repository:
  rC Clang

https://reviews.llvm.org/D52673

Files:
  lib/Driver/ToolChains/HIP.cpp
  test/Driver/hip-device-libs.hip


Index: test/Driver/hip-device-libs.hip
===
--- test/Driver/hip-device-libs.hip
+++ test/Driver/hip-device-libs.hip
@@ -21,8 +21,8 @@


 // COM: [[LLVM_LINK:"*.llvm-link"]]
-// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" 
"{{.*}}irif.amdgcn.bc"
+// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" 
"{{.*}}hip.amdgcn.bc"
 // FLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_on.amdgcn.bc"
 // NOFLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_off.amdgcn.bc"
 // COM-SAME: {{.*}} "-o" "{{.*}}-gfx900-linked-{{.*bc}}"

Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -82,15 +82,15 @@
   FlushDenormalControlBC = "oclc_daz_opt_off.amdgcn.bc";

 BCLibs.append({"opencl.amdgcn.bc",
-   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "irif.amdgcn.bc",
+   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "hip.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
FlushDenormalControlBC,
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
"oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);

   // Add an intermediate output file.
   CmdArgs.push_back("-o");
   std::string TmpName =


Index: test/Driver/hip-device-libs.hip
===
--- test/Driver/hip-device-libs.hip
+++ test/Driver/hip-device-libs.hip
@@ -21,8 +21,8 @@


 // COM: [[LLVM_LINK:"*.llvm-link"]]
-// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" "{{.*}}irif.amdgcn.bc"
+// COM-SAME: {{.*}} "{{.*}}ocml.amdgcn.bc" "{{.*}}ockl.amdgcn.bc" "{{.*}}hip.amdgcn.bc"
 // FLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_on.amdgcn.bc"
 // NOFLUSHD-SAME: {{.*}} "{{.*}}oclc_daz_opt_off.amdgcn.bc"
 // COM-SAME: {{.*}} "-o" "{{.*}}-gfx900-linked-{{.*bc}}"

Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -82,15 +82,15 @@
   FlushDenormalControlBC = "oclc_daz_opt_off.amdgcn.bc";

 BCLibs.append({"opencl.amdgcn.bc",
-   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "irif.amdgcn.bc",
+   "ocml.amdgcn.bc", "ockl.amdgcn.bc", "hip.amdgcn.bc",
"oclc_finite_only_off.amdgcn.bc",
FlushDenormalControlBC,
"oclc_correctly_rounded_sqrt_on.amdgcn.bc",
"oclc_unsafe_math_off.amdgcn.bc", ISAVerBC});
   }
   for (auto Lib : BCLibs)
 addBCLib(C, Args, CmdArgs, LibraryPaths, Lib);

   // Add an intermediate output file.
   CmdArgs.push_back("-o");
   std::string TmpName =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

GCC has -Wignored-qualifiers for long time, so may be better to implement it in 
Clang?




Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:66
+  llvm::Optional Loc = findConstToRemove(Def, Result);
+  if (!Loc) return;
+  DiagnosticBuilder Diagnostics = diag(*Loc,

Please split in two lines.



Comment at: clang-tidy/readability/ConstValueReturnCheck.cpp:74
+  // associate all fixes with the definition.
+  for (auto *Decl = Def->getPreviousDecl(); Decl != nullptr;
+   Decl = Decl->getPreviousDecl()) {

Please don't use auto, because type is not deducible from statement and it's 
not iterator over container.



Comment at: docs/ReleaseNotes.rst:60
 
+- New :doc:`readability-const-value-return
+  ` check.

Please use alphabetical order for list of new checks.



Comment at: docs/ReleaseNotes.rst:64
+  Checks for functions with a ``const``-qualified return type and recommends
+  removal of the `const` keyword.  Such use of ``const`` is superfluous, and
+  prevents valuable compiler optimizations.

Please enclose const in ``.

Once sentence is enough for Release Notes.



Comment at: docs/clang-tidy/checks/readability-const-value-return.rst:7
+Checks for functions with a ``const``-qualified return type and recommends
+removal of the `const` keyword.  Such use of ``const`` is superfluous, and
+prevents valuable compiler optimizations.

Please enclose const in ``.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025



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


[PATCH] D53025: [clang-tidy] implement new check for const return types.

2018-10-09 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: aaron.ballman, JonasToth, ioeric.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.

Adds a new check readability-const-value-return, which checks for functions with
a ``const``-qualified return type and recommends removal of the `const` keyword.
Such use of ``const`` is superfluous, and prevents valuable compiler
optimizations.

Based in part on the (abandoned) review https://reviews.llvm.org/D33531.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53025

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ConstValueReturnCheck.cpp
  clang-tidy/readability/ConstValueReturnCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/utils/LexerUtils.cpp
  clang-tidy/utils/LexerUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-const-value-return.rst
  test/clang-tidy/Inputs/readability-const-value-return/
  test/clang-tidy/Inputs/readability-const-value-return/macro-def.h
  test/clang-tidy/readability-const-value-return.cpp

Index: test/clang-tidy/readability-const-value-return.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-const-value-return.cpp
@@ -0,0 +1,139 @@
+// RUN: %check_clang_tidy %s readability-const-value-return %t -- -- \
+// RUN:   -I %S/Inputs/readability-const-value-return
+
+#include "macro-def.h"
+
+//  p# = positive test
+//  n# = negative test
+
+const int p1() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const`` for values, as it often disables optimizations and causes unnecessary copies
+// CHECK-FIXES: int p1() {
+  return 1;
+}
+
+const int p15();
+// CHECK-FIXES: int p15();
+
+template  class Klazz {};
+class Clazz {
+ public:
+  Clazz *const p2() {
+// CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``
+// CHECK-FIXES: Clazz *p2() {
+return this;
+  }
+
+  Clazz *const p3();
+  // CHECK-FIXES: Clazz *p3();
+
+  const int p4() const {
+// CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``c
+// CHECK-FIXES: int p4() const {
+return 4;
+  }
+
+  const Klazz* const p5() const;
+  // CHECK-FIXES: const Klazz* p5() const;
+
+  const Clazz operator++(int x) {  //  p12
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz operator++(int x) {
+  }
+
+  struct Strukt {
+int i;
+  };
+
+  const Strukt p6() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Strukt p6() {}
+
+  const Strukt* const p7();
+  // CHECK-FIXES: const Strukt* p7();
+
+  static const int p8() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static int p8() {}
+
+  static const Strukt p9() {}
+  // CHECK-MESSAGES: [[@LINE-1]]:10: warning: avoid marking return types as ``co
+  // CHECK-FIXES: static Strukt p9() {}
+
+  int n0() const { return 0; }
+  const Klazz& n11(const Klazz) const;
+};
+
+Clazz *const Clazz::p3() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *Clazz::p3() {
+  return this;
+}
+
+const Klazz* const Clazz::p5() const {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* Clazz::p5() const {}
+
+const Clazz::Strukt* const Clazz::p7() {}
+// CHECK-MESSAGES: [[@LINE-1]]:22: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Clazz::Strukt* Clazz::p7() {}
+
+Clazz *const p10();
+// CHECK-FIXES: Clazz *p10();
+
+Clazz *const p10() {
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: avoid marking return types as ``con
+  // CHECK-FIXES: Clazz *p10() {
+  return new Clazz();
+}
+
+const Clazz bar;
+const Clazz *const p11() {
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: avoid marking return types as ``co
+  // CHECK-FIXES: const Clazz *p11() {
+  return &bar;
+}
+
+const Klazz p12() {}
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: Klazz p12() {}
+
+const Klazz* const p13() {}
+// CHECK-MESSAGES: [[@LINE-1]]:25: warning: avoid marking return types as ``cons
+// CHECK-FIXES: const Klazz* p13() {}
+
+const auto p14() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``cons
+// CHECK-FIXES: auto p14() {
+  const int i = 0;
+  return i;
+}
+
+//another decl at top.
+const int p15();
+// CHECK-FIXES: int p15();
+const int p15() {
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: avoid marking return types as ``const
+// CHECK-FIXES: int p15() {
+  return 0;
+}
+
+const int n1 = 1;
+const Clazz n2 = Clazz();
+const Clazz* n3 = new Clazz();
+Clazz *const n4 = new Clazz();
+const Clazz *const n5 = new Clazz();
+constexpr int n6 = 6;
+constexpr int n7() { return 8; }
+const int eight = 8;
+constexpr const int* n8() { re

[PATCH] D52969: [analyzer][www] Update alpha_checks.html

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: www/analyzer/alpha_checks.html:352-405
+
+alpha.cplusplus.InvalidatedIterator
+(C++)
+Check for use of invalidated iterators.
+
+
 

@baloghadamsoftware Is this a good description of your checker(s)?


https://reviews.llvm.org/D52969



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


[PATCH] D53024: [analyzer][www] Add more open projects

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

Mind you, there are some ideas I didn't add to the list -- I just don't know 
how to put them to words nicely, but I'm on it.

Also, a lot of these is outdated, but I joined the project relatively recently, 
so I'm not sure what's the state on all of them.


Repository:
  rC Clang

https://reviews.llvm.org/D53024



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


[PATCH] D51402: [OpenCL] Adding cl_intel_planar_yuv extension

2018-10-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D51402#1252619, @sidorovd wrote:

> @Anastasia , since there is a problem I described, wouldn't you mind if I 
> stay with the first iteration of the patch (adding the extension to 
> OpenCLExtensions.def) and after we'll investigate what is wrong with -cl-ext 
> approach?


I would prefer not to add it to Clang directly unless absolutely necessary. I 
think it's ok to add this in the header for now as is, but then investigate how 
we can add an architecture guard later. Please, could you just move the testing 
into `test/Headers/opencl-c-header.cl`, because 
`test/SemaOpenCL/extension-version.cl` is for Clang built in extensions.


https://reviews.llvm.org/D51402



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


[PATCH] D52292: [Sema][OpenCL] Improve diagnostics for not viable overloadable function candidates

2018-10-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


https://reviews.llvm.org/D52292



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


[PATCH] D52905: [analyzer] fix accessing GDM data from shared libraries

2018-10-09 Thread Joe Ranieri via Phabricator via cfe-commits
jranieri-grammatech updated this revision to Diff 168815.
jranieri-grammatech added a comment.

Added more context.


Repository:
  rC Clang

https://reviews.llvm.org/D52905

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
  lib/StaticAnalyzer/Core/CMakeLists.txt
  lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  lib/StaticAnalyzer/Core/TaintManager.cpp

Index: lib/StaticAnalyzer/Core/TaintManager.cpp
===
--- lib/StaticAnalyzer/Core/TaintManager.cpp
+++ lib/StaticAnalyzer/Core/TaintManager.cpp
@@ -0,0 +1,23 @@
+//== TaintManager.cpp -- -*- C++ -*--=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h"
+
+using namespace clang;
+using namespace ento;
+
+void *ProgramStateTrait::GDMIndex() {
+  static int index = 0;
+  return &index;
+}
+
+void *ProgramStateTrait::GDMIndex() {
+  static int index;
+  return &index;
+}
Index: lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
@@ -200,6 +200,11 @@
   }
 }
 
+void *ProgramStateTrait::GDMIndex() {
+  static int Index;
+  return &Index;
+}
+
 } // end of namespace ento
 
 } // end of namespace clang
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3106,3 +3106,8 @@
   llvm::errs() << "Warning: dumping graph requires assertions" << "\n";
   return "";
 }
+
+void *ProgramStateTrait::GDMIndex() {
+  static int index = 0;
+  return &index;
+}
Index: lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
===
--- lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
+++ lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
@@ -77,5 +77,10 @@
   }
 }
 
+void *ProgramStateTrait::GDMIndex() {
+  static int index = 0;
+  return &index;
+}
+
 } // namespace ento
 } // namespace clang
Index: lib/StaticAnalyzer/Core/CMakeLists.txt
===
--- lib/StaticAnalyzer/Core/CMakeLists.txt
+++ lib/StaticAnalyzer/Core/CMakeLists.txt
@@ -52,6 +52,7 @@
   Store.cpp
   SubEngine.cpp
   SymbolManager.cpp
+  TaintManager.cpp
   WorkList.cpp
   Z3ConstraintManager.cpp
 
Index: include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/TaintManager.h
@@ -34,10 +34,7 @@
 
 template<> struct ProgramStateTrait
 :  public ProgramStatePartialTrait {
-  static void *GDMIndex() {
-static int index = 0;
-return &index;
-  }
+  static void *GDMIndex();
 };
 
 /// The GDM component mapping derived symbols' parent symbols to their
@@ -49,10 +46,7 @@
 
 template<> struct ProgramStateTrait
 :  public ProgramStatePartialTrait {
-  static void *GDMIndex() {
-static int index;
-return &index;
-  }
+  static void *GDMIndex();
 };
 
 class TaintManager {
Index: include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
@@ -131,7 +131,7 @@
 template <>
 struct ProgramStateTrait
   : public ProgramStatePartialTrait {
-  static void *GDMIndex() { static int Index; return &Index; }
+  static void *GDMIndex();
 };
 
 
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -832,7 +832,7 @@
 template <>
 struct ProgramStateTrait :
   public ProgramStatePartialTrait {
-  static void *GDMIndex() { static int index = 0; return &index; }
+  static void *GDMIndex();
 };
 
 } // namespace ento
Index: include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
===
--- include/clang/Stati

[PATCH] D51372: FENV_ACCESS support for libm-style constrained intrinsics

2018-10-09 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 168814.
kpn added a comment.

Update based on feedback to https://reviews.llvm.org/D52839: add missing AST 
(de)serialization support.

Ping.


https://reviews.llvm.org/D51372

Files:
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/Analysis/BodyFarm.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Frontend/Rewrite/RewriteModernObjC.cpp
  lib/Frontend/Rewrite/RewriteObjC.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CodeGen/fenv-access-pragma.c
  test/CodeGen/fenv-access-pragma.cpp
  test/CodeGen/fenv-math-builtins.c

Index: test/CodeGen/fenv-math-builtins.c
===
--- test/CodeGen/fenv-math-builtins.c
+++ test/CodeGen/fenv-math-builtins.c
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -S -o - -emit-llvm  %s | FileCheck %s 
+
+// Test codegen of math builtins when using FENV_ACCESS ON.
+// Derived from math-builtins.c and keeps calls in the same order.
+#pragma STDC FENV_ACCESS ON
+
+void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
+  __builtin_pow(f,f);__builtin_powf(f,f);   __builtin_powl(f,f);
+
+// CHECK: declare double @llvm.experimental.constrained.pow.f64(double, double, metadata, metadata) [[MATH_INTRINSIC:#[0-9]+]]
+// CHECK: declare float @llvm.experimental.constrained.pow.f32(float, float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.pow.f80(x86_fp80, x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_powi(f,f);__builtin_powif(f,f);   __builtin_powil(f,f);
+
+// CHECK: declare double @llvm.experimental.constrained.powi.f64(double, i32, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.powi.f32(float, i32, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.powi.f80(x86_fp80, i32, metadata, metadata) [[MATH_INTRINSIC]]
+
+  /* math */
+  __builtin_cos(f);__builtin_cosf(f);   __builtin_cosl(f); 
+// CHECK: declare double @llvm.experimental.constrained.cos.f64(double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.cos.f32(float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.cos.f80(x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_exp(f);__builtin_expf(f);   __builtin_expl(f);
+// CHECK: declare double @llvm.experimental.constrained.exp.f64(double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.exp.f32(float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.exp.f80(x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_exp2(f);   __builtin_exp2f(f);  __builtin_exp2l(f); 
+
+// CHECK: declare double @llvm.experimental.constrained.exp2.f64(double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.exp2.f32(float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.exp2.f80(x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_fma(f,f,f);__builtin_fmaf(f,f,f);   __builtin_fmal(f,f,f);
+
+// CHECK: declare double @llvm.experimental.constrained.fma.f64(double, double, double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.fma.f32(float, float, float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.fma.f80(x86_fp80, x86_fp80, x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_log(f);__builtin_logf(f);   __builtin_logl(f);
+
+// CHECK: declare double @llvm.experimental.constrained.log.f64(double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.log.f32(float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.log.f80(x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_log10(f);  __builtin_log10f(f); __builtin_log10l(f);
+
+// CHECK: declare double @llvm.experimental.constrained.log10.f64(double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.experimental.constrained.log10.f32(float, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare x86_fp80 @llvm.experimental.constrained.log10.f80(x86_fp80, metadata, metadata) [[MATH_INTRINSIC]]
+
+  __builtin_nearbyint(f);  __builtin_nearbyintf(f); __builtin_nearbyintl(f);
+
+// CHECK: declare double @llvm.experimental.constrained.nearbyint.f64(double, metadata, metadata) [[MATH_INTRINSIC]]
+// CHECK: declare float @llvm.exp

[PATCH] D52998: [benchmark] Disable exceptions in Microsoft STL

2018-10-09 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added a comment.

Yes. I understand. At the moment, exception handling flags are generated based 
on `BENCHMARK_ENABLE_EXCEPTIONS`  in `utils/benchmark/CMakeLists.txt` .  
However, `_HAS_EXCEPTIONS` is not defined based on this (code below). The 
warnings are a result of this mismatch.

  if (NOT BENCHMARK_ENABLE_EXCEPTIONS)
  add_cxx_compiler_flag(-EHs-)
  add_cxx_compiler_flag(-EHa-)
endif()

I think it makes most sense to add definition for `_HAS_EXCEPTIONS=0 `here as 
opposed to modifying `llvm/CMakeLists.txt`.  Please correct me if I'm wrong. 
I'm not too familiar with CMake. @kbobyrev Please let me know what you think as 
well since you had suggested `llvm/CMakeLists.txt`.


https://reviews.llvm.org/D52998



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


[PATCH] D52989: [clang-tidy] Fix handling of parens around new expressions in make_ checks.

2018-10-09 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344058: [clang-tidy] Fix handling of parens around new 
expressions in make_… (authored by alexfh, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52989

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -44,25 +44,23 @@
   virtual bool isLanguageVersionSupported(const LangOptions &LangOpts) const;
 
   static const char PointerType[];
-  static const char ConstructorCall[];
-  static const char ResetCall[];
-  static const char NewExpression[];
 
 private:
   std::unique_ptr Inserter;
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
   const std::string MakeSmartPtrFunctionHeader;
   const std::string MakeSmartPtrFunctionName;
   const bool IgnoreMacros;
 
-  void checkConstruct(SourceManager &SM, const CXXConstructExpr *Construct,
-  const QualType *Type, const CXXNewExpr *New);
-  void checkReset(SourceManager &SM, const CXXMemberCallExpr *Member,
-  const CXXNewExpr *New);
+  void checkConstruct(SourceManager &SM, ASTContext *Ctx,
+  const CXXConstructExpr *Construct, const QualType *Type,
+  const CXXNewExpr *New);
+  void checkReset(SourceManager &SM, ASTContext *Ctx,
+  const CXXMemberCallExpr *Member, const CXXNewExpr *New);
 
   /// Returns true when the fixes for replacing CXXNewExpr are generated.
   bool replaceNew(DiagnosticBuilder &Diag, const CXXNewExpr *New,
-  SourceManager &SM);
+  SourceManager &SM, ASTContext *Ctx);
   void insertHeader(DiagnosticBuilder &Diag, FileID FD);
 };
 
Index: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -21,6 +21,9 @@
 namespace {
 
 constexpr char StdMemoryHeader[] = "memory";
+constexpr char ConstructorCall[] = "constructorCall";
+constexpr char ResetCall[] = "resetCall";
+constexpr char NewExpression[] = "newExpression";
 
 std::string GetNewExprName(const CXXNewExpr *NewExpr,
const SourceManager &SM,
@@ -30,17 +33,14 @@
   NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),
   SM, Lang);
   if (NewExpr->isArray()) {
-return WrittenName.str() + "[]";
+return (WrittenName + "[]").str();
   }
   return WrittenName.str();
 }
 
 } // namespace
 
 const char MakeSmartPtrCheck::PointerType[] = "pointerType";
-const char MakeSmartPtrCheck::ConstructorCall[] = "constructorCall";
-const char MakeSmartPtrCheck::ResetCall[] = "resetCall";
-const char MakeSmartPtrCheck::NewExpression[] = "newExpression";
 
 MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name,
  ClangTidyContext* Context,
@@ -68,8 +68,8 @@
 
 void MakeSmartPtrCheck::registerPPCallbacks(CompilerInstance &Compiler) {
   if (isLanguageVersionSupported(getLangOpts())) {
-Inserter.reset(new utils::IncludeInserter(
-Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));
+Inserter = llvm::make_unique(
+Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle);
 Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
   }
 }
@@ -122,12 +122,12 @@
 return;
 
   if (Construct)
-checkConstruct(SM, Construct, Type, New);
+checkConstruct(SM, Result.Context, Construct, Type, New);
   else if (Reset)
-checkReset(SM, Reset, New);
+checkReset(SM, Result.Context, Reset, New);
 }
 
-void MakeSmartPtrCheck::checkConstruct(SourceManager &SM,
+void MakeSmartPtrCheck::checkConstruct(SourceManager &SM, ASTContext *Ctx,
const CXXConstructExpr *Construct,
const QualType *Type,
const CXXNewExpr *New) {
@@ -154,7 +154,7 @@
 return;
   }
 
-  if (!replaceNew(Diag, New, SM)) {
+  if (!replaceNew(Diag, New, SM, Ctx)) {
 return;
   }
 
@@ -193,7 +193,7 @@
   insertHeader(Diag, SM.getFileID(ConstructCallStart));
 }
 
-void MakeSmartPtrCheck::checkReset(SourceManager &SM,
+void MakeSmartPtrCheck::checkReset(SourceManager &SM, ASTContext *Ctx,
const CXXMemberCallExpr 

[clang-tools-extra] r344058 - [clang-tidy] Fix handling of parens around new expressions in make_ checks.

2018-10-09 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Tue Oct  9 08:58:18 2018
New Revision: 344058

URL: http://llvm.org/viewvc/llvm-project?rev=344058&view=rev
Log:
[clang-tidy] Fix handling of parens around new expressions in make_ 
checks.

Summary:
Extra parentheses around a new expression result in incorrect code
after applying fixes.

Reviewers: hokein

Reviewed By: hokein

Subscribers: xazax.hun, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.h
clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp?rev=344058&r1=344057&r2=344058&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeSmartPtrCheck.cpp Tue Oct  
9 08:58:18 2018
@@ -21,6 +21,9 @@ namespace modernize {
 namespace {
 
 constexpr char StdMemoryHeader[] = "memory";
+constexpr char ConstructorCall[] = "constructorCall";
+constexpr char ResetCall[] = "resetCall";
+constexpr char NewExpression[] = "newExpression";
 
 std::string GetNewExprName(const CXXNewExpr *NewExpr,
const SourceManager &SM,
@@ -30,7 +33,7 @@ std::string GetNewExprName(const CXXNewE
   
NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),
   SM, Lang);
   if (NewExpr->isArray()) {
-return WrittenName.str() + "[]";
+return (WrittenName + "[]").str();
   }
   return WrittenName.str();
 }
@@ -38,9 +41,6 @@ std::string GetNewExprName(const CXXNewE
 } // namespace
 
 const char MakeSmartPtrCheck::PointerType[] = "pointerType";
-const char MakeSmartPtrCheck::ConstructorCall[] = "constructorCall";
-const char MakeSmartPtrCheck::ResetCall[] = "resetCall";
-const char MakeSmartPtrCheck::NewExpression[] = "newExpression";
 
 MakeSmartPtrCheck::MakeSmartPtrCheck(StringRef Name,
  ClangTidyContext* Context,
@@ -68,8 +68,8 @@ bool MakeSmartPtrCheck::isLanguageVersio
 
 void MakeSmartPtrCheck::registerPPCallbacks(CompilerInstance &Compiler) {
   if (isLanguageVersionSupported(getLangOpts())) {
-Inserter.reset(new utils::IncludeInserter(
-Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle));
+Inserter = llvm::make_unique(
+Compiler.getSourceManager(), Compiler.getLangOpts(), IncludeStyle);
 Compiler.getPreprocessor().addPPCallbacks(Inserter->CreatePPCallbacks());
   }
 }
@@ -122,12 +122,12 @@ void MakeSmartPtrCheck::check(const Matc
 return;
 
   if (Construct)
-checkConstruct(SM, Construct, Type, New);
+checkConstruct(SM, Result.Context, Construct, Type, New);
   else if (Reset)
-checkReset(SM, Reset, New);
+checkReset(SM, Result.Context, Reset, New);
 }
 
-void MakeSmartPtrCheck::checkConstruct(SourceManager &SM,
+void MakeSmartPtrCheck::checkConstruct(SourceManager &SM, ASTContext *Ctx,
const CXXConstructExpr *Construct,
const QualType *Type,
const CXXNewExpr *New) {
@@ -154,7 +154,7 @@ void MakeSmartPtrCheck::checkConstruct(S
 return;
   }
 
-  if (!replaceNew(Diag, New, SM)) {
+  if (!replaceNew(Diag, New, SM, Ctx)) {
 return;
   }
 
@@ -193,7 +193,7 @@ void MakeSmartPtrCheck::checkConstruct(S
   insertHeader(Diag, SM.getFileID(ConstructCallStart));
 }
 
-void MakeSmartPtrCheck::checkReset(SourceManager &SM,
+void MakeSmartPtrCheck::checkReset(SourceManager &SM, ASTContext *Ctx,
const CXXMemberCallExpr *Reset,
const CXXNewExpr *New) {
   const auto *Expr = cast(Reset->getCallee());
@@ -224,7 +224,7 @@ void MakeSmartPtrCheck::checkReset(Sourc
 return;
   }
 
-  if (!replaceNew(Diag, New, SM)) {
+  if (!replaceNew(Diag, New, SM, Ctx)) {
 return;
   }
 
@@ -241,10 +241,24 @@ void MakeSmartPtrCheck::checkReset(Sourc
 }
 
 bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
-   const CXXNewExpr *New,
-   SourceManager& SM) {
-  SourceLocation NewStart = New->getSourceRange().getBegin();
-  SourceLocation NewEnd = New->getSourceRange().getEnd();
+   const CXXNewExpr *New, SourceManager &SM,
+   ASTContext *Ctx) {
+  auto SkipParensParents = [&](const Expr *E) {
+for (const Expr *OldE = nullptr; E != OldE;) {
+  OldE = E;
+  for (const auto &Node : Ctx->getParents(*E)) {
+if (const Expr *Parent = Node.

[PATCH] D52989: [clang-tidy] Fix handling of parens around new expressions in make_ checks.

2018-10-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh updated this revision to Diff 168812.
alexfh marked 2 inline comments as done.
alexfh added a comment.

- Remove recursion, use `auto`.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52989

Files:
  clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tidy/modernize/MakeSmartPtrCheck.h
  test/clang-tidy/modernize-make-shared.cpp
  test/clang-tidy/modernize-make-unique.cpp

Index: test/clang-tidy/modernize-make-unique.cpp
===
--- test/clang-tidy/modernize-make-unique.cpp
+++ test/clang-tidy/modernize-make-unique.cpp
@@ -110,6 +110,19 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
   // CHECK-FIXES: auto P3 = std::make_unique();
 
+  std::unique_ptr P4 = std::unique_ptr((new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: std::unique_ptr P4 = std::make_unique();
+  P4.reset((new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: P4 = std::make_unique();
+  std::unique_ptr P5 = std::unique_ptrnew int;
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: std::unique_ptr P5 = std::make_unique();
+  P5.reset(new int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead [modernize-make-unique]
+  // CHECK-FIXES: P5 = std::make_unique();
+
   {
 // No std.
 using namespace std;
Index: test/clang-tidy/modernize-make-shared.cpp
===
--- test/clang-tidy/modernize-make-shared.cpp
+++ test/clang-tidy/modernize-make-shared.cpp
@@ -70,6 +70,18 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_shared instead
   // CHECK-FIXES: auto P3 = std::make_shared();
 
+  std::shared_ptr P4 = std::shared_ptr((new int));
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_shared instead [modernize-make-shared]
+  // CHECK-FIXES: std::shared_ptr P4 = std::make_shared();
+
+  P4.resetnew int();
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_shared instead [modernize-make-shared]
+  // CHECK-FIXES: P4 = std::make_shared();
+
+  P4 = std::shared_ptr(((new int)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use std::make_shared instead [modernize-make-shared]
+  // CHECK-FIXES: P4 = std::make_shared();
+
   {
 // No std.
 using namespace std;
Index: clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -44,25 +44,23 @@
   virtual bool isLanguageVersionSupported(const LangOptions &LangOpts) const;
 
   static const char PointerType[];
-  static const char ConstructorCall[];
-  static const char ResetCall[];
-  static const char NewExpression[];
 
 private:
   std::unique_ptr Inserter;
   const utils::IncludeSorter::IncludeStyle IncludeStyle;
   const std::string MakeSmartPtrFunctionHeader;
   const std::string MakeSmartPtrFunctionName;
   const bool IgnoreMacros;
 
-  void checkConstruct(SourceManager &SM, const CXXConstructExpr *Construct,
-  const QualType *Type, const CXXNewExpr *New);
-  void checkReset(SourceManager &SM, const CXXMemberCallExpr *Member,
-  const CXXNewExpr *New);
+  void checkConstruct(SourceManager &SM, ASTContext *Ctx,
+  const CXXConstructExpr *Construct, const QualType *Type,
+  const CXXNewExpr *New);
+  void checkReset(SourceManager &SM, ASTContext *Ctx,
+  const CXXMemberCallExpr *Member, const CXXNewExpr *New);
 
   /// Returns true when the fixes for replacing CXXNewExpr are generated.
   bool replaceNew(DiagnosticBuilder &Diag, const CXXNewExpr *New,
-  SourceManager &SM);
+  SourceManager &SM, ASTContext *Ctx);
   void insertHeader(DiagnosticBuilder &Diag, FileID FD);
 };
 
Index: clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -21,6 +21,9 @@
 namespace {
 
 constexpr char StdMemoryHeader[] = "memory";
+constexpr char ConstructorCall[] = "constructorCall";
+constexpr char ResetCall[] = "resetCall";
+constexpr char NewExpression[] = "newExpression";
 
 std::string GetNewExprName(const CXXNewExpr *NewExpr,
const SourceManager &SM,
@@ -30,17 +33,14 @@
   NewExpr->getAllocatedTypeSourceInfo()->getTypeLoc().getSourceRange()),
   SM, Lang);
   if (NewExpr->isArray()) {
-return WrittenName.str() + "[]";
+return (WrittenName + "[]").str();
   }
   return WrittenName.str();
 }
 
 } // namespace
 
 const char MakeSmartPtrCheck::PointerType[] = "

[PATCH] D52989: [clang-tidy] Fix handling of parens around new expressions in make_ checks.

2018-10-09 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:246
+   ASTContext *Ctx) {
+  std::function SkipParensParents =
+  [&](const Expr *E) {

hokein wrote:
> nit: I'd use `auto` to avoid this long type name, the type is clear to me, it 
> is a lambda function.
I first tried it with an `auto`, but the recursive call below didn't compile. 
Works fine without recursion though.



Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:250
+  if (const Expr *Parent = Node.get())
+return SkipParensParents(Parent);
+}

hokein wrote:
> nit: we can easily avoid the recursive call by using while here, I think.
Turned out that iterative approach here doesn't complicate code as much as I 
thought it would.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52989



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


r344057 - [CUDA][HIP] Fix ShouldDeleteSpecialMember for inherited constructors

2018-10-09 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Oct  9 08:53:14 2018
New Revision: 344057

URL: http://llvm.org/viewvc/llvm-project?rev=344057&view=rev
Log:
[CUDA][HIP] Fix ShouldDeleteSpecialMember for inherited constructors

ShouldDeleteSpecialMember is called upon inherited constructors.
It calls inferCUDATargetForImplicitSpecialMember.

Normally the special member enum passed to ShouldDeleteSpecialMember
matches the constructor. However this is not true when inherited
constructor is passed, where DefaultConstructor is passed to treat
the inherited constructor as DefaultConstructor. However
inferCUDATargetForImplicitSpecialMember expects the special
member enum argument to match the constructor, which results
in assertion when this expection is not satisfied.

This patch checks whether the constructor is inherited. If true it will
get the real special member enum for the constructor and pass it
to inferCUDATargetForImplicitSpecialMember.

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

Added:
cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu
cfe/trunk/test/SemaCUDA/inherited-ctor.cu
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=344057&r1=344056&r2=344057&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Oct  9 08:53:14 2018
@@ -7222,8 +7222,17 @@ bool Sema::ShouldDeleteSpecialMember(CXX
   if (getLangOpts().CUDA) {
 // We should delete the special member in CUDA mode if target inference
 // failed.
-return inferCUDATargetForImplicitSpecialMember(RD, CSM, MD, SMI.ConstArg,
-   Diagnose);
+// For inherited constructors (non-null ICI), CSM may be passed so that MD
+// is treated as certain special member, which may not reflect what special
+// member MD really is. However inferCUDATargetForImplicitSpecialMember
+// expects CSM to match MD, therefore recalculate CSM.
+assert(ICI || CSM == getSpecialMember(MD));
+auto RealCSM = CSM;
+if (ICI)
+  RealCSM = getSpecialMember(MD);
+
+return inferCUDATargetForImplicitSpecialMember(RD, RealCSM, MD,
+   SMI.ConstArg, Diagnose);
   }
 
   return false;

Added: cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu?rev=344057&view=auto
==
--- cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu (added)
+++ cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu Tue Oct  9 
08:53:14 2018
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s 
-Wno-defaulted-function-deleted
+
+#include "Inputs/cuda.h"
+
+//--
+// Test 1: infer inherited default ctor to be host.
+
+struct A1_with_host_ctor {
+  A1_with_host_ctor() {}
+};
+// expected-note@-3 {{candidate constructor (the implicit copy constructor) 
not viable}}
+// expected-note@-4 {{candidate constructor (the implicit move constructor) 
not viable}}
+
+// The inherited default constructor is inferred to be host, so we'll encounter
+// an error when calling it from a __device__ function, but not from a __host__
+// function.
+struct B1_with_implicit_default_ctor : A1_with_host_ctor {
+  using A1_with_host_ctor::A1_with_host_ctor;
+};
+
+// expected-note@-4 {{call to __host__ function from __device__}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) 
not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) 
not viable}}
+// expected-note@-6 2{{constructor from base class 'A1_with_host_ctor' 
inherited here}}
+
+void hostfoo() {
+  B1_with_implicit_default_ctor b;
+}
+
+__device__ void devicefoo() {
+  B1_with_implicit_default_ctor b; // expected-error {{no matching 
constructor}}
+}
+
+//--
+// Test 2: infer inherited default ctor to be device.
+
+struct A2_with_device_ctor {
+  __device__ A2_with_device_ctor() {}
+};
+// expected-note@-3 {{candidate constructor (the implicit copy constructor) 
not viable}}
+// expected-note@-4 {{candidate constructor (the implicit move constructor) 
not viable}}
+
+struct B2_with_implicit_default_ctor : A2_with_device_ctor {
+  using A2_with_device_ctor::A2_with_device_ctor;
+};
+
+// expected-note@-4 {{call to __device__ function from __host__}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) 
not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) 
not viable}}
+// expected-note@-6 2{{constructor from b

[PATCH] D51809: [CUDA][HIP] Fix ShouldDeleteSpecialMember for inherited constructors

2018-10-09 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344057: [CUDA][HIP] Fix ShouldDeleteSpecialMember for 
inherited constructors (authored by yaxunl, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51809?vs=168500&id=168811#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D51809

Files:
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu
  cfe/trunk/test/SemaCUDA/inherited-ctor.cu

Index: cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu
===
--- cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu
+++ cfe/trunk/test/SemaCUDA/implicit-member-target-inherited.cu
@@ -0,0 +1,205 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s -Wno-defaulted-function-deleted
+
+#include "Inputs/cuda.h"
+
+//--
+// Test 1: infer inherited default ctor to be host.
+
+struct A1_with_host_ctor {
+  A1_with_host_ctor() {}
+};
+// expected-note@-3 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-4 {{candidate constructor (the implicit move constructor) not viable}}
+
+// The inherited default constructor is inferred to be host, so we'll encounter
+// an error when calling it from a __device__ function, but not from a __host__
+// function.
+struct B1_with_implicit_default_ctor : A1_with_host_ctor {
+  using A1_with_host_ctor::A1_with_host_ctor;
+};
+
+// expected-note@-4 {{call to __host__ function from __device__}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) not viable}}
+// expected-note@-6 2{{constructor from base class 'A1_with_host_ctor' inherited here}}
+
+void hostfoo() {
+  B1_with_implicit_default_ctor b;
+}
+
+__device__ void devicefoo() {
+  B1_with_implicit_default_ctor b; // expected-error {{no matching constructor}}
+}
+
+//--
+// Test 2: infer inherited default ctor to be device.
+
+struct A2_with_device_ctor {
+  __device__ A2_with_device_ctor() {}
+};
+// expected-note@-3 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-4 {{candidate constructor (the implicit move constructor) not viable}}
+
+struct B2_with_implicit_default_ctor : A2_with_device_ctor {
+  using A2_with_device_ctor::A2_with_device_ctor;
+};
+
+// expected-note@-4 {{call to __device__ function from __host__}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) not viable}}
+// expected-note@-6 2{{constructor from base class 'A2_with_device_ctor' inherited here}}
+
+void hostfoo2() {
+  B2_with_implicit_default_ctor b;  // expected-error {{no matching constructor}}
+}
+
+__device__ void devicefoo2() {
+  B2_with_implicit_default_ctor b;
+}
+
+//--
+// Test 3: infer inherited copy ctor
+
+struct A3_with_device_ctors {
+  __host__ A3_with_device_ctors() {}
+  __device__ A3_with_device_ctors(const A3_with_device_ctors&) {}
+};
+
+struct B3_with_implicit_ctors : A3_with_device_ctors {
+  using A3_with_device_ctors::A3_with_device_ctors;
+};
+// expected-note@-3 2{{call to __device__ function from __host__ function}}
+// expected-note@-4 {{default constructor}}
+
+
+void hostfoo3() {
+  B3_with_implicit_ctors b;  // this is OK because the inferred inherited default ctor
+ // here is __host__
+  B3_with_implicit_ctors b2 = b; // expected-error {{no matching constructor}}
+
+}
+
+//--
+// Test 4: infer inherited default ctor from a field, not a base
+
+struct A4_with_host_ctor {
+  A4_with_host_ctor() {}
+};
+
+struct B4_with_inherited_host_ctor : A4_with_host_ctor{
+  using A4_with_host_ctor::A4_with_host_ctor;
+};
+
+struct C4_with_implicit_default_ctor {
+  B4_with_inherited_host_ctor field;
+};
+
+// expected-note@-4 {{call to __host__ function from __device__}}
+// expected-note@-5 {{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-6 {{candidate constructor (the implicit move constructor) not viable}}
+
+void hostfoo4() {
+  C4_with_implicit_default_ctor b;
+}
+
+__device__ void devicefoo4() {
+  C4_with_implicit_default_ctor b; // expected-error {{no matching constructor}}
+}
+
+//--
+// Test 5: inherited copy ctor with non-const param
+
+struct A5_copy_ctor_constness {
+  __host__ A5_copy_ctor_constness() {}
+  __host__ A5_copy_ctor_constness(A5_copy_ctor_constnes

[PATCH] D52905: [analyzer] fix accessing GDM data from shared libraries

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

Please reupload with full context (`-U9`).


Repository:
  rC Clang

https://reviews.llvm.org/D52905



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


[PATCH] D52906: [analyzer] allow plugins built as shared libraries to receive events

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: lib/StaticAnalyzer/Core/Checker.cpp:20
 
+int ImplicitNullDerefEvent::Tag;
+

Szelethus wrote:
> nit: Static fields initialize to 0 without out of line definition.
Never mind, you still have to define it. It's been a while since I used 
`static` :).


Repository:
  rC Clang

https://reviews.llvm.org/D52906



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


[PATCH] D52906: [analyzer] allow plugins built as shared libraries to receive events

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

Please reupload with full context (`-U`).




Comment at: lib/StaticAnalyzer/Core/Checker.cpp:20
 
+int ImplicitNullDerefEvent::Tag;
+

nit: Static fields initialize to 0 without out of line definition.


Repository:
  rC Clang

https://reviews.llvm.org/D52906



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


[PATCH] D53024: [analyzer][www] Add more open projects

2018-10-09 Thread Umann Kristóf via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, george.karpenkov, xazax.hun, MTC.
Herald added subscribers: cfe-commits, jfb, mikhail.ramalho, a.sidorin, 
rnkovacs, szepet, whisperity.

Added some extra tasks to the open projects. These are the ideas of @NoQ and 
@george.karpenkov, I just converted them to HTML.


Repository:
  rC Clang

https://reviews.llvm.org/D53024

Files:
  www/analyzer/open_projects.html

Index: www/analyzer/open_projects.html
===
--- www/analyzer/open_projects.html
+++ www/analyzer/open_projects.html
@@ -25,6 +25,86 @@
   
   Core Analyzer Infrastructure
   
+Implement a dataflow flamework.
+
+ (Difficulty: Hard) 
+
+
+Handle aggregate construction.
+Aggregates are object that can be brace-initialized without calling a
+constructor (i.e., no https://clang.llvm.org/doxygen/classclang_1_1CXXConstructExpr.html";>
+CXXConstructExpr in the AST), but potentially calling
+constructors for their fields and (since C++17) base classes - and these
+constructors of sub-objects need to know what object (field in the
+aggregate) they are constructing. Moreover, if the aggregate contains
+references, lifetime extension needs to be modeled. Aggregates can be
+nested, so https://clang.llvm.org/doxygen/classclang_1_1ConstructionContext.html";>
+ConstructionContext can potentially cover an unlimited amount of
+statements. One can start untangling this problem by trying to replace the
+hacky https://clang.llvm.org/doxygen/classclang_1_1ParentMap.html";>
+ParentMap lookup in https://clang.llvm.org/doxygen/ExprEngineCXX_8cpp_source.html#l00430";>
+CXXConstructExpr::CK_NonVirtualBase branch of
+ExprEngine::VisitCXXConstructExpr() with some actual
+support for the feature.
+ (Difficulty: Medium) 
+
+
+Fix CFG for GNU "binary conditional" operator ?:.
+CFG for GNU "binary conditional" operator ?: is broken in
+C++. Its condition-and-LHS need to only be evaluated once.
+(Difficulty: Easy)
+
+
+Handle unions.
+Currently in the analyzer, the value of a union is always regarded as
+unknown. There has been some discussion about this on the http://lists.llvm.org/pipermail/cfe-dev/2017-March/052864.html";>
+mailing list already, but it is still an untouched area.
+ (Difficulty: Medium) 
+
+
+Enhance the modeling of the standard library.
+There is a huge amount of checker work for teaching the Static Analyzer
+about the C++ standard library. It is very easy to explain to the static
+analyzer that calling .length() on an empty std::string
+ will yield 0, and vice versa, but supporting all of them is a huge
+amount of work. One good thing to start with here would be to notice that
+inlining methods of C++ "containers" is currently outright forbidden in
+order to suppress a lot of false alarms due to weird assume()s
+made within inlined methods. There’s a hypothesis that these suppressions
+should have been instead implemented as bug report visitors, which would
+still suppress false positives, but will not prevent us from inlining the 
+ethods, and therefore will not cause other false positives. Verifying this
+hypothesis would be a wonderful accomplishment. Previous understanding of
+the "inlined defensive checks" problem is a pre-requisite for this project.
+(Difficulty: Medium)
+
+
+Reimplement the representation for various symbolic values.
+https://clang.llvm.org/doxygen/classclang_1_1ento_1_1nonloc_1_1LocAsInteger.html";>
+LocAsInteger is annoying, but alternatives are vague. Casts into
+the opposite direction - integers to pointers - are completely unsupported.
+Pointer-to-pointer casts are a mess; modeling them with https://clang.llvm.org/doxygen/classclang_1_1ento_1_1ElementRegion.html";>
+ElementRegion  is a disaster and we are suffering a lot from this
+hack, but coming up with a significantly better solution is very hard, as
+there are a lot of corner-cases to cover, and it’s hard to maintain balance
+between richness of our representation of symbolic values and our ability to
+understand when the two different values in fact represent the same thing.
+(Difficulty: Hard)
+
+
+ Provide better alternatives to inlining.
+Sometimes instead of inlining, a much simpler behavior would be more
+efficient. For instance, if the function is pure, then a single bit of
+information “this function is pure” would already be much better than
+conservative evaluation, and sometimes good enough to make inlining not
+worth the effort. Gathering such snippets of information - “partial
+summaries" - automatically, from the more simple to the more complex
+summaries, and re-using them later, probably across translation units, might
+improve our analysis quite a lot, while 

[PATCH] D51809: [CUDA][HIP] Fix ShouldDeleteSpecialMember for inherited constructors

2018-10-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:7231
+if (ICI)
+  CSM = getSpecialMember(MD);
+

jlebar wrote:
> LGTM, but perhaps we should use a new variable instead of modifying `CSM` in 
> case someone adds code beneath this branch?
will do when committing.


https://reviews.llvm.org/D51809



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


[clang-tools-extra] r344055 - [clang-move] Fix broken json output.

2018-10-09 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Tue Oct  9 08:17:16 2018
New Revision: 344055

URL: http://llvm.org/viewvc/llvm-project?rev=344055&view=rev
Log:
[clang-move] Fix broken json output.

Modified:
clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp

Modified: clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp?rev=344055&r1=344054&r2=344055&view=diff
==
--- clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp (original)
+++ clang-tools-extra/trunk/clang-move/tool/ClangMoveMain.cpp Tue Oct  9 
08:17:16 2018
@@ -128,7 +128,7 @@ int main(int argc, const char **argv) {
  InitialDirectory.str(), Style, DumpDecls};
   move::DeclarationReporter Reporter;
   move::ClangMoveActionFactory Factory(&Context, &Reporter);
-  
+
   int CodeStatus = Tool.run(&Factory);
   if (CodeStatus)
 return CodeStatus;
@@ -138,8 +138,9 @@ int main(int argc, const char **argv) {
 const auto &Declarations = Reporter.getDeclarationList();
 for (auto I = Declarations.begin(), E = Declarations.end(); I != E; ++I) {
   llvm::outs() << "  {\n";
-  llvm::outs() << "\"DeclarationName\": \"" << I->QualifiedName << 
"\",\n";
-  llvm::outs() << "\"DeclarationType\": \"" << I->Kind << "\"\n";
+  llvm::outs() << "\"DeclarationName\": \"" << I->QualifiedName
+   << "\",\n";
+  llvm::outs() << "\"DeclarationType\": \"" << I->Kind << "\",\n";
   llvm::outs() << "\"Templated\": " << (I->Templated ? "true" : 
"false")
<< "\n";
   llvm::outs() << "  }";


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


[clang-tools-extra] r344054 - [clangd] Fix an accident change in r342999.

2018-10-09 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Oct  9 08:16:14 2018
New Revision: 344054

URL: http://llvm.org/viewvc/llvm-project?rev=344054&view=rev
Log:
[clangd] Fix an accident change in r342999.

Modified:
clang-tools-extra/trunk/clangd/index/YAMLSerialization.cpp

Modified: clang-tools-extra/trunk/clangd/index/YAMLSerialization.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/YAMLSerialization.cpp?rev=344054&r1=344053&r2=344054&view=diff
==
--- clang-tools-extra/trunk/clangd/index/YAMLSerialization.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/YAMLSerialization.cpp Tue Oct  9 
08:16:14 2018
@@ -286,7 +286,7 @@ std::string toYAML(const Symbol &S) {
 llvm::raw_string_ostream OS(Buf);
 llvm::yaml::Output Yout(OS);
 Symbol Sym = S; // copy: Yout<< requires mutability.
-OS << Sym;
+Yout << Sym;
   }
   return Buf;
 }


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


[PATCH] D53019: [clangd] dump xrefs information in dexp tool.

2018-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/index/dex/dexp/Dexp.cpp:65
+  clang::clangd::SymbolID SymID;
+  // We choose the first one if there are overloaded symbols.
+  Index->fuzzyFind(Request, [&](const Symbol &Sym) {

I don't think this is reasonable behavior. I'd suggest either of:
 - processing all results (this function would return a vector)
 - treat this as an error, the error message should include the ID of each 
symbol so we can rerun the command in an unambiguous way



Comment at: clangd/index/dex/dexp/Dexp.cpp:173
+  llvm::outs()
+  << "Missing required argument: please provide -id or -name.\n";
+  return;

nit: just "id" with no dash


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53019



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


[PATCH] D53019: [clangd] dump xrefs information in dexp tool.

2018-10-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 168802.
hokein added a comment.

Minor fix.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53019

Files:
  clangd/index/dex/dexp/CMakeLists.txt
  clangd/index/dex/dexp/Dexp.cpp

Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -12,13 +12,15 @@
 //
 //===--===//
 
-#include "../../Serialization.h"
-#include "../Dex.h"
+#include "Dex.h"
+#include "Serialization.h"
+#include "SourceCode.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Signals.h"
 
 using clang::clangd::FuzzyFindRequest;
@@ -52,6 +54,29 @@
   llvm::outs() << llvm::formatv("{0} took {1:ms+n}.\n", Name, Duration);
 }
 
+llvm::Expected
+getSymbolIDFromIndex(llvm::StringRef QualifiedName, const SymbolIndex *Index) {
+  FuzzyFindRequest Request;
+  Request.Scopes.emplace_back();
+  std::tie(Request.Scopes.back(), Request.Query) =
+  clang::clangd::splitQualifiedName(QualifiedName);
+  bool Found = false;
+  clang::clangd::SymbolID SymID;
+  // We choose the first one if there are overloaded symbols.
+  Index->fuzzyFind(Request, [&](const Symbol &Sym) {
+std::string SymQualifiedName = (Sym.Scope + Sym.Name).str();
+if (!Found && QualifiedName == SymQualifiedName) {
+  SymID = Sym.ID;
+  Found = true;
+}
+  });
+  if (Found)
+return SymID;
+
+  return llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Symbol not found in index.");
+}
+
 // REPL commands inherit from Command and contain their options as members.
 // Creating a Command populates parser options, parseAndRun() resets them.
 class Command {
@@ -88,7 +113,6 @@
 };
 
 // FIXME(kbobyrev): Ideas for more commands:
-// * find symbol references: print set of reference locations
 // * load/swap/reload index: this would make it possible to get rid of llvm::cl
 //   usages in the tool driver and actually use llvm::cl library in the REPL.
 // * show posting list density histogram (our dump data somewhere so that user
@@ -139,12 +163,21 @@
   cl::opt ID{
   "id",
   cl::Positional,
-  cl::Required,
   cl::desc("Symbol ID to look up (hex)"),
   };
+  cl::opt Name{
+  "name", cl::desc("Qualified name to look up."),
+  };
 
   void run() override {
-auto SID = clang::clangd::SymbolID::fromStr(ID);
+if (ID.getNumOccurrences() == 0 && Name.getNumOccurrences() == 0) {
+  llvm::outs()
+  << "Missing required argument: please provide -id or -name.\n";
+  return;
+}
+llvm::Expected SID =
+ID.getNumOccurrences() ? clang::clangd::SymbolID::fromStr(ID)
+   : getSymbolIDFromIndex(Name, Index);
 if (!SID) {
   llvm::outs() << llvm::toString(SID.takeError()) << "\n";
   return;
@@ -162,13 +195,59 @@
   }
 };
 
+class Refs : public Command {
+  cl::opt ID{
+  "id", cl::Positional,
+  cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  cl::opt Name{
+  "name", cl::desc("Qualified name of the symbol being queried."),
+  };
+  cl::opt Filter{
+  "filter",
+  cl::init(".*"),
+  cl::desc(
+  "Print all results from files matching this regular expression."),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 && Name.getNumOccurrences() == 0) {
+  llvm::outs()
+  << "Missing required argument: please provide -id or -name.\n";
+  return;
+}
+llvm::Expected SID =
+ID.getNumOccurrences() ? clang::clangd::SymbolID::fromStr(ID)
+   : getSymbolIDFromIndex(Name, Index);
+if (!SID) {
+  llvm::outs() << llvm::toString(SID.takeError()) << "\n";
+  return;
+}
+clang::clangd::RefsRequest RefRequest;
+RefRequest.IDs.insert(*SID);
+llvm::Regex RegexFilter(Filter);
+Index->refs(RefRequest, [&RegexFilter](const clang::clangd::Ref &R) {
+  auto U = clang::clangd::URI::parse(R.Location.FileURI);
+  if (!U) {
+llvm::outs() << U.takeError();
+return;
+  }
+  if (RegexFilter.match(U->body()))
+llvm::outs() << R << "\n";
+});
+  }
+};
+
 struct {
   const char *Name;
   const char *Description;
   std::function()> Implementation;
 } CommandInfo[] = {
 {"find", "Search for symbols with fuzzyFind", llvm::make_unique},
-{"lookup", "Dump symbol details by ID", llvm::make_unique},
+{"lookup", "Dump symbol details by ID or qualified name",
+ llvm::make_unique},
+{"refs", "Find references by ID or qualified name",
+ llvm::make_unique},
 };
 
 } // namespace
Index: clangd/index/dex/dexp/CMakeLists.txt
===

[PATCH] D53019: [clangd] dump xrefs information in dexp tool.

2018-10-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clangd/index/dex/dexp/Dexp.cpp:204
 {"lookup", "Dump symbol details by ID", llvm::make_unique},
+{"refs", "Find references by qualified name", llvm::make_unique},
 };

sammccall wrote:
> I'm not sure "by qualified name" is a good idea, at least as the only option:
>  - if there are overloads, you can't choose the right one (possible fix: make 
> this a named flag like `refs --name foo::bar`)
>  - you can't search for refs for std::unique without getting std::unique_ptr 
> (possible fix: postfilter by name)
>  - it seems inconsistent with Lookup (possible fix: update both)
> 
> 
Sounds fair enough. I think query the symbol by "qualified_name" would be more 
convenient and practical when we use the tool. ID is not quite straight-forward.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53019



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


[PATCH] D53019: [clangd] dump xrefs information in dexp tool.

2018-10-09 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 168801.
hokein marked 3 inline comments as done.
hokein added a comment.
Herald added a subscriber: mgorny.

Address review comments:

- provide query by qualified name (with -name)
- add -name support for Lookup.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53019

Files:
  clangd/index/dex/dexp/CMakeLists.txt
  clangd/index/dex/dexp/Dexp.cpp

Index: clangd/index/dex/dexp/Dexp.cpp
===
--- clangd/index/dex/dexp/Dexp.cpp
+++ clangd/index/dex/dexp/Dexp.cpp
@@ -12,13 +12,15 @@
 //
 //===--===//
 
-#include "../../Serialization.h"
-#include "../Dex.h"
+#include "Dex.h"
+#include "Serialization.h"
+#include "SourceCode.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/LineEditor/LineEditor.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Signals.h"
 
 using clang::clangd::FuzzyFindRequest;
@@ -52,6 +54,27 @@
   llvm::outs() << llvm::formatv("{0} took {1:ms+n}.\n", Name, Duration);
 }
 
+llvm::Expected
+getSymbolIDFromIndex(llvm::StringRef QualifiedName, const SymbolIndex *Index) {
+  FuzzyFindRequest Request;
+  Request.Scopes.emplace_back();
+  std::tie(Request.Scopes.back(), Request.Query) =
+  clang::clangd::splitQualifiedName(QualifiedName);
+  bool Found = false;
+  clang::clangd::SymbolID SymID;
+  // We choose the first one if there are overloaded symbols.
+  Index->fuzzyFind(Request, [&](const Symbol &Sym) {
+std::string SymQualifiedName = (Sym.Scope + Sym.Name).str();
+if (!Found && QualifiedName == SymQualifiedName) {
+  SymID = Sym.ID;
+  Found = true;
+}
+  });
+  return Found ? SymID
+   : llvm::createStringError(llvm::inconvertibleErrorCode(),
+ "Symbol not found in index.");
+}
+
 // REPL commands inherit from Command and contain their options as members.
 // Creating a Command populates parser options, parseAndRun() resets them.
 class Command {
@@ -88,7 +111,6 @@
 };
 
 // FIXME(kbobyrev): Ideas for more commands:
-// * find symbol references: print set of reference locations
 // * load/swap/reload index: this would make it possible to get rid of llvm::cl
 //   usages in the tool driver and actually use llvm::cl library in the REPL.
 // * show posting list density histogram (our dump data somewhere so that user
@@ -139,12 +161,21 @@
   cl::opt ID{
   "id",
   cl::Positional,
-  cl::Required,
   cl::desc("Symbol ID to look up (hex)"),
   };
+  cl::opt Name{
+  "name", cl::desc("Qualified name to look up."),
+  };
 
   void run() override {
-auto SID = clang::clangd::SymbolID::fromStr(ID);
+if (ID.getNumOccurrences() == 0 && Name.getNumOccurrences() == 0) {
+  llvm::outs()
+  << "Missing required argument: please provide -id or -name.\n";
+  return;
+}
+llvm::Expected SID =
+ID.getNumOccurrences() ? clang::clangd::SymbolID::fromStr(ID)
+   : getSymbolIDFromIndex(Name, Index);
 if (!SID) {
   llvm::outs() << llvm::toString(SID.takeError()) << "\n";
   return;
@@ -162,13 +193,59 @@
   }
 };
 
+class Refs : public Command {
+  cl::opt ID{
+  "id", cl::Positional,
+  cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  cl::opt Name{
+  "name", cl::desc("Qualified name of the symbol being queried."),
+  };
+  cl::opt Filter{
+  "filter",
+  cl::init(".*"),
+  cl::desc(
+  "Print all results from files matching this regular expression."),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 && Name.getNumOccurrences() == 0) {
+  llvm::outs()
+  << "Missing required argument: please provide -id or -name.\n";
+  return;
+}
+llvm::Expected SID =
+ID.getNumOccurrences() ? clang::clangd::SymbolID::fromStr(ID)
+   : getSymbolIDFromIndex(Name, Index);
+if (!SID) {
+  llvm::outs() << llvm::toString(SID.takeError()) << "\n";
+  return;
+}
+clang::clangd::RefsRequest RefRequest;
+RefRequest.IDs.insert(*SID);
+llvm::Regex RegexFilter(Filter);
+Index->refs(RefRequest, [&RegexFilter](const clang::clangd::Ref &R) {
+  auto U = clang::clangd::URI::parse(R.Location.FileURI);
+  if (!U) {
+llvm::outs() << U.takeError();
+return;
+  }
+  if (RegexFilter.match(U->body()))
+llvm::outs() << R << "\n";
+});
+  }
+};
+
 struct {
   const char *Name;
   const char *Description;
   std::function()> Implementation;
 } CommandInfo[] = {
 {"find", "Search for symbols with fuzzyFind", llvm::make_unique},
-{"lookup", "Dump symbol details by ID", llvm::make_unique},
+{"lookup", "Dump symbol details by ID or qualified name",
+ llvm::make_unique

  1   2   >