Re: [PATCH] D17550: Adding doxygen comments to the LLVM intrinsics (part 6, popcntintrin.h)

2016-03-01 Thread Dmitri Gribenko via cfe-commits
On Mon, Feb 29, 2016 at 10:59 AM, Romanova, Katya
 wrote:
> Hi Dmitri,
>
> Could you please let us know your opinion about C++ vs C-style doxygen
> comments. Read this thread for ‘pro’ and ‘con’ arguments about using C++
> headers. Will LLVM online documentation look proper if we decide to use
> C-style headers? Which style do you personally prefer to see?

There are C comments that both Doxygen and Clang recognize well,
equally well to C++ comments.

But I don't think that a change is necessary here.  The reason is that
these are compiler-internal header files, so they will only be ever
parsed by Clang.  No matter which mode Clang is in, it supports
//-style comments, either as a part of the language, or as an
extension, I believe.

While it is true that a pure c89 compiler won't be able to parse these
headers, we are not concerned about these builtin headers used by any
compiler other than Clang.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j*/
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17727: Moved applyAllReplacementsAndFormat to clangFormat to avoid cyclic dependency.

2016-03-01 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include/clang/Format/Format.h:734-736
@@ -733,1 +733,5 @@
 
+/// \brief Return replacements that are merged from orginal replacements
+/// and the replacements for formatting the code after applying the orginal
+/// replacements.
+tooling::Replacements formatReplacements(StringRef Code,

Perhaps: Returns the replacements corresponding to applying and formatting 
'Replaces'.



Comment at: include/clang/Format/Format.h:741-743
@@ +740,5 @@
+
+/// \brief In addition to applying replacements as in `applyAllReplacements` in
+/// Replacement.h, this function also reformats the changed code after applying
+/// replacements.
+///

Given that this is now in a separate file, I'd duplicate the comment from 
applyAllReplacements and put a "See also" at the end of the comment.


Comment at: include/clang/Format/Format.h:750-751
@@ +749,4 @@
+///
+/// \returns the changed code if all replacements apply and code is fixed.
+/// empty string otherwise.
+std::string applyAllReplacementsAndFormat(StringRef Code,

 the changed code with all replacements applied and formatted, if 
successful. The empty string otherwise.


Comment at: unittests/Format/FormatTest.cpp:12
@@ +11,3 @@
+
+#include "../Tooling/RewriterTestContext.h" // FIXME: is it okay to include it?
+#include "FormatTestUtils.h"

Yes.


Comment at: unittests/Format/FormatTest.cpp:11172-11174
@@ -11167,1 +11171,5 @@
 
+// This class is copied from ../Tooling/RefactoringTest.cpp
+// Although we are only use it in one test case, we need it for testing 
features
+// to be added in the future.
+class ReplacementTest : public ::testing::Test {

I don't think it's relevant where this is copied from, as it doesn't really 
contain any code, and is merely a test fixture adapter, which is to be expected.


http://reviews.llvm.org/D17727



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


Re: [PATCH] D17756: [clang-tidy] Make 'modernize-pass-by-value' fix work on header files.

2016-03-01 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thanks!



Comment at: test/clang-tidy/modernize-pass-by-value-header.cpp:1
@@ +1,2 @@
+// RUN: cp %S/Inputs/modernize-pass-by-value/header.h %T/pass-by-value-header.h
+// RUN: clang-tidy %s -checks='-*,modernize-pass-by-value' -header-filter='.*' 
-fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES 
-implicit-check-not="{{warning|error}}:"

This might need `// REQUIRES: shell` (please find other tests using `cp` to 
check this).


Repository:
  rL LLVM

http://reviews.llvm.org/D17756



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


Re: [PATCH] D15283: [ARMv8-M] Add Clang targeting for ARMv8-M Baseline/Mainline

2016-03-01 Thread Bradley Smith via cfe-commits
bsmith added a comment.

Ping. This change has been waiting for review for over a month now, it would be 
great to get this committed. Thanks.


Repository:
  rL LLVM

http://reviews.llvm.org/D15283



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


r262318 - Optionally demote fatal errors to non-fatal errors.

2016-03-01 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Mar  1 04:56:19 2016
New Revision: 262318

URL: http://llvm.org/viewvc/llvm-project?rev=262318&view=rev
Log:
Optionally demote fatal errors to non-fatal errors.

This behavior is enabled when the new CXTranslationUnit_KeepGoing
option is passed to clang_parseTranslationUnit{,2}. It is geared
towards use by IDEs and similar consumers of the clang-c API where
fatal errors may arise when parsing incomplete code mid-edit, or
when include paths are not properly configured yet. In such situations
one still wants to get as much information as possible about a TU.
Previously, the semantic analysis would not instantiate templates
or report additional fatal errors after the first fatal error was
encountered.

Fixes PR24268.

Patch by Milian Wolff.

Added:
cfe/trunk/test/Index/keep-going.cpp
Modified:
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/lib/Basic/DiagnosticIDs.cpp
cfe/trunk/tools/c-index-test/c-index-test.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/unittests/Basic/DiagnosticTest.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=262318&r1=262317&r2=262318&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue Mar  1 04:56:19 2016
@@ -1208,7 +1208,18 @@ enum CXTranslationUnit_Flags {
* trades runtime on the first parse (serializing the preamble takes time) 
for
* reduced runtime on the second parse (can now reuse the preamble).
*/
-  CXTranslationUnit_CreatePreambleOnFirstParse = 0x100
+  CXTranslationUnit_CreatePreambleOnFirstParse = 0x100,
+
+  /**
+   * \brief Do not stop processing when fatal errors are encountered.
+   *
+   * When fatal errors are encountered while parsing a translation unit,
+   * semantic analysis is typically stopped early when compiling code. A common
+   * source for fatal errors are unresolvable include files. For the
+   * purposes of an IDE, this is undesirable behavior and as much information
+   * as possible should be reported. Use this flag to enable this behavior.
+   */
+  CXTranslationUnit_KeepGoing = 0x200
 };
 
 /**

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=262318&r1=262317&r2=262318&view=diff
==
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Tue Mar  1 04:56:19 2016
@@ -173,6 +173,7 @@ private:
   bool WarningsAsErrors; // Treat warnings like errors.
   bool EnableAllWarnings;// Enable all warnings.
   bool ErrorsAsFatal;// Treat errors like fatal errors.
+  bool FatalsAsError; // Treat fatal errors like errors.
   bool SuppressSystemWarnings;   // Suppress warnings in system headers.
   bool SuppressAllDiagnostics;   // Suppress all diagnostics.
   bool ElideType;// Elide common types of templates.
@@ -455,6 +456,12 @@ public:
   void setErrorsAsFatal(bool Val) { ErrorsAsFatal = Val; }
   bool getErrorsAsFatal() const { return ErrorsAsFatal; }
 
+  /// \brief When set to true, any fatal error reported is made an error.
+  ///
+  /// This setting takes precedence over the setErrorsAsFatal setting above.
+  void setFatalsAsError(bool Val) { FatalsAsError = Val; }
+  bool getFatalsAsError() const { return FatalsAsError; }
+
   /// \brief When set to true mask warnings that come from system headers.
   void setSuppressSystemWarnings(bool Val) { SuppressSystemWarnings = Val; }
   bool getSuppressSystemWarnings() const { return SuppressSystemWarnings; }

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=262318&r1=262317&r2=262318&view=diff
==
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Tue Mar  1 04:56:19 2016
@@ -68,6 +68,7 @@ DiagnosticsEngine::DiagnosticsEngine(
   WarningsAsErrors = false;
   EnableAllWarnings = false;
   ErrorsAsFatal = false;
+  FatalsAsError = false;
   SuppressSystemWarnings = false;
   SuppressAllDiagnostics = false;
   ElideType = true;

Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=262318&r1=262317&r2=262318&view=diff
==
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Tue Mar  1 04:56:19 2016
@@ -462,6 +462,12 @@ DiagnosticIDs::getDiagnosticSeverity(uns
   Result = diag::Severity::Fatal;
   }
 
+  // If explicitl

Re: [PATCH] D17727: Moved applyAllReplacementsAndFormat to clangFormat to avoid cyclic dependency.

2016-03-01 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 49470.
ioeric marked 5 inline comments as done.
ioeric added a comment.

- Fixed commenting.


http://reviews.llvm.org/D17727

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  lib/Format/Format.cpp
  lib/Tooling/Core/Replacement.cpp
  unittests/Format/CMakeLists.txt
  unittests/Format/FormatTest.cpp
  unittests/Tooling/RefactoringTest.cpp

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -418,6 +418,25 @@
   EXPECT_FALSE(Range(0, 10).contains(Range(0, 11)));
 }
 
+TEST(Range, CalculateRangesOfReplacements) {
+  // Before: bbz
+  // After : bbzz
+  Replacements Replaces;
+  Replaces.insert(Replacement("foo", 0, 4, ""));
+  Replaces.insert(Replacement("foo", 10, 1, "zz"));
+  Replaces.insert(Replacement("foo", 11, 0, ""));
+
+  std::vector Ranges = calculateChangedRangesInFile(Replaces);
+
+  EXPECT_EQ(3ul, Ranges.size());
+  EXPECT_TRUE(Ranges[0].getOffset() == 0);
+  EXPECT_TRUE(Ranges[0].getLength() == 0);
+  EXPECT_TRUE(Ranges[1].getOffset() == 6);
+  EXPECT_TRUE(Ranges[1].getLength() == 6);
+  EXPECT_TRUE(Ranges[2].getOffset() == 12);
+  EXPECT_TRUE(Ranges[2].getLength() == 16);
+}
+
 TEST(DeduplicateTest, removesDuplicates) {
   std::vector Input;
   Input.push_back(Replacement("fileA", 50, 0, " foo "));
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7,8 +7,12 @@
 //
 //===--===//
 
-#include "FormatTestUtils.h"
 #include "clang/Format/Format.h"
+
+#include "../Tooling/RewriterTestContext.h"
+#include "FormatTestUtils.h"
+
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
@@ -11165,6 +11169,46 @@
   verifyFormat("include \"a.td\"\ninclude \"b.td\"", Style);
 }
 
+class ReplacementTest : public ::testing::Test {
+protected:
+  tooling::Replacement createReplacement(SourceLocation Start, unsigned Length,
+ llvm::StringRef ReplacementText) {
+return tooling::Replacement(Context.Sources, Start, Length,
+ReplacementText);
+  }
+
+  RewriterTestContext Context;
+};
+
+TEST_F(ReplacementTest, FormatCodeAfterReplacements) {
+  // Column limit is 20.
+  std::string Code = "Type *a =\n"
+ "new Type();\n"
+ "g(i, 0, j,\n"
+ "  0, k, 0, mm);\n"
+ "int  bad = format   ;";
+  std::string Expected = "auto a = new Type();\n"
+ "g(i, nullptr,\n"
+ "  j, nullptr,\n"
+ "  k, nullptr,\n"
+ "  mm);\n"
+ "int  bad = format   ;";
+  FileID ID = Context.createInMemoryFile("format.cpp", Code);
+  tooling::Replacements Replaces;
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 3, 10), 1, "nullptr"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 4, 3), 1, "nullptr"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID, 4, 13), 1, "nullptr"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+  EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: unittests/Format/CMakeLists.txt
===
--- unittests/Format/CMakeLists.txt
+++ unittests/Format/CMakeLists.txt
@@ -13,5 +13,6 @@
 
 target_link_libraries(FormatTests
   clangFormat
+  clangFrontend
   clangToolingCore
   )
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -11,14 +11,15 @@
 //
 //===--===//
 
+#include "clang/Tooling/Core/Replacement.h"
+
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Rewrite/Core/Rewriter.h"
-#include "clang/Tooling/Core/Replacement.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_os_ostream.h"
@@

r262321 - [CLANG] [AVX512] [BUILTIN] Adding PSRA{Q|D|QI|DI}{128|256|512} builtin

2016-03-01 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Tue Mar  1 05:38:16 2016
New Revision: 262321

URL: http://llvm.org/viewvc/llvm-project?rev=262321&view=rev
Log:
[CLANG] [AVX512] [BUILTIN] Adding PSRA{Q|D|QI|DI}{128|256|512} builtin

Differential Revision: http://reviews.llvm.org/D17693


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=262321&r1=262320&r2=262321&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Mar  1 05:38:16 2016
@@ -1651,7 +1651,16 @@ TARGET_BUILTIN(__builtin_ia32_psllv2di_m
 TARGET_BUILTIN(__builtin_ia32_psllv4di_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psllv4si_mask, "V4iV4iV4iV4iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psllv8si_mask, "V8iV8iV8iV8iUc","","avx512vl")
-
+TARGET_BUILTIN(__builtin_ia32_pslldi512_mask, "V16iV16iiV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psllqi512_mask, 
"V8LLiV8LLiiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pslld128_mask, "V4iV4iV4iV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pslld256_mask, "V8iV8iV4iV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pslldi128_mask, "V4iV4iiV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pslldi256_mask, "V8iV8iiV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllq256_mask, 
"V4LLiV4LLiV2LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllqi128_mask, 
"V2LLiV2LLiiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllqi256_mask, 
"V4LLiV4LLiiV4LLiUc","","avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=262321&r1=262320&r2=262321&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue Mar  1 05:38:16 2016
@@ -3520,6 +3520,46 @@ __builtin_ia32_prorq512_mask ((__v8di)(
  (__mmask8)( __U));\
 })
 
+#define _mm512_slli_epi32( __A, __B) __extension__ ({ \
+__builtin_ia32_pslldi512_mask ((__v16si)( __A),( __B),\
+  (__v16si)\
+  _mm512_setzero_si512 (),\
+  (__mmask16) -1);\
+})
+
+#define _mm512_mask_slli_epi32( __W, __U, __A ,__B) __extension__ ({ \
+__builtin_ia32_pslldi512_mask ((__v16si) (__A), (__B),\
+  (__v16si)( __W),\
+  (__mmask16)( __U));\
+})
+
+#define _mm512_maskz_slli_epi32( __U, __A, __B) __extension__ ({ \
+__builtin_ia32_pslldi512_mask ((__v16si)( __A),( __B),\
+  (__v16si)\
+  _mm512_setzero_si512 (),\
+  (__mmask16)( __U));\
+})
+
+#define _mm512_slli_epi64( __A, __B) __extension__ ({ \
+__builtin_ia32_psllqi512_mask ((__v8di)( __A),( __B),\
+  (__v8di)\
+  _mm512_setzero_si512 (),\
+  (__mmask8) -1);\
+})
+
+#define _mm512_mask_slli_epi64( __W, __U, __A ,__B) __extension__ ({ \
+__builtin_ia32_psllqi512_mask ((__v8di) (__A), (__B),\
+  (__v8di)( __W),\
+  (__mmask8)( __U));\
+})
+
+#define _mm512_maskz_slli_epi64( __U, __A, __B) __extension__ ({ \
+__builtin_ia32_psllqi512_mask ((__v8di)( __A),( __B),\
+  (__v8di)\
+  _mm512_setzero_si512 (),\
+  (__mmask8)( __U));\
+})
+
 
 #undef __DEFAULT_FN_ATTRS
 

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=262321&r1=262320&r2=262321&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Tue Mar  1 05:38:16 2016
@@ -5215,6 +5215,138 @@ __builtin_ia32_prorq256_mask ((__v4di)(
  (__mmask8)( __U));\
 })
 
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_mask_sll_epi32 (__m128i __W, __mmask8 __U, __m128i __A,
+__m128i __B)
+{
+  return (__m128i) __builtin_ia32_pslld128_mask ((__v4si) __A,
+ (__v4si) __B,
+ (__v4si) __W,
+ (__mmask8) __U);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_maskz_sll_epi32 (__mmask8 __U, __m128i __A, __m128i __B)
+{
+  return (__m128i) __builtin_ia32_pslld128_mask ((__v4si) __A,
+ (__v4si) __B,
+ (__v4si)
+ _mm_setzero_si128 (),
+ (__mmask8) __U);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_mask_sll_epi32 (__m256i __W, __mmask8 __U, __m256i _

Re: [PATCH] D17727: Moved applyAllReplacementsAndFormat to clangFormat to avoid cyclic dependency.

2016-03-01 Thread Manuel Klimek via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG


http://reviews.llvm.org/D17727



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


r262323 - Add functions to apply replacements and reformat them.

2016-03-01 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Mar  1 06:37:30 2016
New Revision: 262323

URL: http://llvm.org/viewvc/llvm-project?rev=262323&view=rev
Log:
Add functions to apply replacements and reformat them.

This is a commonly useful feature to have, and we have implemented it
multiple times with different kinds of bugs. This implementation
centralizes the idea in a set of functions that we can then use from the various
tools.

Reverts r262234, which is a revert of r262232, and puts the functions
into FOrmat.h, as they are closely coupled to clang-format, and we
otherwise introduce a cyclic dependency between libFormat and
libTooling.

Patch by Eric Liu.

Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/include/clang/Tooling/Core/Replacement.h
cfe/trunk/lib/Format/Format.cpp
cfe/trunk/lib/Tooling/Core/Replacement.cpp
cfe/trunk/unittests/Format/CMakeLists.txt
cfe/trunk/unittests/Format/FormatTest.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=262323&r1=262322&r2=262323&view=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Tue Mar  1 06:37:30 2016
@@ -731,6 +731,28 @@ tooling::Replacements sortIncludes(const
StringRef FileName,
unsigned *Cursor = nullptr);
 
+/// \brief Returns the replacements corresponding to applying and formatting
+/// \p Replaces.
+tooling::Replacements formatReplacements(StringRef Code,
+ const tooling::Replacements &Replaces,
+ const FormatStyle &Style);
+
+/// \brief In addition to applying all replacements in \p Replaces to \p Code,
+/// this function also reformats the changed code after applying replacements.
+///
+/// \pre Replacements must be for the same file and conflict-free.
+///
+/// Replacement applications happen independently of the success of
+/// other applications.
+///
+/// \returns the changed code with all replacements applied and formatted, if
+/// successful. An empty string otherwise.
+///
+/// See also "include/clang/Tooling/Core/Replacements.h".
+std::string applyAllReplacementsAndFormat(StringRef Code,
+  const tooling::Replacements 
&Replaces,
+  const FormatStyle &Style);
+
 /// \brief Reformats the given \p Ranges in the file \p ID.
 ///
 /// Each range is extended on either end to its next bigger logic unit, i.e.

Modified: cfe/trunk/include/clang/Tooling/Core/Replacement.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Core/Replacement.h?rev=262323&r1=262322&r2=262323&view=diff
==
--- cfe/trunk/include/clang/Tooling/Core/Replacement.h (original)
+++ cfe/trunk/include/clang/Tooling/Core/Replacement.h Tue Mar  1 06:37:30 2016
@@ -220,6 +220,13 @@ bool applyAllReplacements(const std::vec
 /// replacements cannot be applied, this returns an empty \c string.
 std::string applyAllReplacements(StringRef Code, const Replacements &Replaces);
 
+/// \brief Calculate the ranges in a single file that are affected by the
+/// Replacements.
+///
+/// \pre Replacements must be for the same file.
+std::vector
+calculateChangedRangesInFile(const tooling::Replacements &Replaces);
+
 /// \brief Merges two sets of replacements with the second set referring to the
 /// code after applying the first set. Within both 'First' and 'Second',
 /// replacements must not overlap.

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=262323&r1=262322&r2=262323&view=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Mar  1 06:37:30 2016
@@ -1884,6 +1884,34 @@ tooling::Replacements sortIncludes(const
   return Replaces;
 }
 
+tooling::Replacements formatReplacements(StringRef Code,
+ const tooling::Replacements &Replaces,
+ const FormatStyle &Style) {
+  if (Replaces.empty())
+return tooling::Replacements();
+
+  std::string NewCode = applyAllReplacements(Code, Replaces);
+  std::vector ChangedRanges =
+  tooling::calculateChangedRangesInFile(Replaces);
+  StringRef FileName = Replaces.begin()->getFilePath();
+  tooling::Replacements FormatReplaces =
+  reformat(Style, NewCode, ChangedRanges, FileName);
+
+  tooling::Replacements MergedReplacements =
+  mergeReplacements(Replaces, FormatReplaces);
+  return MergedReplacements;
+}
+
+std::string applyAllReplacementsAndFormat(StringRef Code

r262324 - Fix DLL build by adding required dependency.

2016-03-01 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Mar  1 06:47:30 2016
New Revision: 262324

URL: http://llvm.org/viewvc/llvm-project?rev=262324&view=rev
Log:
Fix DLL build by adding required dependency.

Modified:
cfe/trunk/unittests/Format/CMakeLists.txt

Modified: cfe/trunk/unittests/Format/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CMakeLists.txt?rev=262324&r1=262323&r2=262324&view=diff
==
--- cfe/trunk/unittests/Format/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Format/CMakeLists.txt Tue Mar  1 06:47:30 2016
@@ -12,6 +12,7 @@ add_clang_unittest(FormatTests
   )
 
 target_link_libraries(FormatTests
+  clangBasic
   clangFormat
   clangFrontend
   clangToolingCore


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


r262326 - [CLANG][AVX512][BUILTIN] Adding PSRLV builtin

2016-03-01 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Tue Mar  1 07:03:45 2016
New Revision: 262326

URL: http://llvm.org/viewvc/llvm-project?rev=262326&view=rev
Log:
[CLANG][AVX512][BUILTIN] Adding PSRLV builtin 

Differential Revision: http://reviews.llvm.org/D17718


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=262326&r1=262325&r2=262326&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Mar  1 07:03:45 2016
@@ -1661,6 +1661,13 @@ TARGET_BUILTIN(__builtin_ia32_psllq128_m
 TARGET_BUILTIN(__builtin_ia32_psllq256_mask, 
"V4LLiV4LLiV2LLiV4LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psllqi128_mask, 
"V2LLiV2LLiiV2LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psllqi256_mask, 
"V4LLiV4LLiiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrlv32hi_mask, 
"V32sV32sV32sV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_psrlv16hi_mask, 
"V16sV16sV16sV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrlv8hi_mask, 
"V8sV8sV8sV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrlv2di_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrlv4di_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrlv4si_mask, "V4iV4iV4iV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrlv8si_mask, "V8iV8iV8iV8iUc","","avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=262326&r1=262325&r2=262326&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Tue Mar  1 07:03:45 2016
@@ -1718,6 +1718,37 @@ __builtin_ia32_psllwi512_mask ((__v32hi)
   (__mmask32)( __U));\
 })
 
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_srlv_epi16 (__m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_psrlv32hi_mask ((__v32hi) __A,
+  (__v32hi) __B,
+  (__v32hi)
+  _mm512_setzero_hi (),
+  (__mmask32) -1);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_srlv_epi16 (__m512i __W, __mmask32 __U, __m512i __A,
+  __m512i __B)
+{
+  return (__m512i) __builtin_ia32_psrlv32hi_mask ((__v32hi) __A,
+  (__v32hi) __B,
+  (__v32hi) __W,
+  (__mmask32) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_srlv_epi16 (__mmask32 __U, __m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_psrlv32hi_mask ((__v32hi) __A,
+  (__v32hi) __B,
+  (__v32hi)
+  _mm512_setzero_hi (),
+  (__mmask32) __U);
+}
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif

Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=262326&r1=262325&r2=262326&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Tue Mar  1 07:03:45 2016
@@ -2593,6 +2593,68 @@ __builtin_ia32_psllwi256_mask ((__v16hi)
   (__mmask16)( __U));\
 })
 
+
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_srlv_epi16 (__m256i __A, __m256i __B)
+{
+  return (__m256i) __builtin_ia32_psrlv16hi_mask ((__v16hi) __A,
+  (__v16hi) __B,
+  (__v16hi)
+  _mm256_setzero_si256 (),
+  (__mmask16) -1);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_mask_srlv_epi16 (__m256i __W, __mmask16 __U, __m256i __A,
+  __m256i __B)
+{
+  return (__m256i) __builtin_ia32_psrlv16hi_mask ((__v16hi) __A,
+  (__v16hi) __B,
+  (__v16hi) __W,
+  (__mmask16) __U);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_maskz_srlv_epi16 (__mmask16 __U, __m256i __A, __m256i __B)
+{
+  return (__m256i) __builtin_ia32_psrlv16hi_mask ((__v16hi) __A,
+  (__v16hi) __B,
+  (__v16hi)
+  _mm256_setzero_si256 (),
+  (__mmask16) __U);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_srlv_epi16 (__m128i __A, __m128i __B)
+{
+  return (__m128i) __builtin_ia32_psrlv8hi_mask ((__v8hi) __A,
+ (__v8hi) __B,
+ (__v8hi)
+ _mm_setzero_hi (),
+ (__mmask8) -1);
+}
+
+static __inline__ __m128i

r262325 - Fix test breakage on windows where the default std is c++11 by forcing c++03 in the test.

2016-03-01 Thread Manuel Klimek via cfe-commits
Author: klimek
Date: Tue Mar  1 06:53:18 2016
New Revision: 262325

URL: http://llvm.org/viewvc/llvm-project?rev=262325&view=rev
Log:
Fix test breakage on windows where the default std is c++11 by forcing c++03 in 
the test.

Modified:
cfe/trunk/test/Index/keep-going.cpp

Modified: cfe/trunk/test/Index/keep-going.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/keep-going.cpp?rev=262325&r1=262324&r2=262325&view=diff
==
--- cfe/trunk/test/Index/keep-going.cpp (original)
+++ cfe/trunk/test/Index/keep-going.cpp Tue Mar  1 06:53:18 2016
@@ -9,7 +9,7 @@ class B : public A { };
 
 class C : public A { };
 
-// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_KEEP_GOING=1 c-index-test 
-test-print-type %s 2> %t.stderr.txt  | FileCheck %s
+// RUN: env CINDEXTEST_EDITING=1 CINDEXTEST_KEEP_GOING=1 c-index-test 
-test-print-type %s -std=c++03 2> %t.stderr.txt  | FileCheck %s
 // RUN: FileCheck -check-prefix CHECK-DIAG %s < %t.stderr.txt
 
 // CHECK: inclusion directive=missing1.h ((null)) [type=] [typekind=Invalid] 
[isPOD=0]


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


r262329 - FormatTests: Update libdeps corresponding to r262323.

2016-03-01 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Tue Mar  1 07:11:36 2016
New Revision: 262329

URL: http://llvm.org/viewvc/llvm-project?rev=262329&view=rev
Log:
FormatTests: Update libdeps corresponding to r262323.

Modified:
cfe/trunk/unittests/Format/CMakeLists.txt

Modified: cfe/trunk/unittests/Format/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/CMakeLists.txt?rev=262329&r1=262328&r2=262329&view=diff
==
--- cfe/trunk/unittests/Format/CMakeLists.txt (original)
+++ cfe/trunk/unittests/Format/CMakeLists.txt Tue Mar  1 07:11:36 2016
@@ -15,5 +15,6 @@ target_link_libraries(FormatTests
   clangBasic
   clangFormat
   clangFrontend
+  clangRewrite
   clangToolingCore
   )


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


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-01 Thread Aaron Ballman via cfe-commits
On Tue, Mar 1, 2016 at 2:16 AM, Alexander Riccio  wrote:
> ariccio updated this revision to Diff 49456.
> ariccio added a comment.
>
> Nit addressed.
>
>
> http://reviews.llvm.org/D17688
>
> Files:
>   llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>
> Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> ===
> --- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> +++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> @@ -169,11 +169,12 @@
>  {
>  public:
>MallocChecker()
> -  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
> -II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr),
> -II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr),
> -II_kmalloc(nullptr), II_if_nameindex(nullptr),
> -II_if_freenameindex(nullptr) {}
> +  : II_alloca(nullptr), II_win_alloca(nullptr), II_malloc(nullptr),
> +II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
> +II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
> +II_strdup(nullptr), II_win_strdup(nullptr), II_kmalloc(nullptr),
> +II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
> +II_wcsdup(nullptr), II_win_wcsdup(nullptr) {}
>
>/// In pessimistic mode, the checker assumes that it does not know which
>/// functions might free the memory.
> @@ -231,10 +232,11 @@
>mutable std::unique_ptr BT_MismatchedDealloc;
>mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
>mutable std::unique_ptr BT_UseZerroAllocated[CK_NumCheckKinds];
> -  mutable IdentifierInfo *II_alloca, *II_malloc, *II_free, *II_realloc,
> - *II_calloc, *II_valloc, *II_reallocf, *II_strndup,
> - *II_strdup, *II_kmalloc, *II_if_nameindex,
> - *II_if_freenameindex;
> +  mutable IdentifierInfo *II_alloca, *II_win_alloca, *II_malloc, *II_free,
> + *II_realloc, *II_calloc, *II_valloc, *II_reallocf,
> + *II_strndup, *II_strdup, *II_win_strdup, 
> *II_kmalloc,
> + *II_if_nameindex, *II_if_freenameindex, *II_wcsdup,
> + *II_win_wcsdup;
>mutable Optional KernelZeroFlagVal;
>
>void initIdentifierInfo(ASTContext &C) const;
> @@ -540,9 +542,15 @@
>II_valloc = &Ctx.Idents.get("valloc");
>II_strdup = &Ctx.Idents.get("strdup");
>II_strndup = &Ctx.Idents.get("strndup");
> +  II_wcsdup = &Ctx.Idents.get("wcsdup");
>II_kmalloc = &Ctx.Idents.get("kmalloc");
>II_if_nameindex = &Ctx.Idents.get("if_nameindex");
>II_if_freenameindex = &Ctx.Idents.get("if_freenameindex");
> +
> +  //MSVC uses `_`-prefixed instead, so we check for them too.
> +  II_win_strdup = &Ctx.Idents.get("_strdup");
> +  II_win_wcsdup = &Ctx.Idents.get("_wcsdup");
> +  II_win_alloca = &Ctx.Idents.get("_alloca");

What about: _mbsdup, _strdup_dbg, _wcsdup_dbg, _aligned_realloc, and
the rest? If we're going to add these (which I really support), it
would be good to make a comprehensive sweep for the Win32 additions
and add them all.

~Aaron

>  }
>
>  bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext &C) 
> const {
> @@ -585,7 +593,8 @@
>  if (Family == AF_Malloc && CheckAlloc) {
>if (FunI == II_malloc || FunI == II_realloc || FunI == II_reallocf ||
>FunI == II_calloc || FunI == II_valloc || FunI == II_strdup ||
> -  FunI == II_strndup || FunI == II_kmalloc)
> +  FunI == II_win_strdup || FunI == II_strndup || FunI == II_wcsdup ||
> +  FunI == II_win_wcsdup || FunI == II_kmalloc)
>  return true;
>  }
>
> @@ -600,7 +609,7 @@
>  }
>
>  if (Family == AF_Alloca && CheckAlloc) {
> -  if (FunI == II_alloca)
> +  if (FunI == II_alloca || FunI == II_win_alloca)
>  return true;
>  }
>}
> @@ -789,11 +798,12 @@
>State = ProcessZeroAllocation(C, CE, 1, State);
>  } else if (FunI == II_free) {
>State = FreeMemAux(C, CE, State, 0, false, ReleasedAllocatedMemory);
> -} else if (FunI == II_strdup) {
> +} else if (FunI == II_strdup || FunI == II_win_strdup ||
> +   FunI == II_wcsdup || FunI == II_win_wcsdup) {
>State = MallocUpdateRefState(C, CE, State);
>  } else if (FunI == II_strndup) {
>State = MallocUpdateRefState(C, CE, State);
> -} else if (FunI == II_alloca) {
> +} else if (FunI == II_alloca || FunI == II_win_alloca) {
>State = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(), State,
> AF_Alloca);
>State = ProcessZeroAllocation(C, CE, 0, State);
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17761: Added applyAllReplacementsAndFormat that works for multiple files.

2016-03-01 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added a reviewer: klimek.
ioeric added subscribers: klimek, cfe-commits.

Added applyAllReplacementsAndFormat that works for multiple files.

http://reviews.llvm.org/D17761

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Tooling/Core/Replacement.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11215,6 +11215,73 @@
   EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+
+  EXPECT_TRUE(applyAllReplacementsAndFormat(Replaces, Context.Rewrite, Style));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
+TEST_F(ReplacementTest, ConflictReplacements) {
+  // Column limit is 20.
+  std::string Code1 = "Did you say it is a code?";
+
+  std::string Code2 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected2 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  FileID ID1 = Context.createInMemoryFile("fake.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("real.cpp", Code2);
+  tooling::Replacements Replaces;
+
+  // Two Replacements for ID1 conflict with each other.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 5), 6, "yoyoyo"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 3), 6, "yoyoyo?"));
+
+  // Replacements for ID2 should be applied independently of the failure in ID1.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 3, 10), 1, "12345678901"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 1), 6, "auto "));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+  EXPECT_FALSE(applyAllReplacementsAndFormat(Replaces, Context.Rewrite, Style));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -390,6 +390,17 @@
 };
 } // namespace
 
+FileToReplacementsMap
+groupReplacementsByFile(const Replacements &Replaces, FileManager &Files) {
+  FileToReplacementsMap FileToReplaces;
+  for (const auto &Replace : Replaces) {
+const FileEntry *Entry = Files.getFile(Replace.getFilePath());
+assert(Entry && "Expected an existing file.");
+FileToReplaces[Entry].push_back(Replace);
+  }
+  return FileToReplaces;
+}
+
 Replacements mergeReplacements(const Replacements &First,
const Replacements &Second) {
   if (First.empty() || Second.empty())
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -23,6 +23,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
+#include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Debug.h"
@@ -1902,6 +1903,47 @@
   return MergedReplacements;

Re: [clang-tools-extra] r262257 - IdentifierNamingCheck.cpp: try to fix MSVC build

2016-03-01 Thread Alexander Kornienko via cfe-commits
Thanks for the fix! When did it start failing? The last change in this file
was quite a while ago. Did it start breaking because of a change in a
header?

On Mon, Feb 29, 2016 at 10:17 PM, Hans Wennborg via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: hans
> Date: Mon Feb 29 15:17:39 2016
> New Revision: 262257
>
> URL: http://llvm.org/viewvc/llvm-project?rev=262257&view=rev
> Log:
> IdentifierNamingCheck.cpp: try to fix MSVC build
>
> It was failing to build with:
>
> clang-tidy\readability\IdentifierNamingCheck.cpp(640):
> error C2882: 'format' : illegal use of namespace identifier in expression
>
> Modified:
>
> clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.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=262257&r1=262256&r2=262257&view=diff
>
> ==
> ---
> clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
> (original)
> +++
> clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
> Mon Feb 29 15:17:39 2016
> @@ -634,10 +634,10 @@ void IdentifierNamingCheck::check(const
>  std::string Fixup = fixupWithStyle(Name, Style);
>  if (StringRef(Fixup).equals(Name)) {
>if (!IgnoreFailedSplit) {
> -DEBUG(llvm::dbgs() << Decl->getLocStart().printToString(
> -  *Result.SourceManager)
> -   << format(": unable to split words for %s
> '%s'\n",
> - KindName.c_str(), Name));
> +DEBUG(llvm::dbgs()
> +  << Decl->getLocStart().printToString(*Result.SourceManager)
> +  << llvm::format(": unable to split words for %s '%s'\n",
> +  KindName.c_str(), Name));
>}
>  } else {
>NamingCheckFailure &Failure = NamingCheckFailures[Decl];
>
>
> ___
> 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


Re: [PATCH] D17761: Added applyAllReplacementsAndFormat that works for multiple files.

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

- Fixed commenting issue due to merge.


http://reviews.llvm.org/D17761

Files:
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Tooling/Core/Replacement.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11215,6 +11215,73 @@
   EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+
+  EXPECT_TRUE(applyAllReplacementsAndFormat(Replaces, Context.Rewrite, Style));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
+TEST_F(ReplacementTest, ConflictReplacements) {
+  // Column limit is 20.
+  std::string Code1 = "Did you say it is a code?";
+
+  std::string Code2 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected2 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  FileID ID1 = Context.createInMemoryFile("fake.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("real.cpp", Code2);
+  tooling::Replacements Replaces;
+
+  // Two Replacements for ID1 conflict with each other.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 5), 6, "yoyoyo"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 3), 6, "yoyoyo?"));
+
+  // Replacements for ID2 should be applied independently of the failure in ID1.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 3, 10), 1, "12345678901"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 1), 6, "auto "));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+  EXPECT_FALSE(applyAllReplacementsAndFormat(Replaces, Context.Rewrite, Style));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -390,6 +390,17 @@
 };
 } // namespace
 
+FileToReplacementsMap
+groupReplacementsByFile(const Replacements &Replaces, FileManager &Files) {
+  FileToReplacementsMap FileToReplaces;
+  for (const auto &Replace : Replaces) {
+const FileEntry *Entry = Files.getFile(Replace.getFilePath());
+assert(Entry && "Expected an existing file.");
+FileToReplaces[Entry].push_back(Replace);
+  }
+  return FileToReplaces;
+}
+
 Replacements mergeReplacements(const Replacements &First,
const Replacements &Second) {
   if (First.empty() || Second.empty())
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -23,6 +23,7 @@
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
+#include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Debug.h"
@@ -1902,6 +1903,47 @@
   return MergedReplacements;
 }
 
+bool applyAllReplacementsAndFormat(const tooling::Replacements

Re: SourceTypeInfo for long long

2016-03-01 Thread Alexander Kornienko via cfe-commits
+cfe-commits for wider audience.

Hi Piotr,

On Tue, Mar 1, 2016 at 2:36 PM, Piotr Padlewski 
wrote:

> Hi Alexey,
>
I am currently writing new check
> https://llvm.org/bugs/show_bug.cgi?id=26763
>

Awesome! Sorry I didn't have time yet to comment on the issues you filed,
though I have a couple of thoughts.


>
> I have problem with SourceTypeInfo. I am doing the same thing as
> modernize-use-auto (for new expression) does, but it doesn't work for non
> pointer types.
>

If you point me to the code, it will be easier to answer your question.
Currently I can only guess what you're talking about.


> I have checked, and my code works for pointers types like long long.
>

What do you mean by `long long` being a `pointer type`?

In any case, without seeing the code it's hard to answer your question. You
can upload a patch to reviews.llvm.org and add a test case that fails for
you (or another good way to reproduce the issue you're facing).


>
> Am I doing something wrong, or is it just bug in SourceTypeInfo.getEnd()?
>
> Piotr
>

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


r262334 - [cmake] Fallback to LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR if COMPILER_RT_SRC_ROOT doesn't exist.

2016-03-01 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue Mar  1 08:08:13 2016
New Revision: 262334

URL: http://llvm.org/viewvc/llvm-project?rev=262334&view=rev
Log:
[cmake] Fallback to LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR if 
COMPILER_RT_SRC_ROOT doesn't exist.

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=262334&r1=262333&r2=262334&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Tue Mar  1 08:08:13 2016
@@ -23,6 +23,13 @@ function(get_ext_project_build_command o
 endfunction()
 
 set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC_DIR}/projects/compiler-rt)
+# Fallback to the external path, if the other one isn't available.
+# This is the same behavior (try "internal", then check the LLVM_EXTERNAL_...
+# variable) as in add_llvm_external_project
+if(NOT EXISTS ${COMPILER_RT_SRC_ROOT})
+  set(COMPILER_RT_SRC_ROOT ${LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR})
+endif()
+
 if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
   if(CMAKE_VERSION VERSION_GREATER 3.3.20150708)
 set(cmake_3_4_USES_TERMINAL_OPTIONS


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


r262335 - [cmake] Use CMake's USES_TERMINAL for the test targets.

2016-03-01 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue Mar  1 08:08:18 2016
New Revision: 262335

URL: http://llvm.org/viewvc/llvm-project?rev=262335&view=rev
Log:
[cmake] Use CMake's USES_TERMINAL for the test targets.

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=262335&r1=262334&r2=262335&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Tue Mar  1 08:08:18 2016
@@ -129,7 +129,9 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
 COMMAND ${run_test_suite}
 DEPENDS compiler-rt-build ${COMPILER_RT_TEST_DEPENDENCIES}
 WORKING_DIRECTORY ${BINARY_DIR}
-VERBATIM)
+VERBATIM
+${cmake_3_2_USES_TERMINAL}
+)
 endforeach()
 
 # Add special target to run all compiler-rt test suites.


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


r262336 - [cmake] Pass through the cmake_3_2_USES_TERMINAL variable so we get progress bars on an external compiler-rt build

2016-03-01 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue Mar  1 08:10:38 2016
New Revision: 262336

URL: http://llvm.org/viewvc/llvm-project?rev=262336&view=rev
Log:
[cmake] Pass through the cmake_3_2_USES_TERMINAL variable so we get progress 
bars on an external compiler-rt build

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=262336&r1=262335&r2=262336&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Tue Mar  1 08:10:38 2016
@@ -79,6 +79,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E

-DCOMPILER_RT_INSTALL_PATH:STRING=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
+   -Dcmake_3_2_USES_TERMINAL=${cmake_3_2_USES_TERMINAL}
${COMPILER_RT_PASSTHROUGH_VARIABLES}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build


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


Re: SourceTypeInfo for long long

2016-03-01 Thread Piotr Padlewski via cfe-commits
review:
http://reviews.llvm.org/D17765

2016-03-01 15:12 GMT+01:00 Piotr Padlewski :

> my pass works for things like
> (note that for test purposes I use lexical_cast that doesn't do anything,
> so the second one compiles)
>
> int a = boost::lexical_cast("42");
> long long* b = boost::lexical_cast("42");
>
> =>
> auto a = boost::lexical_cast("42");
> auto b = boost::lexical_cast("42");
>
> but it doesnt work for
> long long a = boost::lexical_cast("42");
> =>
> auto long a = boost::lexical_cast("42");
>
> I will post review in few minutes.
>
>
> 2016-03-01 15:09 GMT+01:00 Alexander Kornienko :
>
>> +cfe-commits for wider audience.
>>
>> Hi Piotr,
>>
>> On Tue, Mar 1, 2016 at 2:36 PM, Piotr Padlewski <
>> piotr.padlew...@gmail.com> wrote:
>>
>>> Hi Alexey,
>>>
>> I am currently writing new check
>>> https://llvm.org/bugs/show_bug.cgi?id=26763
>>>
>>
>> Awesome! Sorry I didn't have time yet to comment on the issues you filed,
>> though I have a couple of thoughts.
>>
>>
>>>
>>> I have problem with SourceTypeInfo. I am doing the same thing as
>>> modernize-use-auto (for new expression) does, but it doesn't work for non
>>> pointer types.
>>>
>>
>> If you point me to the code, it will be easier to answer your question.
>> Currently I can only guess what you're talking about.
>>
>>
>>> I have checked, and my code works for pointers types like long long.
>>>
>>
>> What do you mean by `long long` being a `pointer type`?
>>
>> In any case, without seeing the code it's hard to answer your question.
>> You can upload a patch to reviews.llvm.org and add a test case that
>> fails for you (or another good way to reproduce the issue you're facing).
>>
>>
>>>
>>> Am I doing something wrong, or is it just bug in SourceTypeInfo.getEnd()?
>>>
>>> Piotr
>>>
>>
>> -- Alexander
>>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17764: Add attributes for AMD GPU Tools

2016-03-01 Thread Konstantin Zhuravlyov via cfe-commits
kzhuravl-AMD created this revision.
kzhuravl-AMD added reviewers: arsenm, tstellarAMD.
kzhuravl-AMD added a subscriber: cfe-commits.

Add following kernel function attributes for AMD GPU Tools (debugger, profiler):
  - amdgpu_tools_insert_nops - insert two nop instructions for each high level 
source statement
  - amdgpu_tools_num_reserved_vgpr() - reserve  vector registers and 
do not use throughout kernel execution
  - amdgpu_tools_num_reserved_sgpr() - reserve  scalar registers and 
do not use throughout kernel execution

Also add similar options that cause to insert attributes for each kernel, 
options take precedence

+ Updated docs, added tests

http://reviews.llvm.org/D17764

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/TargetInfo.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGenOpenCL/amdgpu-tools-attrs-opts-precedence.cl
  test/CodeGenOpenCL/amdgpu-tools-attrs.cl
  test/CodeGenOpenCL/amdgpu-tools-opts.cl
  test/SemaOpenCL/amdgpu-tools-attrs.cl

Index: test/SemaOpenCL/amdgpu-tools-attrs.cl
===
--- /dev/null
+++ test/SemaOpenCL/amdgpu-tools-attrs.cl
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -triple amdgcn-- -verify -fsyntax-only %s
+
+// Check attributes with non kernel function
+typedef __attribute__((amdgpu_tools_insert_nops)) struct foo0_s { // expected-error {{'amdgpu_tools_insert_nops' attribute only applies to kernel functions}}
+  int x;
+  int y;
+} foo0_t;
+typedef __attribute__((amdgpu_tools_num_reserved_vgpr(8))) struct foo1_s { // expected-error {{'amdgpu_tools_num_reserved_vgpr' attribute only applies to kernel functions}}
+  int x;
+  int y;
+} foo1_t;
+typedef __attribute__((amdgpu_tools_num_reserved_sgpr(4))) struct foo2_s { // expected-error {{'amdgpu_tools_num_reserved_sgpr' attribute only applies to kernel functions}}
+  int x;
+  int y;
+} foo2_t;
+
+// Check non integer attribute values.
+__attribute__((amdgpu_tools_num_reserved_vgpr("ABC"))) kernel void foo3() {} // expected-error {{'amdgpu_tools_num_reserved_vgpr' attribute requires an integer constant}}
+__attribute__((amdgpu_tools_num_reserved_sgpr("DEF"))) kernel void foo4() {} // expected-error {{'amdgpu_tools_num_reserved_sgpr' attribute requires an integer constant}}
+
+// Check large attribute values.
+__attribute__((amdgpu_tools_num_reserved_vgpr(4294967296))) kernel void foo5() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
+__attribute__((amdgpu_tools_num_reserved_sgpr(4294967296))) kernel void foo6() {} // expected-error {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
+__attribute__((amdgpu_tools_num_reserved_vgpr(4294967296), amdgpu_tools_num_reserved_sgpr(4294967296))) kernel void foo7() {} // expected-error 2 {{integer constant expression evaluates to value 4294967296 that cannot be represented in a 32-bit unsigned integer type}}
+
+// Check valid attributes.
+__attribute__((amdgpu_tools_insert_nops)) kernel void foo8() {}
+__attribute__((amdgpu_tools_num_reserved_vgpr(8))) kernel void foo9() {}
+__attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_vgpr(8))) kernel void foo10() {}
+__attribute__((amdgpu_tools_num_reserved_sgpr(4))) kernel void foo11() {}
+__attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_sgpr(4))) kernel void foo12() {}
+__attribute__((amdgpu_tools_num_reserved_vgpr(8), amdgpu_tools_num_reserved_sgpr(4))) kernel void foo13() {}
+__attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_vgpr(8), amdgpu_tools_num_reserved_sgpr(4))) kernel void foo14() {}
+// Make sure 0 VGPRs is accepted.
+__attribute__((amdgpu_tools_num_reserved_vgpr(0))) kernel void foo15() {}
+// Make sure 0 SGPRs is accepted.
+__attribute__((amdgpu_tools_num_reserved_sgpr(0))) kernel void foo16() {}
+// Make sure 0 VGPRs and 0 SGPRs is accepted.
+__attribute__((amdgpu_tools_num_reserved_vgpr(0), amdgpu_tools_num_reserved_sgpr(0))) kernel void foo17() {}
+// Make sure kernel keyword can go before __attribute__ keyword.
+kernel __attribute__((amdgpu_tools_insert_nops)) void foo18() {}
+kernel __attribute__((amdgpu_tools_num_reserved_vgpr(8))) void foo19() {}
+kernel __attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_vgpr(8))) void foo20() {}
+kernel __attribute__((amdgpu_tools_num_reserved_sgpr(4))) void foo21() {}
+kernel __attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_sgpr(4))) void foo22() {}
+kernel __attribute__((amdgpu_tools_num_reserved_vgpr(8), amdgpu_tools_num_reserved_sgpr(4))) void foo23() {}
+kernel __attribute__((amdgpu_tools_insert_nops, amdgpu_tools_num_reserved_vgpr(8), amdgpu_tools_num_reserved_sgpr(4))) void foo24(

Re: SourceTypeInfo for long long

2016-03-01 Thread Piotr Padlewski via cfe-commits
my pass works for things like
(note that for test purposes I use lexical_cast that doesn't do anything,
so the second one compiles)

int a = boost::lexical_cast("42");
long long* b = boost::lexical_cast("42");

=>
auto a = boost::lexical_cast("42");
auto b = boost::lexical_cast("42");

but it doesnt work for
long long a = boost::lexical_cast("42");
=>
auto long a = boost::lexical_cast("42");

I will post review in few minutes.


2016-03-01 15:09 GMT+01:00 Alexander Kornienko :

> +cfe-commits for wider audience.
>
> Hi Piotr,
>
> On Tue, Mar 1, 2016 at 2:36 PM, Piotr Padlewski  > wrote:
>
>> Hi Alexey,
>>
> I am currently writing new check
>> https://llvm.org/bugs/show_bug.cgi?id=26763
>>
>
> Awesome! Sorry I didn't have time yet to comment on the issues you filed,
> though I have a couple of thoughts.
>
>
>>
>> I have problem with SourceTypeInfo. I am doing the same thing as
>> modernize-use-auto (for new expression) does, but it doesn't work for non
>> pointer types.
>>
>
> If you point me to the code, it will be easier to answer your question.
> Currently I can only guess what you're talking about.
>
>
>> I have checked, and my code works for pointers types like long long.
>>
>
> What do you mean by `long long` being a `pointer type`?
>
> In any case, without seeing the code it's hard to answer your question.
> You can upload a patch to reviews.llvm.org and add a test case that fails
> for you (or another good way to reproduce the issue you're facing).
>
>
>>
>> Am I doing something wrong, or is it just bug in SourceTypeInfo.getEnd()?
>>
>> Piotr
>>
>
> -- Alexander
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: SourceTypeInfo for long long

2016-03-01 Thread Alexander Kornienko via cfe-commits
Answered on the review thread. The problem is with BuiltinTypeLoc not
storing the location for the end token of builtin type names consisting of
multiple tokens. This can be worked around by re-lexing a fragment of the
code for now.

Richard, does it make sense to store the end location in BuiltinTypeLoc?

On Tue, Mar 1, 2016 at 3:30 PM, Piotr Padlewski 
wrote:

> review:
> http://reviews.llvm.org/D17765
>
> 2016-03-01 15:12 GMT+01:00 Piotr Padlewski :
>
>> my pass works for things like
>> (note that for test purposes I use lexical_cast that doesn't do anything,
>> so the second one compiles)
>>
>> int a = boost::lexical_cast("42");
>> long long* b = boost::lexical_cast("42");
>>
>> =>
>> auto a = boost::lexical_cast("42");
>> auto b = boost::lexical_cast("42");
>>
>> but it doesnt work for
>> long long a = boost::lexical_cast("42");
>> =>
>> auto long a = boost::lexical_cast("42");
>>
>> I will post review in few minutes.
>>
>>
>> 2016-03-01 15:09 GMT+01:00 Alexander Kornienko :
>>
>>> +cfe-commits for wider audience.
>>>
>>> Hi Piotr,
>>>
>>> On Tue, Mar 1, 2016 at 2:36 PM, Piotr Padlewski <
>>> piotr.padlew...@gmail.com> wrote:
>>>
 Hi Alexey,

>>> I am currently writing new check
 https://llvm.org/bugs/show_bug.cgi?id=26763

>>>
>>> Awesome! Sorry I didn't have time yet to comment on the issues you
>>> filed, though I have a couple of thoughts.
>>>
>>>

 I have problem with SourceTypeInfo. I am doing the same thing as
 modernize-use-auto (for new expression) does, but it doesn't work for non
 pointer types.

>>>
>>> If you point me to the code, it will be easier to answer your question.
>>> Currently I can only guess what you're talking about.
>>>
>>>
 I have checked, and my code works for pointers types like long long.

>>>
>>> What do you mean by `long long` being a `pointer type`?
>>>
>>> In any case, without seeing the code it's hard to answer your question.
>>> You can upload a patch to reviews.llvm.org and add a test case that
>>> fails for you (or another good way to reproduce the issue you're facing).
>>>
>>>

 Am I doing something wrong, or is it just bug in
 SourceTypeInfo.getEnd()?

 Piotr

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


Re: [PATCH] D17722: Make sure SLocEntry is an expansion before using getExpansion() method in SourceManager.

2016-03-01 Thread Benjamin Kramer via cfe-commits
bkramer added a comment.

This doesn't have a test case. Also I don't understand why this is the correct 
fix. If someone is calling one of those method with a file SourceLocation (as 
opposed to a macro SourceLocation) they should stop doing that.


Repository:
  rL LLVM

http://reviews.llvm.org/D17722



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


r262340 - [cmake] Try to appease the buildbots.

2016-03-01 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue Mar  1 09:07:19 2016
New Revision: 262340

URL: http://llvm.org/viewvc/llvm-project?rev=262340&view=rev
Log:
[cmake] Try to appease the buildbots.

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=262340&r1=262339&r2=262340&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Tue Mar  1 09:07:19 2016
@@ -27,7 +27,10 @@ set(COMPILER_RT_SRC_ROOT ${LLVM_MAIN_SRC
 # This is the same behavior (try "internal", then check the LLVM_EXTERNAL_...
 # variable) as in add_llvm_external_project
 if(NOT EXISTS ${COMPILER_RT_SRC_ROOT})
-  set(COMPILER_RT_SRC_ROOT ${LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR})
+  # We don't want to set it if LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR is ""
+  if(${LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR})
+set(COMPILER_RT_SRC_ROOT ${LLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR})
+  endif()
 endif()
 
 if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)


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


Re: [PATCH] D17761: Added applyAllReplacementsAndFormat that works for multiple files.

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

- Added getOrCreateFileID interface in SourceManager.


http://reviews.llvm.org/D17761

Files:
  include/clang/Basic/SourceManager.h
  include/clang/Format/Format.h
  include/clang/Tooling/Core/Replacement.h
  lib/Format/CMakeLists.txt
  lib/Format/Format.cpp
  lib/Tooling/Core/Replacement.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11215,6 +11215,73 @@
   EXPECT_EQ(Expected, applyAllReplacementsAndFormat(Code, Replaces, Style));
 }
 
+TEST_F(ReplacementTest, MultipleFilesReplaceAndFormat) {
+  // Column limit is 20.
+  std::string Code1 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected1 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  std::string Code2 = "int x = 123;\n"
+  "int y = 0;";
+  std::string Expected2 = "int x =\n"
+  "1234567890123;\n"
+  "int y = 10;";
+  FileID ID1 = Context.createInMemoryFile("format_1.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("format_2.cpp", Code2);
+
+  tooling::Replacements Replaces;
+  // Scrambled the order of replacements.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 12), 0, "4567890123"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 1), 6, "auto "));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 2, 9), 1, "10"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 3, 10), 1, "12345678901"));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+
+  EXPECT_TRUE(applyAllReplacementsAndFormat(Replaces, Context.Rewrite, Style));
+  EXPECT_EQ(Expected1, Context.getRewrittenText(ID1));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
+TEST_F(ReplacementTest, ConflictReplacements) {
+  // Column limit is 20.
+  std::string Code1 = "Did you say it is a code?";
+
+  std::string Code2 = "Long *a =\n"
+  "new Long();\n"
+  "long x = 1;";
+  std::string Expected2 = "auto a = new Long();\n"
+  "long x =\n"
+  "12345678901;";
+  FileID ID1 = Context.createInMemoryFile("fake.cpp", Code1);
+  FileID ID2 = Context.createInMemoryFile("real.cpp", Code2);
+  tooling::Replacements Replaces;
+
+  // Two Replacements for ID1 conflict with each other.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 5), 6, "yoyoyo"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID1, 1, 3), 6, "yoyoyo?"));
+
+  // Replacements for ID2 should be applied independently of the failure in ID1.
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 3, 10), 1, "12345678901"));
+  Replaces.insert(tooling::Replacement(
+  Context.Sources, Context.getLocation(ID2, 1, 1), 6, "auto "));
+
+  format::FormatStyle Style = format::getLLVMStyle();
+  Style.ColumnLimit = 20; // Set column limit to 20 to increase readibility.
+  EXPECT_FALSE(applyAllReplacementsAndFormat(Replaces, Context.Rewrite, Style));
+  EXPECT_EQ(Expected2, Context.getRewrittenText(ID2));
+}
+
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Tooling/Core/Replacement.cpp
===
--- lib/Tooling/Core/Replacement.cpp
+++ lib/Tooling/Core/Replacement.cpp
@@ -58,14 +58,8 @@
   const FileEntry *Entry = SM.getFileManager().getFile(FilePath);
   if (!Entry)
 return false;
-  FileID ID;
-  // FIXME: Use SM.translateFile directly.
-  SourceLocation Location = SM.translateFileLineCol(Entry, 1, 1);
-  ID = Location.isValid() ?
-SM.getFileID(Location) :
-SM.createFileID(Entry, SourceLocation(), SrcMgr::C_User);
-  // FIXME: We cannot check whether Offset + Length is in the file, as
-  // the remapping API is not public in the RewriteBuffer.
+
+  FileID ID = SM.getOrCreateFileID(Entry, SrcMgr::C_User);
   const SourceLocation Start =
 SM.getLocForStartOfFile(ID).
 getLocWithOffset(ReplacementRange.getOffset());
@@ -390,6 +384,17 @@
 };
 } // namespace
 
+FileToReplacementsMap
+groupReplacementsByFile(const Replacements &Replaces, FileManager &Files) {
+  FileToReplacementsMap FileToReplaces;
+  for (const auto &Replace : Replaces) {
+const FileEntry *Entry = Files.getFile(Replace.getFilePath());
+assert(Entry && "Expected an existing file.");
+FileToReplaces[Entry].push_back(Replace);
+  }
+  ret

r262341 - [cmake] Add a few more compiler-rt check-* targets for EXTERNAL_COMPILER_RT

2016-03-01 Thread Filipe Cabecinhas via cfe-commits
Author: filcab
Date: Tue Mar  1 09:33:52 2016
New Revision: 262341

URL: http://llvm.org/viewvc/llvm-project?rev=262341&view=rev
Log:
[cmake] Add a few more compiler-rt check-* targets for EXTERNAL_COMPILER_RT

Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=262341&r1=262340&r2=262341&view=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Tue Mar  1 09:33:52 2016
@@ -126,7 +126,8 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
 
 # Add top-level targets for various compiler-rt test suites.
 set(COMPILER_RT_TEST_SUITES check-asan check-asan-dynamic check-dfsan
-  check-lsan check-msan check-sanitizer check-tsan check-ubsan)
+  check-lsan check-msan check-sanitizer check-tsan check-ubsan
+  check-profile check-cfi check-cfi-and-supported check-safestack)
 foreach(test_suite ${COMPILER_RT_TEST_SUITES})
   get_ext_project_build_command(run_test_suite ${test_suite})
   add_custom_target(${test_suite}


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


Re: [PATCH] D17491: Add performance check to flag function parameters of expensive to copy types that can be safely converted to const references.

2016-03-01 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:25-32
@@ +24,10 @@
+std::string paramNameOrIndex(StringRef Name, size_t Index) {
+  std::string Output;
+  llvm::raw_string_ostream Stream(Output);
+  if (!Name.empty()) {
+Stream << "'" << Name << "'";
+  } else {
+Stream << "#" << ++Index;
+  }
+  return Stream.str();
+}

How about `return (Name.empty() ? llvm::Twine('#') + (Index + 1) : 
llvm::Twine('\'') + Name + '\'').str();` or something like this?


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:42
@@ +41,3 @@
+  decl().bind("param"));
+  Finder->addMatcher(
+  functionDecl(isDefinition(), unless(cxxMethodDecl(isOverride())),

Can you first try adding tests with template parameter packs and C-style 
variadic functions?


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:56
@@ +55,3 @@
+   Function->parameters().begin();
+  if (Index >= Function->getNumParams()) {
+return;

nit: No braces around single-line `if` bodies.


http://reviews.llvm.org/D17491



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


Re: [clang-tools-extra] r262257 - IdentifierNamingCheck.cpp: try to fix MSVC build

2016-03-01 Thread Hans Wennborg via cfe-commits
I only noticed this when I tried to build the weekly Windows snapshot,
and I didn't build one last week, so I don't know exactly when it
started failing. As you said, it might be due to a header change
somewhere. Since this was inside a DEBUG(), I suppose it would only
show in builds with asserts enabled.


On Tue, Mar 1, 2016 at 5:54 AM, Alexander Kornienko via cfe-commits
 wrote:
> Thanks for the fix! When did it start failing? The last change in this file
> was quite a while ago. Did it start breaking because of a change in a
> header?
>
> On Mon, Feb 29, 2016 at 10:17 PM, Hans Wennborg via cfe-commits
>  wrote:
>>
>> Author: hans
>> Date: Mon Feb 29 15:17:39 2016
>> New Revision: 262257
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=262257&view=rev
>> Log:
>> IdentifierNamingCheck.cpp: try to fix MSVC build
>>
>> It was failing to build with:
>>
>> clang-tidy\readability\IdentifierNamingCheck.cpp(640):
>> error C2882: 'format' : illegal use of namespace identifier in expression
>>
>> Modified:
>>
>> clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.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=262257&r1=262256&r2=262257&view=diff
>>
>> ==
>> ---
>> clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp
>> (original)
>> +++
>> clang-tools-extra/trunk/clang-tidy/readability/IdentifierNamingCheck.cpp Mon
>> Feb 29 15:17:39 2016
>> @@ -634,10 +634,10 @@ void IdentifierNamingCheck::check(const
>>  std::string Fixup = fixupWithStyle(Name, Style);
>>  if (StringRef(Fixup).equals(Name)) {
>>if (!IgnoreFailedSplit) {
>> -DEBUG(llvm::dbgs() << Decl->getLocStart().printToString(
>> -  *Result.SourceManager)
>> -   << format(": unable to split words for %s
>> '%s'\n",
>> - KindName.c_str(), Name));
>> +DEBUG(llvm::dbgs()
>> +  << Decl->getLocStart().printToString(*Result.SourceManager)
>> +  << llvm::format(": unable to split words for %s '%s'\n",
>> +  KindName.c_str(), Name));
>>}
>>  } else {
>>NamingCheckFailure &Failure = NamingCheckFailures[Decl];
>>
>>
>> ___
>> 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
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: RFC: Update Intel386, x86-64 and IA MCU psABIs for passing/returning empty struct

2016-03-01 Thread Michael Matz via cfe-commits
Hi,

On Mon, 29 Feb 2016, Jason Merrill wrote:

> > Also this insistence that all of "trivially copyable" is already quite 
> > nicely specified in the C++ ABI is still not really relevant because 
> > C++ _is not the only language out there_.  I'm not sure how often I 
> > have to repeat this until people get it.
> 
> Other language ABIs can handle language specific calling conventions as 
> appropriate for them.  The psABI can only talk about things that are in 
> its domain.

Naturally.  How far to follow that road, though?  Remove the word "class" 
from the description of empty types again?  Why is that in-domain and the 
notion of trivially copyable isn't?


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


[PATCH] D17772: [clang-tidy]: string_view of temporary string

2016-03-01 Thread Jonathan B Coe via cfe-commits
jbcoe created this revision.
jbcoe added reviewers: aaron.ballman, alexfh.
jbcoe added a subscriber: cfe-commits.
jbcoe set the repository for this revision to rL LLVM.

Find instances where a string_view is constructed from a temporary string and 
replace the string_view with a string.

Repository:
  rL LLVM

http://reviews.llvm.org/D17772

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringViewOfTemporaryCheck.cpp
  clang-tidy/misc/StringViewOfTemporaryCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string_view-of-temporary.rst
  test/clang-tidy/misc-string_view-of-temporary.cpp

Index: test/clang-tidy/misc-string_view-of-temporary.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-string_view-of-temporary.cpp
@@ -0,0 +1,33 @@
+// RUN: %check_clang_tidy %s misc-string_view-of-temporary %t
+
+namespace std {
+inline namespace implementation {
+class string {
+public:
+  string(const char *);
+};
+
+class string_view {
+public:
+  string_view(const string &);
+  string_view(const char*);
+};
+}
+}
+
+using std::string;
+using std::string_view;
+
+string f();
+void g(string_view);
+void h()
+{
+  string_view sv(f());
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: string_view 'sv' is constructed from a temporary string [misc-string_view-of-temporary]
+// CHECK-FIXES: std::string sv(f());
+  g(f());
+  auto s = f();
+  string_view sv2(s);
+  string_view sv3("char[] construction");
+}
+
Index: docs/clang-tidy/checks/misc-string_view-of-temporary.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-string_view-of-temporary.rst
@@ -0,0 +1,25 @@
+.. title:: clang-tidy - misc-string_view-of-temporary
+
+misc-string_view-of-temporary
+=
+
+Find non-temporary ``string_view``s constructed from temporary strings and
+replace them with ``std::string``s.
+
+The following construction of a ``string_view`` constructs a view of a
+temporary object: 
+
+.. code:: c++
+
+  std::string f();
+
+  std::string_view s(f());
+
+The fix replaces the ``std::string_view`` with an ``std::string``:
+
+.. code:: c++
+
+  std::string f();
+
+  std::string s(f());
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -65,6 +65,7 @@
misc-sizeof-container
misc-static-assert
misc-string-integer-assignment
+   misc-string_view-of-temporary
misc-suspicious-semicolon
misc-swapped-arguments
misc-throw-by-value-catch-by-reference
Index: clang-tidy/misc/StringViewOfTemporaryCheck.h
===
--- /dev/null
+++ clang-tidy/misc/StringViewOfTemporaryCheck.h
@@ -0,0 +1,35 @@
+//===--- String_viewOfTemporaryCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_VIEW_OF_TEMPORARY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_VIEW_OF_TEMPORARY_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Find non-temporary string_views constructed from temporary strings.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-string_view-of-temporary.html
+class String_viewOfTemporaryCheck : public ClangTidyCheck {
+public:
+  String_viewOfTemporaryCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_VIEW_OF_TEMPORARY_H
Index: clang-tidy/misc/StringViewOfTemporaryCheck.cpp
===
--- /dev/null
+++ clang-tidy/misc/StringViewOfTemporaryCheck.cpp
@@ -0,0 +1,55 @@
+//===--- StringViewOfTemporaryCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "StringViewOfTemporaryCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+namespace {
+
+AST_MATCHER(Reco

r262350 - Explicitly select IAS in new embed-bitcode.c test.

2016-03-01 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Tue Mar  1 11:15:11 2016
New Revision: 262350

URL: http://llvm.org/viewvc/llvm-project?rev=262350&view=rev
Log:
Explicitly select IAS in new embed-bitcode.c test.

This should fix clang-cmake-mips builder since MIPS does not have IAS enabled
by default (yet).


Modified:
cfe/trunk/test/Driver/embed-bitcode.c

Modified: cfe/trunk/test/Driver/embed-bitcode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/embed-bitcode.c?rev=262350&r1=262349&r2=262350&view=diff
==
--- cfe/trunk/test/Driver/embed-bitcode.c (original)
+++ cfe/trunk/test/Driver/embed-bitcode.c Tue Mar  1 11:15:11 2016
@@ -2,7 +2,7 @@
 // CHECK: clang
 // CHECK: clang
 
-// RUN: %clang %s -c -fembed-bitcode 2>&1 -### | FileCheck %s 
-check-prefix=CHECK-CC
+// RUN: %clang %s -c -fembed-bitcode -fintegrated-as 2>&1 -### | FileCheck %s 
-check-prefix=CHECK-CC
 // CHECK-CC: -cc1
 // CHECK-CC: -emit-llvm-bc
 // CHECK-CC: -cc1
@@ -26,7 +26,7 @@
 // CHECK-LTO-NOT: -cc1
 // CHECK-LTO-NOT: -fembed-bitcode
 
-// RUN: %clang -c %s -fembed-bitcode-marker 2>&1 -### | FileCheck %s 
-check-prefix=CHECK-MARKER
+// RUN: %clang -c %s -fembed-bitcode-marker -fintegrated-as 2>&1 -### | 
FileCheck %s -check-prefix=CHECK-MARKER
 // CHECK-MARKER: -cc1
 // CHECK-MARKER: -emit-obj
 // CHECK-MARKER: -fembed-bitcode-marker


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


RE: r262282 - Introduce -fembed-bitcode driver option

2016-03-01 Thread Daniel Sanders via cfe-commits
Hi,

I've made a small change to the test case in r262350 to fix the 
clang-cmake-mips builder. MIPS doesn't
enable the integrated assembler by default yet so it was failing to find the 
-emit-obj option. I've fixed this by adding -fintegrated-as.


From: cfe-commits [cfe-commits-boun...@lists.llvm.org] on behalf of Steven Wu 
via cfe-commits [cfe-commits@lists.llvm.org]
Sent: 01 March 2016 01:07
To: cfe-commits@lists.llvm.org
Subject: r262282 - Introduce -fembed-bitcode driver option

Author: steven_wu
Date: Mon Feb 29 19:07:58 2016
New Revision: 262282

URL: http://llvm.org/viewvc/llvm-project?rev=262282&view=rev
Log:
Introduce -fembed-bitcode driver option

Summary:
This is the clang driver part of the change to embedded bitcode. This
includes:
1. -fembed-bitcode option which breaks down the compilation into two
stages. The first stage emits optimized bitcode and the second stage
compiles bitcode into object file.
2. -fembed-bitcode-marker option which doesn't really break down to
two stages to speedup the compilation flow.
3. pass the correct linker flag to darwin linker if tool chains supports
embedded bitcode.

Reviewers: rsmith, thakis

Subscribers: thakis, cfe-commits

Differential Revision: http://reviews.llvm.org/D17390

Added:
cfe/trunk/test/Driver/embed-bitcode.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=262282&r1=262281&r2=262282&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Feb 29 19:07:58 
2016
@@ -134,7 +134,9 @@ def err_drv_omp_host_ir_file_not_found :
   "The provided host compiler IR file '%0' is required to generate code for 
OpenMP target regions but cannot be found.">;
 def err_drv_omp_host_target_not_supported : Error<
   "The target '%0' is not a supported OpenMP host target.">;
-
+def err_drv_bitcode_unsupported_on_toolchain : Error<
+  "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
+
 def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup;
 def warn_drv_lto_libpath : Warning<"libLTO.dylib relative to clang installed 
dir not found; using 'ld' default search path instead">,
   InGroup;

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=262282&r1=262281&r2=262282&view=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Mon Feb 29 19:07:58 2016
@@ -83,6 +83,12 @@ class Driver {
 SaveTempsObj
   } SaveTemps;

+  enum BitcodeEmbedMode {
+EmbedNone,
+EmbedMarker,
+EmbedBitcode
+  } BitcodeEmbed;
+
   /// LTO mode selected via -f(no-)?lto(=.*)? options.
   LTOKind LTOMode;

@@ -262,6 +268,9 @@ public:
   bool isSaveTempsEnabled() const { return SaveTemps != SaveTempsNone; }
   bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; }

+  bool embedBitcodeEnabled() const { return BitcodeEmbed == EmbedBitcode; }
+  bool embedBitcodeMarkerOnly() const { return BitcodeEmbed == EmbedMarker; }
+
   /// @}
   /// @name Primary Functionality
   /// @{

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=262282&r1=262281&r2=262282&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Feb 29 19:07:58 2016
@@ -437,6 +437,12 @@ def fno_autolink : Flag <["-"], "fno-aut
   Flags<[DriverOption, CC1Option]>,
   HelpText<"Disable generation of linker directives for automatic library 
linking">;

+def fembed_bitcode : Flag<["-"], "fembed-bitcode">, Group,
+  Flags<[CC1Option, CC1AsOption]>,
+  HelpText<"Embed LLVM IR bitcode as data">;
+def fembed_bitcode_marker : Flag<["-"], "fembed-bitcode-marker">,
+  Group, Flags<[CC1Option]>,
+  HelpText<"Embed placeholder LLVM IR data as a marker">;
 def fgnu_inline_asm : Flag<["-"], "fgnu-inline-asm">, Group, 
Flags<[DriverOption]>;
 def fno_gnu_inline_asm : Flag<["-"], "fno-gnu-inline-asm">, Group,
   Flags<[DriverOption, CC1Option]>,

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=262282&r1

Re: r262282 - Introduce -fembed-bitcode driver option

2016-03-01 Thread Steven Wu via cfe-commits
Great. Thanks for the fix.

Steven

> On Mar 1, 2016, at 9:24 AM, Daniel Sanders  wrote:
> 
> Hi,
> 
> I've made a small change to the test case in r262350 to fix the 
> clang-cmake-mips builder. MIPS doesn't
> enable the integrated assembler by default yet so it was failing to find the 
> -emit-obj option. I've fixed this by adding -fintegrated-as.
> 
> 
> From: cfe-commits [cfe-commits-boun...@lists.llvm.org] on behalf of Steven Wu 
> via cfe-commits [cfe-commits@lists.llvm.org]
> Sent: 01 March 2016 01:07
> To: cfe-commits@lists.llvm.org
> Subject: r262282 - Introduce -fembed-bitcode driver option
> 
> Author: steven_wu
> Date: Mon Feb 29 19:07:58 2016
> New Revision: 262282
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=262282&view=rev
> Log:
> Introduce -fembed-bitcode driver option
> 
> Summary:
> This is the clang driver part of the change to embedded bitcode. This
> includes:
> 1. -fembed-bitcode option which breaks down the compilation into two
> stages. The first stage emits optimized bitcode and the second stage
> compiles bitcode into object file.
> 2. -fembed-bitcode-marker option which doesn't really break down to
> two stages to speedup the compilation flow.
> 3. pass the correct linker flag to darwin linker if tool chains supports
> embedded bitcode.
> 
> Reviewers: rsmith, thakis
> 
> Subscribers: thakis, cfe-commits
> 
> Differential Revision: http://reviews.llvm.org/D17390
> 
> Added:
>cfe/trunk/test/Driver/embed-bitcode.c
> Modified:
>cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>cfe/trunk/include/clang/Driver/Driver.h
>cfe/trunk/include/clang/Driver/Options.td
>cfe/trunk/include/clang/Driver/ToolChain.h
>cfe/trunk/lib/Driver/Driver.cpp
>cfe/trunk/lib/Driver/ToolChains.cpp
>cfe/trunk/lib/Driver/ToolChains.h
>cfe/trunk/lib/Driver/Tools.cpp
> 
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=262282&r1=262281&r2=262282&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Feb 29 
> 19:07:58 2016
> @@ -134,7 +134,9 @@ def err_drv_omp_host_ir_file_not_found :
>   "The provided host compiler IR file '%0' is required to generate code for 
> OpenMP target regions but cannot be found.">;
> def err_drv_omp_host_target_not_supported : Error<
>   "The target '%0' is not a supported OpenMP host target.">;
> -
> +def err_drv_bitcode_unsupported_on_toolchain : Error<
> +  "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
> +
> def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup;
> def warn_drv_lto_libpath : Warning<"libLTO.dylib relative to clang installed 
> dir not found; using 'ld' default search path instead">,
>   InGroup;
> 
> Modified: cfe/trunk/include/clang/Driver/Driver.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=262282&r1=262281&r2=262282&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Driver.h (original)
> +++ cfe/trunk/include/clang/Driver/Driver.h Mon Feb 29 19:07:58 2016
> @@ -83,6 +83,12 @@ class Driver {
> SaveTempsObj
>   } SaveTemps;
> 
> +  enum BitcodeEmbedMode {
> +EmbedNone,
> +EmbedMarker,
> +EmbedBitcode
> +  } BitcodeEmbed;
> +
>   /// LTO mode selected via -f(no-)?lto(=.*)? options.
>   LTOKind LTOMode;
> 
> @@ -262,6 +268,9 @@ public:
>   bool isSaveTempsEnabled() const { return SaveTemps != SaveTempsNone; }
>   bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; }
> 
> +  bool embedBitcodeEnabled() const { return BitcodeEmbed == EmbedBitcode; }
> +  bool embedBitcodeMarkerOnly() const { return BitcodeEmbed == EmbedMarker; }
> +
>   /// @}
>   /// @name Primary Functionality
>   /// @{
> 
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=262282&r1=262281&r2=262282&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Mon Feb 29 19:07:58 2016
> @@ -437,6 +437,12 @@ def fno_autolink : Flag <["-"], "fno-aut
>   Flags<[DriverOption, CC1Option]>,
>   HelpText<"Disable generation of linker directives for automatic library 
> linking">;
> 
> +def fembed_bitcode : Flag<["-"], "fembed-bitcode">, Group,
> +  Flags<[CC1Option, CC1AsOption]>,
> +  HelpText<"Embed LLVM IR bitcode as data">;
> +def fembed_bitcode_marker : Flag<["-"], "fembed-bitcode-marker">,
> +  Group, Flags<[CC1Option]>,
> +  HelpText<"Embed placeholder LLVM IR data as a marker">;
> def fgnu_inline_asm : Flag<["-"], "fg

Re: [PATCH] D17772: [clang-tidy]: string_view of temporary string

2016-03-01 Thread David Blaikie via cfe-commits
dblaikie added a subscriber: dblaikie.
dblaikie added a comment.

Any way to/would it be worth broadening this with an annotation or some
such (or just a lost for now) of types that maintain references to their
ctor params? (Eg: llvm arrayref, etc)


Repository:
  rL LLVM

http://reviews.llvm.org/D17772



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


Re: [PATCH] D17772: [clang-tidy]: string_view of temporary string

2016-03-01 Thread David Blaikie via cfe-commits
Any way to/would it be worth broadening this with an annotation or some
such (or just a lost for now) of types that maintain references to their
ctor params? (Eg: llvm arrayref, etc)
On Mar 1, 2016 9:19 AM, "Jonathan B Coe via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> jbcoe created this revision.
> jbcoe added reviewers: aaron.ballman, alexfh.
> jbcoe added a subscriber: cfe-commits.
> jbcoe set the repository for this revision to rL LLVM.
>
> Find instances where a string_view is constructed from a temporary string
> and replace the string_view with a string.
>
> Repository:
>   rL LLVM
>
> http://reviews.llvm.org/D17772
>
> Files:
>   clang-tidy/misc/CMakeLists.txt
>   clang-tidy/misc/MiscTidyModule.cpp
>   clang-tidy/misc/StringViewOfTemporaryCheck.cpp
>   clang-tidy/misc/StringViewOfTemporaryCheck.h
>   docs/clang-tidy/checks/list.rst
>   docs/clang-tidy/checks/misc-string_view-of-temporary.rst
>   test/clang-tidy/misc-string_view-of-temporary.cpp
>
>
> ___
> 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


Re: [PATCH] D17752: [MSVC Compat] Correctly handle finallys nested within finallys

2016-03-01 Thread Reid Kleckner via cfe-commits
rnk added inline comments.


Comment at: lib/CodeGen/CGException.cpp:1680-1682
@@ -1679,4 +1679,5 @@
 
   StartFunction(GlobalDecl(), RetTy, Fn, FnInfo, Args,
 OutlinedStmt->getLocStart(), OutlinedStmt->getLocStart());
+  CurCodeDecl = ParentCGF.CurCodeDecl;
 

Let's have a new field for this. We don't want most of the behavior controlled 
by CurCodeDecl in the rest of CodeGen.


http://reviews.llvm.org/D17752



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


Re: [PATCH] D17764: Add attributes for AMD GPU Tools

2016-03-01 Thread Matt Arsenault via cfe-commits
arsenm added inline comments.


Comment at: include/clang/Basic/Attr.td:993-998
@@ +992,8 @@
+
+def AMDGPUToolsInsertNops : InheritableAttr {
+  let Spellings = [GNU<"amdgpu_tools_insert_nops">];
+  let Documentation = [AMDGPUToolsInsertNopsDocs];
+  let Subjects = SubjectList<[Function], ErrorDiag,
+ "ExpectedKernelFunction">;
+}
+

I didn't envision these as being user code facing attributes, and only the 
function emission would add them. Is there a use for these being used manually?


Comment at: include/clang/Driver/Options.td:355-365
@@ -354,2 +354,13 @@
 def allowable__client : Separate<["-"], "allowable_client">;
+def amdgpu_tools_insert_nops :
+  Flag<["--"], "amdgpu-tools-insert-nops">, Flags<[CC1Option, HelpHidden]>,
+  HelpText<"Insert two nop instructions for each high level source statement">;
+def amdgpu_tools_num_reserved_vgpr :
+  Joined<["--"], "amdgpu-tools-num-reserved-vgpr=">,
+  Flags<[CC1Option, HelpHidden]>,
+  HelpText<"Reserve  vector registers">, MetaVarName<"">;
+def amdgpu_tools_num_reserved_sgpr :
+  Joined<["--"], "amdgpu-tools-num-reserved-sgpr=">,
+  Flags<[CC1Option, HelpHidden]>,
+  HelpText<"Reserve  scalar registers">, MetaVarName<"">;
 def ansi : Flag<["-", "--"], "ansi">;

These are user facing options, not cc1 flags? I wouldn't expect these to be 
exposed to users, and they would just be implied by -g. Is there a need for 
this? Even if there is some need for these, I don't see anything testing for 
these with only -g


Comment at: lib/CodeGen/CGCall.cpp:1601
@@ +1600,3 @@
+if (CodeGenOpts.AMDGPUToolsInsertNopsOpt)
+  FuncAttrs.addAttribute("amdgpu_tools_insert_nops");
+if (CodeGenOpts.AMDGPUToolsNumReservedVGPROpt)

I've been trying to switch to consistently using the '-' separates words 
conventions most function attributes use.


Comment at: test/CodeGenOpenCL/amdgpu-tools-attrs.cl:1
@@ +1,2 @@
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu kaveri -O0 -emit-llvm -o - %s 
| FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -O0 -emit-llvm -verify -o 
- %s | FileCheck -check-prefix=X86 %s

I all of the run lines should use amdhsa triple


http://reviews.llvm.org/D17764



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


r262355 - [CLANG][AVX512][BUILTIN] Adding PSRL{DI|QI}{128|256|512} builtin

2016-03-01 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Tue Mar  1 11:49:03 2016
New Revision: 262355

URL: http://llvm.org/viewvc/llvm-project?rev=262355&view=rev
Log:
[CLANG][AVX512][BUILTIN] Adding PSRL{DI|QI}{128|256|512} builtin

Differential Revision: http://reviews.llvm.org/D17714

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=262355&r1=262354&r2=262355&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue Mar  1 11:49:03 2016
@@ -1668,6 +1668,16 @@ TARGET_BUILTIN(__builtin_ia32_psrlv2di_m
 TARGET_BUILTIN(__builtin_ia32_psrlv4di_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psrlv4si_mask, "V4iV4iV4iV4iUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_psrlv8si_mask, "V8iV8iV8iV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrldi512_mask, "V16iV16iiV16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psrlqi512_mask, 
"V8LLiV8LLiiV8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_psrld128_mask, "V4iV4iV4iV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrld256_mask, "V8iV8iV4iV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrldi128_mask, "V4iV4iIiV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrldi256_mask, "V8iV8iIiV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrlq128_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrlq256_mask, 
"V4LLiV4LLiV2LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrlqi128_mask, 
"V2LLiV2LLiIiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psrlqi256_mask, 
"V4LLiV4LLiIiV4LLiUc","","avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=262355&r1=262354&r2=262355&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue Mar  1 11:49:03 2016
@@ -3561,6 +3561,47 @@ __builtin_ia32_psllqi512_mask ((__v8di)(
 })
 
 
+
+#define _mm512_srli_epi32( __A, __B) __extension__ ({ \
+__builtin_ia32_psrldi512_mask ((__v16si)( __A),( __B),\
+  (__v16si)\
+  _mm512_setzero_si512 (),\
+  (__mmask16) -1);\
+})
+
+#define _mm512_mask_srli_epi32( __W, __U, __A, __B) __extension__ ({ \
+__builtin_ia32_psrldi512_mask ((__v16si)( __A),( __B),\
+  (__v16si)( __W),\
+  (__mmask16)( __U));\
+})
+
+#define _mm512_maskz_srli_epi32( __U, __A, __B) __extension__ ({ \
+__builtin_ia32_psrldi512_mask ((__v16si)( __A),( __B),\
+  (__v16si)\
+  _mm512_setzero_si512 (),\
+  (__mmask16)( __U));\
+})
+
+#define _mm512_srli_epi64( __A, __B) __extension__ ({ \
+__builtin_ia32_psrlqi512_mask ((__v8di)( __A),( __B),\
+  (__v8di)\
+  _mm512_setzero_si512 (),\
+  (__mmask8) -1);\
+})
+
+#define _mm512_mask_srli_epi64( __W, __U, __A, __B) __extension__ ({ \
+__builtin_ia32_psrlqi512_mask ((__v8di)( __A),( __B),\
+  (__v8di)( __W),\
+  (__mmask8)( __U));\
+})
+
+#define _mm512_maskz_srli_epi64( __U, __A, __B) __extension__ ({ \
+__builtin_ia32_psrlqi512_mask ((__v8di)( __A),( __B),\
+  (__v8di)\
+  _mm512_setzero_si512 (),\
+  (__mmask8)( __U));\
+})
+
 #undef __DEFAULT_FN_ATTRS
 
 #endif // __AVX512FINTRIN_H

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=262355&r1=262354&r2=262355&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Tue Mar  1 11:49:03 2016
@@ -5638,6 +5638,140 @@ _mm256_maskz_srlv_epi32 (__mmask8 __U, _
  (__mmask8) __U);
 }
 
+
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_mask_srl_epi32 (__m128i __W, __mmask8 __U, __m128i __A,
+__m128i __B)
+{
+  return (__m128i) __builtin_ia32_psrld128_mask ((__v4si) __A,
+ (__v4si) __B,
+ (__v4si) __W,
+ (__mmask8) __U);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm_maskz_srl_epi32 (__mmask8 __U, __m128i __A, __m128i __B)
+{
+  return (__m128i) __builtin_ia32_psrld128_mask ((__v4si) __A,
+ (__v4si) __B,
+ (__v4si)
+ _mm_setzero_si128 (),
+ (__mmask8) __U);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm256_mask_srl_ep

Re: [PATCH] D17772: [clang-tidy]: string_view of temporary string

2016-03-01 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

As David noted, there are other similar classes like `llvm::StringRef`, 
`llvm::ArraryRef`, `gsl::span`, `StringPiece` (in various Google projects, e.g. 
https://github.com/google/re2/blob/master/re2/stringpiece.h) and numerous other 
in different code bases. I think, we should make the check sufficiently 
configurable to be able to support other similar classes.



Comment at: clang-tidy/misc/MiscTidyModule.cpp:36
@@ -34,2 +35,2 @@
 #include "SwappedArgumentsCheck.h"
 #include "ThrowByValueCatchByReferenceCheck.h"

Please include the full context in the diff (see 
http://llvm.org/docs/Phabricator.html).


Comment at: clang-tidy/misc/MiscTidyModule.cpp:89
@@ -87,1 +88,3 @@
 "misc-string-integer-assignment");
+CheckFactories.registerCheck(
+"misc-string_view-of-temporary");

Please use CamelCase for class names: `StringViewOfTemporaryCheck`.


Comment at: clang-tidy/misc/MiscTidyModule.cpp:90
@@ -88,1 +89,3 @@
+CheckFactories.registerCheck(
+"misc-string_view-of-temporary");
 CheckFactories.registerCheck(

Please only use dashes as delimiters in the check name: 
`misc-string-view-of-temporary`.


Repository:
  rL LLVM

http://reviews.llvm.org/D17772



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


r262359 - [PPC64][VSX] Add short, char, and bool data type for vec_vsx_ld and vec_vsx_st intrinsics

2016-03-01 Thread Kit Barton via cfe-commits
Author: kbarton
Date: Tue Mar  1 12:11:28 2016
New Revision: 262359

URL: http://llvm.org/viewvc/llvm-project?rev=262359&view=rev
Log:
[PPC64][VSX] Add short, char, and bool data type for vec_vsx_ld and vec_vsx_st 
intrinsics

Issue: https://llvm.org/bugs/show_bug.cgi?id=26720

Fix compile error when building ffmpeg for PowerPC64LE because of some
vec_vsx_ld/vec_vsx_st intrinsics are not supported by current clang.

New added intrinsics:

(vector) {signed|unsigned} {short|char} vec_vsx_ld: (total: 8)
bool vec_vsx_ld: (total: 1)
(vector) {signed|unsigned} {short|char} vec_vsx_st: (total: 8)
bool vec_vsx_st: (total: 1)
Total: 18 intrinsics

Phabricator: http://reviews.llvm.org/D17637

Modified:
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/test/CodeGen/builtins-ppc-vsx.c

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=262359&r1=262358&r2=262359&view=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Tue Mar  1 12:11:28 2016
@@ -10137,6 +10137,51 @@ static vector double __ATTRS_o_ai vec_vs
   return (vector double)__builtin_vsx_lxvd2x(__a, __b);
 }
 
+static vector signed short __ATTRS_o_ai
+vec_vsx_ld(int __a, const vector signed short *__b) {
+  return (vector signed short)__builtin_vsx_lxvw4x(__a, __b);
+}
+
+static vector signed short __ATTRS_o_ai
+vec_vsx_ld(int __a, const signed short *__b) {
+  return (vector signed short)__builtin_vsx_lxvw4x(__a, __b);
+}
+
+static vector unsigned short __ATTRS_o_ai
+vec_vsx_ld(int __a, const vector unsigned short *__b) {
+  return (vector unsigned short)__builtin_vsx_lxvw4x(__a, __b);
+}
+
+static vector unsigned short __ATTRS_o_ai
+vec_vsx_ld(int __a, const unsigned short *__b) {
+  return (vector unsigned short)__builtin_vsx_lxvw4x(__a, __b);
+}
+
+static vector bool char __ATTRS_o_ai
+vec_vsx_ld(int __a, const vector bool char *__b) {
+  return (vector bool char)__builtin_vsx_lxvw4x(__a, __b);
+}
+
+static vector signed char __ATTRS_o_ai
+vec_vsx_ld(int __a, const vector signed char *__b) {
+  return (vector signed char)__builtin_vsx_lxvw4x(__a, __b);
+}
+
+static vector signed char __ATTRS_o_ai
+vec_vsx_ld(int __a, const signed char *__b) {
+  return (vector signed char)__builtin_vsx_lxvw4x(__a, __b);
+}
+
+static vector unsigned char __ATTRS_o_ai
+vec_vsx_ld(int __a, const vector unsigned char *__b) {
+  return (vector unsigned char)__builtin_vsx_lxvw4x(__a, __b);
+}
+
+static vector unsigned char __ATTRS_o_ai
+vec_vsx_ld(int __a, const unsigned char *__b) {
+  return (vector unsigned char)__builtin_vsx_lxvw4x(__a, __b);
+}
+
 #endif
 
 /* vec_vsx_st */
@@ -10148,11 +10193,21 @@ static void __ATTRS_o_ai vec_vsx_st(vect
   __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
 }
 
+static void __ATTRS_o_ai vec_vsx_st(vector signed int __a, int __b,
+   signed int *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
 static void __ATTRS_o_ai vec_vsx_st(vector unsigned int __a, int __b,
 vector unsigned int *__c) {
   __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
 }
 
+static void __ATTRS_o_ai vec_vsx_st(vector unsigned int __a, int __b,
+   unsigned int *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
 static void __ATTRS_o_ai vec_vsx_st(vector float __a, int __b,
 vector float *__c) {
   __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
@@ -10173,6 +10228,61 @@ static void __ATTRS_o_ai vec_vsx_st(vect
   __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
 }
 
+static void __ATTRS_o_ai vec_vsx_st(vector signed short __a, int __b,
+vector signed short *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
+static void __ATTRS_o_ai vec_vsx_st(vector signed short __a, int __b,
+   signed short *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
+static void __ATTRS_o_ai vec_vsx_st(vector unsigned short __a, int __b,
+vector unsigned short *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
+static void __ATTRS_o_ai vec_vsx_st(vector unsigned short __a, int __b,
+   unsigned short *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
+static void __ATTRS_o_ai vec_vsx_st(vector signed char __a, int __b,
+vector signed char *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
+static void __ATTRS_o_ai vec_vsx_st(vector signed char __a, int __b,
+   signed char *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
+static void __ATTRS_o_ai vec_vsx_st(vector unsigned char __a, int __b,
+ 

Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-03-01 Thread Weiming Zhao via cfe-commits
weimingz added a comment.

In http://reviews.llvm.org/D17741#364954, @thakis wrote:

> In http://reviews.llvm.org/D17741#364931, @weimingz wrote:
>
> > In http://reviews.llvm.org/D17741#364756, @thakis wrote:
> >
> > > Instead of doing this, would it make sense to have a flag like 
> > > -ffile-basename that changes what __FILE__ expands to?
> > >
> > > I had wished I'd be able to have some control over __FILE__ (I'd like to 
> > > say "make all __FILE__s relative to this given directory for my use 
> > > case), and changing __FILE__ to something else in all the world's code 
> > > isn't easy – so maybe having a flag that provides some control over 
> > > __FILE__ instead of adding a separate macro would be a good idea.
> >
> >
> > do you mean this?
> >  if source file is /a/b/c/d/foo.c and if  -ffile-name-stem-remove=/a/b/c, 
> > then _FILE_ will be expanded to "d/foo.c" ?
>
>
> Yes, something like that. Maybe it could look like 
> `-f__file__-expansion=basename` (to make __FILE__ expand to just the 
> basename, what you want), `-f__file__-expansion=relative-to:/a/b/c` to make 
> it relative to a given path.


I think we can do this separately. A "basename" macro is easier for programmers 
to use and no build system change needed.


http://reviews.llvm.org/D17741



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


Re: [PATCH] D17637: [PPC64][VSX] Add short, char, and bool data type for vec_vsx_ld and vec_vsx_st intrinsics

2016-03-01 Thread Kit Barton via cfe-commits
kbarton closed this revision.
kbarton added a comment.

Committed r262359


http://reviews.llvm.org/D17637



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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-03-01 Thread Ben Craig via cfe-commits
bcraig added a comment.

LGTM.  You should probably wait for someone else to approve it though.


http://reviews.llvm.org/D17741



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


Re: [PATCH] D16949: Fix for: Bug 5941 - improve diagnostic for * vs & confusion

2016-03-01 Thread David Blaikie via cfe-commits
dblaikie added a comment.

Are there not any existing cases that test this diagnostic?

Could you just update some existing cases to cover this? (it looks like, in the 
same file, the test case added for PR 6117 could be expanded to test this as 
well, perhaps?) It looks like that's the original test for this diagnostic, so 
it'd be a good/right place to test the extra text and add any extra variants 
that have become relevant.


http://reviews.llvm.org/D16949



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


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-01 Thread via cfe-commits
I'd quite happily add them... but can I do it in another patch? I think I
could be more thorough that way.

For the same reason, can we list all the microsoft memory allocating
routines here? There are a thousand routines we might want to add, and then
a few others (like _dupenv_s, _malloca, and _expand) which are especially
important to be able to analyze (because they have really tricky APIs), but
*because* of their kooky APIs, they're harder to implement checkers for.

Sincerely,
Alexander Riccio
--
"Change the world or go home."
about.me/ariccio


If left to my own devices, I will build more.
⁂

On Tue, Mar 1, 2016 at 8:38 AM, Aaron Ballman 
wrote:

> On Tue, Mar 1, 2016 at 2:16 AM, Alexander Riccio 
> wrote:
> > ariccio updated this revision to Diff 49456.
> > ariccio added a comment.
> >
> > Nit addressed.
> >
> >
> > http://reviews.llvm.org/D17688
> >
> > Files:
> >   llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> >
> > Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> > ===
> > --- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> > +++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
> > @@ -169,11 +169,12 @@
> >  {
> >  public:
> >MallocChecker()
> > -  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
> > -II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr),
> > -II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr),
> > -II_kmalloc(nullptr), II_if_nameindex(nullptr),
> > -II_if_freenameindex(nullptr) {}
> > +  : II_alloca(nullptr), II_win_alloca(nullptr), II_malloc(nullptr),
> > +II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
> > +II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
> > +II_strdup(nullptr), II_win_strdup(nullptr), II_kmalloc(nullptr),
> > +II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
> > +II_wcsdup(nullptr), II_win_wcsdup(nullptr) {}
> >
> >/// In pessimistic mode, the checker assumes that it does not know
> which
> >/// functions might free the memory.
> > @@ -231,10 +232,11 @@
> >mutable std::unique_ptr BT_MismatchedDealloc;
> >mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
> >mutable std::unique_ptr
> BT_UseZerroAllocated[CK_NumCheckKinds];
> > -  mutable IdentifierInfo *II_alloca, *II_malloc, *II_free, *II_realloc,
> > - *II_calloc, *II_valloc, *II_reallocf,
> *II_strndup,
> > - *II_strdup, *II_kmalloc, *II_if_nameindex,
> > - *II_if_freenameindex;
> > +  mutable IdentifierInfo *II_alloca, *II_win_alloca, *II_malloc,
> *II_free,
> > + *II_realloc, *II_calloc, *II_valloc,
> *II_reallocf,
> > + *II_strndup, *II_strdup, *II_win_strdup,
> *II_kmalloc,
> > + *II_if_nameindex, *II_if_freenameindex,
> *II_wcsdup,
> > + *II_win_wcsdup;
> >mutable Optional KernelZeroFlagVal;
> >
> >void initIdentifierInfo(ASTContext &C) const;
> > @@ -540,9 +542,15 @@
> >II_valloc = &Ctx.Idents.get("valloc");
> >II_strdup = &Ctx.Idents.get("strdup");
> >II_strndup = &Ctx.Idents.get("strndup");
> > +  II_wcsdup = &Ctx.Idents.get("wcsdup");
> >II_kmalloc = &Ctx.Idents.get("kmalloc");
> >II_if_nameindex = &Ctx.Idents.get("if_nameindex");
> >II_if_freenameindex = &Ctx.Idents.get("if_freenameindex");
> > +
> > +  //MSVC uses `_`-prefixed instead, so we check for them too.
> > +  II_win_strdup = &Ctx.Idents.get("_strdup");
> > +  II_win_wcsdup = &Ctx.Idents.get("_wcsdup");
> > +  II_win_alloca = &Ctx.Idents.get("_alloca");
>
> What about: _mbsdup, _strdup_dbg, _wcsdup_dbg, _aligned_realloc, and
> the rest? If we're going to add these (which I really support), it
> would be good to make a comprehensive sweep for the Win32 additions
> and add them all.
>
> ~Aaron
>
> >  }
> >
> >  bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext
> &C) const {
> > @@ -585,7 +593,8 @@
> >  if (Family == AF_Malloc && CheckAlloc) {
> >if (FunI == II_malloc || FunI == II_realloc || FunI ==
> II_reallocf ||
> >FunI == II_calloc || FunI == II_valloc || FunI == II_strdup ||
> > -  FunI == II_strndup || FunI == II_kmalloc)
> > +  FunI == II_win_strdup || FunI == II_strndup || FunI ==
> II_wcsdup ||
> > +  FunI == II_win_wcsdup || FunI == II_kmalloc)
> >  return true;
> >  }
> >
> > @@ -600,7 +609,7 @@
> >  }
> >
> >  if (Family == AF_Alloca && CheckAlloc) {
> > -  if (FunI == II_alloca)
> > +  if (FunI == II_alloca || FunI == II_win_alloca)
> >  return true;
> >  }
> >}
> > @@ -789,11 +798,12 @@
> >State = ProcessZeroAllocation(C, CE, 1, State);
> >  } else if (FunI == II_free) {
> >   

Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2016-03-01 Thread Nemanja Ivanovic via cfe-commits
nemanjai updated this revision to Diff 49508.
nemanjai added a comment.

Removed questionable macro definitions.
Renamed the test function for invalid conversions and changed the semantics so 
that it allows __float128 <-> long double conversions only if the two types 
have the same representation or the latter has the same representation as 
double.
Removed unnecessary check for the representation of __float128 when returning a 
float type of width 128.


Repository:
  rL LLVM

http://reviews.llvm.org/D15120

Files:
  bindings/python/clang/cindex.py
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/AST/Type.h
  include/clang/AST/TypeLoc.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/TokenKinds.def
  include/clang/Driver/Options.td
  include/clang/Lex/LiteralSupport.h
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Format/FormatToken.cpp
  lib/Index/USRGeneration.cpp
  lib/Lex/LiteralSupport.cpp
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseTentative.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaLookup.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/CodeGenCXX/float128-declarations.cpp
  test/Preprocessor/init.c
  test/Sema/128bitfloat.cpp
  test/Sema/float128-ld-incompatibility.cpp
  test/SemaCXX/deleted-operator.cpp
  test/SemaCXX/overloaded-builtin-operators.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -51,6 +51,7 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(Float128);
 BTCASE(NullPtr);
 BTCASE(Overload);
 BTCASE(Dependent);
@@ -466,6 +467,7 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(Float128);
 TKIND(NullPtr);
 TKIND(Overload);
 TKIND(Dependent);
Index: test/SemaCXX/overloaded-builtin-operators.cpp
===
--- test/SemaCXX/overloaded-builtin-operators.cpp
+++ test/SemaCXX/overloaded-builtin-operators.cpp
@@ -183,7 +183,7 @@
   // FIXME: lots of candidates here!
   (void)(1.0f * a); // expected-error{{ambiguous}} \
 // expected-note 4{{candidate}} \
-// expected-note {{remaining 117 candidates omitted; pass -fshow-overloads=all to show them}}
+// expected-note {{remaining 140 candidates omitted; pass -fshow-overloads=all to show them}}
 }
 
 // pr5432
Index: test/SemaCXX/deleted-operator.cpp
===
--- test/SemaCXX/deleted-operator.cpp
+++ test/SemaCXX/deleted-operator.cpp
@@ -9,7 +9,7 @@
   PR10757 a1;
   // FIXME: We get a ridiculous number of "built-in candidate" notes here...
   if(~a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 8 {{built-in candidate}}
-  if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 121 {{built-in candidate}}
+  if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 144 {{built-in candidate}}
 }
 
 struct DelOpDel {
Index: test/Sema/float128-ld-incompatibility.cpp
===
--- test/Sema/float128-ld-incompatibility.cpp
+++ test/Sema/float128-ld-incompatibility.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
+// RUN: -triple powerpc64le-unknown-linux-gnu -target-cpu pwr8 \
+// RUN: -target-feature +float128 %s
+
+__float128 qf();
+long double ldf();
+
+// FIXME: once operations between long double and __float128 are implemented for
+//targets where the types are different, these next two will change
+long double ld{qf()}; // expected-error {{cannot initialize a variable of type 'long double' with an rvalue of type '__float128'}}
+__float128 q{ldf()};  // expected-error {{cannot initialize a variable of type '__float128' with an rvalue of type 'long double'}}
+
+auto test1(__float128 q, long double ld) -> decltype(q + ld) { // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
+  return q + ld;  // ex

RE: [PATCH] D17550: Adding doxygen comments to the LLVM intrinsics (part 6, popcntintrin.h)

2016-03-01 Thread Romanova, Katya via cfe-commits
Hi Dmitri,
Thank you for your reply. I have double-checked that compiling a test invoking 
an intrinsic that has C++ style doxygen comments in the corresponding header 
doesn't cause compile-time errors/warnings in 
-std=c89 (and in  gnu89, c99, gnu99, c11, gnu11) modes.

I will continue committing the rest of the x86 inrinsics header files with 
C++-style doxygen comments, unless there are any other objections.
Katya.



> -Original Message-
> From: Dmitri Gribenko [mailto:griboz...@gmail.com]
> Sent: Tuesday, March 01, 2016 1:47 AM
> To: Romanova, Katya
> Cc: Eric Christopher;
> reviews+d17550+public+bc8ce213fd9db...@reviews.llvm.org; Robinson,
> Paul; Bedwell, Greg; cfe-commits@lists.llvm.org
> Subject: Re: [PATCH] D17550: Adding doxygen comments to the LLVM
> intrinsics (part 6, popcntintrin.h)
> 
> On Mon, Feb 29, 2016 at 10:59 AM, Romanova, Katya
>  wrote:
> > Hi Dmitri,
> >
> > Could you please let us know your opinion about C++ vs C-style doxygen
> > comments. Read this thread for ‘pro’ and ‘con’ arguments about using
> > C++ headers. Will LLVM online documentation look proper if we decide
> > to use C-style headers? Which style do you personally prefer to see?
> 
> There are C comments that both Doxygen and Clang recognize well, equally
> well to C++ comments.
> 
> But I don't think that a change is necessary here.  The reason is that these
> are compiler-internal header files, so they will only be ever parsed by Clang.
> No matter which mode Clang is in, it supports //-style comments, either as a
> part of the language, or as an extension, I believe.
> 
> While it is true that a pure c89 compiler won't be able to parse these
> headers, we are not concerned about these builtin headers used by any
> compiler other than Clang.
> 
> Dmitri
> 
> --
> main(i,j){for(i=2;;i++){for(j=2;j (j){printf("%d\n",i);}}} /*Dmitri Gribenko */

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


[PATCH] D17775: Add a few dllimport/dllexport tests. NFC

2016-03-01 Thread Warren Ristow via cfe-commits
wristow created this revision.
wristow added reviewers: cfe-commits, rnk, majnemer.

This change just adds tests for some corner cases of dllimport/dllexport,
primarily for some static methods.

We plan to enable dllimport/dllexport support for the PS4, and these
additional tests are for points we previously were testing internally.

Can someone review, and if OK then commit this patch for me, please?

-Warren Ristow
SN Systems - Sony Computer Entertainment Group

http://reviews.llvm.org/D17775

Files:
  llvm/tools/clang/test/CodeGenCXX/dllexport.cpp
  llvm/tools/clang/test/CodeGenCXX/dllimport.cpp

Index: llvm/tools/clang/test/CodeGenCXX/dllimport.cpp
===
--- llvm/tools/clang/test/CodeGenCXX/dllimport.cpp
+++ llvm/tools/clang/test/CodeGenCXX/dllimport.cpp
@@ -27,6 +27,7 @@
 #define USEVAR(var) USEVARTYPE(int, var)
 #define USE(func) void UNIQ(use)() { func(); }
 #define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return 
&class::func; }
+#define USESTATICMEMFUNC(class, func) void (*UNIQ(use)())() { return 
&class::func; }
 #define USECLASS(class) void UNIQ(USE)() { class x; }
 #define USECOPYASSIGN(class) class& (class::*UNIQ(use)())(class&) { return 
&class::operator=; }
 #define USEMOVEASSIGN(class) class& (class::*UNIQ(use)())(class&&) { return 
&class::operator=; }
@@ -590,6 +591,10 @@
   void a() {}
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void 
@"\01?a@T@@QAEXXZ"
 
+  static void StaticMethod();
+  // MSC-DAG: declare dllimport void @"\01?StaticMethod@T@@SAXXZ"()
+  // GNU-DAG: declare dllimport void @_ZN1T12StaticMethodEv()
+
   static int b;
   // MO1-DAG: @"\01?b@T@@2HA" = external dllimport global i32
 
@@ -602,6 +607,7 @@
   // M19-DAG: define available_externally dllimport x86_thiscallcc 
dereferenceable({{[0-9]+}}) %struct.T* @"\01??4T@@QAEAAU0@$$QAU0@@Z"
 };
 USEMEMFUNC(T, a)
+USESTATICMEMFUNC(T, StaticMethod)
 USEVAR(T::b)
 USECOPYASSIGN(T)
 USEMOVEASSIGN(T)
Index: llvm/tools/clang/test/CodeGenCXX/dllexport.cpp
===
--- llvm/tools/clang/test/CodeGenCXX/dllexport.cpp
+++ llvm/tools/clang/test/CodeGenCXX/dllexport.cpp
@@ -570,6 +570,30 @@
 USEVAR(T::b)
 int T::c;
 
+// Export template class with static member variable
+// MSC-DAG: @"\01?StaticClassVarExpTmplClass@?$TmplClass@H@@2HA" = weak_odr 
dllexport global i32 0, comdat, align 4
+// GNU-DAG: @_ZN9TmplClassIiE26StaticClassVarExpTmplClassE = weak_odr 
dllexport global i32 0, comdat, align 4
+template
+struct __declspec(dllexport) TmplClass
+{
+  static T StaticClassVarExpTmplClass;
+};
+
+template
+T TmplClass::StaticClassVarExpTmplClass;
+
+// Export a definition of a template function.
+// MSC-DAG: define weak_odr dllexport i32 @"\01??$TypeFunTmpl@H@@YAHH@Z"
+// GNU-DAG: define weak_odr dllexport i32 @_Z11TypeFunTmplIiET_S0_
+template
+T __declspec(dllexport) TypeFunTmpl(T t) { return t + t; }
+
+// Instantiate the exported template class and the exported template function.
+int useExportedTmplStaticAndFun()
+{
+  return TmplClass::StaticClassVarExpTmplClass + TypeFunTmpl(10);
+}
+
 template  struct __declspec(dllexport) U { void foo() {} };
 struct __declspec(dllexport) V : public U { };
 // U's assignment operator is emitted.


Index: llvm/tools/clang/test/CodeGenCXX/dllimport.cpp
===
--- llvm/tools/clang/test/CodeGenCXX/dllimport.cpp
+++ llvm/tools/clang/test/CodeGenCXX/dllimport.cpp
@@ -27,6 +27,7 @@
 #define USEVAR(var) USEVARTYPE(int, var)
 #define USE(func) void UNIQ(use)() { func(); }
 #define USEMEMFUNC(class, func) void (class::*UNIQ(use)())() { return &class::func; }
+#define USESTATICMEMFUNC(class, func) void (*UNIQ(use)())() { return &class::func; }
 #define USECLASS(class) void UNIQ(USE)() { class x; }
 #define USECOPYASSIGN(class) class& (class::*UNIQ(use)())(class&) { return &class::operator=; }
 #define USEMOVEASSIGN(class) class& (class::*UNIQ(use)())(class&&) { return &class::operator=; }
@@ -590,6 +591,10 @@
   void a() {}
   // MO1-DAG: define available_externally dllimport x86_thiscallcc void @"\01?a@T@@QAEXXZ"
 
+  static void StaticMethod();
+  // MSC-DAG: declare dllimport void @"\01?StaticMethod@T@@SAXXZ"()
+  // GNU-DAG: declare dllimport void @_ZN1T12StaticMethodEv()
+
   static int b;
   // MO1-DAG: @"\01?b@T@@2HA" = external dllimport global i32
 
@@ -602,6 +607,7 @@
   // M19-DAG: define available_externally dllimport x86_thiscallcc dereferenceable({{[0-9]+}}) %struct.T* @"\01??4T@@QAEAAU0@$$QAU0@@Z"
 };
 USEMEMFUNC(T, a)
+USESTATICMEMFUNC(T, StaticMethod)
 USEVAR(T::b)
 USECOPYASSIGN(T)
 USEMOVEASSIGN(T)
Index: llvm/tools/clang/test/CodeGenCXX/dllexport.cpp
===
--- llvm/tools/clang/test/CodeGenCXX/dllexport.cpp
+++ llvm/tools/clang/test/CodeGenCXX/dllexport.cpp
@@ -570,6 +570,30 @@
 USEVAR(T::b)
 int T::c;
 
+// Export

Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-03-01 Thread Nico Weber via cfe-commits
thakis added a comment.

> I think we can do this separately. A "basename" macro is easier for 
> programmers to use and no build system change needed.


Hm, I would think that adding a flag to your CFLAGS is easier than getting all 
your dependencies to use a clang-only new macro…


http://reviews.llvm.org/D17741



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


Re: [PATCH] D17737: [PGO] change profile use cc1 option

2016-03-01 Thread Rong Xu via cfe-commits
xur marked an inline comment as done.


Comment at: lib/CodeGen/CodeGenModule.cpp:154
@@ +153,3 @@
+assert(!CodeGenOpts.ProfileInstrumentUsePath.empty() &&
+   "Need to explicitly specify the profile name.");
+auto ReaderOrErr = llvm::IndexedInstrProfReader::create(

silvas wrote:
> Are we ensuring consistency in the driver? If not, we definitely want to do 
> that.
I think in driver level, the change change is consistent with the old behavior: 
driver will always set option -fprofile-instrument-use-path= for the pgo use 
compilation,
i.e. when -fprofile-instru-use{=} or -fprofile-use{=} is in the 
command line, we will always have -fprofile-instrument-use-path=,
It will be translated to CodeGenOpts.ProfileInstrumentUsePath in 
ParseCodeGenArgs(). 

In the cc1 level, the behavior changed: old behavior is:
-fprofile-instru-use= will trigger the use compilation.
Now requires two cc1 opitons:
-fprofile-instrument=clang -fprofile-instrument-use-path=.
Having -fprofile-instrument=clang only will trigger the assertion and
having -fprofile-instrument-use-path= is vold op.
I did this because the old pgo use cc1 option requires the profile path.

This is contrast in the IR level instrument, where 
-fprofile-instrument-use-path= is optional: we will use default.profdata 
in the absence.




Comment at: lib/Frontend/CompilerInvocation.cpp:381
@@ +380,3 @@
+   OptSpecifier Id, DiagnosticsEngine &Diags) {
+  if (Id != OPT_fprofile_instrument_EQ && Id != OPT_fprofile_instrument_use_EQ)
+return;

silvas wrote:
> I think it would be better to assert that it is one of the two options rather 
> than silently doing nothing.
Yes. Assertion is better. Will do in the commit.


http://reviews.llvm.org/D17737



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


Re: [PATCH] D17550: Adding doxygen comments to the LLVM intrinsics (part 6, popcntintrin.h)

2016-03-01 Thread Eric Christopher via cfe-commits
That's fine, thanks.

On Tue, Mar 1, 2016 at 10:52 AM Romanova, Katya <
katya_roman...@playstation.sony.com> wrote:

> Hi Dmitri,
> Thank you for your reply. I have double-checked that compiling a test
> invoking an intrinsic that has C++ style doxygen comments in the
> corresponding header doesn't cause compile-time errors/warnings in
> -std=c89 (and in  gnu89, c99, gnu99, c11, gnu11) modes.
>
> I will continue committing the rest of the x86 inrinsics header files with
> C++-style doxygen comments, unless there are any other objections.
> Katya.
>
>
>
> > -Original Message-
> > From: Dmitri Gribenko [mailto:griboz...@gmail.com]
> > Sent: Tuesday, March 01, 2016 1:47 AM
> > To: Romanova, Katya
> > Cc: Eric Christopher;
> > reviews+d17550+public+bc8ce213fd9db...@reviews.llvm.org; Robinson,
> > Paul; Bedwell, Greg; cfe-commits@lists.llvm.org
> > Subject: Re: [PATCH] D17550: Adding doxygen comments to the LLVM
> > intrinsics (part 6, popcntintrin.h)
> >
> > On Mon, Feb 29, 2016 at 10:59 AM, Romanova, Katya
> >  wrote:
> > > Hi Dmitri,
> > >
> > > Could you please let us know your opinion about C++ vs C-style doxygen
> > > comments. Read this thread for ‘pro’ and ‘con’ arguments about using
> > > C++ headers. Will LLVM online documentation look proper if we decide
> > > to use C-style headers? Which style do you personally prefer to see?
> >
> > There are C comments that both Doxygen and Clang recognize well, equally
> > well to C++ comments.
> >
> > But I don't think that a change is necessary here.  The reason is that
> these
> > are compiler-internal header files, so they will only be ever parsed by
> Clang.
> > No matter which mode Clang is in, it supports //-style comments, either
> as a
> > part of the language, or as an extension, I believe.
> >
> > While it is true that a pure c89 compiler won't be able to parse these
> > headers, we are not concerned about these builtin headers used by any
> > compiler other than Clang.
> >
> > Dmitri
> >
> > --
> > main(i,j){for(i=2;;i++){for(j=2;j > (j){printf("%d\n",i);}}} /*Dmitri Gribenko */
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16876: [OpenCL] Refine pipe builtin support

2016-03-01 Thread Anastasia Stulova via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM!


http://reviews.llvm.org/D16876



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


Re: [PATCH] D17752: [MSVC Compat] Correctly handle finallys nested within finallys

2016-03-01 Thread David Majnemer via cfe-commits
majnemer updated this revision to Diff 49522.
majnemer added a comment.

- Address Reid's review comments


http://reviews.llvm.org/D17752

Files:
  lib/CodeGen/CGException.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/exceptions-seh-finally.c

Index: test/CodeGen/exceptions-seh-finally.c
===
--- test/CodeGen/exceptions-seh-finally.c
+++ test/CodeGen/exceptions-seh-finally.c
@@ -230,3 +230,28 @@
 
 // CHECK-LABEL: define internal void @"\01?fin$1@0@nested___finally___finally_with_eh_edge@@"({{.*}})
 // CHECK: unreachable
+
+void finally_within_finally() {
+  __try {
+might_crash();
+  } __finally {
+__try {
+  might_crash();
+} __finally {
+}
+  }
+}
+
+// CHECK-LABEL: define void @finally_within_finally(
+// CHECK: invoke void @might_crash(
+
+// CHECK: call void @"\01?fin$0@0@finally_within_finally@@"(
+// CHECK: call void @"\01?fin$0@0@finally_within_finally@@"({{.*}}) [ "funclet"(
+
+// CHECK-LABEL: define internal void @"\01?fin$0@0@finally_within_finally@@"(
+// CHECK: invoke void @might_crash(
+
+// CHECK: call void @"\01?fin$1@0@finally_within_finally@@"(
+// CHECK: call void @"\01?fin$1@0@finally_within_finally@@"({{.*}}) [ "funclet"(
+
+// CHECK-LABEL: define internal void @"\01?fin$1@0@finally_within_finally@@"(
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -276,6 +276,8 @@
   /// potentially set the return value.
   bool SawAsmBlock;
 
+  const FunctionDecl *CurSEHParent = nullptr;
+
   /// True if the current function is an outlined SEH helper. This can be a
   /// finally block or filter expression.
   bool IsOutlinedSEHHelper;
@@ -1150,10 +1152,7 @@
 return getInvokeDestImpl();
   }
 
-  bool currentFunctionUsesSEHTry() const {
-const auto *FD = dyn_cast_or_null(CurCodeDecl);
-return FD && FD->usesSEHTry();
-  }
+  bool currentFunctionUsesSEHTry() const { return CurSEHParent != nullptr; }
 
   const TargetInfo &getTarget() const { return Target; }
   llvm::LLVMContext &getLLVMContext() { return CGM.getLLVMContext(); }
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -669,6 +669,9 @@
 
   DidCallStackSave = false;
   CurCodeDecl = D;
+  if (const auto *FD = dyn_cast_or_null(D))
+if (FD->usesSEHTry())
+  CurSEHParent = FD;
   CurFuncDecl = (D ? D->getNonClosureContext() : nullptr);
   FnRetTy = RetTy;
   CurFn = Fn;
Index: lib/CodeGen/CGException.cpp
===
--- lib/CodeGen/CGException.cpp
+++ lib/CodeGen/CGException.cpp
@@ -1625,14 +1625,13 @@
   SmallString<128> Name;
   {
 llvm::raw_svector_ostream OS(Name);
-const Decl *ParentCodeDecl = ParentCGF.CurCodeDecl;
-const NamedDecl *Parent = dyn_cast_or_null(ParentCodeDecl);
-assert(Parent && "FIXME: handle unnamed decls (lambdas, blocks) with SEH");
+const FunctionDecl *ParentSEHFn = ParentCGF.CurSEHParent;
+assert(ParentSEHFn && "No CurSEHParent!");
 MangleContext &Mangler = CGM.getCXXABI().getMangleContext();
 if (IsFilter)
-  Mangler.mangleSEHFilterExpression(Parent, OS);
+  Mangler.mangleSEHFilterExpression(ParentSEHFn, OS);
 else
-  Mangler.mangleSEHFinallyBlock(Parent, OS);
+  Mangler.mangleSEHFinallyBlock(ParentSEHFn, OS);
   }
 
   FunctionArgList Args;
@@ -1679,6 +1678,7 @@
 
   StartFunction(GlobalDecl(), RetTy, Fn, FnInfo, Args,
 OutlinedStmt->getLocStart(), OutlinedStmt->getLocStart());
+  CurSEHParent = ParentCGF.CurSEHParent;
 
   CGM.SetLLVMFunctionAttributes(nullptr, FnInfo, CurFn);
   EmitCapturedLocals(ParentCGF, OutlinedStmt, IsFilter);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17752: [MSVC Compat] Correctly handle finallys nested within finallys

2016-03-01 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


http://reviews.llvm.org/D17752



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


Re: [PATCH] D17752: [MSVC Compat] Correctly handle finallys nested within finallys

2016-03-01 Thread David Majnemer via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262379: [MSVC Compat] Correctly handle finallys nested 
within finallys (authored by majnemer).

Changed prior to commit:
  http://reviews.llvm.org/D17752?vs=49522&id=49525#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17752

Files:
  cfe/trunk/lib/CodeGen/CGException.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/test/CodeGen/exceptions-seh-finally.c

Index: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
@@ -669,6 +669,9 @@
 
   DidCallStackSave = false;
   CurCodeDecl = D;
+  if (const auto *FD = dyn_cast_or_null(D))
+if (FD->usesSEHTry())
+  CurSEHParent = FD;
   CurFuncDecl = (D ? D->getNonClosureContext() : nullptr);
   FnRetTy = RetTy;
   CurFn = Fn;
Index: cfe/trunk/lib/CodeGen/CGException.cpp
===
--- cfe/trunk/lib/CodeGen/CGException.cpp
+++ cfe/trunk/lib/CodeGen/CGException.cpp
@@ -1625,14 +1625,13 @@
   SmallString<128> Name;
   {
 llvm::raw_svector_ostream OS(Name);
-const Decl *ParentCodeDecl = ParentCGF.CurCodeDecl;
-const NamedDecl *Parent = dyn_cast_or_null(ParentCodeDecl);
-assert(Parent && "FIXME: handle unnamed decls (lambdas, blocks) with SEH");
+const FunctionDecl *ParentSEHFn = ParentCGF.CurSEHParent;
+assert(ParentSEHFn && "No CurSEHParent!");
 MangleContext &Mangler = CGM.getCXXABI().getMangleContext();
 if (IsFilter)
-  Mangler.mangleSEHFilterExpression(Parent, OS);
+  Mangler.mangleSEHFilterExpression(ParentSEHFn, OS);
 else
-  Mangler.mangleSEHFinallyBlock(Parent, OS);
+  Mangler.mangleSEHFinallyBlock(ParentSEHFn, OS);
   }
 
   FunctionArgList Args;
@@ -1679,6 +1678,7 @@
 
   StartFunction(GlobalDecl(), RetTy, Fn, FnInfo, Args,
 OutlinedStmt->getLocStart(), OutlinedStmt->getLocStart());
+  CurSEHParent = ParentCGF.CurSEHParent;
 
   CGM.SetLLVMFunctionAttributes(nullptr, FnInfo, CurFn);
   EmitCapturedLocals(ParentCGF, OutlinedStmt, IsFilter);
Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h
===
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h
@@ -276,6 +276,8 @@
   /// potentially set the return value.
   bool SawAsmBlock;
 
+  const FunctionDecl *CurSEHParent = nullptr;
+
   /// True if the current function is an outlined SEH helper. This can be a
   /// finally block or filter expression.
   bool IsOutlinedSEHHelper;
@@ -1150,10 +1152,7 @@
 return getInvokeDestImpl();
   }
 
-  bool currentFunctionUsesSEHTry() const {
-const auto *FD = dyn_cast_or_null(CurCodeDecl);
-return FD && FD->usesSEHTry();
-  }
+  bool currentFunctionUsesSEHTry() const { return CurSEHParent != nullptr; }
 
   const TargetInfo &getTarget() const { return Target; }
   llvm::LLVMContext &getLLVMContext() { return CGM.getLLVMContext(); }
Index: cfe/trunk/test/CodeGen/exceptions-seh-finally.c
===
--- cfe/trunk/test/CodeGen/exceptions-seh-finally.c
+++ cfe/trunk/test/CodeGen/exceptions-seh-finally.c
@@ -230,3 +230,28 @@
 
 // CHECK-LABEL: define internal void @"\01?fin$1@0@nested___finally___finally_with_eh_edge@@"({{.*}})
 // CHECK: unreachable
+
+void finally_within_finally() {
+  __try {
+might_crash();
+  } __finally {
+__try {
+  might_crash();
+} __finally {
+}
+  }
+}
+
+// CHECK-LABEL: define void @finally_within_finally(
+// CHECK: invoke void @might_crash(
+
+// CHECK: call void @"\01?fin$0@0@finally_within_finally@@"(
+// CHECK: call void @"\01?fin$0@0@finally_within_finally@@"({{.*}}) [ "funclet"(
+
+// CHECK-LABEL: define internal void @"\01?fin$0@0@finally_within_finally@@"(
+// CHECK: invoke void @might_crash(
+
+// CHECK: call void @"\01?fin$1@0@finally_within_finally@@"(
+// CHECK: call void @"\01?fin$1@0@finally_within_finally@@"({{.*}}) [ "funclet"(
+
+// CHECK-LABEL: define internal void @"\01?fin$1@0@finally_within_finally@@"(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262379 - [MSVC Compat] Correctly handle finallys nested within finallys

2016-03-01 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Tue Mar  1 13:42:53 2016
New Revision: 262379

URL: http://llvm.org/viewvc/llvm-project?rev=262379&view=rev
Log:
[MSVC Compat] Correctly handle finallys nested within finallys

We'd lose track of the parent CodeGenFunction, leading us to get
confused with regard to which function a nested finally belonged to.

Differential Revision: http://reviews.llvm.org/D17752

Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGen/exceptions-seh-finally.c

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=262379&r1=262378&r2=262379&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Mar  1 13:42:53 2016
@@ -1625,14 +1625,13 @@ void CodeGenFunction::startOutlinedSEHHe
   SmallString<128> Name;
   {
 llvm::raw_svector_ostream OS(Name);
-const Decl *ParentCodeDecl = ParentCGF.CurCodeDecl;
-const NamedDecl *Parent = dyn_cast_or_null(ParentCodeDecl);
-assert(Parent && "FIXME: handle unnamed decls (lambdas, blocks) with SEH");
+const FunctionDecl *ParentSEHFn = ParentCGF.CurSEHParent;
+assert(ParentSEHFn && "No CurSEHParent!");
 MangleContext &Mangler = CGM.getCXXABI().getMangleContext();
 if (IsFilter)
-  Mangler.mangleSEHFilterExpression(Parent, OS);
+  Mangler.mangleSEHFilterExpression(ParentSEHFn, OS);
 else
-  Mangler.mangleSEHFinallyBlock(Parent, OS);
+  Mangler.mangleSEHFinallyBlock(ParentSEHFn, OS);
   }
 
   FunctionArgList Args;
@@ -1679,6 +1678,7 @@ void CodeGenFunction::startOutlinedSEHHe
 
   StartFunction(GlobalDecl(), RetTy, Fn, FnInfo, Args,
 OutlinedStmt->getLocStart(), OutlinedStmt->getLocStart());
+  CurSEHParent = ParentCGF.CurSEHParent;
 
   CGM.SetLLVMFunctionAttributes(nullptr, FnInfo, CurFn);
   EmitCapturedLocals(ParentCGF, OutlinedStmt, IsFilter);

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=262379&r1=262378&r2=262379&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Mar  1 13:42:53 2016
@@ -669,6 +669,9 @@ void CodeGenFunction::StartFunction(Glob
 
   DidCallStackSave = false;
   CurCodeDecl = D;
+  if (const auto *FD = dyn_cast_or_null(D))
+if (FD->usesSEHTry())
+  CurSEHParent = FD;
   CurFuncDecl = (D ? D->getNonClosureContext() : nullptr);
   FnRetTy = RetTy;
   CurFn = Fn;

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=262379&r1=262378&r2=262379&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Tue Mar  1 13:42:53 2016
@@ -276,6 +276,8 @@ public:
   /// potentially set the return value.
   bool SawAsmBlock;
 
+  const FunctionDecl *CurSEHParent = nullptr;
+
   /// True if the current function is an outlined SEH helper. This can be a
   /// finally block or filter expression.
   bool IsOutlinedSEHHelper;
@@ -1150,10 +1152,7 @@ public:
 return getInvokeDestImpl();
   }
 
-  bool currentFunctionUsesSEHTry() const {
-const auto *FD = dyn_cast_or_null(CurCodeDecl);
-return FD && FD->usesSEHTry();
-  }
+  bool currentFunctionUsesSEHTry() const { return CurSEHParent != nullptr; }
 
   const TargetInfo &getTarget() const { return Target; }
   llvm::LLVMContext &getLLVMContext() { return CGM.getLLVMContext(); }

Modified: cfe/trunk/test/CodeGen/exceptions-seh-finally.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/exceptions-seh-finally.c?rev=262379&r1=262378&r2=262379&view=diff
==
--- cfe/trunk/test/CodeGen/exceptions-seh-finally.c (original)
+++ cfe/trunk/test/CodeGen/exceptions-seh-finally.c Tue Mar  1 13:42:53 2016
@@ -230,3 +230,28 @@ int nested___finally___finally_with_eh_e
 
 // CHECK-LABEL: define internal void 
@"\01?fin$1@0@nested___finally___finally_with_eh_edge@@"({{.*}})
 // CHECK: unreachable
+
+void finally_within_finally() {
+  __try {
+might_crash();
+  } __finally {
+__try {
+  might_crash();
+} __finally {
+}
+  }
+}
+
+// CHECK-LABEL: define void @finally_within_finally(
+// CHECK: invoke void @might_crash(
+
+// CHECK: call void @"\01?fin$0@0@finally_within_finally@@"(
+// CHECK: call void @"\01?fin$0@0@finally_within_finally@@"({{.*}}) [ 
"funclet"(
+
+// CHECK-LABEL: define internal void @"\01?fin$0@0@finally_within_finally@@"(
+// CHECK: invoke void @might_crash(
+
+// C

r262382 - Reword a misleading comment discussing landingpads and SEH

2016-03-01 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Mar  1 13:51:48 2016
New Revision: 262382

URL: http://llvm.org/viewvc/llvm-project?rev=262382&view=rev
Log:
Reword a misleading comment discussing landingpads and SEH

SEH doesn't use landingpads anymore.

Modified:
cfe/trunk/lib/CodeGen/CGException.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=262382&r1=262381&r2=262382&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Mar  1 13:51:48 2016
@@ -686,8 +686,10 @@ llvm::BasicBlock *CodeGenFunction::getIn
   assert(EHStack.requiresLandingPad());
   assert(!EHStack.empty());
 
-  // If exceptions are disabled, there are usually no landingpads. However, 
when
-  // SEH is enabled, functions using SEH still get landingpads.
+  // If exceptions are disabled and SEH is not in use, then there is no invoke
+  // destination. SEH "works" even if exceptions are off. In practice, this
+  // means that C++ destructors and other EH cleanups don't run, which is
+  // consistent with MSVC's behavior.
   const LangOptions &LO = CGM.getLangOpts();
   if (!LO.Exceptions) {
 if (!LO.Borland && !LO.MicrosoftExt)


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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-03-01 Thread Sean Silva via cfe-commits
On Tue, Mar 1, 2016 at 10:54 AM, Nico Weber via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> thakis added a comment.
>
> > I think we can do this separately. A "basename" macro is easier for
> programmers to use and no build system change needed.
>
>
> Hm, I would think that adding a flag to your CFLAGS is easier than getting
> all your dependencies to use a clang-only new macro…
>

Yeah, we have gotten an internal request for similar functionality and it
definitely was a "whole build" granularity (i.e. CFLAGS) that the behavior
was desired. That being said, __FILE_BASENAME__ might be useful to have in
its own right.

-- Sean Silva


>
>
> http://reviews.llvm.org/D17741
>
>
>
> ___
> 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


Re: [PATCH] D17741: adds __FILE_BASENAME__ builtin macro

2016-03-01 Thread Ben Craig via cfe-commits
bcraig added a comment.

In http://reviews.llvm.org/D17741#365457, @thakis wrote:

> > I think we can do this separately. A "basename" macro is easier for 
> > programmers to use and no build system change needed.
>
>
> Hm, I would think that adding a flag to your CFLAGS is easier than getting 
> all your dependencies to use a clang-only new macro…


Depends a lot on the person and code base.
**Pro-macro situations:**
I've had code bases where the bulk of the code refused to use compiler / 
environment provided preprocessor tokens.  In those environments, all of the 
uses of __FILE__ and the like were in one place.  Adding a compiler test and 
switching to __CLANG_FILE_BASENAME__ would be easy in those code bases.  
Changing CFLAGS in dozens of different compiles wouldn't.

I've also seen uses of __FILE__ that would break if the file name changed 
drastically and unexpectedly.

**Pro-compilation switch situation:**
If __FILE__ is used in a lot of places, and the files are compiled with 
multiple compilers, then switching to a different macro would be problematic.  
If it is easy to change CFLAGS in all of your builds then the compilation 
switch makes sense.


http://reviews.llvm.org/D17741



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


Re: [PATCH] D17775: Add a few dllimport/dllexport tests. NFC

2016-03-01 Thread Sean Silva via cfe-commits
silvas added a subscriber: silvas.
silvas added a comment.

Random question:

> We plan to enable dllimport/dllexport support for the PS4


How are you planning on codegenning them? The same way as we do in our private 
branch?


http://reviews.llvm.org/D17775



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


Re: [PATCH] D15654: A Python code model for C++ used to drive code generators

2016-03-01 Thread Jonathan B Coe via cfe-commits
jbcoe added a comment.

Has anyone had a chance to look over this?


http://reviews.llvm.org/D15654



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


r262385 - This patch adds doxygen comments for the intrinsincs in the header file popcntintrin.h.

2016-03-01 Thread Ekaterina Romanova via cfe-commits
Author: kromanova
Date: Tue Mar  1 14:04:57 2016
New Revision: 262385

URL: http://llvm.org/viewvc/llvm-project?rev=262385&view=rev
Log:
This patch adds doxygen comments for the intrinsincs in the header file 
popcntintrin.h.

The doxygen comments are automatically generated based on Sony's intrinsics 
documentation.

Differential Revision: http://reviews.llvm.org/D17550 


Modified:
cfe/trunk/lib/Headers/popcntintrin.h

Modified: cfe/trunk/lib/Headers/popcntintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/popcntintrin.h?rev=262385&r1=262384&r2=262385&view=diff
==
--- cfe/trunk/lib/Headers/popcntintrin.h (original)
+++ cfe/trunk/lib/Headers/popcntintrin.h Tue Mar  1 14:04:57 2016
@@ -27,12 +27,32 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("popcnt")))
 
+/// \brief Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c POPCNT instruction.
+///
+/// \param __A
+///An unsigned 32-bit integer operand.
+/// \returns A 32-bit integer containing the number of bits with value 1 in the
+///source operand.
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_popcnt_u32(unsigned int __A)
 {
   return __builtin_popcount(__A);
 }
 
+/// \brief Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c POPCNT instruction.
+///
+/// \param __A
+///A signed 32-bit integer operand.
+/// \returns A 32-bit integer containing the number of bits with value 1 in the
+///source operand.
 static __inline__ int __DEFAULT_FN_ATTRS
 _popcnt32(int __A)
 {
@@ -40,12 +60,32 @@ _popcnt32(int __A)
 }
 
 #ifdef __x86_64__
+/// \brief Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c POPCNT instruction.
+///
+/// \param __A
+///An unsigned 64-bit integer operand.
+/// \returns A 64-bit integer containing the number of bits with value 1 in the
+///source operand.
 static __inline__ long long __DEFAULT_FN_ATTRS
 _mm_popcnt_u64(unsigned long long __A)
 {
   return __builtin_popcountll(__A);
 }
 
+/// \brief Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c POPCNT instruction.
+///
+/// \param __A
+///A signed 64-bit integer operand.
+/// \returns A 64-bit integer containing the number of bits with value 1 in the
+///source operand.
 static __inline__ long long __DEFAULT_FN_ATTRS
 _popcnt64(long long __A)
 {


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


Re: [PATCH] D17550: Adding doxygen comments to the LLVM intrinsics (part 6, popcntintrin.h)

2016-03-01 Thread Katya Romanova via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL262385: This patch adds doxygen comments for the intrinsincs 
in the header file… (authored by kromanova).

Changed prior to commit:
  http://reviews.llvm.org/D17550?vs=48844&id=49534#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17550

Files:
  cfe/trunk/lib/Headers/popcntintrin.h

Index: cfe/trunk/lib/Headers/popcntintrin.h
===
--- cfe/trunk/lib/Headers/popcntintrin.h
+++ cfe/trunk/lib/Headers/popcntintrin.h
@@ -27,25 +27,65 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("popcnt")))
 
+/// \brief Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c POPCNT instruction.
+///
+/// \param __A
+///An unsigned 32-bit integer operand.
+/// \returns A 32-bit integer containing the number of bits with value 1 in the
+///source operand.
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_popcnt_u32(unsigned int __A)
 {
   return __builtin_popcount(__A);
 }
 
+/// \brief Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c POPCNT instruction.
+///
+/// \param __A
+///A signed 32-bit integer operand.
+/// \returns A 32-bit integer containing the number of bits with value 1 in the
+///source operand.
 static __inline__ int __DEFAULT_FN_ATTRS
 _popcnt32(int __A)
 {
   return __builtin_popcount(__A);
 }
 
 #ifdef __x86_64__
+/// \brief Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c POPCNT instruction.
+///
+/// \param __A
+///An unsigned 64-bit integer operand.
+/// \returns A 64-bit integer containing the number of bits with value 1 in the
+///source operand.
 static __inline__ long long __DEFAULT_FN_ATTRS
 _mm_popcnt_u64(unsigned long long __A)
 {
   return __builtin_popcountll(__A);
 }
 
+/// \brief Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c POPCNT instruction.
+///
+/// \param __A
+///A signed 64-bit integer operand.
+/// \returns A 64-bit integer containing the number of bits with value 1 in the
+///source operand.
 static __inline__ long long __DEFAULT_FN_ATTRS
 _popcnt64(long long __A)
 {


Index: cfe/trunk/lib/Headers/popcntintrin.h
===
--- cfe/trunk/lib/Headers/popcntintrin.h
+++ cfe/trunk/lib/Headers/popcntintrin.h
@@ -27,25 +27,65 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("popcnt")))
 
+/// \brief Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c POPCNT instruction.
+///
+/// \param __A
+///An unsigned 32-bit integer operand.
+/// \returns A 32-bit integer containing the number of bits with value 1 in the
+///source operand.
 static __inline__ int __DEFAULT_FN_ATTRS
 _mm_popcnt_u32(unsigned int __A)
 {
   return __builtin_popcount(__A);
 }
 
+/// \brief Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c POPCNT instruction.
+///
+/// \param __A
+///A signed 32-bit integer operand.
+/// \returns A 32-bit integer containing the number of bits with value 1 in the
+///source operand.
 static __inline__ int __DEFAULT_FN_ATTRS
 _popcnt32(int __A)
 {
   return __builtin_popcount(__A);
 }
 
 #ifdef __x86_64__
+/// \brief Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c POPCNT instruction.
+///
+/// \param __A
+///An unsigned 64-bit integer operand.
+/// \returns A 64-bit integer containing the number of bits with value 1 in the
+///source operand.
 static __inline__ long long __DEFAULT_FN_ATTRS
 _mm_popcnt_u64(unsigned long long __A)
 {
   return __builtin_popcountll(__A);
 }
 
+/// \brief Counts the number of bits in the source operand having a value of 1.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c POPCNT instruction.
+///
+/// \param __A
+///A signed 64-bit integer operand.
+/// \returns A 64-bit integer containing the number of bits with value 1 in the
+///source operand.
 static __inline__ long long __DEFAULT_FN_ATTRS
 _popcnt64(long long __A)
 {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17772: [clang-tidy]: string_view of temporary string

2016-03-01 Thread Jonathan Coe via cfe-commits
Maybe config options could allow addition of owning and non-owning pairs?

I'd like to do that as an extension if this path is approved.

Jon

On 1 March 2016 at 12:29, David Blaikie  wrote:

> Any way to/would it be worth broadening this with an annotation or some
> such (or just a lost for now) of types that maintain references to their
> ctor params? (Eg: llvm arrayref, etc)
> On Mar 1, 2016 9:19 AM, "Jonathan B Coe via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
>> jbcoe created this revision.
>> jbcoe added reviewers: aaron.ballman, alexfh.
>> jbcoe added a subscriber: cfe-commits.
>> jbcoe set the repository for this revision to rL LLVM.
>>
>> Find instances where a string_view is constructed from a temporary string
>> and replace the string_view with a string.
>>
>> Repository:
>>   rL LLVM
>>
>> http://reviews.llvm.org/D17772
>>
>> Files:
>>   clang-tidy/misc/CMakeLists.txt
>>   clang-tidy/misc/MiscTidyModule.cpp
>>   clang-tidy/misc/StringViewOfTemporaryCheck.cpp
>>   clang-tidy/misc/StringViewOfTemporaryCheck.h
>>   docs/clang-tidy/checks/list.rst
>>   docs/clang-tidy/checks/misc-string_view-of-temporary.rst
>>   test/clang-tidy/misc-string_view-of-temporary.cpp
>>
>>
>> ___
>> 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


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-01 Thread Alexander Riccio via cfe-commits
ariccio added a comment.

Is this patch all clear to go?

I hope I don't sound too pushy - I just don't want to lose momentum here.


http://reviews.llvm.org/D17688



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


Re: [PATCH] D17764: Add attributes for AMD GPU Tools

2016-03-01 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

Some quick thoughts below.



Comment at: include/clang/Basic/Attr.td:997
@@ +996,3 @@
+  let Subjects = SubjectList<[Function], ErrorDiag,
+ "ExpectedKernelFunction">;
+}

I don't see any code that checks whether the function is actually a kernel 
function, nor sema tests that diagnose if this is attached to a non-kernel 
function.

It may make sense to make a SubsetSubject that does the checking for you, and 
use that in all of these attributes.


Comment at: include/clang/Basic/AttrDocs.td:943
@@ +942,3 @@
+
+Clang supports following attributes for tools, such as debugger and profiler:
+  }];

