[PATCH] D26196: AMDGPU: Translate null pointers in private and local addr space

2016-11-03 Thread Matt Arsenault via cfe-commits
arsenm added a comment.

In https://reviews.llvm.org/D26196#586433, @rjmccall wrote:

> I think there are a number of conceptual questions here, chiefly among them 
> whether an llvm::ConstantPointerNull in an address-space type should have the 
> correct representation for the target.  If the decision for that is "no", 
> then ok, we can produce an explicit representation in IRGen; however, we will 
> need to update quite a bit of code in order to do so correctly.


I think the answer for this is yes, but doing so would be a pretty involved 
project.

In https://reviews.llvm.org/D26196#586723, @Anastasia wrote:

> My understanding of NULL constant in IR was that it doesn't assume any 
> specific integer value (i.e. 0). And currently as I can see it is lowered 
> very late in LLVM backend  during the code selection phase.
>
> Looking at the lowering code in LLVM, it seems like it shouldn't be too 
> difficult to special case the NULL value based on the address space: 
> http://llvm.org/docs/doxygen/html/SelectionDAGBuilder_8cpp_source.html#l01039 
> instead of using hard-coded 0 at it's done now.
>
> My opinion is that we should try to lower the code as late as possible and 
> Clang doesn't seem like an ideal place for this. Also this change adds extra 
> overhead by adding extra addresspacecast instructions and complicates 
> frontend implementation. I don't see immediate benefit in changing this in 
> the frontend compared to changing LLVM code selection phase instead.


This is essentially moving the lowering of the constant to as late as possible 
by moving it to the addrspacecast lowering. I think it would be a pretty 
substantial project to add non-0 null pointer support, but would be better long 
term. It is treated as isNull, so computeKnownBits and other places already 
treat null as an alias for 0. Tracking down all of these would be a time 
consuming endeavor


https://reviews.llvm.org/D26196



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


[PATCH] D26287: clang-format: Use git-ls-tree to get file mode in diff mode

2016-11-03 Thread Mark Lodato via cfe-commits
lodato accepted this revision.
lodato added a comment.
This revision is now accepted and ready to land.

Thanks for the fix!


https://reviews.llvm.org/D26287



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


[PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

2016-11-03 Thread Mehdi AMINI via cfe-commits
mehdi_amini added a comment.

(Quick stylistic comments)




Comment at: include/clang/Analysis/CloneDetection.h:224
 
-  /// \brief Searches the provided statements for clones.
+  /// \brief Represents a way to filter clones from a list of clone groups.
   ///

Use of `\brief` is deprecated (we enabled auto brief quite some time ago).



Comment at: include/clang/Analysis/CloneDetection.h:417
+public:
+  virtual ~MatchingVariablePatternConstraint() {}
+

`= default`



Comment at: include/clang/Analysis/CloneDetection.h:419
+
+  virtual bool
+  acceptsPrototype(const StmtSequence ,

No need for virtual on override.


https://reviews.llvm.org/D23418



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


[PATCH] D16135: Macro Debug Info support in Clang

2016-11-03 Thread Richard Smith via cfe-commits
rsmith added inline comments.



Comment at: include/clang/AST/ASTConsumer.h:163
+  /// The caller takes ownership on the returned pointer.
+  virtual std::unique_ptr 
CreatePreprocessorCallbacks(Preprocessor );
 };

aaboud wrote:
> Richard,
> I know that you suggested not to introduce the Preprocessor in anyway to the 
> ASTConsumer.
> However, as I could not understand the other way to support macros in Clang 
> without applying a huge redesign, I decided to upload the code I suggested in 
> the proposal.
> http://lists.llvm.org/pipermail/llvm-dev/2015-November/092449.html
> 
> If you still think that this approach is not the right one, I would 
> appreciate it if you can explain again how to implement the macro support 
> differently.
Don't add this to `ASTConsumer`; an AST consumer and a PP consumer are two 
largely separate ideas. Instead, you could create and register a `PPCallbacks` 
object directly from `CodeGenAction::CreateASTConsumer`. In fact, if you look 
there, a `PPCallbacks` subclass is already registered (for code coverage); you 
can do something similar to register your `MacroPPCallbacks` object.



Comment at: lib/CodeGen/CMakeLists.txt:76
   ItaniumCXXABI.cpp
+  MacroPPCallbacks.cpp
   MicrosoftCXXABI.cpp

This file is missing from the diff.



Comment at: lib/CodeGen/CodeGenModule.cpp:28
 #include "CoverageMappingGen.h"
+#include "MacroPPCallbacks.h"
 #include "TargetInfo.h"

This file is missing from the diff.


https://reviews.llvm.org/D16135



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


[PATCH] D26267: [Modules] Include builtins with #include instead of #import for ObjC

2016-11-03 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added a comment.

Could you include more context when creating the diff eg. git diff -U, or 
equivalent.




Comment at: include/clang/Lex/ModuleMap.h:278
+  /// headers.
+  static bool isBuiltinHeader(StringRef FileName);
+

It seems this is in the private section and it is accessed by 
FrontendActions.cpp:224.


https://reviews.llvm.org/D26267



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


r285971 - Remove the unused POLLY_LINK_LIBS for linking polly into clang

2016-11-03 Thread Hongbin Zheng via cfe-commits
Author: ether
Date: Thu Nov  3 17:02:40 2016
New Revision: 285971

URL: http://llvm.org/viewvc/llvm-project?rev=285971=rev
Log:
Remove the unused POLLY_LINK_LIBS for linking polly into clang

Modified:
cfe/trunk/tools/driver/CMakeLists.txt

Modified: cfe/trunk/tools/driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/CMakeLists.txt?rev=285971=285970=285971=diff
==
--- cfe/trunk/tools/driver/CMakeLists.txt (original)
+++ cfe/trunk/tools/driver/CMakeLists.txt Thu Nov  3 17:02:40 2016
@@ -117,9 +117,4 @@ endif()
 
 if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)
   target_link_libraries(clang Polly)
-  if(POLLY_LINK_LIBS)
-foreach(lib ${POLLY_LINK_LIBS})
-  target_link_libraries(clang ${lib})
-endforeach(lib)
-  endif(POLLY_LINK_LIBS)
 endif(WITH_POLLY AND LINK_POLLY_INTO_TOOLS)


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


[PATCH] D26288: Deduplicate replacements by FileEntry instead of file names.

2016-11-03 Thread Eric Liu via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D26288#586902, @klimek wrote:

> If the files do not exist, how does this work? Won't that potentially give 
> different results if the files exist locally vs if they don't?


This would be problematic. Thanks for the catch!


https://reviews.llvm.org/D26288



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


[PATCH] D26288: Deduplicate replacements by FileEntry instead of file names.

2016-11-03 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 76894.
ioeric added a comment.

- Addressed comments: handle non-existing files.


https://reviews.llvm.org/D26288

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -19,6 +19,7 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Format/Format.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
@@ -972,40 +973,64 @@
   toReplacements({{"", 0, 3, "cc"}, {"", 3, 3, "dd"}}));
 }
 
-TEST(DeduplicateByFileTest, LeaveLeadingDotDot) {
+TEST(DeduplicateByFileTest, PathsWithDots) {
   std::map FileToReplaces;
+  llvm::IntrusiveRefCntPtr VFS(
+  new vfs::InMemoryFileSystem());
+  FileManager *FileMgr = new FileManager(FileSystemOptions(), VFS);
 #if !defined(LLVM_ON_WIN32)
-  FileToReplaces["../../a/b/.././c.h"] = Replacements();
-  FileToReplaces["../../a/c.h"] = Replacements();
+  StringRef Path1 = "a/b/.././c.h";
+  StringRef Path2 = "a/c.h";
 #else
-  FileToReplaces["..\\..\\a\\b\\..\\.\\c.h"] = Replacements();
-  FileToReplaces["..\\..\\a\\c.h"] = Replacements();
+  StringRef Path1 = "a\\b\\..\\.\\c.h";
+  StringRef Path2 = "a\\c.h";
 #endif
-  FileToReplaces = groupReplacementsByFile(FileToReplaces);
+  EXPECT_TRUE(VFS->addFile(Path1, 0, llvm::MemoryBuffer::getMemBuffer("")));
+  EXPECT_TRUE(VFS->addFile(Path2, 0, llvm::MemoryBuffer::getMemBuffer("")));
+  FileToReplaces[Path1] = Replacements();
+  FileToReplaces[Path2] = Replacements();
+  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
   EXPECT_EQ(1u, FileToReplaces.size());
-#if !defined(LLVM_ON_WIN32)
-  EXPECT_EQ("../../a/c.h", FileToReplaces.begin()->first);
-#else
-  EXPECT_EQ("..\\..\\a\\c.h", FileToReplaces.begin()->first);
-#endif
+  EXPECT_EQ(Path1, FileToReplaces.begin()->first);
 }
 
-TEST(DeduplicateByFileTest, RemoveDotSlash) {
+TEST(DeduplicateByFileTest, PathWithDotSlash) {
   std::map FileToReplaces;
+  llvm::IntrusiveRefCntPtr VFS(
+  new vfs::InMemoryFileSystem());
+  FileManager *FileMgr = new FileManager(FileSystemOptions(), VFS);
 #if !defined(LLVM_ON_WIN32)
-  FileToReplaces["./a/b/.././c.h"] = Replacements();
-  FileToReplaces["a/c.h"] = Replacements();
+  StringRef Path1 = "./a/b/c.h";
+  StringRef Path2 = "a/b/c.h";
 #else
-  FileToReplaces[".\\a\\b\\..\\.\\c.h"] = Replacements();
-  FileToReplaces["a\\c.h"] = Replacements();
+  StringRef Path1 = ".\\a\\b\\c.h";
+  StringRef Path2 = "a\\b\\c.h";
 #endif
-  FileToReplaces = groupReplacementsByFile(FileToReplaces);
+  EXPECT_TRUE(VFS->addFile(Path1, 0, llvm::MemoryBuffer::getMemBuffer("")));
+  EXPECT_TRUE(VFS->addFile(Path2, 0, llvm::MemoryBuffer::getMemBuffer("")));
+  FileToReplaces[Path1] = Replacements();
+  FileToReplaces[Path2] = Replacements();
+  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
   EXPECT_EQ(1u, FileToReplaces.size());
+  EXPECT_EQ(Path1, FileToReplaces.begin()->first);
+}
+
+TEST(DeduplicateByFileTest, NonExistingFilePath) {
+  std::map FileToReplaces;
+  llvm::IntrusiveRefCntPtr VFS(
+  new vfs::InMemoryFileSystem());
+  FileManager *FileMgr = new FileManager(FileSystemOptions(), VFS);
 #if !defined(LLVM_ON_WIN32)
-  EXPECT_EQ("a/c.h", FileToReplaces.begin()->first);
+  StringRef Path1 = "./a/b/c.h";
+  StringRef Path2 = "a/b/c.h";
 #else
-  EXPECT_EQ("a\\c.h", FileToReplaces.begin()->first);
+  StringRef Path1 = ".\\a\\b\\c.h";
+  StringRef Path2 = "a\\b\\c.h";
 #endif
+  FileToReplaces[Path1] = Replacements();
+  FileToReplaces[Path2] = Replacements();
+  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
+  EXPECT_TRUE(FileToReplaces.empty());
 }
 
 } // end namespace tooling
Index: lib/Tooling/Refactoring.cpp
===
--- lib/Tooling/Refactoring.cpp
+++ lib/Tooling/Refactoring.cpp
@@ -57,7 +57,8 @@
 
 bool RefactoringTool::applyAllReplacements(Rewriter ) {
   bool Result = true;
-  for (const auto  : groupReplacementsByFile(FileToReplaces))
+  for (const auto  : groupReplacementsByFile(
+   Rewrite.getSourceMgr().getFileManager(), FileToReplaces))
 Result = tooling::applyAllReplacements(Entry.second, Rewrite) && Result;
   return Result;
 }
@@ -73,7 +74,8 @@
   FileManager  = SM.getFileManager();
 
   bool Result = true;
-  for (const auto  : groupReplacementsByFile(FileToReplaces)) {
+  for (const auto  : groupReplacementsByFile(
+   Rewrite.getSourceMgr().getFileManager(), FileToReplaces)) {
 const std::string  = 

Re: r276934 - [OpenMP] Add support to map member expressions with references to pointers.

2016-11-03 Thread Richard Smith via cfe-commits
On Wed, Jul 27, 2016 at 3:52 PM, Samuel Antao via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sfantao
> Date: Wed Jul 27 17:52:16 2016
> New Revision: 276934
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276934=rev
> Log:
> [OpenMP] Add support to map member expressions with references to pointers.
>
> Summary: This patch add support to map pointers through references in
> class members. Although a reference does not have storage that a user can
> access, it still has to be mapped in order to get the deep copy right and
> the dereferencing code work properly.
>
> Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev
>
> Subscribers: caomhin, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D22787
>
> Modified:
> cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> cfe/trunk/test/OpenMP/target_map_codegen.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> CGOpenMPRuntime.cpp?rev=276934=276933=276934=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Wed Jul 27 17:52:16 2016
> @@ -5320,14 +5320,34 @@ private:
>  isa(Next->getAssociatedExpression()))
> &&
> "Unexpected expression");
>
> -// Save the base we are currently using.
> -BasePointers.push_back(BP);
> -
>  auto *LB = CGF.EmitLValue(I->getAssociatedExpression()).
> getPointer();
>  auto *Size = getExprTypeSize(I->getAssociatedExpression());
>
> +// If we have a member expression and the current component is a
> +// reference, we have to map the reference too. Whenever we have a
> +// reference, the section that reference refers to is going to be
> a
> +// load instruction from the storage assigned to the reference.
> +if (isa(I->getAssociatedExpression()) &&
> +I->getAssociatedDeclaration()->getType()->isReferenceType())
> {
> +  auto *LI = cast(LB);
> +  auto *RefAddr = LI->getPointerOperand();
> +
> +  BasePointers.push_back(BP);
> +  Pointers.push_back(RefAddr);
> +  Sizes.push_back(CGF.getTypeSize(CGF.getContext().VoidPtrTy));
> +  Types.push_back(getMapTypeBits(
> +  /*MapType*/ OMPC_MAP_alloc, /*MapTypeModifier=*/OMPC_MAP_
> unknown,
> +  !IsExpressionFirstInfo, IsCaptureFirstInfo));
> +  IsExpressionFirstInfo = false;
> +  IsCaptureFirstInfo = false;
> +  // The reference will be the next base address.
> +  BP = RefAddr;
> +}
> +
> +BasePointers.push_back(BP);
>  Pointers.push_back(LB);
>  Sizes.push_back(Size);
> +
>  // We need to add a pointer flag for each map that comes from the
>  // same expression except for the first one. We also need to
> signal
>  // this map is the first one that relates with the current capture
>
> Modified: cfe/trunk/test/OpenMP/target_map_codegen.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/
> target_map_codegen.cpp?rev=276934=276933=276934=diff
> 
> ==
> --- cfe/trunk/test/OpenMP/target_map_codegen.cpp (original)
> +++ cfe/trunk/test/OpenMP/target_map_codegen.cpp Wed Jul 27 17:52:16 2016
>

This test file now takes 30s to run with a debug binary, and is one of
Clang's slowest tests (tests are typically expected to finish in well under
a second).

Can you take a look? Instead of running the compiler 174 times on the same
inputs with the same flags, how about just running it once and -- if
necessary -- storing the output to a temporary file and passing that to
FileCheck multiple times?

@@ -4564,4 +4564,193 @@ void explicit_maps_pointer_references (i
>}
>  }
>  #endif
> +///
> ==///
> +// RUN: %clang_cc1 -DCK29 -verify -fopenmp 
> -fopenmp-targets=powerpc64le-ibm-linux-gnu
> -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck
> %s --check-prefix CK29 --check-prefix CK29-64
> +// RUN: %clang_cc1 -DCK29 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu
> -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
> +// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu
> -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t
> -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK29
> --check-prefix CK29-64
> +// RUN: %clang_cc1 -DCK29 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu
> -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
> --check-prefix CK29 --check-prefix CK29-32
> +// RUN: %clang_cc1 -DCK29 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x
> c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t 

Re: r273191 - [OpenCL] Include opencl-c.h by default as a clang module

2016-11-03 Thread Richard Smith via cfe-commits
Hi,

This test (test/Headers/opencl-c-header.cl) is *extremely* slow -- it
parses the 17KLoC opencl-c.h header 40 times, and on my Debug builds it's
the slowest test by far, taking nearly 2 minutes to run *alone*. (For
reference, the *entire clang test suite* finishes in 90s on my machine with
this test removed.)

Please can you do something about this? Do we really need to parse this
header in 40 configurations here?

