[PATCH] D31491: [XRay][clang] Fix the -fxray-instruction-threshold flag processing

2017-03-30 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris created this revision.

The refactoring introduced a regression in the flag processing for
-fxray-instruction-threshold which causes it to not get passed properly.
This change should restore the previous behaviour.


https://reviews.llvm.org/D31491

Files:
  lib/Driver/XRayArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/xray-instruction-threshold.cpp


Index: test/CodeGen/xray-instruction-threshold.cpp
===
--- /dev/null
+++ test/CodeGen/xray-instruction-threshold.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -x c++ 
-std=c++11 -emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+int foo() {
+  return 1;
+}
+
+[[clang::xray_never_instrument]] int bar() {
+  return 2;
+}
+
+// CHECK-DAG: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
+// CHECK-DAG: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {
+// CHECK-DAG: attributes #[[THRESHOLD]] = {{.*}} 
"xray-instruction-threshold"="1" {{.*}}
+// CHECK-DAG: attributes #[[NEVERATTR]] = {{.*}} 
"function-instrument"="xray-never" {{.*}}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -721,7 +721,7 @@
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
   Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
   Opts.XRayInstructionThreshold =
-  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.CallFEntry = Args.hasArg(OPT_mfentry);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
@@ -2308,9 +2308,11 @@
   getLastArgIntValue(Args, OPT_fsanitize_address_field_padding, 0, Diags);
   Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsanitize_blacklist);
 
-  // -fxray-{always,never}-instrument= filenames.
+  // -fxray-instrument
   Opts.XRayInstrument =
   Args.hasFlag(OPT_fxray_instrument, OPT_fnoxray_instrument, false);
+
+  // -fxray-{always,never}-instrument= filenames.
   Opts.XRayAlwaysInstrumentFiles =
   Args.getAllArgValues(OPT_fxray_always_instrument);
   Opts.XRayNeverInstrumentFiles =
Index: lib/Driver/XRayArgs.cpp
===
--- lib/Driver/XRayArgs.cpp
+++ lib/Driver/XRayArgs.cpp
@@ -16,8 +16,8 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/SpecialCaseList.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/SpecialCaseList.h"
 
 using namespace clang;
 using namespace clang::driver;
@@ -91,8 +91,8 @@
 return;
 
   CmdArgs.push_back(XRayInstrumentOption);
-  CmdArgs.push_back(Args.MakeArgString(XRayInstructionThresholdOption +
-   llvm::to_string(InstructionThreshold)));
+  CmdArgs.push_back(Args.MakeArgString(Twine(XRayInstructionThresholdOption) +
+   Twine(InstructionThreshold)));
 
   for (const auto &Always : AlwaysInstrumentFiles) {
 SmallString<64> AlwaysInstrumentOpt(XRayAlwaysInstrumentOption);


Index: test/CodeGen/xray-instruction-threshold.cpp
===
--- /dev/null
+++ test/CodeGen/xray-instruction-threshold.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -x c++ -std=c++11 -emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+int foo() {
+  return 1;
+}
+
+[[clang::xray_never_instrument]] int bar() {
+  return 2;
+}
+
+// CHECK-DAG: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
+// CHECK-DAG: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {
+// CHECK-DAG: attributes #[[THRESHOLD]] = {{.*}} "xray-instruction-threshold"="1" {{.*}}
+// CHECK-DAG: attributes #[[NEVERATTR]] = {{.*}} "function-instrument"="xray-never" {{.*}}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -721,7 +721,7 @@
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
   Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
   Opts.XRayInstructionThreshold =
-  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
+  getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.CallFEntry = Args.hasArg(OPT_mfentry);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
@@ -2308,9 +2308,11 @@
   getLastArgIntValue(Args, OPT_fsanitize_address_field_padding, 0, Diags);
   Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsani

[PATCH] D31492: Add `addReplacement` interface in AtomicChange.

2017-03-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
Herald added a subscriber: klimek.

https://reviews.llvm.org/D31492

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  lib/Tooling/Refactoring/AtomicChange.cpp


Index: lib/Tooling/Refactoring/AtomicChange.cpp
===
--- lib/Tooling/Refactoring/AtomicChange.cpp
+++ lib/Tooling/Refactoring/AtomicChange.cpp
@@ -132,6 +132,10 @@
   return E;
 }
 
+llvm::Error AtomicChange::addReplacement(const Replacement& R) {
+  return Replaces.add(R);
+}
+
 llvm::Error AtomicChange::insert(const SourceManager &SM, SourceLocation Loc,
  llvm::StringRef Text, bool InsertAfter) {
   if (Text.empty())
Index: include/clang/Tooling/Refactoring/AtomicChange.h
===
--- include/clang/Tooling/Refactoring/AtomicChange.h
+++ include/clang/Tooling/Refactoring/AtomicChange.h
@@ -70,6 +70,9 @@
   /// \brief Returns the error message or an empty string if it does not exist.
   const std::string &getError() const { return Error; }
 
+  /// \brief Adds a replacement to the atomic change.
+  llvm::Error addReplacement(const Replacement& R);
+
   /// \brief Adds a replacement that replaces range [Loc, Loc+Length) with
   /// \p Text.
   /// \returns An llvm::Error carrying ReplacementError on error.


Index: lib/Tooling/Refactoring/AtomicChange.cpp
===
--- lib/Tooling/Refactoring/AtomicChange.cpp
+++ lib/Tooling/Refactoring/AtomicChange.cpp
@@ -132,6 +132,10 @@
   return E;
 }
 