This reads a bit strangely, can it be "debuggers" and "profilers" (plural)?


Comment at: include/clang/Basic/AttrDocs.td:951
@@ +950,3 @@
+
+Clang supports ``__attribute__((amdgpu_tools_insert_nops))`` attribute on AMD
+Southern Islands GPUs and later. If specified, causes AMD GPU Backend to insert

"supports the `__attribute__`" (insert the).


Comment at: include/clang/Basic/AttrDocs.td:952
@@ +951,3 @@
+Clang supports ``__attribute__((amdgpu_tools_insert_nops))`` attribute on AMD
+Southern Islands GPUs and later. If specified, causes AMD GPU Backend to insert
+two nop instructions for each high level source statement: one nop instruction

"it causes" (insert it).


Comment at: include/clang/Basic/AttrDocs.td:954
@@ +953,3 @@
+two nop instructions for each high level source statement: one nop instruction
+is inserted before first isa instruction of high level source statement, and 
one
+nop instruction is inserted after last isa instruction of high level source

"before the first ISA" (insert the, capitalize acronym).
"of the high level" (insert the).


Comment at: include/clang/Basic/AttrDocs.td:955
@@ +954,3 @@
+is inserted before first isa instruction of high level source statement, and 
one
+nop instruction is inserted after last isa instruction of high level source
+statement.