On Mon, Jun 20, 2016 at 12:26 PM, Yaxun Liu via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: yaxunl
> Date: Mon Jun 20 14:26:00 2016
> New Revision: 273191
>
> URL: http://llvm.org/viewvc/llvm-project?rev=273191=rev
> Log:
> [OpenCL] Include opencl-c.h by default as a clang module
>
> Include opencl-c.h by default as a module to utilize the automatic AST
> caching mechanism of clang modules.
>
> Add an option -finclude-default-header to enable default header for
> OpenCL, which is off by default.
>
> Differential Revision: http://reviews.llvm.org/D20444
>
> Modified:
> cfe/trunk/include/clang/Basic/LangOptions.def
> cfe/trunk/include/clang/Driver/CC1Options.td
> cfe/trunk/include/clang/Frontend/CompilerInvocation.h
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Headers/module.modulemap
> cfe/trunk/test/Headers/opencl-c-header.cl
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/LangOptions.def?rev=273191=273190=273191=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Jun 20 14:26:00 2016
> @@ -218,7 +218,7 @@ LANGOPT(ObjCWeak, 1, 0, "Obj
>  LANGOPT(ObjCSubscriptingLegacyRuntime , 1, 0, "Subscripting
> support in legacy ObjectiveC runtime")
>  LANGOPT(FakeAddressSpaceMap , 1, 0, "OpenCL fake address space map")
>  ENUM_LANGOPT(AddressSpaceMapMangling , AddrSpaceMapMangling, 2,
> ASMM_Target, "OpenCL address space map mangling mode")
> -
> +LANGOPT(IncludeDefaultHeader, 1, 0, "Include default header file for
> OpenCL")
>  BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template parsing")
>  LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime")
>
>
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/CC1Options.td?rev=273191=273190=273191=diff
> 
> ==
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Jun 20 14:26:00 2016
> @@ -612,6 +612,8 @@ def fallow_half_arguments_and_returns :
>HelpText<"Allow function arguments and returns of type half">;
>  def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">,
>HelpText<"Set default MS calling convention">;
> +def finclude_default_header : Flag<["-"], "finclude-default-header">,
> +  HelpText<"Include the default header file for OpenCL">;
>
>  // C++ TSes.
>  def fcoroutines : Flag<["-"], "fcoroutines">,
>
> Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/
> CompilerInvocation.h?rev=273191=273190=273191=diff
> 
> ==
> --- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
> +++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Mon Jun 20
> 14:26:00 2016
> @@ -155,9 +155,10 @@ public:
>/// \param Opts - The LangOptions object to set up.
>/// \param IK - The input language.
>/// \param T - The target triple.
> +  /// \param PPOpts - The PreprocessorOptions affected.
>/// \param LangStd - The input language standard.
>static void setLangDefaults(LangOptions , InputKind IK,
> -   const llvm::Triple ,
> +   const llvm::Triple , PreprocessorOptions ,
> LangStandard::Kind LangStd = LangStandard::lang_
> unspecified);
>
>/// \brief Retrieve a module hash string that is suitable for uniquely
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/
> Frontend/CompilerInvocation.cpp?rev=273191=273190=273191=diff
> 
> ==
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Jun 20 14:26:00 2016
> @@ -1459,6 +1459,7 @@ bool isOpenCL(LangStandard::Kind LangStd
>
>  void CompilerInvocation::setLangDefaults(LangOptions , InputKind IK,
>   const llvm::Triple ,
> + PreprocessorOptions ,
>   LangStandard::Kind LangStd) {
> 

[PATCH] D26285: [index] Expose FriendDecl

2016-11-03 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a reviewer: rsmith.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D26285



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


[PATCH] D26288: Deduplicate replacements by FileEntry instead of file names.

2016-11-03 Thread Manuel Klimek via cfe-commits
klimek added a comment.

If the files do not exist, how does this work? Won't that potentially give 
different results if the files exist locally vs if they don't?


https://reviews.llvm.org/D26288



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


[PATCH] D26288: Deduplicate replacements by FileEntry instead of file names.

2016-11-03 Thread Eric Liu via cfe-commits
ioeric added inline comments.



Comment at: lib/Tooling/Core/Replacement.cpp:578
+  continue;
+ProcessedFileEntries.insert(FE);
+Result[Entry.first] = std::move(Entry.second);

alexshap wrote:
> (saves 2 lines of code) (although not particularly important) 
>   if (ProcessedFileEntries.insert(FE).second)
>  Result[Entry.first] = std::move(Entry.second);
Always nice to save a few lines :) Thanks!


https://reviews.llvm.org/D26288



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


[PATCH] D26288: Deduplicate replacements by FileEntry instead of file names.

2016-11-03 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 76888.
ioeric added a comment.

- Kill a few lines.


https://reviews.llvm.org/D26288

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -972,39 +972,41 @@
   toReplacements({{"", 0, 3, "cc"}, {"", 3, 3, "dd"}}));
 }
 
-TEST(DeduplicateByFileTest, LeaveLeadingDotDot) {
+TEST(DeduplicateByFileTest, PathsWithDots) {
   std::map FileToReplaces;
+  FileManager *FileMgr = new FileManager(FileSystemOptions());
 #if !defined(LLVM_ON_WIN32)
   FileToReplaces["../../a/b/.././c.h"] = Replacements();
   FileToReplaces["../../a/c.h"] = Replacements();
 #else
   FileToReplaces["..\\..\\a\\b\\..\\.\\c.h"] = Replacements();
   FileToReplaces["..\\..\\a\\c.h"] = Replacements();
 #endif
-  FileToReplaces = groupReplacementsByFile(FileToReplaces);
+  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
   EXPECT_EQ(1u, FileToReplaces.size());
 #if !defined(LLVM_ON_WIN32)
-  EXPECT_EQ("../../a/c.h", FileToReplaces.begin()->first);
+  EXPECT_EQ("../../a/b/.././c.h", FileToReplaces.begin()->first);
 #else
-  EXPECT_EQ("..\\..\\a\\c.h", FileToReplaces.begin()->first);
+  EXPECT_EQ("..\\..\\a\\b\\..\\.\\c.h", FileToReplaces.begin()->first);
 #endif
 }
 
-TEST(DeduplicateByFileTest, RemoveDotSlash) {
+TEST(DeduplicateByFileTest, PathWithDotSlash) {
   std::map FileToReplaces;
+  FileManager *FileMgr = new FileManager(FileSystemOptions());
 #if !defined(LLVM_ON_WIN32)
-  FileToReplaces["./a/b/.././c.h"] = Replacements();
-  FileToReplaces["a/c.h"] = Replacements();
+  FileToReplaces["./a/b/c.h"] = Replacements();
+  FileToReplaces["a/b/c.h"] = Replacements();
 #else
-  FileToReplaces[".\\a\\b\\..\\.\\c.h"] = Replacements();
-  FileToReplaces["a\\c.h"] = Replacements();
+  FileToReplaces[".\\a\\b\\c.h"] = Replacements();
+  FileToReplaces["a\\b\\c.h"] = Replacements();
 #endif
-  FileToReplaces = groupReplacementsByFile(FileToReplaces);
+  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
   EXPECT_EQ(1u, FileToReplaces.size());
 #if !defined(LLVM_ON_WIN32)
-  EXPECT_EQ("a/c.h", FileToReplaces.begin()->first);
+  EXPECT_EQ("./a/b/c.h", FileToReplaces.begin()->first);
 #else
-  EXPECT_EQ("a\\c.h", FileToReplaces.begin()->first);
+  EXPECT_EQ(".\\a\\b\\c.h", FileToReplaces.begin()->first);
 #endif
 }
 
Index: lib/Tooling/Refactoring.cpp
===
--- lib/Tooling/Refactoring.cpp
+++ lib/Tooling/Refactoring.cpp
@@ -57,7 +57,8 @@
 
 bool RefactoringTool::applyAllReplacements(Rewriter ) {
   bool Result = true;
-  for (const auto  : groupReplacementsByFile(FileToReplaces))
+  for (const auto  : groupReplacementsByFile(
+   Rewrite.getSourceMgr().getFileManager(), FileToReplaces))
 Result = tooling::applyAllReplacements(Entry.second, Rewrite) && Result;
   return Result;
 }
@@ -73,7 +74,8 @@
   FileManager  = SM.getFileManager();
 
   bool Result = true;
-  for (const auto  : groupReplacementsByFile(FileToReplaces)) {
+  for (const auto  : groupReplacementsByFile(
+   Rewrite.getSourceMgr().getFileManager(), FileToReplaces)) {
 const std::string  = FileAndReplaces.first;
 auto  = FileAndReplaces.second;
 
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -20,6 +20,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
@@ -566,13 +567,13 @@
 }
 
 std::map groupReplacementsByFile(
+FileManager ,
 const std::map ) {
   std::map Result;
-  for (const auto  : FileToReplaces) {
-llvm::SmallString<256> CleanPath(Entry.first.data());
-llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
-Result[CleanPath.str()] = std::move(Entry.second);
-  }
+  llvm::SmallPtrSet ProcessedFileEntries;
+  for (const auto  : FileToReplaces)
+if (ProcessedFileEntries.insert(FileMgr.getFile(Entry.first)).second)
+  Result[Entry.first] = std::move(Entry.second);
   return Result;
 }
 
Index: include/clang/Tooling/Core/Replacement.h
===
--- include/clang/Tooling/Core/Replacement.h
+++ include/clang/Tooling/Core/Replacement.h
@@ -19,6 +19,7 @@
 #ifndef LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
 #define LLVM_CLANG_TOOLING_CORE_REPLACEMENT_H
 

[PATCH] D26288: Deduplicate replacements by FileEntry instead of file names.

2016-11-03 Thread Alexander Shaposhnikov via cfe-commits
alexshap added inline comments.



Comment at: lib/Tooling/Core/Replacement.cpp:578
+  continue;
+ProcessedFileEntries.insert(FE);
+Result[Entry.first] = std::move(Entry.second);

(saves 2 lines of code) (although not particularly important) 
  if (ProcessedFileEntries.insert(FE).second)
 Result[Entry.first] = std::move(Entry.second);


https://reviews.llvm.org/D26288



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


[PATCH] D24969: [Sema] Use the instantiated name of destructors in FindInstantiatedDecl and RebuildMemberExpr

2016-11-03 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 76883.
ahatanak added a comment.

Rebase. Pass the destructor's DeclarationNameInfo to the call to 
RebuildMemberExpr rather than getting it inside RebuildMemberExpr.


https://reviews.llvm.org/D24969

Files:
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/destructor.cpp


Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -431,3 +431,23 @@
 
 // The constructor definition should not have errors
 Invalid::~Invalid() {}
+
+namespace PR30361 {
+template 
+struct C1 {
+  ~C1() {}
+  operator C1* () { return nullptr; }
+  void foo1();
+};
+
+template
+void C1::foo1() {
+  C1::operator C1*();
+  C1::~C1();
+}
+
+void foo1() {
+  C1 x;
+  x.foo1();
+}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -8723,11 +8723,16 @@
   // nested-name-qualifier (and therefore could do the lookup).
   NamedDecl *FirstQualifierInScope = nullptr;
 
+  DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
+
+  if (isa(FoundDecl))
+MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
+
   return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
 E->isArrow(),
 QualifierLoc,
 TemplateKWLoc,
-E->getMemberNameInfo(),
+MemberNameInfo,
 Member,
 FoundDecl,
 (E->hasExplicitTemplateArgs()
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4842,7 +4842,11 @@
 
 NamedDecl *Result = nullptr;
 if (D->getDeclName()) {
-  DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName());
+  DeclarationName Name = D->getDeclName();
+  if (auto *DD = dyn_cast(D))
+Name =
+SubstDeclarationNameInfo(DD->getNameInfo(), 
TemplateArgs).getName();
+  DeclContext::lookup_result Found = ParentDC->lookup(Name);
   Result = findInstantiationOf(Context, D, Found.begin(), Found.end());
 } else {
   // Since we don't have a name for the entity we're looking for,


Index: test/SemaCXX/destructor.cpp
===
--- test/SemaCXX/destructor.cpp
+++ test/SemaCXX/destructor.cpp
@@ -431,3 +431,23 @@
 
 // The constructor definition should not have errors
 Invalid::~Invalid() {}
+
+namespace PR30361 {
+template 
+struct C1 {
+  ~C1() {}
+  operator C1* () { return nullptr; }
+  void foo1();
+};
+
+template
+void C1::foo1() {
+  C1::operator C1*();
+  C1::~C1();
+}
+
+void foo1() {
+  C1 x;
+  x.foo1();
+}
+}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -8723,11 +8723,16 @@
   // nested-name-qualifier (and therefore could do the lookup).
   NamedDecl *FirstQualifierInScope = nullptr;
 
+  DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
+
+  if (isa(FoundDecl))
+MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
+
   return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
 E->isArrow(),
 QualifierLoc,
 TemplateKWLoc,
-E->getMemberNameInfo(),
+MemberNameInfo,
 Member,
 FoundDecl,
 (E->hasExplicitTemplateArgs()
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4842,7 +4842,11 @@
 
 NamedDecl *Result = nullptr;
 if (D->getDeclName()) {
-  DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName());
+  DeclarationName Name = D->getDeclName();
+  if (auto *DD = dyn_cast(D))
+Name =
+SubstDeclarationNameInfo(DD->getNameInfo(), TemplateArgs).getName();
+  DeclContext::lookup_result Found = ParentDC->lookup(Name);
   Result = findInstantiationOf(Context, D, Found.begin(), Found.end());
 } else {
   // Since we don't have a name for the entity we're looking for,
___
cfe-commits mailing list

[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-03 Thread Pekka Jääskeläinen via cfe-commits
pekka.jaaskelainen added a comment.

Indeed, it requires wider scale discussion to get it right, and e.g. to pass 
the info to AA. But to be honest, I think OpenCL and CUDA are still considered 
'minority' languages in Clang/LLVM which makes me usually lean towards least 
intrusive implementation solutions whenever possible.

The matter was discussed 5 years ago: 
http://clang-developers.42468.n3.nabble.com/OpenCL-Address-Spaces-and-Runtimes-td2814865.html

The current situation of having the target AS in the MD is clearly not the way 
to go due to the loss of info for flat AS machines, so I think this discussion 
should be mostly about what should those designated IDs be.

Sure, we could use strings such as "opencl.global" there instead, but I'm not 
sure how much that adds value to simply having known integer IDs instead. SPIR 
1.2-2.0 is based on LLVM and designed to store info of OpenCL C kernels, 
therefore I thought the SPIR IDs are logical as we can just refer to SPIR specs 
in this case. Other alternative might be to retain the Clang's logical IDs, but 
I recall there was some special semantics/handling for AS IDs > 255. I might be 
wrong though.


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


r285960 - Add debug info support for C++11 inline namespaces.

2016-11-03 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Thu Nov  3 14:42:14 2016
New Revision: 285960

URL: http://llvm.org/viewvc/llvm-project?rev=285960=rev
Log:
Add debug info support for C++11 inline namespaces.



Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=285960=285959=285960=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Nov  3 14:42:14 2016
@@ -3848,8 +3848,8 @@ CGDebugInfo::getOrCreateNameSpace(const
   unsigned LineNo = getLineNumber(NSDecl->getLocation());
   llvm::DIFile *FileD = getOrCreateFile(NSDecl->getLocation());
   llvm::DIScope *Context = getDeclContextDescriptor(NSDecl);
-  llvm::DINamespace *NS =
-  DBuilder.createNameSpace(Context, NSDecl->getName(), FileD, LineNo);
+  llvm::DINamespace *NS = DBuilder.createNameSpace(
+  Context, NSDecl->getName(), FileD, LineNo, NSDecl->isInline());
   NameSpaceCache[NSDecl].reset(NS);
   return NS;
 }

Modified: cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp?rev=285960=285959=285960=diff
==
--- cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-namespace.cpp Thu Nov  3 14:42:14 2016
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -debug-info-kind=limited -S -emit-llvm %s -o - | FileCheck 
%s
-// RUN: %clang_cc1 -debug-info-kind=line-tables-only -S -emit-llvm %s -o - | 
FileCheck -check-prefix=CHECK-GMLT %s
-// RUN: %clang_cc1 -debug-info-kind=standalone -S -emit-llvm %s -o - | 
FileCheck -check-prefix=CHECK-NOLIMIT %s
+// RUN: %clang_cc1 -std=c++11 -debug-info-kind=limited -S -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -debug-info-kind=line-tables-only -S -emit-llvm 
%s -o - | FileCheck -check-prefix=CHECK-GMLT %s
+// RUN: %clang_cc1 -std=c++11 -debug-info-kind=standalone -S -emit-llvm %s -o 
- | FileCheck -check-prefix=CHECK-NOLIMIT %s
 
 namespace A {
 #line 1 "foo.cpp"
@@ -49,6 +49,9 @@ using B::i;
 namespace B {
 int var_fwd = i;
 }
+inline namespace I {
+int var_i;
+}
 }
 void B::func_fwd() {}
 
@@ -63,6 +66,8 @@ void B::func_fwd() {}
 // CHECK: [[VAR_FWD:![0-9]+]] = distinct !DIGlobalVariable(name: 
"var_fwd",{{.*}} scope: [[NS]],
 // CHECK-SAME: line: 44
 // CHECK-SAME: isDefinition: true
+// CHECK: distinct !DIGlobalVariable(name: "var_i",{{.*}} scope: 
[[INLINE:![0-9]+]],
+// CHECK: [[INLINE]] = !DINamespace(name: "I", scope: [[CTXT]], file: 
[[FOOCPP]], line: 46, exportSymbols: true)
 // CHECK: [[CU:![0-9]+]] = distinct !DICompileUnit(
 // CHECK-SAME:imports: [[MODULES:![0-9]*]]
 // CHECK: [[MODULES]] = !{[[M1:![0-9]+]], [[M2:![0-9]+]], [[M3:![0-9]+]], 
[[M4:![0-9]+]], [[M5:![0-9]+]], [[M6:![0-9]+]], [[M7:![0-9]+]], [[M8:![0-9]+]], 
[[M9:![0-9]+]], [[M10:![0-9]+]], [[M11:![0-9]+]], [[M12:![0-9]+]], 
[[M13:![0-9]+]], [[M14:![0-9]+]], [[M15:![0-9]+]], [[M16:![0-9]+]], 
[[M17:![0-9]+]]}
@@ -101,7 +106,7 @@ void B::func_fwd() {}
 // CHECK-SAME:  scope: [[NS]], file: [[FOOCPP]], line: 
9
 // CHECK: [[M15]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: 
[[FUNC]], entity: [[VAR_FWD:![0-9]+]]
 // CHECK: [[M16]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: 
[[FUNC]], entity: [[FUNC_FWD:![0-9]+]]
-// CHECK: [[FUNC_FWD]] = distinct !DISubprogram(name: "func_fwd",{{.*}} line: 
47,{{.*}} isDefinition: true
+// CHECK: [[FUNC_FWD]] = distinct !DISubprogram(name: "func_fwd",{{.*}} line: 
50,{{.*}} isDefinition: true
 // CHECK: [[M17]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: 
[[CTXT]], entity: [[I]]
 
 // CHECK-GMLT: [[CU:![0-9]+]] = distinct !DICompileUnit(


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


[PATCH] D26288: Deduplicate replacements by FileEntry instead of file names.

2016-11-03 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: djasper.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

The current version does not deduplicate equivalent file paths correctly.
For example, a relative path and an absolute path are considered inequivalent.
Comparing FileEnry addresses these issues.


https://reviews.llvm.org/D26288

Files:
  include/clang/Tooling/Core/Replacement.h
  lib/Tooling/Core/Replacement.cpp
  lib/Tooling/Refactoring.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -972,39 +972,41 @@
   toReplacements({{"", 0, 3, "cc"}, {"", 3, 3, "dd"}}));
 }
 
-TEST(DeduplicateByFileTest, LeaveLeadingDotDot) {
+TEST(DeduplicateByFileTest, PathsWithDots) {
   std::map FileToReplaces;
+  FileManager *FileMgr = new FileManager(FileSystemOptions());
 #if !defined(LLVM_ON_WIN32)
   FileToReplaces["../../a/b/.././c.h"] = Replacements();
   FileToReplaces["../../a/c.h"] = Replacements();
 #else
   FileToReplaces["..\\..\\a\\b\\..\\.\\c.h"] = Replacements();
   FileToReplaces["..\\..\\a\\c.h"] = Replacements();
 #endif
-  FileToReplaces = groupReplacementsByFile(FileToReplaces);
+  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
   EXPECT_EQ(1u, FileToReplaces.size());
 #if !defined(LLVM_ON_WIN32)
-  EXPECT_EQ("../../a/c.h", FileToReplaces.begin()->first);
+  EXPECT_EQ("../../a/b/.././c.h", FileToReplaces.begin()->first);
 #else
-  EXPECT_EQ("..\\..\\a\\c.h", FileToReplaces.begin()->first);
+  EXPECT_EQ("..\\..\\a\\b\\..\\.\\c.h", FileToReplaces.begin()->first);
 #endif
 }
 
-TEST(DeduplicateByFileTest, RemoveDotSlash) {
+TEST(DeduplicateByFileTest, PathWithDotSlash) {
   std::map FileToReplaces;
+  FileManager *FileMgr = new FileManager(FileSystemOptions());
 #if !defined(LLVM_ON_WIN32)
-  FileToReplaces["./a/b/.././c.h"] = Replacements();
-  FileToReplaces["a/c.h"] = Replacements();
+  FileToReplaces["./a/b/c.h"] = Replacements();
+  FileToReplaces["a/b/c.h"] = Replacements();
 #else
-  FileToReplaces[".\\a\\b\\..\\.\\c.h"] = Replacements();
-  FileToReplaces["a\\c.h"] = Replacements();
+  FileToReplaces[".\\a\\b\\c.h"] = Replacements();
+  FileToReplaces["a\\b\\c.h"] = Replacements();
 #endif
-  FileToReplaces = groupReplacementsByFile(FileToReplaces);
+  FileToReplaces = groupReplacementsByFile(*FileMgr, FileToReplaces);
   EXPECT_EQ(1u, FileToReplaces.size());
 #if !defined(LLVM_ON_WIN32)
-  EXPECT_EQ("a/c.h", FileToReplaces.begin()->first);
+  EXPECT_EQ("./a/b/c.h", FileToReplaces.begin()->first);
 #else
-  EXPECT_EQ("a\\c.h", FileToReplaces.begin()->first);
+  EXPECT_EQ(".\\a\\b\\c.h", FileToReplaces.begin()->first);
 #endif
 }
 
Index: lib/Tooling/Refactoring.cpp
===
--- lib/Tooling/Refactoring.cpp
+++ lib/Tooling/Refactoring.cpp
@@ -57,7 +57,8 @@
 
 bool RefactoringTool::applyAllReplacements(Rewriter ) {
   bool Result = true;
-  for (const auto  : groupReplacementsByFile(FileToReplaces))
+  for (const auto  : groupReplacementsByFile(
+   Rewrite.getSourceMgr().getFileManager(), FileToReplaces))
 Result = tooling::applyAllReplacements(Entry.second, Rewrite) && Result;
   return Result;
 }
@@ -73,7 +74,8 @@
   FileManager  = SM.getFileManager();
 
   bool Result = true;
-  for (const auto  : groupReplacementsByFile(FileToReplaces)) {
+  for (const auto  : groupReplacementsByFile(
+   Rewrite.getSourceMgr().getFileManager(), FileToReplaces)) {
 const std::string  = FileAndReplaces.first;
 auto  = FileAndReplaces.second;
 
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -20,6 +20,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
@@ -566,12 +567,16 @@
 }
 
 std::map groupReplacementsByFile(
+FileManager ,
 const std::map ) {
   std::map Result;
+  llvm::SmallPtrSet ProcessedFileEntries;
   for (const auto  : FileToReplaces) {
-llvm::SmallString<256> CleanPath(Entry.first.data());
-llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
-Result[CleanPath.str()] = std::move(Entry.second);
+const FileEntry *FE = FileMgr.getFile(Entry.first);
+if (ProcessedFileEntries.count(FE) != 0)
+  continue;
+ProcessedFileEntries.insert(FE);
+Result[Entry.first] = std::move(Entry.second);
   }
   return Result;
 }
Index: 

[PATCH] D26286: [Sparc]: correct the ATOMIC_LLONG_LOCK_FREE macro

2016-11-03 Thread Douglas Katzman via cfe-commits
dougk updated this revision to Diff 76879.
dougk added a comment.

fix atomics-inlining test


https://reviews.llvm.org/D26286

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/atomics-inlining.c
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -6913,6 +6913,7 @@
 // SPARC:#define __FLT_MIN_EXP__ (-125)
 // SPARC:#define __FLT_MIN__ 1.17549435e-38F
 // SPARC:#define __FLT_RADIX__ 2
+// SPARC:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
 // SPARC:#define __INT16_C_SUFFIX__
 // SPARC:#define __INT16_FMTd__ "hd"
 // SPARC:#define __INT16_FMTi__ "hi"
Index: test/CodeGen/atomics-inlining.c
===
--- test/CodeGen/atomics-inlining.c
+++ test/CodeGen/atomics-inlining.c
@@ -3,7 +3,8 @@
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm %s -o - | FileCheck 
%s -check-prefix=PPC64
 // RUN: %clang_cc1 -triple mipsel-linux-gnu -emit-llvm %s -o - | FileCheck %s 
-check-prefix=MIPS32
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -emit-llvm %s -o - | FileCheck 
%s -check-prefix=MIPS64
-// RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck 
%s -check-prefix=SPARC
+// RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck 
%s -check-prefix=SPARCV8 -check-prefix=SPARC
+// RUN: %clang_cc1 -triple sparcv9-unknown-eabi -emit-llvm %s -o - | FileCheck 
%s -check-prefix=SPARCV9 -check-prefix=SPARC
 
 unsigned char c1, c2;
 unsigned short s1, s2;
@@ -99,8 +100,10 @@
 // SPARC: store atomic i16 {{.*}}, i16* @s1 seq_cst
 // SPARC: = load atomic i32, i32* @i1 seq_cst
 // SPARC: store atomic i32 {{.*}}, i32* @i1 seq_cst
-// SPARC: = load atomic i64, i64* @ll1 seq_cst
-// SPARC: store atomic i64 {{.*}}, i64* @ll1 seq_cst
-// SPARC: call void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 x 
i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], 
[100 x i8]* @a2, i32 0, i32 0)
-// SPARC: call void @__atomic_store(i32 100, i8* getelementptr inbounds ([100 
x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], 
[100 x i8]* @a2, i32 0, i32 0)
+// SPARCV8: call i64 @__atomic_load_8(i8* bitcast (i64* @ll1 to i8*)
+// SPARCV8: call void @__atomic_store_8(i8* bitcast (i64* @ll1 to i8*), i64
+// SPARCV9: load atomic i64, i64* @ll1 seq_cst, align 8
+// SPARCV9: store atomic i64 %7, i64* @ll1 seq_cst, align 8
+// SPARCV8: call void @__atomic_load(i32 100, i8* getelementptr inbounds ([100 
x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x i8], 
[100 x i8]* @a2, i32 0, i32 0)
+// SPARCV8: call void @__atomic_store(i32 100, i8* getelementptr inbounds 
([100 x i8], [100 x i8]* @a1, i32 0, i32 0), i8* getelementptr inbounds ([100 x 
i8], [100 x i8]* @a2, i32 0, i32 0)
 }
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6797,7 +6797,10 @@
   PtrDiffType = SignedLong;
   break;
 }
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+// Up to 32 bits are lock-free atomic, but we're willing to do atomic ops
+// on up to 64 bits.
+MaxAtomicPromoteWidth = 64;
+MaxAtomicInlineWidth = 32;
   }
 
   void getTargetDefines(const LangOptions ,


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -6913,6 +6913,7 @@
 // SPARC:#define __FLT_MIN_EXP__ (-125)
 // SPARC:#define __FLT_MIN__ 1.17549435e-38F
 // SPARC:#define __FLT_RADIX__ 2
+// SPARC:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
 // SPARC:#define __INT16_C_SUFFIX__
 // SPARC:#define __INT16_FMTd__ "hd"
 // SPARC:#define __INT16_FMTi__ "hi"
Index: test/CodeGen/atomics-inlining.c
===
--- test/CodeGen/atomics-inlining.c
+++ test/CodeGen/atomics-inlining.c
@@ -3,7 +3,8 @@
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=PPC64
 // RUN: %clang_cc1 -triple mipsel-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS32
 // RUN: %clang_cc1 -triple mips64el-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=MIPS64
-// RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARC
+// RUN: %clang_cc1 -triple sparc-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARCV8 -check-prefix=SPARC
+// RUN: %clang_cc1 -triple sparcv9-unknown-eabi -emit-llvm %s -o - | FileCheck %s -check-prefix=SPARCV9 -check-prefix=SPARC
 
 unsigned char c1, c2;
 unsigned short s1, s2;
@@ -99,8 +100,10 @@
 // SPARC: store atomic i16 {{.*}}, i16* @s1 seq_cst
 // SPARC: = load atomic i32, i32* @i1 seq_cst
 // SPARC: store atomic i32 {{.*}}, i32* @i1 seq_cst
-// SPARC: = load atomic i64, i64* @ll1 seq_cst
-// SPARC: 

[PATCH] D26207: [ClangTidy - performance-unnecessary-value-param] Only add "const" when current parameter is not already const qualified

2016-11-03 Thread Felix Berger via cfe-commits
flx removed rL LLVM as the repository for this revision.
flx updated this revision to Diff 76877.

https://reviews.llvm.org/D26207

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  test/clang-tidy/performance-unnecessary-value-param.cpp


Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -237,3 +237,19 @@
   ExpensiveToCopyType B;
   B = A;
 }
+
+// Case where parameter in declaration is already const-qualified but not in
+// implementation. Make sure a second 'const' is not added to the declaration.
+void PositiveConstDeclaration(const ExpensiveToCopyType A);
+// CHECK-FIXES: void PositiveConstDeclaration(const ExpensiveToCopyType& A);
+void PositiveConstDeclaration(ExpensiveToCopyType A) {
+  // CHECK-MESSAGES: [[@LINE-1]]:51: warning: the parameter 'A' is copied
+  // CHECK-FIXES: void PositiveConstDeclaration(const ExpensiveToCopyType& A) {
+}
+
+void PositiveNonConstDeclaration(ExpensiveToCopyType A);
+// CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& A);
+void PositiveNonConstDeclaration(const ExpensiveToCopyType A) {
+  // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the const qualified parameter 'A'
+  // CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& 
A) {
+}
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -128,7 +128,10 @@
 const auto  = *FunctionDecl->getParamDecl(Index);
 Diag << utils::fixit::changeVarDeclToReference(CurrentParam,
*Result.Context);
-if (!IsConstQualified)
+// The parameter of each declaration needs to be checked individually as to
+// whether it is const or not as constness can differ between definition 
and
+// declaration.
+if (!CurrentParam.getType().getCanonicalType().isConstQualified())
   Diag << utils::fixit::changeVarDeclToConst(CurrentParam);
   }
 }


Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -237,3 +237,19 @@
   ExpensiveToCopyType B;
   B = A;
 }
+
+// Case where parameter in declaration is already const-qualified but not in
+// implementation. Make sure a second 'const' is not added to the declaration.
+void PositiveConstDeclaration(const ExpensiveToCopyType A);
+// CHECK-FIXES: void PositiveConstDeclaration(const ExpensiveToCopyType& A);
+void PositiveConstDeclaration(ExpensiveToCopyType A) {
+  // CHECK-MESSAGES: [[@LINE-1]]:51: warning: the parameter 'A' is copied
+  // CHECK-FIXES: void PositiveConstDeclaration(const ExpensiveToCopyType& A) {
+}
+
+void PositiveNonConstDeclaration(ExpensiveToCopyType A);
+// CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& A);
+void PositiveNonConstDeclaration(const ExpensiveToCopyType A) {
+  // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the const qualified parameter 'A'
+  // CHECK-FIXES: void PositiveNonConstDeclaration(const ExpensiveToCopyType& A) {
+}
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -128,7 +128,10 @@
 const auto  = *FunctionDecl->getParamDecl(Index);
 Diag << utils::fixit::changeVarDeclToReference(CurrentParam,
*Result.Context);
-if (!IsConstQualified)
+// The parameter of each declaration needs to be checked individually as to
+// whether it is const or not as constness can differ between definition and
+// declaration.
+if (!CurrentParam.getType().getCanonicalType().isConstQualified())
   Diag << utils::fixit::changeVarDeclToConst(CurrentParam);
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26207: [ClangTidy - performance-unnecessary-value-param] Only add "const" when current parameter is not already const qualified

2016-11-03 Thread Felix Berger via cfe-commits
flx marked an inline comment as done.
flx added inline comments.



Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:242
+// Case where parameter in declaration is already const-qualified but not in
+// implementation. Make sure a second 'const' is not added to the declaration.
+void PositiveConstDeclaration(const ExpensiveToCopyType A);