+llvm::Error AtomicChange::addReplacement(const Replacement& R) {
+  return Replaces.add(R);
+}
+
 llvm::Error AtomicChange::insert(const SourceManager &SM, SourceLocation Loc,
  llvm::StringRef Text, bool InsertAfter) {
   if (Text.empty())
Index: include/clang/Tooling/Refactoring/AtomicChange.h
===
--- include/clang/Tooling/Refactoring/AtomicChange.h
+++ include/clang/Tooling/Refactoring/AtomicChange.h
@@ -70,6 +70,9 @@
   /// \brief Returns the error message or an empty string if it does not exist.
   const std::string &getError() const { return Error; }
 
+  /// \brief Adds a replacement to the atomic change.
+  llvm::Error addReplacement(const Replacement& R);
+
   /// \brief Adds a replacement that replaces range [Loc, Loc+Length) with
   /// \p Text.
   /// \returns An llvm::Error carrying ReplacementError on error.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31492: Add `addReplacement` interface in AtomicChange.

2017-03-30 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Please see comment from a previous patch 
(https://reviews.llvm.org/D27054?id=79099#inline-234270). Generally, 
`AtomicChange` is a higher level of abstraction than `Replacement`, and we 
don't want users to deal with `Replacement` and the related errors.


https://reviews.llvm.org/D31492



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


[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-03-30 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In https://reviews.llvm.org/D29221#698679, @amaiorano wrote:

> Hey guys, any feedback on this? About 1.5 weeks ago, @hans asked @klimek and 
> @djasper for their opinions on "clang-format" vs "ClangFormat". Thanks!


Let's get this committed now and not worry about renaming things.

Do you have commit access, or would you like me to commit it for you?


https://reviews.llvm.org/D29221



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


[PATCH] D31492: Add `addReplacement` interface in AtomicChange.

2017-03-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 93456.
hokein added a comment.

Get rid of Replacement, and implement "replace" interface with range.


https://reviews.llvm.org/D31492

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  lib/Tooling/Refactoring/AtomicChange.cpp


Index: lib/Tooling/Refactoring/AtomicChange.cpp
===
--- lib/Tooling/Refactoring/AtomicChange.cpp
+++ lib/Tooling/Refactoring/AtomicChange.cpp
@@ -132,6 +132,12 @@
   return E;
 }
 
+llvm::Error AtomicChange::replace(const SourceManager &SM,
+  const CharSourceRange &Range,
+  llvm::StringRef ReplacementText) {
+  return Replacements.add(Replacement(SM, Range, ReplacementText));
+}
+
 llvm::Error AtomicChange::insert(const SourceManager &SM, SourceLocation Loc,
  llvm::StringRef Text, bool InsertAfter) {
   if (Text.empty())
Index: include/clang/Tooling/Refactoring/AtomicChange.h
===
--- include/clang/Tooling/Refactoring/AtomicChange.h
+++ include/clang/Tooling/Refactoring/AtomicChange.h
@@ -70,6 +70,12 @@
   /// \brief Returns the error message or an empty string if it does not exist.
   const std::string &getError() const { return Error; }
 
+  /// \brief Adds a replacement that replaces the given Range with
+  /// ReplacementText.
+  /// \returns An llvm::Error carrying ReplacementError on error.
+  llvm::Error replace(const SourceManager &SM, const CharSourceRange &Range,
+  llvm::StringRef ReplacementText);
+
   /// \brief Adds a replacement that replaces range [Loc, Loc+Length) with
   /// \p Text.
   /// \returns An llvm::Error carrying ReplacementError on error.


Index: lib/Tooling/Refactoring/AtomicChange.cpp
===
--- lib/Tooling/Refactoring/AtomicChange.cpp
+++ lib/Tooling/Refactoring/AtomicChange.cpp
@@ -132,6 +132,12 @@
   return E;
 }
 
+llvm::Error AtomicChange::replace(const SourceManager &SM,
+  const CharSourceRange &Range,
+  llvm::StringRef ReplacementText) {
+  return Replacements.add(Replacement(SM, Range, ReplacementText));
+}
+
 llvm::Error AtomicChange::insert(const SourceManager &SM, SourceLocation Loc,
  llvm::StringRef Text, bool InsertAfter) {
   if (Text.empty())
Index: include/clang/Tooling/Refactoring/AtomicChange.h
===
--- include/clang/Tooling/Refactoring/AtomicChange.h
+++ include/clang/Tooling/Refactoring/AtomicChange.h
@@ -70,6 +70,12 @@
   /// \brief Returns the error message or an empty string if it does not exist.
   const std::string &getError() const { return Error; }
 
+  /// \brief Adds a replacement that replaces the given Range with
+  /// ReplacementText.
+  /// \returns An llvm::Error carrying ReplacementError on error.
+  llvm::Error replace(const SourceManager &SM, const CharSourceRange &Range,
+  llvm::StringRef ReplacementText);
+
   /// \brief Adds a replacement that replaces range [Loc, Loc+Length) with
   /// \p Text.
   /// \returns An llvm::Error carrying ReplacementError on error.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31492: Add `replace` interface with range in AtomicChange.

2017-03-30 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexshap added a comment.

to avoid misunderstanding - are the tools like clang-rename, change-namespace 
and clang-reorder-fields supposed to use AtomicChange (via the methods insert, 
replace etc) ?
(i am asking just to make sure i understand correctly the intentions behind 
AtomicChange interface)


https://reviews.llvm.org/D31492



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


[PATCH] D26830: [libcxx] Add string_view literals

2017-03-30 Thread Anton Bikineev via Phabricator via cfe-commits
AntonBikineev added a comment.

In https://reviews.llvm.org/D26830#711870, @EricWF wrote:

> @AntonBikineev when will you be able to make he requested changes? I would 
> like to land this ASAP.


Eric, have you looked at commit 7d32d2f5a1f39d4cae9469645faa74b647698001? This 
functionality has already been implemented by Marshall, we should abandon this 
patch.


https://reviews.llvm.org/D26830



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


[PATCH] D31370: [clang-tidy] Prototype to check for exception specification

2017-03-30 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added inline comments.



Comment at: docs/clang-tidy/checks/modernize-noexcept-correctness.rst:7
+This check will mark functions as noexcept if that is possible.
+`noexcept` is a new keyword in C++ 11 to signal, that no exception will escape 
from 
+the function annotated with it. Some examples to show how this new feature is 
used are below.

Eugene.Zelenko wrote:
> Please highlight language constructs with ``.
Omit comma before "that".



Comment at: docs/clang-tidy/checks/modernize-noexcept-correctness.rst:27
+
+// Definitly throw an exception on one path. The check will not analyze if 
this
+// path is actually executed (in this function it wouldn't!).

Typo: "Definitely"



Comment at: test/clang-tidy/modernize-noexcept-correctness.cpp:61
+// This one is hard, since one must figure out if all possible exceptions are 
handled.
+// I think that is to complex (for now) and should be let alone. So the 
programmer
+// must ensure its correctly either marked noexcept or not.

 Typos: "too complex", "left alone"


Repository:
  rL LLVM

https://reviews.llvm.org/D31370



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


[PATCH] D31492: Add `replace` interface with range in AtomicChange.

2017-03-30 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

In https://reviews.llvm.org/D31492#713908, @alexshap wrote:

> to avoid misunderstanding - are the tools like clang-rename, change-namespace 
> and clang-reorder-fields supposed to use AtomicChange (via the methods 
> insert, replace etc) ?
>  (i am asking just to make sure i understand correctly the intentions behind 
> AtomicChange interface)


In the future, yes. We have a plan to redesign `ClangTool` interface and the 
refactoring infrastructure (e.g. to support multi-TU/codebase-wide refactoring) 
which would use `AtomicChange` interface in the user level.


https://reviews.llvm.org/D31492



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


[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-03-30 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano added a comment.

In https://reviews.llvm.org/D29221#713902, @hans wrote:

> In https://reviews.llvm.org/D29221#698679, @amaiorano wrote:
>
> > Hey guys, any feedback on this? About 1.5 weeks ago, @hans asked @klimek 
> > and @djasper for their opinions on "clang-format" vs "ClangFormat". Thanks!
>
>
> Let's get this committed now and not worry about renaming things.
>
> Do you have commit access, or would you like me to commit it for you?


I've got commit access, so I'll commit this ASAP. Thanks!


https://reviews.llvm.org/D29221



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


[PATCH] D31492: Add `replace` interface with range in AtomicChange.

2017-03-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 93467.
hokein added a comment.

Rebase to master.


https://reviews.llvm.org/D31492

Files:
  include/clang/Tooling/Refactoring/AtomicChange.h
  lib/Tooling/Refactoring/AtomicChange.cpp


Index: lib/Tooling/Refactoring/AtomicChange.cpp
===
--- lib/Tooling/Refactoring/AtomicChange.cpp
+++ lib/Tooling/Refactoring/AtomicChange.cpp
@@ -132,6 +132,12 @@
   return E;
 }
 
+llvm::Error AtomicChange::replace(const SourceManager &SM,
+  const CharSourceRange &Range,
+  llvm::StringRef ReplacementText) {
+  return Replaces.add(Replacement(SM, Range, ReplacementText));
+}
+
 llvm::Error AtomicChange::replace(const SourceManager &SM, SourceLocation Loc,
   unsigned Length, llvm::StringRef Text) {
   return Replaces.add(Replacement(SM, Loc, Length, Text));
Index: include/clang/Tooling/Refactoring/AtomicChange.h
===
--- include/clang/Tooling/Refactoring/AtomicChange.h
+++ include/clang/Tooling/Refactoring/AtomicChange.h
@@ -70,6 +70,12 @@
   /// \brief Returns the error message or an empty string if it does not exist.
   const std::string &getError() const { return Error; }
 
+  /// \brief Adds a replacement that replaces the given Range with
+  /// ReplacementText.
+  /// \returns An llvm::Error carrying ReplacementError on error.
+  llvm::Error replace(const SourceManager &SM, const CharSourceRange &Range,
+  llvm::StringRef ReplacementText);
+
   /// \brief Adds a replacement that replaces range [Loc, Loc+Length) with
   /// \p Text.
   /// \returns An llvm::Error carrying ReplacementError on error.


Index: lib/Tooling/Refactoring/AtomicChange.cpp
===
--- lib/Tooling/Refactoring/AtomicChange.cpp
+++ lib/Tooling/Refactoring/AtomicChange.cpp
@@ -132,6 +132,12 @@
   return E;
 }
 
+llvm::Error AtomicChange::replace(const SourceManager &SM,
+  const CharSourceRange &Range,
+  llvm::StringRef ReplacementText) {
+  return Replaces.add(Replacement(SM, Range, ReplacementText));
+}
+
 llvm::Error AtomicChange::replace(const SourceManager &SM, SourceLocation Loc,
   unsigned Length, llvm::StringRef Text) {
   return Replaces.add(Replacement(SM, Loc, Length, Text));
Index: include/clang/Tooling/Refactoring/AtomicChange.h
===
--- include/clang/Tooling/Refactoring/AtomicChange.h
+++ include/clang/Tooling/Refactoring/AtomicChange.h
@@ -70,6 +70,12 @@
   /// \brief Returns the error message or an empty string if it does not exist.
   const std::string &getError() const { return Error; }
 
+  /// \brief Adds a replacement that replaces the given Range with
+  /// ReplacementText.
+  /// \returns An llvm::Error carrying ReplacementError on error.
+  llvm::Error replace(const SourceManager &SM, const CharSourceRange &Range,
+  llvm::StringRef ReplacementText);
+
   /// \brief Adds a replacement that replaces range [Loc, Loc+Length) with
   /// \p Text.
   /// \returns An llvm::Error carrying ReplacementError on error.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31492: Add `replace` interface with range in AtomicChange.

2017-03-30 Thread Eric Liu via Phabricator via cfe-commits
ioeric added a comment.

Could you add a simple test?


https://reviews.llvm.org/D31492



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


[PATCH] D31176: [clang-rename] Support renaming qualified symbol

2017-03-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 93468.
hokein marked 2 inline comments as done.
hokein added a comment.

Use AtomicChange.


https://reviews.llvm.org/D31176

Files:
  clang-rename/CMakeLists.txt
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/USRFinder.cpp
  clang-rename/USRFindingAction.cpp
  clang-rename/USRLocFinder.cpp
  clang-rename/USRLocFinder.h
  unittests/clang-rename/CMakeLists.txt
  unittests/clang-rename/ClangRenameTest.h
  unittests/clang-rename/ClangRenameTests.cpp
  unittests/clang-rename/RenameClassTest.cpp

Index: unittests/clang-rename/RenameClassTest.cpp
===
--- /dev/null
+++ unittests/clang-rename/RenameClassTest.cpp
@@ -0,0 +1,668 @@
+//===-- RenameClassTest.cpp - unit tests for renaming classes -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ClangRenameTest.h"
+
+namespace clang {
+namespace clang_rename {
+namespace test {
+namespace {
+
+class RenameClassTest : public ClangRenameTest {
+public:
+  RenameClassTest() {
+AppendToHeader(R"(
+  namespace a {
+class Foo {
+  public:
+struct Nested {
+  enum NestedEnum {E1, E2};
+};
+void func() {}
+  static int Constant;
+};
+class Goo {
+  public:
+struct Nested {
+  enum NestedEnum {E1, E2};
+};
+};
+int Foo::Constant = 1;
+  } // namespace a
+  namespace b {
+  class Foo {};
+  } // namespace b
+
+  #define MACRO(x) x
+
+  template class ptr {};
+)");
+  }
+};
+
+INSTANTIATE_TEST_CASE_P(
+RenameClassTests, RenameClassTest,
+testing::ValuesIn(std::vector({
+// basic classes
+{"a::Foo f;", "b::Bar f;"},
+{"void f(a::Foo f) {}", "void f(b::Bar f) {}"},
+{"void f(a::Foo *f) {}", "void f(b::Bar *f) {}"},
+{"a::Foo f() { return a::Foo(); }", "b::Bar f() { return b::Bar(); }"},
+{"namespace a {a::Foo f() { return Foo(); }}",
+ "namespace a {b::Bar f() { return b::Bar(); }}"},
+{"void f(const a::Foo& a1) {}", "void f(const b::Bar& a1) {}"},
+{"void f(const a::Foo* a1) {}", "void f(const b::Bar* a1) {}"},
+{"namespace a { void f(Foo a1) {} }",
+ "namespace a { void f(b::Bar a1) {} }"},
+{"void f(MACRO(a::Foo) a1) {}", "void f(MACRO(b::Bar) a1) {}"},
+{"void f(MACRO(a::Foo a1)) {}", "void f(MACRO(b::Bar a1)) {}"},
+{"a::Foo::Nested ns;", "b::Bar::Nested ns;"},
+{"auto t = a::Foo::Constant;", "auto t = b::Bar::Constant;"},
+{"a::Foo::Nested ns;", "a::Foo::Nested2 ns;", "a::Foo::Nested",
+ "a::Foo::Nested2"},
+
+// use namespace and typedefs
+{"using a::Foo; Foo gA;", "using b::Bar; b::Bar gA;"},
+{"using a::Foo; void f(Foo gA) {}", "using b::Bar; void f(Bar gA) {}"},
+{"using a::Foo; namespace x { Foo gA; }",
+ "using b::Bar; namespace x { Bar gA; }"},
+{"struct S { using T = a::Foo; T a_; };",
+ "struct S { using T = b::Bar; T a_; };"},
+{"using T = a::Foo; T gA;", "using T = b::Bar; T gA;"},
+{"typedef a::Foo T; T gA;", "typedef b::Bar T; T gA;"},
+{"typedef MACRO(a::Foo) T; T gA;", "typedef MACRO(b::Bar) T; T gA;"},
+
+// struct members and other oddities
+{"struct S : public a::Foo {};", "struct S : public b::Bar {};"},
+{"struct F { void f(a::Foo a1) {} };",
+ "struct F { void f(b::Bar a1) {} };"},
+{"struct F { a::Foo a_; };", "struct F { b::Bar a_; };"},
+{"struct F { ptr a_; };", "struct F { ptr a_; };"},
+
+{"void f() { a::Foo::Nested ne; }", "void f() { b::Bar::Nested ne; }"},
+{"void f() { a::Goo::Nested ne; }", "void f() { a::Goo::Nested ne; }"},
+{"void f() { a::Foo::Nested::NestedEnum e; }",
+ "void f() { b::Bar::Nested::NestedEnum e; }"},
+{"void f() { auto e = a::Foo::Nested::NestedEnum::E1; }",
+ "void f() { auto e = b::Bar::Nested::NestedEnum::E1; }"},
+{"void f() { auto e = a::Foo::Nested::E1; }",
+ "void f() { auto e = b::Bar::Nested::E1; }"},
+
+// templates
+{"template  struct Foo { T t; };\n"
+ "void f() { Foo foo; }",
+ "template  struct Foo { T t; };\n"
+ "void f() { Foo foo; }"},
+{"template  struct Foo { a::Foo a; };",
+ "template  struct Foo { b::Bar a; };"},
+{"template  void f(T t) {}\n"
+ "void g() { f(a::Foo()); }",
+ "template  void f(T t) {}\n"
+ "void g() { f(b::Bar()); }"},
+{"template  int f() { return 1; }\n"
+ "template <> int f() { return 2; }\n"
+ 

[PATCH] D31176: [clang-rename] Support renaming qualified symbol

2017-03-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 93469.
hokein marked an inline comment as done.
hokein added a comment.

update comments.


https://reviews.llvm.org/D31176

Files:
  clang-rename/CMakeLists.txt
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/USRFinder.cpp
  clang-rename/USRFindingAction.cpp
  clang-rename/USRLocFinder.cpp
  clang-rename/USRLocFinder.h
  unittests/clang-rename/CMakeLists.txt
  unittests/clang-rename/ClangRenameTest.h
  unittests/clang-rename/ClangRenameTests.cpp
  unittests/clang-rename/RenameClassTest.cpp

Index: unittests/clang-rename/RenameClassTest.cpp
===
--- /dev/null
+++ unittests/clang-rename/RenameClassTest.cpp
@@ -0,0 +1,668 @@
+//===-- RenameClassTest.cpp - unit tests for renaming classes -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ClangRenameTest.h"
+
+namespace clang {
+namespace clang_rename {
+namespace test {
+namespace {
+
+class RenameClassTest : public ClangRenameTest {
+public:
+  RenameClassTest() {
+AppendToHeader(R"(
+  namespace a {
+class Foo {
+  public:
+struct Nested {
+  enum NestedEnum {E1, E2};
+};
+void func() {}
+  static int Constant;
+};
+class Goo {
+  public:
+struct Nested {
+  enum NestedEnum {E1, E2};
+};
+};
+int Foo::Constant = 1;
+  } // namespace a
+  namespace b {
+  class Foo {};
+  } // namespace b
+
+  #define MACRO(x) x
+
+  template class ptr {};
+)");
+  }
+};
+
+INSTANTIATE_TEST_CASE_P(
+RenameClassTests, RenameClassTest,
+testing::ValuesIn(std::vector({
+// basic classes
+{"a::Foo f;", "b::Bar f;"},
+{"void f(a::Foo f) {}", "void f(b::Bar f) {}"},
+{"void f(a::Foo *f) {}", "void f(b::Bar *f) {}"},
+{"a::Foo f() { return a::Foo(); }", "b::Bar f() { return b::Bar(); }"},
+{"namespace a {a::Foo f() { return Foo(); }}",
+ "namespace a {b::Bar f() { return b::Bar(); }}"},
+{"void f(const a::Foo& a1) {}", "void f(const b::Bar& a1) {}"},
+{"void f(const a::Foo* a1) {}", "void f(const b::Bar* a1) {}"},
+{"namespace a { void f(Foo a1) {} }",
+ "namespace a { void f(b::Bar a1) {} }"},
+{"void f(MACRO(a::Foo) a1) {}", "void f(MACRO(b::Bar) a1) {}"},
+{"void f(MACRO(a::Foo a1)) {}", "void f(MACRO(b::Bar a1)) {}"},
+{"a::Foo::Nested ns;", "b::Bar::Nested ns;"},
+{"auto t = a::Foo::Constant;", "auto t = b::Bar::Constant;"},
+{"a::Foo::Nested ns;", "a::Foo::Nested2 ns;", "a::Foo::Nested",
+ "a::Foo::Nested2"},
+
+// use namespace and typedefs
+{"using a::Foo; Foo gA;", "using b::Bar; b::Bar gA;"},
+{"using a::Foo; void f(Foo gA) {}", "using b::Bar; void f(Bar gA) {}"},
+{"using a::Foo; namespace x { Foo gA; }",
+ "using b::Bar; namespace x { Bar gA; }"},
+{"struct S { using T = a::Foo; T a_; };",
+ "struct S { using T = b::Bar; T a_; };"},
+{"using T = a::Foo; T gA;", "using T = b::Bar; T gA;"},
+{"typedef a::Foo T; T gA;", "typedef b::Bar T; T gA;"},
+{"typedef MACRO(a::Foo) T; T gA;", "typedef MACRO(b::Bar) T; T gA;"},
+
+// struct members and other oddities
+{"struct S : public a::Foo {};", "struct S : public b::Bar {};"},
+{"struct F { void f(a::Foo a1) {} };",
+ "struct F { void f(b::Bar a1) {} };"},
+{"struct F { a::Foo a_; };", "struct F { b::Bar a_; };"},
+{"struct F { ptr a_; };", "struct F { ptr a_; };"},
+
+{"void f() { a::Foo::Nested ne; }", "void f() { b::Bar::Nested ne; }"},
+{"void f() { a::Goo::Nested ne; }", "void f() { a::Goo::Nested ne; }"},
+{"void f() { a::Foo::Nested::NestedEnum e; }",
+ "void f() { b::Bar::Nested::NestedEnum e; }"},
+{"void f() { auto e = a::Foo::Nested::NestedEnum::E1; }",
+ "void f() { auto e = b::Bar::Nested::NestedEnum::E1; }"},
+{"void f() { auto e = a::Foo::Nested::E1; }",
+ "void f() { auto e = b::Bar::Nested::E1; }"},
+
+// templates
+{"template  struct Foo { T t; };\n"
+ "void f() { Foo foo; }",
+ "template  struct Foo { T t; };\n"
+ "void f() { Foo foo; }"},
+{"template  struct Foo { a::Foo a; };",
+ "template  struct Foo { b::Bar a; };"},
+{"template  void f(T t) {}\n"
+ "void g() { f(a::Foo()); }",
+ "template  void f(T t) {}\n"
+ "void g() { f(b::Bar()); }"},
+{"template  int f() { return 1; }\n"
+ "template <> int f() { return 2; }\n"
+  

[PATCH] D31176: [clang-rename] Support renaming qualified symbol

2017-03-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-rename/USRLocFinder.cpp:359
+
+  // Returns a list of using declarations which are needed to update.
+  const std::vector &getUsingDecls() const {

ioeric wrote:
> hokein wrote:
> > ioeric wrote:
> > > I think these are using shadows only?
> > These are interested `UsingDecl`s which contain `UsingShadowDecl` of the 
> > symbol declarations being renamed.
> Sure. But maybe also document it?
I have documented it at the "UsingDecls" member definition.



Comment at: clang-rename/USRLocFinder.h:36
+/// \return Replacement for renaming.
+std::vector
+createRenameReplacement(llvm::ArrayRef USRs,

ioeric wrote:
> hokein wrote:
> > ioeric wrote:
> > > Why use `std::vector` instead of `tooling::Replacements`?
> > Seems that we don't get many benefits from using `tooling::Replacements` 
> > here. This function could be called multiple times (for renaming multiple 
> > symbols), we need to merge/add all replacements in caller side. if using 
> > `tooling::Replacements`, we will merge twice (one is in the API 
> > implementation).
> I think what we really want is `AtomicChange`. We shouldn't be using 
> `std::vector` or `std::set` replacements anymore.
Good idea. Done. I think we might still need to refine the interface in the 
future.


https://reviews.llvm.org/D31176



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


[clang-tools-extra] r299068 - [clang-tidy] add aliases for hicpp module

2017-03-30 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Thu Mar 30 06:57:54 2017
New Revision: 299068

URL: http://llvm.org/viewvc/llvm-project?rev=299068&view=rev
Log:
[clang-tidy] add aliases for hicpp module

Summary: Add some hicpp checks that can be implmented as alises for existing 
clang-tidy checks:
hicpp-explicit-conversions
hicpp-function-size
hicpp-named-parameter
hicpp-invalid-access-moved
hicpp-member-init
hicpp-new-delete-operators
hicpp-noexcept-move
hicpp-special-member-functions
hicpp-undelegated-constructor
hicpp-use-equals-default
hicpp-use-equals-delete
hicpp-use-override

Reviewers: dberlin, jbcoe, aaron.ballman, alexfh

Reviewed By: aaron.ballman

Subscribers: JDevlieghere

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

Patch By: Jonas Toth

Added:

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-explicit-conversions.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-function-size.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-invalid-access-moved.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-member-init.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-named-parameter.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-new-delete-operators.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-noexcept-move.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-special-member-functions.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-undelegated-constructor.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-default.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-equals-delete.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-use-override.rst
Modified:
clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp?rev=299068&r1=299067&r2=299068&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp Thu Mar 30 
06:57:54 2017
@@ -10,6 +10,19 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "../cppcoreguidelines/ProTypeMemberInitCheck.h"
+#include "../cppcoreguidelines/SpecialMemberFunctionsCheck.h"
+#include "../google/DefaultArgumentsCheck.h"
+#include "../google/ExplicitConstructorCheck.h"
+#include "../misc/NewDeleteOverloadsCheck.h"
+#include "../misc/NoexceptMoveConstructorCheck.h"
+#include "../misc/UndelegatedConstructor.h"
+#include "../misc/UseAfterMoveCheck.h"
+#include "../modernize/UseEqualsDefaultCheck.h"
+#include "../modernize/UseEqualsDeleteCheck.h"
+#include "../modernize/UseOverrideCheck.h"
+#include "../readability/FunctionSizeCheck.h"
+#include "../readability/IdentifierNamingCheck.h"
 #include "NoAssemblerCheck.h"
 
 namespace clang {
@@ -19,8 +32,32 @@ namespace hicpp {
 class HICPPModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
-CheckFactories.registerCheck(
-"hicpp-no-assembler");
+CheckFactories.registerCheck(
+"hicpp-explicit-conversions");
+CheckFactories.registerCheck(
+"hicpp-function-size");
+CheckFactories.registerCheck(
+"hicpp-named-parameter");
+CheckFactories.registerCheck(
+"hicpp-invalid-access-moved");
+CheckFactories.registerCheck(
+"hicpp-member-init");
+CheckFactories.registerCheck(
+"hicpp-new-delete-operators");
+CheckFactories.registerCheck(
+"hicpp-noexcept-move");
+CheckFactories.registerCheck("hicpp-no-assembler");
+CheckFactories
+.registerCheck(
+"hicpp-special-member-functions");
+CheckFactories.registerCheck(
+"hicpp-undelegated-constructor");
+CheckFactories.registerCheck(
+"hicpp-use-equals-default");
+CheckFactories.registerCheck(
+"hicpp-use-equals-delete");
+CheckFactories.registerCheck(
+"hicpp-use-override");
   }
 };
 

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=299068&r1=299067&r2=299068&view=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu Mar 30 06:57:54 2017
@@ -76,10 +76,10 @@ Improvements to clang-tidy
 
   Finds functions that have more then `ParameterThreshold` parameters and 
emits a warning.
 
-- New `safety-no-assembler
-  `_ 
check
+- New `hicpp` module
 
-  Finds uses of inline ass

[PATCH] D31176: [clang-rename] Support renaming qualified symbol

2017-03-30 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Lg with a few nits.




Comment at: clang-rename/RenamingAction.cpp:104
+  USRList[I], NewNames[I], Context.getTranslationUnitDecl());
+  for (const auto AtomicChange : AtomicChanges) {
+for (const auto &Replace : AtomicChange.getReplacements()) {

Maybe add a `FIXME` to fully replace this with `AtomicChange`s in the future?



Comment at: clang-rename/USRLocFinder.h:38
+std::vector
+createAtomicChanges(llvm::ArrayRef USRs, llvm::StringRef NewName,
+Decl *TranslationUnitDecl);

I'd name this `createRenameAtomicChanges` for clarity.


https://reviews.llvm.org/D31176



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


[PATCH] D30009: Add support for '#pragma clang attribute'

2017-03-30 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: docs/LanguageExtensions.rst:2430
+
+- ``function(is_method)``: Can be used to apply attributes to C++ methods,
+  including operators and constructors/destructors.

aaron.ballman wrote:
> Instead of `is_method`, I think we should use `is_instance`, `is_member`, or 
> something else. C++ doesn't really use the terminology "method", but 
> Objective-C does, which is why this could be confusing. It might also be good 
> to mention the behavior of a static member functions.
> 
> Whatever terminology gets picked, you should use that phrasing wherever you 
> say "C++ method".
I think `function(is_member)` should work well.



Comment at: docs/LanguageExtensions.rst:2443
+
+- ``record(unless(is_union))``: Can be used to apply attributes only to
+  ``struct`` and ``class`` declarations.

aaron.ballman wrote:
> Does unless() work in other combinations? e.g., can I use 
> record(unless(is_enum))? I'm not saying that it has to, but it would be good 
> to document one way or the other.
No, right now `unless` is very rigid and only works with a select set of match 
sub rules which are needed for attributes. I have noted that in the docs.



Comment at: docs/LanguageExtensions.rst:2448
+
+- ``enum_case``: Can be used to apply attributes to enumerators.
+

aaron.ballman wrote:
> I'd prefer these to be named `enumeration` and `enumerator`, `enum` and 
> `enum_constant`, or something. `enum_case` is too novel of a term for me.
I think `enum_constant` would work. I was thinking about `enumeration` and 
`enumerator` before, but they just look too alike so it might be easy to 
confuse them.



Comment at: docs/LanguageExtensions.rst:2486
+
+- ``block``: Can be used to apply attributes to block declarations. This does
+  not include variables/fields of block pointer type.

aaron.ballman wrote:
> Perhaps name this one `objc_block` to be consistent with the other 
> objective-c features?
Blocks can be used outside of Objective-C.



Comment at: docs/LanguageExtensions.rst:2497
+:doc:`individual documentation for that attribute `.
+
+The attributes are applied to a declaration only when there would

aaron.ballman wrote:
> We should also support __declspec attributes shouldn't we (I see no reason to 
> support 2 out of the 3 attribute styles)? If so, the docs should state that, 
> and if not, I'd like to understand why and the docs should still state that.
Sure. A proper consistent style with `__attribute__` as you mentioned earlier 
is better for us as well due to legacy macros. Now `__attribute__` is required 
and I also added support for the `__declspec` attributes.



Comment at: include/clang/Sema/Sema.h:8160
+  /// '\#pragma clang attribute push' directives to the given declaration.
+  void AddPragmaAttributes(Scope *S, Decl *D);
+

aaron.ballman wrote:
> I worry about new calls to ProcessDeclAttributes() that don't have a nearby 
> call to AddPragmaAttributes(). I wonder if there's a way that we can combat 
> that likely misuse?
Perhaps we could just always call `AddPragmaAttributes` from 
`ProcessDeclAttributes` (after the declarator attributes are applied). That 
would mean that `#pragma clang attribute` will apply its attributes earlier 
than other pragmas or implicit attributes.



Comment at: lib/Parse/ParsePragma.cpp:1158
+  Diag(Loc, diag::err_pragma_attribute_multiple_attributes);
+  Attrs.getList()->setNext(nullptr);
+}

aaron.ballman wrote:
> Is this going to cause a memory leak for those attributes that were parsed 
> but dropped?
Possibly, I fixed this up.



Comment at: lib/Sema/SemaAttr.cpp:602-603
+  PragmaAttributeStack.pop_back();
+  // FIXME: Should we check the attribute even when it's not applied to any
+  // declaration?
+}

aaron.ballman wrote:
> I think that makes sense (I can imagine someone writing the pragma push and 
> pop before writing all their declarations), but I might be misunderstanding 
> the question.
That would make sense, I agree. I added a warning that warns about unapplied 
attributes in push pop regions. However, my original question was more about 
correctness of the attribute which we can’t check semantically unless we apply 
it first. I don’t think it’s really needed though, so I removed the “fixme”.



Comment at: lib/Sema/SemaAttr.cpp:631
+ProcessDeclAttributeList(S, D, Entry.Attribute);
+HasFailed = Trap.hasErrorOccurred();
+  }

aaron.ballman wrote:
> Do we only care about errors, or should we also care about warnings? 
> Incorrect attributes that do not affect code generation often are treated as 
> warnings (and the attribute is simply ignored) rather than errors, so the 
> user may want to know about those issues.

[clang-tools-extra] r299070 - [clang-tidy] fix for linker errors in hicpp checks

2017-03-30 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Thu Mar 30 07:31:02 2017
New Revision: 299070

URL: http://llvm.org/viewvc/llvm-project?rev=299070&view=rev
Log:
[clang-tidy] fix for linker errors in hicpp checks

Speculative fix for linker errors in r299068.

Modified:
clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt?rev=299070&r1=299069&r2=299070&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt Thu Mar 30 07:31:02 
2017
@@ -10,5 +10,10 @@ add_clang_library(clangTidyHICPPModule
   clangBasic
   clangLex
   clangTidy
+  clangTidyCppCoreGuidelinesModule
+  clangTidyGoogleModule
+  clangTidyMiscModule
+  clangTidyModernizeModule
+  clangTidyReadabilityModule
   clangTidyUtils
   )


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


[PATCH] D31492: Add `replace` interface with range in AtomicChange.

2017-03-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 93472.
hokein added a comment.

Add unittest.


https://reviews.llvm.org/D31492

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

Index: unittests/Tooling/RefactoringTest.cpp
===
--- unittests/Tooling/RefactoringTest.cpp
+++ unittests/Tooling/RefactoringTest.cpp
@@ -1092,7 +1092,7 @@
 
 class AtomicChangeTest : public ::testing::Test {
   protected:
-void setUp() {
+void SetUp() override {
   DefaultFileID = Context.createInMemoryFile("input.cpp", DefaultCode);
   DefaultLoc = Context.Sources.getLocForStartOfFile(DefaultFileID)
.getLocWithOffset(20);
@@ -1107,7 +1107,6 @@
 };
 
 TEST_F(AtomicChangeTest, AtomicChangeToYAML) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err =
   Change.insert(Context.Sources, DefaultLoc, "aa", /*InsertAfter=*/false);
@@ -1140,7 +1139,6 @@
 }
 
 TEST_F(AtomicChangeTest, YAMLToAtomicChange) {
-  setUp();
   std::string YamlContent = "---\n"
 "Key: 'input.cpp:20'\n"
 "FilePath:input.cpp\n"
@@ -1187,14 +1185,12 @@
 }
 
 TEST_F(AtomicChangeTest, CheckKeyAndKeyFile) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   EXPECT_EQ("input.cpp:20", Change.getKey());
   EXPECT_EQ("input.cpp", Change.getFilePath());
 }
 
 TEST_F(AtomicChangeTest, Replace) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err = Change.replace(Context.Sources, DefaultLoc, 2, "aa");
   ASSERT_TRUE(!Err);
@@ -1209,8 +1205,18 @@
   EXPECT_EQ(Change.getReplacements().size(), 1u);
 }
 
+TEST_F(AtomicChangeTest, ReplaceWithRange) {
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  SourceLocation End = DefaultLoc.getLocWithOffset(20);
+  llvm::Error Err = Change.replace(
+  Context.Sources, CharSourceRange::getCharRange(DefaultLoc, End), "aa");
+  ASSERT_TRUE(!Err);
+  EXPECT_EQ(Change.getReplacements().size(), 1u);
+  EXPECT_EQ(*Change.getReplacements().begin(),
+Replacement(Context.Sources, DefaultLoc, 20, "aa"));
+}
+
 TEST_F(AtomicChangeTest, InsertBefore) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err = Change.insert(Context.Sources, DefaultLoc, "aa");
   ASSERT_TRUE(!Err);
@@ -1225,7 +1231,6 @@
 }
 
 TEST_F(AtomicChangeTest, InsertAfter) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err = Change.insert(Context.Sources, DefaultLoc, "aa");
   ASSERT_TRUE(!Err);
@@ -1240,7 +1245,6 @@
 }
 
 TEST_F(AtomicChangeTest, InsertBeforeWithInvalidLocation) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err =
   Change.insert(Context.Sources, DefaultLoc, "a", /*InsertAfter=*/false);
@@ -1254,11 +1258,9 @@
   std::move(Err), replacement_error::wrong_file_path,
   Replacement(Context.Sources, DefaultLoc, 0, "a"),
   Replacement(Context.Sources, SourceLocation(), 0, "a")));
-
 }
 
 TEST_F(AtomicChangeTest, InsertBeforeToWrongFile) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err =
   Change.insert(Context.Sources, DefaultLoc, "a", /*InsertAfter=*/false);
@@ -1276,7 +1278,6 @@
 }
 
 TEST_F(AtomicChangeTest, InsertAfterWithInvalidLocation) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err = Change.insert(Context.Sources, DefaultLoc, "a");
   ASSERT_TRUE(!Err);
Index: lib/Tooling/Refactoring/AtomicChange.cpp
===
--- lib/Tooling/Refactoring/AtomicChange.cpp
+++ lib/Tooling/Refactoring/AtomicChange.cpp
@@ -132,6 +132,12 @@
   return E;
 }
 
+llvm::Error AtomicChange::replace(const SourceManager &SM,
+  const CharSourceRange &Range,
+  llvm::StringRef ReplacementText) {
+  return Replaces.add(Replacement(SM, Range, ReplacementText));
+}
+
 llvm::Error AtomicChange::replace(const SourceManager &SM, SourceLocation Loc,
   unsigned Length, llvm::StringRef Text) {
   return Replaces.add(Replacement(SM, Loc, Length, Text));
Index: include/clang/Tooling/Refactoring/AtomicChange.h
===
--- include/clang/Tooling/Refactoring/AtomicChange.h
+++ include/clang/Tooling/Refactoring/AtomicChange.h
@@ -70,6 +70,12 @@
   /// \brief Returns the error message or an empty string if it does not exist.
   const std::string &getError() const { return Error; }
 
+  /// \brief Adds a replacement that replaces the given Range with
+  /// ReplacementText.
+  /// \returns An llvm::Error carrying ReplacementError on error.
+  llvm::Error replace(const SourceManager &SM, const CharSourceRange &Range,
+  llvm:

[PATCH] D31492: Add `replace` interface with range in AtomicChange.

2017-03-30 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Looks good and thanks for the cleanup.


https://reviews.llvm.org/D31492



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


[clang-tools-extra] r299071 - [clang-tidy] fix docs in hicpp checks

2017-03-30 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Thu Mar 30 07:59:41 2017
New Revision: 299071

URL: http://llvm.org/viewvc/llvm-project?rev=299071&view=rev
Log:
[clang-tidy] fix docs in hicpp checks

Fix for sphinx-doc warnings in r299068.

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-noexcept-move.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-noexcept-move.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-noexcept-move.rst?rev=299071&r1=299070&r2=299071&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-noexcept-move.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-noexcept-move.rst Thu 
Mar 30 07:59:41 2017
@@ -4,4 +4,4 @@ hicpp-noexcept-move
 ===
 
 This check is an alias for `misc-noexcept-moveconstructor 
`_.
-Checks `rule 12.5.4 
`_
 to mark move assignment and move construction `noexcept`.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=299071&r1=299070&r2=299071&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Thu Mar 30 07:59:41 
2017
@@ -53,7 +53,19 @@ Clang-Tidy Checks
google-runtime-memset
google-runtime-operator
google-runtime-references
+   hicpp-explicit-conversions
+   hicpp-function-size
+   hicpp-invalid-access-moved
+   hicpp-member-init
+   hicpp-named-parameter
+   hicpp-new-delete-operators
hicpp-no-assembler
+   hicpp-noexcept-move
+   hicpp-special-member-functions
+   hicpp-undelegated-constructor
+   hicpp-use-equals-default
+   hicpp-use-equals-delete
+   hicpp-use-override
llvm-header-guard
llvm-include-order
llvm-namespace-comment


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


[PATCH] D31328: [clangd] Add code completion support

2017-03-30 Thread Benjamin Kramer via Phabricator via cfe-commits
bkramer accepted this revision.
bkramer added a comment.

lg


https://reviews.llvm.org/D31328



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


r299073 - Add `replace` interface with range in AtomicChange.

2017-03-30 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Thu Mar 30 08:07:38 2017
New Revision: 299073

URL: http://llvm.org/viewvc/llvm-project?rev=299073&view=rev
Log:
Add `replace` interface with range in AtomicChange.

Reviewers: ioeric

Reviewed By: ioeric

Subscribers: alexshap, klimek, cfe-commits

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

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h?rev=299073&r1=299072&r2=299073&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h Thu Mar 30 
08:07:38 2017
@@ -70,6 +70,12 @@ public:
   /// \brief Returns the error message or an empty string if it does not exist.
   const std::string &getError() const { return Error; }
 
+  /// \brief Adds a replacement that replaces the given Range with
+  /// ReplacementText.
+  /// \returns An llvm::Error carrying ReplacementError on error.
+  llvm::Error replace(const SourceManager &SM, const CharSourceRange &Range,
+  llvm::StringRef ReplacementText);
+
   /// \brief Adds a replacement that replaces range [Loc, Loc+Length) with
   /// \p Text.
   /// \returns An llvm::Error carrying ReplacementError on error.

Modified: cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp?rev=299073&r1=299072&r2=299073&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp Thu Mar 30 08:07:38 2017
@@ -132,6 +132,12 @@ AtomicChange AtomicChange::convertFromYA
   return E;
 }
 
+llvm::Error AtomicChange::replace(const SourceManager &SM,
+  const CharSourceRange &Range,
+  llvm::StringRef ReplacementText) {
+  return Replaces.add(Replacement(SM, Range, ReplacementText));
+}
+
 llvm::Error AtomicChange::replace(const SourceManager &SM, SourceLocation Loc,
   unsigned Length, llvm::StringRef Text) {
   return Replaces.add(Replacement(SM, Loc, Length, Text));

Modified: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringTest.cpp?rev=299073&r1=299072&r2=299073&view=diff
==
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp Thu Mar 30 08:07:38 2017
@@ -1092,7 +1092,7 @@ TEST(DeduplicateByFileTest, NonExistingF
 
 class AtomicChangeTest : public ::testing::Test {
   protected:
-void setUp() {
+void SetUp() override {
   DefaultFileID = Context.createInMemoryFile("input.cpp", DefaultCode);
   DefaultLoc = Context.Sources.getLocForStartOfFile(DefaultFileID)
.getLocWithOffset(20);
@@ -1107,7 +1107,6 @@ class AtomicChangeTest : public ::testin
 };
 
 TEST_F(AtomicChangeTest, AtomicChangeToYAML) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err =
   Change.insert(Context.Sources, DefaultLoc, "aa", /*InsertAfter=*/false);
@@ -1140,7 +1139,6 @@ TEST_F(AtomicChangeTest, AtomicChangeToY
 }
 
 TEST_F(AtomicChangeTest, YAMLToAtomicChange) {
-  setUp();
   std::string YamlContent = "---\n"
 "Key: 'input.cpp:20'\n"
 "FilePath:input.cpp\n"
@@ -1187,14 +1185,12 @@ TEST_F(AtomicChangeTest, YAMLToAtomicCha
 }
 
 TEST_F(AtomicChangeTest, CheckKeyAndKeyFile) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   EXPECT_EQ("input.cpp:20", Change.getKey());
   EXPECT_EQ("input.cpp", Change.getFilePath());
 }
 
 TEST_F(AtomicChangeTest, Replace) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err = Change.replace(Context.Sources, DefaultLoc, 2, "aa");
   ASSERT_TRUE(!Err);
@@ -1209,8 +1205,18 @@ TEST_F(AtomicChangeTest, Replace) {
   EXPECT_EQ(Change.getReplacements().size(), 1u);
 }
 
+TEST_F(AtomicChangeTest, ReplaceWithRange) {
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  SourceLocation End = DefaultLoc.getLocWithOffset(20);
+  llvm::Error Err = Change.replace(
+  Context.Sources, CharSourceRange::getCharRange(DefaultLoc, End), "aa");
+  ASSERT_TRUE(!Err);
+  EXPECT_EQ(Change.getReplacements().size(), 1u);
+  EXPECT_EQ(*Change.getReplacements().begin(),
+Replacement(Context.Sources, DefaultLoc, 20, "aa"));
+}
+
 TEST_F(AtomicC

[PATCH] D31492: Add `replace` interface with range in AtomicChange.

2017-03-30 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299073: Add `replace` interface with range in AtomicChange. 
(authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D31492?vs=93472&id=93473#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31492

Files:
  cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
  cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
  cfe/trunk/unittests/Tooling/RefactoringTest.cpp

Index: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
===
--- cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
+++ cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
@@ -70,6 +70,12 @@
   /// \brief Returns the error message or an empty string if it does not exist.
   const std::string &getError() const { return Error; }
 
+  /// \brief Adds a replacement that replaces the given Range with
+  /// ReplacementText.
+  /// \returns An llvm::Error carrying ReplacementError on error.
+  llvm::Error replace(const SourceManager &SM, const CharSourceRange &Range,
+  llvm::StringRef ReplacementText);
+
   /// \brief Adds a replacement that replaces range [Loc, Loc+Length) with
   /// \p Text.
   /// \returns An llvm::Error carrying ReplacementError on error.
Index: cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
@@ -132,6 +132,12 @@
   return E;
 }
 
+llvm::Error AtomicChange::replace(const SourceManager &SM,
+  const CharSourceRange &Range,
+  llvm::StringRef ReplacementText) {
+  return Replaces.add(Replacement(SM, Range, ReplacementText));
+}
+
 llvm::Error AtomicChange::replace(const SourceManager &SM, SourceLocation Loc,
   unsigned Length, llvm::StringRef Text) {
   return Replaces.add(Replacement(SM, Loc, Length, Text));
Index: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
===
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp
@@ -1092,7 +1092,7 @@
 
 class AtomicChangeTest : public ::testing::Test {
   protected:
-void setUp() {
+void SetUp() override {
   DefaultFileID = Context.createInMemoryFile("input.cpp", DefaultCode);
   DefaultLoc = Context.Sources.getLocForStartOfFile(DefaultFileID)
.getLocWithOffset(20);
@@ -1107,7 +1107,6 @@
 };
 
 TEST_F(AtomicChangeTest, AtomicChangeToYAML) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err =
   Change.insert(Context.Sources, DefaultLoc, "aa", /*InsertAfter=*/false);
@@ -1140,7 +1139,6 @@
 }
 
 TEST_F(AtomicChangeTest, YAMLToAtomicChange) {
-  setUp();
   std::string YamlContent = "---\n"
 "Key: 'input.cpp:20'\n"
 "FilePath:input.cpp\n"
@@ -1187,14 +1185,12 @@
 }
 
 TEST_F(AtomicChangeTest, CheckKeyAndKeyFile) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   EXPECT_EQ("input.cpp:20", Change.getKey());
   EXPECT_EQ("input.cpp", Change.getFilePath());
 }
 
 TEST_F(AtomicChangeTest, Replace) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err = Change.replace(Context.Sources, DefaultLoc, 2, "aa");
   ASSERT_TRUE(!Err);
@@ -1209,8 +1205,18 @@
   EXPECT_EQ(Change.getReplacements().size(), 1u);
 }
 
+TEST_F(AtomicChangeTest, ReplaceWithRange) {
+  AtomicChange Change(Context.Sources, DefaultLoc);
+  SourceLocation End = DefaultLoc.getLocWithOffset(20);
+  llvm::Error Err = Change.replace(
+  Context.Sources, CharSourceRange::getCharRange(DefaultLoc, End), "aa");
+  ASSERT_TRUE(!Err);
+  EXPECT_EQ(Change.getReplacements().size(), 1u);
+  EXPECT_EQ(*Change.getReplacements().begin(),
+Replacement(Context.Sources, DefaultLoc, 20, "aa"));
+}
+
 TEST_F(AtomicChangeTest, InsertBefore) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err = Change.insert(Context.Sources, DefaultLoc, "aa");
   ASSERT_TRUE(!Err);
@@ -1225,7 +1231,6 @@
 }
 
 TEST_F(AtomicChangeTest, InsertAfter) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err = Change.insert(Context.Sources, DefaultLoc, "aa");
   ASSERT_TRUE(!Err);
@@ -1240,7 +1245,6 @@
 }
 
 TEST_F(AtomicChangeTest, InsertBeforeWithInvalidLocation) {
-  setUp();
   AtomicChange Change(Context.Sources, DefaultLoc);
   llvm::Error Err =
   Change.insert(Context.Sources, DefaultLoc, "a", /*InsertAfter=*/false);
@@ -1254,11 +1258,9 @@
   std::move(Err), replacement_error::wrong_file_path,
   Replacement(Context.Sources, DefaultLoc, 0, "a"),
   Replacement(Context.

[clang-tools-extra] r299074 - Spelling mistakes in comments. NFCI.

2017-03-30 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Mar 30 08:10:33 2017
New Revision: 299074

URL: http://llvm.org/viewvc/llvm-project?rev=299074&view=rev
Log:
Spelling mistakes in comments. NFCI.

Based on corrections mentioned in patch for clang for PR27635

Modified:
clang-tools-extra/trunk/clang-rename/USRFinder.cpp
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/NoMallocCheck.h
clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp
clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h

Modified: clang-tools-extra/trunk/clang-rename/USRFinder.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/USRFinder.cpp?rev=299074&r1=299073&r2=299074&view=diff
==
--- clang-tools-extra/trunk/clang-rename/USRFinder.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/USRFinder.cpp Thu Mar 30 08:10:33 2017
@@ -27,7 +27,7 @@ namespace rename {
 
 // NamedDeclFindingASTVisitor recursively visits each AST node to find the
 // symbol underneath the cursor.
-// FIXME: move to seperate .h/.cc file if this gets too large.
+// FIXME: move to separate .h/.cc file if this gets too large.
 namespace {
 class NamedDeclFindingASTVisitor
 : public clang::RecursiveASTVisitor {

Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/NoMallocCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/NoMallocCheck.h?rev=299074&r1=299073&r2=299074&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/NoMallocCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/NoMallocCheck.h Thu 
Mar 30 08:10:33 2017
@@ -44,13 +44,13 @@ public:
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
 private:
-  /// Semicolon-seperated list of fully qualified names of memory allocation
+  /// Semicolon-separated list of fully qualified names of memory allocation
   /// functions the check warns about. Defaults to `::malloc;::calloc`.
   const std::string AllocList;
-  /// Semicolon-seperated list of fully qualified names of memory reallocation 
+  /// Semicolon-separated list of fully qualified names of memory reallocation
   /// functions the check warns about. Defaults to `::realloc`.
   const std::string ReallocList;
-  /// Semicolon-seperated list of fully qualified names of memory deallocation 
+  /// Semicolon-separated list of fully qualified names of memory deallocation
   /// functions the check warns about. Defaults to `::free`.
   const std::string DeallocList;
 };

Modified: clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp?rev=299074&r1=299073&r2=299074&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/utils/HeaderGuard.cpp Thu Mar 30 
08:10:33 2017
@@ -76,7 +76,7 @@ public:
 
   // We use clang's header guard detection. This has the advantage of also
   // emitting a warning for cases where a pseudo header guard is found but
-  // preceeded by something blocking the header guard optimization.
+  // preceded by something blocking the header guard optimization.
   if (!MI->isUsedForHeaderGuard())
 continue;
 

Modified: clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h?rev=299074&r1=299073&r2=299074&view=diff
==
--- clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h (original)
+++ clang-tools-extra/trunk/include-fixer/SymbolIndexManager.h Thu Mar 30 
08:10:33 2017
@@ -30,7 +30,7 @@ namespace clang {
 namespace include_fixer {
 
 /// This class provides an interface for finding the header files corresponding
-/// to an indentifier in the source code from multiple symbol databases.
+/// to an identifier in the source code from multiple symbol databases.
 class SymbolIndexManager {
 public:
   void addSymbolIndex(std::function()> F) {


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


[PATCH] D31176: [clang-rename] Support renaming qualified symbol

2017-03-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 93474.
hokein marked 2 inline comments as done.
hokein added a comment.

Fix a few nits.


https://reviews.llvm.org/D31176

Files:
  clang-rename/CMakeLists.txt
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/USRFinder.cpp
  clang-rename/USRFindingAction.cpp
  clang-rename/USRLocFinder.cpp
  clang-rename/USRLocFinder.h
  unittests/clang-rename/CMakeLists.txt
  unittests/clang-rename/ClangRenameTest.h
  unittests/clang-rename/ClangRenameTests.cpp
  unittests/clang-rename/RenameClassTest.cpp

Index: unittests/clang-rename/RenameClassTest.cpp
===
--- /dev/null
+++ unittests/clang-rename/RenameClassTest.cpp
@@ -0,0 +1,668 @@
+//===-- RenameClassTest.cpp - unit tests for renaming classes -===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "ClangRenameTest.h"
+
+namespace clang {
+namespace clang_rename {
+namespace test {
+namespace {
+
+class RenameClassTest : public ClangRenameTest {
+public:
+  RenameClassTest() {
+AppendToHeader(R"(
+  namespace a {
+class Foo {
+  public:
+struct Nested {
+  enum NestedEnum {E1, E2};
+};
+void func() {}
+  static int Constant;
+};
+class Goo {
+  public:
+struct Nested {
+  enum NestedEnum {E1, E2};
+};
+};
+int Foo::Constant = 1;
+  } // namespace a
+  namespace b {
+  class Foo {};
+  } // namespace b
+
+  #define MACRO(x) x
+
+  template class ptr {};
+)");
+  }
+};
+
+INSTANTIATE_TEST_CASE_P(
+RenameClassTests, RenameClassTest,
+testing::ValuesIn(std::vector({
+// basic classes
+{"a::Foo f;", "b::Bar f;"},
+{"void f(a::Foo f) {}", "void f(b::Bar f) {}"},
+{"void f(a::Foo *f) {}", "void f(b::Bar *f) {}"},
+{"a::Foo f() { return a::Foo(); }", "b::Bar f() { return b::Bar(); }"},
+{"namespace a {a::Foo f() { return Foo(); }}",
+ "namespace a {b::Bar f() { return b::Bar(); }}"},
+{"void f(const a::Foo& a1) {}", "void f(const b::Bar& a1) {}"},
+{"void f(const a::Foo* a1) {}", "void f(const b::Bar* a1) {}"},
+{"namespace a { void f(Foo a1) {} }",
+ "namespace a { void f(b::Bar a1) {} }"},
+{"void f(MACRO(a::Foo) a1) {}", "void f(MACRO(b::Bar) a1) {}"},
+{"void f(MACRO(a::Foo a1)) {}", "void f(MACRO(b::Bar a1)) {}"},
+{"a::Foo::Nested ns;", "b::Bar::Nested ns;"},
+{"auto t = a::Foo::Constant;", "auto t = b::Bar::Constant;"},
+{"a::Foo::Nested ns;", "a::Foo::Nested2 ns;", "a::Foo::Nested",
+ "a::Foo::Nested2"},
+
+// use namespace and typedefs
+{"using a::Foo; Foo gA;", "using b::Bar; b::Bar gA;"},
+{"using a::Foo; void f(Foo gA) {}", "using b::Bar; void f(Bar gA) {}"},
+{"using a::Foo; namespace x { Foo gA; }",
+ "using b::Bar; namespace x { Bar gA; }"},
+{"struct S { using T = a::Foo; T a_; };",
+ "struct S { using T = b::Bar; T a_; };"},
+{"using T = a::Foo; T gA;", "using T = b::Bar; T gA;"},
+{"typedef a::Foo T; T gA;", "typedef b::Bar T; T gA;"},
+{"typedef MACRO(a::Foo) T; T gA;", "typedef MACRO(b::Bar) T; T gA;"},
+
+// struct members and other oddities
+{"struct S : public a::Foo {};", "struct S : public b::Bar {};"},
+{"struct F { void f(a::Foo a1) {} };",
+ "struct F { void f(b::Bar a1) {} };"},
+{"struct F { a::Foo a_; };", "struct F { b::Bar a_; };"},
+{"struct F { ptr a_; };", "struct F { ptr a_; };"},
+
+{"void f() { a::Foo::Nested ne; }", "void f() { b::Bar::Nested ne; }"},
+{"void f() { a::Goo::Nested ne; }", "void f() { a::Goo::Nested ne; }"},
+{"void f() { a::Foo::Nested::NestedEnum e; }",
+ "void f() { b::Bar::Nested::NestedEnum e; }"},
+{"void f() { auto e = a::Foo::Nested::NestedEnum::E1; }",
+ "void f() { auto e = b::Bar::Nested::NestedEnum::E1; }"},
+{"void f() { auto e = a::Foo::Nested::E1; }",
+ "void f() { auto e = b::Bar::Nested::E1; }"},
+
+// templates
+{"template  struct Foo { T t; };\n"
+ "void f() { Foo foo; }",
+ "template  struct Foo { T t; };\n"
+ "void f() { Foo foo; }"},
+{"template  struct Foo { a::Foo a; };",
+ "template  struct Foo { b::Bar a; };"},
+{"template  void f(T t) {}\n"
+ "void g() { f(a::Foo()); }",
+ "template  void f(T t) {}\n"
+ "void g() { f(b::Bar()); }"},
+{"template  int f() { return 1; }\n"
+ "template <> int f() { return 2; }\n"
+   

[PATCH] D31492: Add `replace` interface with range in AtomicChange.

2017-03-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

> are the tools like clang-rename, change-namespace and clang-reorder-fields 
> supposed to use AtomicChange (via the methods insert, replace etc) ?

Yeah. We are using AtomicChange in clang-rename refinement 
(https://reviews.llvm.org/D31176).


Repository:
  rL LLVM

https://reviews.llvm.org/D31492



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


r299078 - [Sema][ObjC] Avoid the "type of property does not match type of accessor"

2017-03-30 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Mar 30 08:33:51 2017
New Revision: 299078

URL: http://llvm.org/viewvc/llvm-project?rev=299078&view=rev
Log:
[Sema][ObjC] Avoid the "type of property does not match type of accessor"
warning for methods that resemble the setters of readonly properties

rdar://30415679

Modified:
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/test/SemaObjC/property-typecheck-1.m

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=299078&r1=299077&r2=299078&view=diff
==
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Thu Mar 30 08:33:51 2017
@@ -2185,12 +2185,9 @@ void Sema::ProcessPropertyDecl(ObjCPrope
   DiagnosePropertyAccessorMismatch(property, GetterMethod,
property->getLocation());
 
-  if (SetterMethod) {
-ObjCPropertyDecl::PropertyAttributeKind CAttr =
-  property->getPropertyAttributes();
-if ((!(CAttr & ObjCPropertyDecl::OBJC_PR_readonly)) &&
-Context.getCanonicalType(SetterMethod->getReturnType()) !=
-Context.VoidTy)
+  if (!property->isReadOnly() && SetterMethod) {
+if (Context.getCanonicalType(SetterMethod->getReturnType()) !=
+Context.VoidTy)
   Diag(SetterMethod->getLocation(), diag::err_setter_type_void);
 if (SetterMethod->param_size() != 1 ||
 !Context.hasSameUnqualifiedType(

Modified: cfe/trunk/test/SemaObjC/property-typecheck-1.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/property-typecheck-1.m?rev=299078&r1=299077&r2=299078&view=diff
==
--- cfe/trunk/test/SemaObjC/property-typecheck-1.m (original)
+++ cfe/trunk/test/SemaObjC/property-typecheck-1.m Thu Mar 30 08:33:51 2017
@@ -78,6 +78,11 @@ typedef void (F)(void);
 
 - (NSMutableArray*) pieces; // expected-note 2 {{declared here}}
 - (NSArray*) first;
+
+// Don't warn about setter-like methods for readonly properties.
+- (void)setFirst:(char)val;
+- (void)setPieces:(char)val;
+
 @end
 
 @interface Class2  {


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


r299079 - Move NumRegParameters Module Flag. NFCI.

2017-03-30 Thread Nirav Dave via cfe-commits
Author: niravd
Date: Thu Mar 30 08:41:44 2017
New Revision: 299079

URL: http://llvm.org/viewvc/llvm-project?rev=299079&view=rev
Log:
Move NumRegParameters Module Flag. NFCI.

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

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=299079&r1=299078&r2=299079&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Mar 30 08:41:44 2017
@@ -159,12 +159,6 @@ CodeGenModule::CodeGenModule(ASTContext
   // CoverageMappingModuleGen object.
   if (CodeGenOpts.CoverageMapping)
 CoverageMapping.reset(new CoverageMappingModuleGen(*this, *CoverageInfo));
-
-  // Record mregparm value now so it is visible through rest of codegen.
-  if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86)
-getModule().addModuleFlag(llvm::Module::Error, "NumRegisterParameters",
-  CodeGenOpts.NumRegisterParameters);
-
 }
 
 CodeGenModule::~CodeGenModule() {}
@@ -424,6 +418,11 @@ void CodeGenModule::Release() {
 EmitModuleLinkOptions();
   }
 
+  // Record mregparm value now so it is visible through rest of codegen.
+  if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86)
+getModule().addModuleFlag(llvm::Module::Error, "NumRegisterParameters",
+  CodeGenOpts.NumRegisterParameters);
+  
   if (CodeGenOpts.DwarfVersion) {
 // We actually want the latest version when there are conflicts.
 // We can change from Warning to Latest if such mode is supported.


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


r299080 - [ARC][ObjC++] Use ObjC semantic rules for comparisons between a pointer and

2017-03-30 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu Mar 30 08:48:33 2017
New Revision: 299080

URL: http://llvm.org/viewvc/llvm-project?rev=299080&view=rev
Log:
[ARC][ObjC++] Use ObjC semantic rules for comparisons between a pointer and
an ObjC object pointer

When ARC is enabled in Objective-C++, comparisons between a pointer and
Objective-C object pointer typically result in errors like this:
"invalid operands to a binary expression". This error message can be quite
confusing as it doesn't provide a solution to the problem, unlike the non-C++
diagnostic: "implicit conversion of Objective-C pointer type 'id' to C pointer
type 'void *' requires a bridged cast" (it also provides fix-its). This commit
forces comparisons between pointers and Objective-C object pointers in ARC to
use the Objective-C semantic rules to ensure that a better diagnostic is
reported.

rdar://31103857

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

Added:
cfe/trunk/test/SemaObjCXX/arc-ptr-comparison.mm
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=299080&r1=299079&r2=299080&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Mar 30 08:48:33 2017
@@ -9423,7 +9423,10 @@ QualType Sema::CheckCompareOperands(Expr
 //   If both operands are pointers, [...] bring them to their composite
 //   pointer type.
 if ((int)LHSType->isPointerType() + (int)RHSType->isPointerType() >=
-(IsRelational ? 2 : 1)) {
+(IsRelational ? 2 : 1) &&
+(!LangOpts.ObjCAutoRefCount ||
+ !(LHSType->isObjCObjectPointerType() ||
+   RHSType->isObjCObjectPointerType( {
   if (convertPointersToCompositeType(*this, Loc, LHS, RHS))
 return QualType();
   else

Added: cfe/trunk/test/SemaObjCXX/arc-ptr-comparison.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/arc-ptr-comparison.mm?rev=299080&view=auto
==
--- cfe/trunk/test/SemaObjCXX/arc-ptr-comparison.mm (added)
+++ cfe/trunk/test/SemaObjCXX/arc-ptr-comparison.mm Thu Mar 30 08:48:33 2017
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-fobjc-arc -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-verify -DNOARC %s
+#ifdef NOARC
+// expected-no-diagnostics
+#endif
+
+int testObjCComparisonRules(void *v, id x, id y) {
+  return v == x;
+#ifndef NOARC
+// expected-error@-2 {{implicit conversion of Objective-C pointer type 'id' to 
C pointer type 'void *' requires a bridged cast}}
+// expected-note@-3 {{use __bridge to convert directly (no change in 
ownership)}}
+// expected-note@-4 {{use __bridge_retained to make an ARC object available as 
a +1 'void *'}}
+#endif
+  return v >= x;
+#ifndef NOARC
+// expected-error@-2 {{implicit conversion of Objective-C pointer type 'id' to 
C pointer type 'void *' requires a bridged cast}}
+// expected-note@-3 {{use __bridge to convert directly (no change in 
ownership)}}
+// expected-note@-4 {{use __bridge_retained to make an ARC object available as 
a +1 'void *'}}
+#endif
+  return v == (id)(void *)0; // OK
+  return v == nullptr; // OK
+  return v == (void *)0;
+  return x == y;
+}


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


[PATCH] D31177: [ARC][ObjC++] Use ObjC semantic rules for comparisons between a pointer and objective-c object pointer

2017-03-30 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299080: [ARC][ObjC++] Use ObjC semantic rules for 
comparisons between a pointer and (authored by arphaman).

Changed prior to commit:
  https://reviews.llvm.org/D31177?vs=92783&id=93475#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31177

Files:
  cfe/trunk/lib/Sema/SemaExpr.cpp
  cfe/trunk/test/SemaObjCXX/arc-ptr-comparison.mm


Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -9423,7 +9423,10 @@
 //   If both operands are pointers, [...] bring them to their composite
 //   pointer type.
 if ((int)LHSType->isPointerType() + (int)RHSType->isPointerType() >=
-(IsRelational ? 2 : 1)) {
+(IsRelational ? 2 : 1) &&
+(!LangOpts.ObjCAutoRefCount ||
+ !(LHSType->isObjCObjectPointerType() ||
+   RHSType->isObjCObjectPointerType( {
   if (convertPointersToCompositeType(*this, Loc, LHS, RHS))
 return QualType();
   else
Index: cfe/trunk/test/SemaObjCXX/arc-ptr-comparison.mm
===
--- cfe/trunk/test/SemaObjCXX/arc-ptr-comparison.mm
+++ cfe/trunk/test/SemaObjCXX/arc-ptr-comparison.mm
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-fobjc-arc -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only 
-verify -DNOARC %s
+#ifdef NOARC
+// expected-no-diagnostics
+#endif
+
+int testObjCComparisonRules(void *v, id x, id y) {
+  return v == x;
+#ifndef NOARC
+// expected-error@-2 {{implicit conversion of Objective-C pointer type 'id' to 
C pointer type 'void *' requires a bridged cast}}
+// expected-note@-3 {{use __bridge to convert directly (no change in 
ownership)}}
+// expected-note@-4 {{use __bridge_retained to make an ARC object available as 
a +1 'void *'}}
+#endif
+  return v >= x;
+#ifndef NOARC
+// expected-error@-2 {{implicit conversion of Objective-C pointer type 'id' to 
C pointer type 'void *' requires a bridged cast}}
+// expected-note@-3 {{use __bridge to convert directly (no change in 
ownership)}}
+// expected-note@-4 {{use __bridge_retained to make an ARC object available as 
a +1 'void *'}}
+#endif
+  return v == (id)(void *)0; // OK
+  return v == nullptr; // OK
+  return v == (void *)0;
+  return x == y;
+}


Index: cfe/trunk/lib/Sema/SemaExpr.cpp
===
--- cfe/trunk/lib/Sema/SemaExpr.cpp
+++ cfe/trunk/lib/Sema/SemaExpr.cpp
@@ -9423,7 +9423,10 @@
 //   If both operands are pointers, [...] bring them to their composite
 //   pointer type.
 if ((int)LHSType->isPointerType() + (int)RHSType->isPointerType() >=
-(IsRelational ? 2 : 1)) {
+(IsRelational ? 2 : 1) &&
+(!LangOpts.ObjCAutoRefCount ||
+ !(LHSType->isObjCObjectPointerType() ||
+   RHSType->isObjCObjectPointerType( {
   if (convertPointersToCompositeType(*this, Loc, LHS, RHS))
 return QualType();
   else
Index: cfe/trunk/test/SemaObjCXX/arc-ptr-comparison.mm
===
--- cfe/trunk/test/SemaObjCXX/arc-ptr-comparison.mm
+++ cfe/trunk/test/SemaObjCXX/arc-ptr-comparison.mm
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin11 -fsyntax-only -verify -DNOARC %s
+#ifdef NOARC
+// expected-no-diagnostics
+#endif
+
+int testObjCComparisonRules(void *v, id x, id y) {
+  return v == x;
+#ifndef NOARC
+// expected-error@-2 {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}}
+// expected-note@-3 {{use __bridge to convert directly (no change in ownership)}}
+// expected-note@-4 {{use __bridge_retained to make an ARC object available as a +1 'void *'}}
+#endif
+  return v >= x;
+#ifndef NOARC
+// expected-error@-2 {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}}
+// expected-note@-3 {{use __bridge to convert directly (no change in ownership)}}
+// expected-note@-4 {{use __bridge_retained to make an ARC object available as a +1 'void *'}}
+#endif
+  return v == (id)(void *)0; // OK
+  return v == nullptr; // OK
+  return v == (void *)0;
+  return x == y;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-03-30 Thread Dan Liew via Phabricator via cfe-commits
delcypher added a comment.

I'm a little late to the review but hopefully I'll have useful comments. Nice 
work @ddc

> I looked around for a generic smt-lib interface earlier, but couldn't find 
> much available, and since I wanted floating-point arithmetic support, I ended 
> up just directly using the Z3 C interface (the C++ interface uses exceptions, 
> which causes problems). As far as I know, CVC4 doesn't have built-in 
> floating-point support. But longer term, I'd agree that this backend should 
> be made more generic.

FYI I've been working on floating point support in KLEE and have extended it to 
support floating point (note however only the Z3 backend actually supports 
consuming floating point constraints). I've not yet open sourced what I've done 
as I'm not entirely happy with the design but if there is interest we could see 
if we could figure out a way of pulling `klee::Expr` (and the solver bits) out 
of KLEE to make a standalone library. Note there is a project called `metaSMT` 
that uses template meta programming to give the same interface to multiple 
solvers. KLEE does support it but I'm not familiar with it.

Also using Z3's C interface is the way to go. We also use this in KLEE.


https://reviews.llvm.org/D28952



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


Re: r299079 - Move NumRegParameters Module Flag. NFCI.

2017-03-30 Thread Yaron Keren via cfe-commits
Thanks!
If you like, might make sense now to move all these addModuleFlag() into a
new helper function, addModuleFlags().


‫בתאריך יום ה׳, 30 במרץ 2017 ב-16:54 מאת ‪Nirav Dave via cfe-commits‬‏ <‪
cfe-commits@lists.llvm.org‬‏>:‬

> Author: niravd
> Date: Thu Mar 30 08:41:44 2017
> New Revision: 299079
>
> URL: http://llvm.org/viewvc/llvm-project?rev=299079&view=rev
> Log:
> Move NumRegParameters Module Flag. NFCI.
>
> Modified:
> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=299079&r1=299078&r2=299079&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Mar 30 08:41:44 2017
> @@ -159,12 +159,6 @@ CodeGenModule::CodeGenModule(ASTContext
>// CoverageMappingModuleGen object.
>if (CodeGenOpts.CoverageMapping)
>  CoverageMapping.reset(new CoverageMappingModuleGen(*this,
> *CoverageInfo));
> -
> -  // Record mregparm value now so it is visible through rest of codegen.
> -  if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86)
> -getModule().addModuleFlag(llvm::Module::Error,
> "NumRegisterParameters",
> -  CodeGenOpts.NumRegisterParameters);
> -
>  }
>
>  CodeGenModule::~CodeGenModule() {}
> @@ -424,6 +418,11 @@ void CodeGenModule::Release() {
>  EmitModuleLinkOptions();
>}
>
> +  // Record mregparm value now so it is visible through rest of codegen.
> +  if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86)
> +getModule().addModuleFlag(llvm::Module::Error,
> "NumRegisterParameters",
> +  CodeGenOpts.NumRegisterParameters);
> +
>if (CodeGenOpts.DwarfVersion) {
>  // We actually want the latest version when there are conflicts.
>  // We can change from Warning to Latest if such mode is supported.
>
>
> ___
> 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


r299083 - Spelling mistakes in comments. NFCI. (PR27635)

2017-03-30 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Thu Mar 30 09:13:19 2017
New Revision: 299083

URL: http://llvm.org/viewvc/llvm-project?rev=299083&view=rev
Log:
Spelling mistakes in comments. NFCI. (PR27635)

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/include/clang/ASTMatchers/Dynamic/VariantValue.h
cfe/trunk/include/clang/CodeGen/CodeGenABITypes.h
cfe/trunk/include/clang/Driver/Tool.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.h
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/Analysis/ThreadSafetyTIL.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGCXXABI.h
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.h
cfe/trunk/lib/CodeGen/CodeGenModule.h
cfe/trunk/lib/CodeGen/EHScopeStack.h
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteMacros.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
cfe/trunk/lib/Parse/ParseStmtAsm.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Serialization/ModuleManager.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
cfe/trunk/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=299083&r1=299082&r2=299083&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Mar 30 09:13:19 2017
@@ -476,7 +476,7 @@ private:
   /// entities should not be instrumented.
   std::unique_ptr SanitizerBL;
 
-  /// \breif Function filtering mehcanism to determine whether a given function
+  /// \brief Function filtering mehcanism to determine whether a given function
   /// should be imbued with the XRay "always" or "never" attributes.
   std::unique_ptr XRayFilter;
 

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=299083&r1=299082&r2=299083&view=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Mar 30 09:13:19 2017
@@ -838,7 +838,7 @@ protected:
 
 /// Describes the kind of default argument for this parameter. By default
 /// this is none. If this is normal, then the default argument is stored in
-/// the \c VarDecl initalizer expression unless we were unble to parse
+/// the \c VarDecl initializer expression unless we were unble to parse
 /// (even an invalid) expression for the default argument.
 unsigned DefaultArgKind : 2;
 

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=299083&r1=299082&r2=299083&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Mar 30 09:13:19 2017
@@ -2079,7 +2079,7 @@ public:
 : Type(Builtin, QualType(), /*Dependent=*/(K == Dependent),
/*InstantiationDependent=*/(K == Dependent),
/*VariablyModified=*/false,
-   /*Unexpanded paramter pack=*/false) {
+   /*Unexpanded parameter pack=*/false) {
 BuiltinTypeBits.Kind = K;
   }
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=299083&r1=299082&r2=299083&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Mar 30 09:13:19 2017
@@ -2595,7 +2595,7 @@ AST_MATCHER_P(CXXMemberCallExpr, on, int
 /// \brief Matches on the receiver of an ObjectiveC Message expression.
 ///
 /// Example
-/// matcher = objCMessageExpr(hasRecieverType(asString("UIWebView *")));
+/// matcher = objCMessageExpr(hasReceive

[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-03-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: include/clang/AST/ASTContext.h:2319
 return AddrSpaceMapMangling || 
-   AS < LangAS::Offset || 
-   AS >= LangAS::Offset + LangAS::Count;
+   AS > LangAS::target_first;
   }

t-tye wrote:
> Should this be >= since it wants to return for all target address spaces, and 
> target_first is the first one?
Will do.



Comment at: include/clang/AST/Type.h:336-342
+  /// Get the address space value used in diagnostics.
+  unsigned getAddressSpacePrintValue() const {
+unsigned AS = getAddressSpace();
+if (AS >= LangAS::target_first)
+  return AS - LangAS::target_first;
+return AS;
+  }

t-tye wrote:
> Is this the right thing to do? This is making the CLANG named address spaces 
> have the same numbers as the target-specific address space numbers which 
> would seem rather confusing.
> 
> What do the diagnostics want to display? For example, they could display the 
> address space as a human readable form such as "Default", "OpenCL-global", 
> CUDA-device", "target-specific(5)", etc. To do that this function could take 
> an iostream and a LangAS value and use << to write to the iostream.
This function is used by diagnostics for address spaces specified by 
`__attribute__((address_space(n)))`. There are several lit tests for that, e.g. 

https://github.com/llvm-mirror/clang/blob/master/test/SemaCXX/address-space-newdelete.cpp
https://github.com/llvm-mirror/clang/blob/master/test/SemaCXX/address-space-references.cpp

It is desirable to use the same value as specified by the attribute, otherwise 
it may confuse the user.


https://reviews.llvm.org/D31404



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


[PATCH] D31487: [coroutines] Fix rebuilding of implicit and dependent coroutine statements.

2017-03-30 Thread Gor Nishanov via Phabricator via cfe-commits
GorNishanov added inline comments.



Comment at: lib/Sema/CoroutineBuilder.h:53
+assert(this->IsValid && "coroutine already invalid");
+this->IsValid = makeReturnObject() && makeParamMoves();
+if (this->IsValid && !IsPromiseDependentType)

makeReturnObject is built as $promise.get_return_object() should it be put into 
buildDependentStatements?



https://reviews.llvm.org/D31487



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


[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-03-30 Thread Dan Liew via Phabricator via cfe-commits
delcypher added a comment.

In https://reviews.llvm.org/D28952#655337, @dcoughlin wrote:

> In https://reviews.llvm.org/D28952#655278, @ddcc wrote:
>
> > > - That said, I think there are still significant optimization 
> > > opportunities. It looks like when performing a query you create a new 
> > > solver for each set of constraints. My understanding (and perhaps @nlopes 
> > > can correct me here) is that these days Z3 is quite good at incremental 
> > > solves so you may be leaving a lot of performance on the table. For 
> > > example, in `getSymVal()` you create one solver to query for a satisfying 
> > > assignment and then later create a completely new one to determine 
> > > whether it is the only satisfying assignment. Since those two queries 
> > > share all of their conjuncts but one it might be faster to reuse the 
> > > first solver and add the new assertion for the second. Similarly, since 
> > > analyzer exploration is a DFS, you could imagine building up the path 
> > > condition incrementally. Z3 has solver APIs for pushing and popping 
> > > assertions. (Again, @nlopes may have a better idea of whether this would 
> > > pay off in practice.)
> >
> > I agree that the performance is the main problem, and that there are still 
> > a lot of performance optimizations available. I've separated the Z3 solver 
> > and model into separate classes, and reuse the solver now in `getSymVal()` 
> > and `checkNull()`. I looked at using the push/pop approach briefly when I 
> > started writing the solver, but since the static analyzer itself seems to 
> > have an internal worklist, I wasn't sure if the state traversal order is 
> > deterministic and predictable, so I didn't try to reuse a single solver 
> > across all program states. This is the new timing:
> >
> > Z3ConstraintManager (built-in, previous changes and solver state reuse): 
> > 202.37 sec
>
>
> The improvement here (200s vs. 250s) makes me think that some form of 
> caching/incrementalization could pay off.


KLEE has a few optimization ideas that you could consider implementing that 
certainly help in the context of symbolic execution.

- Constraint independence. This splits a set of constraints into independent 
constraints and solves them separately. This can be useful for further 
processing (e.g. increases the likely hood of a cache hit)
- "CounterExampleCache" . The naming is rather unfortunate and confusing 
(because KLEE works in terms of validity rather than satisfiability). The idea 
is to cache models for solver queries that are SAT (i.e. maintain a mapping 
from models to satisfying assignments with a sentinel to indicate when a query 
does not have a satisfying assignment) and when handling future queries
- If the new query is in the existing cache if it has a model it is SAT 
otherwise it is UNSAT.
- If the new query is a superset of an existing query in the cache then: If 
there was no model for the cached query then the super set query is also UNSAT. 
If there is a model for the original query try substituting it into the query 
(along with a deterministic values for symbolic values in the new query that 
aren't in the model) to try to quickly check if the cached model also satisfies 
the superset. If this fails then call the real solver
- If the new query is a subset of an existing query in the cache then: If there 
is a model for the cached query then that model will also satisfying the new 
query. If there is no model then the new query is UNSAT.

KLEE also does very aggressive constant folding and expression canonicalization 
to try to get more cache hits and have smaller constraints.


https://reviews.llvm.org/D28952



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


Re: r299058 - [APInt] Remove references to integerPartWidth and integerPart outside of APFloat implentation.

2017-03-30 Thread David Majnemer via cfe-commits
On Thu, Mar 30, 2017 at 7:48 AM, Craig Topper via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ctopper
> Date: Thu Mar 30 00:48:58 2017
> New Revision: 299058
>
> URL: http://llvm.org/viewvc/llvm-project?rev=299058&view=rev
> Log:
> [APInt] Remove references to integerPartWidth and integerPart outside of
> APFloat implentation.
>
> Turns out integerPartWidth only explicitly defines the width of the tc
> functions in the APInt class. Functions that aren't used by APInt
> implementation itself. Many places in the code base already assume APInt is
> made up of 64-bit pieces. Explicitly assuming 64-bit here doesn't make that
> situation much worse. A full audit would need to be done if it ever changes.
>
> Modified:
> cfe/trunk/lib/AST/ItaniumMangle.cpp
>
> Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ItaniumMangle.cpp?rev=299058&r1=299057&r2=299058&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
> +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Thu Mar 30 00:48:58 2017
> @@ -982,9 +982,8 @@ void CXXNameMangler::mangleFloat(const l
>  unsigned digitBitIndex = 4 * (numCharacters - stringIndex - 1);
>
>  // Project out 4 bits starting at 'digitIndex'.
> -llvm::integerPart hexDigit
> -  = valueBits.getRawData()[digitBitIndex / llvm::integerPartWidth];
> -hexDigit >>= (digitBitIndex % llvm::integerPartWidth);
> +uint64_t hexDigit = valueBits.getRawData()[digitBitIndex / 64];
> +hexDigit >>= (digitBitIndex % 64);
>

Would be nice to use APINT_BITS_PER_WORD to make this coupling more
explicit.


>  hexDigit &= 0xF;
>
>  // Map that over to a lowercase hex digit.
>
>
> ___
> 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


[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-03-30 Thread Dan Liew via Phabricator via cfe-commits
delcypher added inline comments.



Comment at: CMakeLists.txt:188
 
+find_package(Z3 4.5)
+

@ddcc It is of course up to you but I recently [[ added support for using 
`libz3` directly | added support for using `libz3` directly ]] from CMake. via 
it's own CMake config package. You only get this if Z3 was built with CMake so 
you might not want this restriction.  This feature has only just landed though 
and might not be sufficient for your needs.  If you take a look at Z3's example 
projects they are now built with this mechanism when building with CMake.

If you are interested I'd be more than happy to work with you to get this 
feature ready for your needs in upstream Z3 so you can use it here.



Comment at: include/clang/Config/config.h.cmake:42
+/* Define if we have z3 and want to build it */
+#cmakedefine CLANG_ANALYZER_WITH_Z3 ${CLANG_ANALYZER_WITH_Z3}
+

Do you really want such a specific name? How about 
`CLANG_ANALYSER_HAS_SMT_SOLVER`?



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:70
+public:
+  static Z3_context ZC;
+

@ddc
This decision of having a global context might come back to bite you. 
Especially if you switch to doing parallel solving in the future. This is why 
KLEE's `Z3ASTHandle` and `Z3SortHandle` store the context so it's possible to 
use different context.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:81
+
+class Z3Expr {
+  friend class Z3Model;

@ddcc 
[[ 
https://github.com/klee/klee/blob/1f13e9dbf9db2095b6612a47717c2b86e4aaba72/lib/Solver/Z3Builder.h#L20
 | In KLEE I have something similar to represent Z3Expr ]] called Z3ASTHandle 
and Z3SortHandle for doing manual reference counting. You might want to take a 
look at. I don't see you doing reference counting on sorts here so I think you 
might be leaking memory.

We also have a handy `dump()` method on `Z3ASTHandle` and `Z3SortHandle` for 
debugging.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:113
+  // Determine whether two float semantics are equivalent
+  static bool areEquivalent(const llvm::fltSemantics &LHS,
+const llvm::fltSemantics &RHS) {

@ddcc Of course this is fine for now but I think we really need to fix the 
APFloat API. I use it heavily myself and I've come across problems with it such 
as this one.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:160
+  return llvm::APFloat::IEEEdouble();
+case 128:
+  return llvm::APFloat::IEEEquad();

128 is actually ambiguous. It could also be `ppc_fp128`. I had the same problem 
in KLEE and for now I just assumed IEEEQuad like you have done but at the very 
least we should leave a comment here noting that this should be fixed some how.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:438
+// Logical operators
+case BO_LAnd: {
+  Z3_ast Args[] = {LHS.AST, RHS.AST};

@ddcc Isn't this repeating some of the logic in `fromBinOp()`?



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:559
+  Float.toString(Chars, 0, 0);
+  AST = Z3_mk_numeral(Z3Context::ZC, Chars.c_str(), Sort);
+  break;

@ddcc I'm not convinced this is a good idea. Printing as a decimal string could 
lead to rounding errors. I think you're better of getting an APInt from the 
APFloat, constructing a bitvector constant from those bits and then using 
`Z3_mk_fpa_to_fp_bv()` to get a Z3Expr of the right sort. That was we are being 
bit-wise accurate.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:581
+  /// Construct an APFloat from a Z3Expr, given the AST representation
+  static bool toAPFloat(const Z3_sort &Sort, const Z3_ast &AST,
+llvm::APFloat &Float, bool useSemantics = true) {

@ddcc Again I don't think the use of strings here is a good idea. You can do 
this in a bit-precise way by getting the bits, making an APInt from that and 
then making an APFloat from that.


https://reviews.llvm.org/D28952



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


[PATCH] D31496: Make -defsym a driver option

2017-03-30 Thread Salman Arif via Phabricator via cfe-commits
salari01 created this revision.

Extended the integrated assembler -Wa,-defsym option to be usable with the 
Clang driver. Both options arehandled in the same way. Using -defsym when 
not assembling files shows an unused argument warning.


https://reviews.llvm.org/D31496

Files:
  include/clang/Driver/CC1Options.td
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/defsym.c
  test/Driver/defsym.s

Index: test/Driver/defsym.s
===
--- test/Driver/defsym.s
+++ test/Driver/defsym.s
@@ -1,37 +1,73 @@
 // RUN: %clang -### -c -integrated-as %s \
 // RUN: -Wa,-defsym,abc=5 -Wa,-defsym,xyz=0xa \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
+// RUN: %clang -### -c -integrated-as %s \
+// RUN: -defsym abc=5 -defsym xyz=0xa \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
 
 // RUN: %clang -### -c -no-integrated-as -target x86_64-unknown-unknown %s \
 // RUN: -Wa,-defsym,abc=5 -Wa,-defsym,xyz=0xa \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM1
+// RUN: %clang -### -c -no-integrated-as -target x86_64-unknown-unknown %s \
+// RUN: -defsym abc=5 -defsym xyz=0xa \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-UNUSED
 
 // CHECK-DEFSYM1: "-defsym"
 // CHECK-DEFSYM1: "abc=5"
 // CHECK-DEFSYM1: "-defsym"
 // CHECK-DEFSYM1: "xyz=0xa"
+// CHECK-UNUSED:  warning: argument unused during compilation: '-defsym abc=5' [-Wunused-command-line-argument]
+// CHECK-UNUSED:  warning: argument unused during compilation: '-defsym xyz=0xa' [-Wunused-command-line-argument]
 
 // RUN: not %clang -c -integrated-as -o /dev/null %s \
 // RUN: -Wa,-defsym,abc= \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR1
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -defsym abc= \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR1
 // CHECK-DEFSYM-ERR1: error: defsym must be of the form: sym=value: abc=
 
 // RUN: not %clang -c -integrated-as -o /dev/null %s \
-// RUN: -Wa,-defsym,=123 \
+// RUN: -Wa,-defsym,abc \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR2
-// CHECK-DEFSYM-ERR2: error: defsym must be of the form: sym=value: =123
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -defsym abc \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR2
+// CHECK-DEFSYM-ERR2: error: defsym must be of the form: sym=value: abc
 
 // RUN: not %clang -c -integrated-as -o /dev/null %s \
-// RUN: -Wa,-defsym,abc=1a2b3c \
+// RUN: -Wa,-defsym,=123 \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR3
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -defsym =123 \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR3
-// CHECK-DEFSYM-ERR3: error: Value is not an integer: 1a2b3c
+// CHECK-DEFSYM-ERR3: error: defsym must be of the form: sym=value: =123
 
 // RUN: not %clang -c -integrated-as -o /dev/null %s \
-// RUN: -Wa,-defsym \
+// RUN: -Wa,-defsym,123 \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR4
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -defsym 123 \
 // RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR4
+// CHECK-DEFSYM-ERR4: error: defsym must be of the form: sym=value: 123
 
 // RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -Wa,-defsym,abc=1a2b3c \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR5
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -defsym abc=1a2b3c \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR5
+// CHECK-DEFSYM-ERR5: error: Value is not an integer: 1a2b3c
+
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -Wa,-defsym \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR6
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
 // RUN: -Wa,-defsym, \
-// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR4
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR6
+// CHECK-DEFSYM-ERR6: error: defsym must be of the form: sym=value: -defsym
 
-// CHECK-DEFSYM-ERR4: error: defsym must be of the form: sym=value: -defsym
+// RUN: not %clang -c -integrated-as -o /dev/null %s \
+// RUN: -defsym \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR7
+// CHECK-DEFSYM-ERR7: error: argument to '-defsym' is missing (expected 1 value)
\ No newline at end of file
Index: test/Driver/defsym.c
===
--- /dev/null
+++ test/Driver/defsym.c
@@ -0,0 +1,13 @@
+// RUN: not %clang -c -o /dev/null %s \
+// RUN: -defsym \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-ERR
+// CHECK-DEFSYM-ERR: error: argument to '-defsym' is missing (expected 1 value)
+
+// RUN: %clang -c -o /dev/null %s \
+// RUN: -defsym bar=1 \
+// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-DEFSYM-WARN
+// CHECK-DEFSYM-WARN: warning: argument unused during compilation: '-defsym bar=1'
+
+int foo

[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-03-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: include/clang/AST/Type.h:336-342
+  /// Get the address space value used in diagnostics.
+  unsigned getAddressSpacePrintValue() const {
+unsigned AS = getAddressSpace();
+if (AS >= LangAS::target_first)
+  return AS - LangAS::target_first;
+return AS;
+  }

yaxunl wrote:
> t-tye wrote:
> > Is this the right thing to do? This is making the CLANG named address 
> > spaces have the same numbers as the target-specific address space numbers 
> > which would seem rather confusing.
> > 
> > What do the diagnostics want to display? For example, they could display 
> > the address space as a human readable form such as "Default", 
> > "OpenCL-global", CUDA-device", "target-specific(5)", etc. To do that this 
> > function could take an iostream and a LangAS value and use << to write to 
> > the iostream.
> This function is used by diagnostics for address spaces specified by 
> `__attribute__((address_space(n)))`. There are several lit tests for that, 
> e.g. 
> 
> https://github.com/llvm-mirror/clang/blob/master/test/SemaCXX/address-space-newdelete.cpp
> https://github.com/llvm-mirror/clang/blob/master/test/SemaCXX/address-space-references.cpp
> 
> It is desirable to use the same value as specified by the attribute, 
> otherwise it may confuse the user.
I can change it to

```
  unsigned getAddressSpacePrintValue() const {
return getAddressSpace() - LangAS::target_first;
  }
```
Since the value is only used for `__attribute__((address_space(n)))`, in case 
the user specifies negative value to achieve language specific addr space, the 
diag msg will just show the same negative value they used in  
`__attribute__((address_space(n)))`


https://reviews.llvm.org/D31404



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


[PATCH] D31496: Make -defsym a driver option

2017-03-30 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:1882
+TakeNextArg = true;
   }
   } else {

I wonder if you should `break;` here if validation fails like the original code 
did?


https://reviews.llvm.org/D31496



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


[PATCH] D31496: Make -defsym a driver option

2017-03-30 Thread Salman Arif via Phabricator via cfe-commits
salari01 added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:1882
+TakeNextArg = true;
   }
   } else {

rogfer01 wrote:
> I wonder if you should `break;` here if validation fails like the original 
> code did?
The reason for removing it is that this way, all erroneous `-defsym` options 
specified can be listed during the same invocation. This provides a better user 
experience than tackling them one at a time, as with the original code.


https://reviews.llvm.org/D31496



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


[PATCH] D31496: Make -defsym a driver option

2017-03-30 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:1882
+TakeNextArg = true;
   }
   } else {

salari01 wrote:
> rogfer01 wrote:
> > I wonder if you should `break;` here if validation fails like the original 
> > code did?
> The reason for removing it is that this way, all erroneous `-defsym` options 
> specified can be listed during the same invocation. This provides a better 
> user experience than tackling them one at a time, as with the original code.
Ah, I see, thanks!


https://reviews.llvm.org/D31496



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


[PATCH] D19979: [analyzer] ScopeContext - initial implementation

2017-03-30 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

What is the status of this?
Aleksei, could you upload a new patch with the context available?
(And also with a testcase added for jumps/gotos and VLA.)

You modified the malloc checker but I did not see a test for that.


https://reviews.llvm.org/D19979



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


[PATCH] D31168: Set FMF for -ffp-contract=fast

2017-03-30 Thread Adam Nemet via Phabricator via cfe-commits
anemet updated this revision to Diff 93487.
anemet added a comment.

Also add 'contract' for CompoundAssignOperator (+= and -=).  For l-values,
these don't go through the expr-visitor in ScalarExprEmitter::Visit.  This
again piggybacks on how debug-locations are added.


https://reviews.llvm.org/D31168

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/ffp-contract-fast-option.cpp


Index: test/CodeGen/ffp-contract-fast-option.cpp
===
--- /dev/null
+++ test/CodeGen/ffp-contract-fast-option.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple %itanium_abi_triple 
-emit-llvm -o - %s | FileCheck %s
+
+float fp_contract_1(float a, float b, float c) {
+  // CHECK-LABEL: fp_contract_1fff(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  return a * b + c;
+}
+
+float fp_contract_2(float a, float b, float c) {
+  // CHECK-LABEL: fp_contract_2fff(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  return a * b - c;
+}
+
+void fp_contract_3(float *a, float b, float c) {
+  // CHECK-LABEL: fp_contract_3Pfff(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  a[0] += b * c;
+}
+
+void fp_contract_4(float *a, float b, float c) {
+  // CHECK-LABEL: fp_contract_4Pfff(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  a[0] -= b * c;
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3822,6 +3822,25 @@
   }
 };
 
+/// A RAII to apply the FP features from the expression to the IRBuilder.
+struct ApplyFPFeatures : public CGBuilderTy::FastMathFlagGuard {
+  static Optional getFPFeatures(const Expr *E) {
+if (const auto *BO = dyn_cast(E))
+  return BO->getFPFeatures();
+else if (const auto *CE = dyn_cast(E))
+  return CE->getFPFeatures();
+return None;
+  }
+
+  ApplyFPFeatures(llvm::IRBuilderBase &Builder, const Expr *E)
+  : CGBuilderTy::FastMathFlagGuard(Builder) {
+if (Optional FPFeatures = getFPFeatures(E)) {
+  llvm::FastMathFlags FMF = Builder.getFastMathFlags();
+  FMF.setAllowContract(FPFeatures->allowFPContractAcrossStatement());
+  Builder.setFastMathFlags(FMF);
+}
+  }
+};
 }  // end namespace CodeGen
 }  // end namespace clang
 
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -258,6 +258,7 @@
 
   Value *Visit(Expr *E) {
 ApplyDebugLocation DL(CGF, E);
+ApplyFPFeatures FPF(Builder, E);
 return StmtVisitor::Visit(E);
   }
 
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -1013,6 +1013,7 @@
 ///
 LValue CodeGenFunction::EmitLValue(const Expr *E) {
   ApplyDebugLocation DL(*this, E);
+  ApplyFPFeatures FPF(Builder, E);
   switch (E->getStmtClass()) {
   default: return EmitUnsupportedLValue(E, "l-value expression");
 


Index: test/CodeGen/ffp-contract-fast-option.cpp
===
--- /dev/null
+++ test/CodeGen/ffp-contract-fast-option.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
+
+float fp_contract_1(float a, float b, float c) {
+  // CHECK-LABEL: fp_contract_1fff(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  return a * b + c;
+}
+
+float fp_contract_2(float a, float b, float c) {
+  // CHECK-LABEL: fp_contract_2fff(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  return a * b - c;
+}
+
+void fp_contract_3(float *a, float b, float c) {
+  // CHECK-LABEL: fp_contract_3Pfff(
+  // CHECK: fmul contract float
+  // CHECK: fadd contract float
+  a[0] += b * c;
+}
+
+void fp_contract_4(float *a, float b, float c) {
+  // CHECK-LABEL: fp_contract_4Pfff(
+  // CHECK: fmul contract float
+  // CHECK: fsub contract float
+  a[0] -= b * c;
+}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -3822,6 +3822,25 @@
   }
 };
 
+/// A RAII to apply the FP features from the expression to the IRBuilder.
+struct ApplyFPFeatures : public CGBuilderTy::FastMathFlagGuard {
+  static Optional getFPFeatures(const Expr *E) {
+if (const auto *BO = dyn_cast(E))
+  return BO->getFPFeatures();
+else if (const auto *CE = dyn_cast(E))
+  return CE->getFPFeatures();
+return None;
+  }
+
+  ApplyFPFeatures(llvm::IRBuilderBase &Builder, const Expr *E)
+  : CGBuilderTy::FastMathFlagGuard(Builder) {
+if (Optional FPFeatures = getFPFeatures(E)) {
+  llvm::FastMathFlags FMF = Builder.getFastMathFlag

[PATCH] D31406: [clang-tidy] Reuse FileID in getLocation

2017-03-30 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

Thank you for finding out the root cause here!




Comment at: clang-tidy/ClangTidy.cpp:241
 
-const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+if (Path2FileID.find(FilePath) == Path2FileID.end()) {
+  const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);

Repeating lookup three times is not necessary:

  FileID &ID = Path2FileID[FilePath];
  if (!ID.isValid()) {
const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
  }

But even this seems to be unnecessary, since SourceManager provides a better 
API that we should have used here:

  FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);



Comment at: clang-tidy/ClangTidy.cpp:256
 
+  DenseMap Path2FileID;
   FileManager Files;

`llvm::StringMap` would be a better container, if we needed it (see the 
comment above).


https://reviews.llvm.org/D31406



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


[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 93491.
erichkeane marked 3 inline comments as done.
erichkeane added a comment.

Thanks for the feedback John!


https://reviews.llvm.org/D29599

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGen/alloc-align-attr.c
  test/Sema/alloc-align-attr.c
  test/SemaCXX/alloc-align-attr.cpp

Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -4348,6 +4348,10 @@
   llvm::ConstantInt *AlignmentCI = cast(Alignment);
   EmitAlignmentAssumption(Ret.getScalarVal(), AlignmentCI->getZExtValue(),
   OffsetValue);
+} else if (const auto *AA = TargetDecl->getAttr()) {
+  llvm::Value *ParamVal =
+  CallArgs[AA->getParamIndex() - 1].RV.getScalarVal();
+  EmitAlignmentAssumption(Ret.getScalarVal(), ParamVal);
 }
   }
 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2465,6 +2465,12 @@
   PeepholeProtection protectFromPeepholes(RValue rvalue);
   void unprotectFromPeepholes(PeepholeProtection protection);
 
+  void EmitAlignmentAssumption(llvm::Value *PtrValue, llvm::Value *Alignment,
+   llvm::Value *OffsetValue = nullptr) {
+Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
+  OffsetValue);
+  }
+
   //======//
   // Statement Emission
   //======//
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -168,6 +168,16 @@
 Aligned->getSpellingListIndex());
 }
 
+static void instantiateDependentAllocAlignAttr(
+Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs,
+const AllocAlignAttr *Align, Decl *New) {
+  Expr *Param = IntegerLiteral::Create(
+  S.getASTContext(), llvm::APInt(64, Align->getParamIndex()),
+  S.getASTContext().UnsignedLongLongTy, Align->getLocation());
+  S.AddAllocAlignAttr(Align->getLocation(), New, Param,
+  Align->getSpellingListIndex());
+}
+
 static Expr *instantiateDependentFunctionAttrCondition(
 Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs,
 const Attr *A, Expr *OldCond, const Decl *Tmpl, FunctionDecl *New) {
@@ -380,6 +390,12 @@
   continue;
 }
 
+if (const auto *AllocAlign = dyn_cast(TmplAttr)) {
+  instantiateDependentAllocAlignAttr(*this, TemplateArgs, AllocAlign, New);
+  continue;
+}
+
+
 if (const auto *EnableIf = dyn_cast(TmplAttr)) {
   instantiateDependentEnableIfAttr(*this, TemplateArgs, EnableIf, Tmpl,
cast(New));
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -218,21 +218,45 @@
std::greater());
 }
 
+/// \brief A helper function to provide Attribute Location for the Attr types
+/// AND the AttributeList.
+template 
+static typename std::enable_if::value,
+   SourceLocation>::type
+getAttrLoc(const AttrInfo &Attr) {
+  return Attr.getLocation();
+}
+static SourceLocation getAttrLoc(const clang::AttributeList &Attr) {
+  return Attr.getLoc();
+}
+
+/// \brief A helper function to provide Attribute Name for the Attr types
+/// AND the AttributeList.
+template 
+static typename std::enable_if::value,
+   const AttrInfo *>::type
+getAttrName(const AttrInfo &Attr) {
+  return &Attr;
+}
+const IdentifierInfo *getAttrName(const clang::AttributeList &Attr) {
+  return Attr.getName();
+}
+
 /// \brief If Expr is a valid integer constant, get the value of the integer
 /// expression and return success or failure. May output an error.
-static bool checkUInt32Argument(Sema &S, const AttributeList &Attr,
-const Expr *Expr, uint32_t &Val,
-unsigned Idx = UINT_MAX) {
+template
+static bool checkUInt32Argument(Sema &S, const AttrInfo& Attr, const Expr *Expr,
+uint32_t &Val, unsigned Idx = UINT_MAX) {
   llvm::APSInt I(32);
   if (Expr->isTypeDependent() || Expr->isValueDependent() ||
   !Expr->isIntegerConstantExpr(I, S.Context)) {
 if (Idx != UINT_MAX)
-  S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-  

[PATCH] D31501: [RFC] Integrate clang -cc1as diagnostics into DiagnosticsEngine

2017-03-30 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 created this revision.
Herald added a subscriber: aemerson.

Add initial support for printing assembly diagnostics using the
DiagnosticsEngine infrastructure.  Add support for -w (no warnings) and
-Werror (warnings are errors) and print a summary with the number of
errors and warnings. -fcolor-diagnostics handling is implemented as
well.

I am looking for feedback on the overall approach and suggestions for a
way to split it up into manageable pieces (if necessary).

---

The approach is to teach DiagnosticsEngine and underlying classes to
emit diagnostics using llvm::SMLocs.  Converting from llvm::SMLoc to
clang::SourceLocation (and the associated SourceManager and FileManager)
is quite infeasible.  With these changes in place, it will be relatively
easy to convert inline assembly diagnostics to this infrastructure as
well.

Unfortunately, there is still quite a lot of code duplication which I
hope to factor out (or leave as FIXMEs).  The plan is to leave the
emit*() functions as they are in this patch, but factor common bits into
private methods. Some of the diagnostics options handling has already
been factored out.

Currently missing is support for ranges and hits, but the assembly
diagnostics don't seem to generate many of those anyway.

Some examples with test.s:
.thumb

ADD r0, r0, #0xF001
LDM r0, {r1, r0}

$ clang --target=arm-none-eabi -march=armv8-m.main -c test.s

test.s:2:12: error: invalid operand for instruction

  ADD r0,r0,#0xF001
^

test.s:3:14: warning: register list not in ascending order

  LDM r0, {r1, r0}
   ^

1 warning and 1 error generated.

$ clang --target=arm-none-eabi -march=armv8-m.main -c test.s -Werror

test.s:2:12: error: invalid operand for instruction

  ADD r0,r0,#0xF001
^

test.s:3:14: error: register list not in ascending order

  LDM r0, {r1, r0}
   ^

2 errors generated.

$ clang --target=arm-none-eabi -march=armv8-m.main -c test.s -w

test.s:2:12: error: invalid operand for instruction

  ADD r0,r0,#0xF001
^

1 error generated.


https://reviews.llvm.org/D31501

Files:
  include/clang/Basic/Diagnostic.h
  include/clang/Driver/Options.h
  include/clang/Driver/Options.td
  include/clang/Frontend/CompilerInvocation.h
  include/clang/Frontend/DiagnosticRenderer.h
  include/clang/Frontend/TextDiagnostic.h
  lib/Driver/DriverOptions.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/DiagnosticRenderer.cpp
  lib/Frontend/TextDiagnostic.cpp
  lib/Frontend/TextDiagnosticPrinter.cpp
  tools/driver/cc1as_main.cpp

Index: tools/driver/cc1as_main.cpp
===
--- tools/driver/cc1as_main.cpp
+++ tools/driver/cc1as_main.cpp
@@ -14,6 +14,10 @@
 
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
@@ -45,6 +49,7 @@
 #include "llvm/Support/Host.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -209,6 +214,8 @@
   Opts.DebugCompilationDir = Args.getLastArgValue(OPT_fdebug_compilation_dir);
   Opts.MainFileName = Args.getLastArgValue(OPT_main_file_name);
 
+  ParseDiagnosticArgs(Diags.getDiagnosticOptions(), Args, &Diags, false, false);
+
   // Frontend Options
   if (Args.hasArg(OPT_INPUT)) {
 bool First = true;
@@ -281,6 +288,29 @@
   return Out;
 }
 
+struct DiagsHandlerContext {
+  DiagnosticsEngine &Diags;
+  const SourceMgr *SrcMgr;
+};
+
+static void AssemblerDiagsHandler(const SMDiagnostic &D, void *Context) {
+  auto &Diags = *static_cast(Context);
+  unsigned DiagID;
+  switch (D.getKind()) {
+  case llvm::SourceMgr::DK_Error:
+DiagID = diag::err_fe_inline_asm;
+break;
+  case llvm::SourceMgr::DK_Warning:
+DiagID = diag::warn_fe_inline_asm;
+break;
+  case llvm::SourceMgr::DK_Note:
+DiagID = diag::note_fe_inline_asm;
+break;
+  }
+
+  Diags.Report(D.getSourceMgr(), D.getLoc(), DiagID) << D.getMessage();
+}
+
 static bool ExecuteAssembler(AssemblerInvocation &Opts,
  DiagnosticsEngine &Diags) {
   // Get the target specific parser.
@@ -306,6 +336,8 @@
   // it later.
   SrcMgr.setIncludeDirs(Opts.IncludePaths);
 
+  SrcMgr.setDiagHandler(AssemblerDiagsHandler, &Diags);
+
   std::unique_ptr MRI(TheTarget->createMCRegInfo(Opts.Triple));
   assert(MRI && "Unable to create target register info!");
 
@@ -472,7 +504,7 @@
   IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
   TextDiagnosticPrinter *DiagClient
 = new

[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens

2017-03-30 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/readability/OperatorsRepresentationCheck.cpp:34
+
+  if (const auto *B = Result.Nodes.getNodeAs("binary")) {
+switch (B->getOpcode()) {

aaron.ballman wrote:
> mgehre wrote:
> > aaron.ballman wrote:
> > > alexfh wrote:
> > > > aaron.ballman wrote:
> > > > > I think this would make more sense lifted into an AST matcher -- 
> > > > > there are bound to be a *lot* of binary operators, so letting the 
> > > > > matcher memoize things is likely to give better performance.
> > > > Any reasons not to do this on the lexer level?
> > > Technical reasons? None.
> > > User-experience reasons? We wouldn't want this to be on by default (I 
> > > don't think) and we usually don't implement off-by-default diagnostics in 
> > > Clang. I think a case could be made for doing it in the Lexer if the 
> > > performance is really that bad with a clang-tidy check and we couldn't 
> > > improve it here, though.
> > Do I correctly understand that "doing this on lexer level" would mean to 
> > implement this as a warning directly into clang? If yes, would it be 
> > possible to generate fixits and have them possibly applied automatically 
> > (as it is the case for clang-tidy)?
> You are correct, that means implementing it as a warning in Clang. I believe 
> you can still generate those fixits from lexer-level diagnostics, but have 
> not verified it.
> 
> However, I don't think this diagnostic would be appropriate for Clang because 
> it would have to be off by default.
Actually, I was thinking about changing this clang-tidy check to analyze token 
stream somehow (probably by handling `PPCallbacks` to detect ranges that need 
to be re-lexed) instead of matching the AST. I didn't intend to propose a new 
Clang warning (but it looks like the wording was misleading).


https://reviews.llvm.org/D31308



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


[libcxxabi] r299087 - [libc++abi] Remove unistd.h include

2017-03-30 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Mar 30 11:27:09 2017
New Revision: 299087

URL: http://llvm.org/viewvc/llvm-project?rev=299087&view=rev
Log:
[libc++abi] Remove unistd.h include

This was originally there for the _POSIX_THREADS define, to detect the
presence of pthreads. That went away with the externalized threading
support, so the include can go away too.

config.h is now completely empty. A follow-up commit will remove it
entirely.

Modified:
libcxxabi/trunk/src/config.h

Modified: libcxxabi/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/config.h?rev=299087&r1=299086&r2=299087&view=diff
==
--- libcxxabi/trunk/src/config.h (original)
+++ libcxxabi/trunk/src/config.h Thu Mar 30 11:27:09 2017
@@ -14,6 +14,4 @@
 #ifndef LIBCXXABI_CONFIG_H
 #define LIBCXXABI_CONFIG_H
 
-#include 
-
 #endif // LIBCXXABI_CONFIG_H


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


[PATCH] D31502: [libc++abi] Delete config.h

2017-03-30 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.

It's now completely empty, so we can remove it entirely.


https://reviews.llvm.org/D31502

Files:
  src/config.h
  src/cxa_default_handlers.cpp
  src/cxa_exception.cpp
  src/cxa_exception_storage.cpp
  src/cxa_guard.cpp
  src/cxa_handlers.cpp
  src/cxa_personality.cpp
  src/fallback_malloc.cpp
  test/test_exception_storage.pass.cpp
  test/test_guard.pass.cpp

Index: test/test_guard.pass.cpp
===
--- test/test_guard.pass.cpp
+++ test/test_guard.pass.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-#include "../src/config.h"
 #include "cxxabi.h"
 
 #include 
Index: test/test_exception_storage.pass.cpp
===
--- test/test_exception_storage.pass.cpp
+++ test/test_exception_storage.pass.cpp
@@ -11,7 +11,6 @@
 // This breaks this test when compiled in C++17. For now fix this by manually
 // re-enabling the STL functions.
 #define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS
-#include "../src/config.h"
 
 #include 
 #include 
Index: src/fallback_malloc.cpp
===
--- src/fallback_malloc.cpp
+++ src/fallback_malloc.cpp
@@ -9,7 +9,6 @@
 
 #include "fallback_malloc.h"
 
-#include "config.h"
 #include <__threading_support>
 
 #include  // for malloc, calloc, free
Index: src/cxa_personality.cpp
===
--- src/cxa_personality.cpp
+++ src/cxa_personality.cpp
@@ -18,7 +18,6 @@
 #include 
 
 #include "__cxxabi_config.h"
-#include "config.h"
 #include "cxa_exception.hpp"
 #include "cxa_handlers.hpp"
 #include "private_typeinfo.h"
Index: src/cxa_handlers.cpp
===
--- src/cxa_handlers.cpp
+++ src/cxa_handlers.cpp
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include "abort_message.h"
-#include "config.h"
 #include "cxxabi.h"
 #include "cxa_handlers.hpp"
 #include "cxa_exception.hpp"
Index: src/cxa_guard.cpp
===
--- src/cxa_guard.cpp
+++ src/cxa_guard.cpp
@@ -10,7 +10,6 @@
 #include "__cxxabi_config.h"
 
 #include "abort_message.h"
-#include "config.h"
 #include <__threading_support>
 
 #include 
Index: src/cxa_exception_storage.cpp
===
--- src/cxa_exception_storage.cpp
+++ src/cxa_exception_storage.cpp
@@ -13,7 +13,6 @@
 
 #include "cxa_exception.hpp"
 
-#include "config.h"
 #include <__threading_support>
 
 #if defined(_LIBCXXABI_HAS_NO_THREADS)
Index: src/cxa_exception.cpp
===
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -11,7 +11,6 @@
 //  
 //===--===//
 
-#include "config.h"
 #include "cxxabi.h"
 
 #include // for std::terminate
Index: src/cxa_default_handlers.cpp
===
--- src/cxa_default_handlers.cpp
+++ src/cxa_default_handlers.cpp
@@ -14,7 +14,6 @@
 #include 
 #include 
 #include "abort_message.h"
-#include "config.h" // For __sync_swap
 #include "cxxabi.h"
 #include "cxa_handlers.hpp"
 #include "cxa_exception.hpp"
Index: src/config.h
===
--- src/config.h
+++ /dev/null
@@ -1,17 +0,0 @@
-//===- config.h ---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//
-//  Defines macros used within the libc++abi project.
-//
-//===--===//
-
-
-#ifndef LIBCXXABI_CONFIG_H
-#define LIBCXXABI_CONFIG_H
-
-#endif // LIBCXXABI_CONFIG_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28952: [analyzer] Add new Z3 constraint manager backend

2017-03-30 Thread Dan Liew via Phabricator via cfe-commits
delcypher added inline comments.



Comment at: CMakeLists.txt:188
 
+find_package(Z3 4.5)
+

delcypher wrote:
> @ddcc It is of course up to you but I recently [[ added support for using 
> `libz3` directly | added support for using `libz3` directly ]] from CMake. 
> via it's own CMake config package. You only get this if Z3 was built with 
> CMake so you might not want this restriction.  This feature has only just 
> landed though and might not be sufficient for your needs.  If you take a look 
> at Z3's example projects they are now built with this mechanism when building 
> with CMake.
> 
> If you are interested I'd be more than happy to work with you to get this 
> feature ready for your needs in upstream Z3 so you can use it here.
Sorry that URL should be https://github.com/Z3Prover/z3/pull/926


https://reviews.llvm.org/D28952



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


[PATCH] D31406: [clang-tidy] Reuse FileID in getLocation

2017-03-30 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 93499.
chh marked an inline comment as done.
chh added a comment.

Use getOrCreateFileID.


https://reviews.llvm.org/D31406

Files:
  clang-tidy/ClangTidy.cpp


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -238,7 +238,7 @@
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 


Index: clang-tidy/ClangTidy.cpp
===
--- clang-tidy/ClangTidy.cpp
+++ clang-tidy/ClangTidy.cpp
@@ -238,7 +238,7 @@
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D30837: [libcxx] Support for shared_ptr

2017-03-30 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington updated this revision to Diff 93488.
erik.pilkington marked 2 inline comments as done.
erik.pilkington added a comment.

In this new patch, use an explicit specialization of std::allocator that 
specifically only performs a rebind. This needs to be a specialization of 
std::allocator so we can use allocator's `allocator(const allocator &)` ctor 
from `shared_ptr_pointer::__on_zero_shared_weak()`.
Thanks,
Erik


https://reviews.llvm.org/D30837

Files:
  include/memory
  
test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp

Index: test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
===
--- test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
+++ test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
@@ -45,6 +45,13 @@
 virtual ~Foo() = default;
 };
 
+struct Result {};
+static Result theFunction() { return Result(); }
+static int resultDeletorCount;
+static void resultDeletor(Result (*pf)()) {
+  assert(pf == theFunction);
+  ++resultDeletorCount;
+}
 
 int main()
 {
@@ -65,7 +72,11 @@
 std::shared_ptr p2 = std::make_shared();
 assert(p2.get());
 }
-
+{ // https://bugs.llvm.org/show_bug.cgi?id=27566
+  std::shared_ptr x(&theFunction, &resultDeletor);
+  std::shared_ptr y(theFunction, resultDeletor);
+}
+assert(resultDeletorCount == 2);
 #if TEST_STD_VER >= 11
 nc = globalMemCounter.outstanding_new;
 {
Index: include/memory
===
--- include/memory
+++ include/memory
@@ -3601,6 +3601,17 @@
 __a.deallocate(_PTraits::pointer_to(*this), 1);
 }
 
+struct __shared_ptr_dummy_rebind_allocator_type;
+template <>
+class _LIBCPP_TEMPLATE_VIS allocator<__shared_ptr_dummy_rebind_allocator_type>
+{
+template 
+struct rebind
+{
+typedef allocator<_Other> other;
+};
+};
+
 template class _LIBCPP_TEMPLATE_VIS enable_shared_from_this;
 
 template
@@ -3869,6 +3880,17 @@
 #endif  // _LIBCPP_HAS_NO_VARIADICS
 
 private:
+template ::value>
+struct __shared_ptr_default_allocator
+{
+typedef allocator<_Yp> type;
+};
+
+template 
+struct __shared_ptr_default_allocator<_Yp, true>
+{
+typedef allocator<__shared_ptr_dummy_rebind_allocator_type> type;
+};
 
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -3884,8 +3906,7 @@
 }
 }
 
-_LIBCPP_INLINE_VISIBILITY
-void __enable_weak_this(const volatile void*, const volatile void*) _NOEXCEPT {}
+_LIBCPP_INLINE_VISIBILITY void __enable_weak_this(...) _NOEXCEPT {}
 
 template  friend class _LIBCPP_TEMPLATE_VIS shared_ptr;
 template  friend class _LIBCPP_TEMPLATE_VIS weak_ptr;
@@ -3916,8 +3937,9 @@
 : __ptr_(__p)
 {
 unique_ptr<_Yp> __hold(__p);
-typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, allocator<_Yp> > _CntrlBlk;
-__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), allocator<_Yp>());
+typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
+typedef __shared_ptr_pointer<_Yp*, default_delete<_Yp>, _AllocT > _CntrlBlk;
+__cntrl_ = new _CntrlBlk(__p, default_delete<_Yp>(), _AllocT());
 __hold.release();
 __enable_weak_this(__p, __p);
 }
@@ -3932,8 +3954,9 @@
 try
 {
 #endif  // _LIBCPP_NO_EXCEPTIONS
-typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
-__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Yp>());
+typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
+typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk;
+__cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
 __enable_weak_this(__p, __p);
 #ifndef _LIBCPP_NO_EXCEPTIONS
 }
@@ -3954,8 +3977,9 @@
 try
 {
 #endif  // _LIBCPP_NO_EXCEPTIONS
-typedef __shared_ptr_pointer > _CntrlBlk;
-__cntrl_ = new _CntrlBlk(__p, __d, allocator<_Tp>());
+typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT;
+typedef __shared_ptr_pointer _CntrlBlk;
+__cntrl_ = new _CntrlBlk(__p, __d, _AllocT());
 #ifndef _LIBCPP_NO_EXCEPTIONS
 }
 catch (...)
@@ -4123,8 +4147,9 @@
 else
 #endif
 {
-typedef __shared_ptr_pointer<_Yp*, _Dp, allocator<_Yp> > _CntrlBlk;
-__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), allocator<_Yp>());
+typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT;
+typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT > _CntrlBlk;
+__cntrl_ = new _CntrlBlk(__r.get(), __r.get_deleter(), _AllocT());
 __enable_weak_this(__r.get(), __r.get());
 }
 __r.release();
@@ -4152,10 +4177,11 @@
 else
 #endif
 {

LLVM buildmaster will be updated and restarted tonight

2017-03-30 Thread Galina Kistanova via cfe-commits
Hello everyone,

LLVM buildmaster will be updated and restarted after 5 PM Pacific time
today.

Thanks

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


[PATCH] D31404: [OpenCL] Allow alloca return non-zero private pointer

2017-03-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

I can't see clearly why the alloca has to be extended to accommodate the 
address space too? Couldn't  the address space for alloca just be taken 
directly from the data layout?

In fact is seems from the LLVM review, an address space for alloca doesn't go 
into the bitcode.




Comment at: include/clang/Basic/AddressSpaces.h:28
 enum ID {
-  Offset = 0x7FFF00,
+  Default = 0,
 

Somehow I wish that opencl_private would be represented explicitly instead and 
then an absence of an address space attribute would signify the default one to 
be used. But since opencl_private has always been represented as an absence of 
an address space attribute not only in AST but in IR as well, I believe it 
might be a bigger change now. However, how does this default address space 
align with default AS we put during type parsing in processTypeAttrs 
(https://reviews.llvm.org/D13168). I think after this step we shouldn't need 
default AS explicitly any longer? 



Comment at: include/clang/Basic/AddressSpaces.h:41
+
+  target_first = Count
 };

I don't entirely understand the motivation for this. I think the idea of LangAS 
is to represent the source ASes while target ASes are reflected in the Map of 
Targets.cpp.



Comment at: lib/AST/ASTContext.cpp:9553
+  // alloca.
+  if (AS == LangAS::Default && LangOpts.OpenCL)
+return getTargetInfo().getDataLayout().getAllocaAddrSpace();

Here it seems that LangAS::Default is indeed opencl_private?



Comment at: test/Sema/invalid-assignment-constant-address-space.c:4
-#define OPENCL_CONSTANT 8388354
-int __attribute__((address_space(OPENCL_CONSTANT))) c[3] = {0};
 

Is this test even correct? I don't think we can assume that C address spaces 
inherit the same restrictions as OpenCL. Especially that the notion of 
private/local/constant/global is an OpenCL specific thing.

I feel like Clang doesn't behave correctly for C address spaces now.

As for OpenCL I don't see why would anyone use __attribute__((address_space())) 
for constant AS. Especially that it's not part of the spec.


https://reviews.llvm.org/D31404



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


[PATCH] D31321: [OpenCL] Do not generate "kernel_arg_type_qual" metadata for non-pointer args

2017-03-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: test/CodeGenOpenCL/kernel-arg-info.cl:66
 // CHECK: ![[MD13]] = !{!"int*", !"int", !"int", !"float*"}
-// CHECK: ![[MD14]] = !{!"restrict", !"const", !"volatile", !"restrict const"}
 // ARGINFO: ![[MD15]] = !{!"X", !"Y", !"anotherArg", !"Z"}

echuraev wrote:
> Anastasia wrote:
> > Could we modify the test to check that const and volatile are added for the 
> > pointers though?
> Added test case only for volatile pointer because const is checked in the Z 
> argument of foo function.
I think it would still be nice to add an argument with explicit const because 
the current test doesn't have it explicitly.


https://reviews.llvm.org/D31321



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


[PATCH] D30643: [OpenCL] Extended diagnostics for atomic initialization

2017-03-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: test/SemaOpenCL/atomic-init.cl:6
+kernel void test_atomic_initialization() {
+  a1 = 1; // expected-error {{atomic variable can only be assigned to a 
compile time constant and to variables in global adress space}}
+  atomic_int a2 = 0; // expected-error {{atomic variable can only be assigned 
to a compile time constant and to variables in global adress space}}

Anastasia wrote:
> Btw, you could keep "initialized" here by using 'select' in the diagnostic 
> message. 
Btw you still keep "assigned" in the error message. What I mean is that we 
could put "initialized" instead in this case.


https://reviews.llvm.org/D30643



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


[PATCH] D16682: 19957 - OpenCL incorrectly accepts implicit address space conversion with ternary operator

2017-03-30 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Is this still necessary? The bug is marked fixed


https://reviews.llvm.org/D16682



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


[PATCH] D29642: [OpenMP] Make OpenMP generated code for the NVIDIA device relocatable by default

2017-03-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93501.
gtbercea added a comment.

Remove redundant check.


Repository:
  rL LLVM

https://reviews.llvm.org/D29642

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -587,3 +587,11 @@
 // CHK-UBUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]"
 // CHK-UBUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" 
"-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux"
 "-outputs=
 // CHK-UBUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" 
"-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]"
+
+/// ###
+
+/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using 
OpenMP.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
+
+// CHK-PTXAS: ptxas{{.*}}" "-c"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -272,6 +272,10 @@
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
+  // In OpenMP we need to generate relocatable code.
+  if (JA.isOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-c");
+
   const char *Exec;
   if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
 Exec = A->getValue();


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -587,3 +587,11 @@
 // CHK-UBUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]"
 // CHK-UBUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=
 // CHK-UBUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" "-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]"
+
+/// ###
+
+/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
+
+// CHK-PTXAS: ptxas{{.*}}" "-c"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -272,6 +272,10 @@
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
+  // In OpenMP we need to generate relocatable code.
+  if (JA.isOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-c");
+
   const char *Exec;
   if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
 Exec = A->getValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29644: [OpenMP] Pass -v to PTXAS if it was passed to the driver.

2017-03-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93502.
gtbercea added a comment.

Remove redundant check.


Repository:
  rL LLVM

https://reviews.llvm.org/D29644

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -595,3 +595,12 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
 
 // CHK-PTXAS: ptxas{{.*}}" "-c"
+// CHK-PTXAS-NEXT: /bin/cp
+
+/// ###
+
+/// Check that CLANG forwards the -v flag to PTXAS.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes -v %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
+
+// CHK-VERBOSE: ptxas{{.*}}" "-v"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -262,6 +262,10 @@
 CmdArgs.push_back("-O0");
   }
 
+  // Pass -v to ptxas if it was passed to the driver.
+  if (Args.hasArg(options::OPT_v))
+CmdArgs.push_back("-v");
+
   CmdArgs.push_back("--gpu-name");
   CmdArgs.push_back(Args.MakeArgString(CudaArchToString(gpu_arch)));
   CmdArgs.push_back("--output-file");


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -595,3 +595,12 @@
 // RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
 
 // CHK-PTXAS: ptxas{{.*}}" "-c"
+// CHK-PTXAS-NEXT: /bin/cp
+
+/// ###
+
+/// Check that CLANG forwards the -v flag to PTXAS.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes -v %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-VERBOSE %s
+
+// CHK-VERBOSE: ptxas{{.*}}" "-v"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -262,6 +262,10 @@
 CmdArgs.push_back("-O0");
   }
 
+  // Pass -v to ptxas if it was passed to the driver.
+  if (Args.hasArg(options::OPT_v))
+CmdArgs.push_back("-v");
+
   CmdArgs.push_back("--gpu-name");
   CmdArgs.push_back(Args.MakeArgString(CudaArchToString(gpu_arch)));
   CmdArgs.push_back("--output-file");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2017-03-30 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor updated this revision to Diff 93503.
teemperor added a comment.

- Remove the mysterious unicode-character at the start of CloneDetection.cpp
- Fixed formatting of the comment in CloneDetectionTest.cpp
- Fixed comment in StmtSequence::contains that was still talking about checking 
for translation units even though we compared declarations.

I think this is everything from my side for now :)


https://reviews.llvm.org/D23418

Files:
  include/clang/Analysis/CloneDetection.h
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  unittests/Analysis/CMakeLists.txt
  unittests/Analysis/CloneDetectionTest.cpp

Index: unittests/Analysis/CloneDetectionTest.cpp
===
--- /dev/null
+++ unittests/Analysis/CloneDetectionTest.cpp
@@ -0,0 +1,110 @@
+//===- unittests/Analysis/CloneDetectionTest.cpp - Clone detection tests --===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Analysis/CloneDetection.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace analysis {
+namespace {
+
+class CloneDetectionVisitor
+: public RecursiveASTVisitor {
+
+  CloneDetector &Detector;
+
+public:
+  explicit CloneDetectionVisitor(CloneDetector &D) : Detector(D) {}
+
+  bool VisitFunctionDecl(FunctionDecl *D) {
+Detector.analyzeCodeBody(D);
+return true;
+  }
+};
+
+/// Example constraint for testing purposes.
+/// Filters out all statements that are in a function which name starts with
+/// "bar".
+class NoBarFunctionConstraint {
+public:
+  void constrain(std::vector &CloneGroups) {
+CloneConstraint::splitCloneGroups(
+CloneGroups, [](const StmtSequence &A, const StmtSequence &B) {
+  // Check if one of the sequences is in a function which name starts
+  // with "bar".
+  for (const StmtSequence &Arg : {A, B}) {
+if (const auto *D =
+dyn_cast(Arg.getContainingDecl())) {
+  if (D->getNameAsString().find("bar") == 0)
+return false;
+}
+  }
+  return true;
+});
+  }
+};
+
+TEST(CloneDetector, NoPostOrderTraversal) {
+  auto ASTUnit =
+  clang::tooling::buildASTFromCode("void foo1(int &a1) { a1++; }\n"
+   "void foo2(int &a2) { a2++; }\n"
+   "void bar1(int &a3) { a3++; }\n"
+   "void bar2(int &a4) { a4++; }\n");
+  auto TU = ASTUnit->getASTContext().getTranslationUnitDecl();
+
+  CloneDetector Detector;
+  // Push all the function bodies into the detector.
+  CloneDetectionVisitor Visitor(Detector);
+  Visitor.TraverseTranslationUnitDecl(TU);
+
+  // Find clones with the usual settings, but but we want to filter out
+  // all statements from functions which names start with "bar".
+  std::vector CloneGroups;
+  Detector.findClones(CloneGroups, NoBarFunctionConstraint(),
+  RecursiveCloneTypeIIConstraint(),
+  MinComplexityConstraint(2), MinGroupSizeConstraint(2),
+  OnlyLargestCloneConstraint());
+
+  ASSERT_EQ(CloneGroups.size(), 1u);
+  ASSERT_EQ(CloneGroups.front().size(), 2u);
+
+  for (auto &Clone : CloneGroups.front()) {
+const auto ND = dyn_cast(Clone.getContainingDecl());
+ASSERT_TRUE(ND != nullptr);
+// Check that no function name starting with "bar" is in the results...
+ASSERT_TRUE(ND->getNameAsString().find("bar") != 0);
+  }
+
+  // Retry above's example without the filter...
+  CloneGroups.clear();
+
+  Detector.findClones(CloneGroups, RecursiveCloneTypeIIConstraint(),
+  MinComplexityConstraint(2), MinGroupSizeConstraint(2),
+  OnlyLargestCloneConstraint());
+  ASSERT_EQ(CloneGroups.size(), 1u);
+  ASSERT_EQ(CloneGroups.front().size(), 4u);
+
+  // Count how many functions with the bar prefix we have in the results.
+  int FoundFunctionsWithBarPrefix = 0;
+  for (auto &Clone : CloneGroups.front()) {
+const auto ND = dyn_cast(Clone.getContainingDecl());
+ASSERT_TRUE(ND != nullptr);
+// This time check that we picked up the bar functions from above
+if (ND->getNameAsString().find("bar") == 0) {
+  FoundFunctionsWithBarPrefix++;
+}
+  }
+  // We should have found the two functions bar1 and bar2.
+  ASSERT_EQ(FoundFunctionsWithBarPrefix, 2);
+}
+} // namespace
+} // namespace analysis
+} // namespace clang
Index: unittests/Analysis/CMakeLists.txt
===
--- unittests/Analysis/CMakeLists.txt
+++ unittests/Analysis/CMakeLists.txt
@@ -2,11 +2,12 @@
   Support
   )
 

[PATCH] D31441: [clang-format] fix crash in NamespaceEndCommentsFixer (PR32438)

2017-03-30 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 93507.
mgehre added a comment.

Updated for comments


https://reviews.llvm.org/D31441

Files:
  lib/Format/NamespaceEndCommentsFixer.cpp
  unittests/Format/NamespaceEndCommentsFixerTest.cpp


Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -582,6 +582,21 @@
 "} // namespace\n"
 "}"));
 }
+
+TEST_F(NamespaceEndCommentsFixerTest, HandlesInlineAtEndOfLine_PR32438) {
+  EXPECT_EQ("template  struct a {};\n"
+"struct a b() {\n"
+"}\n"
+"#define c inline\n"
+"void d() {\n"
+"}\n",
+fixNamespaceEndComments("template  struct a {};\n"
+"struct a b() {\n"
+"}\n"
+"#define c inline\n"
+"void d() {\n"
+"}\n"));
+}
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/NamespaceEndCommentsFixer.cpp
===
--- lib/Format/NamespaceEndCommentsFixer.cpp
+++ lib/Format/NamespaceEndCommentsFixer.cpp
@@ -133,7 +133,7 @@
 // Detect "(inline)? namespace" in the beginning of a line.
 if (NamespaceTok->is(tok::kw_inline))
   NamespaceTok = NamespaceTok->getNextNonComment();
-if (NamespaceTok->isNot(tok::kw_namespace))
+if (!NamespaceTok || NamespaceTok->isNot(tok::kw_namespace))
   continue;
 FormatToken *RBraceTok = EndLine->First;
 if (RBraceTok->Finalized)


Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -582,6 +582,21 @@
 "} // namespace\n"
 "}"));
 }
+
+TEST_F(NamespaceEndCommentsFixerTest, HandlesInlineAtEndOfLine_PR32438) {
+  EXPECT_EQ("template  struct a {};\n"
+"struct a b() {\n"
+"}\n"
+"#define c inline\n"
+"void d() {\n"
+"}\n",
+fixNamespaceEndComments("template  struct a {};\n"
+"struct a b() {\n"
+"}\n"
+"#define c inline\n"
+"void d() {\n"
+"}\n"));
+}
 } // end namespace
 } // end namespace format
 } // end namespace clang
Index: lib/Format/NamespaceEndCommentsFixer.cpp
===
--- lib/Format/NamespaceEndCommentsFixer.cpp
+++ lib/Format/NamespaceEndCommentsFixer.cpp
@@ -133,7 +133,7 @@
 // Detect "(inline)? namespace" in the beginning of a line.
 if (NamespaceTok->is(tok::kw_inline))
   NamespaceTok = NamespaceTok->getNextNonComment();
-if (NamespaceTok->isNot(tok::kw_namespace))
+if (!NamespaceTok || NamespaceTok->isNot(tok::kw_namespace))
   continue;
 FormatToken *RBraceTok = EndLine->First;
 if (RBraceTok->Finalized)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31487: [coroutines] Fix rebuilding of implicit and dependent coroutine statements.

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 93508.
EricWF added a comment.

- Fix insane definition of `hasDependentPromiseType()`


https://reviews.llvm.org/D31487

Files:
  include/clang/AST/StmtCXX.h
  lib/AST/StmtCXX.cpp
  lib/Sema/CoroutineBuilder.h
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -534,6 +534,12 @@
   co_await a;
 }
 
+template 
+coro bad_implicit_return_dependent(T) { // expected-error {{'bad_promise_6' declares both 'return_value' and 'return_void'}}
+  co_await a;
+}
+template coro bad_implicit_return_dependent(bad_promise_6); // expected-note {{in instantiation}}
+
 struct bad_promise_7 {
   coro get_return_object();
   suspend_always initial_suspend();
@@ -544,25 +550,38 @@
   co_await a;
 }
 
+template 
+coro no_unhandled_exception_dependent(T) { // expected-error {{'bad_promise_7' is required to declare the member 'unhandled_exception()'}}
+  co_await a;
+}
+template coro no_unhandled_exception_dependent(bad_promise_7); // expected-note {{in instantiation}}
+
 struct bad_promise_base {
 private:
   void return_void();
 };
 struct bad_promise_8 : bad_promise_base {
   coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
-  void unhandled_exception() __attribute__((unavailable)); // expected-note {{made unavailable}}
-  void unhandled_exception() const;// expected-note {{candidate}}
-  void unhandled_exception(void *) const;  // expected-note {{requires 1 argument, but 0 were provided}}
+  void unhandled_exception() __attribute__((unavailable)); // expected-note 2 {{made unavailable}}
+  void unhandled_exception() const;// expected-note 2 {{candidate}}
+  void unhandled_exception(void *) const;  // expected-note 2 {{requires 1 argument, but 0 were provided}}
 };
 coro calls_unhandled_exception() {
   // expected-error@-1 {{call to unavailable member function 'unhandled_exception'}}
   // FIXME: also warn about private 'return_void' here. Even though building
   // the call to unhandled_exception has already failed.
   co_await a;
 }
 
+template 
+coro calls_unhandled_exception_dependent(T) {
+  // expected-error@-1 {{call to unavailable member function 'unhandled_exception'}}
+  co_await a;
+}
+template coro calls_unhandled_exception_dependent(bad_promise_8); // expected-note {{in instantiation}}
+
 struct bad_promise_9 {
   coro get_return_object();
   suspend_always initial_suspend();
@@ -652,3 +671,26 @@
 extern "C" int f(promise_on_alloc_failure_tag) {
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
+
+struct bad_promise_11 {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void unhandled_exception();
+  void return_void();
+
+private:
+  static coro get_return_object_on_allocation_failure(); // expected-note 2 {{declared private here}}
+};
+coro private_alloc_failure_handler() {
+  // expected-error@-1 {{'get_return_object_on_allocation_failure' is a private member of 'bad_promise_11'}}
+  co_return; // FIXME: Add a "declared coroutine here" note.
+}
+
+template 
+coro dependent_private_alloc_failure_handler(T) {
+  // expected-error@-1 {{'get_return_object_on_allocation_failure' is a private member of 'bad_promise_11'}}
+  co_return; // FIXME: Add a "declared coroutine here" note.
+}
+template coro dependent_private_alloc_failure_handler(bad_promise_11);
+// expected-note@-1 {{requested here}}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
 #define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
 
+#include "CoroutineBuilder.h"
 #include "TypeLocBuilder.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
@@ -6849,11 +6850,10 @@
 TreeTransform::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) {
   // The coroutine body should be re-formed by the caller if necessary.
   // FIXME: The coroutine body is always rebuilt by ActOnFinishFunctionBody
-  CoroutineBodyStmt::CtorArgs BodyArgs;
 
   auto *ScopeInfo = SemaRef.getCurFunction();
   auto *FD = cast(SemaRef.CurContext);
-  assert(ScopeInfo && !ScopeInfo->CoroutinePromise &&
+  assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
  ScopeInfo->NeedsCoroutineSuspends &&
  ScopeInfo->CoroutineSuspends.first == nullptr &&
  ScopeInfo->CoroutineSuspends.second == nullptr &&
@@ -6865,17 +6865,11 @@
 
   // The new CoroutinePromise object needs to be built and put into the current
   // FunctionScopeInfo before any transformations or rebuilding occurs.
-  auto *Promise = S->getPromiseDecl();
-  auto *NewPromise = Sem

[PATCH] D31502: [libc++abi] Delete config.h

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

Thanks. I'm surprised this wasn't done earlier.


https://reviews.llvm.org/D31502



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


r299094 - Correcting a typo; NFC.

2017-03-30 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Mar 30 13:11:20 2017
New Revision: 299094

URL: http://llvm.org/viewvc/llvm-project?rev=299094&view=rev
Log:
Correcting a typo; NFC.

Modified:
cfe/trunk/test/Analysis/simple-stream-checks.c

Modified: cfe/trunk/test/Analysis/simple-stream-checks.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/simple-stream-checks.c?rev=299094&r1=299093&r2=299094&view=diff
==
--- cfe/trunk/test/Analysis/simple-stream-checks.c (original)
+++ cfe/trunk/test/Analysis/simple-stream-checks.c Thu Mar 30 13:11:20 2017
@@ -65,7 +65,7 @@ void SymbolEscapedThroughFunctionCall()
 }
 
 FILE *GlobalF;
-void SymbolEscapedThroughAssignmentToGloabl() {
+void SymbolEscapedThroughAssignmentToGlobal() {
   FILE *F = fopen("myfile.txt", "w");
   GlobalF = F;
   return; // no warning


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


[PATCH] D31491: [XRay][clang] Fix the -fxray-instruction-threshold flag processing

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

lgtm




Comment at: test/CodeGen/xray-instruction-threshold.cpp:11
+
+// CHECK-DAG: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
+// CHECK-DAG: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {

Any reason to use -DAG on the decls? The IR should be in source order, with the 
attributes always at the end. The attribute sets need -DAG, of course.


https://reviews.llvm.org/D31491



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


[PATCH] D24892: [clang-tidy] Add option "LiteralInitializers" to cppcoreguidelines-pro-type-member-init

2017-03-30 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 93511.
mgehre added a comment.

Put 'u' and 'l' on integer literals


https://reviews.llvm.org/D24892

Files:
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
  
test/clang-tidy/cppcoreguidelines-pro-type-member-init-literal-initializers.cpp

Index: test/clang-tidy/cppcoreguidelines-pro-type-member-init-literal-initializers.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-pro-type-member-init-literal-initializers.cpp
@@ -0,0 +1,40 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -config="{CheckOptions: [{key: "cppcoreguidelines-pro-type-member-init.LiteralInitializers", value: 1}]}" -- -std=c++11
+
+struct T {
+  int i;
+};
+
+struct S {
+  bool b;
+  // CHECK-FIXES: bool b = false;
+  char c;
+  // CHECK-FIXES: char c = 0;
+  signed char sc;
+  // CHECK-FIXES: signed char sc = 0;
+  unsigned char uc;
+  // CHECK-FIXES: unsigned char uc = 0u;
+  int i;
+  // CHECK-FIXES: int i = 0;
+  unsigned u;
+  // CHECK-FIXES: unsigned u = 0u;
+  long l;
+  // CHECK-FIXES: long l = 0l;
+  unsigned long ul;
+  // CHECK-FIXES: unsigned long ul = 0ul;
+  long long ll;
+  // CHECK-FIXES: long long ll = 0ll;
+  unsigned long long ull;
+  // CHECK-FIXES: unsigned long long ull = 0ull;
+  float f;
+  // CHECK-FIXES: float f = 0.0f;
+  double d;
+  // CHECK-FIXES: double d = 0.0;
+  long double ld;
+  // CHECK-FIXES: double ld = 0.0l;
+  int *ptr;
+  // CHECK-FIXES: int *ptr = nullptr;
+  T t;
+  // CHECK-FIXES: T t{};
+  S() {};
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these fields:
+};
Index: docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
===
--- docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
+++ docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
@@ -33,6 +33,10 @@
zero-initialized during construction. For performance critical code, it may
be important to not initialize fixed-size array members. Default is `0`.
 
+.. option:: LiteralInitializers
+   If set to non-zero, the check will provide fix-its with literal initializers
+   (``int i = 0;``) instead of curly braces (``int i{};``).
+
 This rule is part of the "Type safety" profile of the C++ Core
 Guidelines, corresponding to rule Type.6. See
 https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-memberinit.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -67,6 +67,10 @@
 
   Allow custom memory management functions to be considered as well.
 
+- Added `LiteralInitializers` option to `cppcoreguidelines-pro-type-member-init`
+   If set to true, the check will provide fix-its with literal initializers
+   (``int i = 0;``) instead of curly braces (``int i{};``).
+
 - New `readability-misleading-indentation
   `_ check
 
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
@@ -65,6 +65,9 @@
 
   // Whether arrays need to be initialized or not. Default is false.
   bool IgnoreArrays;
+  // Whether fix-its for initializers of fundamental type use literals. Only
+  // effective in C++11 mode. Default is false.
+  bool LiteralInitializers;
 };
 
 } // namespace cppcoreguidelines
Index: clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -255,7 +255,8 @@
 ProTypeMemberInitCheck::ProTypeMemberInitCheck(StringRef Name,
ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
-  IgnoreArrays(Options.get("IgnoreArrays", false)) {}
+  IgnoreArrays(Options.get("IgnoreArrays", false)),
+  LiteralInitializers(Options.get("LiteralInitializers", false)) {}
 
 void ProTypeMemberInitCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
@@ -319,6 +320,7 @@
 
 void ProTypeMemberInitCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "IgnoreArrays", IgnoreArrays);
+  Options.store(Opts, "LiteralInitializers", LiteralInitializers);
 }
 
 // FIXME: Copied from clang/lib/Sema/SemaDeclCXX.cpp.
@@ -343,6 +345,56 @@
   return isIncompleteOrZeroLengthArrayType(Context, Type);
 }
 
+static const char *getInitializer(QualType type, b

[PATCH] D15031: CFG: Add CFGElement for automatic variables that leave the scope

2017-03-30 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre marked an inline comment as done.
mgehre added a comment.

Friendly ping


https://reviews.llvm.org/D15031



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


[PATCH] D31167: Use FPContractModeKind universally

2017-03-30 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: cfe/trunk/include/clang/Basic/LangOptions.h:217
   /// Adjust BinaryOperator::FPFeatures to match the bit-field size of this.
-  unsigned fp_contract : 1;
+  LangOptions::FPContractModeKind fp_contract : 2;
 };

anemet wrote:
> rnk wrote:
> > Please do not use bitfields with enum types, it's a good way to break the 
> > build on Windows. This change triggered this clang-cl warning:
> > ```
> > C:\src\llvm-project\clang\include\clang/Basic/LangOptions.h(208,17):  
> > warning: implicit truncation from 'clang::LangOptions::FPContractModeKind' 
> > to bit-field changes value from 2 to -2 [-Wbitfield-constant-conversion]
> > fp_contract = LangOptions::FPC_Fast;
> > ^ ~
> > ```
> Noted and thanks for the fix!  Unfortunately the warning wasn't showing up on 
> my host.  I'll take a look why.
Clang doesn't emit that warning on Posix because it wouldn't be true. The 
implicit underlying type of the enum on non-Windows is 'unsigned', not 'int'. 
We could issue a portability warning, but we wouldn't be able to turn it on by 
default because many users don't care about Windows portability.

Anyway, sorry about the bother. This is one of the reasons we just use 
'unsigned' for all our bitfields. =/


Repository:
  rL LLVM

https://reviews.llvm.org/D31167



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


Re: r298913 - Added `applyAtomicChanges` function.

2017-03-30 Thread Juergen Ributzka via cfe-commits
[+ Adrian]

Adrian knows more about the bot setup.

On Wed, Mar 29, 2017 at 8:04 AM, Eric Liu  wrote:

> Hi Juergen, thanks for taking care of this, but I'm wondering if this
> build bot is using a different set of build rules? The error message says 
> "Clang_Tooling
> -> Clang_Format -> Clang_Tooling"; however, the actual dependency is
> clangToolingRefactor -> clangFormat -> clangToolingCore, which seems fine
> for me. I guess the module build uses build rules with lower granularity.
>
> - Eric
>
> On Wed, Mar 29, 2017 at 2:39 AM Juergen Ributzka 
> wrote:
>
>> I reverted the commit in r298967. Please fix the cyclic dependency issue
>> found here:
>> http://lab.llvm.org:8080/green/job/clang-stage2-cmake-
>> modulesRDA_build/4776/
>>
>> Cheers,
>> Juergen
>>
>> On Tue, Mar 28, 2017 at 6:05 AM, Eric Liu via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>> Author: ioeric
>> Date: Tue Mar 28 08:05:32 2017
>> New Revision: 298913
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=298913&view=rev
>> Log:
>> Added `applyAtomicChanges` function.
>>
>> Summary: ... which applies a set of `AtomicChange`s on code.
>>
>> Reviewers: klimek, djasper
>>
>> Reviewed By: djasper
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D30777
>>
>> Modified:
>> cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
>> cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
>> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>>
>> Modified: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
>> clang/Tooling/Refactoring/AtomicChange.h?rev=298913&r1=
>> 298912&r2=298913&view=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h (original)
>> +++ cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h Tue Mar
>> 28 08:05:32 2017
>> @@ -16,6 +16,7 @@
>>  #define LLVM_CLANG_TOOLING_REFACTOR_ATOMICCHANGE_H
>>
>>  #include "clang/Basic/SourceManager.h"
>> +#include "clang/Format/Format.h"
>>  #include "clang/Tooling/Core/Replacement.h"
>>  #include "llvm/ADT/StringRef.h"
>>  #include "llvm/Support/Error.h"
>> @@ -123,6 +124,39 @@ private:
>>tooling::Replacements Replaces;
>>  };
>>
>> +// Defines specs for applying changes.
>> +struct ApplyChangesSpec {
>> +  // If true, cleans up redundant/erroneous code around changed code with
>> +  // clang-format's cleanup functionality, e.g. redundant commas around
>> deleted
>> +  // parameter or empty namespaces introduced by deletions.
>> +  bool Cleanup = true;
>> +
>> +  format::FormatStyle Style = format::getNoStyle();
>> +
>> +  // Options for selectively formatting changes with clang-format:
>> +  // kAll: Format all changed lines.
>> +  // kNone: Don't format anything.
>> +  // kViolations: Format lines exceeding the `ColumnLimit` in `Style`.
>> +  enum FormatOption { kAll, kNone, kViolations };
>> +
>> +  FormatOption Format = kNone;
>> +};
>> +
>> +/// \brief Applies all AtomicChanges in \p Changes to the \p Code.
>> +///
>> +/// This completely ignores the file path in each change and replaces
>> them with
>> +/// \p FilePath, i.e. callers are responsible for ensuring all changes
>> are for
>> +/// the same file.
>> +///
>> +/// \returns The changed code if all changes are applied successfully;
>> +/// otherwise, an llvm::Error carrying llvm::StringError is returned
>> (the Error
>> +/// message can be converted to string with `llvm::toString()` and the
>> +/// error_code should be ignored).
>> +llvm::Expected
>> +applyAtomicChanges(llvm::StringRef FilePath, llvm::StringRef Code,
>> +   llvm::ArrayRef Changes,
>> +   const ApplyChangesSpec &Spec);
>> +
>>  } // end namespace tooling
>>  } // end namespace clang
>>
>>
>> Modified: cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/
>> Refactoring/AtomicChange.cpp?rev=298913&r1=298912&r2=298913&view=diff
>> 
>> ==
>> --- cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp (original)
>> +++ cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp Tue Mar 28
>> 08:05:32 2017
>> @@ -84,6 +84,116 @@ template <> struct MappingTraits>
>>  namespace clang {
>>  namespace tooling {
>> +namespace {
>> +
>> +// Returns true if there is any line that violates \p ColumnLimit in
>> range
>> +// [Start, End].
>> +bool violatesColumnLimit(llvm::StringRef Code, unsigned ColumnLimit,
>> + unsigned Start, unsigned End) {
>> +  auto StartPos = Code.rfind('\n', Start);
>> +  StartPos = (StartPos == llvm::StringRef::npos) ? 0 : StartPos + 1;
>> +
>> +  auto EndPos = Code.find("\n", End);
>> +  if (EndPos == llvm::StringRef::npos)
>> +EndPos = Code.size();
>> +
>> +  llvm::SmallVector Lines;
>> +  Code.substr(StartPos, EndPos - StartPos

[PATCH] D29904: [OpenMP] Prevent emission of exception handling code when using OpenMP to offload to NVIDIA devices.

2017-03-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93513.
gtbercea added a comment.
Herald added a subscriber: rengolin.

Clean-up test.


Repository:
  rL LLVM

https://reviews.llvm.org/D29904

Files:
  lib/Frontend/CompilerInvocation.cpp
  test/OpenMP/target_parallel_no_exceptions.cpp


Index: test/OpenMP/target_parallel_no_exceptions.cpp
===
--- /dev/null
+++ test/OpenMP/target_parallel_no_exceptions.cpp
@@ -0,0 +1,27 @@
+/// Make sure no exception messages are inclided in the llvm output.
+// RUN: %clang -fopenmp -S -emit-llvm -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck 
-check-prefix=CHK-EXCEPTION %s
+
+int inc(int a) {
+  return a + 1;
+}
+
+int test_increment() {
+  int a;
+#pragma omp target
+  {
+#pragma omp parallel
+{
+  a = inc(a);
+}
+  }
+  return a;
+}
+
+int main() {
+  return test_increment();
+}
+
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLESTART__ openmp-nvptx64-nvidia-cuda
+//CHK-EXCEPTION-NOT: __cxa_begin_catch
+//CHK-EXCEPTION-NOT: terminate.lpad
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLEEND__ openmp-nvptx64-nvidia-cuda
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2224,6 +2224,13 @@
 break;
   }
 }
+
+// Set the flag to prevent the implementation from emitting device 
exception
+// handling code for those requiring so.
+if (Opts.OpenMPIsDevice && T.isNVPTX()) {
+  Opts.Exceptions = 0;
+  Opts.CXXExceptions = 0;
+}
   }
 
   // Get the OpenMP target triples if any.


Index: test/OpenMP/target_parallel_no_exceptions.cpp
===
--- /dev/null
+++ test/OpenMP/target_parallel_no_exceptions.cpp
@@ -0,0 +1,27 @@
+/// Make sure no exception messages are inclided in the llvm output.
+// RUN: %clang -fopenmp -S -emit-llvm -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck -check-prefix=CHK-EXCEPTION %s
+
+int inc(int a) {
+  return a + 1;
+}
+
+int test_increment() {
+  int a;
+#pragma omp target
+  {
+#pragma omp parallel
+{
+  a = inc(a);
+}
+  }
+  return a;
+}
+
+int main() {
+  return test_increment();
+}
+
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLESTART__ openmp-nvptx64-nvidia-cuda
+//CHK-EXCEPTION-NOT: __cxa_begin_catch
+//CHK-EXCEPTION-NOT: terminate.lpad
+//CHK-EXCEPTION: __CLANG_OFFLOAD_BUNDLEEND__ openmp-nvptx64-nvidia-cuda
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2224,6 +2224,13 @@
 break;
   }
 }
+
+// Set the flag to prevent the implementation from emitting device exception
+// handling code for those requiring so.
+if (Opts.OpenMPIsDevice && T.isNVPTX()) {
+  Opts.Exceptions = 0;
+  Opts.CXXExceptions = 0;
+}
   }
 
   // Get the OpenMP target triples if any.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r298913 - Added `applyAtomicChanges` function.

2017-03-30 Thread Adrian Prantl via cfe-commits
Note that the green dragon bot doesn't use local submodule visibility, so every 
#include pulls in the entire clang module that header belongs to. Does this 
explain what you are seeing? (You should be able to reproduce with cmake 
-DLLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY=0)

-- adrian

> On Mar 30, 2017, at 11:44 AM, Juergen Ributzka  wrote:
> 
> [+ Adrian]
> 
> Adrian knows more about the bot setup.
> 
> On Wed, Mar 29, 2017 at 8:04 AM, Eric Liu  > wrote:
> Hi Juergen, thanks for taking care of this, but I'm wondering if this build 
> bot is using a different set of build rules? The error message says 
> "Clang_Tooling -> Clang_Format -> Clang_Tooling"; however, the actual 
> dependency is clangToolingRefactor -> clangFormat -> clangToolingCore, which 
> seems fine for me. I guess the module build uses build rules with lower 
> granularity. 
> 
> - Eric
> 
> On Wed, Mar 29, 2017 at 2:39 AM Juergen Ributzka  > wrote:
> I reverted the commit in r298967. Please fix the cyclic dependency issue 
> found here:
> http://lab.llvm.org:8080/green/job/clang-stage2-cmake-modulesRDA_build/4776/ 
> 
> 
> Cheers,
> Juergen
> 
> On Tue, Mar 28, 2017 at 6:05 AM, Eric Liu via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: ioeric
> Date: Tue Mar 28 08:05:32 2017
> New Revision: 298913
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=298913&view=rev 
> 
> Log:
> Added `applyAtomicChanges` function.
> 
> Summary: ... which applies a set of `AtomicChange`s on code.
> 
> Reviewers: klimek, djasper
> 
> Reviewed By: djasper
> 
> Subscribers: cfe-commits
> 
> Differential Revision: https://reviews.llvm.org/D30777 
> 
> 
> Modified:
> cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
> cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
> cfe/trunk/unittests/Tooling/RefactoringTest.cpp
> 
> Modified: cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h?rev=298913&r1=298912&r2=298913&view=diff
>  
> 
> ==
> --- cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h (original)
> +++ cfe/trunk/include/clang/Tooling/Refactoring/AtomicChange.h Tue Mar 28 
> 08:05:32 2017
> @@ -16,6 +16,7 @@
>  #define LLVM_CLANG_TOOLING_REFACTOR_ATOMICCHANGE_H
> 
>  #include "clang/Basic/SourceManager.h"
> +#include "clang/Format/Format.h"
>  #include "clang/Tooling/Core/Replacement.h"
>  #include "llvm/ADT/StringRef.h"
>  #include "llvm/Support/Error.h"
> @@ -123,6 +124,39 @@ private:
>tooling::Replacements Replaces;
>  };
> 
> +// Defines specs for applying changes.
> +struct ApplyChangesSpec {
> +  // If true, cleans up redundant/erroneous code around changed code with
> +  // clang-format's cleanup functionality, e.g. redundant commas around 
> deleted
> +  // parameter or empty namespaces introduced by deletions.
> +  bool Cleanup = true;
> +
> +  format::FormatStyle Style = format::getNoStyle();
> +
> +  // Options for selectively formatting changes with clang-format:
> +  // kAll: Format all changed lines.
> +  // kNone: Don't format anything.
> +  // kViolations: Format lines exceeding the `ColumnLimit` in `Style`.
> +  enum FormatOption { kAll, kNone, kViolations };
> +
> +  FormatOption Format = kNone;
> +};
> +
> +/// \brief Applies all AtomicChanges in \p Changes to the \p Code.
> +///
> +/// This completely ignores the file path in each change and replaces them 
> with
> +/// \p FilePath, i.e. callers are responsible for ensuring all changes are 
> for
> +/// the same file.
> +///
> +/// \returns The changed code if all changes are applied successfully;
> +/// otherwise, an llvm::Error carrying llvm::StringError is returned (the 
> Error
> +/// message can be converted to string with `llvm::toString()` and the
> +/// error_code should be ignored).
> +llvm::Expected
> +applyAtomicChanges(llvm::StringRef FilePath, llvm::StringRef Code,
> +   llvm::ArrayRef Changes,
> +   const ApplyChangesSpec &Spec);
> +
>  } // end namespace tooling
>  } // end namespace clang
> 
> 
> Modified: cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/AtomicChange.cpp?rev=298913&r1=298912&r2=298913&view=diff
>  
> 
> ==
> --- cfe/trunk/lib/Tooling/Refactoring/AtomicC

[PATCH] D31308: [clang-tidy] new check readability-no-alternative-tokens

2017-03-30 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 93519.
mgehre added a comment.

only check C++ code; only match operators that can have alternative 
representations


https://reviews.llvm.org/D31308

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/OperatorsRepresentationCheck.cpp
  clang-tidy/readability/OperatorsRepresentationCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-operators-representation.rst
  test/clang-tidy/readability-operators-representation.cpp

Index: test/clang-tidy/readability-operators-representation.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-operators-representation.cpp
@@ -0,0 +1,63 @@
+// RUN: %check_clang_tidy %s readability-operators-representation %t
+
+void f() {
+  bool a, b, c;
+
+  c = a and b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'and' is an alternative token spelling; consider using '&&' [readability-operators-representation]
+  // CHECK-FIXES: c = a && b;
+  c and_eq a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'and_eq' is an alternative
+  // CHECK-FIXES: c &= a;
+  c = a bitand b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'bitand' is an alternative
+  // CHECK-FIXES: c = a & b;
+  c = a bitor b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'bitor' is an alternative
+  // CHECK-FIXES: c = a | b;
+  c = compl a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'compl' is an alternative
+  // CHECK-FIXES: c = ~ a;
+  c = not a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'not' is an alternative
+  // CHECK-FIXES: c = ! a;
+  c = a not_eq b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'not_eq' is an alternative
+  // CHECK-FIXES: c = a != b;
+  c = a or b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'or' is an alternative
+  // CHECK-FIXES: c = a || b;
+  c or_eq a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'or_eq' is an alternative
+  // CHECK-FIXES: c |= a;
+  c = a xor b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: 'xor' is an alternative
+  // CHECK-FIXES: c = a ^ b;
+  c xor_eq a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'xor_eq' is an alternative
+  // CHECK-FIXES: c ^= a;
+
+#define M a xor
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 'xor' is an alternative
+  // CHECK-FIXES: #define M a ^
+  c = M b;
+
+  int arr[2];
+  for (int i : arr) // OK (Here is an implicit != operator.)
+;
+
+  auto ptr = &c; // OK
+  auto i = -1;   // OK
+  c = a && b;// OK
+  c &= a;// OK
+  c = !a;// OK
+}
+
+struct S {
+  friend S &operator and(const S &, const S &);
+};
+
+int g() {
+  S s1, s2;
+  S s3 = s1 and s2; // OK
+}
Index: docs/clang-tidy/checks/readability-operators-representation.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-operators-representation.rst
@@ -0,0 +1,23 @@
+.. title:: clang-tidy - readability-operators-representation
+
+readability-operators-representation
+
+
+Flags (and replaces) the alternative tokens for binary and unary operators by
+their primary ones for consistency.
+
+=== ===
+Primary Alternative
+=== ===
+``&&``  ``and``
+``&=``  ``and_eq``
+``&``   ``bitand``
+``|``   ``bitor``
+``~``   ``compl``
+``!``   ``not``
+``!=``  ``not_eq``
+``||``  ``or``
+``|=``  ``or_eq``
+``^``   ``xor``
+``^=``  ``xor_eq``
+=== ===
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -145,6 +145,7 @@
readability-misleading-indentation
readability-misplaced-array-index
readability-named-parameter
+   readability-operators-representation
readability-non-const-parameter
readability-redundant-control-flow
readability-redundant-declaration
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -72,6 +72,12 @@
 
   Finds misleading indentation where braces should be introduced or the code should be reformatted.
 
+- New `readability-operators-representation
+  `_ check
+
+  Flags (and replaces) the alternative tokens for binary and unary operators,
+  such as ``not`` (for ``!``) and ``or`` (for ``||``).
+
 - Added `ParameterThreshold` to `readability-function-size`.
 
   Finds functions that have more then `ParameterThreshold` parameters and emits a warning.
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -24,6 +24,7 @@
 #include "MisplacedArrayIndexCheck.h

[PATCH] D31487: [coroutines] Fix rebuilding of implicit and dependent coroutine statements.

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 93510.
EricWF added a comment.

- Remove incorrect comments.


https://reviews.llvm.org/D31487

Files:
  include/clang/AST/StmtCXX.h
  lib/AST/StmtCXX.cpp
  lib/Sema/CoroutineBuilder.h
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/TreeTransform.h
  test/SemaCXX/coroutines.cpp

Index: test/SemaCXX/coroutines.cpp
===
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -534,6 +534,12 @@
   co_await a;
 }
 
+template 
+coro bad_implicit_return_dependent(T) { // expected-error {{'bad_promise_6' declares both 'return_value' and 'return_void'}}
+  co_await a;
+}
+template coro bad_implicit_return_dependent(bad_promise_6); // expected-note {{in instantiation}}
+
 struct bad_promise_7 {
   coro get_return_object();
   suspend_always initial_suspend();
@@ -544,25 +550,38 @@
   co_await a;
 }
 
+template 
+coro no_unhandled_exception_dependent(T) { // expected-error {{'bad_promise_7' is required to declare the member 'unhandled_exception()'}}
+  co_await a;
+}
+template coro no_unhandled_exception_dependent(bad_promise_7); // expected-note {{in instantiation}}
+
 struct bad_promise_base {
 private:
   void return_void();
 };
 struct bad_promise_8 : bad_promise_base {
   coro get_return_object();
   suspend_always initial_suspend();
   suspend_always final_suspend();
-  void unhandled_exception() __attribute__((unavailable)); // expected-note {{made unavailable}}
-  void unhandled_exception() const;// expected-note {{candidate}}
-  void unhandled_exception(void *) const;  // expected-note {{requires 1 argument, but 0 were provided}}
+  void unhandled_exception() __attribute__((unavailable)); // expected-note 2 {{made unavailable}}
+  void unhandled_exception() const;// expected-note 2 {{candidate}}
+  void unhandled_exception(void *) const;  // expected-note 2 {{requires 1 argument, but 0 were provided}}
 };
 coro calls_unhandled_exception() {
   // expected-error@-1 {{call to unavailable member function 'unhandled_exception'}}
   // FIXME: also warn about private 'return_void' here. Even though building
   // the call to unhandled_exception has already failed.
   co_await a;
 }
 
+template 
+coro calls_unhandled_exception_dependent(T) {
+  // expected-error@-1 {{call to unavailable member function 'unhandled_exception'}}
+  co_await a;
+}
+template coro calls_unhandled_exception_dependent(bad_promise_8); // expected-note {{in instantiation}}
+
 struct bad_promise_9 {
   coro get_return_object();
   suspend_always initial_suspend();
@@ -652,3 +671,26 @@
 extern "C" int f(promise_on_alloc_failure_tag) {
   co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
 }
+
+struct bad_promise_11 {
+  coro get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend();
+  void unhandled_exception();
+  void return_void();
+
+private:
+  static coro get_return_object_on_allocation_failure(); // expected-note 2 {{declared private here}}
+};
+coro private_alloc_failure_handler() {
+  // expected-error@-1 {{'get_return_object_on_allocation_failure' is a private member of 'bad_promise_11'}}
+  co_return; // FIXME: Add a "declared coroutine here" note.
+}
+
+template 
+coro dependent_private_alloc_failure_handler(T) {
+  // expected-error@-1 {{'get_return_object_on_allocation_failure' is a private member of 'bad_promise_11'}}
+  co_return; // FIXME: Add a "declared coroutine here" note.
+}
+template coro dependent_private_alloc_failure_handler(bad_promise_11);
+// expected-note@-1 {{requested here}}
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
 #define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
 
+#include "CoroutineBuilder.h"
 #include "TypeLocBuilder.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
@@ -6847,13 +6848,9 @@
 template
 StmtResult
 TreeTransform::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) {
-  // The coroutine body should be re-formed by the caller if necessary.
-  // FIXME: The coroutine body is always rebuilt by ActOnFinishFunctionBody
-  CoroutineBodyStmt::CtorArgs BodyArgs;
-
   auto *ScopeInfo = SemaRef.getCurFunction();
   auto *FD = cast(SemaRef.CurContext);
-  assert(ScopeInfo && !ScopeInfo->CoroutinePromise &&
+  assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
  ScopeInfo->NeedsCoroutineSuspends &&
  ScopeInfo->CoroutineSuspends.first == nullptr &&
  ScopeInfo->CoroutineSuspends.second == nullptr &&
@@ -6865,17 +6862,11 @@
 
   // The new CoroutinePromise object needs to be built and put into the current
   // FunctionScopeInfo before any transformations or rebuilding occurs.
-  auto *Promise = S->getPromiseDecl();
-  auto *NewPromise = SemaRef.

[PATCH] D31487: [coroutines] Fix rebuilding of implicit and dependent coroutine statements.

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: lib/Sema/CoroutineBuilder.h:53
+assert(this->IsValid && "coroutine already invalid");
+this->IsValid = makeReturnObject() && makeParamMoves();
+if (this->IsValid && !IsPromiseDependentType)

GorNishanov wrote:
> makeReturnObject is built as $promise.get_return_object() should it be put 
> into buildDependentStatements?
> 
I don't think so because the statement is required, so we can build it right 
away and transform it later. The "dependent" statements are ones built 
different depending on the results of name lookup.


https://reviews.llvm.org/D31487



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


[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGCall.cpp:4363
+} else if (AllocAlignParam && TargetDecl->hasAttr())
+  EmitAlignmentAssumption(Ret.getScalarVal(), AllocAlignParam);
   }

rjmccall wrote:
> Your old code was fine, you just needed to get the value with 
> CallArgs[index].second.getScalarVal() instead of IRCallArgs[index].
Please add the test cases I suggested here.  You might have to make part of the 
test target-specific.


https://reviews.llvm.org/D29599



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


[libcxx] r299100 - Implement LWG 2842 - optional(U&&) needs to SFINAE on decay_t

2017-03-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Mar 30 14:43:50 2017
New Revision: 299100

URL: http://llvm.org/viewvc/llvm-project?rev=299100&view=rev
Log:
Implement LWG 2842 - optional(U&&) needs to SFINAE on decay_t

Modified:
libcxx/trunk/include/optional

libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/optional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/optional?rev=299100&r1=299099&r2=299100&view=diff
==
--- libcxx/trunk/include/optional (original)
+++ libcxx/trunk/include/optional Thu Mar 30 14:43:50 2017
@@ -531,7 +531,7 @@ private:
 };
 template 
 using _CheckOptionalArgsCtor = conditional_t<
-!is_same_v &&
+!is_same_v, in_place_t> &&
 !is_same_v, optional>,
 _CheckOptionalArgsConstructor,
 __check_tuple_constructor_fail

Modified: 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp?rev=299100&r1=299099&r2=299100&view=diff
==
--- 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp
 Thu Mar 30 14:43:50 2017
@@ -35,6 +35,11 @@ struct ExplicitThrow
 constexpr explicit ExplicitThrow(int x) { if (x != -1) TEST_THROW(6);}
 };
 
+struct ImplicitAny {
+  template 
+  constexpr ImplicitAny(U&&) {}
+};
+
 
 template 
 constexpr bool implicit_conversion(optional&& opt, const From& v)
@@ -79,6 +84,15 @@ void test_implicit()
 using T = TestTypes::TestType;
 assert(implicit_conversion(3, T(3)));
 }
+  {
+using O = optional;
+static_assert(!test_convertible(), "");
+static_assert(!test_convertible(), "");
+static_assert(!test_convertible(), "");
+static_assert(!test_convertible(), "");
+static_assert(!test_convertible(), "");
+
+  }
 #ifndef TEST_HAS_NO_EXCEPTIONS
 {
 try {

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=299100&r1=299099&r2=299100&view=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Thu Mar 30 14:43:50 2017
@@ -460,7 +460,7 @@
http://wg21.link/LWG2835";>2835LWG 2536 
seems to misspecify Kona
http://wg21.link/LWG2837";>2837gcd and lcm 
should support a wider range of input 
valuesKonaComplete
http://wg21.link/LWG2838";>2838is_literal_type specification 
needs a little cleanupKonaComplete
-   http://wg21.link/LWG2842";>2842in_place_t 
check for optional::optional(U&&) should decay 
UKona
+   http://wg21.link/LWG2842";>2842in_place_t 
check for optional::optional(U&&) should decay 
UKonaComplete
http://wg21.link/LWG2850";>2850std::function move constructor 
does unnecessary workKona
http://wg21.link/LWG2853";>2853Possible 
inconsistency in specification of erase in 
[vector.modifiers]Kona
http://wg21.link/LWG2855";>2855std::throw_with_nested("string_literal")Kona


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


[libcxx] r299105 - Fix LWG 2934 - optional doesn't compare with T

2017-03-30 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Mar 30 15:06:52 2017
New Revision: 299105

URL: http://llvm.org/viewvc/llvm-project?rev=299105&view=rev
Log:
Fix LWG 2934 - optional doesn't compare with T

Modified:
libcxx/trunk/include/optional
libcxx/trunk/test/std/utilities/optional/optional.comp_with_t/equal.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.comp_with_t/greater.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.comp_with_t/greater_equal.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.comp_with_t/less_equal.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.comp_with_t/less_than.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.comp_with_t/not_equal.pass.cpp
libcxx/trunk/test/std/utilities/optional/optional.relops/equal.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.relops/greater_equal.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.relops/greater_than.pass.cpp
libcxx/trunk/test/std/utilities/optional/optional.relops/less_equal.pass.cpp
libcxx/trunk/test/std/utilities/optional/optional.relops/less_than.pass.cpp
libcxx/trunk/test/std/utilities/optional/optional.relops/not_equal.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/include/optional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/optional?rev=299105&r1=299104&r2=299105&view=diff
==
--- libcxx/trunk/include/optional (original)
+++ libcxx/trunk/include/optional Thu Mar 30 15:06:52 2017
@@ -921,14 +921,14 @@ private:
 };
 
 // Comparisons between optionals
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v() ==
-_VSTD::declval()), bool>,
+_VSTD::declval()), bool>,
 bool
 >
-operator==(const optional<_Tp>& __x, const optional<_Tp>& __y)
+operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
 {
 if (static_cast(__x) != static_cast(__y))
 return false;
@@ -937,14 +937,14 @@ operator==(const optional<_Tp>& __x, con
 return *__x == *__y;
 }
 
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v() !=
-_VSTD::declval()), bool>,
+_VSTD::declval()), bool>,
 bool
 >
-operator!=(const optional<_Tp>& __x, const optional<_Tp>& __y)
+operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
 {
 if (static_cast(__x) != static_cast(__y))
 return true;
@@ -953,14 +953,14 @@ operator!=(const optional<_Tp>& __x, con
 return *__x != *__y;
 }
 
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v() <
-_VSTD::declval()), bool>,
+_VSTD::declval()), bool>,
 bool
 >
-operator<(const optional<_Tp>& __x, const optional<_Tp>& __y)
+operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
 {
 if (!static_cast(__y))
 return false;
@@ -969,14 +969,14 @@ operator<(const optional<_Tp>& __x, cons
 return *__x < *__y;
 }
 
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v() >
-_VSTD::declval()), bool>,
+_VSTD::declval()), bool>,
 bool
 >