"after the last ISA" (insert the, capitalize acronym).
"of the high level" (insert the).


Comment at: include/clang/Basic/AttrDocs.td:959
@@ +958,3 @@
+In addition to specifying this attribute manually, clang can add this attribute
+for each kernel function in module if ``--amdgpu-tools-insert-nops`` clang
+command line option is specified.

"function in module" -> "function in the translation unit"? At least insert 
"the", but uncertain what you mean by "module", which I assume to be a 
translation unit.

Also add "the" before the command line option.


Comment at: include/clang/Basic/AttrDocs.td:964
@@ +963,3 @@
+
+def AMDGPUToolsNumReservedVGPRDocs : Documentation {
+  let Category = DocCatAMDGPUToolsAttributes;

Same sentence comments apply to the following attributes as above.


Comment at: test/SemaOpenCL/amdgpu-tools-attrs.cl:5
@@ +4,3 @@
+typedef __attribute__((amdgpu_tools_insert_nops)) struct foo0_s { // 
expected-error {{'amdgpu_tools_insert_nops' attribute only applies to kernel 
functions}}
+  int x;
+  int y;

You can make the struct empty in these tests, but more importantly, it would be 
good to see a test that ensures the following diagnoses:
```
__attribute__((amdgpu_tools_insert_nops)) void not_a_kernel_func() {}
```


http://reviews.llvm.org/D17764



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


Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-01 Thread Aaron Ballman via cfe-commits
On Tue, Mar 1, 2016 at 1:42 PM, 
 wrote:
> I'd quite happily add them... but can I do it in another patch? I think I
> could be more thorough that way.

I'm not certain I understand the reasoning, but I also don't have
strong feelings on whether it's this patch or another. I just don't
understand why some functions made it in this patch and not others
(notably, why the lack of _mbsdup, which is documented on the same
page as others you are adding).

> For the same reason, can we list all the microsoft memory allocating
> routines here? There are a thousand routines we might want to add, and then
> a few others (like _dupenv_s, _malloca, and _expand) which are especially
> important to be able to analyze (because they have really tricky APIs), but
> because of their kooky APIs, they're harder to implement checkers for.

By "here", do you mean in this review thread, or as part of this
section of code?

~Aaron

>
> Sincerely,
> Alexander Riccio
> --
> "Change the world or go home."
> about.me/ariccio
>
> If left to my own devices, I will build more.
> ⁂
>
> On Tue, Mar 1, 2016 at 8:38 AM, Aaron Ballman 
> wrote:
>>
>> On Tue, Mar 1, 2016 at 2:16 AM, Alexander Riccio 
>> wrote:
>> > ariccio updated this revision to Diff 49456.
>> > ariccio added a comment.
>> >
>> > Nit addressed.
>> >
>> >
>> > http://reviews.llvm.org/D17688
>> >
>> > Files:
>> >   llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> >
>> > Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> > ===
>> > --- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> > +++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> > @@ -169,11 +169,12 @@
>> >  {
>> >  public:
>> >MallocChecker()
>> > -  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
>> > -II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr),
>> > -II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr),
>> > -II_kmalloc(nullptr), II_if_nameindex(nullptr),
>> > -II_if_freenameindex(nullptr) {}
>> > +  : II_alloca(nullptr), II_win_alloca(nullptr), II_malloc(nullptr),
>> > +II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
>> > +II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
>> > +II_strdup(nullptr), II_win_strdup(nullptr),
>> > II_kmalloc(nullptr),
>> > +II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
>> > +II_wcsdup(nullptr), II_win_wcsdup(nullptr) {}
>> >
>> >/// In pessimistic mode, the checker assumes that it does not know
>> > which
>> >/// functions might free the memory.
>> > @@ -231,10 +232,11 @@
>> >mutable std::unique_ptr BT_MismatchedDealloc;
>> >mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
>> >mutable std::unique_ptr
>> > BT_UseZerroAllocated[CK_NumCheckKinds];
>> > -  mutable IdentifierInfo *II_alloca, *II_malloc, *II_free, *II_realloc,
>> > - *II_calloc, *II_valloc, *II_reallocf,
>> > *II_strndup,
>> > - *II_strdup, *II_kmalloc, *II_if_nameindex,
>> > - *II_if_freenameindex;
>> > +  mutable IdentifierInfo *II_alloca, *II_win_alloca, *II_malloc,
>> > *II_free,
>> > + *II_realloc, *II_calloc, *II_valloc,
>> > *II_reallocf,
>> > + *II_strndup, *II_strdup, *II_win_strdup,
>> > *II_kmalloc,
>> > + *II_if_nameindex, *II_if_freenameindex,
>> > *II_wcsdup,
>> > + *II_win_wcsdup;
>> >mutable Optional KernelZeroFlagVal;
>> >
>> >void initIdentifierInfo(ASTContext &C) const;
>> > @@ -540,9 +542,15 @@
>> >II_valloc = &Ctx.Idents.get("valloc");
>> >II_strdup = &Ctx.Idents.get("strdup");
>> >II_strndup = &Ctx.Idents.get("strndup");
>> > +  II_wcsdup = &Ctx.Idents.get("wcsdup");
>> >II_kmalloc = &Ctx.Idents.get("kmalloc");
>> >II_if_nameindex = &Ctx.Idents.get("if_nameindex");
>> >II_if_freenameindex = &Ctx.Idents.get("if_freenameindex");
>> > +
>> > +  //MSVC uses `_`-prefixed instead, so we check for them too.
>> > +  II_win_strdup = &Ctx.Idents.get("_strdup");
>> > +  II_win_wcsdup = &Ctx.Idents.get("_wcsdup");
>> > +  II_win_alloca = &Ctx.Idents.get("_alloca");
>>
>> What about: _mbsdup, _strdup_dbg, _wcsdup_dbg, _aligned_realloc, and
>> the rest? If we're going to add these (which I really support), it
>> would be good to make a comprehensive sweep for the Win32 additions
>> and add them all.
>>
>> ~Aaron
>>
>> >  }
>> >
>> >  bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext
>> > &C) const {
>> > @@ -585,7 +593,8 @@
>> >  if (Family == AF_Malloc && CheckAlloc) {
>> >if (FunI == II_malloc || FunI == II_realloc || FunI ==
>> > II_reallocf ||
>> >FunI == II_calloc || FunI == II_valloc || FunI == II_strdup
>> > ||
>> > -  FunI == II_strndup || FunI == 

Re: [PATCH] D17682: [X86] AMD Bobcat CPU (btver1) doesn't support XSAVE

2016-03-01 Thread Yunzhong Gao via cfe-commits
ygao added a subscriber: ygao.


Comment at: lib/Basic/Targets.cpp:2772
@@ -2771,2 +2771,3 @@
 setFeatureEnabledImpl(Features, "xsaveopt", true);
+setFeatureEnabledImpl(Features, "xsave", true);
 // FALLTHROUGH

Is this line necessary? Line#3027 below in the same file says that xsaveopt 
already implies xsave.


Repository:
  rL LLVM

http://reviews.llvm.org/D17682



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


Re: r256907 - [modules] When a tag type that was imported from a module is referenced via an

2016-03-01 Thread Adrian Prantl via cfe-commits
Hi Richard,

it looks like this commit causes an assertion failure in Sema when mixing PCH 
and modules. The following script is the smallest reproduction I could come up 
with. Could you please have a look?

$ cat ../repro.sh
mkdir -p usr/include
mkdir -p usr/include/bsm
mkdir -p usr/include/netinet
mkdir -p usr/include/netinet6
echo 'module Darwin {
   module in {
  header "netinet/in.h"
  exclude header "netinet6/in6.h"
   }
   umbrella header "bsm/libbsm.h"
}' > usr/include/module.modulemap
echo 'typedef struct __darwin_ucontext ucontext_t;'  > usr/include/bsm/libbsm.h
echo 'struct sockaddr_in6;' >> usr/include/bsm/libbsm.h 
echo '#include ' > usr/include/netinet/in.h 
echo 'struct sockaddr_in6 {};' > usr/include/netinet6/in6.h 

echo '#include ' > prefix.pch
echo '#include 
@interface I {}
+ (void):(struct sockaddr_in6 *)s;
@end
@implementation I 
+ (void):(struct sockaddr_in6*)s {};
@end
struct sockaddr_in6 *f() {}' > test.m

CC=clang

$CC -x objective-c-header -arch x86_64 -fmodules -c prefix.pch -o 
prefix.pch.pch -I. -fmodules-cache-path=cache -isysroot $PWD
$CC -x objective-c -arch x86_64 -fmodules  -c test.m -o test.o -include-pch 
prefix.pch.pch -I. -fmodules-cache-path=cache -isysroot $PWD




sh ../repro.sh 
test.m:4:18: warning: declaration of 'struct sockaddr_in6' will not be visible 
outside of this function [-Wvisibility]
+ (void):(struct sockaddr_in6 *)s;
 ^
test.m:7:18: warning: declaration of 'struct sockaddr_in6' will not be visible 
outside of this function [-Wvisibility]
+ (void):(struct sockaddr_in6*)s {};
 ^
test.m:3:12: warning: class 'I' defined without specifying a base class 
[-Wobjc-root-class]
@interface I {}
   ^
test.m:3:13: note: add a super class to fix this problem
@interface I {}
^
Assertion failed: (I != Vec.end() && "list does not contain decl"), function 
remove, file ../tools/clang/include/clang/AST/DeclContextInternals.h, line 116.
0  clang-3.80x00010ec886ae 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46
1  clang-3.80x00010ec88af9 
PrintStackTraceSignalHandler(void*) + 25
2  clang-3.80x00010ec85299 llvm::sys::RunSignalHandlers() + 
425
3  clang-3.80x00010ec88e59 SignalHandler(int) + 345
4  libsystem_platform.dylib 0x7fff9700a30a _sigtramp + 26
5  clang-3.80x00011273dbf5 guard variable for 
shouldAddRequirement(clang::Module*, llvm::StringRef, bool&)::IOKitAVC + 82405
6  clang-3.80x00010ec88b1b raise + 27
7  clang-3.80x00010ec88bd2 abort + 18
8  clang-3.80x00010ec88bb1 __assert_rtn + 129
9  clang-3.80x000111b8f989 
clang::StoredDeclsList::remove(clang::NamedDecl*) + 537
10 clang-3.80x000111b8b18c 
clang::DeclContext::removeDecl(clang::Decl*) + 1068
11 clang-3.80x000111b5e725 
clang::FunctionDecl::setDeclsInPrototypeScope(llvm::ArrayRef)
 + 677
12 clang-3.80x000110bec4e2 
clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, 
clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, 
llvm::MutableArrayRef, bool&) + 9874
13 clang-3.80x000110be8c93 
clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, 
llvm::MutableArrayRef) + 3379
14 clang-3.80x000110c01e07 
clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Declarator&, 
llvm::MutableArrayRef, 
clang::Sema::SkipBodyInfo*) + 295
15 clang-3.80x0001107362af 
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, 
clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) + 
2303
16 clang-3.80x0001106799f8 
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int, 
clang::SourceLocation*, clang::Parser::ForRangeInit*) + 1048
17 clang-3.80x00011073599b 
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
 clang::ParsingDeclSpec&, clang::AccessSpecifier) + 1163
