r352956 - [ASTImporter] Fix up test that only works on X86.

2019-02-02 Thread David Green via cfe-commits
Author: dmgreen
Date: Sat Feb  2 00:31:22 2019
New Revision: 352956

URL: http://llvm.org/viewvc/llvm-project?rev=352956&view=rev
Log:
[ASTImporter] Fix up test that only works on X86.

The test will fail if the default target triple is not X86,
even if the host platform is. So move the check into the
test at runtime.


Modified:
cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp

Modified: cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp?rev=352956&r1=352955&r2=352956&view=diff
==
--- cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp (original)
+++ cfe/trunk/unittests/AST/StructuralEquivalenceTest.cpp Sat Feb  2 00:31:22 
2019
@@ -378,10 +378,12 @@ TEST_F(StructuralEquivalenceFunctionTest
   EXPECT_TRUE(testStructuralMatch(t));
 }
 
-// These attributes may not be available on certain platforms.
-#if defined(__x86_64__) && defined(__linux__)
 TEST_F(StructuralEquivalenceFunctionTest,
 FunctionsWithDifferentCallingConventions) {
+  // These attributes may not be available on certain platforms.
+  if (llvm::Triple(llvm::sys::getDefaultTargetTriple()).getArch() !=
+  llvm::Triple::x86_64)
+return;
   auto t = makeNamedDecls(
   "__attribute__((preserve_all)) void foo();",
   "__attribute__((ms_abi))   void foo();",
@@ -390,13 +392,15 @@ TEST_F(StructuralEquivalenceFunctionTest
 }
 
 TEST_F(StructuralEquivalenceFunctionTest, FunctionsWithDifferentSavedRegsAttr) 
{
+  if (llvm::Triple(llvm::sys::getDefaultTargetTriple()).getArch() !=
+  llvm::Triple::x86_64)
+return;
   auto t = makeNamedDecls(
   "__attribute__((no_caller_saved_registers)) void foo();",
   "   void foo();",
   Lang_C);
   EXPECT_FALSE(testStructuralMatch(t));
 }
-#endif
 
 struct StructuralEquivalenceCXXMethodTest : StructuralEquivalenceTest {
 };


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


Re: r352055 - Fix failing buildbots

2019-02-02 Thread David Green via cfe-commits
Sounds good to me, easy enough for me to test here. And I'll count that as a 
review.


I've given it a try in rC352956. We can see how that bot feels about it.


Dave

> Dave,
>
> The idea to check explicitly the triple inside the test function is quite 
> convincing. Will you try to fix it that way? Or if it can wait a bit, this 
> will be my first thing to do on Monday.
>
> Gábor
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r352957 - [clangd] Fix heap-use-after-free after r352868

2019-02-02 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Sat Feb  2 02:35:39 2019
New Revision: 352957

URL: http://llvm.org/viewvc/llvm-project?rev=352957&view=rev
Log:
[clangd] Fix heap-use-after-free after r352868

Modified:
clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp

Modified: clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp?rev=352957&r1=352956&r2=352957&view=diff
==
--- clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/QualityTests.cpp Sat Feb  2 
02:35:39 2019
@@ -180,14 +180,17 @@ TEST(QualityTests, SymbolRelevanceSignal
   EXPECT_TRUE(Relevance.InBaseClass);
 
   auto Index = Test.index();
-  Symbol X;
   FuzzyFindRequest Req;
   Req.Query = "X";
   Req.AnyScope = true;
-  Index->fuzzyFind(Req, [&X](const Symbol& S){ X = S; });
-  Relevance = {};
-  Relevance.merge(X);
-  EXPECT_EQ(Relevance.Scope, SymbolRelevanceSignals::FileScope);
+  bool Matched = false;
+  Index->fuzzyFind(Req, [&](const Symbol &S) {
+Matched = true;
+Relevance = {};
+Relevance.merge(S);
+EXPECT_EQ(Relevance.Scope, SymbolRelevanceSignals::FileScope);
+  });
+  EXPECT_TRUE(Matched);
 }
 
 // Do the signals move the scores in the direction we expect?


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


Re: r352055 - Fix failing buildbots

2019-02-02 Thread Gábor Márton via cfe-commits
Thank you for taking care of this! As I see now the hexagon build bot is
happy and the other bots too.

Thanks again,
Gábor

On Sat, 2 Feb 2019, 09:34 David Green  Sounds good to me, easy enough for me to test here. And I'll count that as
> a review.
>
>
> I've given it a try in rC352956. We can see how that bot feels about it.
>
>
> Dave
>
> > Dave,
> >
> > The idea to check explicitly the triple inside the test function is
> quite convincing. Will you try to fix it that way? Or if it can wait a bit,
> this will be my first thing to do on Monday.
> >
> > Gábor
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57540: [C++17] Don't crash while diagnosing different access specifier of a deduction guide.

2019-02-02 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete marked an inline comment as done.
Rakete added inline comments.



Comment at: test/SemaCXX/cxx1z-class-template-argument-deduction.cpp:360-361
+  struct Type {
+Typo(); // expected-error{{deduction guide must be declared in the same 
scope}}
+// expected-error@-1{{deduction guide declaration without trailing return 
type}}
+  };

aaron.ballman wrote:
> These errors are pretty unfortunate -- they don't really help the user to 
> understand what's gone wrong here. They're an improvement over the crash, but 
> I think we should try to make the errors more useful if we can.
> 
> Why is `Typo()` being treated as a deduction guide? Perhaps we could look to 
> see if there is a `->` before making that determination?
> Perhaps we could look to see if there is a -> before making that 
> determination?

Yes that would be possible. The diagnostic would change for the following code:

```
template 
struct Foo {};

Foo();// -> Foo; 
// currently: deduction guide missing ->
// after: C++ requires type specifier for every declaration
```

Is that acceptable? Or I guess I could restrict this to partial deduction 
guides in classes.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57540



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


[PATCH] D46421: [analyzer][CrossTU] Extend CTU to VarDecls with initializer

2019-02-02 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> I think you should change back to getInit()

I am not entirely sure about this because the initalizer may not be attached to 
the canonical decl. `getInit()` gives the initializer of one given specific 
Decl, however, `getAnyInitializer()` searches through the whole redecl chain.


Repository:
  rC Clang

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

https://reviews.llvm.org/D46421



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