-operator>(const optional<_Tp>& __x, const optional<_Tp>& __y)
+operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
 {
 if (!static_cast(__x))
 return false;
@@ -985,14 +985,14 @@ operator>(const optional<_Tp>& __x, cons
 return *__x > *__y;
 }
 
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v() <=
-_VSTD::declval()), bool>,
+_VSTD::declval()), bool>,
 bool
 >
-operator<=(const optional<_Tp>& __x, const optional<_Tp>& __y)
+operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
 {
 if (!static_cast(__x))
 return true;
@@ -1001,14 +1001,14 @@ operator<=(const optional<_Tp>& __x, con
 return *__x <= *__y;
 }
 
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v() >=
-_VSTD::declval()), bool>,
+_VSTD::declval()), bool>,
 bool
 >
-operator>=(const optional<_Tp>& __x, const optional<_Tp>& __y)
+operator>=(const optional<_Tp>& __x, const optional<_Up>& __y)
 {
 if (!static_cast(__y))
 return true;
@@ -1115,146 +1115,146 @@ operator>=(nullopt_t, const optional<_Tp
 }
 
 // Comparisons with T
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v() ==
-_VSTD::declval()), bool>,
+_VSTD::declval()), bool>,
 bool
 >
-operator==(const optional<_Tp>& __x, const _Tp& __v)
+operator==(const optional<_Tp>& __x, const _Up& __v)
 {
 return static_cast(__x) ? *__x == __v : false;
 }
 