18 clang-3.80x000110735125 
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
 clang::ParsingDeclSpec*, clang::AccessSpecifier) + 197
19 clang-3.80x0001107348dd 
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
 clang::ParsingDeclSpec*) + 3469
20 clang-3.80x000110733b06 
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&) + 1030
21 clang-3.80x0001106611c5 clang::ParseAST(clang::Sema&, 
bool, bool) + 1013
22 clang-3.80x00010f77408f 
clang::ASTFrontendAction::ExecuteAction() + 511
23 clang-3.80x00010f21de55 
clang::CodeGenAction::ExecuteAction() + 10501
24 clang-3.80x00010f7735f0 clang::FrontendAction::Execute() 
+ 112
25 clang

[PATCH] D17779: [CUDA] Emit host-side 'shadows' for device-side global variables

2016-03-01 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: jlebar, jingyue.
tra added a subscriber: cfe-commits.

.. and register them with CUDA runtime.

This is needed for commonly used cudaMemcpy*() APIs that use address of 
host-side shadow to access their counterparts on device side.

Fixes PR26340.

http://reviews.llvm.org/D17779

Files:
  lib/CodeGen/CGCUDANV.cpp
  lib/CodeGen/CGCUDARuntime.h
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCUDA/device-stub.cu
  test/CodeGenCUDA/filter-decl.cu