aaron.ballman wrote:
> flx wrote:
> > aaron.ballman wrote:
> > > flx wrote:
> > > > aaron.ballman wrote:
> > > > > This comment doesn't really match the test cases. The original code 
> > > > > has two *different* declarations (only one of which is a definition), 
> > > > > not one declaration and one redeclaration with the definition.
> > > > > 
> > > > > I think what is really happening is that it is adding the `&` 
> > > > > qualifier to the first declaration, and adding the `const` and `&` 
> > > > > qualifiers to the second declaration, and the result is that you get 
> > > > > harmonization. But it brings up a question to me; what happens with:
> > > > > ```
> > > > > void f1(ExpensiveToCopyType A) {
> > > > > }
> > > > > 
> > > > > void f1(const ExpensiveToCopyType A) {
> > > > > 
> > > > > }
> > > > > ```
> > > > > Does the fix-it try to create two definitions of the same function?
> > > > Good catch. I added the reverse case as well and modified the check 
> > > > slightly to make that case work as well.
> > > Can you add a test like this as well?
> > > ```
> > > void f1(ExpensiveToCopyType A); // Declared, not defined
> > > 
> > > void f1(const ExpensiveToCopyType A) {}
> > > void f1(const ExpensiveToCopyType ) {}
> > > ```
> > > I'm trying to make sure this check does not suggest a fixit that breaks 
> > > existing code because of overload sets. I would expect a diagnostic for 
> > > the first two declarations, but no fixit suggestion for `void f1(const 
> > > ExpensiveToCopyType A)` because that would result in an ambiguous 
> > > function definition.
> > The current code suggests the following fixes:
> > 
> > -void f1(ExpensiveToCopyType A); // Declared, not defined
> > +void f1(const ExpensiveToCopyType& A); // Declared, not defined
> >  
> > -void f1(const ExpensiveToCopyType A) {}
> > +void f1(const ExpensiveToCopyType& A) {}
> >  void f1(const ExpensiveToCopyType ) {}
> > 
> > and we get a warning message for the void f1(const ExpensiveToCopyType A) {}
> > 
> > I think the compiler sees "void f1(const ExpensiveToCopyType A) {}" as 
> > definition of "void f1(ExpensiveToCopyType A); // Declared, not defined" 
> > and thus both places get fixed.
> > 
> > Since the check is catching cases where the value argument is either 
> > modified or could be moved it and this is not the case here it is worth 
> > raising this issue of what looks like a very subtle difference in overrides.
> > 
> > My inclination is to leave this as is. What do you suggest we do?
> > 
> I think this behavior isn't new with your changes, so we can leave it as is. 
> However, we should file a bug report about the bad behavior with overload 
> sets (and provide the example that's failing) so that we don't forget to come 
> back and fix the functionality.
Filed to track this: https://llvm.org/bugs/show_bug.cgi?id=30902 (


https://reviews.llvm.org/D26207



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


r285954 - Improve obvious-most-derived-type devirtualization:

2016-11-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Nov  3 13:55:18 2016
New Revision: 285954

URL: http://llvm.org/viewvc/llvm-project?rev=285954=rev
Log:
Improve obvious-most-derived-type devirtualization:

  * if the base is produced by a series of derived-to-base conversions, check
the expression inside them when looking for an expression with a known
dynamic type
  * step past MaterializeTemporaryExprs when checking for a known dynamic type
  * when checking for a known dynamic type, treat all class prvalues as having
a known dynamic type after skipping all relevant rvalue subobject
adjustments
  * treat callees formed by pointer-to-member access for a non-reference member
type like callees formed by member access.

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=285954=285953=285954=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Thu Nov  3 13:55:18 2016
@@ -828,6 +828,11 @@ public:
   /// behavior if the object isn't dynamically of the derived type.
   const CXXRecordDecl *getBestDynamicClassType() const;
 
+  /// \brief Get the inner expression that determines the best dynamic class.
+  /// If this is a prvalue, we guarantee that it is of the most-derived type
+  /// for the object itself.
+  const Expr *getBestDynamicClassTypeExpr() const;
+
   /// Walk outwards from an expression we want to bind a reference to and
   /// find the expression whose lifetime needs to be extended. Record
   /// the LHSs of comma expressions and adjustments needed along the path.

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=285954=285953=285954=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Nov  3 13:55:18 2016
@@ -35,9 +35,33 @@
 #include 
 using namespace clang;
 
-const CXXRecordDecl *Expr::getBestDynamicClassType() const {
-  const Expr *E = ignoreParenBaseCasts();
+const Expr *Expr::getBestDynamicClassTypeExpr() const {
+  const Expr *E = this;
+  while (true) {
+E = E->ignoreParenBaseCasts();
+
+// Follow the RHS of a comma operator.
+if (auto *BO = dyn_cast(E)) {
+  if (BO->getOpcode() == BO_Comma) {
+E = BO->getRHS();
+continue;
+  }
+}
+
+// Step into initializer for materialized temporaries.
+if (auto *MTE = dyn_cast(E)) {
+  E = MTE->GetTemporaryExpr();
+  continue;
+}
 
+break;
+  }
+
+  return E;
+}
+
+const CXXRecordDecl *Expr::getBestDynamicClassType() const {
+  const Expr *E = getBestDynamicClassTypeExpr();
   QualType DerivedType = E->getType();
   if (const PointerType *PTy = DerivedType->getAs())
 DerivedType = PTy->getPointeeType();

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=285954=285953=285954=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Thu Nov  3 13:55:18 2016
@@ -2842,31 +2842,6 @@ llvm::Value *CodeGenFunction::EmitVTable
   cast(VTable->getType())->getElementType());
 }
 
-// FIXME: Ideally Expr::IgnoreParenNoopCasts should do this, but it doesn't do
-// quite what we want.
-static const Expr *skipNoOpCastsAndParens(const Expr *E) {
-  while (true) {
-if (const ParenExpr *PE = dyn_cast(E)) {
-  E = PE->getSubExpr();
-  continue;
-}
-
-if (const CastExpr *CE = dyn_cast(E)) {
-  if (CE->getCastKind() == CK_NoOp) {
-E = CE->getSubExpr();
-continue;
-  }
-}
-if (const UnaryOperator *UO = dyn_cast(E)) {
-  if (UO->getOpcode() == UO_Extension) {
-E = UO->getSubExpr();
-continue;
-  }
-}
-return E;
-  }
-}
-
 bool
 CodeGenFunction::CanDevirtualizeMemberFunctionCall(const Expr *Base,
const CXXMethodDecl *MD) {
@@ -2880,6 +2855,12 @@ CodeGenFunction::CanDevirtualizeMemberFu
   if (MD->hasAttr())
 return true;
 
+  // If the base expression (after skipping derived-to-base conversions) is a
+  // class prvalue, then we can devirtualize.
+  Base = Base->getBestDynamicClassTypeExpr();
+  if (Base->isRValue() && Base->getType()->isRecordType())
+return true;
+
   // If the most derived class is marked final, we know that no subclass can
   // override this member function and so we can devirtualize it. For example:
   //
@@ -2907,7 +2888,6 @@ CodeGenFunction::CanDevirtualizeMemberFu
   if (MD->getParent()->hasAttr())
 return true;

Re: RE: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.

2016-11-03 Thread Samuel F Antao via cfe-commits
This issue should be fixed in r285925.
 
Thanks,
Samuel
 
- Original message -From: "Hahnfeld, Jonas" To: "Hahnfeld, Jonas" , Samuel F Antao/Watson/IBM@IBMUSCc: "cfe-commits@lists.llvm.org" Subject: RE: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.Date: Thu, Nov 3, 2016 12:36 PM 
From C++14:
 
3.4.1 Unqualified name lookup, (1):
“In all the cases listed in 3.4.1, the scopes are searched for a declaration in the order listed in each of the respective categories; name lookup ends as soon as a declaration is found for the name. If no declaration is found, the program is ill-formed.”
 
I assume that “the order listed in each of the respective categories” for method lookup means “from derived to base classes” (though I haven’t looked this up…)
 
 
3.4 Name lookup, (1):
“[…]Only after name lookup, function overload resolution (if applicable) and access checking have succeeded are the attributes introduced by the name’s declaration used further in _expression_ processing (Clause 5). […]”
 
I think this means that the compiler will for example find clang::driver::tools::Clang::ConstructJob but is not allowed to use clang::driver::Tool::ConstructJob as a resolution unless “using Tool::ConstructJob;” is specified.
 
Cheers,
Jonas
 
From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of Hahnfeld, Jonas via cfe-commitsSent: Thursday, November 03, 2016 1:11 PMTo: Samuel F AntaoCc: cfe-commits@lists.llvm.orgSubject: RE: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.
 
Hi Samuel,
 
if we trust StackOverflow, the code is wrong because all functions with the same name are hidden, ignoring the rest of the signature. I will try to find the corresponding section in the C++ standard…
 
I think any version of GCC gives the error, I was able to reproduce this with the attached small code:$ g++ --version
g++ (GCC) 6.2.0
[…]
$ g++ -Woverloaded-virtual virtual-name-hiding.cpp -o virtual-name-hiding.exe
virtual-name-hiding.cpp:2:16: warning: ‘virtual void Base::test(const long int&)’ was hidden [-Woverloaded-virtual]
   virtual void test(const long );
    ^~~~
virtual-name-hiding.cpp:7:16: warning:   by ‘virtual void Child::test(const int&)’ [-Woverloaded-virtual]
   virtual void test(const int ) override { };
    ^~~~
 
Regards,
Jonas
 
From: Samuel F Antao [mailto:sfan...@us.ibm.com]Sent: Thursday, November 03, 2016 1:04 PMTo: Hahnfeld, JonasCc: cfe-commits@lists.llvm.org; gkistan...@gmail.comSubject: Re: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.
 
Hi Jonas,
 
I think that the code is correct. Is probably some bug in the compiler. We are not hiding anything - the compiler is checking against the wrong virtual function (using the wrong signature).
 
I am in process to compile the same version of gcc the bot is using to see if there is any massagin in the code that can be done to silence that.
 
Thanks!
Samuel
 
- Original message -From: "Hahnfeld, Jonas" To: Galina Kistanova , Samuel F Antao/Watson/IBM@IBMUSCc: "cfe-commits@lists.llvm.org" Subject: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.Date: Thu, Nov 3, 2016 11:53 AM 
Hi,
 
I think I have identified what is the problem here: the so-called “name hiding” when overloading virtual functions. (see http://stackoverflow.com/a/1629074)
To fix it, I see two possible solutions: Either apply the attached patch or rename one method so that the hiding does not happen.
 
Finally: Why didn’t the other bots point to this problem?!?
 
Cheers,
Jonas
 
From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of Galina Kistanova via cfe-commitsSent: Tuesday, November 01, 2016 7:29 PMTo: Samuel F AntaoCc: cfe-commitsSubject: Re: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.
 
http://lab.llvm.org:8011/builders/clang-3stage-ubuntu/builds/128/steps/cmake-configure/logs/stdio-- The C compiler identification is GNU 4.8.4-- The CXX compiler identification is GNU 4.8.4The code itself seems fine. The similar builder that uses the ToT Clang does not generate any warnings.http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/107​ThanksGalina
 
On Mon, Oct 31, 2016 at 6:26 PM, Samuel F Antao  wrote:
Hi Galina,
 
Thanks for letting me know. Can you tell me which compiler (kind and version) is used in the buildbot slave? Looks like that compiler is not doing what it should, so I need to be able to test a workaround.
 
We have  
 
virtual void ConstructJob(Compilation , const JobAction ,                            const InputInfo ,                            const InputInfoList ,                            const llvm::opt::ArgList ,                            const 

[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-11-03 Thread Joerg Sonnenberger via cfe-commits
joerg added a comment.

It works for me with the mentioned TODO item. But I'm not the right one to give 
a full OK.


https://reviews.llvm.org/D23657



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


r285950 - Instead of resetting the pointer, or releasing it which was the previous

2016-11-03 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Thu Nov  3 13:03:14 2016
New Revision: 285950

URL: http://llvm.org/viewvc/llvm-project?rev=285950=rev
Log:
Instead of resetting the pointer, or releasing it which was the previous
code, let's just assert that the DiagonsticEngine doesn't own the client
because our constructor took ownership of it and has a std::unique_ptr
that handles deleting it. This seems much more clear -- the release was
harmless but confusing as if there were some memory there it would have
leaked, and the reset was harmless but confusing as if there were some
memory there it would have been double-freed. But in both cases there
was nothing there.

Modified:
cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp

Modified: cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp?rev=285950=285949=285950=diff
==
--- cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp (original)
+++ cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp Thu Nov  3 13:03:14 2016
@@ -43,7 +43,8 @@ VerifyDiagnosticConsumer::~VerifyDiagnos
   assert(!CurrentPreprocessor && "CurrentPreprocessor should be invalid!");
   SrcManager = nullptr;
   CheckDiagnostics();
-  Diags.takeClient().reset();
+  assert(!Diags.ownsClient() &&
+ "The VerifyDiagnosticConsumer takes over ownership of the client!");
 }
 
 #ifndef NDEBUG


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


[PATCH] D26286: [Sparc]: correct the ATOMIC_LLONG_LOCK_FREE macro

2016-11-03 Thread Douglas Katzman via cfe-commits
dougk created this revision.
dougk added a reviewer: jyknight.
dougk added a subscriber: cfe-commits.

https://reviews.llvm.org/D26286

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -6913,6 +6913,7 @@
 // SPARC:#define __FLT_MIN_EXP__ (-125)
 // SPARC:#define __FLT_MIN__ 1.17549435e-38F
 // SPARC:#define __FLT_RADIX__ 2
+// SPARC:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
 // SPARC:#define __INT16_C_SUFFIX__
 // SPARC:#define __INT16_FMTd__ "hd"
 // SPARC:#define __INT16_FMTi__ "hi"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6797,7 +6797,10 @@
   PtrDiffType = SignedLong;
   break;
 }
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+// Up to 32 bits are lock-free atomic, but we're willing to do atomic ops
+// on up to 64 bits.
+MaxAtomicPromoteWidth = 64;
+MaxAtomicInlineWidth = 32;
   }
 
   void getTargetDefines(const LangOptions ,


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -6913,6 +6913,7 @@
 // SPARC:#define __FLT_MIN_EXP__ (-125)
 // SPARC:#define __FLT_MIN__ 1.17549435e-38F
 // SPARC:#define __FLT_RADIX__ 2
+// SPARC:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
 // SPARC:#define __INT16_C_SUFFIX__
 // SPARC:#define __INT16_FMTd__ "hd"
 // SPARC:#define __INT16_FMTi__ "hi"
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6797,7 +6797,10 @@
   PtrDiffType = SignedLong;
   break;
 }
-MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
+// Up to 32 bits are lock-free atomic, but we're willing to do atomic ops
+// on up to 64 bits.
+MaxAtomicPromoteWidth = 64;
+MaxAtomicInlineWidth = 32;
   }
 
   void getTargetDefines(const LangOptions ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285946 - Using release to free memory is at best confusing -- one would expect

2016-11-03 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Thu Nov  3 12:42:32 2016
New Revision: 285946

URL: http://llvm.org/viewvc/llvm-project?rev=285946=rev
Log:
Using release to free memory is at best confusing -- one would expect
that its result is in fact used. Instead, use reset.

This was pointed out by PVS-Studio.

Modified:
cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp

Modified: cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp?rev=285946=285945=285946=diff
==
--- cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp (original)
+++ cfe/trunk/lib/Frontend/VerifyDiagnosticConsumer.cpp Thu Nov  3 12:42:32 2016
@@ -43,7 +43,7 @@ VerifyDiagnosticConsumer::~VerifyDiagnos
   assert(!CurrentPreprocessor && "CurrentPreprocessor should be invalid!");
   SrcManager = nullptr;
   CheckDiagnostics();
-  Diags.takeClient().release();
+  Diags.takeClient().reset();
 }
 
 #ifndef NDEBUG


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


[PATCH] D23657: Remove some false positives when taking the address of packed members

2016-11-03 Thread Roger Ferrer Ibanez via cfe-commits
rogfer01 added a comment.

Ping? :)


https://reviews.llvm.org/D23657



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


[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-03 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

I am wondering whether returning the strings with source level information 
would be an option instead? But yes this MD are OpenCL specific indeed. I am 
just not sure whether putting hard-coded arbitrary numbers would not cause any 
confusions in the future. I feel that entire problem is that documentation is 
missing about such important  aspects which opens rooms for multiple 
interpretations.


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


[PATCH] D26285: [index] Expose FriendDecl

2016-11-03 Thread Olivier Goffart via cfe-commits
ogoffart created this revision.
ogoffart added reviewers: cfe-commits, alexey.klimov.dev, bkramer.

I need to be able to visit friend declarations (the function) for the clang 
based qdoc (documentation parser).

This also fix KDevelop not highlighting friend declarations. (Espetialy 
ennoying when declaring an operator with a body)


https://reviews.llvm.org/D26285

Files:
  include/clang-c/Index.h
  lib/Sema/SemaCodeComplete.cpp
  test/Index/load-classes.cpp
  tools/libclang/CIndex.cpp
  tools/libclang/CursorVisitor.h

Index: tools/libclang/CursorVisitor.h
===
--- tools/libclang/CursorVisitor.h
+++ tools/libclang/CursorVisitor.h
@@ -239,7 +239,8 @@
   bool VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D);
   bool VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D);
   bool VisitStaticAssertDecl(StaticAssertDecl *D);
-  
+  bool VisitFriendDecl(FriendDecl *D);
+
   // Name visitor
   bool VisitDeclarationNameInfo(DeclarationNameInfo Name);
   bool VisitNestedNameSpecifier(NestedNameSpecifier *NNS, SourceRange Range);
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1249,6 +1249,17 @@
   return false;
 }
 
+bool CursorVisitor::VisitFriendDecl(FriendDecl *D) {
+  if (NamedDecl *FriendD = D->getFriendDecl()) {
+if (Visit(MakeCXCursor(FriendD, TU, RegionOfInterest)))
+  return true;
+  } else if (TypeSourceInfo *TI = D->getFriendType()) {
+if (Visit(TI->getTypeLoc()))
+  return true;
+  }
+  return false;
+}
+
 bool CursorVisitor::VisitDeclarationNameInfo(DeclarationNameInfo Name) {
   switch (Name.getName().getNameKind()) {
   case clang::DeclarationName::Identifier:
@@ -4923,6 +4934,8 @@
   return cxstring::createRef("TypeAliasTemplateDecl");
   case CXCursor_StaticAssert:
   return cxstring::createRef("StaticAssert");
+  case CXCursor_FriendDecl:
+return cxstring::createRef("FriendDecl");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");
Index: test/Index/load-classes.cpp
===
--- test/Index/load-classes.cpp
+++ test/Index/load-classes.cpp
@@ -18,13 +18,18 @@
 
   virtual void virtualMemberFunction();
   virtual void pureVirtualMemberFunction() = 0;
+
+  friend void friendFunction();
+  template 
+  friend void friendFunctionTemplate();
+  friend class F;
 };
 
 X::X(int value) {
 }
 
 // RUN: c-index-test -test-load-source all %s | FileCheck %s
-// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) Extent=[3:1 - 21:2]
+// CHECK: load-classes.cpp:3:8: StructDecl=X:3:8 (Definition) Extent=[3:1 - 26:2]
 // CHECK: load-classes.cpp:4:3: CXXConstructor=X:4:3 (converting constructor) Extent=[4:3 - 4:15] [access=public]
 // FIXME: missing TypeRef in the constructor name
 // CHECK: load-classes.cpp:4:9: ParmDecl=value:4:9 (Definition) Extent=[4:5 - 4:14]
@@ -46,7 +51,14 @@
 // CHECK: load-classes.cpp:16:21: TemplateTypeParameter=T:16:21 (Definition) Extent=[16:12 - 16:22] [access=public]
 // CHECK: load-classes.cpp:19:16: CXXMethod=virtualMemberFunction:19:16 (virtual) Extent=[19:3 - 19:39] [access=private]
 // CHECK: load-classes.cpp:20:16: CXXMethod=pureVirtualMemberFunction:20:16 (virtual) (pure) Extent=[20:3 - 20:47] [access=private]
-// CHECK: load-classes.cpp:23:4: CXXConstructor=X:23:4 (Definition) (converting constructor) Extent=[23:1 - 24:2] [access=public]
-// CHECK: load-classes.cpp:23:1: TypeRef=struct X:3:8 Extent=[23:1 - 23:2]
-// CHECK: load-classes.cpp:23:10: ParmDecl=value:23:10 (Definition) Extent=[23:6 - 23:15]
-// CHECK: load-classes.cpp:23:17: CompoundStmt= Extent=[23:17 - 24:2]
+// CHECK: load-classes.cpp:22:15: FriendDecl=:22:15 Extent=[22:3 - 22:31] [access=public]
+// CHECK: load-classes.cpp:22:15: FunctionDecl=friendFunction:22:15 Extent=[22:3 - 22:31] [access=public]
+// CHECK: load-classes.cpp:24:15: FriendDecl=:24:15 Extent=[23:3 - 24:39] [access=public]
+// CHECK: load-classes.cpp:24:15: FunctionTemplate=friendFunctionTemplate:24:15 Extent=[23:3 - 24:39] [access=public]
+// CHECK: load-classes.cpp:23:22: TemplateTypeParameter=T:23:22 (Definition) Extent=[23:13 - 23:23] [access=public]
+// CHECK: load-classes.cpp:25:10: FriendDecl=:25:10 Extent=[25:3 - 25:17] [access=public]
+// CHECK: load-classes.cpp:25:16: TypeRef=class F:25:16 Extent=[25:16 - 25:17]
+// CHECK: load-classes.cpp:28:4: CXXConstructor=X:28:4 (Definition) (converting constructor) Extent=[28:1 - 29:2] [access=public]
+// CHECK: load-classes.cpp:28:1: TypeRef=struct X:3:8 Extent=[28:1 - 28:2]
+// CHECK: load-classes.cpp:28:10: ParmDecl=value:28:10 (Definition) Extent=[28:6 - 28:15]
+// CHECK: load-classes.cpp:28:17: CompoundStmt= Extent=[28:17 - 29:2]
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp

[PATCH] D26285: [index] Expose FriendDecl

2016-11-03 Thread Olivier Goffart via cfe-commits
ogoffart added a comment.

KDevelop bug report: https://bugs.kde.org/show_bug.cgi?id=360509


https://reviews.llvm.org/D26285



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


[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-03 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

The enum for address space is not necessarily bound to SPIR as long as the 
runtime knows it.

Since most OpenCL runtime already uses that definition (if they use clang as 
compiler), I don't see a reason to change that. I doubt this metadata can be 
used for anything else other than clGetKernelArgInfo, therefore other languages 
most likely do not need it.


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


Re: [PATCH] D26166: [Sema] Don't issue analysis-based warnings when a fatal error has occurred

2016-11-03 Thread Akira Hatanaka via cfe-commits
Thanks, fixed in r285938.

> On Nov 3, 2016, at 8:27 AM, Malcolm Parsons via cfe-commits 
>  wrote:
> 
> malcolm.parsons added inline comments.
> 
> 
> 
> Comment at: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp:213
> +  // Don't allow further instantiation if a fatal error and an uncompilable
> +  // error have occcured. Any diagnostics we might have raised will not be
> +  // visible, and we do not need to construct a correct AST.
> 
> s/occcured/occurred/
> 
> 
> Repository:
>  rL LLVM
> 
> https://reviews.llvm.org/D26166
> 
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


r285938 - Fix spelling mistake.

2016-11-03 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Nov  3 12:11:28 2016
New Revision: 285938

URL: http://llvm.org/viewvc/llvm-project?rev=285938=rev
Log:
Fix spelling mistake.

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=285938=285937=285938=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Thu Nov  3 12:11:28 2016
@@ -210,7 +210,7 @@ Sema::InstantiatingTemplate::Instantiati
 : SemaRef(SemaRef), SavedInNonInstantiationSFINAEContext(
 SemaRef.InNonInstantiationSFINAEContext) {
   // Don't allow further instantiation if a fatal error and an uncompilable
-  // error have occcured. Any diagnostics we might have raised will not be
+  // error have occurred. Any diagnostics we might have raised will not be
   // visible, and we do not need to construct a correct AST.
   if (SemaRef.Diags.hasFatalErrorOccurred() &&
   SemaRef.Diags.hasUncompilableErrorOccurred()) {


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


[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-03 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

In https://reviews.llvm.org/D26157#586764, @yaxunl wrote:

> One purpose of kernel arg info metadata is to be passed to OpenCL runtime to 
> fulfill clGetKernelArgInfo queries. 
> (https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clGetKernelArgInfo.html).
>  As such, the address space id needs to be at source level instead of IR 
> level.


Right, but what do you propose the numbers of source AS IDs to be or should we 
put CL_KERNEL_ARG_ADDRESS_GLOBAL, etc, as strings instead? I am not sure it's a 
good idea to tie SPIR and OpenCL together. At the end SPIR is meant to be an IR 
to compile from different source languages and not just OpenCL.


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


[PATCH] D25439: Fixed column shift when formatting line containing bit shift operators

2016-11-03 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285934: Fixed column shift when formatting line containing 
bit shift operators (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D25439?vs=75635=76869#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25439

Files:
  cfe/trunk/lib/Format/FormatTokenLexer.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp


Index: cfe/trunk/lib/Format/FormatTokenLexer.cpp
===
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp
@@ -525,10 +525,12 @@
   } else if (FormatTok->Tok.is(tok::greatergreater)) {
 FormatTok->Tok.setKind(tok::greater);
 FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
+++Column;
 StateStack.push(LexerState::TOKEN_STASHED);
   } else if (FormatTok->Tok.is(tok::lessless)) {
 FormatTok->Tok.setKind(tok::less);
 FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
+++Column;
 StateStack.push(LexerState::TOKEN_STASHED);
   }
 
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -5501,6 +5501,18 @@
   verifyFormat("< < < < < < < < < < < < < < < < < < < < < < < < < < < < < <");
 }
 
+TEST_F(FormatTest, BitshiftOperatorWidth) {
+  EXPECT_EQ("int a = 1 << 2; /* foo\n"
+"   bar */",
+format("inta=1<<2;  /* foo\n"
+   "   bar */"));
+
+  EXPECT_EQ("int b = 256 >> 1; /* foo\n"
+" bar */",
+format("int  b  =256>>1 ;  /* foo\n"
+   "  bar */"));
+}
+
 TEST_F(FormatTest, UnderstandsBinaryOperators) {
   verifyFormat("COMPARE(a, ==, b);");
   verifyFormat("auto s = sizeof...(Ts) - 1;");


Index: cfe/trunk/lib/Format/FormatTokenLexer.cpp
===
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp
@@ -525,10 +525,12 @@
   } else if (FormatTok->Tok.is(tok::greatergreater)) {
 FormatTok->Tok.setKind(tok::greater);
 FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
+++Column;
 StateStack.push(LexerState::TOKEN_STASHED);
   } else if (FormatTok->Tok.is(tok::lessless)) {
 FormatTok->Tok.setKind(tok::less);
 FormatTok->TokenText = FormatTok->TokenText.substr(0, 1);
+++Column;
 StateStack.push(LexerState::TOKEN_STASHED);
   }
 
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -5501,6 +5501,18 @@
   verifyFormat("< < < < < < < < < < < < < < < < < < < < < < < < < < < < < <");
 }
 
+TEST_F(FormatTest, BitshiftOperatorWidth) {
+  EXPECT_EQ("int a = 1 << 2; /* foo\n"
+"   bar */",
+format("inta=1<<2;  /* foo\n"
+   "   bar */"));
+
+  EXPECT_EQ("int b = 256 >> 1; /* foo\n"
+" bar */",
+format("int  b  =256>>1 ;  /* foo\n"
+   "  bar */"));
+}
+
 TEST_F(FormatTest, UnderstandsBinaryOperators) {
   verifyFormat("COMPARE(a, ==, b);");
   verifyFormat("auto s = sizeof...(Ts) - 1;");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25439: Fixed column shift when formatting line containing bit shift operators

2016-11-03 Thread Paweł Żukowski via cfe-commits
idlecode added a comment.

No, not yet - I was about to ask someone to commit this for me :)


https://reviews.llvm.org/D25439



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


[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-03 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

One purpose of kernel arg info metadata is to be passed to OpenCL runtime to 
fulfill clGetKernelArgInfo queries. 
(https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clGetKernelArgInfo.html).
 As such, the address space id needs to be at source level instead of IR level.


Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


[PATCH] D26196: AMDGPU: Translate null pointers in private and local addr space

2016-11-03 Thread Tom Stellard via cfe-commits
tstellarAMD added a comment.

In https://reviews.llvm.org/D26196#586723, @Anastasia wrote:

> My understanding of NULL constant in IR was that it doesn't assume any 
> specific integer value (i.e. 0). And currently as I can see it is lowered 
> very late in LLVM backend  during the code selection phase.


It is assumed to be zero in some places.  For example:
https://github.com/llvm-mirror/llvm/blob/master/lib/IR/ConstantFold.cpp#L620
https://github.com/llvm-mirror/llvm/blob/master/lib/Analysis/ValueTracking.cpp#L1512

-Tom


https://reviews.llvm.org/D26196



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


[PATCH] D26160: [PowerPC] Implement remaining vector comparison builtins

2016-11-03 Thread Tony Jiang via cfe-commits
jtony updated this revision to Diff 76862.
jtony marked 2 inline comments as done.
jtony added a comment.

Fix a few format and layout issues.

Format: clang-format is not always correct, sometimes separate parameters in 
different lines is better.
Layout: put the overloaded builtin functions  in such order:  signed version, 
unsigned version and bool version.


https://reviews.llvm.org/D26160

Files:
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-altivec.c
  test/CodeGen/builtins-ppc-p8vector.c

Index: test/CodeGen/builtins-ppc-p8vector.c
===
--- test/CodeGen/builtins-ppc-p8vector.c
+++ test/CodeGen/builtins-ppc-p8vector.c
@@ -151,6 +151,11 @@
 // CHECK-PPC: warning: implicit declaration of function 'vec_mergeo'
   
   /* vec_cmpeq */
+  res_vbll = vec_cmpeq(vbll, vbll);
+// CHECK: @llvm.ppc.altivec.vcmpequd
+// CHECK-LE: @llvm.ppc.altivec.vcmpequd
+// CHECK-PPC: error: call to 'vec_cmpeq' is ambiguous
+
   res_vbll = vec_cmpeq(vsll, vsll);
 // CHECK: @llvm.ppc.altivec.vcmpequd
 // CHECK-LE: @llvm.ppc.altivec.vcmpequd
Index: test/CodeGen/builtins-ppc-altivec.c
===
--- test/CodeGen/builtins-ppc-altivec.c
+++ test/CodeGen/builtins-ppc-altivec.c
@@ -938,22 +938,34 @@
 // CHECK: @llvm.ppc.altivec.vcmpequb
 // CHECK-LE: @llvm.ppc.altivec.vcmpequb
 
+  res_vbc = vec_cmpeq(vbc, vbc);
+// CHECK: @llvm.ppc.altivec.vcmpequb
+// CHECK-LE: @llvm.ppc.altivec.vcmpequb
+
   res_vbs = vec_cmpeq(vs, vs);
 // CHECK: @llvm.ppc.altivec.vcmpequh
 // CHECK-LE: @llvm.ppc.altivec.vcmpequh
 
   res_vbs = vec_cmpeq(vus, vus);
 // CHECK: @llvm.ppc.altivec.vcmpequh
 // CHECK-LE: @llvm.ppc.altivec.vcmpequh
 
+  res_vbs = vec_cmpeq(vbs, vbs);
+// CHECK: @llvm.ppc.altivec.vcmpequh
+// CHECK-LE: @llvm.ppc.altivec.vcmpequh
+
   res_vbi = vec_cmpeq(vi, vi);
 // CHECK: @llvm.ppc.altivec.vcmpequw
 // CHECK-LE: @llvm.ppc.altivec.vcmpequw
 
   res_vbi = vec_cmpeq(vui, vui);
 // CHECK: @llvm.ppc.altivec.vcmpequw
 // CHECK-LE: @llvm.ppc.altivec.vcmpequw
 
+  res_vbi = vec_cmpeq(vbi, vbi);
+// CHECK: @llvm.ppc.altivec.vcmpequw
+// CHECK-LE: @llvm.ppc.altivec.vcmpequw
+
   res_vbi = vec_cmpeq(vf, vf);
 // CHECK: @llvm.ppc.altivec.vcmpeqfp
 // CHECK-LE: @llvm.ppc.altivec.vcmpeqfp
Index: lib/Headers/altivec.h
===
--- lib/Headers/altivec.h
+++ lib/Headers/altivec.h
@@ -1564,6 +1564,12 @@
   (vector char)__b);
 }
 
+static __inline__ vector bool char __ATTRS_o_ai
+vec_cmpeq(vector bool char __a, vector bool char __b) {
+  return (vector bool char)__builtin_altivec_vcmpequb((vector char)__a,
+  (vector char)__b);
+}
+
 static __inline__ vector bool short __ATTRS_o_ai vec_cmpeq(vector short __a,
vector short __b) {
   return (vector bool short)__builtin_altivec_vcmpequh(__a, __b);
@@ -1575,6 +1581,12 @@
(vector short)__b);
 }
 
+static __inline__ vector bool short __ATTRS_o_ai
+vec_cmpeq(vector bool short __a, vector bool short __b) {
+  return (vector bool short)__builtin_altivec_vcmpequh((vector short)__a,
+   (vector short)__b);
+}
+
 static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector int __a,
  vector int __b) {
   return (vector bool int)__builtin_altivec_vcmpequw(__a, __b);
@@ -1586,6 +1598,12 @@
  (vector int)__b);
 }
 