-template 
+template 
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<
 is_convertible_v() ==
-_VSTD::declval()), bool>,
+_VSTD::declval()), bool>,
 bool
 >
-operato

Re: [PATCH] Use the correct ObjC++ personality

2017-03-30 Thread Jonathan Schleifer via cfe-commits
> Testcase?

Shouldn't be necessary for such a simple and extremely obvious one-liner.

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


[PATCH] D31101: [ThinLTO] Use clang's existing code gen handling for ThinLTO backends

2017-03-30 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: lib/CodeGen/BackendUtil.cpp:1007
   else
 AsmHelper.EmitAssembly(Action, std::move(OS));
 

tejohnson wrote:
> I just noticed that EmitAssembly does a lot more than just emission - it is 
> also setting up an optimization pipeline in CreatePasses, which we don't want 
> to do in the ThinLTO backend case as we already do the opt in LTO. Which 
> makes me think that the simplest and most consistent solution, especially if 
> as in discussed in D31114 we'll be using the LTO API for emitting object and 
> assembly code, is to use LTO for all file emission in the ThinLTO backend 
> case. It would mean extending lto::Config to be able to flag when we want to 
> emit-llvm or emit-llvm-bc, and invoke the appropriate module writer/printer 
> instead of normal codegen. That way -emit-llvm* will always get output 
> corresponding to the native object/assembly in the ThinLTO backend case. WDYT?
I have a new patch set that will do just this that I am uploading momentarily