Index: test/CodeGenCUDA/filter-decl.cu
===
--- test/CodeGenCUDA/filter-decl.cu
+++ test/CodeGenCUDA/filter-decl.cu
@@ -9,11 +9,11 @@
 // CHECK-DEVICE-NOT: module asm "file scope asm is host only"
 __asm__("file scope asm is host only");
 
-// CHECK-HOST-NOT: constantdata = externally_initialized global
+// CHECK-HOST: constantdata = internal global
 // CHECK-DEVICE: constantdata = externally_initialized global
 __constant__ char constantdata[256];
 
-// CHECK-HOST-NOT: devicedata = externally_initialized global
+// CHECK-HOST: devicedata = internal global
 // CHECK-DEVICE: devicedata = externally_initialized global
 __device__ char devicedata[256];
 
Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -2,6 +2,40 @@
 
 #include "Inputs/cuda.h"
 
+// CHECK-DAG: @device_var = internal global i32
+__device__ int device_var;
+
+// CHECK-DAG: @constant_var = internal global i32
+__constant__ int constant_var;
+
+// CHECK-DAG: @shared_var = internal global i32
+__shared__ int shared_var;
+
+// Make sure host globals don't get internalized..
+// CHECK-DAG: @host_var = global i32
+int host_var;
+// .. and that extern vars remain external.
+// CHECK-DAG: @ext_host_var = external global i32
+extern int ext_host_var;
+
+// Shadows for external device-side variables are *definitions* of
+// those variables.
+// CHECK-DAG: @ext_device_var = internal global i32
+extern __device__ int ext_device_var;
+// CHECK-DAG: @ext_device_var = internal global i32
+extern __constant__ int ext_constant_var;
+
+void use_pointers() {
+  int *p;
+  p = &device_var;
+  p = &constant_var;
+  p = &shared_var;
+  p = &host_var;
+  p = &ext_device_var;
+  p = &ext_constant_var;
+  p = &ext_host_var;
+}
+
 // Make sure that all parts of GPU code init/cleanup are there:
 // * constant unnamed string with the kernel name
 // CHECK: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