r352959 - [analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized fields

2019-02-02 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Sat Feb  2 06:50:04 2019
New Revision: 352959

URL: http://llvm.org/viewvc/llvm-project?rev=352959&view=rev
Log:
[analyzer][UninitializedObjectChecker] New flag to ignore guarded uninitialized 
fields

This patch is an implementation of the ideas discussed on the mailing list[1].

The idea is to somewhat heuristically guess whether the field that was confirmed
to be uninitialized is actually guarded with ifs, asserts, switch/cases and so
on. Since this is a syntactic check, it is very much prone to drastically
reduce the amount of reports the checker emits. The reports however that do not
get filtered out though have greater likelihood of them manifesting into actual
runtime errors.

[1] http://lists.llvm.org/pipermail/cfe-dev/2018-September/059255.html

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

Added:
cfe/trunk/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
Modified:

cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h

cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h?rev=352959&r1=352958&r2=352959&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h 
Sat Feb  2 06:50:04 2019
@@ -34,6 +34,12 @@
 // `-analyzer-config \
 // 
alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true`.
 //
+// TODO: With some clever heuristics, some pointers should be dereferenced
+// by default. For example, if the pointee is constructed within the
+// constructor call, it's reasonable to say that no external object
+// references it, and we wouldn't generate multiple report on the same
+// pointee.
+//
 //   - "IgnoreRecordsWithField" (string). If supplied, the checker will not
 // analyze structures that have a field with a name or type name that
 // matches the given pattern. Defaults to "".
@@ -41,11 +47,12 @@
 // `-analyzer-config \
 // 
alpha.cplusplus.UninitializedObject:IgnoreRecordsWithField="[Tt]ag|[Kk]ind"`.
 //
-// TODO: With some clever heuristics, some pointers should be dereferenced
-// by default. For example, if the pointee is constructed within the
-// constructor call, it's reasonable to say that no external object
-// references it, and we wouldn't generate multiple report on the same
-// pointee.
+//   - "IgnoreGuardedFields" (boolean). If set to true, the checker will 
analyze
+// _syntactically_ whether the found uninitialized object is used without a
+// preceding assert call. Defaults to false.
+//
+// `-analyzer-config \
+// alpha.cplusplus.UninitializedObject:IgnoreGuardedFields=true`.
 //
 // Most of the following methods as well as the checker itself is defined in
 // UninitializedObjectChecker.cpp.
@@ -68,6 +75,7 @@ struct UninitObjCheckerOptions {
   bool ShouldConvertNotesToWarnings = false;
   bool CheckPointeeInitialization = false;
   std::string IgnoredRecordsWithFieldPattern;
+  bool IgnoreGuardedFields = false;
 };
 
 /// A lightweight polymorphic wrapper around FieldRegion *. We'll use this

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp?rev=352959&r1=352958&r2=352959&view=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
 (original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
 Sat Feb  2 06:50:04 2019
@@ -19,6 +19,7 @@
 
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "UninitializedObject.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
@@ -26,6 +27,7 @@
 
 using namespace clang;
 using namespace clang::ento;
+using namespace clang::ast_matchers;
 
 /// We'll mark fields (and pointee of fields) that are confirmed to be
 /// uninitialized as already analyzed.
@@ -118,6 +120,16 @@ static bool willObjectBeAnalyzedLater(co
 /// \p Pattern.
 static bool shouldIgnoreRecord(const RecordDecl *RD, StringRef Pattern);
 
+/// Checks _syntactically_ whether it is possible to access FD from the record
+/// that contains it without a preceding assert (even if that access happens
+/// inside a 

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

2019-02-02 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352959: [analyzer][UninitializedObjectChecker] New flag to 
ignore guarded uninitialized… (authored by Szelethus, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D51866?vs=177080&id=184904#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D51866

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

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

[clang-tools-extra] r352964 - [clang-tidy] Rename time lookup functions; NFC

2019-02-02 Thread Hyrum Wright via cfe-commits
Author: hwright
Date: Sat Feb  2 11:57:37 2019
New Revision: 352964

URL: http://llvm.org/viewvc/llvm-project?rev=352964&view=rev
Log:
[clang-tidy] Rename time lookup functions; NFC

Modified:
clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp
clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp?rev=352964&r1=352963&r2=352964&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationAdditionCheck.cpp Sat Feb 
 2 11:57:37 2019
@@ -22,7 +22,7 @@ void DurationAdditionCheck::registerMatc
   Finder->addMatcher(
   binaryOperator(hasOperatorName("+"),
  hasEitherOperand(expr(ignoringParenImpCasts(
- callExpr(callee(functionDecl(TimeFactoryFunction())
+ callExpr(callee(functionDecl(TimeConversionFunction())
  .bind("function_decl")))
  .bind("call")
   .bind("binop"),
@@ -43,7 +43,7 @@ void DurationAdditionCheck::check(const
   if (!Scale)
 return;
 
-  llvm::StringRef TimeFactory = getTimeFactoryForScale(*Scale);
+  llvm::StringRef TimeFactory = getTimeInverseForScale(*Scale);
 
   FixItHint Hint;
   if (Call == Binop->getLHS()->IgnoreParenImpCasts()) {

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp?rev=352964&r1=352963&r2=352964&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.cpp Sat Feb  2 
11:57:37 2019
@@ -104,7 +104,7 @@ llvm::StringRef getDurationFactoryForSca
 }
 
 /// Returns the Time factory function name for a given `Scale`.
-llvm::StringRef getTimeFactoryForScale(DurationScale scale) {
+llvm::StringRef getTimeInverseForScale(DurationScale scale) {
   switch (scale) {
   case DurationScale::Hours:
 return "absl::ToUnixHours";

Modified: clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h?rev=352964&r1=352963&r2=352964&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h (original)
+++ clang-tools-extra/trunk/clang-tidy/abseil/DurationRewriter.h Sat Feb  2 
11:57:37 2019
@@ -31,9 +31,6 @@ enum class DurationScale : std::uint8_t
 /// constructing a `Duration` for that scale.
 llvm::StringRef getDurationFactoryForScale(DurationScale Scale);
 
-/// Returns the Time factory function name for a given `Scale`.
-llvm::StringRef getTimeFactoryForScale(DurationScale scale);
-
 // Determine if `Node` represents a literal floating point or integral zero.
 bool IsLiteralZero(const ast_matchers::MatchFinder::MatchResult &Result,
const Expr &Node);
@@ -75,6 +72,9 @@ llvm::Optional getScaleFo
 const std::pair &
 getDurationInverseForScale(DurationScale Scale);
 
+/// Returns the Time inverse function name for a given `Scale`.
+llvm::StringRef getTimeInverseForScale(DurationScale scale);
+
 /// Assuming `Node` has type `double` or `int` representing a time interval of
 /// `Scale`, return the expression to make it a suitable `Duration`.
 std::string rewriteExprFromNumberToDuration(
@@ -107,7 +107,7 @@ AST_MATCHER_FUNCTION(ast_matchers::inter
 }
 
 AST_MATCHER_FUNCTION(ast_matchers::internal::Matcher,
- TimeFactoryFunction) {
+ TimeConversionFunction) {
   using namespace clang::ast_matchers;
   return functionDecl(hasAnyName(
   "::absl::ToUnixHours", "::absl::ToUnixMinutes", "::absl::ToUnixSeconds",


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


[libunwind] r352965 - [libunwind] Remove the remote unwinding support

2019-02-02 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Sat Feb  2 12:54:03 2019
New Revision: 352965

URL: http://llvm.org/viewvc/llvm-project?rev=352965&view=rev
Log:
[libunwind] Remove the remote unwinding support

This is unfinished, unused and incomplete. This could be brought back in
the future if there's a desire to build a more complete implementation,
but at the moment it's just bitrotting.

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

Modified:
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/AddressSpace.hpp
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=352965&r1=352964&r2=352965&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Sat Feb  2 12:54:03 2019
@@ -124,32 +124,6 @@ extern int unw_get_proc_name(unw_cursor_
 
 extern unw_addr_space_t unw_local_addr_space;
 
-#ifdef UNW_REMOTE
-/*
- * Mac OS X "remote" API for unwinding other processes on same machine
- *
- */
-extern unw_addr_space_t unw_create_addr_space_for_task(task_t);
-extern void unw_destroy_addr_space(unw_addr_space_t);
-extern int unw_init_remote_thread(unw_cursor_t *, unw_addr_space_t, thread_t 
*);
-#endif /* UNW_REMOTE */
-
-/*
- * traditional libunwind "remote" API
- *   NOT IMPLEMENTED on Mac OS X
- *
- * extern int   unw_init_remote(unw_cursor_t*, unw_addr_space_t,
- *  thread_t*);
- * extern unw_accessors_t   unw_get_accessors(unw_addr_space_t);
- * extern unw_addr_space_t  unw_create_addr_space(unw_accessors_t, int);
- * extern void  unw_flush_cache(unw_addr_space_t, unw_word_t,
- *  unw_word_t);
- * extern int   unw_set_caching_policy(unw_addr_space_t,
- * unw_caching_policy_t);
- * extern void  _U_dyn_register(unw_dyn_info_t*);
- * extern void  _U_dyn_cancel(unw_dyn_info_t*);
- */
-
 #ifdef __cplusplus
 }
 #endif

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=352965&r1=352964&r2=352965&view=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Sat Feb  2 12:54:03 2019
@@ -607,138 +607,6 @@ inline bool LocalAddressSpace::findFunct
   return false;
 }
 
-
-
-#ifdef UNW_REMOTE
-
-/// RemoteAddressSpace is used as a template parameter to UnwindCursor when
-/// unwinding a thread in the another process.  The other process can be a
-/// different endianness and a different pointer size which is handled by
-/// the P template parameter.
-template 
-class RemoteAddressSpace {
-public:
-  RemoteAddressSpace(task_t task) : fTask(task) {}
-
-  typedef typename P::uint_t pint_t;
-
-  uint8_t   get8(pint_t addr);
-  uint16_t  get16(pint_t addr);
-  uint32_t  get32(pint_t addr);
-  uint64_t  get64(pint_t addr);
-  pint_tgetP(pint_t addr);
-  uint64_t  getRegister(pint_t addr);
-  uint64_t  getULEB128(pint_t &addr, pint_t end);
-  int64_t   getSLEB128(pint_t &addr, pint_t end);
-  pint_tgetEncodedP(pint_t &addr, pint_t end, uint8_t encoding,
-pint_t datarelBase = 0);
-  bool  findFunctionName(pint_t addr, char *buf, size_t bufLen,
-unw_word_t *offset);
-  bool  findUnwindSections(pint_t targetAddr, UnwindInfoSections &info);
-  bool  findOtherFDE(pint_t targetAddr, pint_t &fde);
-private:
-  void *localCopy(pint_t addr);
-
-  task_t fTask;
-};
-
-template  uint8_t RemoteAddressSpace::get8(pint_t addr) {
-  return *((uint8_t *)localCopy(addr));
-}
-
-template  uint16_t RemoteAddressSpace::get16(pint_t addr) {
-  return P::E::get16(*(uint16_t *)localCopy(addr));
-}
-
-template  uint32_t RemoteAddressSpace::get32(pint_t addr) {
-  return P::E::get32(*(uint32_t *)localCopy(addr));
-}
-
-template  uint64_t RemoteAddressSpace::get64(pint_t addr) {
-  return P::E::get64(*(uint64_t *)localCopy(addr));
-}
-
-template 
-typename P::uint_t RemoteAddressSpace::getP(pint_t addr) {
-  return P::getP(*(uint64_t *)localCopy(addr));
-}
-
-template 
-typename P::uint_t OtherAddressSpace::getRegister(pint_t addr) {
-  return P::getRegister(*(uint64_t *)localCopy(addr));
-}
-
-template 
-uint64_t OtherAddressSpace::getULEB128(pint_t &addr, pint_t end) {
-  uintptr_t size = (end - addr);
-  LocalAddressSpace::pint_t laddr = (LocalAddressSpace::pint_t) 
localCopy(addr);
-  LocalAddressSpace::pint_t sladdr = laddr;
-  uint64_t result = LocalAddressSpace::getULEB128(laddr, laddr + size);
-  addr += (laddr - sladdr);
-  return result;
-}
-
-template 
-int64_t RemoteAddressSpace::getSLEB128(pint_t &addr, pint_t end) {
-  uintptr_t size = (end - addr);
-  LocalAddressSpa

[libunwind] r352966 - [libunwind] Provide placement new definition

2019-02-02 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Sat Feb  2 13:15:49 2019
New Revision: 352966

URL: http://llvm.org/viewvc/llvm-project?rev=352966&view=rev
Log:
[libunwind] Provide placement new definition

While Clang automatically generates the code for placement new,
g++ doesn't do that so we need to provide our own definition.

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

Modified:
libunwind/trunk/src/Unwind-seh.cpp
libunwind/trunk/src/UnwindCursor.hpp
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/src/Unwind-seh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/Unwind-seh.cpp?rev=352966&r1=352965&r2=352966&view=diff
==
--- libunwind/trunk/src/Unwind-seh.cpp (original)
+++ libunwind/trunk/src/Unwind-seh.cpp Sat Feb  2 13:15:49 2019
@@ -49,10 +49,6 @@ using namespace libunwind;
 /// Class of foreign exceptions based on unrecognized SEH exceptions.
 static const uint64_t kSEHExceptionClass = 0x434C4E4753454800; // CLNGSEH\0
 
-// libunwind does not and should not depend on C++ library which means that we
-// need our own declaration of global placement new.
-void *operator new(size_t, void*);
-
 /// Exception cleanup routine used by \c _GCC_specific_handler to
 /// free foreign exceptions.
 static void seh_exc_cleanup(_Unwind_Reason_Code urc, _Unwind_Exception *exc) {
@@ -452,20 +448,23 @@ _Unwind_GetRegionStart(struct _Unwind_Co
 static int
 _unw_init_seh(unw_cursor_t *cursor, CONTEXT *context) {
 #ifdef _LIBUNWIND_TARGET_X86_64
-  new ((void *)cursor) UnwindCursor(
-  context, LocalAddressSpace::sThisAddressSpace);
+  new (reinterpret_cast 
*>(cursor))
+  UnwindCursor(
+  context, LocalAddressSpace::sThisAddressSpace);
   auto *co = reinterpret_cast(cursor);
   co->setInfoBasedOnIPRegister();
   return UNW_ESUCCESS;
 #elif defined(_LIBUNWIND_TARGET_ARM)
-  new ((void *)cursor) UnwindCursor(
-  context, LocalAddressSpace::sThisAddressSpace);
+  new (reinterpret_cast 
*>(cursor))
+  UnwindCursor(
+  context, LocalAddressSpace::sThisAddressSpace);
   auto *co = reinterpret_cast(cursor);
   co->setInfoBasedOnIPRegister();
   return UNW_ESUCCESS;
 #elif defined(_LIBUNWIND_TARGET_AARCH64)
-  new ((void *)cursor) UnwindCursor(
-  context, LocalAddressSpace::sThisAddressSpace);
+  new (reinterpret_cast 
*>(cursor))
+  UnwindCursor(
+  context, LocalAddressSpace::sThisAddressSpace);
   auto *co = reinterpret_cast(cursor);
   co->setInfoBasedOnIPRegister();
   return UNW_ESUCCESS;

Modified: libunwind/trunk/src/UnwindCursor.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindCursor.hpp?rev=352966&r1=352965&r2=352966&view=diff
==
--- libunwind/trunk/src/UnwindCursor.hpp (original)
+++ libunwind/trunk/src/UnwindCursor.hpp Sat Feb  2 13:15:49 2019
@@ -894,6 +894,10 @@ public:
   virtual voidsaveVFPAsX();
 #endif
 
+  // libunwind does not and should not depend on C++ library which means that 
we
+  // need our own defition of inline placement new.
+  static void *operator new(size_t, UnwindCursor *p) { return p; }
+
 private:
 
 #if defined(_LIBUNWIND_ARM_EHABI)

Modified: libunwind/trunk/src/libunwind.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/libunwind.cpp?rev=352966&r1=352965&r2=352966&view=diff
==
--- libunwind/trunk/src/libunwind.cpp (original)
+++ libunwind/trunk/src/libunwind.cpp Sat Feb  2 13:15:49 2019
@@ -23,10 +23,6 @@
 
 using namespace libunwind;
 
-// libunwind does not and should not depend on C++ library which means that we
-// need our own declaration of global placement new.
-void *operator new(size_t, void*);
-
 /// internal object to represent this processes address space
 LocalAddressSpace LocalAddressSpace::sThisAddressSpace;
 
@@ -70,8 +66,9 @@ _LIBUNWIND_EXPORT int unw_init_local(unw
 # error Architecture not supported
 #endif
   // Use "placement new" to allocate UnwindCursor in the cursor buffer.
-  new ((void *)cursor) UnwindCursor(
- context, 
LocalAddressSpace::sThisAddressSpace);
+  new (reinterpret_cast 
*>(cursor))
+  UnwindCursor(
+  context, LocalAddressSpace::sThisAddressSpace);
 #undef REGISTER_KIND
   AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
   co->setInfoBasedOnIPRegister();


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


[PATCH] D57642: [X86] Update clobber list in a test after D57641. Remove filter for 'fpsw' in MS inline asm clobber list generation since the backend now uses 'fpsr'.

2019-02-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added a reviewer: rnk.
Herald added subscribers: cfe-commits, eraman.
Herald added a project: clang.

The backend used to print the x87 FPSW register as 'fpsw', but gcc inline asm 
uses 'fpsr'. After D57641 , the backend now 
uses 'fpsr' to match. So we need to update the test and we can remove the code 
that excluded the 'fpsw' string.


Repository:
  rC Clang

https://reviews.llvm.org/D57642

Files:
  lib/Parse/ParseStmtAsm.cpp
  test/CodeGen/ms-inline-asm.c


Index: test/CodeGen/ms-inline-asm.c
===
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -571,7 +571,7 @@
 // CHECK: fld dword ptr $1
   __asm fistp i
 // CHECK: fistp dword ptr $0
-// CHECK: "=*m,*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, float* %{{.*}})
+// CHECK: "=*m,*m,~{fpsr},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, float* 
%{{.*}})
 }
 
 void t41(unsigned short a) {
Index: lib/Parse/ParseStmtAsm.cpp
===
--- lib/Parse/ParseStmtAsm.cpp
+++ lib/Parse/ParseStmtAsm.cpp
@@ -636,7 +636,7 @@
   // Filter out "fpsw" and "mxcsr". They aren't valid GCC asm clobber
   // constraints. Clang always adds fpsr to the clobber list anyway.
   llvm::erase_if(Clobbers, [](const std::string &C) {
-return C == "fpsw" || C == "mxcsr";
+return C == "mxcsr";
   });
 
   // Build the vector of clobber StringRefs.


Index: test/CodeGen/ms-inline-asm.c
===
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -571,7 +571,7 @@
 // CHECK: fld dword ptr $1
   __asm fistp i
 // CHECK: fistp dword ptr $0
-// CHECK: "=*m,*m,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, float* %{{.*}})
+// CHECK: "=*m,*m,~{fpsr},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}}, float* %{{.*}})
 }
 
 void t41(unsigned short a) {
Index: lib/Parse/ParseStmtAsm.cpp
===
--- lib/Parse/ParseStmtAsm.cpp
+++ lib/Parse/ParseStmtAsm.cpp
@@ -636,7 +636,7 @@
   // Filter out "fpsw" and "mxcsr". They aren't valid GCC asm clobber
   // constraints. Clang always adds fpsr to the clobber list anyway.
   llvm::erase_if(Clobbers, [](const std::string &C) {
-return C == "fpsw" || C == "mxcsr";
+return C == "mxcsr";
   });
 
   // Build the vector of clobber StringRefs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57207: [clang-tidy] Make google-objc-function-naming ignore implicit functions 🙈

2019-02-02 Thread Stephane Moore via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE352968: [clang-tidy] Make google-objc-function-naming 
ignore implicit functions 🙈 (authored by stephanemoore, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D57207?vs=184553&id=184918#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57207

Files:
  clang-tidy/google/FunctionNamingCheck.cpp
  test/clang-tidy/google-objc-function-naming.m


Index: clang-tidy/google/FunctionNamingCheck.cpp
===
--- clang-tidy/google/FunctionNamingCheck.cpp
+++ clang-tidy/google/FunctionNamingCheck.cpp
@@ -93,12 +93,16 @@
   if (!getLangOpts().ObjC)
 return;
 
-  // Match function declarations that are not in system headers and are not
-  // main.
+  // Enforce Objective-C function naming conventions on all functions except:
+  // • Functions defined in system headers.
+  // • C++ member functions.
+  // • Namespaced functions.
+  // • Implicitly defined functions.
+  // • The main function.
   Finder->addMatcher(
   functionDecl(
   unless(anyOf(isExpansionInSystemHeader(), cxxMethodDecl(),
-   hasAncestor(namespaceDecl()), isMain(),
+   hasAncestor(namespaceDecl()), isMain(), isImplicit(),
matchesName(validFunctionNameRegex(true)),
allOf(isStaticStorageClass(),
  matchesName(validFunctionNameRegex(false))
Index: test/clang-tidy/google-objc-function-naming.m
===
--- test/clang-tidy/google-objc-function-naming.m
+++ test/clang-tidy/google-objc-function-naming.m
@@ -1,5 +1,13 @@
 // RUN: %check_clang_tidy %s google-objc-function-naming %t
 
+#import 
+
+static void TestImplicitFunctionDeclaration(int a) {
+  // Call a builtin function so that the compiler generates an implicit
+  // function declaration.
+  printf("%d", a);
+}
+
 typedef _Bool bool;
 
 static bool ispositive(int a) { return a > 0; }


Index: clang-tidy/google/FunctionNamingCheck.cpp
===
--- clang-tidy/google/FunctionNamingCheck.cpp
+++ clang-tidy/google/FunctionNamingCheck.cpp
@@ -93,12 +93,16 @@
   if (!getLangOpts().ObjC)
 return;
 
-  // Match function declarations that are not in system headers and are not
-  // main.
+  // Enforce Objective-C function naming conventions on all functions except:
+  // • Functions defined in system headers.
+  // • C++ member functions.
+  // • Namespaced functions.
+  // • Implicitly defined functions.
+  // • The main function.
   Finder->addMatcher(
   functionDecl(
   unless(anyOf(isExpansionInSystemHeader(), cxxMethodDecl(),
-   hasAncestor(namespaceDecl()), isMain(),
+   hasAncestor(namespaceDecl()), isMain(), isImplicit(),
matchesName(validFunctionNameRegex(true)),
allOf(isStaticStorageClass(),
  matchesName(validFunctionNameRegex(false))
Index: test/clang-tidy/google-objc-function-naming.m
===
--- test/clang-tidy/google-objc-function-naming.m
+++ test/clang-tidy/google-objc-function-naming.m
@@ -1,5 +1,13 @@
 // RUN: %check_clang_tidy %s google-objc-function-naming %t
 
+#import 
+
+static void TestImplicitFunctionDeclaration(int a) {
+  // Call a builtin function so that the compiler generates an implicit
+  // function declaration.
+  printf("%d", a);
+}
+
 typedef _Bool bool;
 
 static bool ispositive(int a) { return a > 0; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57207: [clang-tidy] Make google-objc-function-naming ignore implicit functions 🙈

2019-02-02 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore marked an inline comment as done.
stephanemoore added inline comments.



Comment at: test/clang-tidy/google-objc-function-naming.m:3
 
+#import 
+

It turns out importing  is problematic and breaks the build (though 
everything built successfully for me locally 🤔). I believe that the import is 
not strictly necessary and I can embed a function declaration for `printf` to 
reproduce the implicit function declaration with the caveat that the check will 
trigger on a `printf` declaration that is not from a system header. I suppose 
it might be reasonable to suppress the check output on `printf`?

I have reverted this change for now and will follow up with appropriate fixes.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57207



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


r352971 - Replace uses of %T with %t in from previous frontend test differential

2019-02-02 Thread Nico Weber via cfe-commits
Author: nico
Date: Sat Feb  2 15:16:30 2019
New Revision: 352971

URL: http://llvm.org/viewvc/llvm-project?rev=352971&view=rev
Log:
Replace uses of %T with %t in from previous frontend test differential

After committing a change I had made to a few frontend tests, it was pointed
out to me that %T is being deprecated in LLVM in favor of %t. This change
simply converts usages of %T to %t while maintaining the integrity of the test.

Previous revision where this discussion took place:
https://reviews.llvm.org/D50563

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

Patch from Justice Adams !

Modified:
cfe/trunk/test/Frontend/output-failures.c
cfe/trunk/test/Frontend/stats-file.c

Modified: cfe/trunk/test/Frontend/output-failures.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/output-failures.c?rev=352971&r1=352970&r2=352971&view=diff
==
--- cfe/trunk/test/Frontend/output-failures.c (original)
+++ cfe/trunk/test/Frontend/output-failures.c Sat Feb  2 15:16:30 2019
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -emit-llvm -o %T/doesnotexist/somename %s 2> %t
+// RUN: not %clang_cc1 -emit-llvm -o %t/doesnotexist/somename %s 2> %t
 // RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
 
 // OUTPUTFAIL: error: unable to open output file 
'{{.*}}doesnotexist{{.}}somename': '{{[nN]}}o such file or directory'

Modified: cfe/trunk/test/Frontend/stats-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/stats-file.c?rev=352971&r1=352970&r2=352971&view=diff
==
--- cfe/trunk/test/Frontend/stats-file.c (original)
+++ cfe/trunk/test/Frontend/stats-file.c Sat Feb  2 15:16:30 2019
@@ -4,5 +4,5 @@
 //  ... here come some json values ...
 // CHECK: }
 
-// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%T/doesnotexist/bla %s 2>&1 | 
FileCheck -check-prefix=OUTPUTFAIL %s
+// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%t/doesnotexist/bla %s 2>&1 | 
FileCheck -check-prefix=OUTPUTFAIL %s
 // OUTPUTFAIL: warning: unable to open statistics output file 
'{{.*}}doesnotexist{{.}}bla': '{{[Nn]}}o such file or directory'


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


[PATCH] D57592: Replace uses of %T with %t in from previous frontend test differential

2019-02-02 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352971: Replace uses of %T with %t in from previous frontend 
test differential (authored by nico, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57592?vs=184768&id=184921#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57592

Files:
  cfe/trunk/test/Frontend/output-failures.c
  cfe/trunk/test/Frontend/stats-file.c


Index: cfe/trunk/test/Frontend/stats-file.c
===
--- cfe/trunk/test/Frontend/stats-file.c
+++ cfe/trunk/test/Frontend/stats-file.c
@@ -4,5 +4,5 @@
 //  ... here come some json values ...
 // CHECK: }
 
-// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%T/doesnotexist/bla %s 2>&1 | 
FileCheck -check-prefix=OUTPUTFAIL %s
+// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%t/doesnotexist/bla %s 2>&1 | 
FileCheck -check-prefix=OUTPUTFAIL %s
 // OUTPUTFAIL: warning: unable to open statistics output file 
'{{.*}}doesnotexist{{.}}bla': '{{[Nn]}}o such file or directory'
Index: cfe/trunk/test/Frontend/output-failures.c
===
--- cfe/trunk/test/Frontend/output-failures.c
+++ cfe/trunk/test/Frontend/output-failures.c
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -emit-llvm -o %T/doesnotexist/somename %s 2> %t
+// RUN: not %clang_cc1 -emit-llvm -o %t/doesnotexist/somename %s 2> %t
 // RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
 
 // OUTPUTFAIL: error: unable to open output file 
'{{.*}}doesnotexist{{.}}somename': '{{[nN]}}o such file or directory'


Index: cfe/trunk/test/Frontend/stats-file.c
===
--- cfe/trunk/test/Frontend/stats-file.c
+++ cfe/trunk/test/Frontend/stats-file.c
@@ -4,5 +4,5 @@
 //  ... here come some json values ...
 // CHECK: }
 
-// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%T/doesnotexist/bla %s 2>&1 | FileCheck -check-prefix=OUTPUTFAIL %s
+// RUN: %clang_cc1 -emit-llvm -o %t -stats-file=%t/doesnotexist/bla %s 2>&1 | FileCheck -check-prefix=OUTPUTFAIL %s
 // OUTPUTFAIL: warning: unable to open statistics output file '{{.*}}doesnotexist{{.}}bla': '{{[Nn]}}o such file or directory'
Index: cfe/trunk/test/Frontend/output-failures.c
===
--- cfe/trunk/test/Frontend/output-failures.c
+++ cfe/trunk/test/Frontend/output-failures.c
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -emit-llvm -o %T/doesnotexist/somename %s 2> %t
+// RUN: not %clang_cc1 -emit-llvm -o %t/doesnotexist/somename %s 2> %t
 // RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
 
 // OUTPUTFAIL: error: unable to open output file '{{.*}}doesnotexist{{.}}somename': '{{[nN]}}o such file or directory'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57592: Replace uses of %T with %t in from previous frontend test differential

2019-02-02 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Done, thanks for the patch!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57592



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


[PATCH] D56935: [NewPM] Add support for new-PM plugins to clang

2019-02-02 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352972: [NewPM] Add support for new-PM plugins to clang 
(authored by pfaffe, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56935?vs=183715&id=184922#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D56935

Files:
  include/clang/Basic/CodeGenOptions.h
  include/clang/Driver/Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1612,6 +1612,9 @@
 def fno_rwpi : Flag<["-"], "fno-rwpi">, Group;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group, 
Flags<[DriverOption]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;
+def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">,
+  Group, Flags<[CC1Option]>, MetaVarName<"">,
+  HelpText<"Load pass plugin from a dynamic shared object file (only with new 
pass manager).">;
 def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">, 
Group;
 def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">, 
Group, Flags<[CC1Option]>,
   HelpText<"Do not preserve comments in inline assembly">;
Index: include/clang/Basic/CodeGenOptions.h
===
--- include/clang/Basic/CodeGenOptions.h
+++ include/clang/Basic/CodeGenOptions.h
@@ -287,6 +287,9 @@
 
   std::vector DefaultFunctionAttrs;
 
+  /// List of dynamic shared object files to be loaded as pass plugins.
+  std::vector PassPlugins;
+
 public:
   // Define accessors/mutators for code generation options of enumeration type.
 #define CODEGENOPT(Name, Bits, Default)
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -5077,6 +5077,13 @@
 A->claim();
   }
 
+  // Forward -fpass-plugin=name.so to -cc1.
+  for (const Arg *A : Args.filtered(options::OPT_fpass_plugin_EQ)) {
+CmdArgs.push_back(
+Args.MakeArgString(Twine("-fpass-plugin=") + A->getValue()));
+A->claim();
+  }
+
   // Setup statistics file output.
   SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D);
   if (!StatsFile.empty())
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1322,6 +1322,8 @@
 
   Opts.DefaultFunctionAttrs = Args.getAllArgValues(OPT_default_function_attr);
 
+  Opts.PassPlugins = Args.getAllArgValues(OPT_fpass_plugin_EQ);
+
   return Success;
 }
 
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -36,6 +36,7 @@
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Passes/PassBuilder.h"
+#include "llvm/Passes/PassPlugin.h"
 #include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -961,6 +962,17 @@
 
   PassBuilder PB(TM.get(), PGOOpt);
 
+  // Attempt to load pass plugins and register their callbacks with PB.
+  for (auto &PluginFN : CodeGenOpts.PassPlugins) {
+auto PassPlugin = PassPlugin::Load(PluginFN);
+if (PassPlugin) {
+  PassPlugin->registerPassBuilderCallbacks(PB);
+} else {
+  Diags.Report(diag::err_fe_unable_to_load_plugin)
+  << PluginFN << toString(PassPlugin.takeError());
+}
+  }
+
   LoopAnalysisManager LAM(CodeGenOpts.DebugPassManager);
   FunctionAnalysisManager FAM(CodeGenOpts.DebugPassManager);
   CGSCCAnalysisManager CGAM(CodeGenOpts.DebugPassManager);


Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1612,6 +1612,9 @@
 def fno_rwpi : Flag<["-"], "fno-rwpi">, Group;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group, Flags<[DriverOption]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;
+def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">,
+  Group, Flags<[CC1Option]>, MetaVarName<"">,
+  HelpText<"Load pass plugin from a dynamic shared object file (only with new pass manager).">;
 def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">, Group;
 def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">, Group, Flags<[CC1Option]>,
   HelpText<"Do not preserve comments in inline assembly">;
Index: include/clang/Basic/CodeGenOptions.h
===
--- include/clang/Basic/CodeGenOptions.h
+++ include/clang/Basic/Code

r352972 - [NewPM] Add support for new-PM plugins to clang

2019-02-02 Thread Philip Pfaffe via cfe-commits
Author: pfaffe
Date: Sat Feb  2 15:19:32 2019
New Revision: 352972

URL: http://llvm.org/viewvc/llvm-project?rev=352972&view=rev
Log:
[NewPM] Add support for new-PM plugins to clang

Summary:
This adds support for new-PM plugin loading to clang. The option
`-fpass-plugin=` may be used to specify a dynamic shared object file
that adheres to the PassPlugin API.

Tested: created simple plugin that registers an EP callback; with optimization 
level > 0, the pass is run as expected.

Committed on behalf of Marco Elver

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

Modified:
cfe/trunk/include/clang/Basic/CodeGenOptions.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.h?rev=352972&r1=352971&r2=352972&view=diff
==
--- cfe/trunk/include/clang/Basic/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.h Sat Feb  2 15:19:32 2019
@@ -287,6 +287,9 @@ public:
 
   std::vector DefaultFunctionAttrs;
 
+  /// List of dynamic shared object files to be loaded as pass plugins.
+  std::vector PassPlugins;
+
 public:
   // Define accessors/mutators for code generation options of enumeration type.
 #define CODEGENOPT(Name, Bits, Default)

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=352972&r1=352971&r2=352972&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Sat Feb  2 15:19:32 2019
@@ -1612,6 +1612,9 @@ def frwpi : Flag<["-"], "frwpi">, Group<
 def fno_rwpi : Flag<["-"], "fno-rwpi">, Group;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group, 
Flags<[DriverOption]>, MetaVarName<"">,
   HelpText<"Load the named plugin (dynamic shared object)">;
+def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">,
+  Group, Flags<[CC1Option]>, MetaVarName<"">,
+  HelpText<"Load pass plugin from a dynamic shared object file (only with new 
pass manager).">;
 def fpreserve_as_comments : Flag<["-"], "fpreserve-as-comments">, 
Group;
 def fno_preserve_as_comments : Flag<["-"], "fno-preserve-as-comments">, 
Group, Flags<[CC1Option]>,
   HelpText<"Do not preserve comments in inline assembly">;

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=352972&r1=352971&r2=352972&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Sat Feb  2 15:19:32 2019
@@ -36,6 +36,7 @@
 #include "llvm/MC/MCAsmInfo.h"
 #include "llvm/MC/SubtargetFeature.h"
 #include "llvm/Passes/PassBuilder.h"
+#include "llvm/Passes/PassPlugin.h"
 #include "llvm/Support/BuryPointer.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -961,6 +962,17 @@ void EmitAssemblyHelper::EmitAssemblyWit
 
   PassBuilder PB(TM.get(), PGOOpt);
 
+  // Attempt to load pass plugins and register their callbacks with PB.
+  for (auto &PluginFN : CodeGenOpts.PassPlugins) {
+auto PassPlugin = PassPlugin::Load(PluginFN);
+if (PassPlugin) {
+  PassPlugin->registerPassBuilderCallbacks(PB);
+} else {
+  Diags.Report(diag::err_fe_unable_to_load_plugin)
+  << PluginFN << toString(PassPlugin.takeError());
+}
+  }
+
   LoopAnalysisManager LAM(CodeGenOpts.DebugPassManager);
   FunctionAnalysisManager FAM(CodeGenOpts.DebugPassManager);
   CGSCCAnalysisManager CGAM(CodeGenOpts.DebugPassManager);

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=352972&r1=352971&r2=352972&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Sat Feb  2 15:19:32 2019
@@ -5077,6 +5077,13 @@ void Clang::ConstructJob(Compilation &C,
 A->claim();
   }
 
+  // Forward -fpass-plugin=name.so to -cc1.
+  for (const Arg *A : Args.filtered(options::OPT_fpass_plugin_EQ)) {
+CmdArgs.push_back(
+Args.MakeArgString(Twine("-fpass-plugin=") + A->getValue()));
+A->claim();
+  }
+
   // Setup statistics file output.
   SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D);
   if (!StatsFile.empty())

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=352972&r1=352971&r2=352972&view=diff
===

[PATCH] D56935: [NewPM] Add support for new-PM plugins to clang

2019-02-02 Thread Philip Pfaffe via Phabricator via cfe-commits
philip.pfaffe added a comment.

Landed it for you in r352972. Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D56935



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


[PATCH] D57573: Disable tidy checks with too many hits

2019-02-02 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

I wonder whether a list of specific checks (without wildcards) would make more 
sense for llvm?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57573



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


[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with'-mframe-pointer='

2019-02-02 Thread Yuanfang Chen via Phabricator via cfe-commits
tabloid.adroit added a comment.
Herald added a project: clang.

ping


Repository:
  rC Clang

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

https://reviews.llvm.org/D56353



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


[PATCH] D57497: [RISCV] Passing -G value to RISCV backend

2019-02-02 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

Hi Shiva, I think you need to check for and pass  along the -G option to the 
linker (gnutools::Linker and RISCV::Linker) and will be available for LTO. 
Check Hexagon, it passes the threshold value to the assembler (via -gpsize)  
and linker (via -G).


Repository:
  rC Clang

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

https://reviews.llvm.org/D57497



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


r352980 - Fix handling of usual deallocation functions in various configuratios.

2019-02-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Feb  2 19:44:31 2019
New Revision: 352980

URL: http://llvm.org/viewvc/llvm-project?rev=352980&view=rev
Log:
Fix handling of usual deallocation functions in various configuratios.

Clang allows users to enable or disable various types of allocation
and deallocation regardless of the C++ dialect. When extended new/delete
overloads are enabled in older dialects, we need to treat them as if
they're usual.

Also, disabling one usual deallocation form shouldn't
disable any others. For example, disabling aligned allocation in C++2a
should have no effect on destroying delete.

Added:
cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp
Modified:
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/test/SemaCXX/cxx2a-destroying-delete.cpp

Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=352980&r1=352979&r2=352980&view=diff
==
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Sat Feb  2 19:44:31 2019
@@ -2091,8 +2091,13 @@ bool CXXMethodDecl::isUsualDeallocationF
 return false;
 
   // In C++17 onwards, all potential usual deallocation functions are actual
-  // usual deallocation functions.
-  if (Context.getLangOpts().AlignedAllocation)
+  // usual deallocation functions. Honor this behavior when post-C++14
+  // deallocation functions are offered as extensions too.
+  // FIXME(EricWF): Destrying Delete should be a language option. How do we
+  // handle when destroying delete is used prior to C++17?
+  if (Context.getLangOpts().CPlusPlus17 ||
+  Context.getLangOpts().AlignedAllocation ||
+  isDestroyingOperatorDelete())
 return true;
 
   // This function is a usual deallocation function if there are no

Modified: cfe/trunk/test/SemaCXX/cxx2a-destroying-delete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx2a-destroying-delete.cpp?rev=352980&r1=352979&r2=352980&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx2a-destroying-delete.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx2a-destroying-delete.cpp Sat Feb  2 19:44:31 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++2a -verify %s
+// RUN: %clang_cc1 -std=c++2a -fexceptions -verify %s
+// RUN: %clang_cc1 -std=c++2a  -verify %s
 
 namespace std {
   using size_t = decltype(sizeof(0));
@@ -58,11 +59,13 @@ namespace delete_selection {
 C();
 void *operator new(std::size_t);
 void operator delete(void*) = delete;
-void operator delete(C *, std::destroying_delete_t) = delete;
+void operator delete(C *, std::destroying_delete_t) = delete; // 
expected-note 0-1 {{deleted here}}
   };
-  // FIXME: This should be ill-formed, but we incorrectly decide that overload
-  // resolution failed (because it selected a deleted function) and thus no
-  // 'operator delete' should be called.
+  // TODO: We only diagnose the use of a deleted operator delete when 
exceptions
+  // are enabled. Otherwise we don't bother doing the lookup.
+#ifdef __EXCEPTIONS
+  // expected-error@+2 {{attempt to use a deleted function}}
+#endif
   C *new_C() { return new C; }
 
   struct D {

Added: cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp?rev=352980&view=auto
==
--- cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp (added)
+++ cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp Sat Feb  2 
19:44:31 2019
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -fexceptions -std=c++2a -fsized-deallocation 
-fno-aligned-allocation -verify %s
+// RUN: %clang_cc1 -fexceptions -std=c++17 -fsized-deallocation 
-fno-aligned-allocation -verify %s
+// RUN: %clang_cc1 -fexceptions -std=c++14 -fsized-deallocation 
-faligned-allocation -DHAS_ALIGN -verify %s
+// RUN: %clang_cc1 -fexceptions -std=c++11 -fsized-deallocation 
-faligned-allocation -DHAS_ALIGN -verify %s
+
+// Test that we handle aligned deallocation, sized deallocation, and destroying
+// delete as usual deallocation functions even if they are used as extensions
+// prior to C++17.
+
+namespace std {
+using size_t = decltype(sizeof(0));
+enum class align_val_t : size_t;
+
+struct destroying_delete_t {
+  struct __construct { explicit __construct() = default; };
+  explicit destroying_delete_t(__construct) {}
+};
+
+inline constexpr destroying_delete_t 
destroying_delete(destroying_delete_t::__construct());
+}
+
+// FIXME: Should destroying delete really be on in all dialects by default?
+struct A {
+  void operator delete(void*) = delete;
+  void operator delete(A*, std::destroying_delete_t) = delete; // 
expected-note {{deleted}}
+};
+void ATest(A* a) { delete a; } // expected-error {{deleted}}
+
+struct B 

r352983 - Correct test my *really really* overaligning a type.

2019-02-02 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Sat Feb  2 20:10:38 2019
New Revision: 352983

URL: http://llvm.org/viewvc/llvm-project?rev=352983&view=rev
Log:
Correct test my *really really* overaligning a type.

Modified:
cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp

Modified: cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp?rev=352983&r1=352982&r2=352983&view=diff
==
--- cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp (original)
+++ cfe/trunk/test/SemaCXX/extended-usual-deallocation-functions.cpp Sat Feb  2 
20:10:38 2019
@@ -33,7 +33,7 @@ struct B {
 void BTest(B *b) { delete b; }// expected-error {{deleted}}
 
 
-struct alignas(32) C {
+struct alignas(128) C {
 #ifndef HAS_ALIGN
   // expected-note@+2 {{deleted}}
 #endif
@@ -54,7 +54,7 @@ struct D {
 };
 void DTest(D *d) { delete d; } // expected-error {{deleted}}
 
-struct alignas(64) E {
+struct alignas(128) E {
   void operator delete(void*) = delete;
   void operator delete(E*, std::destroying_delete_t) = delete;
   void operator delete(E*, std::destroying_delete_t, std::size_t) = delete;


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


[PATCH] D57645: [C++2a] Fix PR40576: Turn destroying delete off prior to C++2a. Add -fdestroying-delete

2019-02-02 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.
EricWF added reviewers: ckennelly, rsmith.
Herald added a project: clang.

Defining new names in namespace `std` is technically a non-conforming 
extensions. This makes it difficult for libc++ to backport C++20 destroying 
delete.
This patch should make it easier for libc++ to support destroying delete as an 
extension.

Currently Clang unconditionally defines `__cpp_impl_destroying_delete`. Unlike 
aligned allocation or sized deallocation which can be turned on or off by user.
I believe we should make destroying delete act similarly. It should be off 
prior to C++20 and  we should provide flags for enabling destroying delete 
prior to C++20.
This patch does just that.

There are some weird corner cases though. What should Clang do when it sees a 
destroying delete overload but `LangOpts.DestroyingDelete` isn't enabled?
My current approach is to tolerate it's existence, but ignore it for the 
purposes of overload resolution (after emitting a warning).

With this patch, if Clang see
When a destroying delete function is found


Repository:
  rC Clang

https://reviews.llvm.org/D57645

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/AST/DeclCXX.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/InitPreprocessor.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  test/CodeGenCXX/cxx2a-destroying-delete.cpp
  test/SemaCXX/cxx2a-destroying-delete.cpp
  test/SemaCXX/extended-usual-deallocation-functions.cpp
  test/SemaCXX/warn-destroying-delete-extension.cpp

Index: test/SemaCXX/warn-destroying-delete-extension.cpp
===
--- /dev/null
+++ test/SemaCXX/warn-destroying-delete-extension.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s
+namespace std {
+struct destroying_delete_t {
+};
+} // namespace std
+struct C {
+  // expected-warning@+2 {{destroying operator delete is ignored prior to C++2a}}
+  // expected-note@+1 {{use -fdestroying-delete to enable destroying operator delete}}
+  void operator delete(C *, std::destroying_delete_t);
+};
Index: test/SemaCXX/extended-usual-deallocation-functions.cpp
===
--- test/SemaCXX/extended-usual-deallocation-functions.cpp
+++ test/SemaCXX/extended-usual-deallocation-functions.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fexceptions -std=c++2a -fsized-deallocation -fno-aligned-allocation -verify %s
-// RUN: %clang_cc1 -fexceptions -std=c++17 -fsized-deallocation -fno-aligned-allocation -verify %s
-// RUN: %clang_cc1 -fexceptions -std=c++14 -fsized-deallocation -faligned-allocation -DHAS_ALIGN -verify %s
-// RUN: %clang_cc1 -fexceptions -std=c++11 -fsized-deallocation -faligned-allocation -DHAS_ALIGN -verify %s
+// RUN: %clang_cc1 -fexceptions -std=c++17 -fdestroying-delete -fsized-deallocation -fno-aligned-allocation -verify %s
+// RUN: %clang_cc1 -fexceptions -std=c++14 -fdestroying-delete -fsized-deallocation -faligned-allocation -DHAS_ALIGN -verify %s
+// RUN: %clang_cc1 -fexceptions -std=c++11 -fdestroying-delete -fsized-deallocation -faligned-allocation -DHAS_ALIGN -verify %s
 
 // Test that we handle aligned deallocation, sized deallocation, and destroying
 // delete as usual deallocation functions even if they are used as extensions
Index: test/SemaCXX/cxx2a-destroying-delete.cpp
===
--- test/SemaCXX/cxx2a-destroying-delete.cpp
+++ test/SemaCXX/cxx2a-destroying-delete.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -std=c++2a -fexceptions -verify %s
 // RUN: %clang_cc1 -std=c++2a  -verify %s
+// RUN: %clang_cc1 -std=c++17 -fexceptions -fdestroying-delete -verify %s
 
 namespace std {
   using size_t = decltype(sizeof(0));
Index: test/CodeGenCXX/cxx2a-destroying-delete.cpp
===
--- test/CodeGenCXX/cxx2a-destroying-delete.cpp
+++ test/CodeGenCXX/cxx2a-destroying-delete.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++2a -emit-llvm %s -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ITANIUM
+// RUN: %clang_cc1 -std=c++11 -faligned-allocation -fdestroying-delete -emit-llvm %s -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-ITANIUM
 // RUN: %clang_cc1 -std=c++2a -emit-llvm %s -triple x86_64-windows -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-MSABI
 
 namespace std {
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -1506,7 +1506,7 @@
   if (!FD)
 return;
   unsigned NumBaseParams = 1;
-  if (FD->isDestroyingOperatorDelete()) {
+  if (FD->isDestroyingOperatorDelete() && S.LangOpts.DestroyingDelete) {
 Destroying = true;

[PATCH] D55250: [clangd] Enhance macro hover to see full definition

2019-02-02 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle updated this revision to Diff 184928.
malaperle marked 2 inline comments as done.
malaperle added a comment.
Herald added a project: clang.

Address comments.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D55250

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/XRefs.cpp
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -648,7 +648,25 @@
 #define MACRO 2
 #undef macro
   )cpp",
-  "#define MACRO",
+  "#define MACRO 1",
+  },
+  {
+  R"cpp(// Macro
+#define MACRO 0
+#define MACRO2 ^MACRO
+  )cpp",
+  "#define MACRO 0",
+  },
+  {
+  R"cpp(// Macro
+#define MACRO {\
+  return 0;\
+}
+int main() ^MACRO
+  )cpp",
+  R"cpp(#define MACRO {\
+  return 0;\
+})cpp",
   },
   {
   R"cpp(// Forward class declaration
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -537,13 +537,30 @@
   return H;
 }
 
-/// Generate a \p Hover object given the macro \p MacroInf.
-static Hover getHoverContents(llvm::StringRef MacroName) {
-  Hover H;
-
-  H.contents.value = "#define ";
-  H.contents.value += MacroName;
+/// Generate a \p Hover object given the macro \p MacroDecl.
+static Hover getHoverContents(MacroDecl Decl, ParsedAST &AST) {
+  SourceManager &SM = AST.getASTContext().getSourceManager();
+  std::string Definition = Decl.Name;
+
+  // Try to get the full definition, not just the name
+  SourceLocation StartLoc = Decl.Info->getDefinitionLoc();
+  SourceLocation EndLoc = Decl.Info->getDefinitionEndLoc();
+  if (EndLoc.isValid()) {
+EndLoc = Lexer::getLocForEndOfToken(EndLoc, 0, SM,
+AST.getASTContext().getLangOpts());
+bool Invalid;
+StringRef Buffer = SM.getBufferData(SM.getFileID(StartLoc), &Invalid);
+if (!Invalid) {
+  unsigned StartOffset = SM.getFileOffset(StartLoc);
+  unsigned EndOffset = SM.getFileOffset(EndLoc);
+  if (EndOffset <= Buffer.size() && StartOffset < EndOffset)
+Definition = Buffer.substr(StartOffset, EndOffset - StartOffset).str();
+}
+  }
 
+  Hover H;
+  H.contents.kind = MarkupKind::PlainText;
+  H.contents.value = "#define " + Definition;
   return H;
 }
 
@@ -667,7 +684,7 @@
   auto Symbols = getSymbolAtPosition(AST, SourceLocationBeg);
 
   if (!Symbols.Macros.empty())
-return getHoverContents(Symbols.Macros[0].Name);
+return getHoverContents(Symbols.Macros[0], AST);
 
   if (!Symbols.Decls.empty())
 return getHoverContents(Symbols.Decls[0].D);
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -331,6 +331,16 @@
 SymbolKind adjustKindToCapability(SymbolKind Kind,
   SymbolKindBitset &supportedSymbolKinds);
 
+enum class MarkupKind {
+  PlainText,
+  Markdown,
+};
+bool fromJSON(const llvm::json::Value &, MarkupKind &);
+constexpr auto MarkupKindMin = static_cast(MarkupKind::PlainText);
+constexpr auto MarkupKindMax = static_cast(MarkupKind::Markdown);
+using MarkupKindBitset = std::bitset;
+bool fromJSON(const llvm::json::Value &, MarkupKindBitset &);
+
 // This struct doesn't mirror LSP!
 // The protocol defines deeply nested structures for client capabilities.
 // Instead of mapping them all, this just parses out the bits we care about.
@@ -362,6 +372,10 @@
   /// Client supports CodeAction return value for textDocument/codeAction.
   /// textDocument.codeAction.codeActionLiteralSupport.
   bool CodeActionStructure = false;
+
+  /// The supported set of MarkupKinds for hover.
+  /// textDocument.hover.contentFormat.
+  llvm::Optional HoverMarkupKinds;
 };
 bool fromJSON(const llvm::json::Value &, ClientCapabilities &);
 
@@ -818,11 +832,6 @@
 };
 bool fromJSON(const llvm::json::Value &, CompletionParams &);
 
-enum class MarkupKind {
-  PlainText,
-  Markdown,
-};
-
 struct MarkupContent {
   MarkupKind kind = MarkupKind::PlainText;
   std::string value;
Index: clangd/Protocol.cpp
===
--- clangd/Protocol.cpp
+++ clangd/Protocol.cpp
@@ -245,6 +245,13 @@
   DocumentSymbol->getBoolean("hierarchicalDocumentSymbolSupport"))
 R.HierarchicalDocumentSymbol = *HierarchicalSupport;
 }
+if (auto *Hover = TextDocument->getObject("hover")) {
+  if (auto HoverMarkupKinds = Hover->get("contentFormat")) {
+R.HoverMarkupKinds.emplace();
+if (!fromJSON(*HoverMarku