https://reviews.llvm.org/D31101



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


[PATCH] D31101: [ThinLTO] Use clang's existing code gen handling for ThinLTO backends

2017-03-30 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 93535.
tejohnson added a comment.

Use LTO to emit LLVM IR


https://reviews.llvm.org/D31101

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/thinlto-emit-llvm.c


Index: test/CodeGen/thinlto-emit-llvm.c
===
--- /dev/null
+++ test/CodeGen/thinlto-emit-llvm.c
@@ -0,0 +1,10 @@
+// Test to ensure -emit-llvm and -emit-llvm-bc work when invoking the
+// ThinLTO backend path.
+// RUN: %clang -O2 %s -flto=thin -c -o %t.o
+// RUN: llvm-lto -thinlto -o %t %t.o
+// RUN: %clang_cc1 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -emit-llvm -o 
- | FileCheck %s
+// RUN: %clang_cc1 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -emit-llvm-bc 
-o - | llvm-dis -o - | FileCheck %s
+
+// CHECK: define void @foo()
+void foo() {
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -902,7 +902,7 @@
 
 static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
   std::unique_ptr OS,
-  std::string SampleProfile) {
+  std::string SampleProfile, BackendAction Action) 
{
   StringMap>
   ModuleToDefinedGVSummaries;
   
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
@@ -954,6 +954,20 @@
   };
   lto::Config Conf;
   Conf.SampleProfile = std::move(SampleProfile);