@@ -32,18 +66,23 @@
 // CHECK: call{{.*}}kernelfunc
 void hostfunc(void) { kernelfunc<<<1, 1>>>(1, 1, 1); }
 
-// Test that we've built a function to register kernels
-// CHECK: define internal void @__cuda_register_kernels
+// Test that we've built a function to register kernels and global vars.
+// CHECK: define internal void @__cuda_register_globals
 // CHECK: call{{.*}}cudaRegisterFunction(i8** %0, {{.*}}kernelfunc
+// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}device_var{{.*}}i32 0, i32 4, i32 0, i32 0
+// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}constant_var{{.*}}i32 0, i32 4, i32 1, i32 0
+// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_device_var{{.*}}i32 1, i32 4, i32 0, i32 0
+// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_constant_var{{.*}}i32 1, i32 4, i32 1, i32 0
+// CHECK: ret void
 
 // Test that we've built contructor..
 // CHECK: define internal void @__cuda_module_ctor
 //   .. that calls __cudaRegisterFatBinary(&__cuda_fatbin_wrapper)
 // CHECK: call{{.*}}cudaRegisterFatBinary{{.*}}__cuda_fatbin_wrapper
 //   .. stores return value in __cuda_gpubin_handle
 // CHECK-NEXT: store{{.*}}__cuda_gpubin_handle
-//   .. and then calls __cuda_register_kernels
-// CHECK-NEXT: call void @__cuda_register_kernels
+//   .. and then calls __cuda_register_globals
+// CHECK-NEXT: call void @__cuda_register_globals
 
 // Test that we've created destructor.
 // CHECK: define internal void @__cuda_module_dtor
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1528,11 +1528,18 @@
   !Global->hasAttr())
 return;
 } else {
-  if (!Global->hasAttr() && (
-Global->hasAttr() ||
-Global->hasAttr() ||
-Global->hasAttr()))
+  // We need to emit host-side 'shadows' for all global
+  // device-side variables because CUDA runtime API needs their
+  // size and host-side address in order to provide access to
+  // their device-side incarnations.
+
+  // So device-only functions are the only things we skip.
+  if (isa(Global) && !Global->hasAttr() &&
+  Global->hasAttr())
 return;
+
+  assert((isa(Global) || isa(Global)) &&
+ "Expected Variable or Function");
 }
   }
 