+static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector bool int __a,
+ vector bool int __b) {
+  return (vector bool int)__builtin_altivec_vcmpequw((vector int)__a,
+ (vector int)__b);
+}
+
 #ifdef __POWER8_VECTOR__
 static __inline__ vector bool long long __ATTRS_o_ai
 vec_cmpeq(vector signed long long __a, vector signed long long __b) {
@@ -1597,6 +1615,13 @@
   return (vector bool long long)__builtin_altivec_vcmpequd(
   (vector long long)__a, (vector long long)__b);
 }
+
+static __inline__ vector bool long long __ATTRS_o_ai
+vec_cmpeq(vector bool long long __a, vector bool long long __b) {
+  return (vector bool long long)__builtin_altivec_vcmpequd(
+  (vector long long)__a, (vector long long)__b);
+}
+
 #endif
 
 static __inline__ vector bool int __ATTRS_o_ai vec_cmpeq(vector float __a,
@@ -2298,14 +2323,15 @@
  result if either is zero.
   */
   vector bool char __tmp1 = vec_cmpeq(__a, __b);
-  vector bool char __tmp2 = __tmp1 | vec_cmpeq(__tmp1, __a) |
-vec_cmpeq(__tmp1, __b);
+  vector bool char __tmp2 = __tmp1 |
+vec_cmpeq((vector signed char)__tmp1, __a) |
+ 

[PATCH] D26282: [PowerPC] Implement plain VSX load/store builtins.

2016-11-03 Thread Tony Jiang via cfe-commits
jtony created this revision.
jtony added reviewers: nemanjai, amehsan, kbarton, sfertile, syzaara, lei.
jtony added subscribers: llvm-commits, cfe-commits, echristo.

Implement all the different 24 overloads for vec_xl and vec_xst.

Signatures:
vector signed char vec_xl (signed long long, signed char *);
vector unsigned char vec_xl (signed long long, unsigned char *);
vector signed int vec_xl (signed long long, signed int *);
vector unsigned int vec_xl (signed long long, unsigned int *);
vector signed __int128 vec_xl (signed long long, signed __int128 *);
vector unsigned __int128 vec_xl (signed long long, unsigned __int128 *);
vector signed long long vec_xl (signed long long, signed long long *);
vector unsigned long long vec_xl (signed long long, unsigned long long *);
vector signed short vec_xl (signed long long, signed short *);
vector unsigned short vec_xl (signed long long, unsigned short *);
vector double vec_xl (signed long long, double *);
vector float vec_xl (signed long long, float *);
void vec_xst (vector signed char, signed long long, signed char *);
void vec_xst (vector unsigned char, signed long long, unsigned char *);
void vec_xst (vector signed int, signed long long, signed int *);
void vec_xst (vector unsigned int, signed long long, unsigned int *);
void vec_xst (vector signed __int128, signed long long, signed __int128 *);
void vec_xst (vector unsigned __int128, signed long long, unsigned __int128 *);
void vec_xst (vector signed long long, signed long long, signed long long *);
void vec_xst (vector unsigned long long, signed long long, unsigned long long 
*);
void vec_xst (vector signed short, signed long long, signed short *);
void vec_xst (vector unsigned short, signed long long, unsigned short *);
void vec_xst (vector double, signed long long, double *);
void vec_xst (vector float, signed long long, float *);


https://reviews.llvm.org/D26282

Files:
  lib/Headers/altivec.h
  test/CodeGen/builtins-ppc-altivec.c
  test/CodeGen/builtins-ppc-quadword.c
  test/CodeGen/builtins-ppc-vsx.c

Index: test/CodeGen/builtins-ppc-vsx.c
===
--- test/CodeGen/builtins-ppc-vsx.c
+++ test/CodeGen/builtins-ppc-vsx.c
@@ -21,6 +21,7 @@
 vector signed long long vsll = { 255LL, -937LL };
 vector unsigned long long vull = { 1447LL, 2894LL };
 double d = 23.4;
+signed long long sll = 618LL;
 float af[4] = {23.4f, 56.7f, 89.0f, 12.3f};
 double ad[2] = {23.4, 56.7};
 signed char asc[16] = { -8,  9, -10, 11, -12, 13, -14, 15,
@@ -31,8 +32,8 @@
 unsigned short aus[8] = { 0, 1, 2, 3, 4, 5, 6, 7 };
 signed int asi[4] = { -1, 2, -3, 4 };
 unsigned int aui[4] = { 0, 1, 2, 3 };
-signed long asl[2] = { -1L, 2L };
-unsigned long aul[2] = { 1L, 2L };
+signed long long asll[2] = { -1L, 2L };
+unsigned long long aull[2] = { 1L, 2L };
 
 vector float res_vf;
 vector double res_vd;
@@ -1248,4 +1249,28 @@
   res_vull = vec_sro(vull, vuc);
 // CHECK: @llvm.ppc.altivec.vsro
 // CHECK-LE: @llvm.ppc.altivec.vsro
+
+res_vsll = vec_xl(sll, asll);
+// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+
+res_vull = vec_xl(sll, aull);
+// CHECK: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: load <2 x i64>, <2 x i64>* %{{[0-9]+}}, align 16
+
+res_vd = vec_xl(sll, ad);
+// CHECK: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
+// CHECK-LE: load <2 x double>, <2 x double>* %{{[0-9]+}}, align 16
+
+vec_xst(vsll, sll, asll);
+// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+
+vec_xst(vull, sll, aull);
+// CHECK: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+// CHECK-LE: store <2 x i64> %{{[0-9]+}}, <2 x i64>* %{{[0-9]+}}, align 16
+
+vec_xst(vd, sll, ad);
+// CHECK: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
+// CHECK-LE: store <2 x double> %{{[0-9]+}}, <2 x double>* %{{[0-9]+}}, align 16
 }
Index: test/CodeGen/builtins-ppc-quadword.c
===
--- test/CodeGen/builtins-ppc-quadword.c
+++ test/CodeGen/builtins-ppc-quadword.c
@@ -15,6 +15,12 @@
 // CHECK-PPC: error: __int128 is not supported on this target
 vector unsigned __int128 vulll = { 1 };
 
+signed long long param_sll;
+// CHECK-PPC: error: __int128 is not supported on this target
+signed __int128 param_lll;
+// CHECK-PPC: error: __int128 is not supported on this target
+unsigned __int128 param_ulll;
+
 // CHECK-PPC: error: __int128 is not supported on this target
 vector signed __int128 res_vlll;
 // CHECK-PPC: error: __int128 is not supported on this target
@@ -165,4 +171,26 @@
 // CHECK-LE: xor <16 x i8>
 // CHECK-LE: call <4 x i32> @llvm.ppc.altivec.vperm(<4 x i32> {{%.+}}, <4 x i32> {{%.+}}, <16 x i8> {{%.+}})
 // CHECK_PPC: error: call to 'vec_revb' is ambiguous
+
+  /* vec_xl */
+  res_vlll = vec_xl(param_sll, _lll);
+  // 

r285925 - Rename the version of ConstructJob for multiple outputs to ConstructJobMultipleOutputs.

2016-11-03 Thread Samuel Antao via cfe-commits
Author: sfantao
Date: Thu Nov  3 10:41:50 2016
New Revision: 285925

URL: http://llvm.org/viewvc/llvm-project?rev=285925=rev
Log:
Rename the version of ConstructJob for multiple outputs to 
ConstructJobMultipleOutputs.

It was causing trouble with the GCC bots.

Modified:
cfe/trunk/include/clang/Driver/Tool.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Tool.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h

Modified: cfe/trunk/include/clang/Driver/Tool.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Tool.h?rev=285925=285924=285925=diff
==
--- cfe/trunk/include/clang/Driver/Tool.h (original)
+++ cfe/trunk/include/clang/Driver/Tool.h Thu Nov  3 10:41:50 2016
@@ -138,11 +138,11 @@ public:
   /// tool chain specific translations applied.
   /// \param LinkingOutput If this output will eventually feed the
   /// linker, then this is the final output name of the linked image.
-  virtual void ConstructJob(Compilation , const JobAction ,
-const InputInfoList ,
-const InputInfoList ,
-const llvm::opt::ArgList ,
-const char *LinkingOutput) const;
+  virtual void ConstructJobMultipleOutputs(Compilation , const JobAction ,
+   const InputInfoList ,
+   const InputInfoList ,
+   const llvm::opt::ArgList ,
+   const char *LinkingOutput) const;
 };
 
 } // end namespace driver

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=285925=285924=285925=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Nov  3 10:41:50 2016
@@ -3199,7 +3199,7 @@ InputInfo Driver::BuildJobsForActionNoCa
   C.getArgsForToolChain(TC, BoundArch, JA->getOffloadingDeviceKind()),
   LinkingOutput);
 else
-  T->ConstructJob(
+  T->ConstructJobMultipleOutputs(
   C, *JA, UnbundlingResults, InputInfos,
   C.getArgsForToolChain(TC, BoundArch, JA->getOffloadingDeviceKind()),
   LinkingOutput);

Modified: cfe/trunk/lib/Driver/Tool.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tool.cpp?rev=285925=285924=285925=diff
==
--- cfe/trunk/lib/Driver/Tool.cpp (original)
+++ cfe/trunk/lib/Driver/Tool.cpp Thu Nov  3 10:41:50 2016
@@ -23,11 +23,11 @@ Tool::Tool(const char *_Name, const char
 Tool::~Tool() {
 }
 
-void Tool::ConstructJob(Compilation , const JobAction ,
-const InputInfoList ,
-const InputInfoList ,
-const llvm::opt::ArgList ,
-const char *LinkingOutput) const {
+void Tool::ConstructJobMultipleOutputs(Compilation , const JobAction ,
+   const InputInfoList ,
+   const InputInfoList ,
+   const llvm::opt::ArgList ,
+   const char *LinkingOutput) const {
   assert(Outputs.size() == 1 && "Expected only one output by default!");
   ConstructJob(C, JA, Outputs.front(), Inputs, TCArgs, LinkingOutput);
-};
+}

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=285925=285924=285925=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Nov  3 10:41:50 2016
@@ -7133,11 +7133,10 @@ void OffloadBundler::ConstructJob(Compil
   CmdArgs, None));
 }
 