+  switch (Action) {
+  case Backend_EmitNothing:
+Conf.IROutputType = lto::Config::EIRT_Nothing;
+break;
+  case Backend_EmitLL:
+Conf.IROutputType = lto::Config::EIRT_LL;
+break;
+  case Backend_EmitBC:
+Conf.IROutputType = lto::Config::EIRT_BC;
+break;
+  default:
+Conf.IROutputType = lto::Config::EIRT_CodeGen;
+break;
+  }
   if (Error E = thinBackend(
   Conf, 0, AddStream, *M, *CombinedIndex, ImportList,
   ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) {
@@ -990,7 +1004,7 @@
 bool DoThinLTOBackend = CombinedIndex != nullptr;
 if (DoThinLTOBackend) {
   runThinLTOBackend(CombinedIndex.get(), M, std::move(OS),
-CGOpts.SampleProfileFile);
+CGOpts.SampleProfileFile, Action);
   return;
 }
   }


Index: test/CodeGen/thinlto-emit-llvm.c
===
--- /dev/null
+++ test/CodeGen/thinlto-emit-llvm.c
@@ -0,0 +1,10 @@
+// Test to ensure -emit-llvm and -emit-llvm-bc work when invoking the
+// ThinLTO backend path.
+// RUN: %clang -O2 %s -flto=thin -c -o %t.o
+// RUN: llvm-lto -thinlto -o %t %t.o
+// RUN: %clang_cc1 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -emit-llvm-bc -o - | llvm-dis -o - | FileCheck %s
+
+// CHECK: define void @foo()
+void foo() {
+}
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -902,7 +902,7 @@
 
 static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
   std::unique_ptr OS,