@@ -1561,9 +1568,13 @@
   } else {
 const auto *

Re: [PATCH] D17775: Add a few dllimport/dllexport tests. NFC

2016-03-01 Thread Warren Ristow via cfe-commits
wristow added a comment.

In http://reviews.llvm.org/D17775#365611, @silvas wrote:

> Random question:
>
> > We plan to enable dllimport/dllexport support for the PS4
>
>
> How are you planning on codegenning them? The same way as we do in our 
> private branch?


Yes, that's the intention.


http://reviews.llvm.org/D17775



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


Re: [PATCH] D17482: [clang-tidy] Allow tests to verify changes made to header files

2016-03-01 Thread Richard via cfe-commits
LegalizeAdulthood added a comment.

Squeak


http://reviews.llvm.org/D17482



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


Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2016-03-01 Thread Hubert Tong via cfe-commits
hubert.reinterpretcast added inline comments.


Comment at: lib/Sema/SemaOverload.cpp:1658
@@ -1657,1 +1657,3 @@
   } else if (FromType->isRealFloatingType() && ToType->isRealFloatingType()) {
+// FIXME: disable conversions between long double and __float128 if
+// their representation is different until there is back end support

The update to check the case where the representation of `long double` is the 
same as that of `double` is missing.


Comment at: lib/Sema/SemaOverload.cpp:1966-1967
@@ -1955,4 +1965,4 @@
   // C99 6.3.1.5p1:
   //   When a float is promoted to double or long double, or a
   //   double is promoted to long double [...].
   if (!getLangOpts().CPlusPlus &&

@rsmith; this is the discussion on floating-point "promotions" in "C" that I 
was asking you about.


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


[PATCH] D17780: [CUDA] Do not generate unnecessary runtime init code.

2016-03-01 Thread Artem Belevich via cfe-commits
tra created this revision.
tra added reviewers: jlebar, jingyue.
tra added a subscriber: cfe-commits.

Do not generate runtime init code if we don't have anything to init.

http://reviews.llvm.org/D17780

Files:
  lib/CodeGen/CGCUDANV.cpp
  test/CodeGenCUDA/device-stub.cu

Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -1,7 +1,11 @@
 // RUN: %clang_cc1 -emit-llvm %s -fcuda-include-gpubinary %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -emit-llvm %s -fcuda-include-gpubinary %s -o -  -DNOGLOBALS 
\
+// RUN:   | FileCheck %s -check-prefix=NOGLOBALS
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN
 
 #include "Inputs/cuda.h"
 
+#ifndef NOGLOBALS
 // CHECK-DAG: @device_var = internal global i32
 __device__ int device_var;
 
@@ -65,6 +69,7 @@
 // CHECK: call{{.*}}cudaConfigureCall
 // CHECK: call{{.*}}kernelfunc
 void hostfunc(void) { kernelfunc<<<1, 1>>>(1, 1, 1); }
+#endif
 
 // Test that we've built a function to register kernels and global vars.
 // CHECK: define internal void @__cuda_register_globals
@@ -89,3 +94,18 @@
 // CHECK: load{{.*}}__cuda_gpubin_handle
 // CHECK-NEXT: call void @__cudaUnregisterFatBinary
 
+// There should be no __cuda_register_globals if we have no
+// device-side globals, but we still need to register GPU binary.
+// Skip GPU binary string first.
+// NOGLOBALS: @0 = private unnamed_addr constant{{.*}}
+// NOGLOBALS-NOT: define internal void @__cuda_register_globals
+// NOGLOBALS: define internal void @__cuda_module_ctor
+// NOGLOBALS: call{{.*}}cudaRegisterFatBinary{{.*}}__cuda_fatbin_wrapper
+// NOGLOBALS-NOT: call void @__cuda_register_globals
+// NOGLOBALS: define internal void @__cuda_module_dtor
+// NOGLOBALS: call void @__cudaUnregisterFatBinary
+
+// There should be no constructors/destructors if we have no GPU binary.
+// NOGPUBIN-NOT: define internal void @__cuda_register_globals
+// NOGPUBIN-NOT: define internal void @__cuda_module_ctor
+// NOGPUBIN-NOT: define internal void @__cuda_module_dtor
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -177,6 +177,10 @@
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeRegisterGlobalsFn() {
+  // No need to register anything
+  if (EmittedKernels.empty() && DeviceVars.empty())
+return nullptr;
+
   llvm::Function *RegisterKernelsFunc = llvm::Function::Create(
   llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),
   llvm::GlobalValue::InternalLinkage, "__cuda_register_globals", 
&TheModule);
@@ -246,6 +250,10 @@
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
+  // No need to generate ctors/dtors if there are no GPU binaries.
+  if (CGM.getCodeGenOpts().CudaGpuBinaryFileNames.empty())
+return nullptr;
+
   // void __cuda_register_globals(void* handle);
   llvm::Function *RegisterGlobalsFunc = makeRegisterGlobalsFn();
   // void ** __cudaRegisterFatBinary(void *);
@@ -303,8 +311,9 @@
 CtorBuilder.CreateAlignedStore(RegisterFatbinCall, GpuBinaryHandle,
CGM.getPointerAlign());
 
-// Call __cuda_register_globalss(GpuBinaryHandle);
-CtorBuilder.CreateCall(RegisterGlobalsFunc, RegisterFatbinCall);
+// Call __cuda_register_globals(GpuBinaryHandle);
+if (RegisterGlobalsFunc)
+  CtorBuilder.CreateCall(RegisterGlobalsFunc, RegisterFatbinCall);
 
 // Save GpuBinaryHandle so we can unregister it in destructor.
 GpuBinaryHandles.push_back(GpuBinaryHandle);
@@ -324,6 +333,10 @@
 /// }
 /// \endcode
 llvm::Function *CGNVCUDARuntime::makeModuleDtorFunction() {
+  // No need for destructor if we don't have handles to unregister.
+  if (GpuBinaryHandles.empty())
+return nullptr;
+
   // void __cudaUnregisterFatBinary(void ** handle);
   llvm::Constant *UnregisterFatbinFunc = CGM.CreateRuntimeFunction(
   llvm::FunctionType::get(VoidTy, VoidPtrPtrTy, false),


Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -1,7 +1,11 @@
 // RUN: %clang_cc1 -emit-llvm %s -fcuda-include-gpubinary %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -fcuda-include-gpubinary %s -o -  -DNOGLOBALS \
+// RUN:   | FileCheck %s -check-prefix=NOGLOBALS
+// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN
 
 #include "Inputs/cuda.h"
 
+#ifndef NOGLOBALS
 // CHECK-DAG: @device_var = internal global i32
 __device__ int device_var;
 
@@ -65,6 +69,7 @@
 // CHECK: call{{.*}}cudaConfigureCall
 // CHECK: call{{.*}}kernelfunc
 void hostfunc(void) { kernelfunc<<<1, 1>>>(1, 1, 1); }
+#endif
 
 // Test that we've built a function to register kernels and global vars.
 // CHECK: define internal void @__cuda_register_globals
@@

r262402 - [clang-format] Detect constructor initializers preceded by `noexcept`.

2016-03-01 Thread Daniel Jasper via cfe-commits
Author: djasper
Date: Tue Mar  1 15:41:58 2016
New Revision: 262402

URL: http://llvm.org/viewvc/llvm-project?rev=262402&view=rev
Log:
[clang-format] Detect constructor initializers preceded by `noexcept`.

Patch by Erik Kessler, thank you.

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=262402&r1=262401&r2=262402&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Mar  1 15:41:58 2016
@@ -505,7 +505,7 @@ private:
 Tok->Type = TT_BitFieldColon;
   } else if (Contexts.size() == 1 &&
  !Line.First->isOneOf(tok::kw_enum, tok::kw_case)) {
-if (Tok->Previous->is(tok::r_paren))
+if (Tok->Previous->isOneOf(tok::r_paren, tok::kw_noexcept))
   Tok->Type = TT_CtorInitializerColon;
 else
   Tok->Type = TT_InheritanceColon;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=262402&r1=262401&r2=262402&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Mar  1 15:41:58 2016
@@ -10389,6 +10389,9 @@ TEST_F(FormatTest, BreakConstructorIniti
   verifyFormat("SomeClass::Constructor()\n"
": a(a) {}",
Style);
+  verifyFormat("SomeClass::Constructor() noexcept\n"
+   ": a(a) {}",
+   Style);
   verifyFormat("SomeClass::Constructor()\n"
": a(a)\n"
", b(b)\n"


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


Re: [PATCH] D17695: clang-cl: Implement initial limited support for precompiled headers.

2016-03-01 Thread Nico Weber via cfe-commits
thakis updated the summary for this revision.
thakis updated this revision to Diff 49541.
thakis marked 5 inline comments as done.
thakis added a comment.

- rebase across jlebar's r261774 => implicit_inputs gone, ForceSuccessCommand 
is new
- .h file is found relative to include paths => introduce -find-pch-source= cc1 
flag to handle that
- turns out several important things (`#pragma comment(lib...)`) aren't 
serialized yet => put this behind -internal-enable-pch for now so we can 
improve on this feature in-tree (and once it's ready that flag will go away 
again)
- address view comments


http://reviews.llvm.org/D17695

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Driver/CC1Options.td
  include/clang/Driver/CLCompatOptions.td
  include/clang/Driver/Driver.h
  include/clang/Driver/Job.h
  include/clang/Frontend/CompilerInstance.h
  include/clang/Frontend/FrontendOptions.h
  lib/Driver/Driver.cpp
  lib/Driver/Job.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/Inputs/pchfile.cpp
  test/Driver/Inputs/pchfile.h
  test/Driver/cl-pch.c
  test/Driver/cl-pch.cpp

Index: test/Driver/cl-pch.cpp
===
--- test/Driver/cl-pch.cpp
+++ test/Driver/cl-pch.cpp
@@ -0,0 +1,309 @@
+// Note: %s and %S must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
+// /Yc
+// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC %s
+// 1. Build .pch file.
+// CHECK-YC: cc1
+// CHECK-YC: -emit-pch
+// CHECK-YC: -o
+// CHECK-YC: pchfile.pch
+// CHECK-YC: -x
+// CHECK-YC: "c++"
+// 2. Use .pch file.
+// CHECK-YC: cc1
+// CHECK-YC: -emit-obj
+// CHECK-YC: -include-pch
+// CHECK-YC: pchfile.pch
+
+// /Yc /Fo
+// /Fo overrides the .obj output filename, but not the .pch filename
+// RUN: %clang_cl -internal-enable-pch -Werror /Fomyobj.obj /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YCO %s
+// 1. Build .pch file.
+// CHECK-YCO: cc1
+// CHECK-YCO: -emit-pch
+// CHECK-YCO: -o
+// CHECK-YCO: pchfile.pch
+// 2. Use .pch file.
+// CHECK-YCO: cc1
+// CHECK-YCO: -emit-obj
+// CHECK-YCO: -include-pch
+// CHECK-YCO: pchfile.pch
+// CHECK-YCO: -o
+// CHECK-YCO: myobj.obj
+
+// /Yc /Y-
+// /Y- disables pch generation
+// RUN: %clang_cl -internal-enable-pch -Werror /Y- /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-Y_ %s
+// CHECK-YC-Y_-NOT: -emit-pch
+// CHECK-YC-Y_-NOT: -include-pch
+
+// /Yu
+// RUN: %clang_cl -internal-enable-pch -Werror /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YU %s
+// Use .pch file, but don't build it.
+// CHECK-YU-NOT: -emit-pch
+// CHECK-YU: cc1
+// CHECK-YU: -emit-obj
+// CHECK-YU: -include-pch
+// CHECK-YU: pchfile.pch
+
+// /Yu /Y-
+// RUN: %clang_cl -internal-enable-pch -Werror /Y- /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YU-Y_ %s
+// CHECK-YU-Y_-NOT: -emit-pch
+// CHECK-YU-Y_-NOT: -include-pch
+
+// /Yc /Yu -- /Yc overrides /Yc if they both refer to the same file
+// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-YU %s
+// 1. Build .pch file.
+// CHECK-YC-YU: cc1
+// CHECK-YC-YU: -emit-pch
+// CHECK-YC-YU: -o
+// CHECK-YC-YU: pchfile.pch
+// 2. Use .pch file.
+// CHECK-YC-YU: cc1
+// CHECK-YC-YU: -emit-obj
+// CHECK-YC-YU: -include-pch
+// CHECK-YC-YU: pchfile.pch
+
+// If /Yc /Yu refer to different files, semantics are pretty wonky.  Since this
+// doesn't seem like something that's important in practice, just punt for now.
+// RUN: %clang_cl -internal-enable-pch -Werror /Ycfoo1.h /Yufoo2.h /FIfoo1.h /FIfoo2.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-YU-MISMATCH %s
+// CHECK-YC-YU-MISMATCH: error: support for '/Yc' and '/Yu' with different filenames not implemented yet; flags ignored
+
+// Similarly, punt on /Yc with more than one input file.
+// RUN: %clang_cl -internal-enable-pch -Werror /Ycfoo1.h /FIfoo1.h /c -### -- %s %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-MULTIINPUT %s
+// CHECK-YC-MULTIINPUT: error: support for '/Yc' with more than one source file not implemented yet; flag ignored
+
+// /Yc /Yu /Y-
+// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /Y- /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-YU-Y_ %s
+// CHECK-YC-YU-Y_-NOT: -emit-pch
+// CHECK-YC-YU-Y_-NOT: -include-pch
+
+// Test computation of pch filename in various cases.
+
+// /Yu /Fpout.pch => out.pch is filename
+// RUN: %clang_cl -internal-enable-pch -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&

Re: [PATCH] D17621: [clang-format] Detect constructor initializers preceded by `noexcept`.

2016-03-01 Thread Daniel Jasper via cfe-commits
djasper closed this revision.
djasper added a comment.

Submitted as r262402. Thank you.


http://reviews.llvm.org/D17621



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


Re: [PATCH] D17695: clang-cl: Implement initial limited support for precompiled headers.

2016-03-01 Thread Nico Weber via cfe-commits
thakis added inline comments.


Comment at: lib/Driver/Driver.cpp:2355
@@ +2354,3 @@
+
+// Add pch if needed: "If you do not specify an extension as part of the
+// path name, an extension of .pch is assumed. "

hans wrote:
> Maybe add .pch if needed?
It already does this in the next line (?)


Comment at: lib/Driver/Tools.cpp:431
@@ +430,3 @@
+  if (AI >= YcIndex)
+continue;
+} else {

hans wrote:
> I got confused here, because even if we don't "continue", we still won't hit 
> the else if (A->getOption().matches(options::OPT_include)) branch below.
> 
> But that branch is just dealing with implicit includes, we will still do the 
> "Not translated, render as usual." step.
> 
> Maybe add a comment to the "else if" branch below that that code is for 
> non-CL style PCH includes?
Done I think, but I'm not sure I understood correctly what you were asking for.


http://reviews.llvm.org/D17695



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


Re: [PATCH] D17695: clang-cl: Implement initial limited support for precompiled headers.

2016-03-01 Thread Nico Weber via cfe-commits
thakis updated this revision to Diff 49544.
thakis added a comment.

forgot to `svn add` two new test files


http://reviews.llvm.org/D17695

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Driver/CC1Options.td
  include/clang/Driver/CLCompatOptions.td
  include/clang/Driver/Driver.h
  include/clang/Driver/Job.h
  include/clang/Frontend/CompilerInstance.h
  include/clang/Frontend/FrontendOptions.h
  lib/Driver/Driver.cpp
  lib/Driver/Job.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/Inputs/pchfile.cpp
  test/Driver/Inputs/pchfile.h
  test/Driver/cl-pch-errorhandling.cpp
  test/Driver/cl-pch-search.cpp
  test/Driver/cl-pch.c
  test/Driver/cl-pch.cpp

Index: test/Driver/cl-pch.cpp
===
--- test/Driver/cl-pch.cpp
+++ test/Driver/cl-pch.cpp
@@ -0,0 +1,309 @@
+// Note: %s and %S must be preceded by --, otherwise it may be interpreted as a
+// command-line option, e.g. on Mac where %s is commonly under /Users.
+
+// /Yc
+// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC %s
+// 1. Build .pch file.
+// CHECK-YC: cc1
+// CHECK-YC: -emit-pch
+// CHECK-YC: -o
+// CHECK-YC: pchfile.pch
+// CHECK-YC: -x
+// CHECK-YC: "c++"
+// 2. Use .pch file.
+// CHECK-YC: cc1
+// CHECK-YC: -emit-obj
+// CHECK-YC: -include-pch
+// CHECK-YC: pchfile.pch
+
+// /Yc /Fo
+// /Fo overrides the .obj output filename, but not the .pch filename
+// RUN: %clang_cl -internal-enable-pch -Werror /Fomyobj.obj /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YCO %s
+// 1. Build .pch file.
+// CHECK-YCO: cc1
+// CHECK-YCO: -emit-pch
+// CHECK-YCO: -o
+// CHECK-YCO: pchfile.pch
+// 2. Use .pch file.
+// CHECK-YCO: cc1
+// CHECK-YCO: -emit-obj
+// CHECK-YCO: -include-pch
+// CHECK-YCO: pchfile.pch
+// CHECK-YCO: -o
+// CHECK-YCO: myobj.obj
+
+// /Yc /Y-
+// /Y- disables pch generation
+// RUN: %clang_cl -internal-enable-pch -Werror /Y- /Ycpchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-Y_ %s
+// CHECK-YC-Y_-NOT: -emit-pch
+// CHECK-YC-Y_-NOT: -include-pch
+
+// /Yu
+// RUN: %clang_cl -internal-enable-pch -Werror /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YU %s
+// Use .pch file, but don't build it.
+// CHECK-YU-NOT: -emit-pch
+// CHECK-YU: cc1
+// CHECK-YU: -emit-obj
+// CHECK-YU: -include-pch
+// CHECK-YU: pchfile.pch
+
+// /Yu /Y-
+// RUN: %clang_cl -internal-enable-pch -Werror /Y- /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YU-Y_ %s
+// CHECK-YU-Y_-NOT: -emit-pch
+// CHECK-YU-Y_-NOT: -include-pch
+
+// /Yc /Yu -- /Yc overrides /Yc if they both refer to the same file
+// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-YU %s
+// 1. Build .pch file.
+// CHECK-YC-YU: cc1
+// CHECK-YC-YU: -emit-pch
+// CHECK-YC-YU: -o
+// CHECK-YC-YU: pchfile.pch
+// 2. Use .pch file.
+// CHECK-YC-YU: cc1
+// CHECK-YC-YU: -emit-obj
+// CHECK-YC-YU: -include-pch
+// CHECK-YC-YU: pchfile.pch
+
+// If /Yc /Yu refer to different files, semantics are pretty wonky.  Since this
+// doesn't seem like something that's important in practice, just punt for now.
+// RUN: %clang_cl -internal-enable-pch -Werror /Ycfoo1.h /Yufoo2.h /FIfoo1.h /FIfoo2.h /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-YU-MISMATCH %s
+// CHECK-YC-YU-MISMATCH: error: support for '/Yc' and '/Yu' with different filenames not implemented yet; flags ignored
+
+// Similarly, punt on /Yc with more than one input file.
+// RUN: %clang_cl -internal-enable-pch -Werror /Ycfoo1.h /FIfoo1.h /c -### -- %s %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-MULTIINPUT %s
+// CHECK-YC-MULTIINPUT: error: support for '/Yc' with more than one source file not implemented yet; flag ignored
+
+// /Yc /Yu /Y-
+// RUN: %clang_cl -internal-enable-pch -Werror /Ycpchfile.h /Yupchfile.h /FIpchfile.h /Y- /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YC-YU-Y_ %s
+// CHECK-YC-YU-Y_-NOT: -emit-pch
+// CHECK-YC-YU-Y_-NOT: -include-pch
+
+// Test computation of pch filename in various cases.
+
+// /Yu /Fpout.pch => out.pch is filename
+// RUN: %clang_cl -internal-enable-pch -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YUFP1 %s
+// Use .pch file, but don't build it.
+// CHECK-YUFP1: -include-pch
+// CHECK-YUFP1: out.pch
+
+// /Yu /Fpout => out.pch is filename (.pch gets added if no extension present)
+// RUN: %clang_cl -internal-enable-pch -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-YUFP2 %s
+// Use .pch file, but don't 

r262409 - Explicitly select IAS on one more RUN line in new embed-bitcode.c test.

2016-03-01 Thread Daniel Sanders via cfe-commits
Author: dsanders
Date: Tue Mar  1 15:57:22 2016
New Revision: 262409

URL: http://llvm.org/viewvc/llvm-project?rev=262409&view=rev
Log:
Explicitly select IAS on one more RUN line in new embed-bitcode.c test.

This should fix clang-cmake-mips builder since MIPS does not have IAS enabled
by default (yet).

Modified:
cfe/trunk/test/Driver/embed-bitcode.c

Modified: cfe/trunk/test/Driver/embed-bitcode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/embed-bitcode.c?rev=262409&r1=262408&r2=262409&view=diff
==
--- cfe/trunk/test/Driver/embed-bitcode.c (original)
+++ cfe/trunk/test/Driver/embed-bitcode.c Tue Mar  1 15:57:22 2016
@@ -9,7 +9,7 @@
 // CHECK-CC: -emit-obj
 // CHECK-CC: -fembed-bitcode
 
-// RUN: %clang %s -c -save-temps -fembed-bitcode 2>&1 -### | FileCheck %s 
-check-prefix=CHECK-SAVE-TEMP
+// RUN: %clang %s -c -save-temps -fembed-bitcode -fintegrated-as 2>&1 -### | 
FileCheck %s -check-prefix=CHECK-SAVE-TEMP
 // CHECK-SAVE-TEMP: -cc1
 // CHECK-SAVE-TEMP: -E
 // CHECK-SAVE-TEMP: -cc1


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


RE: r262282 - Introduce -fembed-bitcode driver option

2016-03-01 Thread Daniel Sanders via cfe-commits
No problem.

It seems I missed one of the relevant RUN lines on the first attempt. I've 
fixed that in r262409. 

From: steve...@apple.com [steve...@apple.com]
Sent: 01 March 2016 17:26
To: Daniel Sanders
Cc: cfe-commits@lists.llvm.org
Subject: Re: r262282 - Introduce -fembed-bitcode driver option

Great. Thanks for the fix.

Steven

> On Mar 1, 2016, at 9:24 AM, Daniel Sanders  wrote:
>
> Hi,
>
> I've made a small change to the test case in r262350 to fix the 
> clang-cmake-mips builder. MIPS doesn't
> enable the integrated assembler by default yet so it was failing to find the 
> -emit-obj option. I've fixed this by adding -fintegrated-as.
>
> 
> From: cfe-commits [cfe-commits-boun...@lists.llvm.org] on behalf of Steven Wu 
> via cfe-commits [cfe-commits@lists.llvm.org]
> Sent: 01 March 2016 01:07
> To: cfe-commits@lists.llvm.org
> Subject: r262282 - Introduce -fembed-bitcode driver option
>
> Author: steven_wu
> Date: Mon Feb 29 19:07:58 2016
> New Revision: 262282
>
> URL: http://llvm.org/viewvc/llvm-project?rev=262282&view=rev
> Log:
> Introduce -fembed-bitcode driver option
>
> Summary:
> This is the clang driver part of the change to embedded bitcode. This
> includes:
> 1. -fembed-bitcode option which breaks down the compilation into two
> stages. The first stage emits optimized bitcode and the second stage
> compiles bitcode into object file.
> 2. -fembed-bitcode-marker option which doesn't really break down to
> two stages to speedup the compilation flow.
> 3. pass the correct linker flag to darwin linker if tool chains supports
> embedded bitcode.
>
> Reviewers: rsmith, thakis
>
> Subscribers: thakis, cfe-commits
>
> Differential Revision: http://reviews.llvm.org/D17390
>
> Added:
>cfe/trunk/test/Driver/embed-bitcode.c
> Modified:
>cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
>cfe/trunk/include/clang/Driver/Driver.h
>cfe/trunk/include/clang/Driver/Options.td
>cfe/trunk/include/clang/Driver/ToolChain.h
>cfe/trunk/lib/Driver/Driver.cpp
>cfe/trunk/lib/Driver/ToolChains.cpp
>cfe/trunk/lib/Driver/ToolChains.h
>cfe/trunk/lib/Driver/Tools.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=262282&r1=262281&r2=262282&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Feb 29 
> 19:07:58 2016
> @@ -134,7 +134,9 @@ def err_drv_omp_host_ir_file_not_found :
>   "The provided host compiler IR file '%0' is required to generate code for 
> OpenMP target regions but cannot be found.">;
> def err_drv_omp_host_target_not_supported : Error<
>   "The target '%0' is not a supported OpenMP host target.">;
> -
> +def err_drv_bitcode_unsupported_on_toolchain : Error<
> +  "-fembed-bitcode is not supported on versions of iOS prior to 6.0">;
> +
> def warn_O4_is_O3 : Warning<"-O4 is equivalent to -O3">, InGroup;
> def warn_drv_lto_libpath : Warning<"libLTO.dylib relative to clang installed 
> dir not found; using 'ld' default search path instead">,
>   InGroup;
>
> Modified: cfe/trunk/include/clang/Driver/Driver.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=262282&r1=262281&r2=262282&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Driver.h (original)
> +++ cfe/trunk/include/clang/Driver/Driver.h Mon Feb 29 19:07:58 2016
> @@ -83,6 +83,12 @@ class Driver {
> SaveTempsObj
>   } SaveTemps;
>
> +  enum BitcodeEmbedMode {
> +EmbedNone,
> +EmbedMarker,
> +EmbedBitcode
> +  } BitcodeEmbed;
> +
>   /// LTO mode selected via -f(no-)?lto(=.*)? options.
>   LTOKind LTOMode;
>
> @@ -262,6 +268,9 @@ public:
>   bool isSaveTempsEnabled() const { return SaveTemps != SaveTempsNone; }
>   bool isSaveTempsObj() const { return SaveTemps == SaveTempsObj; }
>
> +  bool embedBitcodeEnabled() const { return BitcodeEmbed == EmbedBitcode; }
> +  bool embedBitcodeMarkerOnly() const { return BitcodeEmbed == EmbedMarker; }
> +
>   /// @}
>   /// @name Primary Functionality
>   /// @{
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=262282&r1=262281&r2=262282&view=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Mon Feb 29 19:07:58 2016
> @@ -437,6 +437,12 @@ def fno_autolink : Flag <["-"], "fno-aut
>   Flags<[DriverOption, CC1Option]>,
>   HelpText<"Disable generation of linker directives for automatic library 
> linking">;
>
> +def fembed_bitcode : Fl

Re: [PATCH] D17775: Add a few dllimport/dllexport tests. NFC

2016-03-01 Thread Sean Silva via cfe-commits
On Tue, Mar 1, 2016 at 1:00 PM, Warren Ristow <
warren_ris...@playstation.sony.com> wrote:

> wristow added a comment.
>
> In http://reviews.llvm.org/D17775#365611, @silvas wrote:
>
> > Random question:
> >
> > > We plan to enable dllimport/dllexport support for the PS4
> >
> >
> > How are you planning on codegenning them? The same way as we do in our
> private branch?
>
>
> Yes, that's the intention.
>

Glad to hear that the upstream compiler will gain this capability!

-- Sean Silva


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


Re: [PATCH] D17627: Fix false positives for for-loop-analysis warning

2016-03-01 Thread Steven Wu via cfe-commits
steven_wu updated this revision to Diff 49549.
steven_wu added a comment.

I did some more digging of the issue. It seems ObjCSubscriptRefExpr always
rebuilds and hinds both base and key behind OpaqueValueExpr. See 
ObjCSubscriptOpBuilder::rebuildAndCaptureObject so it looks the AST generated
is intentional. If that is the case, Richard's suggestion is the best fix I
can think about. Update the patch to reflect the suggestion.


http://reviews.llvm.org/D17627

Files:
  lib/Sema/SemaStmt.cpp
  test/SemaObjC/warn-loop-analysis.m

Index: test/SemaObjC/warn-loop-analysis.m
===
--- /dev/null
+++ test/SemaObjC/warn-loop-analysis.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wloop-analysis -verify %s
+// expected-no-diagnostics
+
+@interface MyArray
+- (id)objectAtIndexedSubscript:(unsigned int)idx;
+@end
+
+// Do not warn on objc classes has objectAtIndexedSubscript method.
+MyArray *test;
+void foo()
+{
+  unsigned int i;
+  for (i = 42; i > 0;) // No warnings here
+(void)test[--i];
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1440,6 +1440,18 @@
   FoundDecl = true;
 }
 
+void VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
+  // ObjCSubscriptRefExpr always converts its subexpressions behind OVE.
+  // Look pass OVE in case it has the only reference to Decl.
+  if (auto *OVE = dyn_cast(E->getKeyExpr())) {
+if (Expr *Key = OVE->getSourceExpr())
+  Visit(Key);
+  } else
+Visit(E->getKeyExpr());
+
+  Visit(E->getBaseExpr());
+}
+
 bool FoundDeclInUse() { return FoundDecl; }
 
   };  // end class DeclMatcher


Index: test/SemaObjC/warn-loop-analysis.m
===
--- /dev/null
+++ test/SemaObjC/warn-loop-analysis.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -Wloop-analysis -verify %s
+// expected-no-diagnostics
+
+@interface MyArray
+- (id)objectAtIndexedSubscript:(unsigned int)idx;
+@end
+
+// Do not warn on objc classes has objectAtIndexedSubscript method.
+MyArray *test;
+void foo()
+{
+  unsigned int i;
+  for (i = 42; i > 0;) // No warnings here
+(void)test[--i];
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -1440,6 +1440,18 @@
   FoundDecl = true;
 }
 
+void VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
+  // ObjCSubscriptRefExpr always converts its subexpressions behind OVE.
+  // Look pass OVE in case it has the only reference to Decl.
+  if (auto *OVE = dyn_cast(E->getKeyExpr())) {
+if (Expr *Key = OVE->getSourceExpr())
+  Visit(Key);
+  } else
+Visit(E->getKeyExpr());
+
+  Visit(E->getBaseExpr());
+}
+
 bool FoundDeclInUse() { return FoundDecl; }
 
   };  // end class DeclMatcher
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262414 - Mangle extended qualifiers in the proper order and mangle the

2016-03-01 Thread John McCall via cfe-commits
Author: rjmccall
Date: Tue Mar  1 16:18:03 2016
New Revision: 262414

URL: http://llvm.org/viewvc/llvm-project?rev=262414&view=rev
Log:
Mangle extended qualifiers in the proper order and mangle the
ARC ownership-convention function type modifications.

According to the Itanium ABI, vendor extended qualifiers are
supposed to be mangled in reverse-alphabetical order before
any CVR qualifiers.  The ARC function type conventions are
plausibly order-significant (they are associated with the
function type), which permits us to ignore the need to correctly
inter-order them with any other vendor qualifiers on the parameter
and return types.

Implementing these rules correctly is technically an ABI break.
Apple is comfortable with the risk of incompatibility here for
the ARC features, and I believe that address-space qualification
is still uncommon enough to allow us to adopt the conforming
rule without serious risk.  Still, targets which make heavy
use of address space qualification may want to revert to the
non-conforming order.

Modified:
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-address-space.cpp
cfe/trunk/test/CodeGenObjCXX/arc-attrs.mm
cfe/trunk/test/CodeGenObjCXX/arc-mangle.mm
cfe/trunk/test/CodeGenObjCXX/arc-move.mm

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=262414&r1=262413&r2=262414&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Tue Mar  1 16:18:03 2016
@@ -364,6 +364,7 @@ private:
   StringRef Prefix = "");
   void mangleOperatorName(DeclarationName Name, unsigned Arity);
   void mangleOperatorName(OverloadedOperatorKind OO, unsigned Arity);
+  void mangleVendorQualifier(StringRef qualifier);
   void mangleQualifiers(Qualifiers Quals);
   void mangleRefQualifier(RefQualifierKind RefQualifier);
 
@@ -377,7 +378,10 @@ private:
 
   void mangleType(const TagType*);
   void mangleType(TemplateName);
-  void mangleBareFunctionType(const FunctionType *T, bool MangleReturnType,
+  static StringRef getCallingConvQualifierName(CallingConv CC);
+  void mangleExtParameterInfo(FunctionProtoType::ExtParameterInfo info);
+  void mangleExtFunctionInfo(const FunctionType *T);
+  void mangleBareFunctionType(const FunctionProtoType *T, bool 
MangleReturnType,
   const FunctionDecl *FD = nullptr);
   void mangleNeonVectorType(const VectorType *T);
   void mangleAArch64NeonVectorType(const VectorType *T);
@@ -523,7 +527,7 @@ void CXXNameMangler::mangleFunctionEncod
 FD = PrimaryTemplate->getTemplatedDecl();
   }
 
-  mangleBareFunctionType(FD->getType()->getAs(), 
+  mangleBareFunctionType(FD->getType()->castAs(),
  MangleReturnType, FD);
 }
 
@@ -1767,14 +1771,9 @@ CXXNameMangler::mangleOperatorName(Overl
 }
 
 void CXXNameMangler::mangleQualifiers(Qualifiers Quals) {
-  //  ::= [r] [V] [K]# restrict (C99), volatile, const
-  if (Quals.hasRestrict())
-Out << 'r';
-  if (Quals.hasVolatile())
-Out << 'V';
-  if (Quals.hasConst())
-Out << 'K';
+  // Vendor qualifiers come first.
 
+  // Address space qualifiers start with an ordinary letter.
   if (Quals.hasAddressSpace()) {
 // Address space extension:
 //
@@ -1802,10 +1801,10 @@ void CXXNameMangler::mangleQualifiers(Qu
   case LangAS::cuda_shared: ASString = "CUshared";   break;
   }
 }
-Out << 'U' << ASString.size() << ASString;
+mangleVendorQualifier(ASString);
   }
-  
-  StringRef LifetimeName;
+
+  // The ARC ownership qualifiers start with underscores.
   switch (Quals.getObjCLifetime()) {
   // Objective-C ARC Extension:
   //
@@ -1816,15 +1815,15 @@ void CXXNameMangler::mangleQualifiers(Qu
 break;
 
   case Qualifiers::OCL_Weak:
-LifetimeName = "__weak";
+mangleVendorQualifier("__weak");
 break;
 
   case Qualifiers::OCL_Strong:
-LifetimeName = "__strong";
+mangleVendorQualifier("__strong");
 break;
 
   case Qualifiers::OCL_Autoreleasing:
-LifetimeName = "__autoreleasing";
+mangleVendorQualifier("__autoreleasing");
 break;
 
   case Qualifiers::OCL_ExplicitNone:
@@ -1837,8 +1836,18 @@ void CXXNameMangler::mangleQualifiers(Qu
 // in any type signatures that need to be mangled.
 break;
   }
-  if (!LifetimeName.empty())
-Out << 'U' << LifetimeName.size() << LifetimeName;
+
+  //  ::= [r] [V] [K]# restrict (C99), volatile, const
+  if (Quals.hasRestrict())
+Out << 'r';
+  if (Quals.hasVolatile())
+Out << 'V';
+  if (Quals.hasConst())
+Out << 'K';
+}
+
+void CXXNameMangler::mangleVendorQualifier(StringRef name) {
+  Out << 'U' << name.size() << name;
 }
 
 void CXXNameMangler::mangleRefQualifier(RefQualifierKind RefQualifier) {
@@ -2137,10 +2146,63 @@ void CXXNameMangler::mangleType(const

Re: [PATCH] D17682: [X86] AMD Bobcat CPU (btver1) doesn't support XSAVE

2016-03-01 Thread Simon Pilgrim via cfe-commits
RKSimon updated this revision to Diff 49552.
RKSimon added a comment.

Thanks - I've removed adding XSAVE to btver2, as long as nobody thinks we need 
to keep it to be explicit?


Repository:
  rL LLVM

http://reviews.llvm.org/D17682

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

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -1474,13 +1474,12 @@
 // CHECK_BTVER1_M32: #define __SSE2__ 1
 // CHECK_BTVER1_M32: #define __SSE3__ 1
 // CHECK_BTVER1_M32: #define __SSE4A__ 1
-// CHECK_BTVER1_M32: #define __SSE_MATH__ 1
-// CHECK_BTVER1_M32: #define __SSE__ 1
-// CHECK_BTVER1_M32: #define __SSSE3__ 1
-// CHECK_BTVER1_M32: #define __XSAVE__ 1
-// CHECK_BTVER1_M32: #define __btver1 1
-// CHECK_BTVER1_M32: #define __btver1__ 1
-// CHECK_BTVER1_M32: #define __i386 1
+// CHECK_BTVER1_M32: #define __SSE_MATH__ 1
+// CHECK_BTVER1_M32: #define __SSE__ 1
+// CHECK_BTVER1_M32: #define __SSSE3__ 1
+// CHECK_BTVER1_M32: #define __btver1 1
+// CHECK_BTVER1_M32: #define __btver1__ 1
+// CHECK_BTVER1_M32: #define __i386 1
 // CHECK_BTVER1_M32: #define __i386__ 1
 // CHECK_BTVER1_M32: #define __tune_btver1__ 1
 // RUN: %clang -march=btver1 -m64 -E -dM %s -o - 2>&1 \
@@ -1496,13 +1495,12 @@
 // CHECK_BTVER1_M64: #define __SSE2__ 1
 // CHECK_BTVER1_M64: #define __SSE3__ 1
 // CHECK_BTVER1_M64: #define __SSE4A__ 1
-// CHECK_BTVER1_M64: #define __SSE_MATH__ 1
-// CHECK_BTVER1_M64: #define __SSE__ 1
-// CHECK_BTVER1_M64: #define __SSSE3__ 1
-// CHECK_BTVER1_M64: #define __XSAVE__ 1
-// CHECK_BTVER1_M64: #define __amd64 1
-// CHECK_BTVER1_M64: #define __amd64__ 1
-// CHECK_BTVER1_M64: #define __btver1 1
+// CHECK_BTVER1_M64: #define __SSE_MATH__ 1
+// CHECK_BTVER1_M64: #define __SSE__ 1
+// CHECK_BTVER1_M64: #define __SSSE3__ 1
+// CHECK_BTVER1_M64: #define __amd64 1
+// CHECK_BTVER1_M64: #define __amd64__ 1
+// CHECK_BTVER1_M64: #define __btver1 1
 // CHECK_BTVER1_M64: #define __btver1__ 1
 // CHECK_BTVER1_M64: #define __tune_btver1__ 1
 // CHECK_BTVER1_M64: #define __x86_64 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2780,7 +2780,6 @@
 setFeatureEnabledImpl(Features, "prfchw", true);
 setFeatureEnabledImpl(Features, "cx16", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
-setFeatureEnabledImpl(Features, "xsave", true);
 break;
   case CK_BDVER4:
 setFeatureEnabledImpl(Features, "avx2", true);


Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -1474,13 +1474,12 @@
 // CHECK_BTVER1_M32: #define __SSE2__ 1
 // CHECK_BTVER1_M32: #define __SSE3__ 1
 // CHECK_BTVER1_M32: #define __SSE4A__ 1
-// CHECK_BTVER1_M32: #define __SSE_MATH__ 1
-// CHECK_BTVER1_M32: #define __SSE__ 1
-// CHECK_BTVER1_M32: #define __SSSE3__ 1
-// CHECK_BTVER1_M32: #define __XSAVE__ 1
-// CHECK_BTVER1_M32: #define __btver1 1
-// CHECK_BTVER1_M32: #define __btver1__ 1
-// CHECK_BTVER1_M32: #define __i386 1
+// CHECK_BTVER1_M32: #define __SSE_MATH__ 1
+// CHECK_BTVER1_M32: #define __SSE__ 1
+// CHECK_BTVER1_M32: #define __SSSE3__ 1
+// CHECK_BTVER1_M32: #define __btver1 1
+// CHECK_BTVER1_M32: #define __btver1__ 1
+// CHECK_BTVER1_M32: #define __i386 1
 // CHECK_BTVER1_M32: #define __i386__ 1
 // CHECK_BTVER1_M32: #define __tune_btver1__ 1
 // RUN: %clang -march=btver1 -m64 -E -dM %s -o - 2>&1 \
@@ -1496,13 +1495,12 @@
 // CHECK_BTVER1_M64: #define __SSE2__ 1
 // CHECK_BTVER1_M64: #define __SSE3__ 1
 // CHECK_BTVER1_M64: #define __SSE4A__ 1
-// CHECK_BTVER1_M64: #define __SSE_MATH__ 1
-// CHECK_BTVER1_M64: #define __SSE__ 1
-// CHECK_BTVER1_M64: #define __SSSE3__ 1
-// CHECK_BTVER1_M64: #define __XSAVE__ 1
-// CHECK_BTVER1_M64: #define __amd64 1
-// CHECK_BTVER1_M64: #define __amd64__ 1
-// CHECK_BTVER1_M64: #define __btver1 1
+// CHECK_BTVER1_M64: #define __SSE_MATH__ 1
+// CHECK_BTVER1_M64: #define __SSE__ 1
+// CHECK_BTVER1_M64: #define __SSSE3__ 1
+// CHECK_BTVER1_M64: #define __amd64 1
+// CHECK_BTVER1_M64: #define __amd64__ 1
+// CHECK_BTVER1_M64: #define __btver1 1
 // CHECK_BTVER1_M64: #define __btver1__ 1
 // CHECK_BTVER1_M64: #define __tune_btver1__ 1
 // CHECK_BTVER1_M64: #define __x86_64 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2780,7 +2780,6 @@
 setFeatureEnabledImpl(Features, "prfchw", true);
 setFeatureEnabledImpl(Features, "cx16", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
-setFeatureEnabledImpl(Features, "xsave", true);
 break;
   case CK_BDVER4:
 setFeatureEnabledImpl(Features, "avx2", true);
___

Re: [PATCH] D17779: [CUDA] Emit host-side 'shadows' for device-side global variables

2016-03-01 Thread Justin Lebar via cfe-commits
jlebar added inline comments.


Comment at: lib/CodeGen/CGCUDANV.cpp:168
@@ -163,1 +167,3 @@
+/// of global scope device-side variables generated in this module
+/// with the CUDA runtime.
 /// \code

This is kind of hard to parse.  How about rephrasing to something like:

Creates a function that sets up state on the host side for CUDA objects that 
have a presence on both the host and device sides.  Specifically, registers the 
host side of kernel functions and __device__ global variables with the CUDA 
runtime.


Comment at: lib/CodeGen/CGCUDANV.cpp:213
@@ +212,3 @@
+  // void __cudaRegisterVar(void **, char *, char *, const char *,
+  //int, int, int, int)
+  std::vector RegisterVarParams = {

Can we say what these args mean?


Comment at: lib/CodeGen/CGCUDANV.cpp:224
@@ +223,3 @@
+llvm::Constant *VarName = makeConstantString(Var->getName());
+llvm::Value *args[] = {
+&GpuBinaryHandlePtr, Builder.CreateBitCast(Var, VoidPtrTy), VarName,

Nit: s/args/Args/?


Comment at: lib/CodeGen/CGCUDANV.cpp:228
@@ +227,3 @@
+llvm::ConstantInt::get(IntTy, CGM.getDataLayout().getTypeAllocSize(
+  Var->getValueType())), // sizeof(var)
+llvm::ConstantInt::get(IntTy, (Flags & DevVarConst) ? 1 : 0),

Nit: Maybe pull this expression out as a separate var?  Then the comment isn't 
needed (would be nice, because at the moment it's ambiguous exactly what 
"sizeof(var)" refers to.


Comment at: lib/CodeGen/CodeGenModule.cpp:1532
@@ +1531,3 @@
+  // We need to emit host-side 'shadows' for all global
+  // device-side variables because CUDA runtime API needs their
+  // size and host-side address in order to provide access to

s/CUDA runtime API/the CUDA runtime/ (not really a requirement of the API, I 
think?)


Comment at: lib/CodeGen/CodeGenModule.cpp:1575
@@ +1574,3 @@
+  // definition, because we still need to define host-side shadow
+  // for it.
+} else if (VD->isThisDeclarationADefinition() != VarDecl::Definition &&

Kind of an odd way of writing this control flow?  Could we phrase it more 
idiomatically as

  MustEmitForCUDA = !VD->hasDefinition() && ...;
  if (!MustEmitForCUDA && ...) return;


Comment at: lib/CodeGen/CodeGenModule.cpp:2477
@@ +2476,3 @@
+  if (D->hasAttr() || D->hasAttr()) {
+Linkage = llvm::GlobalValue::InternalLinkage;
+

Is it worth explaining why the shadows get internal linkage?


Comment at: lib/CodeGen/CodeGenModule.cpp:2480
@@ +2479,3 @@
+// Shadow variables and their properties must be registered
+// with CUDA runtime.
+unsigned Flags = 0;

with the CUDA runtime


Comment at: lib/CodeGen/CodeGenModule.cpp:2483
@@ +2482,3 @@
+if (!D->hasDefinition())
+  Flags |= CGCUDARuntime::DevVarExt;
+if (D->hasAttr())

Now that I see them in context, I think these flags would be a lot easier to 
handle if they employed less abbreviation.  "ExternalDeviceVar", 
"ConstDeviceVar"?


Comment at: test/CodeGenCUDA/device-stub.cu:14
@@ +13,3 @@
+
+// Make sure host globals don't get internalized..
+// CHECK-DAG: @host_var = global i32

Not sure if this is a typo or if you mean "...".


Comment at: test/CodeGenCUDA/device-stub.cu:17
@@ +16,3 @@
+int host_var;
+// .. and that extern vars remain external.
+// CHECK-DAG: @ext_host_var = external global i32

Here you do seem to mean "..."


http://reviews.llvm.org/D17779



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


r262418 - Updated SSE41 builtin tests to more closely match the llvm fast-isel equivalent tests

2016-03-01 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Mar  1 16:38:33 2016
New Revision: 262418

URL: http://llvm.org/viewvc/llvm-project?rev=262418&view=rev
Log:
Updated SSE41 builtin tests to more closely match the llvm fast-isel equivalent 
tests

Modified:
cfe/trunk/test/CodeGen/sse41-builtins.c

Modified: cfe/trunk/test/CodeGen/sse41-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sse41-builtins.c?rev=262418&r1=262417&r2=262418&view=diff
==
--- cfe/trunk/test/CodeGen/sse41-builtins.c (original)
+++ cfe/trunk/test/CodeGen/sse41-builtins.c Tue Mar  1 16:38:33 2016
@@ -6,6 +6,8 @@
 
 #include 
 
+// NOTE: This should match the tests in 
llvm/test/CodeGen/X86/sse41-intrinsics-fast-isel.ll
+
 __m128i test_mm_blend_epi16(__m128i V1, __m128i V2) {
   // CHECK-LABEL: test_mm_blend_epi16
   // CHECK: shufflevector <8 x i16> %{{.*}}, <8 x i16> %{{.*}}, <8 x i32> 
@@ -26,84 +28,91 @@ __m128 test_mm_blend_ps(__m128 V1, __m12
 
 __m128i test_mm_blendv_epi8(__m128i V1, __m128i V2, __m128i V3) {
   // CHECK-LABEL: test_mm_blendv_epi8
-  // CHECK: call <16 x i8> @llvm.x86.sse41.pblendvb
+  // CHECK: call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %{{.*}}, <16 x 
i8> %{{.*}}, <16 x i8> %{{.*}})
   return _mm_blendv_epi8(V1, V2, V3);
 }
 
 __m128d test_mm_blendv_pd(__m128d V1, __m128d V2, __m128d V3) {
   // CHECK-LABEL: test_mm_blendv_pd
-  // CHECK: call <2 x double> @llvm.x86.sse41.blendvpd
+  // CHECK: call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %{{.*}}, 
<2 x double> %{{.*}}, <2 x double> %{{.*}})
   return _mm_blendv_pd(V1, V2, V3);
 }
 
 __m128 test_mm_blendv_ps(__m128 V1, __m128 V2, __m128 V3) {
   // CHECK-LABEL: test_mm_blendv_ps
-  // CHECK: call <4 x float> @llvm.x86.sse41.blendvps
+  // CHECK: call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> %{{.*}}, <4 
x float> %{{.*}}, <4 x float> %{{.*}})
   return _mm_blendv_ps(V1, V2, V3);
 }
 
 __m128d test_mm_ceil_pd(__m128d x) {
   // CHECK-LABEL: test_mm_ceil_pd
-  // CHECK: call <2 x double> @llvm.x86.sse41.round.pd
+  // CHECK: call <2 x double> @llvm.x86.sse41.round.pd(<2 x double> %{{.*}}, 
i32 2)
   return _mm_ceil_pd(x);
 }
 
 __m128 test_mm_ceil_ps(__m128 x) {
   // CHECK-LABEL: test_mm_ceil_ps
-  // CHECK: call <4 x float> @llvm.x86.sse41.round.ps
+  // CHECK: call <4 x float> @llvm.x86.sse41.round.ps(<4 x float> %{{.*}}, i32 
2)
   return _mm_ceil_ps(x);
 }
 
 __m128d test_mm_ceil_sd(__m128d x, __m128d y) {
   // CHECK-LABEL: test_mm_ceil_sd
-  // CHECK: call <2 x double> @llvm.x86.sse41.round.sd
+  // CHECK: call <2 x double> @llvm.x86.sse41.round.sd(<2 x double> %{{.*}}, 
<2 x double> %{{.*}}, i32 2)
   return _mm_ceil_sd(x, y);
 }
 
 __m128 test_mm_ceil_ss(__m128 x, __m128 y) {
   // CHECK-LABEL: test_mm_ceil_ss
-  // CHECK: call <4 x float> @llvm.x86.sse41.round.ss
+  // CHECK: call <4 x float> @llvm.x86.sse41.round.ss(<4 x float> %{{.*}}, <4 
x float> %{{.*}}, i32 2)
   return _mm_ceil_ss(x, y);
 }
 
 __m128i test_mm_cmpeq_epi64(__m128i A, __m128i B) {
   // CHECK-LABEL: test_mm_cmpeq_epi64
   // CHECK: icmp eq <2 x i64>
+  // CHECK: sext <2 x i1> %{{.*}} to <2 x i64>
   return _mm_cmpeq_epi64(A, B);
 }
 
 __m128i test_mm_cvtepi8_epi16(__m128i a) {
   // CHECK-LABEL: test_mm_cvtepi8_epi16
+  // CHECK: shufflevector <16 x i8> {{.*}}, <16 x i8> {{.*}}, <8 x i32> 
   // CHECK: sext <8 x i8> {{.*}} to <8 x i16>
   return _mm_cvtepi8_epi16(a);
 }
 
 __m128i test_mm_cvtepi8_epi32(__m128i a) {
   // CHECK-LABEL: test_mm_cvtepi8_epi32
+  // CHECK: shufflevector <16 x i8> {{.*}}, <16 x i8> {{.*}}, <4 x i32> 
   // CHECK: sext <4 x i8> {{.*}} to <4 x i32>
   return _mm_cvtepi8_epi32(a);
 }
 
 __m128i test_mm_cvtepi8_epi64(__m128i a) {
   // CHECK-LABEL: test_mm_cvtepi8_epi64
+  // CHECK: shufflevector <16 x i8> {{.*}}, <16 x i8> {{.*}}, <2 x i32> 
   // CHECK: sext <2 x i8> {{.*}} to <2 x i64>
   return _mm_cvtepi8_epi64(a);
 }
 
 __m128i test_mm_cvtepi16_epi32(__m128i a) {
   // CHECK-LABEL: test_mm_cvtepi16_epi32
+  // CHECK: shufflevector <8 x i16> {{.*}}, <8 x i16> {{.*}}, <4 x i32> 
   // CHECK: sext <4 x i16> {{.*}} to <4 x i32>
   return _mm_cvtepi16_epi32(a);
 }
 
 __m128i test_mm_cvtepi16_epi64(__m128i a) {
   // CHECK-LABEL: test_mm_cvtepi16_epi64
+  // CHECK: shufflevector <8 x i16> {{.*}}, <8 x i16> {{.*}}, <2 x i32> 
   // CHECK: sext <2 x i16> {{.*}} to <2 x i64>
   return _mm_cvtepi16_epi64(a);
 }
 
 __m128i test_mm_cvtepi32_epi64(__m128i a) {
   // CHECK-LABEL: test_mm_cvtepi32_epi64
+  // CHECK: shufflevector <4 x i32> {{.*}}, <4 x i32> {{.*}}, <2 x i32> 
   // CHECK: sext <2 x i32> {{.*}} to <2 x i64>
   return _mm_cvtepi32_epi64(a);
 }
@@ -159,6 +168,7 @@ __m128 test_mm_dp_ps(__m128 x, __m128 y)
 int test_mm_extract_epi8(__m128i x) {
   // CHECK-LABEL: test_mm_extract_epi8
   // CHECK: extractelement <16 x i8> %{{.*}}, i32 0
+  // CHECK: zext i8 %{{.*}} to i32
   return _mm_extract_epi8(x, 16);
 }
 
@@ -175,31 +185,31 @@ long long test_mm_extr

[PATCH] D17784: Check if LLVM_PREFIX is defined before using it.

2016-03-01 Thread Chaoren Lin via cfe-commits
chaoren created this revision.
chaoren added reviewers: kparzysz, bkramer.
chaoren added a subscriber: cfe-commits.

LLVM_PREFIX could be undefined if CMAKE_INSTALL_PREFIX were set to empty.

http://reviews.llvm.org/D17784

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -2607,9 +2607,11 @@
   if (getVFS().exists(InstallRelDir = InstalledDir + "/../target"))
 return InstallRelDir;
 
+#ifdef LLVM_PREFIX
   std::string PrefixRelDir = std::string(LLVM_PREFIX) + "/target";
   if (getVFS().exists(PrefixRelDir))
 return PrefixRelDir;
+#endif
 
   return InstallRelDir;
 }


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -2607,9 +2607,11 @@
   if (getVFS().exists(InstallRelDir = InstalledDir + "/../target"))
 return InstallRelDir;
 
+#ifdef LLVM_PREFIX
   std::string PrefixRelDir = std::string(LLVM_PREFIX) + "/target";
   if (getVFS().exists(PrefixRelDir))
 return PrefixRelDir;
+#endif
 
   return InstallRelDir;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17695: clang-cl: Implement initial limited support for precompiled headers.

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

lgtm2



Comment at: include/clang/Driver/Job.h:142
@@ +141,3 @@
+/// Like Command, but always pretends that the wrapped command succeeded.
+/// the primary command crashes.
+class ForceSuccessCommand : public Command {

The second sentence looks weird.


Comment at: lib/Driver/Driver.cpp:2369
@@ +2368,3 @@
+
+// Add pch if needed: "If you do not specify an extension as part of the
+// path name, an extension of .pch is assumed. "

Not a big deal, I just meant the comment would make it more obvious that it's 
about adding a pch *extension* to the filename if it says ".pch" instead of 
"pch". I know it becomes obvious later, but then my brain had already asked 
"what do you mean 'add pch'"?



Comment at: lib/Driver/Tools.cpp:438
@@ +437,3 @@
+  if (AI >= YcIndex)
+continue;
+} else {

You got it.


Comment at: lib/Frontend/CompilerInstance.cpp:746
@@ +745,3 @@
+  File = FileMgr.getFile(InputFile, /*OpenFile=*/true);
+} else {
+  const FileEntry *FindFile = FileMgr.getFile(Opts.FindPchSource);

Maybe add a comment about this FindPchSource mode


http://reviews.llvm.org/D17695



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


Re: [PATCH] D17695: clang-cl: Implement initial limited support for precompiled headers.

2016-03-01 Thread Nico Weber via cfe-commits
thakis closed this revision.
thakis marked 3 inline comments as done.
thakis added a comment.

r262420, thanks!


http://reviews.llvm.org/D17695



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


r262420 - clang-cl: Implement initial limited support for precompiled headers.

2016-03-01 Thread Nico Weber via cfe-commits
Author: nico
Date: Tue Mar  1 17:16:44 2016
New Revision: 262420

URL: http://llvm.org/viewvc/llvm-project?rev=262420&view=rev
Log:
clang-cl: Implement initial limited support for precompiled headers.

In the gcc precompiled header model, one explicitly runs clang with `-x
c++-header` on a .h file to produce a gch file, and then includes the header
with `-include foo.h` and if a .gch file exists for that header it gets used.
This is documented at
http://clang.llvm.org/docs/UsersManual.html#precompiled-headers

cl.exe's model is fairly different, and controlled by the two flags /Yc and
/Yu. A pch file is generated as a side effect of a regular compilation when
/Ycheader.h is passed. While the compilation is running, the compiler keeps
track of #include lines in the main translation unit and writes everything up
to an `#include "header.h"` line into a pch file. Conversely, /Yuheader.h tells
the compiler to skip all code in the main TU up to and including `#include
"header.h"` and instead load header.pch. (It's also possible to use /Yc and /Yu
without an argument, in that case a `#pragma hrdstop` takes the role of
controlling the point where pch ends and real code begins.)

This patch implements limited support for this in that it requires the pch
header to be passed as a /FI force include flag – with this restriction,
it can be implemented almost completely in the driver with fairly small amounts
of code. For /Yu, this is trivial, and for /Yc a separate pch action is added
that runs before the actual compilation. After r261774, the first failing
command makes a compilation stop – this means if the pch fails to build the
main compilation won't run, which is what we want. However, in /fallback builds
we need to run the main compilation even if the pch build fails so that the
main compilation's fallback can run. To achieve this, add a ForceSuccessCommand
that pretends that the pch build always succeeded in /fallback builds (the main
compilation will then fail to open the pch and run the fallback cl.exe
invocation).

If /Yc /Yu are used in a setup that clang-cl doesn't implement yet, clang-cl
will now emit a "not implemented yet; flag ignored" warning that can be
disabled using -Wno-clang-cl-pch.

Since clang-cl doesn't yet serialize some important things (most notably
`pragma comment(lib, ...)`, this feature is disabled by default and only
enabled by an internal driver flag. Once it's more stable, this internal flag
will disappear.

(The default stdafx.h setup passes stdafx.h as explicit argument to /Yc but not
as /FI – instead every single TU has to `#include ` as first thing it
does. Implementing support for this should be possible with the approach in
this patch with minimal frontend changes by passing a --stop-at / --start-at
flag from the driver to the frontend. This is left for a follow-up. I don't
think we ever want to support `#pragma hdrstop`, and supporting it with this
approach isn't easy: This approach relies on the driver knowing the pch
filename in advance, and `#pragma hdrstop(out.pch)` can set the output
filename, so the driver can't know about it in advance.)

clang-cl now also honors /Fp and puts pch files in the same spot that cl.exe
would put them, but the pch file format is of course incompatible. This has
ramifications on /fallback, so /Yc /Yu aren't passed through to cl.exe in
/fallback builds.

http://reviews.llvm.org/D17695

Added:
cfe/trunk/test/Driver/Inputs/pchfile.cpp
cfe/trunk/test/Driver/Inputs/pchfile.h
cfe/trunk/test/Driver/cl-pch-errorhandling.cpp
cfe/trunk/test/Driver/cl-pch-search.cpp
cfe/trunk/test/Driver/cl-pch.c
cfe/trunk/test/Driver/cl-pch.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/include/clang/Driver/Job.h
cfe/trunk/include/clang/Frontend/CompilerInstance.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Job.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=262420&r1=262419&r2=262420&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Tue Mar  1 17:16:44 
2016
@@ -98,6 +98,20 @@ def err_drv_unknown_argument : Error<"un
 def warn_drv_unknown_argument_clang_cl : Warning<
   "unknown argument ignored in clang-cl: '%0'">,
   InGroup;
+
+def warn_drv_ycyu_no_arg_clang_cl : Warning<
+  "support for '%0' without a filename not imp

Re: [PATCH] D17385: clang-format: [JS] re-quote single or double quoted strings.

2016-03-01 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: include/clang/Format/Format.h:606
@@ +605,3 @@
+  /// \brief The QuoteStyle to use for JavaScript strings.
+  QuoteStyle Quotes;
+

As this only affects JavaScript and doesn't make any sense for Java or C++, I'd 
like to have JS/JavaScript in the option and enum name.


Comment at: lib/Format/Format.cpp:76
@@ +75,3 @@
+  static void enumeration(IO &IO, FormatStyle::QuoteStyle &Value) {
+IO.enumCase(Value, "leave", FormatStyle::QS_Leave);
+IO.enumCase(Value, "single", FormatStyle::QS_Single);

For almost all the other enums we use upper case.


Comment at: lib/Format/Format.cpp:1087
@@ +1086,3 @@
+(Style.Quotes == FormatStyle::QS_Single &&
+ !FormatTok->TokenText.startswith("\"")) ||
+(Style.Quotes == FormatStyle::QS_Double &&

Are there more than the two options? Otherwise, I would find:

  Style.Quotes == FormatStyle::QS_Single && 
FormatTok->TokenText.startswith("\'")

more intuitive.


Comment at: lib/Format/Format.cpp:1094
@@ +1093,3 @@
+
+StringRef Input = FormatTok->TokenText;
+size_t ColumnWidth = FormatTok->TokenText.size();

Move this up so you can use it in the if-statement?


Comment at: unittests/Format/FormatTestJS.cpp:638
@@ -637,3 +637,3 @@
 TEST_F(FormatTestJS, StringLiteralConcatenation) {
-  verifyFormat("var literal = 'hello ' +\n"
-   "'world';");
+  verifyFormat("var literal =\n"
+   "'hello ' + 'world';",

Why change this test? I think this was meant to test that we always add a line 
break between two consecutive string literals as otherwise the user could just 
have written this without the "' + '".


Comment at: unittests/Format/FormatTestJS.cpp:878
@@ -876,3 +877,3 @@
"  Y,\n"
-   "} from 'some/long/module.js';",
+   "} from\n'some/long/module.js';",
getGoogleJSStyleWithColumns(20));

I don't think this is intended.


http://reviews.llvm.org/D17385



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


Re: [PATCH] D15643: [clang-format] Don't allow newline after uppercase Obj-C block return types

2016-03-01 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Sorry for the delayed reply. I think this looks good.


http://reviews.llvm.org/D15643



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


RE: [PATCH] D17688: Fix missed leak from MSVC specific allocationfunctions

2016-03-01 Thread Alexander Riccio via cfe-commits
> I just don't understand why some functions made it in this patch and not 
> others (notably, why the lack of _mbsdup, which is documented on the same 
> page as others you are adding).

It's partly because of the better wrapper class that was mentioned (in a 
discussion that I'm having trouble finding), and partly because I highly prefer 
locking in small changes rather than repeatedly growing patches. 

Personally, the more I grow a patch, the less likely it is that I'll ever 
actually get it accepted. I think this has a bit to do with using svn instead 
of git.

> By "here", do you mean in this review thread, or as part of this section of 
> code?

Whoops. I meant in this thread or an email, but I don't actually remembering 
why I asked this in the first place. I'll just whack some of the easiest ones 
in, and we'll go from there.

I'll need to separately implement the aligned versions, because they shouldn't 
be mixed with the normal versions.


sent from my (stupid) windows phone

-Original Message-
From: "Aaron Ballman" 
Sent: ‎3/‎1/‎2016 3:33 PM
To: "" 
Cc: "reviews+d17688+public+c9d6a65abf2d2...@reviews.llvm.org" 
; "Devin Coughlin" 
; "Anna Zaks" ; "cfe-commits" 

Subject: Re: [PATCH] D17688: Fix missed leak from MSVC specific 
allocationfunctions

On Tue, Mar 1, 2016 at 1:42 PM, 
 wrote:
> I'd quite happily add them... but can I do it in another patch? I think I
> could be more thorough that way.

I'm not certain I understand the reasoning, but I also don't have
strong feelings on whether it's this patch or another. I just don't
understand why some functions made it in this patch and not others
(notably, why the lack of _mbsdup, which is documented on the same
page as others you are adding).

> For the same reason, can we list all the microsoft memory allocating
> routines here? There are a thousand routines we might want to add, and then
> a few others (like _dupenv_s, _malloca, and _expand) which are especially
> important to be able to analyze (because they have really tricky APIs), but
> because of their kooky APIs, they're harder to implement checkers for.

By "here", do you mean in this review thread, or as part of this
section of code?

~Aaron

>
> Sincerely,
> Alexander Riccio
> --
> "Change the world or go home."
> about.me/ariccio
>
> If left to my own devices, I will build more.
> ⁂
>
> On Tue, Mar 1, 2016 at 8:38 AM, Aaron Ballman 
> wrote:
>>
>> On Tue, Mar 1, 2016 at 2:16 AM, Alexander Riccio 
>> wrote:
>> > ariccio updated this revision to Diff 49456.
>> > ariccio added a comment.
>> >
>> > Nit addressed.
>> >
>> >
>> > http://reviews.llvm.org/D17688
>> >
>> > Files:
>> >   llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> >
>> > Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> > ===
>> > --- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> > +++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
>> > @@ -169,11 +169,12 @@
>> >  {
>> >  public:
>> >MallocChecker()
>> > -  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
>> > -II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr),
>> > -II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr),
>> > -II_kmalloc(nullptr), II_if_nameindex(nullptr),
>> > -II_if_freenameindex(nullptr) {}
>> > +  : II_alloca(nullptr), II_win_alloca(nullptr), II_malloc(nullptr),
>> > +II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
>> > +II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
>> > +II_strdup(nullptr), II_win_strdup(nullptr),
>> > II_kmalloc(nullptr),
>> > +II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
>> > +II_wcsdup(nullptr), II_win_wcsdup(nullptr) {}
>> >
>> >/// In pessimistic mode, the checker assumes that it does not know
>> > which
>> >/// functions might free the memory.
>> > @@ -231,10 +232,11 @@
>> >mutable std::unique_ptr BT_MismatchedDealloc;
>> >mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
>> >mutable std::unique_ptr
>> > BT_UseZerroAllocated[CK_NumCheckKinds];
>> > -  mutable IdentifierInfo *II_alloca, *II_malloc, *II_free, *II_realloc,
>> > - *II_calloc, *II_valloc, *II_reallocf,
>> > *II_strndup,
>> > - *II_strdup, *II_kmalloc, *II_if_nameindex,
>> > - *II_if_freenameindex;
>> > +  mutable IdentifierInfo *II_alloca, *II_win_alloca, *II_malloc,
>> > *II_free,
>> > + *II_realloc, *II_calloc, *II_valloc,
>> > *II_reallocf,
>> > + *II_strndup, *II_strdup, *II_win_strdup,
>> > *II_kmalloc,
>> > + *II_if_nameindex, *II_if_freenameindex,
>> > *II_wcsdup,
>> > + *II_win_wcsdup;
>> >mutable Optional KernelZeroFlagVal;
>> >
>> >void initIdentifierInfo(ASTConte

Re: [PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-03-01 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

I suggest to update the malloc regression test with these.


http://reviews.llvm.org/D17688



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


Re: [PATCH] D17779: [CUDA] Emit host-side 'shadows' for device-side global variables

2016-03-01 Thread Artem Belevich via cfe-commits
tra updated this revision to Diff 49561.
tra marked 9 inline comments as done.
tra added a comment.

Addressed Justin's comments.


http://reviews.llvm.org/D17779

Files:
  lib/CodeGen/CGCUDANV.cpp
  lib/CodeGen/CGCUDARuntime.h
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCUDA/device-stub.cu
  test/CodeGenCUDA/filter-decl.cu

Index: test/CodeGenCUDA/filter-decl.cu
===
--- test/CodeGenCUDA/filter-decl.cu
+++ test/CodeGenCUDA/filter-decl.cu
@@ -9,15 +9,15 @@
 // CHECK-DEVICE-NOT: module asm "file scope asm is host only"
 __asm__("file scope asm is host only");
 
-// CHECK-HOST-NOT: constantdata = externally_initialized global
+// CHECK-HOST: constantdata = internal global
 // CHECK-DEVICE: constantdata = externally_initialized global
 __constant__ char constantdata[256];
 
-// CHECK-HOST-NOT: devicedata = externally_initialized global
+// CHECK-HOST: devicedata = internal global
 // CHECK-DEVICE: devicedata = externally_initialized global
 __device__ char devicedata[256];
 
-// CHECK-HOST-NOT: shareddata = global
+// CHECK-HOST: shareddata = internal global
 // CHECK-DEVICE: shareddata = global
 __shared__ char shareddata[256];
 
Index: test/CodeGenCUDA/device-stub.cu
===
--- test/CodeGenCUDA/device-stub.cu
+++ test/CodeGenCUDA/device-stub.cu
@@ -2,6 +2,40 @@
 
 #include "Inputs/cuda.h"
 
+// CHECK-DAG: @device_var = internal global i32
+__device__ int device_var;
+
+// CHECK-DAG: @constant_var = internal global i32
+__constant__ int constant_var;
+
+// CHECK-DAG: @shared_var = internal global i32
+__shared__ int shared_var;
+
+// Make sure host globals don't get internalized...
+// CHECK-DAG: @host_var = global i32
+int host_var;
+// ... and that extern vars remain external.
+// CHECK-DAG: @ext_host_var = external global i32
+extern int ext_host_var;
+
+// Shadows for external device-side variables are *definitions* of
+// those variables.
+// CHECK-DAG: @ext_device_var = internal global i32
+extern __device__ int ext_device_var;
+// CHECK-DAG: @ext_device_var = internal global i32
+extern __constant__ int ext_constant_var;
+
+void use_pointers() {
+  int *p;
+  p = &device_var;
+  p = &constant_var;
+  p = &shared_var;
+  p = &host_var;
+  p = &ext_device_var;
+  p = &ext_constant_var;
+  p = &ext_host_var;
+}
+
 // Make sure that all parts of GPU code init/cleanup are there:
 // * constant unnamed string with the kernel name
 // CHECK: private unnamed_addr constant{{.*}}kernelfunc{{.*}}\00"
@@ -32,18 +66,23 @@
 // CHECK: call{{.*}}kernelfunc
 void hostfunc(void) { kernelfunc<<<1, 1>>>(1, 1, 1); }
 
-// Test that we've built a function to register kernels
-// CHECK: define internal void @__cuda_register_kernels
+// Test that we've built a function to register kernels and global vars.
+// CHECK: define internal void @__cuda_register_globals
 // CHECK: call{{.*}}cudaRegisterFunction(i8** %0, {{.*}}kernelfunc
+// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}device_var{{.*}}i32 0, i32 4, i32 0, i32 0
+// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}constant_var{{.*}}i32 0, i32 4, i32 1, i32 0
+// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_device_var{{.*}}i32 1, i32 4, i32 0, i32 0
+// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_constant_var{{.*}}i32 1, i32 4, i32 1, i32 0
+// CHECK: ret void
 
 // Test that we've built contructor..
 // CHECK: define internal void @__cuda_module_ctor
 //   .. that calls __cudaRegisterFatBinary(&__cuda_fatbin_wrapper)
 // CHECK: call{{.*}}cudaRegisterFatBinary{{.*}}__cuda_fatbin_wrapper
 //   .. stores return value in __cuda_gpubin_handle
 // CHECK-NEXT: store{{.*}}__cuda_gpubin_handle
-//   .. and then calls __cuda_register_kernels
-// CHECK-NEXT: call void @__cuda_register_kernels
+//   .. and then calls __cuda_register_globals
+// CHECK-NEXT: call void @__cuda_register_globals
 
 // Test that we've created destructor.
 // CHECK: define internal void @__cuda_module_dtor
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1528,11 +1528,18 @@
   !Global->hasAttr())
 return;
 } else {
-  if (!Global->hasAttr() && (
-Global->hasAttr() ||
-Global->hasAttr() ||
-Global->hasAttr()))
+  // We need to emit host-side 'shadows' for all global
+  // device-side variables because the CUDA runtime needs their
+  // size and host-side address in order to provide access to
+  // their device-side incarnations.
+
+  // So device-only functions are the only things we skip.
+  if (isa(Global) && !Global->hasAttr() &&
+  Global->hasAttr())
 return;
+
+  assert((isa(Global) || isa(Global)) &&
+ "Expected Variable or Function");
 }
   }
 
@@ -1561,8 +1568,15 @@
   } else {
 const auto *VD 

Re: [PATCH] D17385: clang-format: [JS] re-quote single or double quoted strings.

2016-03-01 Thread Martin Probst via cfe-commits
mprobst added inline comments.


Comment at: lib/Format/Format.cpp:1087
@@ +1086,3 @@
+(Style.Quotes == FormatStyle::QS_Single &&
+ !FormatTok->TokenText.startswith("\"")) ||
+(Style.Quotes == FormatStyle::QS_Double &&

djasper wrote:
> Are there more than the two options? Otherwise, I would find:
> 
>   Style.Quotes == FormatStyle::QS_Single && 
> FormatTok->TokenText.startswith("\'")
> 
> more intuitive.
I would too, but think about `template strings`. Added a comment. I think it's 
safer to specifically check for the thing that we do handle/fix below, instead 
of just accepting everything we think is not correct.


Comment at: unittests/Format/FormatTestJS.cpp:638
@@ -637,3 +637,3 @@
 TEST_F(FormatTestJS, StringLiteralConcatenation) {
-  verifyFormat("var literal = 'hello ' +\n"
-   "'world';");
+  verifyFormat("var literal =\n"
+   "'hello ' + 'world';",

djasper wrote:
> Why change this test? I think this was meant to test that we always add a 
> line break between two consecutive string literals as otherwise the user 
> could just have written this without the "' + '".
This was exposed by the char_literal/string_literal test, it aligns the 
behaviour with what would always happen for a double quoted string. It fits the 
no-alignment rule.

I've changed the test to make sure it actually wraps on two lines.


Comment at: unittests/Format/FormatTestJS.cpp:878
@@ -876,3 +877,3 @@
"  Y,\n"
-   "} from 'some/long/module.js';",
+   "} from\n'some/long/module.js';",
getGoogleJSStyleWithColumns(20));

djasper wrote:
> I don't think this is intended.
It is. This was incorrectly handled before, the line is longer than 20 chars. 
It's because I switched single quoted strings from char_literal to 
string_literal.


http://reviews.llvm.org/D17385



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


  1   2   >