-void OffloadBundler::ConstructJob(Compilation , const JobAction ,
-  const InputInfoList ,
-  const InputInfoList ,
-  const llvm::opt::ArgList ,
-  const char *LinkingOutput) const {
+void OffloadBundler::ConstructJobMultipleOutputs(
+Compilation , const JobAction , const InputInfoList ,
+const InputInfoList , const llvm::opt::ArgList ,
+const char *LinkingOutput) const {
   // The version with multiple outputs is expected to refer to a unbundling 
job.
   auto  = cast(JA);
 

Modified: cfe/trunk/lib/Driver/Tools.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=285925=285924=285925=diff
==
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Thu Nov  3 10:41:50 2016
@@ -148,10 +148,11 @@ public:
  

[PATCH] D26157: [OpenCL] always use SPIR address spaces for kernel_arg_addr_space MD

2016-11-03 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

> Is there nowadays such a thing as "standard OpenCL logical AS IDs" which 
> could be retained down to code gen? I must say I haven't checked the current 
> situation here. It used to be that the logical ids are assumed to be 
> converted to the target ones already in Clang and I'm afraid changing this 
> requires a major rework.

I think it's really hard topic and people probably have different 
interpretations. My understanding is that Clang AST contains source level AS  
(i.e. OpenCL and CUDA) and translates down to logical AS in IR (different AS in 
CUDA and OpenCL could map to the same AS in IR). I don't think those ASes in IR 
are fixed or agreed to have some defined semantic either. This is probably the 
source of major confusions. Clang translates to target (i.e. IR) address spaces 
which should be lowered by LLVM as late as possible into physical ones when the 
address space information is not needed any more.

But I think there are a lot of different implementations and shortcuts to 
either translate early or late at the moment. It's hard to say what's best. I 
guess as soon as it works and generic enough for everyone needs. But in a 
longer term some better understanding and common concepts should be found in my 
opinion.

I must say for this particular change it will probably be confusing to see 
different AS numbers between IR operations and MD in case some targets have 
different mapping than SPIR. Perhaps, we could discuss alternative strategies.

> pocl has used the fake-address-space ids until now for exactly this -- 
> retaining the logical AS info in the IR which can be exploited for disjoint 
> address space AA, but is also required for handling the different AS kernel 
> arguments as local arguments must be treated differently memory allocation 
> wise.
> 
> However, as all backends are not expected to support mapping the fake address 
> spaces to their internal ones (in single AS it's trivial to simply ignore the 
> AS ids, but for multi-AS machines there has to be explicit mapping) we have 
> had an IR pass that converts the address spaces to the target's before code 
> gen. This pass we call TargetAddressSpaces has grown way too complex and is a 
> major source of bugs all the time.
> 
> Also, another source of bugs is the fact that many passes simply ignore 
> address spaces as they have been developed for single AS machines and only 
> tested on them. This leads to bugs where the AS ID info is silently dropped 
> (converted to 0) which makes them hard to catch.  If the pointer creation 
> APIs of LLVM were forced to include the AS ID in the construction, it might 
> yield out majority of these issues -- as long as the coders respect the fact 
> that there can be multiple ASs and not simply use 0 there all the time.
> 
> Also, some optimizations such as vectorization might get confused in case it 
> sees non-0 address spaces for CPU targets (e.g. there might not be vectorized 
> intrinsics available for non-0 ASs).

I think it's the same for the frontend actually. Clang hasn't been written with 
AS in mind and although with time most problems have been fixed, many commits 
still revolve around various AS issues.

Is it something that should be addressed by LLVM community? Something that we 
could discuss to be improved on llvm-dev list? I am guessing a lot of 
contributors that work with segmented memory architectures can benefit from 
this work.

> Etc. Thus, due to the limited time our group has available for hunting the 
> bugs that stem from this, I decided it might be best to avoid the use of the 
> "logical IDs" inside IR for now and think about how to implement the disjoint 
> AA without them later on.




Repository:
  rL LLVM

https://reviews.llvm.org/D26157



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


[PATCH] D26166: [Sema] Don't issue analysis-based warnings when a fatal error has occurred

2016-11-03 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added inline comments.



Comment at: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp:213
+  // Don't allow further instantiation if a fatal error and an uncompilable
+  // error have occcured. Any diagnostics we might have raised will not be
+  // visible, and we do not need to construct a correct AST.

s/occcured/occurred/


Repository:
  rL LLVM

https://reviews.llvm.org/D26166



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


r285923 - [Sema] Avoid instantiating templates only when UncompilableErrorOccurred

2016-11-03 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Nov  3 10:04:58 2016
New Revision: 285923

URL: http://llvm.org/viewvc/llvm-project?rev=285923=rev
Log:
[Sema] Avoid instantiating templates only when UncompilableErrorOccurred
and FatalErrorOccurred are both set.

This fixes a crash that occurs when a warning promoted to a fatal error
leaves the AST in an incomplete state, and then later CFG analysis is
run on the incomplete AST.

rdar://problem/28558923

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

Added:
cfe/trunk/test/SemaCXX/instantiate-template-fatal-error.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=285923=285922=285923=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Thu Nov  3 10:04:58 2016
@@ -209,9 +209,11 @@ Sema::InstantiatingTemplate::Instantiati
 sema::TemplateDeductionInfo *DeductionInfo)
 : SemaRef(SemaRef), SavedInNonInstantiationSFINAEContext(
 SemaRef.InNonInstantiationSFINAEContext) {
-  // Don't allow further instantiation if a fatal error has occcured.  Any
-  // diagnostics we might have raised will not be visible.
-  if (SemaRef.Diags.hasFatalErrorOccurred()) {
+  // Don't allow further instantiation if a fatal error and an uncompilable
+  // error have occcured. Any diagnostics we might have raised will not be
+  // visible, and we do not need to construct a correct AST.
+  if (SemaRef.Diags.hasFatalErrorOccurred() &&
+  SemaRef.Diags.hasUncompilableErrorOccurred()) {
 Invalid = true;
 return;
   }

Added: cfe/trunk/test/SemaCXX/instantiate-template-fatal-error.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/instantiate-template-fatal-error.cpp?rev=285923=auto
==
--- cfe/trunk/test/SemaCXX/instantiate-template-fatal-error.cpp (added)
+++ cfe/trunk/test/SemaCXX/instantiate-template-fatal-error.cpp Thu Nov  3 
10:04:58 2016
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+
+#pragma clang diagnostic fatal "-Wall"
+#pragma clang diagnostic fatal "-Wold-style-cast"
+
+template  bool foo0(const long long *a, T* b) {
+  return a == (const long long*)b; // expected-error {{use of old-style cast}}
+}
+
+template
+struct S1 {
+};
+
+template
+struct S2 : S1 {
+  bool m1(const long long *a, T *b) const { return foo0(a, b); }
+};
+
+bool foo1(const long long *a, int *b) {
+  S2 s2;
+  return s2.m1(a, b);
+}


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


[PATCH] D26166: [Sema] Don't issue analysis-based warnings when a fatal error has occurred

2016-11-03 Thread Akira Hatanaka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285923: [Sema] Avoid instantiating templates only when 
UncompilableErrorOccurred (authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D26166?vs=76521=76863#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26166

Files:
  cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
  cfe/trunk/test/SemaCXX/instantiate-template-fatal-error.cpp


Index: cfe/trunk/test/SemaCXX/instantiate-template-fatal-error.cpp
===
--- cfe/trunk/test/SemaCXX/instantiate-template-fatal-error.cpp
+++ cfe/trunk/test/SemaCXX/instantiate-template-fatal-error.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+
+#pragma clang diagnostic fatal "-Wall"
+#pragma clang diagnostic fatal "-Wold-style-cast"
+
+template  bool foo0(const long long *a, T* b) {
+  return a == (const long long*)b; // expected-error {{use of old-style cast}}
+}
+
+template
+struct S1 {
+};
+
+template
+struct S2 : S1 {
+  bool m1(const long long *a, T *b) const { return foo0(a, b); }
+};
+
+bool foo1(const long long *a, int *b) {
+  S2 s2;
+  return s2.m1(a, b);
+}
Index: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
@@ -209,9 +209,11 @@
 sema::TemplateDeductionInfo *DeductionInfo)
 : SemaRef(SemaRef), SavedInNonInstantiationSFINAEContext(
 SemaRef.InNonInstantiationSFINAEContext) {
-  // Don't allow further instantiation if a fatal error has occcured.  Any
-  // diagnostics we might have raised will not be visible.
-  if (SemaRef.Diags.hasFatalErrorOccurred()) {
+  // Don't allow further instantiation if a fatal error and an uncompilable
+  // error have occcured. Any diagnostics we might have raised will not be
+  // visible, and we do not need to construct a correct AST.
+  if (SemaRef.Diags.hasFatalErrorOccurred() &&
+  SemaRef.Diags.hasUncompilableErrorOccurred()) {
 Invalid = true;
 return;
   }


Index: cfe/trunk/test/SemaCXX/instantiate-template-fatal-error.cpp
===
--- cfe/trunk/test/SemaCXX/instantiate-template-fatal-error.cpp
+++ cfe/trunk/test/SemaCXX/instantiate-template-fatal-error.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 %s
+
+#pragma clang diagnostic fatal "-Wall"
+#pragma clang diagnostic fatal "-Wold-style-cast"
+
+template  bool foo0(const long long *a, T* b) {
+  return a == (const long long*)b; // expected-error {{use of old-style cast}}
+}
+
+template
+struct S1 {
+};
+
+template
+struct S2 : S1 {
+  bool m1(const long long *a, T *b) const { return foo0(a, b); }
+};
+
+bool foo1(const long long *a, int *b) {
+  S2 s2;
+  return s2.m1(a, b);
+}
Index: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
===
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
@@ -209,9 +209,11 @@
 sema::TemplateDeductionInfo *DeductionInfo)
 : SemaRef(SemaRef), SavedInNonInstantiationSFINAEContext(
 SemaRef.InNonInstantiationSFINAEContext) {
-  // Don't allow further instantiation if a fatal error has occcured.  Any
-  // diagnostics we might have raised will not be visible.
-  if (SemaRef.Diags.hasFatalErrorOccurred()) {
+  // Don't allow further instantiation if a fatal error and an uncompilable
+  // error have occcured. Any diagnostics we might have raised will not be
+  // visible, and we do not need to construct a correct AST.
+  if (SemaRef.Diags.hasFatalErrorOccurred() &&
+  SemaRef.Diags.hasUncompilableErrorOccurred()) {
 Invalid = true;
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24894: [clang-tidy] Prefer transparent functors to non-transparent one.

2016-11-03 Thread Gábor Horváth via cfe-commits
xazax.hun updated this revision to Diff 76860.
xazax.hun marked 5 inline comments as done.
xazax.hun added a comment.

- Addressed review comments.


https://reviews.llvm.org/D24894

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
  clang-tidy/modernize/UseTransparentFunctorsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-transparent-functors.rst
  test/clang-tidy/modernize-use-transparent-functors.cpp

Index: test/clang-tidy/modernize-use-transparent-functors.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-transparent-functors.cpp
@@ -0,0 +1,107 @@
+// RUN: %check_clang_tidy %s modernize-use-transparent-functors %t -- -- -std=c++14
+
+namespace std {
+template
+struct remove_reference;
+
+template 
+constexpr T &(typename std::remove_reference::type );
+
+template 
+constexpr T &(typename std::remove_reference::type &);
+
+template 
+struct plus {
+  constexpr T operator()(const T , const T ) const;
+};
+
+template <>
+struct plus {
+  template 
+  constexpr auto operator()(T &, U &) const -> 
+decltype(forward(Lhs) + forward(Rhs));
+};
+
+template 
+struct less {
+  constexpr bool operator()(const T , const T ) const;
+};
+
+template <>
+struct less {
+  template 
+  constexpr bool operator()(T &, U &) const;
+};
+
+template 
+struct logical_not {
+  constexpr bool operator()(const T ) const;
+};
+
+template <>
+struct logical_not {
+  template 
+  constexpr bool operator()(T &) const;
+};
+
+template 
+class allocator;
+
+template <
+class Key,
+class Compare = std::less<>,
+class Allocator = std::allocator>
+class set {};
+
+template <
+class Key,
+class Compare = std::less,
+class Allocator = std::allocator>
+class set2 {};
+
+template 
+InputIt find_if(InputIt first, InputIt last,
+UnaryPredicate p);
+
+template 
+void sort(RandomIt first, RandomIt last, Compare comp);
+
+class iterator {};
+class string {};
+}
+
+int main() {
+  using std::set;
+  using std::less;
+  std::set s;
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: prefer transparent functors (less<>) [modernize-use-transparent-functors]
+  // CHECK-FIXES: {{^}}  std::set> s;{{$}}
+  set s2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  set> s2;{{$}}
+  set s3;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  set> s3;{{$}}
+  std::set> s4;
+  std::set> s5;
+  std::set, std::less<>> s6;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  std::set>, std::less<>> s6;{{$}}
+  std::iterator begin, end;
+  sort(begin, end, std::less());
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: prefer transparent functors
+  std::sort(begin, end, std::less<>());
+  find_if(begin, end, std::logical_not());
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: prefer transparent functors
+  std::find_if(begin, end, std::logical_not<>());
+  using my_set = std::set;
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: prefer transparent functors
+  // CHECK-FIXES: {{^}}  using my_set = std::set>;{{$}}
+  using my_set2 = std::set;
+  using my_less = std::less;
+  find_if(begin, end, my_less());
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: prefer transparent functors
+  std::set2 control;
+}
+
+
Index: docs/clang-tidy/checks/modernize-use-transparent-functors.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/modernize-use-transparent-functors.rst
@@ -0,0 +1,39 @@
+.. title:: clang-tidy - modernize-use-transparent-functors
+
+modernize-use-transparent-functors
+==
+
+Prefer transparent functors to non-transparent ones. When using transparent
+functors, the type does not need to be repeated. The code is easier to read,
+maintain and less prone to errors. It not possible to introduce unwanted
+conversions.
+
+  .. code-block:: c++
+
+// Non-transparent functor  
+std::map s;
+
+// Transparent functor.
+std::map> s;
+
+// Non-transparent functor
+using MyFunctor = std::less;
+
+It is not always a safe transformation though. The following case will be 
+untouched to preserve the semantics.
+
+  .. code-block:: c++
+
+// Non-transparent functor  
+std::map> s;
+
+Options
+---
+
+.. option:: SafeMode
+
+   If the option is set to non-zero (default is `0`), the check will not
+   warn on these cases as shown above, where automatic FIXIT is not safe to
+   apply.
+
+This check 

[PATCH] D24933: Enable configuration files in clang

2016-11-03 Thread Hans Wennborg via cfe-commits
hans added a comment.

Apologies for seeming so negative here. I can see that this would possibly be 
beneficial for some users. This would be a powerful feature, which is what 
worries me.

Here's a specific scenario I'm worried about.

For Chromium, our build system provides a specific Clang version close to ToT, 
and obviously what flags to use when invoking it. (Developers can of course 
override the flags when configuring if they want.) Now maybe a developer has a 
~/clang.cfg because they want certain flags on by default when they build 
*other* projects, those flags would now be applied to all clangs, including the 
one we provide, and potentially wreak havoc.

As for compiler bugs getting harder to reproduce, we already get a lot of bug 
reports where only the driver invocation is provided, e.g. "clang -O2 foo.c". 
If the user has a config file that sets -fsome-other-flag, we wouldn't see it. 
Even worse, what if distros start trying to be helpful and provide default 
config files?

Other random thoughts:
Do we want to get the same config file for "clang", "clang++" and "clang-cl"? 
They accept different flags.
If we are going to move forward with this, I think the patch should also 
include an update to docs/UsersManual.rst, explaining exactly how it works 
(after that's been figured out of course).


https://reviews.llvm.org/D24933



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


[PATCH] D26196: AMDGPU: Translate null pointers in private and local addr space

2016-11-03 Thread Anastasia Stulova via cfe-commits
Anastasia added a comment.

My understanding of NULL constant in IR was that it doesn't assume any specific 
integer value (i.e. 0). And currently as I can see it is lowered very late in 
LLVM backend  during the code selection phase.

Looking at the lowering code in LLVM, it seems like it shouldn't be too 
difficult to special case the NULL value based on the address space: 
http://llvm.org/docs/doxygen/html/SelectionDAGBuilder_8cpp_source.html#l01039 
instead of using hard-coded 0 at it's done now.

My opinion is that we should try to lower the code as late as possible and 
Clang doesn't seem like an ideal place for this. Also this change adds extra 
overhead by adding extra addresspacecast instructions and complicates frontend 
implementation. I don't see immediate benefit in changing this in the frontend 
compared to changing LLVM code selection phase instead.


https://reviews.llvm.org/D26196



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


r285909 - Support for Python 3 in libclang python bindings

2016-11-03 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Thu Nov  3 08:55:34 2016
New Revision: 285909

URL: http://llvm.org/viewvc/llvm-project?rev=285909=rev
Log:
Support for Python 3 in libclang python bindings

Summary:
Python bindings tests now pass in Python 3.

`map` in Python 3 is lazily evaluated so the method by which functions are 
registered needed updating.

Strings are unicode in Python 3 not UTF-8, I've tried to create an new 
c_types-like class (c_string_p) to automate the conversion.

String conversions made explicit where required.

Reviewers: eliben, nemanjai, skalinichev, compnerd

Subscribers: mgorny, cfe-commits

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=285909=285908=285909=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Thu Nov  3 08:55:34 2016
@@ -64,6 +64,7 @@ call is efficient.
 
 from ctypes import *
 import collections
+import sys
 
 import clang.enumerations
 
@@ -73,6 +74,33 @@ import clang.enumerations
 # this by marshalling object arguments as void**.
 c_object_p = POINTER(c_void_p)
 
+if sys.version_info[0] > 2:
+# Python 3 strings are unicode, translate them to/from utf8 for C-interop
+# Python 3 replaces xrange with range, we want xrange behaviour
+xrange = range
+
+class c_string_p(c_char_p):
+def __init__(self, p=None):
+if type(p) == str:
+p = p.encode("utf8")
+super(c_char_p, self).__init__(p)
+
+def __str__(self):
+return str(self.value)
+
+@property
+def value(self):
+if super(c_char_p, self).value is None:
+return None
+return super(c_char_p, self).value.decode("utf8")
+
+@classmethod
+def from_param(cls, param):
+return cls(param)
+else:
+c_string_p = c_char_p
+
+
 callbacks = {}
 
 ### Exception Classes ###
@@ -147,7 +175,7 @@ class CachedProperty(object):
 class _CXString(Structure):
 """Helper for transforming CXString results."""
 
-_fields_ = [("spelling", c_char_p), ("free", c_int)]
+_fields_ = [("spelling", c_string_p), ("free", c_int)]
 
 def __del__(self):
 conf.lib.clang_disposeString(self)
@@ -329,7 +357,7 @@ class Diagnostic(object):
 
 @property
 def spelling(self):
-return conf.lib.clang_getDiagnosticSpelling(self)
+return str(conf.lib.clang_getDiagnosticSpelling(self))
 
 @property
 def ranges(self):
@@ -358,8 +386,8 @@ class Diagnostic(object):
 
 def __getitem__(self, key):
 range = SourceRange()
-value = conf.lib.clang_getDiagnosticFixIt(self.diag, key,
-byref(range))
+value = str(conf.lib.clang_getDiagnosticFixIt(self.diag, key,
+byref(range)))
 if len(value) == 0:
 raise IndexError
 
@@ -392,12 +420,12 @@ class Diagnostic(object):
 @property
 def category_name(self):
 """The string name of the category for this diagnostic."""
-return conf.lib.clang_getDiagnosticCategoryText(self)
+return str(conf.lib.clang_getDiagnosticCategoryText(self))
 
 @property
 def option(self):
 """The command-line option that enables this diagnostic."""
-return conf.lib.clang_getDiagnosticOption(self, None)
+return str(conf.lib.clang_getDiagnosticOption(self, None))
 
 @property
 def disable_option(self):
@@ -405,7 +433,7 @@ class Diagnostic(object):
 disable = _CXString()
 conf.lib.clang_getDiagnosticOption(self, byref(disable))
 
-return conf.lib.clang_getCString(disable)
+return str(conf.lib.clang_getCString(disable))
 
 def format(self, options=None):
 """
@@ -554,8 +582,8 @@ class BaseEnumeration(object):
 if value >= len(self.__class__._kinds):
 self.__class__._kinds += [None] * (value - 
len(self.__class__._kinds) + 1)
 if self.__class__._kinds[value] is not None:
-raise ValueError,'{0} value {1} already loaded'.format(
-str(self.__class__), value)
+raise ValueError('{0} value {1} already loaded'.format(
+str(self.__class__), value))
 self.value = value
 self.__class__._kinds[value] = self
 self.__class__._name_map = None
@@ -572,12 +600,12 @@ class BaseEnumeration(object):
 for key, value in self.__class__.__dict__.items():
 if isinstance(value, self.__class__):
 self._name_map[value] = key
-return self._name_map[self]
+return 

[PATCH] D26082: Support for Python 3 in libclang python bindings

2016-11-03 Thread Jonathan B Coe via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285909: Support for Python 3 in libclang python bindings 
(authored by jbcoe).

Changed prior to commit:
  https://reviews.llvm.org/D26082?vs=76774=76854#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26082

Files:
  cfe/trunk/bindings/python/clang/cindex.py
  cfe/trunk/bindings/python/tests/cindex/test_translation_unit.py

Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -64,6 +64,7 @@
 
 from ctypes import *
 import collections
+import sys
 
 import clang.enumerations
 
@@ -73,6 +74,33 @@
 # this by marshalling object arguments as void**.
 c_object_p = POINTER(c_void_p)
 
+if sys.version_info[0] > 2:
+# Python 3 strings are unicode, translate them to/from utf8 for C-interop
+# Python 3 replaces xrange with range, we want xrange behaviour
+xrange = range
+
+class c_string_p(c_char_p):
+def __init__(self, p=None):
+if type(p) == str:
+p = p.encode("utf8")
+super(c_char_p, self).__init__(p)
+
+def __str__(self):
+return str(self.value)
+
+@property
+def value(self):
+if super(c_char_p, self).value is None:
+return None
+return super(c_char_p, self).value.decode("utf8")
+
+@classmethod
+def from_param(cls, param):
+return cls(param)
+else:
+c_string_p = c_char_p
+
+
 callbacks = {}
 
 ### Exception Classes ###
@@ -147,7 +175,7 @@
 class _CXString(Structure):
 """Helper for transforming CXString results."""
 
-_fields_ = [("spelling", c_char_p), ("free", c_int)]
+_fields_ = [("spelling", c_string_p), ("free", c_int)]
 
 def __del__(self):
 conf.lib.clang_disposeString(self)
@@ -329,7 +357,7 @@
 
 @property
 def spelling(self):
-return conf.lib.clang_getDiagnosticSpelling(self)
+return str(conf.lib.clang_getDiagnosticSpelling(self))
 
 @property
 def ranges(self):
@@ -358,8 +386,8 @@
 
 def __getitem__(self, key):
 range = SourceRange()
-value = conf.lib.clang_getDiagnosticFixIt(self.diag, key,
-byref(range))
+value = str(conf.lib.clang_getDiagnosticFixIt(self.diag, key,
+byref(range)))
 if len(value) == 0:
 raise IndexError
 
@@ -392,20 +420,20 @@
 @property
 def category_name(self):
 """The string name of the category for this diagnostic."""
-return conf.lib.clang_getDiagnosticCategoryText(self)
+return str(conf.lib.clang_getDiagnosticCategoryText(self))
 
 @property
 def option(self):
 """The command-line option that enables this diagnostic."""
-return conf.lib.clang_getDiagnosticOption(self, None)
+return str(conf.lib.clang_getDiagnosticOption(self, None))
 
 @property
 def disable_option(self):
 """The command-line option that disables this diagnostic."""
 disable = _CXString()
 conf.lib.clang_getDiagnosticOption(self, byref(disable))
 
-return conf.lib.clang_getCString(disable)
+return str(conf.lib.clang_getCString(disable))
 
 def format(self, options=None):
 """
@@ -554,8 +582,8 @@
 if value >= len(self.__class__._kinds):
 self.__class__._kinds += [None] * (value - len(self.__class__._kinds) + 1)
 if self.__class__._kinds[value] is not None:
-raise ValueError,'{0} value {1} already loaded'.format(
-str(self.__class__), value)
+raise ValueError('{0} value {1} already loaded'.format(
+str(self.__class__), value))
 self.value = value
 self.__class__._kinds[value] = self
 self.__class__._name_map = None
@@ -572,12 +600,12 @@
 for key, value in self.__class__.__dict__.items():
 if isinstance(value, self.__class__):
 self._name_map[value] = key
-return self._name_map[self]
+return str(self._name_map[self])
 
 @classmethod
 def from_id(cls, id):
 if id >= len(cls._kinds) or cls._kinds[id] is None:
-raise ValueError,'Unknown template argument kind %d' % id
+raise ValueError('Unknown template argument kind %d' % id)
 return cls._kinds[id]
 
 def __repr__(self):
@@ -596,7 +624,7 @@
 @staticmethod
 def get_all_kinds():
 """Return all CursorKind enumeration instances."""
-return filter(None, CursorKind._kinds)
+return [x for x in CursorKind._kinds if x]
 
 def is_declaration(self):
 """Test if this is a declaration kind."""
@@ -1427,9 +1455,9 @@
 def spelling(self):
 """Return the spelling of the 

[clang-tools-extra] r285907 - [clang-tidy] Ignore forward declarations without definitions in the same translation unit in readability-identifier-naming

2016-11-03 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Thu Nov  3 08:52:09 2016
New Revision: 285907

URL: http://llvm.org/viewvc/llvm-project?rev=285907=rev
Log:
[clang-tidy] Ignore forward declarations without definitions in the same 
translation unit in readability-identifier-naming

Summary: This change ensures that forward declarations of classes are not 
considered for identifier naming checks within a translation unit.

Reviewers: alexfh, aaron.ballman

Subscribers: mgehre

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp?rev=285907=285906=285907=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp 
Thu Nov  3 08:52:09 2016
@@ -395,6 +395,9 @@ static StyleKind findStyleKind(
 if (Decl->isAnonymousStructOrUnion())
   return SK_Invalid;
 
+if (!Decl->getCanonicalDecl()->isThisDeclarationADefinition())
+  return SK_Invalid;
+
 if (Decl->hasDefinition() && Decl->isAbstract() &&
 NamingStyles[SK_AbstractClass].isSet())
   return SK_AbstractClass;

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp?rev=285907=285906=285907=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-identifier-naming.cpp 
Thu Nov  3 08:52:09 2016
@@ -190,6 +190,11 @@ public:
 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: invalid case style for class 
member 'ClassMember_2'
 // CHECK-FIXES: {{^}}static int ClassMember2;{{$}}
 };
+class my_class;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 
'my_class'
+// CHECK-FIXES: {{^}}class CMyClass;{{$}}
+
+class my_forward_declared_class; // No warning should be triggered.
 
 const int my_class::classConstant = 4;
 // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: invalid case style for class 
constant 'classConstant'


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


[PATCH] D26207: [ClangTidy - performance-unnecessary-value-param] Only add "const" when current parameter is not already const qualified

2016-11-03 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.



Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:242
+// Case where parameter in declaration is already const-qualified but not in
+// implementation. Make sure a second 'const' is not added to the declaration.
+void PositiveConstDeclaration(const ExpensiveToCopyType A);

flx wrote:
> aaron.ballman wrote:
> > flx wrote:
> > > aaron.ballman wrote:
> > > > This comment doesn't really match the test cases. The original code has 
> > > > two *different* declarations (only one of which is a definition), not 
> > > > one declaration and one redeclaration with the definition.
> > > > 
> > > > I think what is really happening is that it is adding the `&` qualifier 
> > > > to the first declaration, and adding the `const` and `&` qualifiers to 
> > > > the second declaration, and the result is that you get harmonization. 
> > > > But it brings up a question to me; what happens with:
> > > > ```
> > > > void f1(ExpensiveToCopyType A) {
> > > > }
> > > > 
> > > > void f1(const ExpensiveToCopyType A) {
> > > > 
> > > > }
> > > > ```
> > > > Does the fix-it try to create two definitions of the same function?
> > > Good catch. I added the reverse case as well and modified the check 
> > > slightly to make that case work as well.
> > Can you add a test like this as well?
> > ```
> > void f1(ExpensiveToCopyType A); // Declared, not defined
> > 
> > void f1(const ExpensiveToCopyType A) {}
> > void f1(const ExpensiveToCopyType ) {}
> > ```
> > I'm trying to make sure this check does not suggest a fixit that breaks 
> > existing code because of overload sets. I would expect a diagnostic for the 
> > first two declarations, but no fixit suggestion for `void f1(const 
> > ExpensiveToCopyType A)` because that would result in an ambiguous function 
> > definition.
> The current code suggests the following fixes:
> 
> -void f1(ExpensiveToCopyType A); // Declared, not defined
> +void f1(const ExpensiveToCopyType& A); // Declared, not defined
>  
> -void f1(const ExpensiveToCopyType A) {}
> +void f1(const ExpensiveToCopyType& A) {}
>  void f1(const ExpensiveToCopyType ) {}
> 
> and we get a warning message for the void f1(const ExpensiveToCopyType A) {}
> 
> I think the compiler sees "void f1(const ExpensiveToCopyType A) {}" as 
> definition of "void f1(ExpensiveToCopyType A); // Declared, not defined" and 
> thus both places get fixed.
> 
> Since the check is catching cases where the value argument is either modified 
> or could be moved it and this is not the case here it is worth raising this 
> issue of what looks like a very subtle difference in overrides.
> 
> My inclination is to leave this as is. What do you suggest we do?
> 
I think this behavior isn't new with your changes, so we can leave it as is. 
However, we should file a bug report about the bad behavior with overload sets 
(and provide the example that's failing) so that we don't forget to come back 
and fix the functionality.


Repository:
  rL LLVM

https://reviews.llvm.org/D26207



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


[PATCH] D26279: [clang-tidy] Handle data() in readability-redundant-string-cstr

2016-11-03 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285901: [clang-tidy] Handle data() in 
readability-redundant-string-cstr (authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26279?vs=76848=76851#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26279

Files:
  clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst
  
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
  clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr.cpp

Index: clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -99,7 +99,7 @@
   const auto StringCStrCallExpr =
   cxxMemberCallExpr(on(StringExpr.bind("arg")),
 callee(memberExpr().bind("member")),
-callee(cxxMethodDecl(hasName("c_str"
+callee(cxxMethodDecl(hasAnyName("c_str", "data"
   .bind("call");
 
   // Detect redundant 'c_str()' calls through a string constructor.
@@ -192,15 +192,17 @@
 void RedundantStringCStrCheck::check(const MatchFinder::MatchResult ) {
   const auto *Call = Result.Nodes.getStmtAs("call");
   const auto *Arg = Result.Nodes.getStmtAs("arg");
-  bool Arrow = Result.Nodes.getStmtAs("member")->isArrow();
+  const auto *Member = Result.Nodes.getStmtAs("member");
+  bool Arrow = Member->isArrow();
   // Replace the "call" node with the "arg" node, prefixed with '*'
   // if the call was using '->' rather than '.'.
   std::string ArgText =
   Arrow ? formatDereference(Result, *Arg) : getText(Result, *Arg).str();
   if (ArgText.empty())
 return;
 
-  diag(Call->getLocStart(), "redundant call to `c_str()`")
+  diag(Call->getLocStart(), "redundant call to %0")
+  << Member->getMemberDecl()
   << FixItHint::CreateReplacement(Call->getSourceRange(), ArgText);
 }
 
Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -134,6 +134,10 @@
   Flags member initializations that are unnecessary because the same default
   constructor would be called if they were not present.
 
+- The `readability-redundant-string-cstr
+  `_ check
+  now warns about redundant calls to data() too.
+
 Fixed bugs:
 
 - `modernize-make-unique
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst
@@ -4,4 +4,4 @@
 =
 
 
-Finds unnecessary calls to ``std::string::c_str()``.
+Finds unnecessary calls to ``std::string::c_str()`` and ``std::string::data()``.
Index: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
@@ -12,6 +12,7 @@
   basic_string(const C *p);
   basic_string(const C *p, const A );
   const C *c_str() const;
+  const C *data() const;
 };
 typedef basic_string string;
 }
@@ -24,7 +25,10 @@
 
 void f1(const std::string ) {
   f1(s.c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}f1(s);{{$}}
+  f1(s.data());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'data' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}f1(s);{{$}}
 }
 void f2(const llvm::StringRef r) {
Index: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr.cpp
@@ -16,6 +16,7 @@
   basic_string(const C *p, const A  = A());
 
   const C *c_str() const;
+  const C *data() const;
 
   _Type& append(const C *s);
   _Type& append(const C *s, 

[clang-tools-extra] r285901 - [clang-tidy] Handle data() in readability-redundant-string-cstr

2016-11-03 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Nov  3 07:56:48 2016
New Revision: 285901

URL: http://llvm.org/viewvc/llvm-project?rev=285901=rev
Log:
[clang-tidy] Handle data() in readability-redundant-string-cstr

Summary:
std::string::data() and std::string::c_str() are equivalent.
Enhance the readability-redundant-string-cstr check to also handle
calls to data().

Reviewers: etienneb, alexfh, aaron.ballman

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp?rev=285901=285900=285901=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/RedundantStringCStrCheck.cpp 
Thu Nov  3 07:56:48 2016
@@ -99,7 +99,7 @@ void RedundantStringCStrCheck::registerM
   const auto StringCStrCallExpr =
   cxxMemberCallExpr(on(StringExpr.bind("arg")),
 callee(memberExpr().bind("member")),
-callee(cxxMethodDecl(hasName("c_str"
+callee(cxxMethodDecl(hasAnyName("c_str", "data"
   .bind("call");
 
   // Detect redundant 'c_str()' calls through a string constructor.
@@ -192,7 +192,8 @@ void RedundantStringCStrCheck::registerM
 void RedundantStringCStrCheck::check(const MatchFinder::MatchResult ) {
   const auto *Call = Result.Nodes.getStmtAs("call");
   const auto *Arg = Result.Nodes.getStmtAs("arg");
-  bool Arrow = Result.Nodes.getStmtAs("member")->isArrow();
+  const auto *Member = Result.Nodes.getStmtAs("member");
+  bool Arrow = Member->isArrow();
   // Replace the "call" node with the "arg" node, prefixed with '*'
   // if the call was using '->' rather than '.'.
   std::string ArgText =
@@ -200,7 +201,8 @@ void RedundantStringCStrCheck::check(con
   if (ArgText.empty())
 return;
 
-  diag(Call->getLocStart(), "redundant call to `c_str()`")
+  diag(Call->getLocStart(), "redundant call to %0")
+  << Member->getMemberDecl()
   << FixItHint::CreateReplacement(Call->getSourceRange(), ArgText);
 }
 

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=285901=285900=285901=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu Nov  3 07:56:48 2016
@@ -134,6 +134,10 @@ Improvements to clang-tidy
   Flags member initializations that are unnecessary because the same default
   constructor would be called if they were not present.
 
+- The `readability-redundant-string-cstr
+  
`_
 check
+  now warns about redundant calls to data() too.
+
 Fixed bugs:
 
 - `modernize-make-unique

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst?rev=285901=285900=285901=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-redundant-string-cstr.rst
 Thu Nov  3 07:56:48 2016
@@ -4,4 +4,4 @@ readability-redundant-string-cstr
 =
 
 
-Finds unnecessary calls to ``std::string::c_str()``.
+Finds unnecessary calls to ``std::string::c_str()`` and 
``std::string::data()``.

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp?rev=285901=285900=285901=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
 Thu Nov  3 07:56:48 2016
@@ -12,6 +12,7 @@ struct basic_string {
   basic_string(const C *p);
   basic_string(const C *p, const A );
   const C *c_str() const;
+  const C *data() 

[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-11-03 Thread Alpha Abdoulaye via cfe-commits
Alpha updated this revision to Diff 76850.
Alpha added a comment.

Remove debug symbols.


Repository:
  rL LLVM

https://reviews.llvm.org/D26137

Files:
  include/clang/Tooling/Core/Diagnostic.h
  include/clang/Tooling/DiagnosticsYaml.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Diagnostic.cpp
  
tools/extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  tools/extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  tools/extra/clang-tidy/ClangTidy.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h

Index: lib/Tooling/Core/Diagnostic.cpp
===
--- lib/Tooling/Core/Diagnostic.cpp
+++ lib/Tooling/Core/Diagnostic.cpp
@@ -0,0 +1,43 @@
+//===--- Diagnostic.cpp - Framework for clang diagnostics tools --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Implements classes to support/store diagnostics refactoring.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+namespace tooling {
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message)
+: Message(Message), FileOffset(0) {}
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message,
+ const SourceManager ,
+ SourceLocation Loc)
+: Message(Message) {
+  assert(Loc.isValid() && Loc.isFileID());
+  FilePath = Sources.getFilename(Loc);
+  FileOffset = Sources.getFileOffset(Loc);
+}
+
+Diagnostic::Diagnostic(llvm::StringRef CheckName, Diagnostic::Level DiagLevel)
+: CheckName(CheckName), DiagLevel(DiagLevel) {}
+
+Diagnostic::Diagnostic(llvm::StringRef CheckName, DiagnosticMessage ,
+   llvm::StringMap ,
+   SmallVector ,
+   Level DiagLevel)
+: CheckName(CheckName), Message(Message), Fix(Fix), Notes(Notes),
+  DiagLevel(DiagLevel) {}
+
+} // end namespace tooling
+} // end namespace clang
Index: lib/Tooling/Core/CMakeLists.txt
===
--- lib/Tooling/Core/CMakeLists.txt
+++ lib/Tooling/Core/CMakeLists.txt
@@ -4,6 +4,7 @@
   Lookup.cpp
   Replacement.cpp
   QualTypeNames.cpp
+  Diagnostic.cpp
 
   LINK_LIBS
   clangAST
Index: include/clang/Tooling/DiagnosticsYaml.h
===
--- include/clang/Tooling/DiagnosticsYaml.h
+++ include/clang/Tooling/DiagnosticsYaml.h
@@ -0,0 +1,77 @@
+//===-- DiagnosticsYaml.h -- Serialiazation for Diagnosticss ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file defines the structure of a YAML document for serializing
+/// diagnostics.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_DIAGNOSTICSYAML_H
+#define LLVM_CLANG_TOOLING_DIAGNOSTICSYAML_H
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Tooling/ReplacementsYaml.h"
+#include "llvm/Support/YAMLTraits.h"
+#include 
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(clang::tooling::Diagnostic)
+
+namespace llvm {
+namespace yaml {
+
+template <> struct MappingTraits {
+  /// \brief Helper to (de)serialize a Diagnostic since we don't have direct
+  /// access to its data members.
+  class NormalizedDiagnostic {
+  public:
+NormalizedDiagnostic(const IO &)
+: CheckName(""), Message(), Fix(), Notes(), DiagLevel() {}
+
+NormalizedDiagnostic(const IO &, const clang::tooling::Diagnostic )
+: CheckName(D.CheckName), Message(Message), Fix(D.Fix), Notes(D.Notes),
+  DiagLevel(D.DiagLevel) {}
+
+clang::tooling::Diagnostic denormalize(const IO &) {
+  return clang::tooling::Diagnostic(CheckName, Message, Fix, Notes,
+DiagLevel);
+}
+
+std::string CheckName;
+clang::tooling::DiagnosticMessage Message;
+llvm::StringMap Fix;
+SmallVector Notes;
+clang::tooling::Diagnostic::Level DiagLevel;
+  };
+
+  static void mapping(IO , clang::tooling::Diagnostic ) {
+MappingNormalization Keys(
+Io, D);
+Io.mapRequired("CheckName", 

[PATCH] D26271: [PPC} add extract significand/ extract exponent/test data class for vector float and vector double -- clang portion

2016-11-03 Thread Sean Fertile via cfe-commits
sfertile added inline comments.



Comment at: lib/Headers/altivec.h:15629
+#define vec_test_data_class(__a, __b)  \
+_Generic((__a),\
+   vector float:   \

nemanjai wrote:
> I don't know what happens if the type of the first argument is neither of the 
> two types, but I think we should verify that something sane happens. Namely, 
> some sort of overload resolution error message. 
We do get a decent error diagnostic:

test_data_class_bad.c:9:26: error: controlling expression type '__vector 
unsigned char' (vector of 16 'unsigned char' values) not compatible with any 
generic association type
vector bool int res_f = vec_test_data_class(vfa, 4);
^~~
/home/sfertile/LLVM/publish/assert/bin/../lib/clang/4.0.0/include/altivec.h:15629:18:
 note: expanded from macro 'vec_test_data_class'
_Generic((__a),\
 ^
1 error generated.



Repository:
  rL LLVM

https://reviews.llvm.org/D26271



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


[PATCH] D26137: [clang-tidy] Add check name to YAML export

2016-11-03 Thread Alpha Abdoulaye via cfe-commits
Alpha removed rL LLVM as the repository for this revision.
Alpha updated this revision to Diff 76849.
Alpha added a comment.

Fix diagnostic deserialization bug for clang-apply-replacement.


https://reviews.llvm.org/D26137

Files:
  include/clang/Tooling/Core/Diagnostic.h
  include/clang/Tooling/DiagnosticsYaml.h
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/Diagnostic.cpp
  
tools/extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h
  tools/extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp
  tools/extra/clang-apply-replacements/tool/ClangApplyReplacementsMain.cpp
  tools/extra/clang-tidy/ClangTidy.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  tools/extra/clang-tidy/ClangTidyDiagnosticConsumer.h

Index: lib/Tooling/Core/Diagnostic.cpp
===
--- lib/Tooling/Core/Diagnostic.cpp
+++ lib/Tooling/Core/Diagnostic.cpp
@@ -0,0 +1,43 @@
+//===--- Diagnostic.cpp - Framework for clang diagnostics tools --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+//  Implements classes to support/store diagnostics refactoring.
+//
+//===--===//
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+namespace tooling {
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message)
+: Message(Message), FileOffset(0) {}
+
+DiagnosticMessage::DiagnosticMessage(llvm::StringRef Message,
+ const SourceManager ,
+ SourceLocation Loc)
+: Message(Message) {
+  assert(Loc.isValid() && Loc.isFileID());
+  FilePath = Sources.getFilename(Loc);
+  FileOffset = Sources.getFileOffset(Loc);
+}
+
+Diagnostic::Diagnostic(llvm::StringRef CheckName, Diagnostic::Level DiagLevel)
+: CheckName(CheckName), DiagLevel(DiagLevel) {}
+
+Diagnostic::Diagnostic(llvm::StringRef CheckName, DiagnosticMessage ,
+   llvm::StringMap ,
+   SmallVector ,
+   Level DiagLevel)
+: CheckName(CheckName), Message(Message), Fix(Fix), Notes(Notes),
+  DiagLevel(DiagLevel) {}
+
+} // end namespace tooling
+} // end namespace clang
Index: lib/Tooling/Core/CMakeLists.txt
===
--- lib/Tooling/Core/CMakeLists.txt
+++ lib/Tooling/Core/CMakeLists.txt
@@ -4,6 +4,7 @@
   Lookup.cpp
   Replacement.cpp
   QualTypeNames.cpp
+  Diagnostic.cpp
 
   LINK_LIBS
   clangAST
Index: include/clang/Tooling/DiagnosticsYaml.h
===
--- include/clang/Tooling/DiagnosticsYaml.h
+++ include/clang/Tooling/DiagnosticsYaml.h
@@ -0,0 +1,77 @@
+//===-- DiagnosticsYaml.h -- Serialiazation for Diagnosticss ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// \brief This file defines the structure of a YAML document for serializing
+/// diagnostics.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_DIAGNOSTICSYAML_H
+#define LLVM_CLANG_TOOLING_DIAGNOSTICSYAML_H
+
+#include "clang/Tooling/Core/Diagnostic.h"
+#include "clang/Tooling/ReplacementsYaml.h"
+#include "llvm/Support/YAMLTraits.h"
+#include 
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(clang::tooling::Diagnostic)
+
+namespace llvm {
+namespace yaml {
+
+template <> struct MappingTraits {
+  /// \brief Helper to (de)serialize a Diagnostic since we don't have direct
+  /// access to its data members.
+  class NormalizedDiagnostic {
+  public:
+NormalizedDiagnostic(const IO &)
+: CheckName(""), Message(), Fix(), Notes(), DiagLevel() {}
+
+NormalizedDiagnostic(const IO &, const clang::tooling::Diagnostic )
+: CheckName(D.CheckName), Message(Message), Fix(D.Fix), Notes(D.Notes),
+  DiagLevel(D.DiagLevel) {}
+
+clang::tooling::Diagnostic denormalize(const IO &) {
+  return clang::tooling::Diagnostic(CheckName, Message, Fix, Notes,
+DiagLevel);
+}
+
+std::string CheckName;
+clang::tooling::DiagnosticMessage Message;
+llvm::StringMap Fix;
+SmallVector Notes;
+clang::tooling::Diagnostic::Level DiagLevel;
+  };
+
+  static void mapping(IO , clang::tooling::Diagnostic ) {
+MappingNormalization

Re: RE: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.

2016-11-03 Thread Samuel F Antao via cfe-commits
Hi Jonas,
 
Thanks for the quotes. I'll rename one of the versions of ConstructJob to make the problem disappear. I'll post a patch soon.
 
Thanks again,
Samuel 
 
- Original message -From: "Hahnfeld, Jonas" To: "Hahnfeld, Jonas" , Samuel F Antao/Watson/IBM@IBMUSCc: "cfe-commits@lists.llvm.org" Subject: RE: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.Date: Thu, Nov 3, 2016 12:36 PM 
From C++14:
 
3.4.1 Unqualified name lookup, (1):
“In all the cases listed in 3.4.1, the scopes are searched for a declaration in the order listed in each of the respective categories; name lookup ends as soon as a declaration is found for the name. If no declaration is found, the program is ill-formed.”
 
I assume that “the order listed in each of the respective categories” for method lookup means “from derived to base classes” (though I haven’t looked this up…)
 
 
3.4 Name lookup, (1):
“[…]Only after name lookup, function overload resolution (if applicable) and access checking have succeeded are the attributes introduced by the name’s declaration used further in _expression_ processing (Clause 5). […]”
 
I think this means that the compiler will for example find clang::driver::tools::Clang::ConstructJob but is not allowed to use clang::driver::Tool::ConstructJob as a resolution unless “using Tool::ConstructJob;” is specified.
 
Cheers,
Jonas
 
From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of Hahnfeld, Jonas via cfe-commitsSent: Thursday, November 03, 2016 1:11 PMTo: Samuel F AntaoCc: cfe-commits@lists.llvm.orgSubject: RE: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.
 
Hi Samuel,
 
if we trust StackOverflow, the code is wrong because all functions with the same name are hidden, ignoring the rest of the signature. I will try to find the corresponding section in the C++ standard…
 
I think any version of GCC gives the error, I was able to reproduce this with the attached small code:$ g++ --version
g++ (GCC) 6.2.0
[…]
$ g++ -Woverloaded-virtual virtual-name-hiding.cpp -o virtual-name-hiding.exe
virtual-name-hiding.cpp:2:16: warning: ‘virtual void Base::test(const long int&)’ was hidden [-Woverloaded-virtual]
   virtual void test(const long );
    ^~~~
virtual-name-hiding.cpp:7:16: warning:   by ‘virtual void Child::test(const int&)’ [-Woverloaded-virtual]
   virtual void test(const int ) override { };
    ^~~~
 
Regards,
Jonas
 
From: Samuel F Antao [mailto:sfan...@us.ibm.com]Sent: Thursday, November 03, 2016 1:04 PMTo: Hahnfeld, JonasCc: cfe-commits@lists.llvm.org; gkistan...@gmail.comSubject: Re: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.
 
Hi Jonas,
 
I think that the code is correct. Is probably some bug in the compiler. We are not hiding anything - the compiler is checking against the wrong virtual function (using the wrong signature).
 
I am in process to compile the same version of gcc the bot is using to see if there is any massagin in the code that can be done to silence that.
 
Thanks!
Samuel
 
- Original message -From: "Hahnfeld, Jonas" To: Galina Kistanova , Samuel F Antao/Watson/IBM@IBMUSCc: "cfe-commits@lists.llvm.org" Subject: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.Date: Thu, Nov 3, 2016 11:53 AM 
Hi,
 
I think I have identified what is the problem here: the so-called “name hiding” when overloading virtual functions. (see http://stackoverflow.com/a/1629074)
To fix it, I see two possible solutions: Either apply the attached patch or rename one method so that the hiding does not happen.
 
Finally: Why didn’t the other bots point to this problem?!?
 
Cheers,
Jonas
 
From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of Galina Kistanova via cfe-commitsSent: Tuesday, November 01, 2016 7:29 PMTo: Samuel F AntaoCc: cfe-commitsSubject: Re: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.
 
http://lab.llvm.org:8011/builders/clang-3stage-ubuntu/builds/128/steps/cmake-configure/logs/stdio-- The C compiler identification is GNU 4.8.4-- The CXX compiler identification is GNU 4.8.4The code itself seems fine. The similar builder that uses the ToT Clang does not generate any warnings.http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/107​ThanksGalina
 
On Mon, Oct 31, 2016 at 6:26 PM, Samuel F Antao  wrote:
Hi Galina,
 
Thanks for letting me know. Can you tell me which compiler (kind and version) is used in the buildbot slave? Looks like that compiler is not doing what it should, so I need to be able to test a workaround.
 
We have  
 
virtual void ConstructJob(Compilation , const JobAction ,                            const InputInfo ,                            const 

[PATCH] D26279: [clang-tidy] Handle data() in readability-redundant-string-cstr

2016-11-03 Thread Malcolm Parsons via cfe-commits
malcolm.parsons updated this revision to Diff 76848.
malcolm.parsons added a comment.

Add to release notes.
Add to documentation of check.


https://reviews.llvm.org/D26279

Files:
  clang-tidy/readability/RedundantStringCStrCheck.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-redundant-string-cstr.rst
  test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
  test/clang-tidy/readability-redundant-string-cstr.cpp

Index: test/clang-tidy/readability-redundant-string-cstr.cpp
===
--- test/clang-tidy/readability-redundant-string-cstr.cpp
+++ test/clang-tidy/readability-redundant-string-cstr.cpp
@@ -16,6 +16,7 @@
   basic_string(const C *p, const A  = A());
 
   const C *c_str() const;
+  const C *data() const;
 
   _Type& append(const C *s);
   _Type& append(const C *s, size n);
@@ -66,7 +67,10 @@
 
 void f1(const std::string ) {
   f1(s.c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}f1(s);{{$}}
+  f1(s.data());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'data' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}f1(s);{{$}}
 }
 void f2(const llvm::StringRef r) {
@@ -86,7 +90,7 @@
 void f4(const std::string ) {
   const std::string* ptr = 
   f1(ptr->c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}f1(*ptr);{{$}}
 }
 void f5(const std::string ) {
@@ -168,23 +172,23 @@
 
 void g1(const std::wstring ) {
   g1(s.c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}g1(s);{{$}}
 }
 
 // Tests for std::u16string.
 
 void h1(const std::u16string ) {
   h1(s.c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}h1(s);{{$}}
 }
 
 // Tests for std::u32string.
 
 void k1(const std::u32string ) {
   k1(s.c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}k1(s);{{$}}
 }
 
Index: test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
===
--- test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
+++ test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
@@ -12,6 +12,7 @@
   basic_string(const C *p);
   basic_string(const C *p, const A );
   const C *c_str() const;
+  const C *data() const;
 };
 typedef basic_string string;
 }
@@ -24,7 +25,10 @@
 
 void f1(const std::string ) {
   f1(s.c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}f1(s);{{$}}
+  f1(s.data());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'data' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}f1(s);{{$}}
 }
 void f2(const llvm::StringRef r) {
Index: docs/clang-tidy/checks/readability-redundant-string-cstr.rst
===
--- docs/clang-tidy/checks/readability-redundant-string-cstr.rst
+++ docs/clang-tidy/checks/readability-redundant-string-cstr.rst
@@ -4,4 +4,4 @@
 =
 
 
-Finds unnecessary calls to ``std::string::c_str()``.
+Finds unnecessary calls to ``std::string::c_str()`` and ``std::string::data()``.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -134,6 +134,10 @@
   Flags member initializations that are unnecessary because the same default
   constructor would be called if they were not present.
 
+- The `readability-redundant-string-cstr
+  `_ check
+  now warns about redundant calls to data() too.
+
 Fixed bugs:
 
 - `modernize-make-unique
Index: clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- 

[PATCH] D26279: [clang-tidy] Handle data() in readability-redundant-string-cstr

2016-11-03 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

In https://reviews.llvm.org/D26279#586641, @aaron.ballman wrote:

> I like the idea, but would point out that `data()` and `c_str()` had 
> different semantics once upon a time.


I'm aware of this, but it doesn't affect whether the call is redundant.


https://reviews.llvm.org/D26279



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


[PATCH] D26279: [clang-tidy] Handle data() in readability-redundant-string-cstr

2016-11-03 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!

I like the idea, but would point out that `data()` and `c_str()` had different 
semantics once upon a time. In c++03 and earlier, `data()` was not guaranteed 
to be null terminated, but`c_str()` was. However, I'm not certain that's worth 
altering the behavior of this check for; I don't think any implementation 
actually made that distinction in practice.


https://reviews.llvm.org/D26279



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


[PATCH] D26276: Remove redundant calls to std::string::data()

2016-11-03 Thread Malcolm Parsons via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285899: Remove redundant calls to std::string::data() 
(authored by malcolm.parsons).

Changed prior to commit:
  https://reviews.llvm.org/D26276?vs=76835=76846#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26276

Files:
  cfe/trunk/lib/Parse/ParseObjc.cpp
  cfe/trunk/lib/Tooling/Core/Replacement.cpp


Index: cfe/trunk/lib/Tooling/Core/Replacement.cpp
===
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp
@@ -569,7 +569,7 @@
 const std::map ) {
   std::map Result;
   for (const auto  : FileToReplaces) {
-llvm::SmallString<256> CleanPath(Entry.first.data());
+llvm::SmallString<256> CleanPath(Entry.first);
 llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
 Result[CleanPath.str()] = std::move(Entry.second);
   }
Index: cfe/trunk/lib/Parse/ParseObjc.cpp
===
--- cfe/trunk/lib/Parse/ParseObjc.cpp
+++ cfe/trunk/lib/Parse/ParseObjc.cpp
@@ -1036,7 +1036,7 @@
   case tok::caretequal: {
 std::string ThisTok(PP.getSpelling(Tok));
 if (isLetter(ThisTok[0])) {
-  IdentifierInfo *II = ().get(ThisTok.data());
+  IdentifierInfo *II = ().get(ThisTok);
   Tok.setKind(tok::identifier);
   SelectorLoc = ConsumeToken();
   return II;


Index: cfe/trunk/lib/Tooling/Core/Replacement.cpp
===
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp
@@ -569,7 +569,7 @@
 const std::map ) {
   std::map Result;
   for (const auto  : FileToReplaces) {
-llvm::SmallString<256> CleanPath(Entry.first.data());
+llvm::SmallString<256> CleanPath(Entry.first);
 llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
 Result[CleanPath.str()] = std::move(Entry.second);
   }
Index: cfe/trunk/lib/Parse/ParseObjc.cpp
===
--- cfe/trunk/lib/Parse/ParseObjc.cpp
+++ cfe/trunk/lib/Parse/ParseObjc.cpp
@@ -1036,7 +1036,7 @@
   case tok::caretequal: {
 std::string ThisTok(PP.getSpelling(Tok));
 if (isLetter(ThisTok[0])) {
-  IdentifierInfo *II = ().get(ThisTok.data());
+  IdentifierInfo *II = ().get(ThisTok);
   Tok.setKind(tok::identifier);
   SelectorLoc = ConsumeToken();
   return II;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285899 - Remove redundant calls to std::string::data()

2016-11-03 Thread Malcolm Parsons via cfe-commits
Author: malcolm.parsons
Date: Thu Nov  3 07:25:51 2016
New Revision: 285899

URL: http://llvm.org/viewvc/llvm-project?rev=285899=rev
Log:
Remove redundant calls to std::string::data()

Reviewers: aaron.ballman, mehdi_amini, dblaikie

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Parse/ParseObjc.cpp
cfe/trunk/lib/Tooling/Core/Replacement.cpp

Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=285899=285898=285899=diff
==
--- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
+++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Nov  3 07:25:51 2016
@@ -1036,7 +1036,7 @@ IdentifierInfo *Parser::ParseObjCSelecto
   case tok::caretequal: {
 std::string ThisTok(PP.getSpelling(Tok));
 if (isLetter(ThisTok[0])) {
-  IdentifierInfo *II = ().get(ThisTok.data());
+  IdentifierInfo *II = ().get(ThisTok);
   Tok.setKind(tok::identifier);
   SelectorLoc = ConsumeToken();
   return II;

Modified: cfe/trunk/lib/Tooling/Core/Replacement.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Core/Replacement.cpp?rev=285899=285898=285899=diff
==
--- cfe/trunk/lib/Tooling/Core/Replacement.cpp (original)
+++ cfe/trunk/lib/Tooling/Core/Replacement.cpp Thu Nov  3 07:25:51 2016
@@ -569,7 +569,7 @@ std::map grou
 const std::map ) {
   std::map Result;
   for (const auto  : FileToReplaces) {
-llvm::SmallString<256> CleanPath(Entry.first.data());
+llvm::SmallString<256> CleanPath(Entry.first);
 llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
 Result[CleanPath.str()] = std::move(Entry.second);
   }


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


[PATCH] D26279: [clang-tidy] Handle data() in readability-redundant-string-cstr

2016-11-03 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: etienneb, alexfh, aaron.ballman.
malcolm.parsons added a subscriber: cfe-commits.

std::string::data() and std::string::c_str() are equivalent.
Enhance the readability-redundant-string-cstr check to also handle
calls to data().


https://reviews.llvm.org/D26279

Files:
  clang-tidy/readability/RedundantStringCStrCheck.cpp
  test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
  test/clang-tidy/readability-redundant-string-cstr.cpp

Index: test/clang-tidy/readability-redundant-string-cstr.cpp
===
--- test/clang-tidy/readability-redundant-string-cstr.cpp
+++ test/clang-tidy/readability-redundant-string-cstr.cpp
@@ -16,6 +16,7 @@
   basic_string(const C *p, const A  = A());
 
   const C *c_str() const;
+  const C *data() const;
 
   _Type& append(const C *s);
   _Type& append(const C *s, size n);
@@ -66,7 +67,10 @@
 
 void f1(const std::string ) {
   f1(s.c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}f1(s);{{$}}
+  f1(s.data());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'data' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}f1(s);{{$}}
 }
 void f2(const llvm::StringRef r) {
@@ -86,7 +90,7 @@
 void f4(const std::string ) {
   const std::string* ptr = 
   f1(ptr->c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}f1(*ptr);{{$}}
 }
 void f5(const std::string ) {
@@ -168,23 +172,23 @@
 
 void g1(const std::wstring ) {
   g1(s.c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}g1(s);{{$}}
 }
 
 // Tests for std::u16string.
 
 void h1(const std::u16string ) {
   h1(s.c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}h1(s);{{$}}
 }
 
 // Tests for std::u32string.
 
 void k1(const std::u32string ) {
   k1(s.c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}k1(s);{{$}}
 }
 
Index: test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
===
--- test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
+++ test/clang-tidy/readability-redundant-string-cstr-msvc.cpp
@@ -12,6 +12,7 @@
   basic_string(const C *p);
   basic_string(const C *p, const A );
   const C *c_str() const;
+  const C *data() const;
 };
 typedef basic_string string;
 }
@@ -24,7 +25,10 @@
 
 void f1(const std::string ) {
   f1(s.c_str());
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to `c_str()` [readability-redundant-string-cstr]
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'c_str' [readability-redundant-string-cstr]
+  // CHECK-FIXES: {{^  }}f1(s);{{$}}
+  f1(s.data());
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant call to 'data' [readability-redundant-string-cstr]
   // CHECK-FIXES: {{^  }}f1(s);{{$}}
 }
 void f2(const llvm::StringRef r) {
Index: clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -99,7 +99,7 @@
   const auto StringCStrCallExpr =
   cxxMemberCallExpr(on(StringExpr.bind("arg")),
 callee(memberExpr().bind("member")),
-callee(cxxMethodDecl(hasName("c_str"
+callee(cxxMethodDecl(hasAnyName("c_str", "data"
   .bind("call");
 
   // Detect redundant 'c_str()' calls through a string constructor.
@@ -192,15 +192,17 @@
 void RedundantStringCStrCheck::check(const MatchFinder::MatchResult ) {
   const auto *Call = Result.Nodes.getStmtAs("call");
   const auto *Arg = Result.Nodes.getStmtAs("arg");
-  bool Arrow = Result.Nodes.getStmtAs("member")->isArrow();
+  const auto *Member = Result.Nodes.getStmtAs("member");
+  bool Arrow = Member->isArrow();
   // Replace the "call" node with the "arg" node, prefixed with '*'
   // if the call 

[PATCH] D26276: Remove redundant calls to std::string::data()

2016-11-03 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


https://reviews.llvm.org/D26276



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


RE: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.

2016-11-03 Thread Hahnfeld, Jonas via cfe-commits
Hi Samuel,

 

if we trust StackOverflow, the code is wrong because all functions with the 
same name are hidden, ignoring the rest of the signature. I will try to find 
the corresponding section in the C++ standard…

 

I think any version of GCC gives the error, I was able to reproduce this with 
the attached small code:
$ g++ --version

g++ (GCC) 6.2.0

[…]

$ g++ -Woverloaded-virtual virtual-name-hiding.cpp -o virtual-name-hiding.exe

virtual-name-hiding.cpp:2:16: warning: ‘virtual void Base::test(const long 
int&)’ was hidden [-Woverloaded-virtual]

   virtual void test(const long );

^~~~

virtual-name-hiding.cpp:7:16: warning:   by ‘virtual void Child::test(const 
int&)’ [-Woverloaded-virtual]

   virtual void test(const int ) override { };

^~~~

 

Regards,

Jonas

 

From: Samuel F Antao [mailto:sfan...@us.ibm.com] 
Sent: Thursday, November 03, 2016 1:04 PM
To: Hahnfeld, Jonas
Cc: cfe-commits@lists.llvm.org; gkistan...@gmail.com
Subject: Re: RE: r285326 - [Driver][OpenMP] Add support to create jobs for 
unbundling actions.

 

Hi Jonas,

 

I think that the code is correct. Is probably some bug in the compiler. We are 
not hiding anything - the compiler is checking against the wrong virtual 
function (using the wrong signature).

 

I am in process to compile the same version of gcc the bot is using to see if 
there is any massagin in the code that can be done to silence that.

 

Thanks!

Samuel

 

- Original message -
From: "Hahnfeld, Jonas" 
To: Galina Kistanova , Samuel F Antao/Watson/IBM@IBMUS
Cc: "cfe-commits@lists.llvm.org" 
Subject: RE: r285326 - [Driver][OpenMP] Add support to create jobs for 
unbundling actions.
Date: Thu, Nov 3, 2016 11:53 AM
 

Hi,

 

I think I have identified what is the problem here: the so-called “name hiding” 
when overloading virtual functions. (see http://stackoverflow.com/a/1629074)

To fix it, I see two possible solutions: Either apply the attached patch or 
rename one method so that the hiding does not happen.

 

Finally: Why didn’t the other bots point to this problem?!?

 

Cheers,

Jonas

 

From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
Galina Kistanova via cfe-commits
Sent: Tuesday, November 01, 2016 7:29 PM
To: Samuel F Antao
Cc: cfe-commits
Subject: Re: r285326 - [Driver][OpenMP] Add support to create jobs for 
unbundling actions.

 

http://lab.llvm.org:8011/builders/clang-3stage-ubuntu/builds/128/steps/cmake-configure/logs/stdio

-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4

The code itself seems fine. The similar builder that uses the ToT Clang does 
not generate any warnings.
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/107​

Thanks

Galina

 

On Mon, Oct 31, 2016 at 6:26 PM, Samuel F Antao  wrote:

Hi Galina,

 

Thanks for letting me know. Can you tell me which compiler (kind and version) 
is used in the buildbot slave? Looks like that compiler is not doing what it 
should, so I need to be able to test a workaround.

 

We have  

 

virtual void ConstructJob(Compilation , const JobAction ,
const InputInfo ,
const InputInfoList ,
const llvm::opt::ArgList ,
const char *LinkingOutput) const = 0;

 

which is the signature of ConstructJob that should be overwritten, so we are 
not hiding anything. And in Action.cpp we have an unreachable statement, so no 
need for return. So, the code seems to be okay, but we can probably massage the 
code a little to silence the compiler you are using.

 

Thanks!

Samuel

 

- Original message -
From: Galina Kistanova 
To: Samuel F Antao/Watson/IBM@IBMUS
Cc: cfe-commits 
Subject: Re: r285326 - [Driver][OpenMP] Add support to create jobs for 
unbundling actions.
Date: Tue, Nov 1, 2016 12:59 AM
  

Hi Samuel,

Looks like this revision introduced warning to one of our builders:
http://lab.llvm.org:8011/builders/clang-3stage-ubuntu/builds/67/steps/build-stage3-clang/logs/warnings%20%28830%29

Please have a look at this?

Thanks

Galina

  

On Thu, Oct 27, 2016 at 11:14 AM, Samuel Antao via cfe-commits 
 wrote: 

Author: sfantao
Date: Thu Oct 27 13:14:55 2016
New Revision: 285326

URL: http://llvm.org/viewvc/llvm-project?rev=285326=rev
Log:
[Driver][OpenMP] Add support to create jobs for unbundling actions.

Summary:
This patch adds the support to create jobs for the `OffloadBundlingAction` 
which will invoke the `clang-offload-bundler` tool to unbundle input files.

Unlike other actions, unbundling actions have multiple outputs. Therefore, this 
patch adds the required changes to have a variant of `Tool::ConstructJob` with 
multiple outputs.

The way the naming of the results is 

Re: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.

2016-11-03 Thread Samuel F Antao via cfe-commits
Hi Jonas,
 
I think that the code is correct. Is probably some bug in the compiler. We are not hiding anything - the compiler is checking against the wrong virtual function (using the wrong signature).
 
I am in process to compile the same version of gcc the bot is using to see if there is any massagin in the code that can be done to silence that.
 
Thanks!
Samuel
 
- Original message -From: "Hahnfeld, Jonas" To: Galina Kistanova , Samuel F Antao/Watson/IBM@IBMUSCc: "cfe-commits@lists.llvm.org" Subject: RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.Date: Thu, Nov 3, 2016 11:53 AM 
Hi,
 
I think I have identified what is the problem here: the so-called “name hiding” when overloading virtual functions. (see http://stackoverflow.com/a/1629074)
To fix it, I see two possible solutions: Either apply the attached patch or rename one method so that the hiding does not happen.
 
Finally: Why didn’t the other bots point to this problem?!?
 
Cheers,
Jonas
 
From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of Galina Kistanova via cfe-commitsSent: Tuesday, November 01, 2016 7:29 PMTo: Samuel F AntaoCc: cfe-commitsSubject: Re: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.
 
http://lab.llvm.org:8011/builders/clang-3stage-ubuntu/builds/128/steps/cmake-configure/logs/stdio-- The C compiler identification is GNU 4.8.4-- The CXX compiler identification is GNU 4.8.4The code itself seems fine. The similar builder that uses the ToT Clang does not generate any warnings.http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/107​ThanksGalina
 
On Mon, Oct 31, 2016 at 6:26 PM, Samuel F Antao  wrote:
Hi Galina,
 
Thanks for letting me know. Can you tell me which compiler (kind and version) is used in the buildbot slave? Looks like that compiler is not doing what it should, so I need to be able to test a workaround.
 
We have  
 
virtual void ConstructJob(Compilation , const JobAction ,                            const InputInfo ,                            const InputInfoList ,                            const llvm::opt::ArgList ,                            const char *LinkingOutput) const = 0;
 
which is the signature of ConstructJob that should be overwritten, so we are not hiding anything. And in Action.cpp we have an unreachable statement, so no need for return. So, the code seems to be okay, but we can probably massage the code a little to silence the compiler you are using.
 
Thanks!
Samuel
 
- Original message -From: Galina Kistanova To: Samuel F Antao/Watson/IBM@IBMUSCc: cfe-commits Subject: Re: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.Date: Tue, Nov 1, 2016 12:59 AM  
Hi Samuel,Looks like this revision introduced warning to one of our builders:http://lab.llvm.org:8011/builders/clang-3stage-ubuntu/builds/67/steps/build-stage3-clang/logs/warnings%20%28830%29Please have a look at this?ThanksGalina
  
On Thu, Oct 27, 2016 at 11:14 AM, Samuel Antao via cfe-commits  wrote: 
Author: sfantaoDate: Thu Oct 27 13:14:55 2016New Revision: 285326URL: http://llvm.org/viewvc/llvm-project?rev=285326=revLog:[Driver][OpenMP] Add support to create jobs for unbundling actions.Summary:This patch adds the support to create jobs for the `OffloadBundlingAction` which will invoke the `clang-offload-bundler` tool to unbundle input files.Unlike other actions, unbundling actions have multiple outputs. Therefore, this patch adds the required changes to have a variant of `Tool::ConstructJob` with multiple outputs.The way the naming of the results is implemented is also slightly modified so that the same action can use a different offloading prefix for each use by the different offloading actions.With this patch, it is possible to compile a functional OpenMP binary with offloading support, even with separate compilation.Reviewers: echristo, tra, jlebar, ABataev, hfinkelSubscribers: mkuron, whchung, mehdi_amini, cfe-commits, Hahnfeld, andreybokhanko, arpith-jacob, carlo.bertolli, caomhinDifferential Revision: https://reviews.llvm.org/D21857Modified:    cfe/trunk/include/clang/Driver/Action.h    cfe/trunk/include/clang/Driver/Driver.h    cfe/trunk/include/clang/Driver/Tool.h    cfe/trunk/lib/Driver/Action.cpp    cfe/trunk/lib/Driver/Driver.cpp    cfe/trunk/lib/Driver/Tool.cpp    cfe/trunk/lib/Driver/Tools.cpp    cfe/trunk/lib/Driver/Tools.h    cfe/trunk/test/Driver/cuda-bindings.cu    cfe/trunk/test/Driver/openmp-offload.c    cfe/trunk/test/Driver/opt-record.cModified: cfe/trunk/include/clang/Driver/Action.hURL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=285326=285325=285326=diff==--- cfe/trunk/include/clang/Driver/Action.h 

RE: r285326 - [Driver][OpenMP] Add support to create jobs for unbundling actions.

2016-11-03 Thread Hahnfeld, Jonas via cfe-commits
Hi,

 

I think I have identified what is the problem here: the so-called “name hiding” 
when overloading virtual functions. (see http://stackoverflow.com/a/1629074)

To fix it, I see two possible solutions: Either apply the attached patch or 
rename one method so that the hiding does not happen.

 

Finally: Why didn’t the other bots point to this problem?!?

 

Cheers,

Jonas

 

From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
Galina Kistanova via cfe-commits
Sent: Tuesday, November 01, 2016 7:29 PM
To: Samuel F Antao
Cc: cfe-commits
Subject: Re: r285326 - [Driver][OpenMP] Add support to create jobs for 
unbundling actions.

 

http://lab.llvm.org:8011/builders/clang-3stage-ubuntu/builds/128/steps/cmake-configure/logs/stdio

-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4

The code itself seems fine. The similar builder that uses the ToT Clang does 
not generate any warnings.
http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/107​

Thanks

Galina

 

On Mon, Oct 31, 2016 at 6:26 PM, Samuel F Antao  wrote:

Hi Galina,

 

Thanks for letting me know. Can you tell me which compiler (kind and version) 
is used in the buildbot slave? Looks like that compiler is not doing what it 
should, so I need to be able to test a workaround.

 

We have  

 

virtual void ConstructJob(Compilation , const JobAction ,
const InputInfo ,
const InputInfoList ,
const llvm::opt::ArgList ,
const char *LinkingOutput) const = 0;

 

which is the signature of ConstructJob that should be overwritten, so we are 
not hiding anything. And in Action.cpp we have an unreachable statement, so no 
need for return. So, the code seems to be okay, but we can probably massage the 
code a little to silence the compiler you are using.

 

Thanks!

Samuel

 

- Original message -
From: Galina Kistanova 
To: Samuel F Antao/Watson/IBM@IBMUS
Cc: cfe-commits 
Subject: Re: r285326 - [Driver][OpenMP] Add support to create jobs for 
unbundling actions.
Date: Tue, Nov 1, 2016 12:59 AM
  

Hi Samuel,

Looks like this revision introduced warning to one of our builders:
http://lab.llvm.org:8011/builders/clang-3stage-ubuntu/builds/67/steps/build-stage3-clang/logs/warnings%20%28830%29

Please have a look at this?

Thanks

Galina

  

On Thu, Oct 27, 2016 at 11:14 AM, Samuel Antao via cfe-commits 
 wrote: 

Author: sfantao
Date: Thu Oct 27 13:14:55 2016
New Revision: 285326

URL: http://llvm.org/viewvc/llvm-project?rev=285326=rev
Log:
[Driver][OpenMP] Add support to create jobs for unbundling actions.

Summary:
This patch adds the support to create jobs for the `OffloadBundlingAction` 
which will invoke the `clang-offload-bundler` tool to unbundle input files.

Unlike other actions, unbundling actions have multiple outputs. Therefore, this 
patch adds the required changes to have a variant of `Tool::ConstructJob` with 
multiple outputs.

The way the naming of the results is implemented is also slightly modified so 
that the same action can use a different offloading prefix for each use by the 
different offloading actions.

With this patch, it is possible to compile a functional OpenMP binary with 
offloading support, even with separate compilation.

Reviewers: echristo, tra, jlebar, ABataev, hfinkel

Subscribers: mkuron, whchung, mehdi_amini, cfe-commits, Hahnfeld, 
andreybokhanko, arpith-jacob, carlo.bertolli, caomhin

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

Modified:
cfe/trunk/include/clang/Driver/Action.h
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/include/clang/Driver/Tool.h
cfe/trunk/lib/Driver/Action.cpp
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Tool.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/test/Driver/cuda-bindings.cu
cfe/trunk/test/Driver/openmp-offload.c
cfe/trunk/test/Driver/opt-record.c

Modified: cfe/trunk/include/clang/Driver/Action.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Action.h?rev=285326=285325=285326=diff
==
--- cfe/trunk/include/clang/Driver/Action.h (original)
+++ cfe/trunk/include/clang/Driver/Action.h Thu Oct 27 13:14:55 2016
@@ -157,9 +157,12 @@ public:
   /// Return a string containing the offload kind of the action.
   std::string getOffloadingKindPrefix() const;
   /// Return a string that can be used as prefix in order to generate unique
-  /// files for each offloading kind.
-  std::string
-  getOffloadingFileNamePrefix(llvm::StringRef NormalizedTriple) const;
+  /// files for each offloading kind. By default, no prefix is used for
+  /// non-device kinds, except if \a CreatePrefixForHost is set.
+  static 

[PATCH] D26278: Avoid -Wshadow warnings for shadowed variables that aren't captured by lambdas with an explicit capture list

2016-11-03 Thread Alex Lorenz via cfe-commits
arphaman created this revision.
arphaman added reviewers: rsmith, rnk.
arphaman added a subscriber: cfe-commits.
arphaman set the repository for this revision to rL LLVM.

This patch avoids the -Wshadow warning for variables which shadow variables 
that aren't captured by lambdas with an explicit capture list. It provides an 
additional note that points to location of the explicit capture.

I noticed that we have -Wshadow-all as well, but I wasn't sure how to preserve 
the old behaviour for it (since I don't think I can check if a diagnostic group 
is enabled), or if the old behaviour should be preserved at all. What do you 
think?

This patch fixes PR 21426, but I think that this is a partial fix, since that 
bug doesn't specify that the capture list should be explicit. I plan on working 
on a similar patch for lambdas with a default capture specifier and implicit 
variable captures, but I'm not sure it's 100% needed for them. Do you think 
this kind of change would make sense for implicit captures as well?


Repository:
  rL LLVM

https://reviews.llvm.org/D26278

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/warn-shadow-in-lambdas.cpp

Index: test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -Wshadow %s
+
+void foo(int param) { // expected-note 1+ {{previous declaration is here}}
+  int var = 0; // expected-note 1+ {{previous declaration is here}}
+
+  // Warn for lambdas with a default capture specifier.
+  {
+auto f1 = [=] { int var = 1; };  // expected-warning {{declaration shadows a local variable}}
+auto f2 = [&] { int var = 2; };  // expected-warning {{declaration shadows a local variable}}
+auto f3 = [=] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+auto f4 = [&] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  }
+
+  // Warn normally inside of lambdas.
+  auto l1 = [] { // expected-note {{previous declaration is here}}
+  int x = 1; // expected-note {{previous declaration is here}}
+  { int x = 2; } // expected-warning {{declaration shadows a local variable}}
+  };
+  auto l2 = [] (int x) { // expected-note {{previous declaration is here}}
+{ int x = 1; } // expected-warning {{declaration shadows a local variable}}
+  };
+
+  // Avoid warnings for variables that aren't explicitly captured.
+  {
+auto f1 = [] { int var = 1; }; // no warning
+auto f2 = [] (int param) { ; }; // no warning
+auto f3 = [param] () { int var = 1; }; // no warning
+auto f4 = [var] (int param) { ; }; // no warning
+  };
+
+  // Warn for variables that are explicitly captured.
+  {
+auto f1 = [var] () { // expected-note {{variable 'var' is explicitly captured here}}
+  int var = 1; // expected-warning {{declaration shadows a local variable}}
+};
+auto f2 = [param]   // expected-note {{variable 'param' is explicitly captured here}}
+ (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  }
+
+  // Warn for variables defined in the capture list.
+  auto l3 = [z = var] { // expected-note {{previous declaration is here}}
+int var = 1; // no warning
+{ int z = 1; } // expected-warning {{declaration shadows a local variable}}
+  };
+  auto l4 = [var = param] (int param) { ; }; // no warning
+
+  // Make sure that inner lambdas work as well.
+  auto l5 = [var, l1] { // expected-note {{variable 'l1' is explicitly captured here}}
+auto l1 = [] { // expected-warning {{declaration shadows a local variable}}
+  int var = 1; // no warning
+};
+auto f1 = [] { int var = 1; }; // no warning
+auto f2 = [=] { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+auto f3 = [var] // expected-note {{variable 'var' is explicitly captured here}}
+  { int var = 1; }; // expected-warning {{declaration shadows a local variable}}
+  };
+
+  // Generic lambda arguments should work.
+  auto g1 = [](auto param) { ; }; // no warning
+  auto g2 = [param] // expected-note {{variable 'param' is explicitly captured here}}
+   (auto param) { ; }; // expected-warning {{declaration shadows a local variable}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6582,6 +6582,17 @@
   return OldDC->isFileContext() ? SDK_Global : SDK_Local;
 }
 
+/// Return the location of the capture if the given lambda captures the given
+/// variable \p VD, or an invalid source location otherwise.
+static SourceLocation getCaptureLocation(const LambdaScopeInfo *LSI,
+ const VarDecl *VD) {
+  for (const LambdaScopeInfo::Capture  : LSI->Captures) {
+if (Capture.isVariableCapture() && 

[PATCH] D26276: Remove redundant calls to std::string::data()

2016-11-03 Thread Malcolm Parsons via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, mehdi_amini, dblaikie.
malcolm.parsons added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D26276

Files:
  lib/Parse/ParseObjc.cpp
  lib/Tooling/Core/Replacement.cpp


Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -569,7 +569,7 @@
 const std::map ) {
   std::map Result;
   for (const auto  : FileToReplaces) {
-llvm::SmallString<256> CleanPath(Entry.first.data());
+llvm::SmallString<256> CleanPath(Entry.first);
 llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
 Result[CleanPath.str()] = std::move(Entry.second);
   }
Index: lib/Parse/ParseObjc.cpp
===
--- lib/Parse/ParseObjc.cpp
+++ lib/Parse/ParseObjc.cpp
@@ -1036,7 +1036,7 @@
   case tok::caretequal: {
 std::string ThisTok(PP.getSpelling(Tok));
 if (isLetter(ThisTok[0])) {
-  IdentifierInfo *II = ().get(ThisTok.data());
+  IdentifierInfo *II = ().get(ThisTok);
   Tok.setKind(tok::identifier);
   SelectorLoc = ConsumeToken();
   return II;


Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -569,7 +569,7 @@
 const std::map ) {
   std::map Result;
   for (const auto  : FileToReplaces) {
-llvm::SmallString<256> CleanPath(Entry.first.data());
+llvm::SmallString<256> CleanPath(Entry.first);
 llvm::sys::path::remove_dots(CleanPath, /*remove_dot_dot=*/true);
 Result[CleanPath.str()] = std::move(Entry.second);
   }
Index: lib/Parse/ParseObjc.cpp
===
--- lib/Parse/ParseObjc.cpp
+++ lib/Parse/ParseObjc.cpp
@@ -1036,7 +1036,7 @@
   case tok::caretequal: {
 std::string ThisTok(PP.getSpelling(Tok));
 if (isLetter(ThisTok[0])) {
-  IdentifierInfo *II = ().get(ThisTok.data());
+  IdentifierInfo *II = ().get(ThisTok);
   Tok.setKind(tok::identifier);
   SelectorLoc = ConsumeToken();
   return II;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D26274: clang-format: [JS] do not break after declare namespace.

2016-11-03 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 76831.
mprobst added a comment.

- drop kw_module from ASI protection block


https://reviews.llvm.org/D26274

Files:
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -349,6 +349,37 @@
"}\n");
 }
 
+TEST_F(FormatTestJS, NamespacesMayNotWrap) {
+  verifyFormat("declare namespace foobarbaz {\n"
+   "}\n", getGoogleJSStyleWithColumns(18));
+  verifyFormat("declare module foobarbaz {\n"
+   "}\n", getGoogleJSStyleWithColumns(15));
+  verifyFormat("namespace foobarbaz {\n"
+   "}\n", getGoogleJSStyleWithColumns(10));
+  verifyFormat("module foobarbaz {\n"
+   "}\n", getGoogleJSStyleWithColumns(7));
+}
+
+TEST_F(FormatTestJS, AmbientDeclarations) {
+  FormatStyle NineCols = getGoogleJSStyleWithColumns(9);
+  verifyFormat(
+  "declare class\n"
+  "X {}",
+  NineCols);
+  verifyFormat(
+  "declare function\n"
+  "x();",  // TODO(martinprobst): should ideally be indented.
+  NineCols);
+  verifyFormat(
+  "declare enum X {\n"
+  "}",
+  NineCols);
+  verifyFormat(
+  "declare let\n"
+  "x: number;",
+  NineCols);
+}
+
 TEST_F(FormatTestJS, FormatsFreestandingFunctions) {
   verifyFormat("function outer1(a, b) {\n"
"  function inner1(a, b) {\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -669,14 +669,14 @@
   // FIXME: This returns true for C/C++ keywords like 'struct'.
   return FormatTok->is(tok::identifier) &&
  (FormatTok->Tok.getIdentifierInfo() == nullptr ||
-  !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as,
-  Keywords.kw_async, Keywords.kw_await,
-  Keywords.kw_yield, Keywords.kw_finally,
-  Keywords.kw_function, Keywords.kw_import,
-  Keywords.kw_is, Keywords.kw_let, Keywords.kw_var,
-  Keywords.kw_abstract, Keywords.kw_extends,
-  Keywords.kw_implements, Keywords.kw_instanceof,
-  Keywords.kw_interface, Keywords.kw_throws));
+  !FormatTok->isOneOf(
+  Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, Keywords.kw_async,
+  Keywords.kw_await, Keywords.kw_yield, Keywords.kw_finally,
+  Keywords.kw_function, Keywords.kw_import, Keywords.kw_is,
+  Keywords.kw_let, Keywords.kw_var, tok::kw_const,
+  Keywords.kw_abstract, Keywords.kw_extends, Keywords.kw_implements,
+  Keywords.kw_instanceof, Keywords.kw_interface,
+  Keywords.kw_throws));
 }
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords ,
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2437,6 +2437,18 @@
   return Style.BreakBeforeBinaryOperators != FormatStyle::BOS_None;
 if (Right.is(Keywords.kw_as))
   return false; // must not break before as in 'x as type' casts
+if (Left.is(Keywords.kw_declare) &&
+Right.isOneOf(Keywords.kw_module, tok::kw_namespace,
+  Keywords.kw_function, tok::kw_class, tok::kw_enum,
+  Keywords.kw_interface, Keywords.kw_type, Keywords.kw_var,
+  Keywords.kw_let, tok::kw_const))
+  // See grammar for 'declare' statements at:
+  // https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10
+  return false;
+if (Left.isOneOf(Keywords.kw_module, tok::kw_namespace) &&
+Right.isOneOf(tok::identifier, tok::string_literal)) {
+  return false; // must not break in "module foo { ...}"
+}
   }
 
   if (Left.is(tok::at))
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -580,12 +580,14 @@
 kw_as = ("as");
 kw_async = ("async");
 kw_await = ("await");
+kw_declare = ("declare");
 kw_finally = ("finally");
 kw_from = ("from");
 kw_function = ("function");
 kw_import = ("import");
 kw_is = ("is");
 kw_let = ("let");
+kw_module = ("module");
 kw_type = ("type");
 kw_var = ("var");
 kw_yield = ("yield");
@@ -632,12 +634,14 @@
   IdentifierInfo *kw_as;
   IdentifierInfo *kw_async;
   IdentifierInfo *kw_await;
+  IdentifierInfo *kw_declare;
   IdentifierInfo *kw_finally;
   IdentifierInfo *kw_from;
   IdentifierInfo 

[PATCH] D26274: clang-format: [JS] do not break after declare namespace.

2016-11-03 Thread Martin Probst via cfe-commits
mprobst created this revision.
mprobst added a reviewer: djasper.
mprobst added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

See TypeScript grammar for tokens following 'declare':
https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10

Additional minor change:
clang-format: [JS] Prevent ASI before const.


https://reviews.llvm.org/D26274

Files:
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTestJS.cpp

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -349,6 +349,37 @@
"}\n");
 }
 
+TEST_F(FormatTestJS, NamespacesMayNotWrap) {
+  verifyFormat("declare namespace foobarbaz {\n"
+   "}\n", getGoogleJSStyleWithColumns(18));
+  verifyFormat("declare module foobarbaz {\n"
+   "}\n", getGoogleJSStyleWithColumns(15));
+  verifyFormat("namespace foobarbaz {\n"
+   "}\n", getGoogleJSStyleWithColumns(10));
+  verifyFormat("module foobarbaz {\n"
+   "}\n", getGoogleJSStyleWithColumns(7));
+}
+
+TEST_F(FormatTestJS, AmbientDeclarations) {
+  FormatStyle NineCols = getGoogleJSStyleWithColumns(9);
+  verifyFormat(
+  "declare class\n"
+  "X {}",
+  NineCols);
+  verifyFormat(
+  "declare function\n"
+  "x();",  // TODO(martinprobst): should ideally be indented.
+  NineCols);
+  verifyFormat(
+  "declare enum X {\n"
+  "}",
+  NineCols);
+  verifyFormat(
+  "declare let\n"
+  "x: number;",
+  NineCols);
+}
+
 TEST_F(FormatTestJS, FormatsFreestandingFunctions) {
   verifyFormat("function outer1(a, b) {\n"
"  function inner1(a, b) {\n"
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -669,14 +669,14 @@
   // FIXME: This returns true for C/C++ keywords like 'struct'.
   return FormatTok->is(tok::identifier) &&
  (FormatTok->Tok.getIdentifierInfo() == nullptr ||
-  !FormatTok->isOneOf(Keywords.kw_in, Keywords.kw_of, Keywords.kw_as,
-  Keywords.kw_async, Keywords.kw_await,
-  Keywords.kw_yield, Keywords.kw_finally,
-  Keywords.kw_function, Keywords.kw_import,
-  Keywords.kw_is, Keywords.kw_let, Keywords.kw_var,
-  Keywords.kw_abstract, Keywords.kw_extends,
-  Keywords.kw_implements, Keywords.kw_instanceof,
-  Keywords.kw_interface, Keywords.kw_throws));
+  !FormatTok->isOneOf(
+  Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, Keywords.kw_async,
+  Keywords.kw_await, Keywords.kw_yield, Keywords.kw_finally,
+  Keywords.kw_function, Keywords.kw_import, Keywords.kw_is,
+  Keywords.kw_let, Keywords.kw_var, tok::kw_const,
+  Keywords.kw_abstract, Keywords.kw_extends, Keywords.kw_implements,
+  Keywords.kw_instanceof, Keywords.kw_interface,
+  Keywords.kw_throws));
 }
 
 static bool mustBeJSIdentOrValue(const AdditionalKeywords ,
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2420,10 +2420,10 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 const FormatToken *NonComment = Right.getPreviousNonComment();
 if (Left.isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
- tok::kw_throw) ||
+ tok::kw_throw, Keywords.kw_module) ||
 (NonComment &&
  NonComment->isOneOf(tok::kw_return, tok::kw_continue, tok::kw_break,
- tok::kw_throw)))
+ tok::kw_throw, Keywords.kw_module)))
   return false; // Otherwise a semicolon is inserted.
 if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
   return false;
@@ -2437,6 +2437,18 @@
   return Style.BreakBeforeBinaryOperators != FormatStyle::BOS_None;
 if (Right.is(Keywords.kw_as))
   return false; // must not break before as in 'x as type' casts
+if (Left.is(Keywords.kw_declare) &&
+Right.isOneOf(Keywords.kw_module, tok::kw_namespace,
+  Keywords.kw_function, tok::kw_class, tok::kw_enum,
+  Keywords.kw_interface, Keywords.kw_type, Keywords.kw_var,
+  Keywords.kw_let, tok::kw_const))
+  // See grammar for 'declare' statements at:
+  // https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10
+  return false;
+if (Left.isOneOf(Keywords.kw_module, tok::kw_namespace) &&
+

[PATCH] D21072: [mips] Account for -mabi when determining whether IAS is the default or not.

2016-11-03 Thread Simon Dardis via cfe-commits
sdardis updated this revision to Diff 76824.
sdardis added a comment.

Rebase and ping


https://reviews.llvm.org/D21072

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/MSVCToolChain.cpp
  lib/Driver/MinGWToolChain.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  lib/Driver/Tools.cpp
  test/Driver/mips-integrated-as.s

Index: test/Driver/mips-integrated-as.s
===
--- test/Driver/mips-integrated-as.s
+++ test/Driver/mips-integrated-as.s
@@ -1,3 +1,5 @@
+// RUN: %clang -target mips-linux-gnu -### -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=ABI-O32 %s
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=ABI-O32 %s
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mabi=32 2>&1 | \
@@ -293,3 +295,13 @@
 // IMG-SINGLEFLOAT-EXPLICIT-FPXX: "-target-feature" "+single-float"
 // IMG-SINGLEFLOAT-EXPLICIT-FPXX: "-target-feature" "+fpxx"
 // IMG-SINGLEFLOAT-EXPLICIT-FPXX: "-target-feature" "+nooddspreg"
+
+// RUN: %clang -target mips-linux-gnu -### -c %s -mips64 -mabi=n32 2>&1 | \
+// RUN:   FileCheck -check-prefix=GAS %s
+// RUN: %clang -target mips64-linux-gnu -### -c %s -mabi=n32 2>&1 | \
+// RUN:   FileCheck -check-prefix=GAS %s
+// RUN: %clang -target mips-linux-gnu -### -c %s -mips64 -mabi=64 2>&1 | \
+// RUN:   FileCheck -check-prefix=GAS %s
+// RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 | \
+// RUN:   FileCheck -check-prefix=GAS %s
+// GAS-NOT: -cc1as
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -4552,7 +4552,7 @@
   // Decide whether to use verbose asm. Verbose assembly is the default on
   // toolchains which have the integrated assembler on by default.
   bool IsIntegratedAssemblerDefault =
-  getToolChain().IsIntegratedAssemblerDefault();
+  getToolChain().IsIntegratedAssemblerDefault(Args);
   if (Args.hasFlag(options::OPT_fverbose_asm, options::OPT_fno_verbose_asm,
IsIntegratedAssemblerDefault) ||
   Args.hasArg(options::OPT_dA))
Index: lib/Driver/ToolChains.h
===
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -221,7 +221,8 @@
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
   bool isPICDefaultForced() const override;
-  bool IsIntegratedAssemblerDefault() const override;
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList ) const override;
   llvm::opt::DerivedArgList *
   TranslateArgs(const llvm::opt::DerivedArgList , StringRef BoundArch,
 Action::OffloadKind DeviceOffloadKind) const override;
@@ -339,7 +340,8 @@
 // expected to use /usr/include/Block.h.
 return true;
   }
-  bool IsIntegratedAssemblerDefault() const override {
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList ) const override {
 // Default integrated assembler to on for Apple's MachO targets.
 return true;
   }
@@ -657,7 +659,10 @@
   Solaris(const Driver , const llvm::Triple ,
   const llvm::opt::ArgList );
 
-  bool IsIntegratedAssemblerDefault() const override { return true; }
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList ) const override {
+return true;
+  }
 
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList ,
@@ -675,7 +680,8 @@
   MinGW(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList );
 
-  bool IsIntegratedAssemblerDefault() const override;
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList ) const override;
   bool IsUnwindTablesDefault() const override;
   bool isPICDefault() const override;
   bool isPIEDefault() const override;
@@ -943,7 +949,10 @@
   const llvm::opt::ArgList ,
   llvm::opt::ArgStringList ) const override {}
 
-  bool IsIntegratedAssemblerDefault() const override { return true; }
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList ) const override {
+return true;
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY HexagonToolChain : public Linux {
@@ -966,7 +975,8 @@
   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList ) const override;
 
   StringRef GetGCCLibAndIncVersion() const { return GCCLibAndIncVersion.Text; }
-  bool IsIntegratedAssemblerDefault() const override {
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList ) const override {
 return true;
   }
 
@@ -991,7 +1001,10 @@
   AMDGPUToolChain(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList );
   unsigned GetDefaultDwarfVersion() const override { return 2; }
-  bool IsIntegratedAssemblerDefault() const override { return true; }
+  bool
+  IsIntegratedAssemblerDefault(const llvm::opt::ArgList ) const override {
+return true;
+  }
 };
 
 class LLVM_LIBRARY_VISIBILITY NaClToolChain : public Generic_ELF {

[PATCH] D21070: Pass the ABI in the triple when appropriate (currently for MIPS) for 'clang -cc1' and 'clang -cc1as'

2016-11-03 Thread Simon Dardis via cfe-commits
sdardis updated this revision to Diff 76823.
sdardis added a comment.

Rebase and ping.


https://reviews.llvm.org/D21070

Files:
  lib/Basic/Targets.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  tools/driver/cc1as_main.cpp

Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -69,6 +69,10 @@
   /// The name of the target triple to assemble for.
   std::string Triple;
 
+  /// The name of the ABI to assembler for or the empty string for the default
+  /// ABI.
+  std::string ABI;
+
   /// If given, the name of the target CPU to determine which instructions
   /// are legal.
   std::string CPU;
@@ -134,6 +138,7 @@
 public:
   AssemblerInvocation() {
 Triple = "";
+ABI = "";
 NoInitialTextSection = 0;
 InputFile = "-";
 OutputPath = "-";
@@ -185,13 +190,24 @@
 
   // Target Options
   Opts.Triple = llvm::Triple::normalize(Args.getLastArgValue(OPT_triple));
+  Opts.ABI = Args.getLastArgValue(OPT_target_abi);
   Opts.CPU = Args.getLastArgValue(OPT_target_cpu);
   Opts.Features = Args.getAllArgValues(OPT_target_feature);
 
   // Use the default target triple if unspecified.
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
 
+  // Modify the Triple and ABI according to the Triple and ABI.
+  llvm::Triple ABITriple;
+  StringRef ABIName;
+  std::tie(ABITriple, ABIName) =
+  llvm::Triple(Opts.Triple).getABIVariant(Opts.ABI);
+  if (ABITriple.getArch() == llvm::Triple::UnknownArch)
+Diags.Report(diag::err_target_unknown_abi) << Opts.ABI;
+  Opts.Triple = ABITriple.str();
+  Opts.ABI = ABIName;
+
   // Language Options
   Opts.IncludePaths = Args.getAllArgValues(OPT_I);
   Opts.NoInitialTextSection = Args.hasArg(OPT_n);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2385,6 +2385,17 @@
   // Use the default target triple if unspecified.
   if (Opts.Triple.empty())
 Opts.Triple = llvm::sys::getDefaultTargetTriple();
+
+  // Modify the Triple and ABI according to the Triple and ABI.
+  llvm::Triple ABITriple;
+  StringRef ABIName;
+  std::tie(ABITriple, ABIName) =
+  llvm::Triple(Opts.Triple).getABIVariant(Opts.ABI);
+  if (ABITriple.getArch() == llvm::Triple::UnknownArch)
+Diags.Report(diag::err_target_unknown_abi) << Opts.ABI;
+  Opts.Triple = ABITriple.str();
+  Opts.ABI = ABIName;
+
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1355,7 +1355,7 @@
   // MIPS32r6 is the default for mips(el)?-img-linux-gnu and MIPS64r6 is the
   // default for mips64(el)?-img-linux-gnu.
   if (Triple.getVendor() == llvm::Triple::ImaginationTechnologies &&
-  Triple.getEnvironment() == llvm::Triple::GNU) {
+  Triple.isGNUEnvironment()) {
 DefMips32CPU = "mips32r6";
 DefMips64CPU = "mips64r6";
   }
Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -2470,7 +2470,7 @@
 
   if (TargetTriple.getVendor() == llvm::Triple::ImaginationTechnologies &&
   TargetTriple.getOS() == llvm::Triple::Linux &&
-  TargetTriple.getEnvironment() == llvm::Triple::GNU)
+  TargetTriple.isGNUEnvironment())
 return findMipsImgMultilibs(Flags, NonExistent, Result);
 
   if (findMipsCsMultilibs(Flags, NonExistent, Result))
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -7318,10 +7318,22 @@
 DspRev(NoDSP), HasMSA(false), HasFP64(false) {
 TheCXXABI.set(TargetCXXABI::GenericMIPS);
 
-setABI((getTriple().getArch() == llvm::Triple::mips ||
-getTriple().getArch() == llvm::Triple::mipsel)
-   ? "o32"
-   : "n64");
+if (getTriple().getEnvironment() == llvm::Triple::ABI32 ||
+getTriple().getEnvironment() == llvm::Triple::GNUABI32 ||
+getTriple().getEnvironment() == llvm::Triple::AndroidABI32)
+  setABI("o32");
+else if (getTriple().getEnvironment() == llvm::Triple::ABIN32 ||
+getTriple().getEnvironment() == llvm::Triple::GNUABIN32)
+  setABI("n32");
+else if (getTriple().getEnvironment() == llvm::Triple::ABI64 ||
+ getTriple().getEnvironment() == llvm::Triple::GNUABI64 ||
+ getTriple().getEnvironment() == llvm::Triple::AndroidABI64)
+  setABI("n64");
+else
+  setABI((getTriple().getArch() == llvm::Triple::mips ||
+  getTriple().getArch() == llvm::Triple::mipsel)
+ ? "o32"
+ : "n64");
 
 CPU 

[PATCH] D25439: Fixed column shift when formatting line containing bit shift operators

2016-11-03 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a comment.

Do you have commit access?


https://reviews.llvm.org/D25439



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


r285889 - Reverted r285882 (Enhancement to test for -ast-print)

2016-11-03 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Thu Nov  3 03:58:44 2016
New Revision: 285889

URL: http://llvm.org/viewvc/llvm-project?rev=285889=rev
Log:
Reverted r285882 (Enhancement to test for -ast-print)

It broke buildbot on Windows.

Modified:
cfe/trunk/test/Coverage/ast-printing.c

Modified: cfe/trunk/test/Coverage/ast-printing.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Coverage/ast-printing.c?rev=285889=285888=285889=diff
==
--- cfe/trunk/test/Coverage/ast-printing.c (original)
+++ cfe/trunk/test/Coverage/ast-printing.c Thu Nov  3 03:58:44 2016
@@ -1,7 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only %s
-// RUN: %clang_cc1 -ast-print %s -o %t.1.c
-// RUN: %clang_cc1 -ast-print %t.1.c -o %t.2.c
-// RUN: diff %t.1.c %t.2.c
+// RUN: %clang_cc1 -ast-print %s
 // RUN: %clang_cc1 -ast-dump %s
 // RUN: %clang_cc1 -print-decl-contexts %s
 


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


[PATCH] D26271: [PPC} add extract significand/ extract exponent/test data class for vector float and vector double -- clang portion

2016-11-03 Thread Nemanja Ivanovic via cfe-commits
nemanjai added a comment.

LGTM but I'll let @kbarton have a look and provide the final approval.




Comment at: lib/Headers/altivec.h:15629
+#define vec_test_data_class(__a, __b)  \
+_Generic((__a),\
+   vector float:   \

I don't know what happens if the type of the first argument is neither of the 
two types, but I think we should verify that something sane happens. Namely, 
some sort of overload resolution error message. 


Repository:
  rL LLVM

https://reviews.llvm.org/D26271



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


[PATCH] D21502: Fix heuristics skipping invalid ctor-initializers with C++11

2016-11-03 Thread Olivier Goffart via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285883: Fix heuristics skipping invalid ctor-initializers 
with C++11 (authored by ogoffart).

Changed prior to commit:
  https://reviews.llvm.org/D21502?vs=69223=76819#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D21502

Files:
  cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
  cfe/trunk/test/CodeCompletion/ctor-initializer.cpp

Index: cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
===
--- cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
+++ cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
@@ -1,11 +1,13 @@
 struct Base1 {
   Base1() : {}
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:2:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:2:12 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: COMPLETION: Pattern : member1(<#args#>)
   // CHECK-CC1: COMPLETION: Pattern : member2(<#args#>
 
   Base1(int) : member1(123), {}
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:7:30 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:8:30 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:8:30 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
   // CHECK-CC2-NOT: COMPLETION: Pattern : member1(<#args#>)
   // CHECK-CC2: COMPLETION: Pattern : member2(<#args#>
 
@@ -21,21 +23,40 @@
 };
 
 Derived::Derived() : {}
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:25:22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:25:22 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: COMPLETION: Pattern : Base1(<#args#>)
 // CHECK-CC3: COMPLETION: Pattern : deriv1(<#args#>)
 
 Derived::Derived(int) try : {
 } catch (...) {
 }
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:28:29 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:31:29 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:31:29 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
 // CHECK-CC4: COMPLETION: Pattern : Base1(<#args#>)
 // CHECK-CC4: COMPLETION: Pattern : deriv1(<#args#>)
 
 Derived::Derived(float) try : Base1(),
 {
 } catch (...) {
 }
-// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:35:39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:39:39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:39:39 %s -o - | FileCheck -check-prefix=CHECK-CC5 %s
 // CHECK-CC5-NOT: COMPLETION: Pattern : Base1(<#args#>)
 // CHECK-CC5: COMPLETION: Pattern : deriv1(<#args#>)
+
+struct A {
+  A() : , member2() {}
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:49:9 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:49:9 %s -o - | FileCheck -check-prefix=CHECK-CC6 %s
+  // CHECK-CC6: COMPLETION: Pattern : member1(<#args#>
+  int member1, member2;
+};
+
+struct B {
+  B() : member2() {}
+  // RUN: %clang_cc1 -fsyntax-only -std=c++98 -code-completion-at=%s:57:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
+  // RUN: %clang_cc1 -fsyntax-only -std=c++14 -code-completion-at=%s:57:9 %s -o - | FileCheck -check-prefix=CHECK-CC7 %s
+  // CHECK-CC7: COMPLETION: Pattern : member1(<#args#>
+  int member1, member2;
+};
Index: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
===
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
@@ -832,22 +832,30 @@
 }
   }
 
-  if (Tok.isOneOf(tok::identifier, tok::kw_template)) {
+  if (Tok.is(tok::identifier)) {
 Toks.push_back(Tok);
 ConsumeToken();
-  } else if (Tok.is(tok::code_completion)) {
-Toks.push_back(Tok);
-ConsumeCodeCompletionToken();
-// Consume the rest of the initializers permissively.
-// FIXME: We should be able to perform code-completion here even if
-//there isn't a subsequent '{' token.
-MightBeTemplateArgument = true;
-break;
   } else {
 break;
   }
 } while (Tok.is(tok::coloncolon));
 
+if (Tok.is(tok::code_completion)) {
+  Toks.push_back(Tok);
+  ConsumeCodeCompletionToken();
+  if (Tok.isOneOf(tok::identifier, 

r285883 - Fix heuristics skipping invalid ctor-initializers with C++11

2016-11-03 Thread Olivier Goffart via cfe-commits
Author: ogoffart
Date: Thu Nov  3 02:36:17 2016
New Revision: 285883

URL: http://llvm.org/viewvc/llvm-project?rev=285883=rev
Log:
Fix heuristics skipping invalid ctor-initializers with C++11

Use better heuristics to detect if a '{' might be the start of the constructor 
body
or not. Especially when there is a completion token.

Fix the test 'test/CodeCompletion/ctor-initializer.cpp ' when clang defaults to 
c++11

The problem was is how we recover invalid code in the ctor-init part as we skip 
the
function body. In particular, we want to know if a '{' is the begining of the 
body.
In C++03, we always consider it as the beginng of the body. The problem was 
that in
C++11, it may be the start of an initializer, so we skip over it, causing 
further
parse errors later. (It is important that we are able to parse correctly the 
rest
of the class definition, to know what are the class member, for example)

This commit is improving the heuristics to decide if the '{' is starting a 
function
body. The rules are the following: If we are not in a template argument, and 
that the
previous tokens are not an identifier, or a >, then it is much more likely to 
be the
function body. We verify that further by checking the token after the matching 
'}'

The commit also fix the behavior when there is a code_completion token in the
ctor-initializers.

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

Modified:
cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
cfe/trunk/test/CodeCompletion/ctor-initializer.cpp

Modified: cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp?rev=285883=285882=285883=diff
==
--- cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/trunk/lib/Parse/ParseCXXInlineMethods.cpp Thu Nov  3 02:36:17 2016
@@ -832,22 +832,30 @@ bool Parser::ConsumeAndStoreFunctionProl
 }
   }
 
-  if (Tok.isOneOf(tok::identifier, tok::kw_template)) {
+  if (Tok.is(tok::identifier)) {
 Toks.push_back(Tok);
 ConsumeToken();
-  } else if (Tok.is(tok::code_completion)) {
-Toks.push_back(Tok);
-ConsumeCodeCompletionToken();
-// Consume the rest of the initializers permissively.
-// FIXME: We should be able to perform code-completion here even if
-//there isn't a subsequent '{' token.
-MightBeTemplateArgument = true;
-break;
   } else {
 break;
   }
 } while (Tok.is(tok::coloncolon));
 
+if (Tok.is(tok::code_completion)) {
+  Toks.push_back(Tok);
+  ConsumeCodeCompletionToken();
+  if (Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype)) {
+// Could be the start of another member initializer (the ',' has not
+// been written yet)
+continue;
+  }
+}
+
+if (Tok.is(tok::comma)) {
+  // The initialization is missing, we'll diagnose it later.
+  Toks.push_back(Tok);
+  ConsumeToken();
+  continue;
+}
 if (Tok.is(tok::less))
   MightBeTemplateArgument = true;
 
@@ -888,6 +896,26 @@ bool Parser::ConsumeAndStoreFunctionProl
   // means the initializer is malformed; we'll diagnose it later.
   if (!getLangOpts().CPlusPlus11)
 return false;
+
+  const Token  = Toks[Toks.size() - 2];
+  if (!MightBeTemplateArgument &&
+  !PreviousToken.isOneOf(tok::identifier, tok::greater,
+ tok::greatergreater)) {
+// If the opening brace is not preceded by one of these tokens, we are
+// missing the mem-initializer-id. In order to recover better, we need
+// to use heuristics to determine if this '{' is most likely the
+// begining of a brace-init-list or the function body.
+// Check the token after the corresponding '}'.
+TentativeParsingAction PA(*this);
+if (SkipUntil(tok::r_brace) &&
+!Tok.isOneOf(tok::comma, tok::ellipsis, tok::l_brace)) {
+  // Consider there was a malformed initializer and this is the start
+  // of the function body. We'll diagnose it later.
+  PA.Revert();
+  return false;
+}
+PA.Revert();
+  }
 }
 
 // Grab the initializer (or the subexpression of the template argument).

Modified: cfe/trunk/test/CodeCompletion/ctor-initializer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/ctor-initializer.cpp?rev=285883=285882=285883=diff
==
--- cfe/trunk/test/CodeCompletion/ctor-initializer.cpp (original)
+++ cfe/trunk/test/CodeCompletion/ctor-initializer.cpp Thu Nov  3 02:36:17 2016
@@ -1,11 +1,13 @@
 struct Base1 {
   Base1() : {}
-  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:2:12 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
+  // RUN: 

r285882 - Enhancement to test for -ast-print

2016-11-03 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Thu Nov  3 02:32:02 2016
New Revision: 285882

URL: http://llvm.org/viewvc/llvm-project?rev=285882=rev
Log:
Enhancement to test for -ast-print

Present tests for the functionality provided by command lime option
`-ast-print` check only absence of crash. This change tries to make
testing better, - the output produced by the compiler is compiled again
with option `-print-ast` and both outputs are compared. Such test at
least checks that the output is valid code. This change fixes only the
test for pure C.

Modified:
cfe/trunk/test/Coverage/ast-printing.c

Modified: cfe/trunk/test/Coverage/ast-printing.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Coverage/ast-printing.c?rev=285882=285881=285882=diff
==
--- cfe/trunk/test/Coverage/ast-printing.c (original)
+++ cfe/trunk/test/Coverage/ast-printing.c Thu Nov  3 02:32:02 2016
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only %s
-// RUN: %clang_cc1 -ast-print %s
+// RUN: %clang_cc1 -ast-print %s -o %t.1.c
+// RUN: %clang_cc1 -ast-print %t.1.c -o %t.2.c
+// RUN: diff %t.1.c %t.2.c
 // RUN: %clang_cc1 -ast-dump %s
 // RUN: %clang_cc1 -print-decl-contexts %s
 


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


[PATCH] D25263: [Driver] Allow setting the default linker during build

2016-11-03 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added a comment.

I have two high level remarks here:

1. `CLANG_DEFAULT_LINKER` should override whatever the platform default is. So 
`ToolChain::getDefaultLinker()` should return `ld` as the variable 
`DefaultLinker` currently says and the logic should be in 
`ToolChain::GetLinkerPath()`.
2. The CMake variable is documented to be empty for the platform default. I 
think this will currently not work when used by 
`GetProgramPath(getDefaultLinker())`, will it?




Comment at: lib/Driver/ToolChain.cpp:377
 getDriver().Diag(diag::err_drv_invalid_linker_name) << 
A->getAsString(Args);
-return "";
   }

You can leave this `return` because Clang will exit anyway after emitting the 
error (as I had to learn...)



Comment at: lib/Driver/ToolChain.cpp:721-724
+
+const char *ToolChain::getDefaultLinker() const {
+  return CLANG_DEFAULT_LINKER;
+}

I think this could go into the header


Repository:
  rL LLVM

https://reviews.llvm.org/D25263



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


[PATCH] D25669: [Driver] Simplify ToolChain::GetCXXStdlibType (NFC)

2016-11-03 Thread Jonas Hahnfeld via cfe-commits
Hahnfeld added a comment.

Can I commit this as-is for now and we can think about `StringSwitch` in the 
driver later on?


https://reviews.llvm.org/D25669



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


[PATCH] D23765: Fix for clang PR 29087

2016-11-03 Thread Taewook Oh via cfe-commits
twoh updated this revision to Diff 76817.
twoh added a comment.

Addressing comments from @rsmith. Thanks!


https://reviews.llvm.org/D23765

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/cxx11-crashes.cpp


Index: test/SemaCXX/cxx11-crashes.cpp
===
--- test/SemaCXX/cxx11-crashes.cpp
+++ test/SemaCXX/cxx11-crashes.cpp
@@ -91,3 +91,15 @@
   Foo(lambda);
 }
 }
+
+namespace pr29091 {
+  struct X{ X(const X ); };
+  struct Y: X { using X::X; };
+  bool foo() { return __has_nothrow_constructor(Y); }
+  bool bar() { return __has_nothrow_copy(Y); }
+
+  struct A { template  A(); };
+  struct B : A { using A::A; };
+  bool baz() { return __has_nothrow_constructor(B); }
+  bool qux() { return __has_nothrow_copy(B); }
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4398,9 +4398,12 @@
 // A template constructor is never a copy constructor.
 // FIXME: However, it may actually be selected at the actual overload
 // resolution point.
-if (isa(ND))
+if (isa(ND->getUnderlyingDecl()))
   continue;
-const CXXConstructorDecl *Constructor = cast(ND);
+// UsingDecl itself is not a constructor
+if (isa(ND))
+  continue;
+auto *Constructor = cast(ND->getUnderlyingDecl());
 if (Constructor->isCopyConstructor(FoundTQs)) {
   FoundConstructor = true;
   const FunctionProtoType *CPT
@@ -4434,9 +4437,12 @@
   bool FoundConstructor = false;
   for (const auto *ND : Self.LookupConstructors(RD)) {
 // FIXME: In C++0x, a constructor template can be a default 
constructor.
-if (isa(ND))
+if (isa(ND->getUnderlyingDecl()))
+  continue;
+// UsingDecl itself is not a constructor
+if (isa(ND))
   continue;
-const CXXConstructorDecl *Constructor = cast(ND);
+auto *Constructor = cast(ND->getUnderlyingDecl());
 if (Constructor->isDefaultConstructor()) {
   FoundConstructor = true;
   const FunctionProtoType *CPT


Index: test/SemaCXX/cxx11-crashes.cpp
===
--- test/SemaCXX/cxx11-crashes.cpp
+++ test/SemaCXX/cxx11-crashes.cpp
@@ -91,3 +91,15 @@
   Foo(lambda);
 }
 }
+
+namespace pr29091 {
+  struct X{ X(const X ); };
+  struct Y: X { using X::X; };
+  bool foo() { return __has_nothrow_constructor(Y); }
+  bool bar() { return __has_nothrow_copy(Y); }
+
+  struct A { template  A(); };
+  struct B : A { using A::A; };
+  bool baz() { return __has_nothrow_constructor(B); }
+  bool qux() { return __has_nothrow_copy(B); }
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4398,9 +4398,12 @@
 // A template constructor is never a copy constructor.
 // FIXME: However, it may actually be selected at the actual overload
 // resolution point.
-if (isa(ND))
+if (isa(ND->getUnderlyingDecl()))
   continue;
-const CXXConstructorDecl *Constructor = cast(ND);
+// UsingDecl itself is not a constructor
+if (isa(ND))
+  continue;
+auto *Constructor = cast(ND->getUnderlyingDecl());
 if (Constructor->isCopyConstructor(FoundTQs)) {
   FoundConstructor = true;
   const FunctionProtoType *CPT
@@ -4434,9 +4437,12 @@
   bool FoundConstructor = false;
   for (const auto *ND : Self.LookupConstructors(RD)) {
 // FIXME: In C++0x, a constructor template can be a default constructor.
-if (isa(ND))
+if (isa(ND->getUnderlyingDecl()))
+  continue;
+// UsingDecl itself is not a constructor
+if (isa(ND))
   continue;
-const CXXConstructorDecl *Constructor = cast(ND);
+auto *Constructor = cast(ND->getUnderlyingDecl());
 if (Constructor->isDefaultConstructor()) {
   FoundConstructor = true;
   const FunctionProtoType *CPT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r285879 - [Sema] Remove a dead assignment, NFC.

2016-11-03 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Thu Nov  3 01:35:16 2016
New Revision: 285879

URL: http://llvm.org/viewvc/llvm-project?rev=285879=rev
Log:
[Sema] Remove a dead assignment, NFC.

The assignment to NextIsDereference is either followed by (1) another,
unrelated assignment to NextIsDereference or by (2) an early loop exit.

Found by clang's static analyzer: http://llvm.org/reports/scan-build

(While we're at it fix a typo.)

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=285879=285878=285879=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Nov  3 01:35:16 2016
@@ -9880,15 +9880,14 @@ static void DiagnoseConstAssignment(Sema
   // a note to the error.
   bool DiagnosticEmitted = false;
 
-  // Track if the current expression is the result of a derefence, and if the
-  // next checked expression is the result of a derefence.
+  // Track if the current expression is the result of a dereference, and if the
+  // next checked expression is the result of a dereference.
   bool IsDereference = false;
   bool NextIsDereference = false;
 
   // Loop to process MemberExpr chains.
   while (true) {
 IsDereference = NextIsDereference;
-NextIsDereference = false;
 
 E = E->IgnoreParenImpCasts();
 if (const MemberExpr *ME = dyn_cast(E)) {


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