-  std::string SampleProfile) {
+  std::string SampleProfile, BackendAction Action) {
   StringMap>
   ModuleToDefinedGVSummaries;
   CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
@@ -954,6 +954,20 @@
   };
   lto::Config Conf;
   Conf.SampleProfile = std::move(SampleProfile);
+  switch (Action) {
+  case Backend_EmitNothing:
+Conf.IROutputType = lto::Config::EIRT_Nothing;
+break;
+  case Backend_EmitLL:
+Conf.IROutputType = lto::Config::EIRT_LL;
+break;
+  case Backend_EmitBC:
+Conf.IROutputType = lto::Config::EIRT_BC;
+break;
+  default:
+Conf.IROutputType = lto::Config::EIRT_CodeGen;
+break;
+  }
   if (Error E = thinBackend(
   Conf, 0, AddStream, *M, *CombinedIndex, ImportList,
   ModuleToDefinedGVSummaries[M->getModuleIdentifier()], ModuleMap)) {
@@ -990,7 +1004,7 @@
 bool DoThinLTOBackend = CombinedIndex != nullptr;
 if (DoThinLTOBackend) {
   runThinLTOBackend(CombinedIndex.get(), M, std::move(OS),
-CGOpts.SampleProfileFile);
+CGOpts.SampleProfileFile, Action);
   return;
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31508: [ThinLTO] Set up lto::Config properly for codegen in ThinLTO backends

2017-03-30 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
Herald added a subscriber: Prazek.

This involved refactoring out pieces of
EmitAssemblyHelper::CreateTargetMachine for use in runThinLTOBackend.

Subsumes https://reviews.llvm.org/D31114.


https://reviews.llvm.org/D31508

Files:
  lib/CodeGen/BackendUtil.cpp
  test/CodeGen/function-sections.c

Index: test/CodeGen/function-sections.c
===
--- test/CodeGen/function-sections.c
+++ test/CodeGen/function-sections.c
@@ -9,6 +9,12 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fdata-sections -o - < %s | FileCheck %s --check-prefix=DATA_SECT
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -S -fno-data-sections -fdata-sections -o - < %s | FileCheck %s --check-prefix=DATA_SECT
 
+// Try again through a clang invocation of the ThinLTO backend.
+// RUN: %clang -O2 %s -flto=thin -c -o %t.o
+// RUN: llvm-lto -thinlto -o %t %t.o
+// RUN: %clang -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -ffunction-sections -o - | FileCheck %s --check-prefix=FUNC_SECT
+// RUN: %clang -O2 -x ir %t.o -fthinlto-index=%t.thinlto.bc -S -fdata-sections -o - | FileCheck %s --check-prefix=DATA_SECT
+
 const int hello = 123;
 void world() {}
 
@@ -22,7 +28,7 @@
 // FUNC_SECT: section .rodata,
 // FUNC_SECT: hello:
 
-// DATA_SECT-NOT: section
+// DATA_SECT-NOT: .section
 // DATA_SECT: world:
 // DATA_SECT: .section .rodata.hello,
 // DATA_SECT: hello:
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -294,6 +294,139 @@
   MPM->add(createRewriteSymbolsPass(DL));
 }
 
+static CodeGenOpt::Level getCGOptLevel(const CodeGenOptions &CodeGenOpts) {
+  switch (CodeGenOpts.OptimizationLevel) {
+  default:
+llvm_unreachable("Invalid optimization level!");
+  case 0:
+return CodeGenOpt::None;
+  case 1:
+return CodeGenOpt::Less;
+  case 2:
+return CodeGenOpt::Default; // O2/Os/Oz
+  case 3:
+return CodeGenOpt::Aggressive;
+  }
+}
+
+static llvm::CodeModel::Model getCodeModel(const CodeGenOptions &CodeGenOpts) {
+  unsigned CodeModel =
+  llvm::StringSwitch(CodeGenOpts.CodeModel)
+  .Case("small", llvm::CodeModel::Small)
+  .Case("kernel", llvm::CodeModel::Kernel)
+  .Case("medium", llvm::CodeModel::Medium)
+  .Case("large", llvm::CodeModel::Large)
+  .Case("default", llvm::CodeModel::Default)
+  .Default(~0u);
+  assert(CodeModel != ~0u && "invalid code model!");
+  return static_cast(CodeModel);
+}
+
+static llvm::Reloc::Model getRelocModel(const CodeGenOptions &CodeGenOpts) {
+  // Keep this synced with the equivalent code in tools/driver/cc1as_main.cpp.
+  llvm::Optional RM;
+  RM = llvm::StringSwitch(CodeGenOpts.RelocationModel)
+  .Case("static", llvm::Reloc::Static)
+  .Case("pic", llvm::Reloc::PIC_)
+  .Case("ropi", llvm::Reloc::ROPI)
+  .Case("rwpi", llvm::Reloc::RWPI)
+  .Case("ropi-rwpi", llvm::Reloc::ROPI_RWPI)
+  .Case("dynamic-no-pic", llvm::Reloc::DynamicNoPIC);
+  assert(RM.hasValue() && "invalid PIC model!");
+  return *RM;
+}
+
+static TargetMachine::CodeGenFileType getCodeGenFileType(BackendAction Action) {
+  if (Action == Backend_EmitObj)
+return TargetMachine::CGFT_ObjectFile;
+  else if (Action == Backend_EmitMCNull)
+return TargetMachine::CGFT_Null;
+  else {
+assert(Action == Backend_EmitAssembly && "Invalid action!");
+return TargetMachine::CGFT_AssemblyFile;
+  }
+}
+
+static void initTargetOptions(llvm::TargetOptions &Options,
+  const CodeGenOptions &CodeGenOpts,
+  const clang::TargetOptions &TargetOpts,
+  const LangOptions &LangOpts,
+  const HeaderSearchOptions &HSOpts) {
+  Options.ThreadModel =
+  llvm::StringSwitch(CodeGenOpts.ThreadModel)
+  .Case("posix", llvm::ThreadModel::POSIX)
+  .Case("single", llvm::ThreadModel::Single);
+
+  // Set float ABI type.
+  assert((CodeGenOpts.FloatABI == "soft" || CodeGenOpts.FloatABI == "softfp" ||
+  CodeGenOpts.FloatABI == "hard" || CodeGenOpts.FloatABI.empty()) &&
+ "Invalid Floating Point ABI!");
+  Options.FloatABIType =
+  llvm::StringSwitch(CodeGenOpts.FloatABI)
+  .Case("soft", llvm::FloatABI::Soft)
+  .Case("softfp", llvm::FloatABI::Soft)
+  .Case("hard", llvm::FloatABI::Hard)
+  .Default(llvm::FloatABI::Default);
+
+  // Set FP fusion mode.
+  switch (CodeGenOpts.getFPContractMode()) {
+  case CodeGenOptions::FPC_Off:
+Options.AllowFPOpFusion = llvm::FPOpFusion::Strict;
+break;
+  case CodeGenOptions::FPC_On:
+Options.AllowFPOpFusion = llvm::FPOpFusion::Standard;
+break;
+  case CodeGenOptions::FPC_Fast:
+Options.AllowFPOpFusion = llvm::FPOpFusion::Fast;
+break;
+  }
+
+  Options.UseInitArray = CodeGenOpts.UseInitArray;
+  Options.DisableIntegratedAS = CodeGen

[PATCH] D31114: Refactor `initTargetOptions` out of `EmitAssemblyHelper::CreateTargetMachine` and use it to initialize TargetOptions for ThinLTO Backends

2017-03-30 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

As discussed with Mehdi offline, I am taking this one over. I just mailed 
https://reviews.llvm.org/D31508 which supersedes this one.


https://reviews.llvm.org/D31114



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


[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 93537.
erichkeane added a comment.

Added tests as requested by John.


https://reviews.llvm.org/D29599

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CodeGen/alloc-align-attr.c
  test/Sema/alloc-align-attr.c
  test/SemaCXX/alloc-align-attr.cpp

Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -4348,6 +4348,10 @@
   llvm::ConstantInt *AlignmentCI = cast(Alignment);
   EmitAlignmentAssumption(Ret.getScalarVal(), AlignmentCI->getZExtValue(),
   OffsetValue);
+} else if (const auto *AA = TargetDecl->getAttr()) {
+  llvm::Value *ParamVal =
+  CallArgs[AA->getParamIndex() - 1].RV.getScalarVal();
+  EmitAlignmentAssumption(Ret.getScalarVal(), ParamVal);
 }
   }
 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2465,6 +2465,12 @@
   PeepholeProtection protectFromPeepholes(RValue rvalue);
   void unprotectFromPeepholes(PeepholeProtection protection);
 
+  void EmitAlignmentAssumption(llvm::Value *PtrValue, llvm::Value *Alignment,
+   llvm::Value *OffsetValue = nullptr) {
+Builder.CreateAlignmentAssumption(CGM.getDataLayout(), PtrValue, Alignment,
+  OffsetValue);
+  }
+
   //======//
   // Statement Emission
   //======//
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -168,6 +168,16 @@
 Aligned->getSpellingListIndex());
 }
 
+static void instantiateDependentAllocAlignAttr(
+Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs,
+const AllocAlignAttr *Align, Decl *New) {
+  Expr *Param = IntegerLiteral::Create(
+  S.getASTContext(), llvm::APInt(64, Align->getParamIndex()),
+  S.getASTContext().UnsignedLongLongTy, Align->getLocation());
+  S.AddAllocAlignAttr(Align->getLocation(), New, Param,
+  Align->getSpellingListIndex());
+}
+
 static Expr *instantiateDependentFunctionAttrCondition(
 Sema &S, const MultiLevelTemplateArgumentList &TemplateArgs,
 const Attr *A, Expr *OldCond, const Decl *Tmpl, FunctionDecl *New) {
@@ -380,6 +390,12 @@
   continue;
 }
 
+if (const auto *AllocAlign = dyn_cast(TmplAttr)) {
+  instantiateDependentAllocAlignAttr(*this, TemplateArgs, AllocAlign, New);
+  continue;
+}
+
+
 if (const auto *EnableIf = dyn_cast(TmplAttr)) {
   instantiateDependentEnableIfAttr(*this, TemplateArgs, EnableIf, Tmpl,
cast(New));
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -218,21 +218,45 @@
std::greater());
 }
 
+/// \brief A helper function to provide Attribute Location for the Attr types
+/// AND the AttributeList.
+template 
+static typename std::enable_if::value,
+   SourceLocation>::type
+getAttrLoc(const AttrInfo &Attr) {
+  return Attr.getLocation();
+}
+static SourceLocation getAttrLoc(const clang::AttributeList &Attr) {
+  return Attr.getLoc();
+}
+
+/// \brief A helper function to provide Attribute Name for the Attr types
+/// AND the AttributeList.
+template 
+static typename std::enable_if::value,
+   const AttrInfo *>::type
+getAttrName(const AttrInfo &Attr) {
+  return &Attr;
+}
+const IdentifierInfo *getAttrName(const clang::AttributeList &Attr) {
+  return Attr.getName();
+}
+
 /// \brief If Expr is a valid integer constant, get the value of the integer
 /// expression and return success or failure. May output an error.
-static bool checkUInt32Argument(Sema &S, const AttributeList &Attr,
-const Expr *Expr, uint32_t &Val,
-unsigned Idx = UINT_MAX) {
+template
+static bool checkUInt32Argument(Sema &S, const AttrInfo& Attr, const Expr *Expr,
+uint32_t &Val, unsigned Idx = UINT_MAX) {
   llvm::APSInt I(32);
   if (Expr->isTypeDependent() || Expr->isValueDependent() ||
   !Expr->isIntegerConstantExpr(I, S.Context)) {
 if (Idx != UINT_MAX)
-  S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-<< Attr.getName() << Idx << AANT_Ar

[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks.  With that, LGTM.


https://reviews.llvm.org/D29599



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


[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!

Can you drop the svn props on the new files when you commit? I don't think we 
usually set them, and I've seen commits specifically removing the eol-style 
props before.


https://reviews.llvm.org/D29599



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


[PATCH] D31406: [clang-tidy] Reuse FileID in getLocation

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

LG
Do you have commit rights?


https://reviews.llvm.org/D31406



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


r299117 - Clang changes for alloc_align attribute

2017-03-30 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Thu Mar 30 16:48:55 2017
New Revision: 299117

URL: http://llvm.org/viewvc/llvm-project?rev=299117&view=rev
Log:
Clang changes for alloc_align attribute 

GCC has the alloc_align attribute, which is similar to assume_aligned, except 
the attribute's parameter is the index of the integer parameter that needs 
aligning to.

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

Added:
cfe/trunk/test/CodeGen/alloc-align-attr.c
cfe/trunk/test/Sema/alloc-align-attr.c
cfe/trunk/test/SemaCXX/alloc-align-attr.cpp
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=299117&r1=299116&r2=299117&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Mar 30 16:48:55 2017
@@ -1225,6 +1225,14 @@ def AssumeAligned : InheritableAttr {
   let Documentation = [AssumeAlignedDocs];
 }
 
+def AllocAlign : InheritableAttr {
+  let Spellings = [GCC<"alloc_align">];
+  let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
+ "ExpectedFunctionWithProtoType">;
+  let Args = [IntArgument<"ParamIndex">];
+  let Documentation = [AllocAlignDocs];
+}
+
 def NoReturn : InheritableAttr {
   let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
   // FIXME: Does GCC allow this on the function instead?

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=299117&r1=299116&r2=299117&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Mar 30 16:48:55 2017
@@ -244,6 +244,36 @@ An example of how to use ``alloc_size``
   }];
 }
 
+def AllocAlignDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Use ``__attribute__((alloc_align())`` on a function
+declaration to specify that the return value of the function (which must be a
+pointer type) is at least as aligned as the value of the indicated parameter. 
The 
+parameter is given by its index in the list of formal parameters; the first
+parameter has index 1 unless the function is a C++ non-static member function,
+in which case the first parameter has index 2 to account for the implicit 
``this``
+parameter.
+
+.. code-block:: c++
+
+  // The returned pointer has the alignment specified by the first parameter.
+  void *a(size_t align) __attribute__((alloc_align(1)));
+
+  // The returned pointer has the alignment specified by the second parameter.
+  void *b(void *v, size_t align) __attribute__((alloc_align(2)));
+
+  // The returned pointer has the alignment specified by the second visible
+  // parameter, however it must be adjusted for the implicit 'this' parameter.
+  void *Foo::b(void *v, size_t align) __attribute__((alloc_align(3)));
+
+Note that this attribute merely informs the compiler that a function always
+returns a sufficiently aligned pointer. It does not cause the compiler to 
+emit code to enforce that alignment.  The behavior is undefined if the returned
+poitner is not sufficiently aligned.
+  }];
+}
+
 def EnableIfDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=299117&r1=299116&r2=299117&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Mar 30 16:48:55 2017
@@ -8176,6 +8176,11 @@ public:
   void AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, Expr *OE,
 unsigned SpellingListIndex);
 
+  /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
+  /// declaration.
+  void AddAllocAlignAttr(SourceRange AttrRange, Decl *D, Expr *ParamExpr,
+ unsigned SpellingListIndex);
+
   /// AddAlignValueAttr - Adds an align_value attribute to a particular
   /// declaration.
   void AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E,

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=299117&r1=299116&r2=299117&view=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Mar 30 16:48:55 2017
@@ -4348,6

[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Thanks guys.  I THINK I properly removed the svn properties properly, though, I 
actually didn't know they existed until just now!


Repository:
  rL LLVM

https://reviews.llvm.org/D29599



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


[PATCH] D29599: Clang Changes for alloc_align

2017-03-30 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299117: Clang changes for alloc_align attribute  (authored 
by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D29599?vs=93537&id=93549#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29599

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/CodeGen/CGCall.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
  cfe/trunk/test/CodeGen/alloc-align-attr.c
  cfe/trunk/test/Sema/alloc-align-attr.c
  cfe/trunk/test/SemaCXX/alloc-align-attr.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -8176,6 +8176,11 @@
   void AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E, Expr *OE,
 unsigned SpellingListIndex);
 
+  /// AddAllocAlignAttr - Adds an alloc_align attribute to a particular
+  /// declaration.
+  void AddAllocAlignAttr(SourceRange AttrRange, Decl *D, Expr *ParamExpr,
+ unsigned SpellingListIndex);
+
   /// AddAlignValueAttr - Adds an align_value attribute to a particular
   /// declaration.
   void AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E,
Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -244,6 +244,36 @@
   }];
 }
 
+def AllocAlignDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+Use ``__attribute__((alloc_align())`` on a function
+declaration to specify that the return value of the function (which must be a
+pointer type) is at least as aligned as the value of the indicated parameter. The 
+parameter is given by its index in the list of formal parameters; the first
+parameter has index 1 unless the function is a C++ non-static member function,
+in which case the first parameter has index 2 to account for the implicit ``this``
+parameter.
+
+.. code-block:: c++
+
+  // The returned pointer has the alignment specified by the first parameter.
+  void *a(size_t align) __attribute__((alloc_align(1)));
+
+  // The returned pointer has the alignment specified by the second parameter.
+  void *b(void *v, size_t align) __attribute__((alloc_align(2)));
+
+  // The returned pointer has the alignment specified by the second visible
+  // parameter, however it must be adjusted for the implicit 'this' parameter.
+  void *Foo::b(void *v, size_t align) __attribute__((alloc_align(3)));
+
+Note that this attribute merely informs the compiler that a function always
+returns a sufficiently aligned pointer. It does not cause the compiler to 
+emit code to enforce that alignment.  The behavior is undefined if the returned
+poitner is not sufficiently aligned.
+  }];
+}
+
 def EnableIfDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -1225,6 +1225,14 @@
   let Documentation = [AssumeAlignedDocs];
 }
 
+def AllocAlign : InheritableAttr {
+  let Spellings = [GCC<"alloc_align">];
+  let Subjects = SubjectList<[HasFunctionProto], WarnDiag,
+ "ExpectedFunctionWithProtoType">;
+  let Args = [IntArgument<"ParamIndex">];
+  let Documentation = [AllocAlignDocs];
+}
+
 def NoReturn : InheritableAttr {
   let Spellings = [GCC<"noreturn">, Declspec<"noreturn">];
   // FIXME: Does GCC allow this on the function instead?
Index: cfe/trunk/test/SemaCXX/alloc-align-attr.cpp
===
--- cfe/trunk/test/SemaCXX/alloc-align-attr.cpp
+++ cfe/trunk/test/SemaCXX/alloc-align-attr.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct param_num {
+  void* Foo(int a) __attribute__((alloc_align(1))); // expected-error {{'alloc_align' attribute is invalid for the implicit this argument}}
+};
+
+
+template 
+struct dependent_ret {
+  T* Foo(int a) __attribute__((alloc_align(2)));// no-warning, ends up being int**.
+  T Foo2(int a) __attribute__((alloc_align(2)));// expected-warning {{'alloc_align' attribute only applies to return values that are pointers or references}}
+};
+
+// Following 2 errors associated only with the 'float' versions below.
+template 
+struct dependent_param_struct {
+  void* Foo(T param) __attribute__((alloc_align(2))); // expected-error {{'alloc_align' attribute argument may only refer to a function parameter of integer type}}
+};
+
+template 
+void* dependent_param_func(T param) __attribute__((alloc_al

[PATCH] D31513: [Sema] Add __is_aggregate type-trait and implement LWG 2015

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

LWG 2911  adds 
`std::is_aggregate` to the library, which requires a new builtin trait. This 
patch implements `__is_aggregate`.

Additionally this patch implements LWG 2015 
, which requires than 
arrays used with [meta.unary.prop] traits have a complete element type.


https://reviews.llvm.org/D31513

Files:
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/PCH/cxx-traits.cpp
  test/PCH/cxx-traits.h
  test/SemaCXX/type-traits.cpp
  test/SemaTemplate/instantiate-method.cpp

Index: test/SemaTemplate/instantiate-method.cpp
===
--- test/SemaTemplate/instantiate-method.cpp
+++ test/SemaTemplate/instantiate-method.cpp
@@ -49,6 +49,18 @@
 // the code below should probably instantiate by itself.
 int abstract_destructor[__is_abstract(HasDestructor)? 1 : -1];
 
+template 
+class IsAggregate {
+};
+
+template 
+class IsNotAggregate {
+  T value;
+public:
+  IsNotAggregate() {}
+};
+int test_is_aggregate[__is_aggregate(IsAggregate) ? 1 : -1];
+int test_is_not_aggregate[__is_aggregate(IsNotAggregate) ? -1 : 1];
 
 template
 class Constructors {
Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fms-extensions -Wno-microsoft %s
+
 #define T(b) (b) ? 1 : -1
 #define F(b) (b) ? -1 : 1
 
@@ -9,12 +12,14 @@
 struct POD { Enum e; int i; float f; NonPOD* p; };
 struct Empty {};
 typedef Empty EmptyAr[10];
+typedef Empty EmptyArNB[];
+typedef Empty EmptyArMB[1][2];
 typedef int Int;
 typedef Int IntAr[10];
 typedef Int IntArNB[];
 class Statics { static int priv; static NonPOD np; };
 union EmptyUnion {};
-union IncompleteUnion;
+union IncompleteUnion; // expected-note {{forward declaration of 'IncompleteUnion'}}
 union Union { int i; float f; };
 struct HasFunc { void f (); };
 struct HasOp { void operator *(); };
@@ -38,6 +43,10 @@
 typedef Derives DerivesArNB[];
 struct DerivesEmpty : Empty {};
 struct HasCons { HasCons(int); };
+struct HasDefaultCons { HasDefaultCons() = default; };
+struct HasExplicitDefaultCons { explicit HasExplicitDefaultCons() = default; };
+struct HasInheritedCons : HasDefaultCons { using HasDefaultCons::HasDefaultCons; };
+struct HasNoInheritedCons : HasCons {};
 struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
 struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
 struct HasNoThrowMoveAssign { 
@@ -48,8 +57,15 @@
 const HasNoExceptNoThrowMoveAssign&&) noexcept; 
 };
 struct HasThrowMoveAssign { 
-  HasThrowMoveAssign& operator=(
-const HasThrowMoveAssign&&) throw(POD); };
+  HasThrowMoveAssign& operator=(const HasThrowMoveAssign&&)
+#if __cplusplus <= 201402L
+  throw(POD);
+#else
+  noexcept(false);
+#endif
+};
+
+
 struct HasNoExceptFalseMoveAssign { 
   HasNoExceptFalseMoveAssign& operator=(
 const HasNoExceptFalseMoveAssign&&) noexcept(false); };
@@ -81,6 +97,7 @@
 class  HasPriv { int priv; };
 class  HasProt { protected: int prot; };
 struct HasRef { int i; int& ref; HasRef() : i(0), ref(i) {} };
+struct HasRefAggregate { int i; int& ref; };
 struct HasNonPOD { NonPOD np; };
 struct HasVirt { virtual void Virt() {}; };
 typedef NonPOD NonPODAr[10];
@@ -152,7 +169,12 @@
 };
 
 struct ThrowingDtor {
-  ~ThrowingDtor() throw(int);
+  ~ThrowingDtor()
+#if __cplusplus <= 201402L
+  throw(int);
+#else
+  noexcept(false);
+#endif
 };
 
 struct NoExceptDtor {
@@ -163,6 +185,20 @@
   ~NoThrowDtor() throw();
 };
 
+struct ACompleteType {};
+struct AnIncompleteType; // expected-note 4 {{forward declaration of 'AnIncompleteType'}}
+typedef AnIncompleteType AnIncompleteTypeAr[42];
+typedef AnIncompleteType AnIncompleteTypeArNB[];
+typedef AnIncompleteType AnIncompleteTypeArMB[1][10];
+
+struct HasInClassInit {
+  int x = 42;
+};
+
+struct HasPrivateBase : private ACompleteType {};
+struct HasProtectedBase : protected ACompleteType {};
+struct HasVirtBase : virtual ACompleteType {};
+
 void is_pod()
 {
   { int arr[T(__is_pod(int))]; }
@@ -452,6 +488,66 @@
   int t31[F(__is_floating_point(IntArNB))];
 }
 
+#if __cplusplus <= 201103L
+#define T_AFTER_CPP11(...) F(__VA_ARGS__)
+#else
+#define T_AFTER_CPP11(...) T(__VA_ARGS__)
+#endif
+
+#if __cplusplus <= 201402L
+#define T_AFTER_CPP14(...) F(__VA_ARGS__)
+#else
+#define T_AFTER_CPP14(...) T(__VA_ARGS__)
+#endif
+
+void is_

[clang-tools-extra] r299119 - [clang-tidy] Reuse FileID in getLocation

2017-03-30 Thread Chih-Hung Hsieh via cfe-commits
Author: chh
Date: Thu Mar 30 17:09:17 2017
New Revision: 299119

URL: http://llvm.org/viewvc/llvm-project?rev=299119&view=rev
Log:
[clang-tidy] Reuse FileID in getLocation

One FileID per warning will increase and overflow NextLocalOffset
when input file is large with many warnings.
Reusing FileID avoids this problem.

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


Modified:
clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp

Modified: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp?rev=299119&r1=299118&r2=299119&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp Thu Mar 30 17:09:17 2017
@@ -238,7 +238,7 @@ private:
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 


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


[PATCH] D31406: [clang-tidy] Reuse FileID in getLocation

2017-03-30 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL299119: [clang-tidy] Reuse FileID in getLocation (authored 
by chh).

Changed prior to commit:
  https://reviews.llvm.org/D31406?vs=93499&id=93554#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31406

Files:
  clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp


Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -238,7 +238,7 @@
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 


Index: clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
===
--- clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
+++ clang-tools-extra/trunk/clang-tidy/ClangTidy.cpp
@@ -238,7 +238,7 @@
   return SourceLocation();
 
 const FileEntry *File = SourceMgr.getFileManager().getFile(FilePath);
-FileID ID = SourceMgr.createFileID(File, SourceLocation(), SrcMgr::C_User);
+FileID ID = SourceMgr.getOrCreateFileID(File, SrcMgr::C_User);
 return SourceMgr.getLocForStartOfFile(ID).getLocWithOffset(Offset);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31513: [Sema] Add __is_aggregate type-trait and implement LWG 2015

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 93555.
EricWF added a comment.

- Move test to correct file.


https://reviews.llvm.org/D31513

Files:
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/Parse/ParseDeclCXX.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/PCH/cxx-traits.cpp
  test/PCH/cxx-traits.h
  test/SemaCXX/type-traits.cpp

Index: test/SemaCXX/type-traits.cpp
===
--- test/SemaCXX/type-traits.cpp
+++ test/SemaCXX/type-traits.cpp
@@ -1,20 +1,37 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fms-extensions -Wno-microsoft %s
+
 #define T(b) (b) ? 1 : -1
 #define F(b) (b) ? -1 : 1
 
+#if __cplusplus <= 201103L
+#define T_AFTER_CPP11(...) F(__VA_ARGS__)
+#else
+#define T_AFTER_CPP11(...) T(__VA_ARGS__)
+#endif
+
+#if __cplusplus <= 201402L
+#define T_AFTER_CPP14(...) F(__VA_ARGS__)
+#else
+#define T_AFTER_CPP14(...) T(__VA_ARGS__)
+#endif
+
 struct NonPOD { NonPOD(int); };
 
 // PODs
 enum Enum { EV };
 struct POD { Enum e; int i; float f; NonPOD* p; };
 struct Empty {};
 typedef Empty EmptyAr[10];
+typedef Empty EmptyArNB[];
+typedef Empty EmptyArMB[1][2];
 typedef int Int;
 typedef Int IntAr[10];
 typedef Int IntArNB[];
 class Statics { static int priv; static NonPOD np; };
 union EmptyUnion {};
-union IncompleteUnion;
+union IncompleteUnion; // expected-note {{forward declaration of 'IncompleteUnion'}}
 union Union { int i; float f; };
 struct HasFunc { void f (); };
 struct HasOp { void operator *(); };
@@ -38,6 +55,10 @@
 typedef Derives DerivesArNB[];
 struct DerivesEmpty : Empty {};
 struct HasCons { HasCons(int); };
+struct HasDefaultCons { HasDefaultCons() = default; };
+struct HasExplicitDefaultCons { explicit HasExplicitDefaultCons() = default; };
+struct HasInheritedCons : HasDefaultCons { using HasDefaultCons::HasDefaultCons; };
+struct HasNoInheritedCons : HasCons {};
 struct HasCopyAssign { HasCopyAssign operator =(const HasCopyAssign&); };
 struct HasMoveAssign { HasMoveAssign operator =(const HasMoveAssign&&); };
 struct HasNoThrowMoveAssign { 
@@ -48,8 +69,15 @@
 const HasNoExceptNoThrowMoveAssign&&) noexcept; 
 };
 struct HasThrowMoveAssign { 
-  HasThrowMoveAssign& operator=(
-const HasThrowMoveAssign&&) throw(POD); };
+  HasThrowMoveAssign& operator=(const HasThrowMoveAssign&&)
+#if __cplusplus <= 201402L
+  throw(POD);
+#else
+  noexcept(false);
+#endif
+};
+
+
 struct HasNoExceptFalseMoveAssign { 
   HasNoExceptFalseMoveAssign& operator=(
 const HasNoExceptFalseMoveAssign&&) noexcept(false); };
@@ -81,6 +109,7 @@
 class  HasPriv { int priv; };
 class  HasProt { protected: int prot; };
 struct HasRef { int i; int& ref; HasRef() : i(0), ref(i) {} };
+struct HasRefAggregate { int i; int& ref; };
 struct HasNonPOD { NonPOD np; };
 struct HasVirt { virtual void Virt() {}; };
 typedef NonPOD NonPODAr[10];
@@ -152,7 +181,12 @@
 };
 
 struct ThrowingDtor {
-  ~ThrowingDtor() throw(int);
+  ~ThrowingDtor()
+#if __cplusplus <= 201402L
+  throw(int);
+#else
+  noexcept(false);
+#endif
 };
 
 struct NoExceptDtor {
@@ -163,6 +197,20 @@
   ~NoThrowDtor() throw();
 };
 
+struct ACompleteType {};
+struct AnIncompleteType; // expected-note 4 {{forward declaration of 'AnIncompleteType'}}
+typedef AnIncompleteType AnIncompleteTypeAr[42];
+typedef AnIncompleteType AnIncompleteTypeArNB[];
+typedef AnIncompleteType AnIncompleteTypeArMB[1][10];
+
+struct HasInClassInit {
+  int x = 42;
+};
+
+struct HasPrivateBase : private ACompleteType {};
+struct HasProtectedBase : protected ACompleteType {};
+struct HasVirtBase : virtual ACompleteType {};
+
 void is_pod()
 {
   { int arr[T(__is_pod(int))]; }
@@ -452,6 +500,68 @@
   int t31[F(__is_floating_point(IntArNB))];
 }
 
+template 
+struct AggregateTemplate {
+  T value;
+};
+
+template 
+struct NonAggregateTemplate {
+  T value;
+  NonAggregateTemplate();
+};
+
+void is_aggregate()
+{
+  int t01[F(__is_aggregate(NonPOD))];
+  int t02[F(__is_aggregate(Enum))];
+  int t03[T(__is_aggregate(POD))];
+  int t04[T(__is_aggregate(Empty))];
+  int t05[T(__is_aggregate(EmptyAr))];
+  int t06[T(__is_aggregate(EmptyArNB))];
+  int t07[T(__is_aggregate(EmptyArMB))];
+  int t08[F(__is_aggregate(AnIncompleteType))]; // expected-error {{incomplete type 'AnIncompleteType' used in type trait expression}}
+  int t09[F(__is_aggregate(AnIncompleteTypeAr))]; // expected-error {{incomplete type 'AnIncompleteType' used in type trait expression}}
+  int t10[F(__is_aggregate(AnIncompleteTypeArNB))]; // expected-error {{incomplete type 'AnIncompleteType' used in type trait expression}}
+  int t11[F(__is_aggregate(AnIncompleteTypeArMB))]; // expected-error {{incomplete type 'AnIncompleteType' use

[PATCH] D29904: [OpenMP] Prevent emission of exception handling code when using OpenMP to offload to NVIDIA devices.

2017-03-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added inline comments.



Comment at: lib/Frontend/CompilerInvocation.cpp:2167-2172
+// Set the flag to prevent the implementation from emitting device 
exception
+// handling code for those requiring so.
+if (Opts.OpenMPIsDevice && T.isNVPTX()) {
+  Opts.Exceptions = 0;
+  Opts.CXXExceptions = 0;
+}

ABataev wrote:
> I'm not sure this is the right place for this code.
Alexey, any suggestion where this code should be moved to?


Repository:
  rL LLVM

https://reviews.llvm.org/D29904



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


[PATCH] D29642: [OpenMP] Make OpenMP generated code for the NVIDIA device relocatable by default

2017-03-30 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 93557.
gtbercea added a comment.

Change prefix name in test.


Repository:
  rL LLVM

https://reviews.llvm.org/D29642

Files:
  lib/Driver/ToolChains/Cuda.cpp
  test/Driver/openmp-offload.c


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -587,3 +587,11 @@
 // CHK-UBUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]"
 // CHK-UBUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" 
"-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux"
 "-outputs=
 // CHK-UBUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" 
"-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]"
+
+/// ###
+
+/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using 
OpenMP.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
+
+// CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -272,6 +272,10 @@
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
+  // In OpenMP we need to generate relocatable code.
+  if (JA.isOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-c");
+
   const char *Exec;
   if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
 Exec = A->getValue();


Index: test/Driver/openmp-offload.c
===
--- test/Driver/openmp-offload.c
+++ test/Driver/openmp-offload.c
@@ -587,3 +587,11 @@
 // CHK-UBUJOBS-ST-SAME: [[HOSTOBJ:[^\\/]+\.o]]" "{{.*}}[[HOSTASM]]"
 // CHK-UBUJOBS-ST: clang-offload-bundler{{.*}}" "-type=o" "-targets=openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu,host-powerpc64le--linux" "-outputs=
 // CHK-UBUJOBS-ST-SAME: [[RES:[^\\/]+\.o]]" "-inputs={{.*}}[[T1OBJ]],{{.*}}[[T2OBJ]],{{.*}}[[HOSTOBJ]]"
+
+/// ###
+
+/// Check PTXAS is passed -c flag when offloading to an NVIDIA device using OpenMP.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps -no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS %s
+
+// CHK-PTXAS-DEFAULT: ptxas{{.*}}" "-c"
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -272,6 +272,10 @@
   for (const auto& A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
 CmdArgs.push_back(Args.MakeArgString(A));
 
+  // In OpenMP we need to generate relocatable code.
+  if (JA.isOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-c");
+
   const char *Exec;
   if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
 Exec = A->getValue();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D31515: [libc++] Implement LWG 2911 - add an is_aggregate type-trait

2017-03-30 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

This patch implements http://cplusplus.github.io/LWG/lwg-defects.html#2911.

I'm putting this up for review until __is_aggregate is added to clang (See 
https://reviews.llvm.org/D31513)


https://reviews.llvm.org/D31515

Files:
  include/__config
  include/type_traits
  
test/libcxx/utilities/meta/meta.unary/meta.unary.prop/missing_is_aggregate_trait.fail.cpp
  test/std/utilities/meta/meta.unary/meta.unary.prop/is_aggregate.pass.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -480,7 +480,7 @@
 	http://wg21.link/LWG2904";>2904Make variant move-assignment more exception safeKona
 	http://wg21.link/LWG2905";>2905is_constructible_v, P, D const &> should be false when D is not copy constructibleKona
 	http://wg21.link/LWG2908";>2908The less-than operator for shared pointers could do moreKona
-	http://wg21.link/LWG2911";>2911An is_aggregate type trait is neededKona
+	http://wg21.link/LWG2911";>2911An is_aggregate type trait is neededKonaComplete
 	http://wg21.link/LWG2921";>2921packaged_task and type-erased allocatorsKona
 	http://wg21.link/LWG2934";>2934optional doesn't compare with TKonaComplete
 

  1   2   >