[PATCH] D55782: Fix isInSystemMacro to handle pasted token

2019-01-31 Thread serge via Phabricator via cfe-commits
serge-sans-paille marked an inline comment as done.
serge-sans-paille added a comment.
Herald added a subscriber: llvm-commits.

It's in, thanks @rsmith for the review.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D55782



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


[PATCH] D55782: Fix isInSystemMacro to handle pasted token

2019-01-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352838: Fix isInSystemMacro to handle pasted macros 
(authored by serge_sans_paille, committed by ).
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D55782?vs=184275=184680#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D55782

Files:
  cfe/trunk/include/clang/Basic/SourceManager.h
  cfe/trunk/test/Misc/no-warn-in-system-macro.c
  cfe/trunk/test/Misc/no-warn-in-system-macro.c.inc
  cfe/trunk/test/Misc/warn-in-system-macro-def.c
  cfe/trunk/test/Misc/warn-in-system-macro-def.c.inc

Index: cfe/trunk/include/clang/Basic/SourceManager.h
===
--- cfe/trunk/include/clang/Basic/SourceManager.h
+++ cfe/trunk/include/clang/Basic/SourceManager.h
@@ -1440,6 +1440,12 @@
 return Filename.equals("");
   }
 
+  /// Returns whether \p Loc is located in a  file.
+  bool isWrittenInScratchSpace(SourceLocation Loc) const {
+StringRef Filename(getPresumedLoc(Loc).getFilename());
+return Filename.equals("");
+  }
+
   /// Returns if a SourceLocation is in a system header.
   bool isInSystemHeader(SourceLocation Loc) const {
 return isSystem(getFileCharacteristic(Loc));
@@ -1452,7 +1458,17 @@
 
   /// Returns whether \p Loc is expanded from a macro in a system header.
   bool isInSystemMacro(SourceLocation loc) const {
-return loc.isMacroID() && isInSystemHeader(getSpellingLoc(loc));
+if(!loc.isMacroID())
+  return false;
+
+// This happens when the macro is the result of a paste, in that case
+// its spelling is the scratch memory, so we take the parent context.
+if (isWrittenInScratchSpace(getSpellingLoc(loc))) {
+  return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc)));
+}
+else {
+  return isInSystemHeader(getSpellingLoc(loc));
+}
   }
 
   /// The size of the SLocEntry that \p FID represents.
Index: cfe/trunk/test/Misc/no-warn-in-system-macro.c.inc
===
--- cfe/trunk/test/Misc/no-warn-in-system-macro.c.inc
+++ cfe/trunk/test/Misc/no-warn-in-system-macro.c.inc
@@ -0,0 +1,9 @@
+extern int __isnanf(float f);
+extern int __isnan(double f);
+extern int __isnanl(long double f);
+#define isnan(x) \
+	(sizeof (x) == sizeof (float)\
+	? __isnanf (x)\
+	: sizeof (x) == sizeof (double)   \
+	? __isnan (x) : __isnanl (x))
+
Index: cfe/trunk/test/Misc/warn-in-system-macro-def.c.inc
===
--- cfe/trunk/test/Misc/warn-in-system-macro-def.c.inc
+++ cfe/trunk/test/Misc/warn-in-system-macro-def.c.inc
@@ -0,0 +1,4 @@
+extern int __isnanf(float f);
+extern int __isnan(double f);
+extern int __isnanl(long double f);
+#define ISNAN isnan
Index: cfe/trunk/test/Misc/no-warn-in-system-macro.c
===
--- cfe/trunk/test/Misc/no-warn-in-system-macro.c
+++ cfe/trunk/test/Misc/no-warn-in-system-macro.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -isystem %S -Wdouble-promotion -fsyntax-only %s  2>&1 | FileCheck -allow-empty %s
+// CHECK-NOT: warning:
+
+#include 
+
+int main(void)
+{
+	double foo = 1.0;
+
+	if (isnan(foo))
+		return 1;
+	return 0;
+}
Index: cfe/trunk/test/Misc/warn-in-system-macro-def.c
===
--- cfe/trunk/test/Misc/warn-in-system-macro-def.c
+++ cfe/trunk/test/Misc/warn-in-system-macro-def.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -isystem %S -Wdouble-promotion -fsyntax-only %s  2>&1 | FileCheck -allow-empty %s
+// CHECK: warning:
+// CHECK: expanded from macro 'ISNAN'
+// CHECK: expanded from macro 'isnan'
+
+#include 
+
+#define isnan(x) \
+	(sizeof (x) == sizeof (float)\
+	? __isnanf (x)\
+	: sizeof (x) == sizeof (double)   \
+	? __isnan (x) : __isnanl (x))
+
+int main(void)
+{
+	double foo = 1.0;
+
+	if (ISNAN(foo))
+		return 1;
+	return 0;
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r352837 - [clangd] Fix crash in applyTweak, remove TweakID alias.

2019-01-31 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Thu Jan 31 21:41:50 2019
New Revision: 352837

URL: http://llvm.org/viewvc/llvm-project?rev=352837=rev
Log:
[clangd] Fix crash in applyTweak, remove TweakID alias.

Strings are complicated, giving them opaque names makes us forget
they're complicated.

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/refactor/Tweak.cpp
clang-tools-extra/trunk/clangd/refactor/Tweak.h
clang-tools-extra/trunk/clangd/refactor/tweaks/SwapIfBranches.cpp
clang-tools-extra/trunk/unittests/clangd/TweakTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=352837=352836=352837=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Thu Jan 31 21:41:50 2019
@@ -354,10 +354,10 @@ void ClangdServer::enumerateTweaks(PathR
Bind(Action, std::move(CB), File.str()));
 }
 
-void ClangdServer::applyTweak(PathRef File, Range Sel, TweakID ID,
+void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
   Callback CB) {
-  auto Action = [ID, Sel](decltype(CB) CB, std::string File,
-  Expected InpAST) {
+  auto Action = [Sel](decltype(CB) CB, std::string File, std::string TweakID,
+  Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
 
@@ -369,14 +369,15 @@ void ClangdServer::applyTweak(PathRef Fi
 Tweak::Selection Inputs = {InpAST->Inputs.Contents, InpAST->AST,
*CursorLoc};
 
-auto A = prepareTweak(ID, Inputs);
+auto A = prepareTweak(TweakID, Inputs);
 if (!A)
   return CB(A.takeError());
 // FIXME: run formatter on top of resulting replacements.
 return CB((*A)->apply(Inputs));
   };
-  WorkScheduler.runWithAST("ApplyTweak", File,
-   Bind(Action, std::move(CB), File.str()));
+  WorkScheduler.runWithAST(
+  "ApplyTweak", File,
+  Bind(Action, std::move(CB), File.str(), TweakID.str()));
 }
 
 void ClangdServer::dumpAST(PathRef File,

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=352837=352836=352837=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Thu Jan 31 21:41:50 2019
@@ -214,7 +214,7 @@ public:
   Callback> CB);
 
   struct TweakRef {
-TweakID ID;/// ID to pass for applyTweak.
+std::string ID;/// ID to pass for applyTweak.
 std::string Title; /// A single-line message to show in the UI.
   };
   /// Enumerate the code tweaks available to the user at a specified point.
@@ -222,7 +222,7 @@ public:
Callback> CB);
 
   /// Apply the code tweak with a specified \p ID.
-  void applyTweak(PathRef File, Range Sel, TweakID ID,
+  void applyTweak(PathRef File, Range Sel, StringRef ID,
   Callback CB);
 
   /// Only for testing purposes.

Modified: clang-tools-extra/trunk/clangd/refactor/Tweak.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/Tweak.cpp?rev=352837=352836=352837=diff
==
--- clang-tools-extra/trunk/clangd/refactor/Tweak.cpp (original)
+++ clang-tools-extra/trunk/clangd/refactor/Tweak.cpp Thu Jan 31 21:41:50 2019
@@ -55,7 +55,7 @@ std::vector> prep
   return Available;
 }
 
-llvm::Expected> prepareTweak(TweakID ID,
+llvm::Expected> prepareTweak(StringRef ID,
 const Tweak::Selection ) 
{
   auto It = llvm::find_if(
   TweakRegistry::entries(),

Modified: clang-tools-extra/trunk/clangd/refactor/Tweak.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/Tweak.h?rev=352837=352836=352837=diff
==
--- clang-tools-extra/trunk/clangd/refactor/Tweak.h (original)
+++ clang-tools-extra/trunk/clangd/refactor/Tweak.h Thu Jan 31 21:41:50 2019
@@ -27,14 +27,11 @@
 namespace clang {
 namespace clangd {
 
-using TweakID = llvm::StringRef;
-
 /// An interface base for small context-sensitive refactoring actions.
 /// To implement a new tweak use the following pattern in a .cpp file:
 ///   class MyTweak : public Tweak {
 ///   public:
-/// TweakID id() const override final; // definition provided by
-///// REGISTER_TWEAK.
+/// const char* id() const override final; // defined by REGISTER_TWEAK.
 /// // implement 

[PATCH] D57388: [clangd] Implement textDocument/declaration from LSP 3.14

2019-01-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 184678.
sammccall marked 7 inline comments as done.
sammccall added a comment.
Herald added a project: clang.

Address review comments


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57388

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/XRefs.cpp
  clangd/XRefs.h
  test/clangd/initialize-params.test
  unittests/clangd/ClangdTests.cpp
  unittests/clangd/SyncAPI.cpp
  unittests/clangd/SyncAPI.h
  unittests/clangd/TUSchedulerTests.cpp
  unittests/clangd/XRefsTests.cpp

Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -17,6 +17,7 @@
 #include "index/SymbolCollector.h"
 #include "clang/Index/IndexingAction.h"
 #include "llvm/Support/Path.h"
+#include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -25,7 +26,6 @@
 namespace {
 
 using testing::ElementsAre;
-using testing::Field;
 using testing::IsEmpty;
 using testing::Matcher;
 using testing::UnorderedElementsAreArray;
@@ -95,9 +95,35 @@
   }
 }
 
+MATCHER_P3(Sym, Name, Decl, DefOrNone, "") {
+  llvm::Optional Def = DefOrNone;
+  if (Name != arg.Name) {
+*result_listener << "Name is " << arg.Name;
+return false;
+  }
+  if (Decl != arg.PreferredDeclaration.range) {
+*result_listener << "Declaration is "
+ << llvm::to_string(arg.PreferredDeclaration);
+return false;
+  }
+  if (Def && !arg.Definition) {
+*result_listener << "Has no definition";
+return false;
+  }
+  if (Def && arg.Definition->range != *Def) {
+*result_listener << "Definition is " << llvm::to_string(arg.Definition);
+return false;
+  }
+  return true;
+}
+testing::Matcher Sym(std::string Name, Range Decl) {
+  return Sym(Name, Decl, llvm::None);
+}
+MATCHER_P(Sym, Name, "") { return arg.Name == Name; }
+
 MATCHER_P(RangeIs, R, "") { return arg.range == R; }
 
-TEST(GoToDefinition, WithIndex) {
+TEST(LocateSymbol, WithIndex) {
   Annotations SymbolHeader(R"cpp(
 class $forward[[Forward]];
 class $foo[[Foo]] {};
@@ -115,9 +141,9 @@
   TU.Code = SymbolCpp.code();
   TU.HeaderCode = SymbolHeader.code();
   auto Index = TU.index();
-  auto runFindDefinitionsWithIndex = [](const Annotations ) {
+  auto LocateWithIndex = [](const Annotations ) {
 auto AST = TestTU::withCode(Main.code()).build();
-return clangd::findDefinitions(AST, Main.point(), Index.get());
+return clangd::locateSymbolAt(AST, Main.point(), Index.get());
   };
 
   Annotations Test(R"cpp(// only declaration in AST.
@@ -126,9 +152,8 @@
   ^f1();
 }
   )cpp");
-  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
-  testing::ElementsAreArray(
-  {RangeIs(SymbolCpp.range("f1")), RangeIs(Test.range())}));
+  EXPECT_THAT(LocateWithIndex(Test),
+  ElementsAre(Sym("f1", Test.range(), SymbolCpp.range("f1";
 
   Test = Annotations(R"cpp(// definition in AST.
 void [[f1]]() {}
@@ -136,30 +161,30 @@
   ^f1();
 }
   )cpp");
-  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
-  testing::ElementsAreArray(
-  {RangeIs(Test.range()), RangeIs(SymbolHeader.range("f1"))}));
+  EXPECT_THAT(LocateWithIndex(Test),
+  ElementsAre(Sym("f1", SymbolHeader.range("f1"), Test.range(;
 
   Test = Annotations(R"cpp(// forward declaration in AST.
 class [[Foo]];
 F^oo* create();
   )cpp");
-  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
-  testing::ElementsAreArray(
-  {RangeIs(SymbolHeader.range("foo")), RangeIs(Test.range())}));
+  EXPECT_THAT(LocateWithIndex(Test),
+  ElementsAre(Sym("Foo", Test.range(), SymbolHeader.range("foo";
 
   Test = Annotations(R"cpp(// defintion in AST.
 class [[Forward]] {};
 F^orward create();
   )cpp");
-  EXPECT_THAT(runFindDefinitionsWithIndex(Test),
-  testing::ElementsAreArray({
-  RangeIs(Test.range()),
-  RangeIs(SymbolHeader.range("forward")),
-  }));
+  EXPECT_THAT(
+  LocateWithIndex(Test),
+  ElementsAre(Sym("Forward", SymbolHeader.range("forward"), Test.range(;
 }
 
-TEST(GoToDefinition, All) {
+TEST(LocateSymbol, All) {
+  // Ranges in tests:
+  //   $decl is the declaration location (if absent, no symbol is located)
+  //   $def is the definition location (if absent, symbol has no definition)
+  //   unnamed range becomes both $decl and $def.
   const char *Tests[] = {
   R"cpp(// Local variable
 int main() {
@@ -186,7 +211,7 @@
   )cpp",
 
   R"cpp(// Function declaration via call
-int [[foo]](int);
+int $decl[[foo]](int);
 int main() {
   

[PATCH] D57388: [clangd] Implement textDocument/declaration from LSP 3.14

2019-01-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/ClangdLSPServer.cpp:332
  }},
+{"declarationProvider", true},
 {"definitionProvider", true},

hokein wrote:
> I believe missing this is a LSP protocol bug, vscode uses this term 
> https://github.com/Microsoft/vscode/blob/248aea7fd51a703a7ab94ae5a582c85c11fbff33/src/vs/vscode.d.ts#L2301.
Yeah, agree.



Comment at: clangd/XRefs.cpp:38
+  // Only a single declaration is allowed.
+  if (isa(D)) // except cases above
+return D;

hokein wrote:
> is this a case that we were missing before? can we add a unittest for it (I 
> didn't find a related change in the unittest).
Previously, this function only had to be correct for things that can be 
declared and defined separately.
For some decls that are always definitions (e.g. member variables) we would 
return nullptr here, and treat them as decl-only ... but that was OK, because 
the return value was just "a list of locations" and it didn't matter whether we 
treated them as decls or defs when there's just one.

However now the return type is "here's the decl, and here's the def". Without 
this change, we have Definition == llvm::None for e.g. member variables. While 
the LSP method falls back from def->decl so you probably can't observe this 
problem, API users can.

This is in fact covered by the tests, though it's kind of indirect (this is a 
private helper function, after all).



Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57388



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


[PATCH] D57325: [clangd] Collect macros in static index.

2019-01-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.
Herald added a project: clang.

So I'm not sure this is actually going to be a win.

When building google's big static index, we index these symbols and then throw 
most of them away (a high usage threshold applies).
But there's no mechanism here to do that.
If we do index *all* of these, how often are they going to be good vs bad 
results?

Is there a motivating case for the sorts of macros you are missing?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57325



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


[PATCH] D57438: [Sema][ObjC] Allow declaring ObjC pointer members in C++ unions under ARC

2019-01-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:7084
 
+  if (FD->getParent()->isUnion() &&
+  shouldDeleteForVariantObjCPtrMember(FD, FieldType))

rjmccall wrote:
> I believe the right check for variant-ness is `inUnion()`, not 
> `FD->getParent()->isUnion()`, since the latter can miss cases with e.g. 
> anonymous `struct`s.
Can you try adding a test case here for an anonymous struct nested within an 
anonymous union?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57438



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


[PATCH] D56555: Add Attribute to define nonlazy objc classes

2019-01-31 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

Thanks!  I'd like Aaron to sign off as well before we commit this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56555



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


[PATCH] D56555: Add Attribute to define nonlazy objc classes

2019-01-31 Thread Joe via Phabricator via cfe-commits
joedaniels29 updated this revision to Diff 184671.
joedaniels29 marked 4 inline comments as done.
joedaniels29 added a comment.
Herald added a project: clang.

Docs changes, formatting.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56555

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGenObjC/non-lazy-classes.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/attr-objc-non-lazy.m

Index: clang/test/SemaObjC/attr-objc-non-lazy.m
===
--- /dev/null
+++ clang/test/SemaObjC/attr-objc-non-lazy.m
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -verify -Wno-objc-root-class  -fsyntax-only  %s
+
+__attribute__((objc_nonlazy_class))
+@interface A
+@end
+@implementation A
+@end
+
+__attribute__((objc_nonlazy_class)) int X; // expected-error {{'objc_nonlazy_class' attribute only applies to Objective-C interfaces}}
+
+__attribute__((objc_nonlazy_class()))
+@interface B
+@end
+@implementation B
+@end
+
+__attribute__((objc_nonlazy_class("foo"))) // expected-error{{'objc_nonlazy_class' attribute takes no arguments}}
+@interface C
+@end
+@implementation C
+@end
+
+__attribute__((objc_nonlazy_class)) // expected-error {{'objc_nonlazy_class' attribute only applies to Objective-C interfaces}}
+@protocol B
+@end
+
+__attribute__((objc_nonlazy_class)) // expected-error {{'objc_nonlazy_class' attribute only applies to Objective-C interfaces}}
+void foo();
+
+@interface E
+@end
+__attribute__((objc_nonlazy_class))
+@implementation E // expected-error {{prefix attribute must be followed by an interface or protocol}}
+@end
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 129 attributes:
+// CHECK: #pragma clang attribute supports 130 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -92,6 +92,7 @@
 // CHECK-NEXT: ObjCException (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: ObjCExplicitProtocolImpl (SubjectMatchRule_objc_protocol)
 // CHECK-NEXT: ObjCMethodFamily (SubjectMatchRule_objc_method)
+// CHECK-NEXT: ObjCNonLazyClass (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: ObjCPreciseLifetime (SubjectMatchRule_variable)
 // CHECK-NEXT: ObjCRequiresPropertyDefs (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: ObjCRequiresSuper (SubjectMatchRule_objc_method)
Index: clang/test/CodeGenObjC/non-lazy-classes.m
===
--- clang/test/CodeGenObjC/non-lazy-classes.m
+++ clang/test/CodeGenObjC/non-lazy-classes.m
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -Wno-objc-root-class -emit-llvm -o - %s | \
 // RUN: FileCheck %s
-// CHECK: @"OBJC_LABEL_NONLAZY_CLASS_$" = private global [1 x {{.*}}] {{.*}}@"OBJC_CLASS_$_A"{{.*}}, section "__DATA,__objc_nlclslist,regular,no_dead_strip", align 8
+// CHECK: @"OBJC_LABEL_NONLAZY_CLASS_$" = private global [2 x {{.*}}]{{.*}}@"OBJC_CLASS_$_A"{{.*}},{{.*}}@"OBJC_CLASS_$_D"{{.*}} section "__DATA,__objc_nlclslist,regular,no_dead_strip", align 8
 // CHECK: @"OBJC_LABEL_NONLAZY_CATEGORY_$" = private global [1 x {{.*}}] {{.*}}@"\01l_OBJC_$_CATEGORY_A_$_Cat"{{.*}}, section "__DATA,__objc_nlcatlist,regular,no_dead_strip", align 8
 
 @interface A @end
@@ -30,3 +30,8 @@
 @interface C : A @end
 @implementation C
 @end
+
+__attribute__((objc_nonlazy_class))
+@interface D @end
+
+@implementation D @end
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6374,6 +6374,9 @@
   case ParsedAttr::AT_ObjCRootClass:
 handleSimpleAttribute(S, D, AL);
 break;
+  case ParsedAttr::AT_ObjCNonLazyClass:
+handleSimpleAttribute(S, D, AL);
+break;
   case ParsedAttr::AT_ObjCSubclassingRestricted:
 handleSimpleAttribute(S, D, AL);
 break;
Index: clang/lib/CodeGen/CGObjCMac.cpp
===
--- clang/lib/CodeGen/CGObjCMac.cpp
+++ clang/lib/CodeGen/CGObjCMac.cpp
@@ -6253,9 +6253,10 @@
   return GV;
 }
 
-bool
-CGObjCNonFragileABIMac::ImplementationIsNonLazy(const ObjCImplDecl *OD) const {
-  return OD->getClassMethod(GetNullarySelector("load")) != nullptr;
+bool CGObjCNonFragileABIMac::ImplementationIsNonLazy(
+const ObjCImplDecl *OD) const {
+  return 

[PATCH] D53076: [analyzer] Enhance ConditionBRVisitor to write out more information

2019-01-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:166-173
+  // The declaration of the value may rely on a pointer so take its l-value.
+  if (const auto *DRE = dyn_cast_or_null(CondVarExpr)) {
+if (const auto *VD = dyn_cast_or_null(DRE->getDecl())) {
+  SVal DeclSVal = State->getSVal(State->getLValue(VD, LCtx));
+  if (auto DeclCI = DeclSVal.getAs())
+return >getValue();
+}

I'll take a closer look at the rest of the patch, but this code snippet looks 
suspicious to me at a glance. Does it ever add anything on top of the 
"hard-coded" case? When it does, is it correct?

I mean, the "hard-coded" case does not actually correspond to an integer 
literal expression; it corresponds to any circumstances in which the Static 
Analyzer could compute that the value is going to be exactly that concrete 
integer on this execution path. If the Static Analyzer could not compute that, 
i doubt that this simple procedure will do better.

It might be that this is needed because you're looking at a wrong 
`ExplodedNode` on which the condition expression is either not computed yet or 
already dropped. In this case i'd prefer to try harder to find the right node, 
because `getSVal(CondVarExpr, LCtx)` is just so much more powerful.


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

https://reviews.llvm.org/D53076



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


[PATCH] D57032: [SemaCXX] Param diagnostic matches overload logic

2019-01-31 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Thanks for the reviews!


Repository:
  rC Clang

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

https://reviews.llvm.org/D57032



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


[PATCH] D57032: [SemaCXX] Param diagnostic matches overload logic

2019-01-31 Thread Brian Gesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352831: [SemaCXX] Param diagnostic matches overload logic 
(authored by modocache, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57032?vs=184284=184667#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57032

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/function-redecl.cpp


Index: test/SemaCXX/function-redecl.cpp
===
--- test/SemaCXX/function-redecl.cpp
+++ test/SemaCXX/function-redecl.cpp
@@ -125,3 +125,9 @@
 }
 void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' 
does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 
'BeEvil'?}}
 }
+
+struct CVQualFun {
+  void func(int a, int ); // expected-note {{type of 2nd parameter of member 
declaration does not match definition ('int &' vs 'int')}}
+};
+
+void CVQualFun::func(const int a, int b) {} // expected-error {{out-of-line 
definition of 'func' does not match any declaration in 'CVQualFun'}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5087,7 +5087,7 @@
 QualType DefParamTy = Definition->getParamDecl(Idx)->getType();
 
 // The parameter types are identical
-if (Context.hasSameType(DefParamTy, DeclParamTy))
+if (Context.hasSameUnqualifiedType(DefParamTy, DeclParamTy))
   continue;
 
 QualType DeclParamBaseTy = getCoreType(DeclParamTy);


Index: test/SemaCXX/function-redecl.cpp
===
--- test/SemaCXX/function-redecl.cpp
+++ test/SemaCXX/function-redecl.cpp
@@ -125,3 +125,9 @@
 }
 void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}}
 }
+
+struct CVQualFun {
+  void func(int a, int ); // expected-note {{type of 2nd parameter of member declaration does not match definition ('int &' vs 'int')}}
+};
+
+void CVQualFun::func(const int a, int b) {} // expected-error {{out-of-line definition of 'func' does not match any declaration in 'CVQualFun'}}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -5087,7 +5087,7 @@
 QualType DefParamTy = Definition->getParamDecl(Idx)->getType();
 
 // The parameter types are identical
-if (Context.hasSameType(DefParamTy, DeclParamTy))
+if (Context.hasSameUnqualifiedType(DefParamTy, DeclParamTy))
   continue;
 
 QualType DeclParamBaseTy = getCoreType(DeclParamTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r352831 - [SemaCXX] Param diagnostic matches overload logic

2019-01-31 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Thu Jan 31 19:30:29 2019
New Revision: 352831

URL: http://llvm.org/viewvc/llvm-project?rev=352831=rev
Log:
[SemaCXX] Param diagnostic matches overload logic

Summary:
Given the following test program:

```
class C {
public:
  int A(int a, int& b);
};

int C::A(const int a, int b) {
  return a * b;
}
```

Clang would produce an error message that correctly diagnosed the
redeclaration of `C::A` to not match the original declaration (the
parameters to the two declarations do not match -- the original takes an
`int &` as its 2nd parameter, but the redeclaration takes an `int`). However,
it also produced a note diagnostic that inaccurately pointed to the
first parameter, claiming that `const int` in the redeclaration did not
match the unqualified `int` in the original. The diagnostic is
misleading because it has nothing to do with why the program does not
compile.

The logic for checking for a function overload, in
`Sema::FunctionParamTypesAreEqual`, discards cv-qualifiers before
checking whether the types are equal. Do the same when producing the
overload diagnostic.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: cpplearner, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/function-redecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=352831=352830=352831=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jan 31 19:30:29 2019
@@ -5087,7 +5087,7 @@ static bool hasSimilarParameters(ASTCont
 QualType DefParamTy = Definition->getParamDecl(Idx)->getType();
 
 // The parameter types are identical
-if (Context.hasSameType(DefParamTy, DeclParamTy))
+if (Context.hasSameUnqualifiedType(DefParamTy, DeclParamTy))
   continue;
 
 QualType DeclParamBaseTy = getCoreType(DeclParamTy);

Modified: cfe/trunk/test/SemaCXX/function-redecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/function-redecl.cpp?rev=352831=352830=352831=diff
==
--- cfe/trunk/test/SemaCXX/function-redecl.cpp (original)
+++ cfe/trunk/test/SemaCXX/function-redecl.cpp Thu Jan 31 19:30:29 2019
@@ -125,3 +125,9 @@ bool Foo::isGood() { // expected-error {
 }
 void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' 
does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 
'BeEvil'?}}
 }
+
+struct CVQualFun {
+  void func(int a, int ); // expected-note {{type of 2nd parameter of member 
declaration does not match definition ('int &' vs 'int')}}
+};
+
+void CVQualFun::func(const int a, int b) {} // expected-error {{out-of-line 
definition of 'func' does not match any declaration in 'CVQualFun'}}


___
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-01-31 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 added a comment.
Herald added a project: clang.

In D57497#1378511 , @simoncook wrote:

> As this mllvm option only affects the creation of ELF objects, do we also 
> need to add a similar option for the LTO case, as the -G value would have no 
> effect otherwise?


Hi Simon, I think you're right, we may need a way to pass -G value for the LTO. 
One possible solution is adding passing code in `AddGoldPlugin`, but there's no 
other target specific code.  I can't find other targets passing their `cl::opt` 
flags through the LTO. Any suggestions?


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


[PATCH] D57032: [SemaCXX] Param diagnostic matches overload logic

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

Thanks, LGTM.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57032



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


r352829 - [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls

2019-01-31 Thread Julian Lettner via cfe-commits
Author: yln
Date: Thu Jan 31 18:51:00 2019
New Revision: 352829

URL: http://llvm.org/viewvc/llvm-project?rev=352829=rev
Log:
[Sanitizers] UBSan unreachable incompatible with ASan in the presence of 
`noreturn` calls

Summary:
UBSan wants to detect when unreachable code is actually reached, so it
adds instrumentation before every unreachable instruction. However, the
optimizer will remove code after calls to functions marked with
noreturn. To avoid this UBSan removes noreturn from both the call
instruction as well as from the function itself. Unfortunately, ASan
relies on this annotation to unpoison the stack by inserting calls to
_asan_handle_no_return before noreturn functions. This is important for
functions that do not return but access the the stack memory, e.g.,
unwinder functions *like* longjmp (longjmp itself is actually
"double-proofed" via its interceptor). The result is that when ASan and
UBSan are combined, the noreturn attributes are missing and ASan cannot
unpoison the stack, so it has false positives when stack unwinding is
used.

Changes:
Clang-CodeGen now directly insert calls to `__asan_handle_no_return`
when a call to a noreturn function is encountered and both
UBsan-unreachable and ASan are enabled. This allows UBSan to continue
removing the noreturn attribute from functions without any changes to
the ASan pass.

Previously generated code:
```
  call void @longjmp
  call void @__asan_handle_no_return
  call void @__ubsan_handle_builtin_unreachable
```

Generated code (for now):
```
  call void @__asan_handle_no_return
  call void @longjmp
  call void @__asan_handle_no_return
  call void @__ubsan_handle_builtin_unreachable
```

rdar://problem/40723397

Reviewers: delcypher, eugenis, vsk

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

llvm-svn: 352690

Added:
cfe/trunk/test/CodeGen/ubsan-asan-noreturn.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/test/CodeGenCXX/ubsan-unreachable.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=352829=352828=352829=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Jan 31 18:51:00 2019
@@ -4398,10 +4398,23 @@ RValue CodeGenFunction::EmitCall(const C
 
 // Strip away the noreturn attribute to better diagnose unreachable UB.
 if (SanOpts.has(SanitizerKind::Unreachable)) {
+  // Also remove from function since CI->hasFnAttr(..) also checks 
attributes
+  // of the called function.
   if (auto *F = CI->getCalledFunction())
 F->removeFnAttr(llvm::Attribute::NoReturn);
   CI->removeAttribute(llvm::AttributeList::FunctionIndex,
   llvm::Attribute::NoReturn);
+
+  // Avoid incompatibility with ASan which relies on the `noreturn`
+  // attribute to insert handler calls.
+  if (SanOpts.has(SanitizerKind::Address)) {
+SanitizerScope SanScope(this);
+llvm::IRBuilder<>::InsertPointGuard IPGuard(Builder);
+Builder.SetInsertPoint(CI);
+auto *FnType = llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
+auto *Fn = CGM.CreateRuntimeFunction(FnType, 
"__asan_handle_no_return");
+EmitNounwindRuntimeCall(Fn);
+  }
 }
 
 EmitUnreachable(Loc);

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=352829=352828=352829=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu Jan 31 18:51:00 2019
@@ -4084,8 +4084,8 @@ public:
   /// passing to a runtime sanitizer handler.
   llvm::Constant *EmitCheckSourceLocation(SourceLocation Loc);
 
-  /// Create a basic block that will call a handler function in a
-  /// sanitizer runtime with the provided arguments, and create a conditional
+  /// Create a basic block that will either trap or call a handler function in
+  /// the UBSan runtime with the provided arguments, and create a conditional
   /// branch to it.
   void EmitCheck(ArrayRef> Checked,
  SanitizerHandler Check, ArrayRef StaticArgs,

Added: cfe/trunk/test/CodeGen/ubsan-asan-noreturn.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-asan-noreturn.c?rev=352829=auto
==
--- cfe/trunk/test/CodeGen/ubsan-asan-noreturn.c (added)
+++ cfe/trunk/test/CodeGen/ubsan-asan-noreturn.c Thu Jan 31 18:51:00 2019
@@ -0,0 +1,21 @@
+// Ensure compatiblity of UBSan unreachable with ASan in the presence of
+// noreturn functions.
+// RUN: %clang_cc1 -fsanitize=unreachable,address -triple x86_64-linux 
-emit-llvm -o - %s | FileCheck %s
+
+void my_longjmp(void) 

[PATCH] D57032: [SemaCXX] Param diagnostic matches overload logic

2019-01-31 Thread Brian Gesiak via Phabricator via cfe-commits
modocache marked an inline comment as done.
modocache added a comment.
Herald added a project: clang.

Friendly ping! Is there anything I can do to improve this patch? I think it's a 
clear improvement of the diagnostic, with a test case to boot!


Repository:
  rC Clang

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

https://reviews.llvm.org/D57032



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


[PATCH] D57438: [Sema][ObjC] Allow declaring ObjC pointer members in C++ unions under ARC

2019-01-31 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 184665.
ahatanak marked 3 inline comments as done.
ahatanak added a comment.

Address review comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57438

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/DeclCXX.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/SemaObjCXX/arc-0x.mm
  test/SemaObjCXX/objc-weak.mm

Index: test/SemaObjCXX/objc-weak.mm
===
--- test/SemaObjCXX/objc-weak.mm
+++ test/SemaObjCXX/objc-weak.mm
@@ -13,7 +13,7 @@
 };
 
 union U {
-  __weak id a; // expected-error {{ARC forbids Objective-C objects in union}}
+  __weak id a;
   S b; // expected-error {{union member 'b' has a non-trivial copy constructor}}
 };
 
Index: test/SemaObjCXX/arc-0x.mm
===
--- test/SemaObjCXX/arc-0x.mm
+++ test/SemaObjCXX/arc-0x.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -verify -fblocks -fobjc-exceptions %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -fobjc-weak -verify -fblocks -fobjc-exceptions %s
 
 // "Move" semantics, trivial version.
 void move_it(__strong id &) {
@@ -111,3 +111,141 @@
 func(^(A *a[]){}); // expected-error{{must explicitly describe intended ownership of an object array parameter}}
   }
 }
+
+namespace test_union {
+  // Implicitly-declared special functions of a union are deleted by default if
+  // ARC is enabled and the union has an ObjC pointer field.
+  union U0 {
+id f0; // expected-note 6 {{'U0' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  };
+
+  union U1 {
+__weak id f0; // expected-note 12 {{'U1' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+U1() = default; // expected-warning {{explicitly defaulted default constructor is implicitly deleted}} expected-note {{explicitly defaulted function was implicitly deleted here}}
+~U1() = default; // expected-warning {{explicitly defaulted destructor is implicitly deleted}} expected-note {{explicitly defaulted function was implicitly deleted here}}
+U1(const U1 &) = default; // expected-warning {{explicitly defaulted copy constructor is implicitly deleted}} expected-note 2 {{explicitly defaulted function was implicitly deleted here}}
+U1(U1 &&) = default; // expected-warning {{explicitly defaulted move constructor is implicitly deleted}}
+U1 & operator=(const U1 &) = default; // expected-warning {{explicitly defaulted copy assignment operator is implicitly deleted}} expected-note 2 {{explicitly defaulted function was implicitly deleted here}}
+U1 & operator=(U1 &&) = default; // expected-warning {{explicitly defaulted move assignment operator is implicitly deleted}}
+  };
+
+  id getStrong();
+
+  // If the ObjC pointer field of a union has a default member initializer, the
+  // implicitly-declared default constructor of the union is not deleted by
+  // default.
+  union U2 {
+id f0 = getStrong(); // expected-note 4 {{'U2' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+~U2();
+  };
+
+  // It's fine if the user has explicitly defined the special functions.
+  union U3 {
+id f0;
+U3();
+~U3();
+U3(const U3 &);
+U3(U3 &&);
+U3 & operator=(const U3 &);
+U3 & operator=(U3 &&);
+  };
+
+  // ObjC pointer fields in anonymous union fields delete the defaulted special
+  // functions of the containing class.
+  struct S0 {
+union {
+  id f0; // expected-note 6 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+  char f1;
+};
+  };
+
+  struct S1 {
+union {
+  union { // expected-note 2 {{'S1' is implicitly deleted because variant field '' has a non-trivial}} expected-note 4 {{'S1' is implicitly deleted because field '' has a deleted}}
+id f0; // expected-note 2 {{'' is implicitly deleted because variant field 'f0' is an ObjC pointer}}
+char f1;
+  };
+  int f2;
+};
+  };
+
+  U0 *x0;
+  U1 *x1;
+  U2 *x2;
+  U3 *x3;
+  S0 *x4;
+  S1 *x5;
+
+  static union { // expected-error {{call to implicitly-deleted default constructor of}}
+id g0; // expected-note {{default constructor of '' is implicitly deleted because variant field 'g0' is an ObjC pointer}}
+  };
+
+  static union { // expected-error {{call to implicitly-deleted default constructor of}}
+union { // expected-note {{default constructor of '' is implicitly deleted because field '' has a deleted default constructor}}
+  union { // expected-note {{default constructor of '' is implicitly deleted because field '' has a deleted default constructor}}
+__weak id g1; // expected-note {{default constructor of '' is implicitly deleted because variant field 'g1' is an ObjC pointer}}
+int g2;
+  };
+  int g3;
+   

[PATCH] D57438: [Sema][ObjC] Allow declaring ObjC pointer members in C++ unions under ARC

2019-01-31 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: test/SemaObjCXX/arc-0x.mm:164
+union {
+  union { // expected-note 2 {{'S1' is implicitly deleted because variant 
field '' has a non-trivial}} expected-note 4 {{'S1' is implicitly deleted 
because field '' has a deleted}}
+id f0; // expected-note 2 {{'' is implicitly deleted because variant 
field 'f0' is an ObjC pointer}}

rjmccall wrote:
> ahatanak wrote:
> > The diagnostic message here should say the special function is deleted 
> > because the anonymous union's corresponding special function is deleted, 
> > but when diagnosing a deleted copy assignment operator, it says the 
> > anonymous union's special function is non-trivial. I'm not sure this is a 
> > bug, but I see the same diagnostic message when I compile the following 
> > non-ObjC code:
> > 
> > ```
> > struct S0 {
> >   S0(const S0 &);
> >   S0 =(const S0 &);
> >   int *p;
> > };
> > 
> > struct S1 {
> >   union {
> > union { // copy assignment operator of 'S1' is implicitly deleted 
> > because variant field '' has a non-trivial copy assignment operator
> >   S0 s10;
> >   int b;
> > };
> > int c;
> >   };
> >   ~S1();
> > };
> > 
> > S1 *x0;
> > 
> > void testC1(S1 *a0) {
> >   *a0 = *x0; // error: object of type 'S1' cannot be assigned because its 
> > copy assignment operator is implicitly deleted
> >   *a0 = static_cast(*x0); // error: object of type 'S1' cannot be 
> > assigned because its copy assignment operator is implicitly deleted
> > }
> > ```
> > 
> > It seems that this happens because the following code in 
> > `Sema::ShouldDeleteSpecialMember` is preventing the method declaration from 
> > being marked as deleted:
> > 
> > ```
> >   // For an anonymous struct or union, the copy and assignment special 
> > members
> >   // will never be used, so skip the check. For an anonymous union declared 
> > at
> >   // namespace scope, the constructor and destructor are used.
> >   if (CSM != CXXDefaultConstructor && CSM != CXXDestructor &&
> >   RD->isAnonymousStructOrUnion())
> > return false;
> > ```
> Well, if it's not different from the ordinary C++ treatment, I think we can 
> justify just improving QoI there separately.
I filed PR40555 to fix the C++ case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57438



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


r352827 - [opaque pointer types] Add a FunctionCallee wrapper type, and use it.

2019-01-31 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Thu Jan 31 18:28:03 2019
New Revision: 352827

URL: http://llvm.org/viewvc/llvm-project?rev=352827=rev
Log:
[opaque pointer types] Add a FunctionCallee wrapper type, and use it.

Recommit r352791 after tweaking DerivedTypes.h slightly, so that gcc
doesn't choke on it, hopefully.

Original Message:
The FunctionCallee type is effectively a {FunctionType*,Value*} pair,
and is a useful convenience to enable code to continue passing the
result of getOrInsertFunction() through to EmitCall, even once pointer
types lose their pointee-type.

Then:
- update the CallInst/InvokeInst instruction creation functions to
  take a Callee,
- modify getOrInsertFunction to return FunctionCallee, and
- update all callers appropriately.

One area of particular note is the change to the sanitizer
code. Previously, they had been casting the result of
`getOrInsertFunction` to a `Function*` via
`checkSanitizerInterfaceFunction`, and storing that. That would report
an error if someone had already inserted a function declaraction with
a mismatching signature.

However, in general, LLVM allows for such mismatches, as
`getOrInsertFunction` will automatically insert a bitcast if
needed. As part of this cleanup, cause the sanitizer code to do the
same. (It will call its functions using the expected signature,
however they may have been declared.)

Finally, in a small number of locations, callers of
`getOrInsertFunction` actually were expecting/requiring that a brand
new function was being created. In such cases, I've switched them to
Function::Create instead.

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

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

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=352827=352826=352827=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jan 31 18:28:03 2019
@@ -3056,7 +3056,7 @@ void CodeGenFunction::EmitCfiSlowPathChe
   bool WithDiag = !CGM.getCodeGenOpts().SanitizeTrap.has(Kind);
 
   llvm::CallInst *CheckCall;
-  llvm::Constant *SlowPathFn;
+  llvm::FunctionCallee SlowPathFn;
   if (WithDiag) {
 llvm::Constant *Info = llvm::ConstantStruct::getAnon(StaticArgs);
 auto *InfoPtr =
@@ -3078,7 +3078,8 @@ void CodeGenFunction::EmitCfiSlowPathChe
 CheckCall = Builder.CreateCall(SlowPathFn, {TypeId, Ptr});
   }
 
-  CGM.setDSOLocal(cast(SlowPathFn->stripPointerCasts()));
+  CGM.setDSOLocal(
+  cast(SlowPathFn.getCallee()->stripPointerCasts()));
   CheckCall->setDoesNotThrow();
 
   EmitBlock(Cont);


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


r352824 - [analyzer] [RetainCountChecker] Fix object type for CF/Obj-C bridged casts

2019-01-31 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Thu Jan 31 18:13:02 2019
New Revision: 352824

URL: http://llvm.org/viewvc/llvm-project?rev=352824=rev
Log:
[analyzer] [RetainCountChecker] Fix object type for CF/Obj-C bridged casts

Having an incorrect type for a cast causes the checker to incorrectly
dismiss the operation under ARC, leading to a false positive
use-after-release on the test.

rdar://47709885

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

Modified:

cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
cfe/trunk/test/Analysis/objc-arc.m

Modified: 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp?rev=352824=352823=352824=diff
==
--- 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
(original)
+++ 
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountChecker.cpp 
Thu Jan 31 18:13:02 2019
@@ -185,7 +185,16 @@ void RetainCountChecker::checkPostStmt(c
   if (!BE)
 return;
 
-  ArgEffect AE = ArgEffect(IncRef, ObjKind::ObjC);
+  QualType QT = CE->getType();
+  ObjKind K;
+  if (coreFoundation::isCFObjectRef(QT)) {
+K = ObjKind::CF;
+  } else {
+assert(cocoa::isCocoaObjectRef(QT));
+K = ObjKind::ObjC;
+  }
+
+  ArgEffect AE = ArgEffect(IncRef, K);
 
   switch (BE->getBridgeKind()) {
 case OBC_Bridge:

Modified: cfe/trunk/test/Analysis/objc-arc.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/objc-arc.m?rev=352824=352823=352824=diff
==
--- cfe/trunk/test/Analysis/objc-arc.m (original)
+++ cfe/trunk/test/Analysis/objc-arc.m Thu Jan 31 18:13:02 2019
@@ -123,7 +123,7 @@ void rdar9424882() {
 typedef const void *CFTypeRef;
 typedef const struct __CFString *CFStringRef;
 
-@interface NSString
+@interface NSString : NSObject
 - (id) self;
 @end
 
@@ -231,3 +231,16 @@ id rdar14061675() {
   return result;
 }
 
+typedef const void * CFTypeRef;
+typedef const struct __CFString * CFStringRef;
+typedef const struct __CFAllocator * CFAllocatorRef;
+extern const CFAllocatorRef kCFAllocatorDefault;
+
+extern CFTypeRef CFRetain(CFTypeRef cf);
+extern void CFRelease(CFTypeRef cf);
+
+void check_bridge_retained_cast() {
+NSString *nsStr = [[NSString alloc] init];
+CFStringRef cfStr = (__bridge_retained CFStringRef)nsStr;
+CFRelease(cfStr); // no-warning
+}


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


Re: [PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-31 Thread Sam McCall via cfe-commits
Thanks!
I suspect shared libraries makes a difference here, because the tweaks use
an unusual library type (object library) to force linking.

On Fri, Feb 1, 2019 at 3:01 AM Nathan Ridge via Phabricator <
revi...@reviews.llvm.org> wrote:

> nridge added a comment.
>
> Fix here: https://reviews.llvm.org/D57560
>
>
> Repository:
>   rL LLVM
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D56611/new/
>
> https://reviews.llvm.org/D56611
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45978: dllexport const variables must have external linkage.

2019-01-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I'm still not sure this is the best place to make this change, but the 
functionality is important. There are still unaddressed comments (no need to 
check MSVCCompatibility, formatting), and I think once those are fixed we can 
land this.




Comment at: test/Sema/dllexport.c:70
+// const variables
+__declspec(dllexport) int const x = 3;
 

aaron.ballman wrote:
> zahiraam wrote:
> > aaron.ballman wrote:
> > > Can you think of any redeclaration scenarios we should also test? e.g., 
> > > weird cases like this:
> > > ```
> > > extern int const x;
> > > __declspec(dllexport) int const x = 3;
> > > ```
> > > which brings up an interesting question -- does MSVC truly treat it as 
> > > though it were extern, or just only-kinda-sorta treat it like it was 
> > > extern? e.g., can you do this:
> > > ```
> > > __declspec(dllexport) const int j;
> > > ```
> > > Regardless, having some codegen tests demonstrating that the variable has 
> > > the correct semantics that we're emulating would be nice.
> > With MSVC:
> > 
> > ksh-3.2$ cat t2.cpp
> > __declspec(dllexport) const int j;
> > ksh-3.2$
> > 
> > ksh-3.2$ cl -c t2.cpp
> > Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
> > Copyright (C) Microsoft Corporation.  All rights reserved.
> > 
> > t2.cpp
> > t2.cpp(1): error C2734: 'j': 'const' object must be initialized if not 
> > 'extern'
> > 
> > ksh-3.2$ cat t3.cpp
> > __declspec(dllexport) int const x = 3;
> > int main ()
> > {
> >   int y = x + 10;
> > 
> >   return y;
> > }
> > 
> > ksh-3.2$ cl -c t3.cpp
> > Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
> > Copyright (C) Microsoft Corporation.  All rights reserved.
> > 
> > t3.cpp
> > ksh-3.2$ dumpbin /symbols t3.obj | grep External
> > **008  SECT3  notype ()External | main**
> > ksh-3.2$
> > ksh-3.2$ cat t4.cpp
> > extern int const x = 3;
> > int main ()
> > {
> >   int y = x + 10;
> > 
> >   return y;
> > }
> > 
> > ksh-3.2$ cl -c t4.cpp
> > Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
> > Copyright (C) Microsoft Corporation.  All rights reserved.
> > 
> > t4.cpp
> > ksh-3.2$ dumpbin /symbols t4.obj | grep External
> > **008  SECT3  notype   External | ?x@@3HB (int const x)
> > 00B  SECT4  notype ()External | main**
> > ksh-3.2$
> > 
> > So we see that with dllexport, the ony symbol marked with "External" is 
> > main. With "extern" both main and x are marked as External.
> > 
> > With clang without the patch:
> > ksh-3.2$ clang -c t2.cpp
> > t2.cpp:1:33: error: default initialization of an object of const type 
> > 'const int'
> > __declspec(dllexport) const int j;
> > ^
> >   = 0
> > t2.cpp:1:33: error: 'j' must have external linkage when declared 'dllexport'
> > 2 errors generated.
> > ksh-3.2$
> > ksh-3.2$ clang -c t3.cpp
> > t3.cpp:1:33: error: 'x' must have external linkage when declared 'dllexport'
> > __declspec(dllexport) int const x = 3;
> > ^
> > 1 error generated.
> > ksh-3.2$ clang -c t4.cpp
> > ksh-3.2$ dumpbin /symbols t4.o | grep External
> > **00F  SECT1  notype ()External | main
> > 010  SECT5  notype   External | ?x@@3HB (int const x)**
> > ksh-3.2$
> > 
> > Clang with patch above at the right place (I am thinking in  
> > Sema::AddInitializerToDecl):
> > 
> > ksh-3.2$ clang -c t3.cpp
> > ksh-3.2$ dumpbin /symbols t3.o | grep External
> > **00E  SECT1  notype ()External | main
> > 00F  SECT5  notype   External | ?x@@3HB (int const x)**
> > ksh-3.2$
> > ksh-3.2$ clang -c t4.cpp
> > ksh-3.2$ dumpbin /symbols t4.o | grep External
> > 00C  SECT1  notype ()External | main
> > 00D  SECT5  notype   External | ?x@@3HB (int const x)
> > ksh-3.2$
> > 
> > Both MSVC and clang have the same behavior with t2.cpp.
> > With the patch clang will have the same beahvior than MSVC when extern and 
> > dllexport are used. That's not  quite what MSVC's behavior is!
> > What are your thoughts?
> > Thanks.
> > 
> > 
> Neat, so MSVC treats it as sort-of-extern-but-sort-of-not. I can't tell 
> whether this is intentional and we want to be compatible, or whether this is 
> a bug in MSVC (and if so, is it one uses are relying on and we need to 
> emulate). I'm not certain what the best answer is here. Perhaps @rnk or 
> @majnemer have opinions?
Yes, we should be compatible in this area, it's an extension that we implement, 
not invalid C++.


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

https://reviews.llvm.org/D45978



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


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-31 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Fix here: https://reviews.llvm.org/D57560


Repository:
  rL LLVM

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

https://reviews.llvm.org/D56611



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


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-31 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

The complete commands that's failing is:

  /usr/bin/clang++-8  -fPIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -std=c++11 -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default 
-Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor 
-Wstring-conversion -fdiagnostics-color -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O0 -g3  -fuse-ld=gold -Wl,-allow-shlib-undefined 
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SwapIfBranches.cpp.o
 tools/clang/tools/extra/clangd/tool/CMakeFiles/clangd.dir/ClangdMain.cpp.o  -o 
bin/clangd  -Wl,-rpath,"\$ORIGIN/../lib" lib/libLLVMSupport.so.9svn -lpthread 
lib/libclangBasic.so.9svn lib/libclangTidy.so.9svn lib/libclangDaemon.so.9svn 
lib/libclangFormat.so.9svn lib/libclangFrontend.so.9svn 
lib/libclangSema.so.9svn lib/libclangTooling.so.9svn 
lib/libclangToolingCore.so.9svn


Repository:
  rL LLVM

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

https://reviews.llvm.org/D56611



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


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-31 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D56611#1379876 , @sammccall wrote:

> Hi Nathan,
>  What platform is this on? Not seeing it on the buildbots.
>  Anything unusual in build setup (standalone build, building with shared 
> libraries, etc)?


I'm on Linux, building with shared libraries. Not sure what standalone means in 
this context, I'm building the monorepo with `-DLLVM_ENABLE_PROJECTS="clang"`.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D56611



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


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-31 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D56611#1379785 , @nridge wrote:

> This commit is causing clangd to fail to link, with errors like this:
>
>   
> tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SwapIfBranches.cpp.o:SwapIfBranches.cpp:function
>  clang::RecursiveASTVisitor namespace)::FindIfUnderCursor>::TraverseParmVarDecl(clang::ParmVarDecl*): 
> error: undefined reference to 'clang::ParmVarDecl::hasDefaultArg() const'
>
>
> (and dozens more that are similar).


Hi Nathan,
What platform is this on? Not seeing it on the buildbots.
Anything unusual in build setup (standalone build, building with shared 
libraries, etc)?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D56611



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


[PATCH] D57345: Make clang/test/Index/pch-from-libclang.c pass in more places

2019-01-31 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.
Herald added a project: LLVM.

I think this broke the BUILD_SHARED_LIBS build: https://reviews.llvm.org/D57556


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57345



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


[PATCH] D57521: [CMake] External compiler-rt-configure requires LLVMTestingSupport when including tests

2019-01-31 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a reviewer: phosek.
beanz added a subscriber: phosek.
beanz added a comment.
Herald added a project: clang.

@phosek, does LLVM’s runtime directory do this correctly?

At some point we should try and deprecate and remove this option in favor of 
the LLVM directory because the LLVM approach is much more complete and robust.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57521



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


[PATCH] D50563: Fixed frontend clang tests in windows read-only container

2019-01-31 Thread Justice Adams via Phabricator via cfe-commits
justice_adams added a comment.

@stella.stamenova @thakis Thanks for the feedback all, I will go ahead and make 
this change to the way I'm representing directories, open a new diff for 
review, and add you as a reviewer.


Repository:
  rC Clang

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

https://reviews.llvm.org/D50563



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


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-31 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.
Herald added a project: LLVM.

This commit is causing clangd to fail to link, with errors like this:

  
tools/clang/tools/extra/clangd/refactor/tweaks/CMakeFiles/obj.clangDaemonTweaks.dir/SwapIfBranches.cpp.o:SwapIfBranches.cpp:function
 clang::RecursiveASTVisitor::TraverseParmVarDecl(clang::ParmVarDecl*): 
error: undefined reference to 'clang::ParmVarDecl::hasDefaultArg() const'

(and dozens more that are similar).


Repository:
  rL LLVM

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

https://reviews.llvm.org/D56611



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


Re: r350920 - [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed

2019-01-31 Thread Shoaib Meenai via cfe-commits
+Hans for managing the 8.0 branch.

On 1/31/19, 4:15 PM, "ahatan...@apple.com on behalf of Akira Hatanaka" 
 wrote:

Reverted patch in r352822. I’ll send a new patch later that disallows 
trivial_abi on classes without non-deleted copy or move constructors.

> On Jan 31, 2019, at 3:52 PM, Richard Smith  wrote:
> 
> Given that there's uncertainty as to how to proceed and this patch
> affects the ABI, I would prefer that we revert it for trunk and 8.0.
> 
> The suggested alternative of disallowing trivial_abi in the case where
> all copy/move constructors are deleted seems reasonable to me.
> 
> On Thu, 31 Jan 2019 at 14:31, Shoaib Meenai via cfe-commits
>  wrote:
>> 
>> Just wanted to point out that r350920 is on the 8.0 release branch as 
well. I don't know if there are any additional considerations there.
>> 
>> On 1/31/19, 2:20 PM, "cfe-commits on behalf of John McCall via 
cfe-commits"  wrote:
>> 
>> 
>> 
>>On 31 Jan 2019, at 16:57, Akira Hatanaka wrote:
>> 
>>> Would it be better if we disallowed trivial_abi if the class’ copy
>>> and move destructors were all deleted (and revert r350920)? I think
>>> that would make it easier to reason about when you are allowed to use
>>> trivial_abi and what effect the attribute has (which is to override
>>> the trivialness for the purpose of calls).
>>> 
>>> Sorry for my late reply. It took a while to understand that the patch
>>> I committed might not be the right way to fix the problem.
>> 
>>I'd be fine with that.  If nothing else, we can generalize it later if
>>we decide that's an important use-case.
>> 
>>John.
>> 
>>> 
 On Jan 16, 2019, at 8:37 PM, John McCall via cfe-commits
  wrote:
 
 On 16 Jan 2019, at 20:03, Richard Smith wrote:
 
> On Wed, 16 Jan 2019 at 16:20, John McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> 
>> On 16 Jan 2019, at 18:32, Richard Smith wrote:
>> 
>>> On Wed, 16 Jan 2019 at 09:10, John McCall via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>> 
 On 16 Jan 2019, at 9:13, Aaron Ballman wrote:
 
> On Wed, Jan 16, 2019 at 1:57 AM Akira Hatanaka
> 
> wrote:
>> 
>> Yes, the behavior of the compiler doesn’t match what’s
>> explained
>> in the documentation anymore.
>> 
>> Please take a look at the attached patch, which updates the
>> documentation.
> 
> Patch mostly LGTM, but I did have one wording suggestion.
> 
>> diff --git a/include/clang/Basic/AttrDocs.td
>> b/include/clang/Basic/AttrDocs.td
>> index 5773a92c9c..ca3cfcf9b2 100644
>> --- a/include/clang/Basic/AttrDocs.td
>> +++ b/include/clang/Basic/AttrDocs.td
>> @@ -2478,15 +2478,20 @@ def TrivialABIDocs : Documentation {
>>  let Category = DocCatVariable;
>>  let Content = [{
>> The ``trivial_abi`` attribute can be applied to a C++ class,
>> struct,
>> or union.
>> -It instructs the compiler to pass and return the type using
>> the C
>> ABI for the
>> +``trivial_abi`` has the following effects:
>> +
>> +- It instructs the compiler to pass and return the type using
>> the C
>> ABI for the
>> underlying type when the type would otherwise be considered
>> non-trivial for the
>> purpose of calls.
>> -A class annotated with `trivial_abi` can have non-trivial
>> destructors or copy/move constructors without automatically
>> becoming
>> non-trivial for the purposes of calls. For example:
>> +- It makes the destructor and copy and move constructors of
>> the
>> class trivial
>> +that would otherwise be considered non-trivial under the C++
>> ABI
>> rules.
> 
> How about: It makes the destructor, copy constructors, and move
> constructors of the class trivial even if they would otherwise
> be
> non-trivial under the C++ ABI rules.
 
 Let's not say that it makes them trivial, because it doesn't.  It
 causes
 their immediate non-triviality to be ignored for the purposes of
 deciding
 whether the type can be passed in registers.
 
>>> 
>>> Given the attribute now forces the type to be passed in registers,
>>> I
>> think
>>> it'd be more to the point to say that it makes the 

Re: r351629 - Emit !callback metadata and introduce the callback attribute

2019-01-31 Thread Doerfert, Johannes via cfe-commits
Thanks for the clarifications. I'll fix all mentioned points asap.


From: Eli Friedman 
Sent: Thursday, January 31, 2019 18:17
To: Doerfert, Johannes; Chandler Carruth; cfe-commits@lists.llvm.org
Cc: Raja Venkateswaran
Subject: RE: r351629 - Emit !callback metadata and introduce the callback 
attribute

(Comments inline.)

> -Original Message-
> From: cfe-commits  On Behalf Of
> Doerfert, Johannes Rudolf via cfe-commits
> Sent: Tuesday, January 22, 2019 9:29 AM
> To: Chandler Carruth 
> Cc: cfe-commits cfe 
> Subject: Re: r351629 - Emit !callback metadata and introduce the callback
> attribute
>
> > Another thing I notecide is that this code assumes the system has
> > `pthread.h` -- what about systems without it? I mean, you can disable the
> > test, but it seems bad to lose test coverage just because of that.
>
> So far, I disabled the test with a later addition which makes sure this
> test is only run under Linux. I'm unsure why we loose coverage because
> of that?

There isn't any way to safely disable the test without disabling it everywhere. 
 Specifically, the current version requires both that the host is Unix, and 
that the default target is the host.  Otherwise, the compiler might not be able 
to find and/or build pthread.h .

>
> > I would much prefer that you provide your own stub `pthread.h` in the
> > Inputs/... tree of the test suite and use that to test this in a portable
> > way.
>
> I do not completely follow but I'm open to improving the test. Basically
> I have to make sure the builtin recognition will trigger on the header
> file and the contained declaration. If we can somehow do this in a
> portable way I'm all for it. Is that how we test other builtin gnu extensions?

You don't need a header file; clang doesn't actually care where the builtin is 
declared.  You can just write "void pthread_create(void*,void*,void*(void*), 
void*);" or whatever directly in the C file.  It'll trigger a warning, but with 
your patch, there's no way to declare pthread_create without triggering a 
warning, so that hardly matters.

On a related note, code generation tests should use %clang_cc1.  Among other 
things, this avoids accidentally including headers from the host system.

-Eli

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


RE: r351629 - Emit !callback metadata and introduce the callback attribute

2019-01-31 Thread Eli Friedman via cfe-commits
(Comments inline.)

> -Original Message-
> From: cfe-commits  On Behalf Of
> Doerfert, Johannes Rudolf via cfe-commits
> Sent: Tuesday, January 22, 2019 9:29 AM
> To: Chandler Carruth 
> Cc: cfe-commits cfe 
> Subject: Re: r351629 - Emit !callback metadata and introduce the callback
> attribute
> 
> > Another thing I notecide is that this code assumes the system has
> > `pthread.h` -- what about systems without it? I mean, you can disable the
> > test, but it seems bad to lose test coverage just because of that.
> 
> So far, I disabled the test with a later addition which makes sure this
> test is only run under Linux. I'm unsure why we loose coverage because
> of that?

There isn't any way to safely disable the test without disabling it everywhere. 
 Specifically, the current version requires both that the host is Unix, and 
that the default target is the host.  Otherwise, the compiler might not be able 
to find and/or build pthread.h .

> 
> > I would much prefer that you provide your own stub `pthread.h` in the
> > Inputs/... tree of the test suite and use that to test this in a portable
> > way.
> 
> I do not completely follow but I'm open to improving the test. Basically
> I have to make sure the builtin recognition will trigger on the header
> file and the contained declaration. If we can somehow do this in a
> portable way I'm all for it. Is that how we test other builtin gnu extensions?

You don't need a header file; clang doesn't actually care where the builtin is 
declared.  You can just write "void pthread_create(void*,void*,void*(void*), 
void*);" or whatever directly in the C file.  It'll trigger a warning, but with 
your patch, there's no way to declare pthread_create without triggering a 
warning, so that hardly matters.

On a related note, code generation tests should use %clang_cc1.  Among other 
things, this avoids accidentally including headers from the host system.

-Eli 

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


Re: r350920 - [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed

2019-01-31 Thread Akira Hatanaka via cfe-commits
Reverted patch in r352822. I’ll send a new patch later that disallows 
trivial_abi on classes without non-deleted copy or move constructors.

> On Jan 31, 2019, at 3:52 PM, Richard Smith  wrote:
> 
> Given that there's uncertainty as to how to proceed and this patch
> affects the ABI, I would prefer that we revert it for trunk and 8.0.
> 
> The suggested alternative of disallowing trivial_abi in the case where
> all copy/move constructors are deleted seems reasonable to me.
> 
> On Thu, 31 Jan 2019 at 14:31, Shoaib Meenai via cfe-commits
>  wrote:
>> 
>> Just wanted to point out that r350920 is on the 8.0 release branch as well. 
>> I don't know if there are any additional considerations there.
>> 
>> On 1/31/19, 2:20 PM, "cfe-commits on behalf of John McCall via cfe-commits" 
>>  
>> wrote:
>> 
>> 
>> 
>>On 31 Jan 2019, at 16:57, Akira Hatanaka wrote:
>> 
>>> Would it be better if we disallowed trivial_abi if the class’ copy
>>> and move destructors were all deleted (and revert r350920)? I think
>>> that would make it easier to reason about when you are allowed to use
>>> trivial_abi and what effect the attribute has (which is to override
>>> the trivialness for the purpose of calls).
>>> 
>>> Sorry for my late reply. It took a while to understand that the patch
>>> I committed might not be the right way to fix the problem.
>> 
>>I'd be fine with that.  If nothing else, we can generalize it later if
>>we decide that's an important use-case.
>> 
>>John.
>> 
>>> 
 On Jan 16, 2019, at 8:37 PM, John McCall via cfe-commits
  wrote:
 
 On 16 Jan 2019, at 20:03, Richard Smith wrote:
 
> On Wed, 16 Jan 2019 at 16:20, John McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> 
>> On 16 Jan 2019, at 18:32, Richard Smith wrote:
>> 
>>> On Wed, 16 Jan 2019 at 09:10, John McCall via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>> 
 On 16 Jan 2019, at 9:13, Aaron Ballman wrote:
 
> On Wed, Jan 16, 2019 at 1:57 AM Akira Hatanaka
> 
> wrote:
>> 
>> Yes, the behavior of the compiler doesn’t match what’s
>> explained
>> in the documentation anymore.
>> 
>> Please take a look at the attached patch, which updates the
>> documentation.
> 
> Patch mostly LGTM, but I did have one wording suggestion.
> 
>> diff --git a/include/clang/Basic/AttrDocs.td
>> b/include/clang/Basic/AttrDocs.td
>> index 5773a92c9c..ca3cfcf9b2 100644
>> --- a/include/clang/Basic/AttrDocs.td
>> +++ b/include/clang/Basic/AttrDocs.td
>> @@ -2478,15 +2478,20 @@ def TrivialABIDocs : Documentation {
>>  let Category = DocCatVariable;
>>  let Content = [{
>> The ``trivial_abi`` attribute can be applied to a C++ class,
>> struct,
>> or union.
>> -It instructs the compiler to pass and return the type using
>> the C
>> ABI for the
>> +``trivial_abi`` has the following effects:
>> +
>> +- It instructs the compiler to pass and return the type using
>> the C
>> ABI for the
>> underlying type when the type would otherwise be considered
>> non-trivial for the
>> purpose of calls.
>> -A class annotated with `trivial_abi` can have non-trivial
>> destructors or copy/move constructors without automatically
>> becoming
>> non-trivial for the purposes of calls. For example:
>> +- It makes the destructor and copy and move constructors of
>> the
>> class trivial
>> +that would otherwise be considered non-trivial under the C++
>> ABI
>> rules.
> 
> How about: It makes the destructor, copy constructors, and move
> constructors of the class trivial even if they would otherwise
> be
> non-trivial under the C++ ABI rules.
 
 Let's not say that it makes them trivial, because it doesn't.  It
 causes
 their immediate non-triviality to be ignored for the purposes of
 deciding
 whether the type can be passed in registers.
 
>>> 
>>> Given the attribute now forces the type to be passed in registers,
>>> I
>> think
>>> it'd be more to the point to say that it makes the triviality of
>>> those
>>> special members be ignored when deciding whether to pass a type
>>> with a
>>> subobject of this type in registers.
>> 
>> Wait, it forces it to be passed in registers?  I thought the design
>> was that it didn't override the non-trivial-abi-ness of subobjects;
>> see all the discussion of trivially_relocatable.
>> 
> 
> The attribute is ill-formed if applied to a class that has a
> subobject that
> can't be passed in registers (or that has a vptr). And then as a
> weird

r352822 - Revert "[Sema] Make canPassInRegisters return true if the CXXRecordDecl passed"

2019-01-31 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Thu Jan 31 16:12:06 2019
New Revision: 352822

URL: http://llvm.org/viewvc/llvm-project?rev=352822=rev
Log:
Revert "[Sema] Make canPassInRegisters return true if the CXXRecordDecl passed"

This reverts commit r350920 as it is not clear whether we should force a
class to be returned in registers when copy and move constructors are
both deleted.

For more background, see the following discussion:
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190128/259907.html

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/trivial_abi.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=352822=352821=352822=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Thu Jan 31 16:12:06 2019
@@ -5889,9 +5889,6 @@ static bool canPassInRegisters(Sema ,
   if (D->isDependentType() || D->isInvalidDecl())
 return false;
 
-  if (D->hasAttr())
-return true;
-
   // Clang <= 4 used the pre-C++11 rule, which ignores move operations.
   // The PS4 platform ABI follows the behavior of Clang 3.2.
   if (CCK == TargetInfo::CCK_ClangABI4OrPS4)

Modified: cfe/trunk/test/CodeGenCXX/trivial_abi.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/trivial_abi.cpp?rev=352822=352821=352822=diff
==
--- cfe/trunk/test/CodeGenCXX/trivial_abi.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/trivial_abi.cpp Thu Jan 31 16:12:06 2019
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++17 -fcxx-exceptions 
-fexceptions -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++17 -fcxx-exceptions 
-fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions 
-fexceptions -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -std=c++11 -fcxx-exceptions 
-fexceptions -fclang-abi-compat=4.0 -emit-llvm -o - %s | FileCheck %s
 
 // CHECK: %[[STRUCT_SMALL:.*]] = type { i32* }
 // CHECK: %[[STRUCT_LARGE:.*]] = type { i32*, [128 x i32] }
@@ -43,13 +43,6 @@ struct HasNonTrivial {
   NonTrivial m;
 };
 
-struct __attribute__((trivial_abi)) CopyMoveDeleted {
-  CopyMoveDeleted(int);
-  CopyMoveDeleted(const CopyMoveDeleted &) = delete;
-  CopyMoveDeleted(CopyMoveDeleted &&) = delete;
-  int a;
-};
-
 // CHECK: define void @_Z14testParamSmall5Small(i64 %[[A_COERCE:.*]])
 // CHECK: %[[A:.*]] = alloca %[[STRUCT_SMALL]], align 8
 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_SMALL]], 
%[[STRUCT_SMALL]]* %[[A]], i32 0, i32 0
@@ -244,11 +237,3 @@ void calleeExceptionLarge(Large, Large);
 void testExceptionLarge() {
   calleeExceptionLarge(Large(), Large());
 }
-
-// A class with deleted copy and move constructors can still be passed or
-// returned in registers if the class is annotated with trivial_abi.
-
-// CHECK: define i64 @_Z19testCopyMoveDeletedi(i32 %
-CopyMoveDeleted testCopyMoveDeleted(int a) {
-  return a;
-}


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


[PATCH] D56900: [Fixed Point Arithmetic] Fixed Point and Integer Conversions

2019-01-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan marked an inline comment as done.
leonardchan added inline comments.



Comment at: clang/test/Frontend/fixed_point_conversions.c:437
+  // DEFAULT-NEXT: [[RES:%[a-z0-9]+]] = trunc i39 [[SATMIN]] to i16
+  // DEFAULT-NEXT: store i16 [[RES]], i16* %sat_sa, align 2
+

leonardchan wrote:
> ebevhan wrote:
> > leonardchan wrote:
> > > ebevhan wrote:
> > > > Conversions like this are a bit odd. There shouldn't be a need to 
> > > > upsize/upscale the container before the saturation, should there?
> > > I see. You're saying that we can just check directly if the value exceeds 
> > > 255 (or goes under -256) since the range of target values can always fit 
> > > in the range of source values. Therefore we do not need to cast up since 
> > > the only reason we would need to is if converting to a type with a 
> > > greater source range.
> > > 
> > > In this case, we could technically have a special case for integers where 
> > > I think we can perform the saturation checks without the initial sign 
> > > extension. I think it might be simpler though if in 
> > > `EmitFixedPointConversion`, we treat an integer as a 'zero-scale fixed 
> > > point number'. I think the reason the upsizing occurs in the first place 
> > > is so that we satisfy the first FX conversion rule of calculating the 
> > > result with full precision of both operands.
> > > I see. You're saying that we can just check directly if the value exceeds 
> > > 255 (or goes under -256) since the range of target values can always fit 
> > > in the range of source values. Therefore we do not need to cast up since 
> > > the only reason we would need to is if converting to a type with a 
> > > greater source range.
> > 
> > That's right. Though, for integer to fixed-point conversion, I don't think 
> > you ever need to upcast first; either the integer is larger than or equal 
> > to the integral part of the fixed-point type, in which case we can check 
> > the magnitude in the type as is, or it's smaller, and we don't have to do 
> > any saturation.
> > 
> > > I think it might be simpler though if in `EmitFixedPointConversion`, we 
> > > treat an integer as a 'zero-scale fixed point number'.
> > 
> > Isn't this already the case? The semantics for an integer type are fetched 
> > as a zero scale fixed-point type and used that way (except when the target 
> > is an integer due to the rounding requirement).
> > That's right. Though, for integer to fixed-point conversion, I don't think 
> > you ever need to upcast first; either the integer is larger than or equal 
> > to the integral part of the fixed-point type, in which case we can check 
> > the magnitude in the type as is, or it's smaller, and we don't have to do 
> > any saturation.
> 
> I see. I think this would be more of a matter then of when checking for 
> saturation, we either should check against the source value after resizing 
> and scaling (container), or the source by itself before resizing and scaling. 
> Actually, I think that when comparing saturation against the source value, we 
> could save an instruction since we can just generate a constant  to compare 
> the source against instead of comparing against a potentially shifted value. 
> I think this could work when converting from fixed point types as well.
> 
> With saturation conversion, (if the target scale >= src scale) currently we 
> could generate up to 7 instructions:
> - 1 resize + 1 shift on the result if target scale > src scale
> - 1 cmp gt + 1 select for clamping to max
> - 1 cmp lt + 1 select for clamping to min
> - 1 resize if container width != target width
> 
> I think we don't need either the first or last resize if the constants that 
> we check against are the respective max's/min's of the target type against 
> the source. I think this deserves a patch on it's own though since it could 
> change a bunch of tests that depend on `EmitFixedPointConversion`.
> 
> >Isn't this already the case? The semantics for an integer type are fetched 
> >as a zero scale fixed-point type and used that way (except when the target 
> >is an integer due to the rounding requirement).
> 
> What I meant by this was that we are already doing the right thing in that we 
> calculate the result with the full precision of both operands.
Added this change in D57553 and made it a child of this patch. 


Repository:
  rC Clang

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

https://reviews.llvm.org/D56900



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


[PATCH] D57553: [Fixed Point Arithmetic] Check against source value when converting during saturation

2019-01-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: rjmccall, ebevhan, bjope.
leonardchan added a project: clang.

When converting to a saturating fixed point type, compare against the source 
value instead of our container value. This allows us to not create a container, 
and save up to 2 instructions from extending/truncating to this container size.

These can be seen in conversions between fixed point types of the same width, 
but different scale or different sign.


Repository:
  rC Clang

https://reviews.llvm.org/D57553

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/Frontend/fixed_point_add.c
  clang/test/Frontend/fixed_point_conversions.c
  clang/test/Frontend/fixed_point_sub.c

Index: clang/test/Frontend/fixed_point_sub.c
===
--- clang/test/Frontend/fixed_point_sub.c
+++ clang/test/Frontend/fixed_point_sub.c
@@ -332,11 +332,11 @@
   // CHECK-NEXT: [[I_EXT:%[a-z0-9]+]] = sext i32 [[I]] to i39
   // CHECK-NEXT: [[I:%[a-z0-9]+]] = shl i39 [[I_EXT]], 7
   // CHECK-NEXT: [[SUM:%[0-9]+]] = call i39 @llvm.ssub.sat.i39(i39 [[SA_SAT_EXT]], i39 [[I]])
+  // CHECK-NEXT: [[RES:%[a-z0-9]+]] = trunc i39 [[SUM]] to i16
   // CHECK-NEXT: [[USE_MAX:%[0-9]+]] = icmp sgt i39 [[SUM]], 32767
-  // CHECK-NEXT: [[RES:%[a-z0-9]+]] = select i1 [[USE_MAX]], i39 32767, i39 [[SUM]]
-  // CHECK-NEXT: [[USE_MIN:%[0-9]+]] = icmp slt i39 [[RES]], -32768
-  // CHECK-NEXT: [[RES2:%[a-z0-9]+]] = select i1 [[USE_MIN]], i39 -32768, i39 [[RES]]
-  // CHECK-NEXT: [[RES3:%[a-z0-9]+]] = trunc i39 [[RES2]] to i16
+  // CHECK-NEXT: [[RES2:%[a-z0-9]+]] = select i1 [[USE_MAX]], i16 32767, i16 [[RES]]
+  // CHECK-NEXT: [[USE_MIN:%[0-9]+]] = icmp slt i39 [[SUM]], -32768
+  // CHECK-NEXT: [[RES3:%[a-z0-9]+]] = select i1 [[USE_MIN]], i16 -32768, i16 [[RES2]]
   // CHECK-NEXT: store i16 [[RES3]], i16* %sa_sat, align 2
   sa_sat = sa_sat - i;
 
@@ -346,11 +346,11 @@
   // CHECK-NEXT: [[I_EXT:%[a-z0-9]+]] = zext i32 [[I]] to i40
   // CHECK-NEXT: [[I:%[a-z0-9]+]] = shl i40 [[I_EXT]], 7
   // CHECK-NEXT: [[SUM:%[0-9]+]] = call i40 @llvm.ssub.sat.i40(i40 [[SA_SAT_EXT]], i40 [[I]])
+  // CHECK-NEXT: [[RES:%[a-z0-9]+]] = trunc i40 [[SUM]] to i16
   // CHECK-NEXT: [[USE_MAX:%[0-9]+]] = icmp sgt i40 [[SUM]], 32767
-  // CHECK-NEXT: [[RES:%[a-z0-9]+]] = select i1 [[USE_MAX]], i40 32767, i40 [[SUM]]
-  // CHECK-NEXT: [[USE_MIN:%[0-9]+]] = icmp slt i40 [[RES]], -32768
-  // CHECK-NEXT: [[RES2:%[a-z0-9]+]] = select i1 [[USE_MIN]], i40 -32768, i40 [[RES]]
-  // CHECK-NEXT: [[RES3:%[a-z0-9]+]] = trunc i40 [[RES2]] to i16
+  // CHECK-NEXT: [[RES2:%[a-z0-9]+]] = select i1 [[USE_MAX]], i16 32767, i16 [[RES]]
+  // CHECK-NEXT: [[USE_MIN:%[0-9]+]] = icmp slt i40 [[SUM]], -32768
+  // CHECK-NEXT: [[RES3:%[a-z0-9]+]] = select i1 [[USE_MIN]], i16 -32768, i16 [[RES2]]
   // CHECK-NEXT: store i16 [[RES3]], i16* %sa_sat, align 2
   sa_sat = sa_sat - ui;
 
@@ -371,20 +371,20 @@
   // SIGNED-NEXT: [[I_RESIZE:%[a-z0-9]+]] = sext i32 [[I]] to i40
   // SIGNED-NEXT: [[I_UPSCALE:%[a-z0-9]+]] = shl i40 [[I_RESIZE]], 8
   // SIGNED-NEXT: [[SUM:%[0-9]+]] = call i40 @llvm.usub.sat.i40(i40 [[USA_SAT_RESIZE]], i40 [[I_UPSCALE]])
+  // SIGNED-NEXT: [[RES:%[a-z0-9]+]] = trunc i40 [[SUM]] to i16
   // SIGNED-NEXT: [[USE_MAX:%[0-9]+]] = icmp sgt i40 [[SUM]], 65535
-  // SIGNED-NEXT: [[RESULT:%[a-z0-9]+]] = select i1 [[USE_MAX]], i40 65535, i40 [[SUM]]
-  // SIGNED-NEXT: [[USE_MIN:%[0-9]+]] = icmp slt i40 [[RESULT]], 0
-  // SIGNED-NEXT: [[RESULT2:%[a-z0-9]+]] = select i1 [[USE_MIN]], i40 0, i40 [[RESULT]]
-  // SIGNED-NEXT: [[RESULT:%[a-z0-9]+]] = trunc i40 [[RESULT2]] to i16
+  // SIGNED-NEXT: [[RES2:%[a-z0-9]+]] = select i1 [[USE_MAX]], i16 -1, i16 [[RES]]
+  // SIGNED-NEXT: [[USE_MIN:%[0-9]+]] = icmp slt i40 [[SUM]], 0
+  // SIGNED-NEXT: [[RESULT:%[a-z0-9]+]] = select i1 [[USE_MIN]], i16 0, i16 [[RES2]]
   // UNSIGNED-NEXT: [[USA_SAT_RESIZE:%[a-z0-9]+]] = zext i16 [[USA_SAT]] to i39
   // UNSIGNED-NEXT: [[I_RESIZE:%[a-z0-9]+]] = sext i32 [[I]] to i39
   // UNSIGNED-NEXT: [[I_UPSCALE:%[a-z0-9]+]] = shl i39 [[I_RESIZE]], 7
   // UNSIGNED-NEXT: [[SUM:%[0-9]+]] = call i39 @llvm.usub.sat.i39(i39 [[USA_SAT_RESIZE]], i39 [[I_UPSCALE]])
+  // UNSIGNED-NEXT: [[RES:%[a-z0-9]+]] = trunc i39 [[SUM]] to i16
   // UNSIGNED-NEXT: [[USE_MAX:%[0-9]+]] = icmp sgt i39 [[SUM]], 32767
-  // UNSIGNED-NEXT: [[RESULT:%[a-z0-9]+]] = select i1 [[USE_MAX]], i39 32767, i39 [[SUM]]
-  // UNSIGNED-NEXT: [[USE_MIN:%[0-9]+]] = icmp slt i39 [[RESULT]], 0
-  // UNSIGNED-NEXT: [[RESULT2:%[a-z0-9]+]] = select i1 [[USE_MIN]], i39 0, i39 [[RESULT]]
-  // UNSIGNED-NEXT: [[RESULT:%[a-z0-9]+]] = trunc i39 [[RESULT2]] to i16
+  // UNSIGNED-NEXT: [[RES2:%[a-z0-9]+]] = select i1 [[USE_MAX]], i16 32767, i16 [[RES]]
+  // UNSIGNED-NEXT: [[USE_MIN:%[0-9]+]] = icmp slt i39 [[SUM]], 0
+  // UNSIGNED-NEXT: [[RESULT:%[a-z0-9]+]] = select i1 [[USE_MIN]], i16 0, i16 [[RES2]]
   // CHECK-NEXT: store i16 [[RESULT]], i16* %usa_sat, align 2
   usa_sat = 

Re: r350920 - [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed

2019-01-31 Thread Richard Smith via cfe-commits
Given that there's uncertainty as to how to proceed and this patch
affects the ABI, I would prefer that we revert it for trunk and 8.0.

The suggested alternative of disallowing trivial_abi in the case where
all copy/move constructors are deleted seems reasonable to me.

On Thu, 31 Jan 2019 at 14:31, Shoaib Meenai via cfe-commits
 wrote:
>
> Just wanted to point out that r350920 is on the 8.0 release branch as well. I 
> don't know if there are any additional considerations there.
>
> On 1/31/19, 2:20 PM, "cfe-commits on behalf of John McCall via cfe-commits" 
>  
> wrote:
>
>
>
> On 31 Jan 2019, at 16:57, Akira Hatanaka wrote:
>
> > Would it be better if we disallowed trivial_abi if the class’ copy
> > and move destructors were all deleted (and revert r350920)? I think
> > that would make it easier to reason about when you are allowed to use
> > trivial_abi and what effect the attribute has (which is to override
> > the trivialness for the purpose of calls).
> >
> > Sorry for my late reply. It took a while to understand that the patch
> > I committed might not be the right way to fix the problem.
>
> I'd be fine with that.  If nothing else, we can generalize it later if
> we decide that's an important use-case.
>
> John.
>
> >
> >> On Jan 16, 2019, at 8:37 PM, John McCall via cfe-commits
> >>  wrote:
> >>
> >> On 16 Jan 2019, at 20:03, Richard Smith wrote:
> >>
> >>> On Wed, 16 Jan 2019 at 16:20, John McCall via cfe-commits <
> >>> cfe-commits@lists.llvm.org> wrote:
> >>>
>  On 16 Jan 2019, at 18:32, Richard Smith wrote:
> 
> > On Wed, 16 Jan 2019 at 09:10, John McCall via cfe-commits <
> > cfe-commits@lists.llvm.org> wrote:
> >
> >> On 16 Jan 2019, at 9:13, Aaron Ballman wrote:
> >>
> >>> On Wed, Jan 16, 2019 at 1:57 AM Akira Hatanaka
> >>> 
> >>> wrote:
> 
>  Yes, the behavior of the compiler doesn’t match what’s
>  explained
>  in the documentation anymore.
> 
>  Please take a look at the attached patch, which updates the
>  documentation.
> >>>
> >>> Patch mostly LGTM, but I did have one wording suggestion.
> >>>
>  diff --git a/include/clang/Basic/AttrDocs.td
>  b/include/clang/Basic/AttrDocs.td
>  index 5773a92c9c..ca3cfcf9b2 100644
>  --- a/include/clang/Basic/AttrDocs.td
>  +++ b/include/clang/Basic/AttrDocs.td
>  @@ -2478,15 +2478,20 @@ def TrivialABIDocs : Documentation {
>    let Category = DocCatVariable;
>    let Content = [{
>  The ``trivial_abi`` attribute can be applied to a C++ class,
>  struct,
>  or union.
>  -It instructs the compiler to pass and return the type using
>  the C
>  ABI for the
>  +``trivial_abi`` has the following effects:
>  +
>  +- It instructs the compiler to pass and return the type using
>  the C
>  ABI for the
>  underlying type when the type would otherwise be considered
>  non-trivial for the
>  purpose of calls.
>  -A class annotated with `trivial_abi` can have non-trivial
>  destructors or copy/move constructors without automatically
>  becoming
>  non-trivial for the purposes of calls. For example:
>  +- It makes the destructor and copy and move constructors of
>  the
>  class trivial
>  +that would otherwise be considered non-trivial under the C++
>  ABI
>  rules.
> >>>
> >>> How about: It makes the destructor, copy constructors, and move
> >>> constructors of the class trivial even if they would otherwise
> >>> be
> >>> non-trivial under the C++ ABI rules.
> >>
> >> Let's not say that it makes them trivial, because it doesn't.  It
> >> causes
> >> their immediate non-triviality to be ignored for the purposes of
> >> deciding
> >> whether the type can be passed in registers.
> >>
> >
> > Given the attribute now forces the type to be passed in registers,
> > I
>  think
> > it'd be more to the point to say that it makes the triviality of
> > those
> > special members be ignored when deciding whether to pass a type
> > with a
> > subobject of this type in registers.
> 
>  Wait, it forces it to be passed in registers?  I thought the design
>  was that it didn't override the non-trivial-abi-ness of subobjects;
>  see all the discussion of trivially_relocatable.
> 
> >>>
> >>> The attribute is ill-formed if 

[PATCH] D57219: [Fixed Point Arithmetic] Fixed Point Comparisons

2019-01-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3444
   case BO_NE:
+return Builder.CreateICmpNE(FullLHS, FullRHS);
+  case BO_Mul:

leonardchan wrote:
> rjmccall wrote:
> > Are padding bits guaranteed zero or unspecified?  Or are we just not really 
> > supporting padding bits all the way to IRGen at this time?
> I believe the consensus was leaving them unspecified, so operations that can 
> cause overflow into them would result in undefined behavior.
If I'm understanding you correctly, you're saying that (1) we are assuming that 
inputs are zero-padded and (2) we are taking advantage of the 
non-saturating-overflow-is-UB rule to avoid clearing the padding bits after 
arithmetic.  That's actually what I meant by "guaranteed zero", so we have our 
labels reversed, but at least we understand each other now.

(I suppose you're thinking of this as "unspecified" because non-saturating 
arithmetic can leave an unspecified value there.  I think of this as a 
"guarantee" because it's basically a representational invariant: it's a 
precondition for correctness that the bit is zero, and all operations guarantee 
that the bit will be zero in their well-defined cases (but overflow is not 
well-defined).  Just a difference in perspective, I guess.)

Is this written down somewhere?  Are there targets that use the opposite ABI 
rule that we might need to support someday?

At any rate, I think it's worth adding a short comment here explaining why it's 
okay to do a normal comparison despite the possibility of padding bits.  Along 
those lines, is there any value in communicating to the backend that 
padded-unsigned comparisons could reasonably be done with either a signed or 
unsigned comparison?  Are there interesting targets where one or the other is 
cheaper?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57219



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


r352818 - [sanitizer-coverage] prune trace-cmp instrumentation for CMP isntructions that feed into the backedge branch. Instrumenting these CMP instructions is almost always useless (and harmful) for

2019-01-31 Thread Kostya Serebryany via cfe-commits
Author: kcc
Date: Thu Jan 31 15:43:00 2019
New Revision: 352818

URL: http://llvm.org/viewvc/llvm-project?rev=352818=rev
Log:
[sanitizer-coverage] prune trace-cmp instrumentation for CMP isntructions that 
feed into the backedge branch. Instrumenting these CMP instructions is almost 
always useless (and harmful) for fuzzing

Modified:
cfe/trunk/docs/SanitizerCoverage.rst

Modified: cfe/trunk/docs/SanitizerCoverage.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/SanitizerCoverage.rst?rev=352818=352817=352818=diff
==
--- cfe/trunk/docs/SanitizerCoverage.rst (original)
+++ cfe/trunk/docs/SanitizerCoverage.rst Thu Jan 31 15:43:00 2019
@@ -248,6 +248,9 @@ and with  ``-fsanitize-coverage=trace-ge
 the `LLVM GEP instructions `_
 (to capture array indices).
 
+Unless ``no-prune`` option is provided, some of the comparison instructions
+will not be instrumented.
+
 .. code-block:: c++
 
   // Called before a comparison instruction.


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


Re: r352690 - [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls

2019-01-31 Thread Julian Lettner via cfe-commits
Thank you, Eric, for the reproducer and instructions. Actionable and much appreciated.Can you test my updated patch on your build before I try again?


updated_patch.patch
Description: Binary data



delta.diff
Description: Binary data
On Jan 31, 2019, at 6:19 AM, Eric Liu  wrote:And the stack trace is:```1.       parser at end of file                                                                                                                                                                       [31/1788]2.      Code generation                                                                                                                                                                                            3.      Running pass 'Function Pass Manager' on module 'absl/base/internal/throw_delegate.cc'.                                                                                                                     4.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@_ZN4absl13base_internal18ThrowStdLogicErrorERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'                                         #0 0x55c42e7bce9d SignalHandler(int) (bin/clang+0x1aabe9d)                                               #1 0x7f41b11309a0 __restore_rt (/usr/grte/v4/lib64/libpthread.so.0+0xf9a0)                                                                                                                                     #2 0x55c42fe10b5b findUnwindDestinations(llvm::FunctionLoweringInfo&, llvm::BasicBlock const*, llvm::BranchProbability, llvm::SmallVectorImpl> >&) (bin/clang+0x30ffb5b) #3 0x55c42fe0b49a llvm::SelectionDAGBuilder::visitInvoke(llvm::InvokeInst const&) (bin/clang+0x30fa49a) #4 0x55c4308a8a2f llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (bin/clang+0x3b97a2f) #5 0x55c430878aa5 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator, false, true>, llvm::ilist_iterator::node_options, false, true>, bool&) (bin/clang+0x3b67aa5) #6 0x55c4308768ed llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (bin/clang+0x3b658ed) #7 0x55c43087354a llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (bin/clang+0x3b6254a) #8 0x55c43086d1da (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) (bin/clang+0x3b5c1da) #9 0x55c4309eb833 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (bin/clang+0x3cda833)#10 0x55c43070edbe llvm::FPPassManager::runOnFunction(llvm::Function&) (bin/clang+0x39fddbe)#11 0x55c430711521 llvm::FPPassManager::runOnModule(llvm::Module&) (bin/clang+0x3a00521)#12 0x55c42e4a6f7f llvm::legacy::PassManagerImpl::run(llvm::Module&) (bin/clang+0x1795f7f)#13 0x55c42e7d9594 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, clang::BackendAction, std::__g::unique_ptr >) (bin/clang+0x1ac8594)#14 0x55c42e7a4d8c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (bin/clang+0x1a93d8c)#15 0x55c42e6499b6 clang::ParseAST(clang::Sema&, bool, bool) (bin/clang+0x19389b6)#16 0x55c42e7a8b37 clang::FrontendAction::Execute() (bin/clang+0x1a97b37)#17 0x55c42e7ae75f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (bin/clang+0x1a9d75f)#18 0x55c42e796cfb clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (bin/clang+0x1a85cfb)#19 0x55c42e791071 cc1_main(llvm::ArrayRef, char const*, void*) (bin/clang+0x1a80071)#20 0x55c42e5c019e main (bin/clang+0x18af19e)#21 0x7f41b0e9ebbd __libc_start_main (/usr/grte/v4/lib64/libc.so.6+0x38bbd)#22 0x55c42e6d44a9 _start (bin/clang+0x19c34a9)clang: error: unable to execute command: Segmentation faultclang: error: clang frontend command failed due to signal (use -v to see invocation)```On Thu, Jan 31, 2019 at 3:11 PM Eric Liu  wrote:I managed to get a reproducer (attached) from absl:```clang++ -std=c++17  -fsanitize=address,unreachable throw_delegate.pic.ii```You could regenerate the preprocessed code:```git clone https://github.com/abseil/abseil-cpp.gitcd abseil-cpp/abslbazel build --compilation_mode=fastbuild --save_temps --compile_one_dependency base/internal/throw_delegate.cc```I'll revert the commit to unblock our integration process. Let us know if you need more information.- EricOn Thu, Jan 31, 2019 at 9:01 AM Eric Christopher  wrote:Looks like this broke optimized asan builds via an assert in SCCP. I'll see what I can do about a testcase (or Eric will), however, would you mind reverting in the meantime?Thanks!-ericOn Wed, Jan 30, 2019 at 4:41 PM Julian Lettner via cfe-commits  wrote:Author: yln
Date: Wed Jan 30 15:42:13 2019
New Revision: 352690

URL: http://llvm.org/viewvc/llvm-project?rev=352690=rev
Log:

r352809 - Re-disable pch-from-libclang.c after 352803, some buildbots are still unhappy

2019-01-31 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Jan 31 14:57:52 2019
New Revision: 352809

URL: http://llvm.org/viewvc/llvm-project?rev=352809=rev
Log:
Re-disable pch-from-libclang.c after 352803, some buildbots are still unhappy

Modified:
cfe/trunk/test/Index/pch-from-libclang.c

Modified: cfe/trunk/test/Index/pch-from-libclang.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/pch-from-libclang.c?rev=352809=352808=352809=diff
==
--- cfe/trunk/test/Index/pch-from-libclang.c (original)
+++ cfe/trunk/test/Index/pch-from-libclang.c Thu Jan 31 14:57:52 2019
@@ -13,6 +13,9 @@
 // RUN: %clang -x c-header %s -o %t.clang.h.pch -fmodules 
-fmodules-cache-path=%t.mcp -Xclang -detailed-preprocessing-record -Xclang 
-triple -Xclang x86_64-apple-darwin -Xclang -fallow-pch-with-compiler-errors 
-Xclang -verify
 // RUN: c-index-test -test-load-source local %s -include %t.clang.h -fmodules 
-fmodules-cache-path=%t.mcp -Xclang -triple -Xclang x86_64-apple-darwin | 
FileCheck %s
 
+// FIXME: Still fails on at least some linux boxen.
+// REQUIRES: system-darwin
+
 #ifndef HEADER
 #define HEADER
 


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


[PATCH] D57472: [AST] Extract ASTDumpTraverser class from ASTDumper

2019-01-31 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 184616.
steveire added a comment.

Update


Repository:
  rC Clang

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

https://reviews.llvm.org/D57472

Files:
  include/clang/AST/ASTDumpTraverser.h
  lib/AST/ASTDumper.cpp

Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -12,20 +12,9 @@
 //===--===//
 
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/ASTDumperUtils.h"
-#include "clang/AST/Attr.h"
-#include "clang/AST/AttrVisitor.h"
-#include "clang/AST/CommentVisitor.h"
-#include "clang/AST/DeclCXX.h"
+#include "clang/AST/ASTDumpTraverser.h"
 #include "clang/AST/DeclLookups.h"
-#include "clang/AST/DeclObjC.h"
-#include "clang/AST/DeclOpenMP.h"
-#include "clang/AST/DeclVisitor.h"
-#include "clang/AST/LocInfoType.h"
-#include "clang/AST/StmtVisitor.h"
-#include "clang/AST/TemplateArgumentVisitor.h"
 #include "clang/AST/TextNodeDumper.h"
-#include "clang/AST/TypeVisitor.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/Module.h"
 #include "clang/Basic/SourceManager.h"
@@ -39,557 +28,44 @@
 
 namespace  {
 
-  class ASTDumper
-  : public ConstDeclVisitor,
-public ConstStmtVisitor,
-public ConstCommentVisitor,
-public TypeVisitor,
-public ConstAttrVisitor,
-public ConstTemplateArgumentVisitor {
+class ASTDumper : public ASTDumpTraverser {
 
-TextNodeDumper NodeDumper;
+  TextNodeDumper NodeDumper;
 
-raw_ostream 
+  raw_ostream 
 
-/// Indicates whether we should trigger deserialization of nodes that had
-/// not already been loaded.
-bool Deserialize = false;
+  const bool ShowColors;
 
-const bool ShowColors;
+public:
+  ASTDumper(raw_ostream , const CommandTraits *Traits,
+const SourceManager *SM)
+  : ASTDumper(OS, Traits, SM, SM && SM->getDiagnostics().getShowColors()) {}
 
-  public:
-ASTDumper(raw_ostream , const CommandTraits *Traits,
-  const SourceManager *SM)
-: ASTDumper(OS, Traits, SM,
-SM && SM->getDiagnostics().getShowColors()) {}
+  ASTDumper(raw_ostream , const CommandTraits *Traits,
+const SourceManager *SM, bool ShowColors)
+  : ASTDumper(OS, Traits, SM, ShowColors, LangOptions()) {}
+  ASTDumper(raw_ostream , const CommandTraits *Traits,
+const SourceManager *SM, bool ShowColors,
+const PrintingPolicy )
+  : NodeDumper(OS, ShowColors, SM, PrintPolicy, Traits), OS(OS),
+ShowColors(ShowColors) {}
 
-ASTDumper(raw_ostream , const CommandTraits *Traits,
-  const SourceManager *SM, bool ShowColors)
-: ASTDumper(OS, Traits, SM, ShowColors, LangOptions()) {}
-ASTDumper(raw_ostream , const CommandTraits *Traits,
-  const SourceManager *SM, bool ShowColors,
-  const PrintingPolicy )
-: NodeDumper(OS, ShowColors, SM, PrintPolicy, Traits), OS(OS),
-  ShowColors(ShowColors) {}
+  TextNodeDumper () { return NodeDumper; }
 
-void setDeserialize(bool D) { Deserialize = D; }
+  void dumpLookups(const DeclContext *DC, bool DumpDecls);
 
-void Visit(const Decl *D) {
-  NodeDumper.AddChild([=] {
-NodeDumper.Visit(D);
-if (!D)
-  return;
-
-ConstDeclVisitor::Visit(D);
-
-for (const auto  : D->attrs())
-  Visit(A);
-
-if (const FullComment *Comment =
-D->getASTContext().getLocalCommentForDeclUncached(D))
-  Visit(Comment, Comment);
-
-// Decls within functions are visited by the body.
-if (!isa(*D) && !isa(*D)) {
-  if (const auto *DC = dyn_cast(D))
-dumpDeclContext(DC);
-}
-  });
-}
-
-void Visit(const Stmt *S, StringRef Label = {}) {
-  NodeDumper.AddChild(Label, [=] {
-NodeDumper.Visit(S);
-
-if (!S) {
-  return;
-}
-
-ConstStmtVisitor::Visit(S);
-
-// Some statements have custom mechanisms for dumping their children.
-if (isa(S) || isa(S)) {
-  return;
-}
-
-for (const Stmt *SubStmt : S->children())
-  Visit(SubStmt);
-  });
-}
-
-void Visit(QualType T) {
-  SplitQualType SQT = T.split();
-  if (!SQT.Quals.hasQualifiers())
-return Visit(SQT.Ty);
-
-  NodeDumper.AddChild([=] {
-NodeDumper.Visit(T);
-Visit(T.split().Ty);
-  });
-}
-
-void Visit(const Type *T) {
-  NodeDumper.AddChild([=] {
-NodeDumper.Visit(T);
-if (!T)
-  return;
-TypeVisitor::Visit(T);
-
-QualType SingleStepDesugar =
-T->getLocallyUnqualifiedSingleStepDesugaredType();
-if (SingleStepDesugar != QualType(T, 0))
-  Visit(SingleStepDesugar);
-  });
-}
-
-void Visit(const Attr *A) {
-

[PATCH] D57472: [AST] Extract ASTDumpTraverser class from ASTDumper

2019-01-31 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked an inline comment as done.
steveire added inline comments.



Comment at: include/clang/AST/ASTDumpTraverser.h:83
+
+  NodeVisitorType () { return getDerived().doGetNodeVisitor(); }
+  Derived () { return *static_cast(this); }

aaron.ballman wrote:
> Given that `ASTDumpTraverser` is itself a visitor of nodes, I wonder if a 
> better name for this would be `getNodeDumper()` or something (and similarly 
> renaming the template parameter)?
I'm not opposed to alternative names, but I do like the current name. We 
`visit` each node before traversing.

`NodeVisitor` names make sense to me because 'dumping' isn't necessarily what 
the delegate class does. It is more consistent with what 'Visitor' usually 
means.

Perhaps a type name of `NodeDelegateType` and an accessor `NodeDelegateType 
()` would also make sense. Then we would have eg:

```
  void Visit(const Attr *A) {
getNodeDelegate().AddChild([=] {
  getNodeDelegate().Visit(A);
  ConstAttrVisitor::Visit(A);
});
  }
```



Repository:
  rC Clang

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

https://reviews.llvm.org/D57472



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


[PATCH] D57219: [Fixed Point Arithmetic] Fixed Point Comparisons

2019-01-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3444
   case BO_NE:
+return Builder.CreateICmpNE(FullLHS, FullRHS);
+  case BO_Mul:

rjmccall wrote:
> Are padding bits guaranteed zero or unspecified?  Or are we just not really 
> supporting padding bits all the way to IRGen at this time?
I believe the consensus was leaving them unspecified, so operations that can 
cause overflow into them would result in undefined behavior.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57219



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


[PATCH] D57219: [Fixed Point Arithmetic] Fixed Point Comparisons

2019-01-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 184612.
leonardchan marked 3 inline comments as done.

Repository:
  rC Clang

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

https://reviews.llvm.org/D57219

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/Frontend/fixed_point_comparisons.c

Index: clang/test/Frontend/fixed_point_comparisons.c
===
--- /dev/null
+++ clang/test/Frontend/fixed_point_comparisons.c
@@ -0,0 +1,378 @@
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNPADDED
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -fpadding-on-unsigned-fixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,PADDED
+
+// Fixed point against other fixed point
+_Bool b_eq_true = 2.5hk == 2.5uhk;  // CHECK-DAG: @b_eq_true  = {{.*}}global i8 1, align 1
+_Bool b_eq_false = 2.5hk == 2.4uhk; // CHECK-DAG: @b_eq_false = {{.*}}global i8 0, align 1
+
+_Bool b_ne_true = 2.5hk != 2.4uhk;  // CHECK-DAG: @b_ne_true  = {{.*}}global i8 1, align 1
+_Bool b_ne_false = 2.5hk != 2.5uhk; // CHECK-DAG: @b_ne_false = {{.*}}global i8 0, align 1
+
+_Bool b_lt_true = 2.5hk < 2.75uhk; // CHECK-DAG: @b_lt_true  = {{.*}}global i8 1, align 1
+_Bool b_lt_false = 2.5hk < 2.5uhk; // CHECK-DAG: @b_lt_false = {{.*}}global i8 0, align 1
+
+_Bool b_le_true = 2.5hk <= 2.75uhk; // CHECK-DAG: @b_le_true  = {{.*}}global i8 1, align 1
+_Bool b_le_true2 = 2.5hk <= 2.5uhk; // CHECK-DAG: @b_le_true2 = {{.*}}global i8 1, align 1
+_Bool b_le_false = 2.5hk <= 2.4uhk; // CHECK-DAG: @b_le_false = {{.*}}global i8 0, align 1
+
+_Bool b_gt_true = 2.75hk > 2.5uhk;   // CHECK-DAG: @b_gt_true  = {{.*}}global i8 1, align 1
+_Bool b_gt_false = 2.75hk > 2.75uhk; // CHECK-DAG: @b_gt_false = {{.*}}global i8 0, align 1
+
+_Bool b_ge_true = 2.75hk >= 2.5uhk;   // CHECK-DAG: @b_ge_true  = {{.*}}global i8 1, align 1
+_Bool b_ge_true2 = 2.75hk >= 2.75uhk; // CHECK-DAG: @b_ge_true2 = {{.*}}global i8 1, align 1
+_Bool b_ge_false = 2.5hk >= 2.75uhk;  // CHECK-DAG: @b_ge_false = {{.*}}global i8 0, align 1
+
+// Fixed point against int
+_Bool b_ieq_true = 2.0hk == 2;  // CHECK-DAG: @b_ieq_true  = {{.*}}global i8 1, align 1
+_Bool b_ieq_false = 2.0hk == 3; // CHECK-DAG: @b_ieq_false = {{.*}}global i8 0, align 1
+
+_Bool b_ine_true = 2.0hk != 3;  // CHECK-DAG: @b_ine_true  = {{.*}}global i8 1, align 1
+_Bool b_ine_false = 2.0hk != 2; // CHECK-DAG: @b_ine_false = {{.*}}global i8 0, align 1
+
+_Bool b_ilt_true = 2.0hk < 3;  // CHECK-DAG: @b_ilt_true  = {{.*}}global i8 1, align 1
+_Bool b_ilt_false = 2.0hk < 2; // CHECK-DAG: @b_ilt_false = {{.*}}global i8 0, align 1
+
+_Bool b_ile_true = 2.0hk <= 3;  // CHECK-DAG: @b_ile_true  = {{.*}}global i8 1, align 1
+_Bool b_ile_true2 = 2.0hk <= 2; // CHECK-DAG: @b_ile_true2 = {{.*}}global i8 1, align 1
+_Bool b_ile_false = 2.0hk <= 1; // CHECK-DAG: @b_ile_false = {{.*}}global i8 0, align 1
+
+_Bool b_igt_true = 2.0hk > 1;  // CHECK-DAG: @b_igt_true  = {{.*}}global i8 1, align 1
+_Bool b_igt_false = 2.0hk > 2; // CHECK-DAG: @b_igt_false = {{.*}}global i8 0, align 1
+
+_Bool b_ige_true = 2.0hk >= 1;  // CHECK-DAG: @b_ige_true  = {{.*}}global i8 1, align 1
+_Bool b_ige_true2 = 2.0hk >= 2; // CHECK-DAG: @b_ige_true2 = {{.*}}global i8 1, align 1
+_Bool b_ige_false = 2.0hk >= 3; // CHECK-DAG: @b_ige_false = {{.*}}global i8 0, align 1
+
+// Different signage
+// Since we can have different precisions, non powers of 2 fractions may have
+// different actual values when being compared.
+_Bool b_sne_true = 2.6hk != 2.6uhk;
+// UNPADDED-DAG:   @b_sne_true = {{.*}}global i8 1, align 1
+// PADDED-DAG: @b_sne_true = {{.*}}global i8 0, align 1
+
+_Bool b_seq_true = 2.0hk == 2u;  // CHECK-DAG: @b_seq_true  = {{.*}}global i8 1, align 1
+_Bool b_seq_true2 = 2.0uhk == 2; // CHECK-DAG: @b_seq_true2 = {{.*}}global i8 1, align 1
+
+void TestComparisons() {
+  short _Accum sa;
+  _Accum a;
+  unsigned short _Accum usa;
+  unsigned _Accum ua;
+
+  // Each of these should be a fixed point conversion followed by the actual
+  // comparison operation.
+  sa == a;
+  // CHECK:  [[A:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[A2:%[0-9]+]] = load i32, i32* %a, align 4
+  // CHECK-NEXT: [[RESIZE_A:%[a-z0-9]+]] = sext i16 [[A]] to i32
+  // CHECK-NEXT: [[UPSCALE_A:%[a-z0-9]+]] = shl i32 [[RESIZE_A]], 8
+  // CHECK-NEXT: {{.*}} = icmp eq i32 [[UPSCALE_A]], [[A2]]
+
+  sa != a;
+  // CHECK:  [[A:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[A2:%[0-9]+]] = load i32, i32* %a, align 4
+  // CHECK-NEXT: [[RESIZE_A:%[a-z0-9]+]] = sext i16 [[A]] to i32
+  // CHECK-NEXT: [[UPSCALE_A:%[a-z0-9]+]] = shl i32 [[RESIZE_A]], 8
+  // CHECK-NEXT: {{.*}} = icmp ne i32 [[UPSCALE_A]], [[A2]]
+
+  sa > a;
+  // CHECK:  [[A:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[A2:%[0-9]+]] = load i32, i32* %a, align 4
+ 

Re: r350920 - [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed

2019-01-31 Thread Shoaib Meenai via cfe-commits
Just wanted to point out that r350920 is on the 8.0 release branch as well. I 
don't know if there are any additional considerations there.

On 1/31/19, 2:20 PM, "cfe-commits on behalf of John McCall via cfe-commits" 
 
wrote:



On 31 Jan 2019, at 16:57, Akira Hatanaka wrote:

> Would it be better if we disallowed trivial_abi if the class’ copy 
> and move destructors were all deleted (and revert r350920)? I think 
> that would make it easier to reason about when you are allowed to use 
> trivial_abi and what effect the attribute has (which is to override 
> the trivialness for the purpose of calls).
>
> Sorry for my late reply. It took a while to understand that the patch 
> I committed might not be the right way to fix the problem.

I'd be fine with that.  If nothing else, we can generalize it later if 
we decide that's an important use-case.

John.

>
>> On Jan 16, 2019, at 8:37 PM, John McCall via cfe-commits 
>>  wrote:
>>
>> On 16 Jan 2019, at 20:03, Richard Smith wrote:
>>
>>> On Wed, 16 Jan 2019 at 16:20, John McCall via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 On 16 Jan 2019, at 18:32, Richard Smith wrote:

> On Wed, 16 Jan 2019 at 09:10, John McCall via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On 16 Jan 2019, at 9:13, Aaron Ballman wrote:
>>
>>> On Wed, Jan 16, 2019 at 1:57 AM Akira Hatanaka 
>>> 
>>> wrote:

 Yes, the behavior of the compiler doesn’t match what’s 
 explained
 in the documentation anymore.

 Please take a look at the attached patch, which updates the
 documentation.
>>>
>>> Patch mostly LGTM, but I did have one wording suggestion.
>>>
 diff --git a/include/clang/Basic/AttrDocs.td
 b/include/clang/Basic/AttrDocs.td
 index 5773a92c9c..ca3cfcf9b2 100644
 --- a/include/clang/Basic/AttrDocs.td
 +++ b/include/clang/Basic/AttrDocs.td
 @@ -2478,15 +2478,20 @@ def TrivialABIDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{
 The ``trivial_abi`` attribute can be applied to a C++ class, 
 struct,
 or union.
 -It instructs the compiler to pass and return the type using 
 the C
 ABI for the
 +``trivial_abi`` has the following effects:
 +
 +- It instructs the compiler to pass and return the type using 
 the C
 ABI for the
 underlying type when the type would otherwise be considered
 non-trivial for the
 purpose of calls.
 -A class annotated with `trivial_abi` can have non-trivial
 destructors or copy/move constructors without automatically 
 becoming
 non-trivial for the purposes of calls. For example:
 +- It makes the destructor and copy and move constructors of 
 the
 class trivial
 +that would otherwise be considered non-trivial under the C++ 
 ABI
 rules.
>>>
>>> How about: It makes the destructor, copy constructors, and move
>>> constructors of the class trivial even if they would otherwise 
>>> be
>>> non-trivial under the C++ ABI rules.
>>
>> Let's not say that it makes them trivial, because it doesn't.  It 
>> causes
>> their immediate non-triviality to be ignored for the purposes of
>> deciding
>> whether the type can be passed in registers.
>>
>
> Given the attribute now forces the type to be passed in registers, 
> I
 think
> it'd be more to the point to say that it makes the triviality of 
> those
> special members be ignored when deciding whether to pass a type 
> with a
> subobject of this type in registers.

 Wait, it forces it to be passed in registers?  I thought the design
 was that it didn't override the non-trivial-abi-ness of subobjects;
 see all the discussion of trivially_relocatable.

>>>
>>> The attribute is ill-formed if applied to a class that has a 
>>> subobject that
>>> can't be passed in registers (or that has a vptr). And then as a 
>>> weird
>>> special case we don't instantiate the attribute when instantiating a 
>>> class
>>> if it would be ill-formed (well, we instantiate it and then remove 
>>> it
>>> again, but the effect is the same).
>>>
>>> The commit at the start of this email chain switches us from the 
>>> "just
>>> override the trivialness for the purposes of the 

[PATCH] D57502: [ASTDump] Make template specialization tests more exact

2019-01-31 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352804: [ASTDump] Make template specialization tests more 
exact (authored by steveire, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57502

Files:
  cfe/trunk/test/AST/ast-dump-decl.cpp

Index: cfe/trunk/test/AST/ast-dump-decl.cpp
===
--- cfe/trunk/test/AST/ast-dump-decl.cpp
+++ cfe/trunk/test/AST/ast-dump-decl.cpp
@@ -207,26 +207,28 @@
   // explicit instantiation definition
   template void TestFunctionTemplate(D);
 }
-// CHECK:  FunctionTemplateDecl{{.*}} TestFunctionTemplate
-// CHECK-NEXT:   TemplateTypeParmDecl
-// CHECK-NEXT:   FunctionDecl{{.*}} TestFunctionTemplate 'void (T)'
-// CHECK-NEXT: ParmVarDecl{{.*}} 'T'
-// CHECK-NEXT: CompoundStmt
-// CHECK-NEXT:   FunctionDecl{{.*}} TestFunctionTemplate {{.*}}A
-// CHECK-NEXT: TemplateArgument
-// CHECK-NEXT: ParmVarDecl
-// CHECK-NEXT: CompoundStmt
-// CHECK-NEXT:   Function{{.*}} 'TestFunctionTemplate' {{.*}}B
-// CHECK-NEXT:   FunctionDecl{{.*}} TestFunctionTemplate {{.*}}C
-// CHECK-NEXT: TemplateArgument
-// CHECK-NEXT: ParmVarDecl
-// CHECK-NEXT:   FunctionDecl{{.*}} TestFunctionTemplate {{.*}}D
-// CHECK-NEXT: TemplateArgument
-// CHECK-NEXT: ParmVarDecl
-// CHECK-NEXT: CompoundStmt
-// CHECK:  FunctionDecl{{.*}} TestFunctionTemplate {{.*}}B
-// CHECK-NEXT:   TemplateArgument
-// CHECK-NEXT:   ParmVarDecl
+  // CHECK:   FunctionTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-14]]:3, col:55> col:29 TestFunctionTemplate
+  // CHECK-NEXT:  |-TemplateTypeParmDecl 0x{{.+}}  col:21 referenced typename depth 0 index 0 T
+  // CHECK-NEXT:  |-FunctionDecl 0x{{.+}}  col:29 TestFunctionTemplate 'void (T)'
+  // CHECK-NEXT:  | |-ParmVarDecl 0x{{.+}}  col:51 'T'
+  // CHECK-NEXT:  | `-CompoundStmt 0x{{.+}} 
+  // CHECK-NEXT:  |-FunctionDecl 0x{{.+}}  col:29 used TestFunctionTemplate 'void (testFunctionTemplateDecl::A)'
+  // CHECK-NEXT:  | |-TemplateArgument type 'testFunctionTemplateDecl::A'
+  // CHECK-NEXT:  | |-ParmVarDecl 0x{{.+}}  col:51 'testFunctionTemplateDecl::A':'testFunctionTemplateDecl::A'
+  // CHECK-NEXT:  | `-CompoundStmt 0x{{.+}} 
+  // CHECK-NEXT:  |-Function 0x{{.+}} 'TestFunctionTemplate' 'void (testFunctionTemplateDecl::B)'
+  // CHECK-NEXT:  |-FunctionDecl 0x{{.+}}  col:29 TestFunctionTemplate 'void (testFunctionTemplateDecl::C)'
+  // CHECK-NEXT:  | |-TemplateArgument type 'testFunctionTemplateDecl::C'
+  // CHECK-NEXT:  | `-ParmVarDecl 0x{{.+}}  col:51 'testFunctionTemplateDecl::C':'testFunctionTemplateDecl::C'
+  // CHECK-NEXT:  `-FunctionDecl 0x{{.+}}  col:29 TestFunctionTemplate 'void (testFunctionTemplateDecl::D)'
+  // CHECK-NEXT:|-TemplateArgument type 'testFunctionTemplateDecl::D'
+  // CHECK-NEXT:|-ParmVarDecl 0x{{.+}}  col:51 'testFunctionTemplateDecl::D':'testFunctionTemplateDecl::D'
+  // CHECK-NEXT:`-CompoundStmt 0x{{.+}} 
+
+  // CHECK:   FunctionDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-26]]:3, col:41> col:19 TestFunctionTemplate 'void (testFunctionTemplateDecl::B)'
+  // CHECK-NEXT:  |-TemplateArgument type 'testFunctionTemplateDecl::B'
+  // CHECK-NEXT:  `-ParmVarDecl 0x{{.+}}  col:41 'testFunctionTemplateDecl::B'
+
 
 namespace testClassTemplateDecl {
   class A { };
@@ -273,75 +275,163 @@
   template class TT = TestClassTemplate> struct TestTemplateTemplateDefaultType;
   template class TT> struct TestTemplateTemplateDefaultType { };
 }
-// CHECK:  ClassTemplateDecl{{.*}} TestClassTemplate
-// CHECK-NEXT:   TemplateTypeParmDecl
-// CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
-// CHECK:  CXXRecordDecl{{.*}} class TestClassTemplate
-// CHECK-NEXT: AccessSpecDecl{{.*}} public
-// CHECK-NEXT: CXXConstructorDecl{{.*}} 
-// CHECK-NEXT: CXXDestructorDecl{{.*}} 
-// CHECK-NEXT: CXXMethodDecl{{.*}} 
-// CHECK-NEXT: FieldDecl{{.*}} i
-// CHECK-NEXT:   ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
-// CHECK:  TemplateArgument{{.*}}A
-// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
-// CHECK-NEXT: AccessSpecDecl{{.*}} public
-// CHECK-NEXT: CXXConstructorDecl{{.*}} 
-// CHECK-NEXT: CXXDestructorDecl{{.*}} 
-// CHECK-NEXT: CXXMethodDecl{{.*}} 
-// CHECK-NEXT: FieldDecl{{.*}} i
-// CHECK:ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
-// CHECK-NEXT:   ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
-// CHECK-NEXT:   ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
-
-// CHECK:  ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
-// CHECK-NEXT:   DefinitionData
-// CHECK:TemplateArgument{{.*}}B
-// CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
-// CHECK-NEXT:   FieldDecl{{.*}} j
-
-// CHECK:  

r352804 - [ASTDump] Make template specialization tests more exact

2019-01-31 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Thu Jan 31 14:28:38 2019
New Revision: 352804

URL: http://llvm.org/viewvc/llvm-project?rev=352804=rev
Log:
[ASTDump] Make template specialization tests more exact

Reviewers: aaron.ballman

Subscribers: cfe-commits

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

Modified:
cfe/trunk/test/AST/ast-dump-decl.cpp

Modified: cfe/trunk/test/AST/ast-dump-decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-decl.cpp?rev=352804=352803=352804=diff
==
--- cfe/trunk/test/AST/ast-dump-decl.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-decl.cpp Thu Jan 31 14:28:38 2019
@@ -207,26 +207,28 @@ namespace testFunctionTemplateDecl {
   // explicit instantiation definition
   template void TestFunctionTemplate(D);
 }
-// CHECK:  FunctionTemplateDecl{{.*}} TestFunctionTemplate
-// CHECK-NEXT:   TemplateTypeParmDecl
-// CHECK-NEXT:   FunctionDecl{{.*}} TestFunctionTemplate 'void (T)'
-// CHECK-NEXT: ParmVarDecl{{.*}} 'T'
-// CHECK-NEXT: CompoundStmt
-// CHECK-NEXT:   FunctionDecl{{.*}} TestFunctionTemplate {{.*}}A
-// CHECK-NEXT: TemplateArgument
-// CHECK-NEXT: ParmVarDecl
-// CHECK-NEXT: CompoundStmt
-// CHECK-NEXT:   Function{{.*}} 'TestFunctionTemplate' {{.*}}B
-// CHECK-NEXT:   FunctionDecl{{.*}} TestFunctionTemplate {{.*}}C
-// CHECK-NEXT: TemplateArgument
-// CHECK-NEXT: ParmVarDecl
-// CHECK-NEXT:   FunctionDecl{{.*}} TestFunctionTemplate {{.*}}D
-// CHECK-NEXT: TemplateArgument
-// CHECK-NEXT: ParmVarDecl
-// CHECK-NEXT: CompoundStmt
-// CHECK:  FunctionDecl{{.*}} TestFunctionTemplate {{.*}}B
-// CHECK-NEXT:   TemplateArgument
-// CHECK-NEXT:   ParmVarDecl
+  // CHECK:   FunctionTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-14]]:3, 
col:55> col:29 TestFunctionTemplate
+  // CHECK-NEXT:  |-TemplateTypeParmDecl 0x{{.+}}  col:21 
referenced typename depth 0 index 0 T
+  // CHECK-NEXT:  |-FunctionDecl 0x{{.+}}  col:29 
TestFunctionTemplate 'void (T)'
+  // CHECK-NEXT:  | |-ParmVarDecl 0x{{.+}}  col:51 'T'
+  // CHECK-NEXT:  | `-CompoundStmt 0x{{.+}} 
+  // CHECK-NEXT:  |-FunctionDecl 0x{{.+}}  col:29 used 
TestFunctionTemplate 'void (testFunctionTemplateDecl::A)'
+  // CHECK-NEXT:  | |-TemplateArgument type 'testFunctionTemplateDecl::A'
+  // CHECK-NEXT:  | |-ParmVarDecl 0x{{.+}}  col:51 
'testFunctionTemplateDecl::A':'testFunctionTemplateDecl::A'
+  // CHECK-NEXT:  | `-CompoundStmt 0x{{.+}} 
+  // CHECK-NEXT:  |-Function 0x{{.+}} 'TestFunctionTemplate' 'void 
(testFunctionTemplateDecl::B)'
+  // CHECK-NEXT:  |-FunctionDecl 0x{{.+}}  col:29 
TestFunctionTemplate 'void (testFunctionTemplateDecl::C)'
+  // CHECK-NEXT:  | |-TemplateArgument type 'testFunctionTemplateDecl::C'
+  // CHECK-NEXT:  | `-ParmVarDecl 0x{{.+}}  col:51 
'testFunctionTemplateDecl::C':'testFunctionTemplateDecl::C'
+  // CHECK-NEXT:  `-FunctionDecl 0x{{.+}}  col:29 
TestFunctionTemplate 'void (testFunctionTemplateDecl::D)'
+  // CHECK-NEXT:|-TemplateArgument type 'testFunctionTemplateDecl::D'
+  // CHECK-NEXT:|-ParmVarDecl 0x{{.+}}  col:51 
'testFunctionTemplateDecl::D':'testFunctionTemplateDecl::D'
+  // CHECK-NEXT:`-CompoundStmt 0x{{.+}} 
+
+  // CHECK:   FunctionDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-26]]:3, 
col:41> col:19 TestFunctionTemplate 'void (testFunctionTemplateDecl::B)'
+  // CHECK-NEXT:  |-TemplateArgument type 'testFunctionTemplateDecl::B'
+  // CHECK-NEXT:  `-ParmVarDecl 0x{{.+}}  col:41 
'testFunctionTemplateDecl::B'
+
 
 namespace testClassTemplateDecl {
   class A { };
@@ -273,75 +275,163 @@ namespace testClassTemplateDecl {
   template class TT = TestClassTemplate> struct 
TestTemplateTemplateDefaultType;
   template class TT> struct TestTemplateTemplateDefaultType 
{ };
 }
-// CHECK:  ClassTemplateDecl{{.*}} TestClassTemplate
-// CHECK-NEXT:   TemplateTypeParmDecl
-// CHECK-NEXT:   CXXRecordDecl{{.*}} class TestClassTemplate
-// CHECK:  CXXRecordDecl{{.*}} class TestClassTemplate
-// CHECK-NEXT: AccessSpecDecl{{.*}} public
-// CHECK-NEXT: CXXConstructorDecl{{.*}} 
-// CHECK-NEXT: CXXDestructorDecl{{.*}} 
-// CHECK-NEXT: CXXMethodDecl{{.*}} 
-// CHECK-NEXT: FieldDecl{{.*}} i
-// CHECK-NEXT:   ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
-// CHECK:  TemplateArgument{{.*}}A
-// CHECK-NEXT: CXXRecordDecl{{.*}} class TestClassTemplate
-// CHECK-NEXT: AccessSpecDecl{{.*}} public
-// CHECK-NEXT: CXXConstructorDecl{{.*}} 
-// CHECK-NEXT: CXXDestructorDecl{{.*}} 
-// CHECK-NEXT: CXXMethodDecl{{.*}} 
-// CHECK-NEXT: FieldDecl{{.*}} i
-// CHECK:ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
-// CHECK-NEXT:   ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
-// CHECK-NEXT:   ClassTemplateSpecialization{{.*}} 'TestClassTemplate'
-
-// CHECK:  ClassTemplateSpecializationDecl{{.*}} class TestClassTemplate
-// CHECK-NEXT:   DefinitionData
-// 

Re: r350920 - [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed

2019-01-31 Thread John McCall via cfe-commits



On 31 Jan 2019, at 16:57, Akira Hatanaka wrote:

Would it be better if we disallowed trivial_abi if the class’ copy 
and move destructors were all deleted (and revert r350920)? I think 
that would make it easier to reason about when you are allowed to use 
trivial_abi and what effect the attribute has (which is to override 
the trivialness for the purpose of calls).


Sorry for my late reply. It took a while to understand that the patch 
I committed might not be the right way to fix the problem.


I'd be fine with that.  If nothing else, we can generalize it later if 
we decide that's an important use-case.


John.



On Jan 16, 2019, at 8:37 PM, John McCall via cfe-commits 
 wrote:


On 16 Jan 2019, at 20:03, Richard Smith wrote:


On Wed, 16 Jan 2019 at 16:20, John McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:


On 16 Jan 2019, at 18:32, Richard Smith wrote:


On Wed, 16 Jan 2019 at 09:10, John McCall via cfe-commits <
cfe-commits@lists.llvm.org> wrote:


On 16 Jan 2019, at 9:13, Aaron Ballman wrote:

On Wed, Jan 16, 2019 at 1:57 AM Akira Hatanaka 


wrote:


Yes, the behavior of the compiler doesn’t match what’s 
explained

in the documentation anymore.

Please take a look at the attached patch, which updates the
documentation.


Patch mostly LGTM, but I did have one wording suggestion.


diff --git a/include/clang/Basic/AttrDocs.td
b/include/clang/Basic/AttrDocs.td
index 5773a92c9c..ca3cfcf9b2 100644
--- a/include/clang/Basic/AttrDocs.td
+++ b/include/clang/Basic/AttrDocs.td
@@ -2478,15 +2478,20 @@ def TrivialABIDocs : Documentation {
  let Category = DocCatVariable;
  let Content = [{
The ``trivial_abi`` attribute can be applied to a C++ class, 
struct,

or union.
-It instructs the compiler to pass and return the type using 
the C

ABI for the
+``trivial_abi`` has the following effects:
+
+- It instructs the compiler to pass and return the type using 
the C

ABI for the
underlying type when the type would otherwise be considered
non-trivial for the
purpose of calls.
-A class annotated with `trivial_abi` can have non-trivial
destructors or copy/move constructors without automatically 
becoming

non-trivial for the purposes of calls. For example:
+- It makes the destructor and copy and move constructors of 
the

class trivial
+that would otherwise be considered non-trivial under the C++ 
ABI

rules.


How about: It makes the destructor, copy constructors, and move
constructors of the class trivial even if they would otherwise 
be

non-trivial under the C++ ABI rules.


Let's not say that it makes them trivial, because it doesn't.  It 
causes

their immediate non-triviality to be ignored for the purposes of
deciding
whether the type can be passed in registers.



Given the attribute now forces the type to be passed in registers, 
I

think
it'd be more to the point to say that it makes the triviality of 
those
special members be ignored when deciding whether to pass a type 
with a

subobject of this type in registers.


Wait, it forces it to be passed in registers?  I thought the design
was that it didn't override the non-trivial-abi-ness of subobjects;
see all the discussion of trivially_relocatable.



The attribute is ill-formed if applied to a class that has a 
subobject that
can't be passed in registers (or that has a vptr). And then as a 
weird
special case we don't instantiate the attribute when instantiating a 
class
if it would be ill-formed (well, we instantiate it and then remove 
it

again, but the effect is the same).

The commit at the start of this email chain switches us from the 
"just
override the trivialness for the purposes of the ABI" model to 
/also/
forcing the type to be passed in registers (the type would otherwise 
not be
passed in registers in some corner cases, such as if all its 
copy/move

special members are deleted).


I see.  Alright, I accept your wording, then.

John.
___
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
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57345: Make clang/test/Index/pch-from-libclang.c pass in more places

2019-01-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352803: Make clang/test/Index/pch-from-libclang.c pass in 
more places (authored by nico, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57345?vs=184593=184606#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57345

Files:
  cfe/trunk/include/clang/Driver/Driver.h
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/Index/pch-from-libclang.c
  cfe/trunk/tools/libclang/CIndexer.cpp

Index: cfe/trunk/lib/Driver/Driver.cpp
===
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -89,6 +89,33 @@
 using namespace clang;
 using namespace llvm::opt;
 
+// static
+std::string Driver::GetResourcesPath(StringRef BinaryPath,
+ StringRef CustomResourceDir) {
+  // Since the resource directory is embedded in the module hash, it's important
+  // that all places that need it call this function, so that they get the
+  // exact same string ("a/../b/" and "b/" get different hashes, for example).
+
+  // Dir is bin/ or lib/, depending on where BinaryPath is.
+  std::string Dir = llvm::sys::path::parent_path(BinaryPath);
+
+  SmallString<128> P(Dir);
+  if (CustomResourceDir != "") {
+llvm::sys::path::append(P, CustomResourceDir);
+  } else {
+// On Windows, libclang.dll is in bin/.
+// On non-Windows, libclang.so/.dylib is in lib/.
+// With a static-library build of libclang, LibClangPath will contain the
+// path of the embedding binary, which for LLVM binaries will be in bin/.
+// ../lib gets us to lib/ in both cases.
+P = llvm::sys::path::parent_path(Dir);
+llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang",
+CLANG_VERSION_STRING);
+  }
+
+  return P.str();
+}
+
 Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
DiagnosticsEngine ,
IntrusiveRefCntPtr VFS)
@@ -119,17 +146,7 @@
 #endif
 
   // Compute the path to the resource directory.
-  StringRef ClangResourceDir(CLANG_RESOURCE_DIR);
-  SmallString<128> P(Dir);
-  if (ClangResourceDir != "") {
-llvm::sys::path::append(P, ClangResourceDir);
-  } else {
-StringRef ClangLibdirSuffix(CLANG_LIBDIR_SUFFIX);
-P = llvm::sys::path::parent_path(Dir);
-llvm::sys::path::append(P, Twine("lib") + ClangLibdirSuffix, "clang",
-CLANG_VERSION_STRING);
-  }
-  ResourceDir = P.str();
+  ResourceDir = GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
 }
 
 void Driver::ParseDriverMode(StringRef ProgramName,
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -26,6 +26,7 @@
 #include "clang/Basic/Visibility.h"
 #include "clang/Basic/XRayInstr.h"
 #include "clang/Config/config.h"
+#include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/CommandLineSourceLoc.h"
@@ -1893,18 +1894,7 @@
  void *MainAddr) {
   std::string ClangExecutable =
   llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
-  StringRef Dir = llvm::sys::path::parent_path(ClangExecutable);
-
-  // Compute the path to the resource directory.
-  StringRef ClangResourceDir(CLANG_RESOURCE_DIR);
-  SmallString<128> P(Dir);
-  if (ClangResourceDir != "")
-llvm::sys::path::append(P, ClangResourceDir);
-  else
-llvm::sys::path::append(P, "..", Twine("lib") + CLANG_LIBDIR_SUFFIX,
-"clang", CLANG_VERSION_STRING);
-
-  return P.str();
+  return Driver::GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
 }
 
 static void ParseHeaderSearchArgs(HeaderSearchOptions , ArgList ,
Index: cfe/trunk/tools/libclang/CIndexer.cpp
===
--- cfe/trunk/tools/libclang/CIndexer.cpp
+++ cfe/trunk/tools/libclang/CIndexer.cpp
@@ -14,6 +14,7 @@
 #include "CXString.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/Driver.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/MD5.h"
@@ -62,7 +63,7 @@
 #endif
 #endif
 
-  LibClangPath += llvm::sys::path::parent_path(path);
+  LibClangPath += path;
 #else
   // This silly cast below avoids a C++ warning.
   Dl_info info;
@@ -70,13 +71,11 @@
 llvm_unreachable("Call to dladdr() failed");
 
   // We now have the CIndex directory, locate clang relative to it.
-  LibClangPath += llvm::sys::path::parent_path(info.dli_fname);
+  LibClangPath += info.dli_fname;
 #endif
 
-  

r352803 - Make clang/test/Index/pch-from-libclang.c pass in more places

2019-01-31 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Jan 31 14:15:32 2019
New Revision: 352803

URL: http://llvm.org/viewvc/llvm-project?rev=352803=rev
Log:
Make clang/test/Index/pch-from-libclang.c pass in more places

- fixes the test on macOS with LLVM_ENABLE_PIC=OFF
- together with D57343, gets the test to pass on Windows
- makes it run everywhere (it seems to just pass on Linux)

The main change is to pull out the resource directory computation into a
function shared by all 3 places that do it. In CIndexer.cpp, this now works no
matter if libclang is in lib/ or bin/ or statically linked to a binary in bin/.


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

Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Index/pch-from-libclang.c
cfe/trunk/tools/libclang/CIndexer.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=352803=352802=352803=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Thu Jan 31 14:15:32 2019
@@ -277,6 +277,12 @@ private:
   SmallString<128> );
 
 public:
+
+  /// Takes the path to a binary that's either in bin/ or lib/ and returns
+  /// the path to clang's resource directory.
+  static std::string GetResourcesPath(StringRef BinaryPath,
+  StringRef CustomResourceDir = "");
+
   Driver(StringRef ClangExecutable, StringRef TargetTriple,
  DiagnosticsEngine ,
  IntrusiveRefCntPtr VFS = nullptr);

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=352803=352802=352803=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Thu Jan 31 14:15:32 2019
@@ -89,6 +89,33 @@ using namespace clang::driver;
 using namespace clang;
 using namespace llvm::opt;
 
+// static
+std::string Driver::GetResourcesPath(StringRef BinaryPath,
+ StringRef CustomResourceDir) {
+  // Since the resource directory is embedded in the module hash, it's 
important
+  // that all places that need it call this function, so that they get the
+  // exact same string ("a/../b/" and "b/" get different hashes, for example).
+
+  // Dir is bin/ or lib/, depending on where BinaryPath is.
+  std::string Dir = llvm::sys::path::parent_path(BinaryPath);
+
+  SmallString<128> P(Dir);
+  if (CustomResourceDir != "") {
+llvm::sys::path::append(P, CustomResourceDir);
+  } else {
+// On Windows, libclang.dll is in bin/.
+// On non-Windows, libclang.so/.dylib is in lib/.
+// With a static-library build of libclang, LibClangPath will contain the
+// path of the embedding binary, which for LLVM binaries will be in bin/.
+// ../lib gets us to lib/ in both cases.
+P = llvm::sys::path::parent_path(Dir);
+llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang",
+CLANG_VERSION_STRING);
+  }
+
+  return P.str();
+}
+
 Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
DiagnosticsEngine ,
IntrusiveRefCntPtr VFS)
@@ -119,17 +146,7 @@ Driver::Driver(StringRef ClangExecutable
 #endif
 
   // Compute the path to the resource directory.
-  StringRef ClangResourceDir(CLANG_RESOURCE_DIR);
-  SmallString<128> P(Dir);
-  if (ClangResourceDir != "") {
-llvm::sys::path::append(P, ClangResourceDir);
-  } else {
-StringRef ClangLibdirSuffix(CLANG_LIBDIR_SUFFIX);
-P = llvm::sys::path::parent_path(Dir);
-llvm::sys::path::append(P, Twine("lib") + ClangLibdirSuffix, "clang",
-CLANG_VERSION_STRING);
-  }
-  ResourceDir = P.str();
+  ResourceDir = GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
 }
 
 void Driver::ParseDriverMode(StringRef ProgramName,

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=352803=352802=352803=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Jan 31 14:15:32 2019
@@ -26,6 +26,7 @@
 #include "clang/Basic/Visibility.h"
 #include "clang/Basic/XRayInstr.h"
 #include "clang/Config/config.h"
+#include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/CommandLineSourceLoc.h"
@@ -1893,18 +1894,7 @@ std::string CompilerInvocation::GetResou
  void *MainAddr) {
   std::string ClangExecutable =
   

[PATCH] D54429: [analyzer] Creating standard Sphinx documentation

2019-01-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

P.S. I also support the idea to have a separate page per checker. It encourages 
people to write as much documentation as necessary and continously expand it. 
Otherwise there's a perception that all docs need to be roughly of the same 
size and shape in order to make the page look consistent and not too cluttered.


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

https://reviews.llvm.org/D54429



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


[PATCH] D57521: [CMake] External compiler-rt-configure requires LLVMTestingSupport when including tests

2019-01-31 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris accepted this revision.
dberris added a comment.
This revision is now accepted and ready to land.

LGTM

Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D57521



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


[PATCH] D57527: Do not copy long double and 128-bit fp format from aux target for AMDGPU

2019-01-31 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352801: Do not copy long double and 128-bit fp format from 
aux target for AMDGPU (authored by yaxunl, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57527?vs=184569=184604#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57527

Files:
  lib/Basic/Targets/AMDGPU.cpp
  test/CodeGenCUDA/types.cu


Index: test/CodeGenCUDA/types.cu
===
--- test/CodeGenCUDA/types.cu
+++ test/CodeGenCUDA/types.cu
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple amdgcn -aux-triple x86_64 -fcuda-is-device 
-emit-llvm %s -o - | FileCheck -check-prefix=DEV %s
+// RUN: %clang_cc1 -triple x86_64 -aux-triple amdgcn -emit-llvm %s -o - | 
FileCheck -check-prefix=HOST %s
+
+#include "Inputs/cuda.h"
+
+// HOST: @ld_host = global x86_fp80 0xK
+long double ld_host;
+
+// DEV: @ld_device = addrspace(1) externally_initialized global double 
0.00e+00
+__device__ long double ld_device;
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -307,5 +307,16 @@
 }
 
 void AMDGPUTargetInfo::setAuxTarget(const TargetInfo *Aux) {
+  assert(HalfFormat == Aux->HalfFormat);
+  assert(FloatFormat == Aux->FloatFormat);
+  assert(DoubleFormat == Aux->DoubleFormat);
+
+  // On x86_64 long double is 80-bit extended precision format, which is
+  // not supported by AMDGPU. 128-bit floating point format is also not
+  // supported by AMDGPU. Therefore keep its own format for these two types.
+  auto SaveLongDoubleFormat = LongDoubleFormat;
+  auto SaveFloat128Format = Float128Format;
   copyAuxTarget(Aux);
+  LongDoubleFormat = SaveLongDoubleFormat;
+  Float128Format = SaveFloat128Format;
 }


Index: test/CodeGenCUDA/types.cu
===
--- test/CodeGenCUDA/types.cu
+++ test/CodeGenCUDA/types.cu
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple amdgcn -aux-triple x86_64 -fcuda-is-device -emit-llvm %s -o - | FileCheck -check-prefix=DEV %s
+// RUN: %clang_cc1 -triple x86_64 -aux-triple amdgcn -emit-llvm %s -o - | FileCheck -check-prefix=HOST %s
+
+#include "Inputs/cuda.h"
+
+// HOST: @ld_host = global x86_fp80 0xK
+long double ld_host;
+
+// DEV: @ld_device = addrspace(1) externally_initialized global double 0.00e+00
+__device__ long double ld_device;
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -307,5 +307,16 @@
 }
 
 void AMDGPUTargetInfo::setAuxTarget(const TargetInfo *Aux) {
+  assert(HalfFormat == Aux->HalfFormat);
+  assert(FloatFormat == Aux->FloatFormat);
+  assert(DoubleFormat == Aux->DoubleFormat);
+
+  // On x86_64 long double is 80-bit extended precision format, which is
+  // not supported by AMDGPU. 128-bit floating point format is also not
+  // supported by AMDGPU. Therefore keep its own format for these two types.
+  auto SaveLongDoubleFormat = LongDoubleFormat;
+  auto SaveFloat128Format = Float128Format;
   copyAuxTarget(Aux);
+  LongDoubleFormat = SaveLongDoubleFormat;
+  Float128Format = SaveFloat128Format;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r352801 - Do not copy long double and 128-bit fp format from aux target for AMDGPU

2019-01-31 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Thu Jan 31 13:57:51 2019
New Revision: 352801

URL: http://llvm.org/viewvc/llvm-project?rev=352801=rev
Log:
Do not copy long double and 128-bit fp format from aux target for AMDGPU

rC352620 caused regressions because it copied floating point format from
aux target.

floating point format decides whether extended long double is supported.
It is x86_fp80 on x86 but IEEE double on amdgcn.

Document usage of long doubel type in HIP programming guide 
https://github.com/ROCm-Developer-Tools/HIP/pull/890

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

Added:
cfe/trunk/test/CodeGenCUDA/types.cu
Modified:
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=352801=352800=352801=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Thu Jan 31 13:57:51 2019
@@ -307,5 +307,16 @@ void AMDGPUTargetInfo::getTargetDefines(
 }
 
 void AMDGPUTargetInfo::setAuxTarget(const TargetInfo *Aux) {
+  assert(HalfFormat == Aux->HalfFormat);
+  assert(FloatFormat == Aux->FloatFormat);
+  assert(DoubleFormat == Aux->DoubleFormat);
+
+  // On x86_64 long double is 80-bit extended precision format, which is
+  // not supported by AMDGPU. 128-bit floating point format is also not
+  // supported by AMDGPU. Therefore keep its own format for these two types.
+  auto SaveLongDoubleFormat = LongDoubleFormat;
+  auto SaveFloat128Format = Float128Format;
   copyAuxTarget(Aux);
+  LongDoubleFormat = SaveLongDoubleFormat;
+  Float128Format = SaveFloat128Format;
 }

Added: cfe/trunk/test/CodeGenCUDA/types.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/types.cu?rev=352801=auto
==
--- cfe/trunk/test/CodeGenCUDA/types.cu (added)
+++ cfe/trunk/test/CodeGenCUDA/types.cu Thu Jan 31 13:57:51 2019
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple amdgcn -aux-triple x86_64 -fcuda-is-device 
-emit-llvm %s -o - | FileCheck -check-prefix=DEV %s
+// RUN: %clang_cc1 -triple x86_64 -aux-triple amdgcn -emit-llvm %s -o - | 
FileCheck -check-prefix=HOST %s
+
+#include "Inputs/cuda.h"
+
+// HOST: @ld_host = global x86_fp80 0xK
+long double ld_host;
+
+// DEV: @ld_device = addrspace(1) externally_initialized global double 
0.00e+00
+__device__ long double ld_device;


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


Re: r350920 - [Sema] Make canPassInRegisters return true if the CXXRecordDecl passed

2019-01-31 Thread Akira Hatanaka via cfe-commits
Would it be better if we disallowed trivial_abi if the class’ copy and move 
destructors were all deleted (and revert r350920)? I think that would make it 
easier to reason about when you are allowed to use trivial_abi and what effect 
the attribute has (which is to override the trivialness for the purpose of 
calls).

Sorry for my late reply. It took a while to understand that the patch I 
committed might not be the right way to fix the problem.

> On Jan 16, 2019, at 8:37 PM, John McCall via cfe-commits 
>  wrote:
> 
> On 16 Jan 2019, at 20:03, Richard Smith wrote:
> 
>> On Wed, 16 Jan 2019 at 16:20, John McCall via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>> 
>>> On 16 Jan 2019, at 18:32, Richard Smith wrote:
>>> 
 On Wed, 16 Jan 2019 at 09:10, John McCall via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:
 
> On 16 Jan 2019, at 9:13, Aaron Ballman wrote:
> 
>> On Wed, Jan 16, 2019 at 1:57 AM Akira Hatanaka 
>> wrote:
>>> 
>>> Yes, the behavior of the compiler doesn’t match what’s explained
>>> in the documentation anymore.
>>> 
>>> Please take a look at the attached patch, which updates the
>>> documentation.
>> 
>> Patch mostly LGTM, but I did have one wording suggestion.
>> 
>>> diff --git a/include/clang/Basic/AttrDocs.td
>>> b/include/clang/Basic/AttrDocs.td
>>> index 5773a92c9c..ca3cfcf9b2 100644
>>> --- a/include/clang/Basic/AttrDocs.td
>>> +++ b/include/clang/Basic/AttrDocs.td
>>> @@ -2478,15 +2478,20 @@ def TrivialABIDocs : Documentation {
>>>   let Category = DocCatVariable;
>>>   let Content = [{
>>> The ``trivial_abi`` attribute can be applied to a C++ class, struct,
>>> or union.
>>> -It instructs the compiler to pass and return the type using the C
>>> ABI for the
>>> +``trivial_abi`` has the following effects:
>>> +
>>> +- It instructs the compiler to pass and return the type using the C
>>> ABI for the
>>> underlying type when the type would otherwise be considered
>>> non-trivial for the
>>> purpose of calls.
>>> -A class annotated with `trivial_abi` can have non-trivial
>>> destructors or copy/move constructors without automatically becoming
>>> non-trivial for the purposes of calls. For example:
>>> +- It makes the destructor and copy and move constructors of the
>>> class trivial
>>> +that would otherwise be considered non-trivial under the C++ ABI
>>> rules.
>> 
>> How about: It makes the destructor, copy constructors, and move
>> constructors of the class trivial even if they would otherwise be
>> non-trivial under the C++ ABI rules.
> 
> Let's not say that it makes them trivial, because it doesn't.  It causes
> their immediate non-triviality to be ignored for the purposes of
> deciding
> whether the type can be passed in registers.
> 
 
 Given the attribute now forces the type to be passed in registers, I
>>> think
 it'd be more to the point to say that it makes the triviality of those
 special members be ignored when deciding whether to pass a type with a
 subobject of this type in registers.
>>> 
>>> Wait, it forces it to be passed in registers?  I thought the design
>>> was that it didn't override the non-trivial-abi-ness of subobjects;
>>> see all the discussion of trivially_relocatable.
>>> 
>> 
>> The attribute is ill-formed if applied to a class that has a subobject that
>> can't be passed in registers (or that has a vptr). And then as a weird
>> special case we don't instantiate the attribute when instantiating a class
>> if it would be ill-formed (well, we instantiate it and then remove it
>> again, but the effect is the same).
>> 
>> The commit at the start of this email chain switches us from the "just
>> override the trivialness for the purposes of the ABI" model to /also/
>> forcing the type to be passed in registers (the type would otherwise not be
>> passed in registers in some corner cases, such as if all its copy/move
>> special members are deleted).
> 
> I see.  Alright, I accept your wording, then.
> 
> John.
> ___
> 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
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57219: [Fixed Point Arithmetic] Fixed Point Comparisons

2019-01-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3444
   case BO_NE:
+return Builder.CreateICmpNE(FullLHS, FullRHS);
+  case BO_Mul:

Are padding bits guaranteed zero or unspecified?  Or are we just not really 
supporting padding bits all the way to IRGen at this time?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57219



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


r352800 - Revert "[opaque pointer types] Add a FunctionCallee wrapper type, and use it."

2019-01-31 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Thu Jan 31 13:51:58 2019
New Revision: 352800

URL: http://llvm.org/viewvc/llvm-project?rev=352800=rev
Log:
Revert "[opaque pointer types] Add a FunctionCallee wrapper type, and use it."

This reverts commit f47d6b38c7a61d50db4566b02719de05492dcef1 (r352791).

Seems to run into compilation failures with GCC (but not clang, where
I tested it). Reverting while I investigate.

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

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=352800=352799=352800=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jan 31 13:51:58 2019
@@ -3056,7 +3056,7 @@ void CodeGenFunction::EmitCfiSlowPathChe
   bool WithDiag = !CGM.getCodeGenOpts().SanitizeTrap.has(Kind);
 
   llvm::CallInst *CheckCall;
-  llvm::FunctionCallee SlowPathFn;
+  llvm::Constant *SlowPathFn;
   if (WithDiag) {
 llvm::Constant *Info = llvm::ConstantStruct::getAnon(StaticArgs);
 auto *InfoPtr =
@@ -3078,8 +3078,7 @@ void CodeGenFunction::EmitCfiSlowPathChe
 CheckCall = Builder.CreateCall(SlowPathFn, {TypeId, Ptr});
   }
 
-  CGM.setDSOLocal(
-  cast(SlowPathFn.getCallee()->stripPointerCasts()));
+  CGM.setDSOLocal(cast(SlowPathFn->stripPointerCasts()));
   CheckCall->setDoesNotThrow();
 
   EmitBlock(Cont);


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


[PATCH] D57532: [Index] Make sure c-index-test finds libc++ on Mac

2019-01-31 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman requested changes to this revision.
arphaman added a comment.
This revision now requires changes to proceed.

The real problem is that `clang_parseTranslationUnit2` is broken, so this just 
fixes one client, `c-index-test`. All other macOS clients that call that 
function will still be unable to find the libc++ headers.

`clang_parseTranslationUnit2` should try to infer the binary directory based on 
the libclang path. Libclang already does that for `-resource-dir`, see 
(CIndexer::getClangResourceDir). I think that you should set the `clang` path 
to `CINdexer::getClangToolchainPath()`/bin/clang, and that should fix the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57532



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


[PATCH] D57488: [CUDA] add support for the new kernel launch API in CUDA-9.2+.

2019-01-31 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352799: [CUDA] add support for the new kernel launch API in 
CUDA-9.2+. (authored by tra, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57488?vs=184592=184598#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57488

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGCUDANV.cpp
  lib/Headers/__clang_cuda_runtime_wrapper.h
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaDecl.cpp
  test/CodeGenCUDA/Inputs/cuda.h
  test/CodeGenCUDA/device-stub.cu
  test/CodeGenCUDA/kernel-args-alignment.cu
  test/CodeGenCUDA/kernel-call.cu
  test/Driver/cuda-simple.cu
  test/SemaCUDA/Inputs/cuda.h
  test/SemaCUDA/config-type.cu
  unittests/ASTMatchers/ASTMatchersTest.h

Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -426,5 +426,15 @@
 #pragma pop_macro("__USE_FAST_MATH__")
 #pragma pop_macro("__CUDA_INCLUDE_COMPILER_INTERNAL_HEADERS__")
 
+// CUDA runtime uses this undocumented function to access kernel launch
+// configuration. The declaration is in crt/device_functions.h but that file
+// includes a lot of other stuff we don't want. Instead, we'll provide our own
+// declaration for it here.
+#if CUDA_VERSION >= 9020
+extern "C" unsigned __cudaPushCallConfiguration(dim3 gridDim, dim3 blockDim,
+size_t sharedMem = 0,
+void *stream = 0);
+#endif
+
 #endif // __CUDA__
 #endif // __CLANG_CUDA_RUNTIME_WRAPPER_H__
Index: lib/CodeGen/CGCUDANV.cpp
===
--- lib/CodeGen/CGCUDANV.cpp
+++ lib/CodeGen/CGCUDANV.cpp
@@ -15,6 +15,8 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/Decl.h"
+#include "clang/Basic/Cuda.h"
+#include "clang/CodeGen/CodeGenABITypes.h"
 #include "clang/CodeGen/ConstantInitBuilder.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constants.h"
@@ -102,7 +104,8 @@
 return DummyFunc;
   }
 
-  void emitDeviceStubBody(CodeGenFunction , FunctionArgList );
+  void emitDeviceStubBodyLegacy(CodeGenFunction , FunctionArgList );
+  void emitDeviceStubBodyNew(CodeGenFunction , FunctionArgList );
 
 public:
   CGNVCUDARuntime(CodeGenModule );
@@ -187,11 +190,110 @@
 void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction ,
  FunctionArgList ) {
   EmittedKernels.push_back(CGF.CurFn);
-  emitDeviceStubBody(CGF, Args);
+  if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(),
+ CudaFeature::CUDA_USES_NEW_LAUNCH))
+emitDeviceStubBodyNew(CGF, Args);
+  else
+emitDeviceStubBodyLegacy(CGF, Args);
+}
+
+// CUDA 9.0+ uses new way to launch kernels. Parameters are packed in a local
+// array and kernels are launched using cudaLaunchKernel().
+void CGNVCUDARuntime::emitDeviceStubBodyNew(CodeGenFunction ,
+FunctionArgList ) {
+  // Build the shadow stack entry at the very start of the function.
+
+  // Calculate amount of space we will need for all arguments.  If we have no
+  // args, allocate a single pointer so we still have a valid pointer to the
+  // argument array that we can pass to runtime, even if it will be unused.
+  Address KernelArgs = CGF.CreateTempAlloca(
+  VoidPtrTy, CharUnits::fromQuantity(16), "kernel_args",
+  llvm::ConstantInt::get(SizeTy, std::max(1, Args.size(;
+  // Store pointers to the arguments in a locally allocated launch_args.
+  for (unsigned i = 0; i < Args.size(); ++i) {
+llvm::Value* VarPtr = CGF.GetAddrOfLocalVar(Args[i]).getPointer();
+llvm::Value *VoidVarPtr = CGF.Builder.CreatePointerCast(VarPtr, VoidPtrTy);
+CGF.Builder.CreateDefaultAlignedStore(
+VoidVarPtr, CGF.Builder.CreateConstGEP1_32(KernelArgs.getPointer(), i));
+  }
+
+  llvm::BasicBlock *EndBlock = CGF.createBasicBlock("setup.end");
+
+  // Lookup cudaLaunchKernel function.
+  // cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim, dim3 blockDim,
+  //  void **args, size_t sharedMem,
+  //  cudaStream_t stream);
+  TranslationUnitDecl *TUDecl = CGM.getContext().getTranslationUnitDecl();
+  DeclContext *DC = TranslationUnitDecl::castToDeclContext(TUDecl);
+  IdentifierInfo  =
+  CGM.getContext().Idents.get("cudaLaunchKernel");
+  FunctionDecl *cudaLaunchKernelFD = nullptr;
+  for (const auto  : DC->lookup()) {
+if (FunctionDecl *FD = dyn_cast(Result))
+  cudaLaunchKernelFD = FD;
+  }
+
+  if (cudaLaunchKernelFD == nullptr) {
+CGM.Error(CGF.CurFuncDecl->getLocation(),
+  "Can't find declaration for cudaLaunchKernel()");
+

r352799 - [CUDA] add support for the new kernel launch API in CUDA-9.2+.

2019-01-31 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Jan 31 13:34:03 2019
New Revision: 352799

URL: http://llvm.org/viewvc/llvm-project?rev=352799=rev
Log:
[CUDA] add support for the new kernel launch API in CUDA-9.2+.

Instead of calling CUDA runtime to arrange function arguments,
the new API constructs arguments in a local array and the kernels
are launched with __cudaLaunchKernel().

The old API has been deprecated and is expected to go away
in the next CUDA release.

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGCUDANV.cpp
cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CodeGenCUDA/Inputs/cuda.h
cfe/trunk/test/CodeGenCUDA/device-stub.cu
cfe/trunk/test/CodeGenCUDA/kernel-args-alignment.cu
cfe/trunk/test/CodeGenCUDA/kernel-call.cu
cfe/trunk/test/Driver/cuda-simple.cu
cfe/trunk/test/SemaCUDA/Inputs/cuda.h
cfe/trunk/test/SemaCUDA/config-type.cu
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.h

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=352799=352798=352799=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jan 31 13:34:03 
2019
@@ -7143,7 +7143,7 @@ def err_kern_type_not_void_return : Erro
 def err_kern_is_nonstatic_method : Error<
   "kernel function %0 must be a free function or static member function">;
 def err_config_scalar_return : Error<
-  "CUDA special function 'cudaConfigureCall' must have scalar return type">;
+  "CUDA special function '%0' must have scalar return type">;
 def err_kern_call_not_global_function : Error<
   "kernel call to non-global function %0">;
 def err_global_call_not_config : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=352799=352798=352799=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jan 31 13:34:03 2019
@@ -10348,6 +10348,11 @@ public:
   /// Copies target attributes from the template TD to the function FD.
   void inheritCUDATargetAttrs(FunctionDecl *FD, const FunctionTemplateDecl 
);
 
+  /// Returns the name of the launch configuration function.  This is the name
+  /// of the function that will be called to configure kernel call, with the
+  /// parameters specified via <<<>>>.
+  std::string getCudaConfigureFuncName() const;
+
   /// \name Code completion
   //@{
   /// Describes the context in which code completion occurs.

Modified: cfe/trunk/lib/CodeGen/CGCUDANV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDANV.cpp?rev=352799=352798=352799=diff
==
--- cfe/trunk/lib/CodeGen/CGCUDANV.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCUDANV.cpp Thu Jan 31 13:34:03 2019
@@ -15,6 +15,8 @@
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/Decl.h"
+#include "clang/Basic/Cuda.h"
+#include "clang/CodeGen/CodeGenABITypes.h"
 #include "clang/CodeGen/ConstantInitBuilder.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constants.h"
@@ -102,7 +104,8 @@ private:
 return DummyFunc;
   }
 
-  void emitDeviceStubBody(CodeGenFunction , FunctionArgList );
+  void emitDeviceStubBodyLegacy(CodeGenFunction , FunctionArgList );
+  void emitDeviceStubBodyNew(CodeGenFunction , FunctionArgList );
 
 public:
   CGNVCUDARuntime(CodeGenModule );
@@ -187,11 +190,110 @@ llvm::FunctionType *CGNVCUDARuntime::get
 void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction ,
  FunctionArgList ) {
   EmittedKernels.push_back(CGF.CurFn);
-  emitDeviceStubBody(CGF, Args);
+  if (CudaFeatureEnabled(CGM.getTarget().getSDKVersion(),
+ CudaFeature::CUDA_USES_NEW_LAUNCH))
+emitDeviceStubBodyNew(CGF, Args);
+  else
+emitDeviceStubBodyLegacy(CGF, Args);
 }
 
-void CGNVCUDARuntime::emitDeviceStubBody(CodeGenFunction ,
- FunctionArgList ) {
+// CUDA 9.0+ uses new way to launch kernels. Parameters are packed in a local
+// array and kernels are launched using cudaLaunchKernel().
+void CGNVCUDARuntime::emitDeviceStubBodyNew(CodeGenFunction ,
+FunctionArgList ) {
+  // Build the shadow stack entry at the very start of the function.
+
+  // Calculate amount of space we will need for all arguments.  If we have no
+  // args, allocate a single pointer so we still have a valid pointer to the
+  // argument 

[PATCH] D57487: [CUDA] Propagate detected version of CUDA to cc1

2019-01-31 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352798: [CUDA] Propagate detected version of CUDA to cc1 
(authored by tra, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57487?vs=184416=184596#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57487

Files:
  cfe/trunk/include/clang/Basic/Cuda.h
  cfe/trunk/include/clang/Basic/TargetOptions.h
  cfe/trunk/lib/Basic/Cuda.cpp
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
  cfe/trunk/test/Driver/cuda-detect.cu

Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -3464,13 +3464,25 @@
   NormalizedTriple = C.getSingleOffloadToolChain()
  ->getTriple()
  .normalize();
-else
+else {
+  // Host-side compilation.
   NormalizedTriple =
   (IsCuda ? C.getSingleOffloadToolChain()
   : C.getSingleOffloadToolChain())
   ->getTriple()
   .normalize();
-
+  if (IsCuda) {
+// We need to figure out which CUDA version we're compiling for, as that
+// determines how we load and launch GPU kernels.
+auto *CTC = static_cast(
+C.getSingleOffloadToolChain());
+assert(CTC && "Expected valid CUDA Toolchain.");
+if (CTC && CTC->CudaInstallation.version() != CudaVersion::UNKNOWN)
+  CmdArgs.push_back(Args.MakeArgString(
+  Twine("-target-sdk-version=") +
+  CudaVersionToString(CTC->CudaInstallation.version(;
+  }
+}
 CmdArgs.push_back("-aux-triple");
 CmdArgs.push_back(Args.MakeArgString(NormalizedTriple));
   }
Index: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
@@ -661,9 +661,13 @@
  options::OPT_fno_cuda_short_ptr, false))
 CC1Args.append({"-mllvm", "--nvptx-short-ptr"});
 
+  if (CudaInstallation.version() >= CudaVersion::UNKNOWN)
+CC1Args.push_back(DriverArgs.MakeArgString(
+Twine("-target-sdk-version=") +
+CudaVersionToString(CudaInstallation.version(;
+
   if (DeviceOffloadingKind == Action::OFK_OpenMP) {
 SmallVector LibraryPaths;
-
 if (const Arg *A = DriverArgs.getLastArg(options::OPT_libomptarget_nvptx_path_EQ))
   LibraryPaths.push_back(A->getValue());
 
Index: cfe/trunk/lib/Basic/Cuda.cpp
===
--- cfe/trunk/lib/Basic/Cuda.cpp
+++ cfe/trunk/lib/Basic/Cuda.cpp
@@ -3,6 +3,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/VersionTuple.h"
 
 namespace clang {
 
@@ -28,6 +29,17 @@
   llvm_unreachable("invalid enum");
 }
 
+CudaVersion CudaStringToVersion(llvm::StringRef S) {
+  return llvm::StringSwitch(S)
+  .Case("7.0", CudaVersion::CUDA_70)
+  .Case("7.5", CudaVersion::CUDA_75)
+  .Case("8.0", CudaVersion::CUDA_80)
+  .Case("9.0", CudaVersion::CUDA_90)
+  .Case("9.1", CudaVersion::CUDA_91)
+  .Case("9.2", CudaVersion::CUDA_92)
+  .Case("10.0", CudaVersion::CUDA_100);
+}
+
 const char *CudaArchToString(CudaArch A) {
   switch (A) {
   case CudaArch::LAST:
@@ -322,4 +334,38 @@
   }
 }
 
+static CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
+  int IVer =
+  Version.getMajor() * 10 + Version.getMinor().getValueOr(0);
+  switch(IVer) {
+  case 70:
+return CudaVersion::CUDA_70;
+  case 75:
+return CudaVersion::CUDA_75;
+  case 80:
+return CudaVersion::CUDA_80;
+  case 90:
+return CudaVersion::CUDA_90;
+  case 91:
+return CudaVersion::CUDA_91;
+  case 92:
+return CudaVersion::CUDA_92;
+  case 100:
+return CudaVersion::CUDA_100;
+  default:
+return CudaVersion::UNKNOWN;
+  }
+}
+
+bool CudaFeatureEnabled(llvm::VersionTuple  Version, CudaFeature Feature) {
+  return CudaFeatureEnabled(ToCudaVersion(Version), Feature);
+}
+
+bool CudaFeatureEnabled(CudaVersion Version, CudaFeature Feature) {
+  switch (Feature) {
+  case CudaFeature::CUDA_USES_NEW_LAUNCH:
+return Version >= CudaVersion::CUDA_92;
+  }
+  llvm_unreachable("Unknown CUDA feature.");
+}
 } // namespace clang
Index: cfe/trunk/include/clang/Basic/Cuda.h
===
--- cfe/trunk/include/clang/Basic/Cuda.h
+++ cfe/trunk/include/clang/Basic/Cuda.h
@@ -11,6 +11,7 @@
 
 namespace llvm {
 class StringRef;
+class VersionTuple;
 } // namespace llvm
 
 namespace clang {
@@ -27,9 +28,8 @@
   LATEST = CUDA_100,
 };
 const char 

r352798 - [CUDA] Propagate detected version of CUDA to cc1

2019-01-31 Thread Artem Belevich via cfe-commits
Author: tra
Date: Thu Jan 31 13:32:24 2019
New Revision: 352798

URL: http://llvm.org/viewvc/llvm-project?rev=352798=rev
Log:
[CUDA] Propagate detected version of CUDA to cc1

..and use it to control that parts of CUDA compilation
that depend on the specific version of CUDA SDK.

This patch has a placeholder for a 'new launch API' support
which is in a separate patch. The list will be further
extended in the upcoming patch to support CUDA-10.1.

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

Modified:
cfe/trunk/include/clang/Basic/Cuda.h
cfe/trunk/include/clang/Basic/TargetOptions.h
cfe/trunk/lib/Basic/Cuda.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/test/Driver/cuda-detect.cu

Modified: cfe/trunk/include/clang/Basic/Cuda.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Cuda.h?rev=352798=352797=352798=diff
==
--- cfe/trunk/include/clang/Basic/Cuda.h (original)
+++ cfe/trunk/include/clang/Basic/Cuda.h Thu Jan 31 13:32:24 2019
@@ -11,6 +11,7 @@
 
 namespace llvm {
 class StringRef;
+class VersionTuple;
 } // namespace llvm
 
 namespace clang {
@@ -27,9 +28,8 @@ enum class CudaVersion {
   LATEST = CUDA_100,
 };
 const char *CudaVersionToString(CudaVersion V);
-
-// No string -> CudaVersion conversion function because there's no canonical
-// spelling of the various CUDA versions.
+// Input is "Major.Minor"
+CudaVersion CudaStringToVersion(llvm::StringRef S);
 
 enum class CudaArch {
   UNKNOWN,
@@ -103,6 +103,15 @@ CudaVersion MinVersionForCudaArch(CudaAr
 /// Get the latest CudaVersion that supports the given CudaArch.
 CudaVersion MaxVersionForCudaArch(CudaArch A);
 
+//  Various SDK-dependent features that affect CUDA compilation
+enum class CudaFeature {
+  // CUDA-9.2+ uses a new API for launching kernels.
+  CUDA_USES_NEW_LAUNCH,
+};
+
+bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature);
+bool CudaFeatureEnabled(CudaVersion, CudaFeature);
+
 } // namespace clang
 
 #endif

Modified: cfe/trunk/include/clang/Basic/TargetOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetOptions.h?rev=352798=352797=352798=diff
==
--- cfe/trunk/include/clang/Basic/TargetOptions.h (original)
+++ cfe/trunk/include/clang/Basic/TargetOptions.h Thu Jan 31 13:32:24 2019
@@ -75,6 +75,11 @@ public:
   std::string CodeModel;
 
   /// The version of the SDK which was used during the compilation.
+  /// The option is used for two different purposes:
+  /// * on darwin the version is propagated to LLVM where it's used
+  ///   to support SDK Version metadata (See D55673).
+  /// * CUDA compilation uses it to control parts of CUDA compilation
+  ///   in clang that depend on specific version of the CUDA SDK.
   llvm::VersionTuple SDKVersion;
 };
 

Modified: cfe/trunk/lib/Basic/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Cuda.cpp?rev=352798=352797=352798=diff
==
--- cfe/trunk/lib/Basic/Cuda.cpp (original)
+++ cfe/trunk/lib/Basic/Cuda.cpp Thu Jan 31 13:32:24 2019
@@ -3,6 +3,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/VersionTuple.h"
 
 namespace clang {
 
@@ -28,6 +29,17 @@ const char *CudaVersionToString(CudaVers
   llvm_unreachable("invalid enum");
 }
 
+CudaVersion CudaStringToVersion(llvm::StringRef S) {
+  return llvm::StringSwitch(S)
+  .Case("7.0", CudaVersion::CUDA_70)
+  .Case("7.5", CudaVersion::CUDA_75)
+  .Case("8.0", CudaVersion::CUDA_80)
+  .Case("9.0", CudaVersion::CUDA_90)
+  .Case("9.1", CudaVersion::CUDA_91)
+  .Case("9.2", CudaVersion::CUDA_92)
+  .Case("10.0", CudaVersion::CUDA_100);
+}
+
 const char *CudaArchToString(CudaArch A) {
   switch (A) {
   case CudaArch::LAST:
@@ -322,4 +334,38 @@ CudaVersion MaxVersionForCudaArch(CudaAr
   }
 }
 
+static CudaVersion ToCudaVersion(llvm::VersionTuple Version) {
+  int IVer =
+  Version.getMajor() * 10 + Version.getMinor().getValueOr(0);
+  switch(IVer) {
+  case 70:
+return CudaVersion::CUDA_70;
+  case 75:
+return CudaVersion::CUDA_75;
+  case 80:
+return CudaVersion::CUDA_80;
+  case 90:
+return CudaVersion::CUDA_90;
+  case 91:
+return CudaVersion::CUDA_91;
+  case 92:
+return CudaVersion::CUDA_92;
+  case 100:
+return CudaVersion::CUDA_100;
+  default:
+return CudaVersion::UNKNOWN;
+  }
+}
+
+bool CudaFeatureEnabled(llvm::VersionTuple  Version, CudaFeature Feature) {
+  return CudaFeatureEnabled(ToCudaVersion(Version), Feature);
+}
+
+bool CudaFeatureEnabled(CudaVersion Version, CudaFeature Feature) {
+  switch (Feature) {
+  case CudaFeature::CUDA_USES_NEW_LAUNCH:
+return Version >= CudaVersion::CUDA_92;
+  

[PATCH] D57345: Make clang/test/Index/pch-from-libclang.c pass in more places

2019-01-31 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D57345



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


[PATCH] D57532: [Index] Make sure c-index-test finds libc++ on Mac

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

Looking at D54630 , it seems arphaman and 
dexonsmith are probalby good reviewers for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57532



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


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352796: [clangd] A code action to swap branches of an if 
statement (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56611?vs=184588=184594#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56611

Files:
  clang-tools-extra/trunk/clangd/SourceCode.cpp
  clang-tools-extra/trunk/clangd/SourceCode.h
  clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/trunk/clangd/refactor/tweaks/Dummy.cpp
  clang-tools-extra/trunk/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt
  clang-tools-extra/trunk/unittests/clangd/TweakTests.cpp

Index: clang-tools-extra/trunk/clangd/refactor/tweaks/SwapIfBranches.cpp
===
--- clang-tools-extra/trunk/clangd/refactor/tweaks/SwapIfBranches.cpp
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/SwapIfBranches.cpp
@@ -0,0 +1,132 @@
+//===--- SwapIfBranches.cpp --*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "ClangdUnit.h"
+#include "Logger.h"
+#include "SourceCode.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/Stmt.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+/// Swaps the 'then' and 'else' branch of the if statement.
+/// Before:
+///   if (foo) { return 10; } else { continue; }
+///   ^^^ 
+/// After:
+///   if (foo) { continue; } else { return 10; }
+class SwapIfBranches : public Tweak {
+public:
+  TweakID id() const override final;
+
+  bool prepare(const Selection ) override;
+  Expected apply(const Selection ) override;
+  std::string title() const override;
+
+private:
+  IfStmt *If = nullptr;
+};
+
+REGISTER_TWEAK(SwapIfBranches);
+
+class FindIfUnderCursor : public RecursiveASTVisitor {
+public:
+  FindIfUnderCursor(ASTContext , SourceLocation CursorLoc, IfStmt *)
+  : Ctx(Ctx), CursorLoc(CursorLoc), Result(Result) {}
+
+  bool VisitIfStmt(IfStmt *If) {
+// Check if the cursor is in the range of 'if (cond)'.
+// FIXME: this does not contain the closing paren, add it too.
+auto R = toHalfOpenFileRange(
+Ctx.getSourceManager(), Ctx.getLangOpts(),
+SourceRange(If->getIfLoc(), If->getCond()->getEndLoc().isValid()
+? If->getCond()->getEndLoc()
+: If->getIfLoc()));
+if (R && halfOpenRangeTouches(Ctx.getSourceManager(), *R, CursorLoc)) {
+  Result = If;
+  return false;
+}
+// Check the range of 'else'.
+R = toHalfOpenFileRange(Ctx.getSourceManager(), Ctx.getLangOpts(),
+SourceRange(If->getElseLoc()));
+if (R && halfOpenRangeTouches(Ctx.getSourceManager(), *R, CursorLoc)) {
+  Result = If;
+  return false;
+}
+
+return true;
+  }
+
+private:
+  ASTContext 
+  SourceLocation CursorLoc;
+  IfStmt *
+};
+} // namespace
+
+bool SwapIfBranches::prepare(const Selection ) {
+  auto  = Inputs.AST.getASTContext();
+  FindIfUnderCursor(Ctx, Inputs.Cursor, If).TraverseAST(Ctx);
+  if (!If)
+return false;
+
+  // avoid dealing with single-statement brances, they require careful handling
+  // to avoid changing semantics of the code (i.e. dangling else).
+  if (!If->getThen() || !llvm::isa(If->getThen()) ||
+  !If->getElse() || !llvm::isa(If->getElse()))
+return false;
+  return true;
+}
+
+Expected SwapIfBranches::apply(const Selection ) {
+  auto  = Inputs.AST.getASTContext();
+  auto  = Ctx.getSourceManager();
+
+  auto ThenRng = toHalfOpenFileRange(SrcMgr, Ctx.getLangOpts(),
+ If->getThen()->getSourceRange());
+  if (!ThenRng)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"Could not obtain range of the 'then' branch. Macros?");
+  auto ElseRng = toHalfOpenFileRange(SrcMgr, Ctx.getLangOpts(),
+ If->getElse()->getSourceRange());
+  if (!ElseRng)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"Could not obtain range of the 'else' branch. 

[clang-tools-extra] r352796 - [clangd] A code action to swap branches of an if statement

2019-01-31 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Jan 31 13:30:05 2019
New Revision: 352796

URL: http://llvm.org/viewvc/llvm-project?rev=352796=rev
Log:
[clangd] A code action to swap branches of an if statement

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: llvm-commits, mgorny, ioeric, MaskRay, jkorous, arphaman, 
kadircet, cfe-commits

Tags: #clang

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

Added:
clang-tools-extra/trunk/clangd/refactor/tweaks/SwapIfBranches.cpp
clang-tools-extra/trunk/unittests/clangd/TweakTests.cpp
Removed:
clang-tools-extra/trunk/clangd/refactor/tweaks/Dummy.cpp
Modified:
clang-tools-extra/trunk/clangd/SourceCode.cpp
clang-tools-extra/trunk/clangd/SourceCode.h
clang-tools-extra/trunk/clangd/refactor/tweaks/CMakeLists.txt
clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/SourceCode.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/SourceCode.cpp?rev=352796=352795=352796=diff
==
--- clang-tools-extra/trunk/clangd/SourceCode.cpp (original)
+++ clang-tools-extra/trunk/clangd/SourceCode.cpp Thu Jan 31 13:30:05 2019
@@ -11,6 +11,8 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
@@ -141,6 +143,69 @@ Position sourceLocToPosition(const Sourc
   return P;
 }
 
+bool isValidFileRange(const SourceManager , SourceRange R) {
+  if (!R.getBegin().isValid() || !R.getEnd().isValid())
+return false;
+
+  FileID BeginFID;
+  size_t BeginOffset = 0;
+  std::tie(BeginFID, BeginOffset) = Mgr.getDecomposedLoc(R.getBegin());
+
+  FileID EndFID;
+  size_t EndOffset = 0;
+  std::tie(EndFID, EndOffset) = Mgr.getDecomposedLoc(R.getEnd());
+
+  return BeginFID.isValid() && BeginFID == EndFID && BeginOffset <= EndOffset;
+}
+
+bool halfOpenRangeContains(const SourceManager , SourceRange R,
+   SourceLocation L) {
+  assert(isValidFileRange(Mgr, R));
+
+  FileID BeginFID;
+  size_t BeginOffset = 0;
+  std::tie(BeginFID, BeginOffset) = Mgr.getDecomposedLoc(R.getBegin());
+  size_t EndOffset = Mgr.getFileOffset(R.getEnd());
+
+  FileID LFid;
+  size_t LOffset;
+  std::tie(LFid, LOffset) = Mgr.getDecomposedLoc(L);
+  return BeginFID == LFid && BeginOffset <= LOffset && LOffset < EndOffset;
+}
+
+bool halfOpenRangeTouches(const SourceManager , SourceRange R,
+  SourceLocation L) {
+  return L == R.getEnd() || halfOpenRangeContains(Mgr, R, L);
+}
+
+llvm::Optional toHalfOpenFileRange(const SourceManager ,
+const LangOptions ,
+SourceRange R) {
+  auto Begin = Mgr.getFileLoc(R.getBegin());
+  if (Begin.isInvalid())
+return llvm::None;
+  auto End = Mgr.getFileLoc(R.getEnd());
+  if (End.isInvalid())
+return llvm::None;
+  End = Lexer::getLocForEndOfToken(End, 0, Mgr, LangOpts);
+
+  SourceRange Result(Begin, End);
+  if (!isValidFileRange(Mgr, Result))
+return llvm::None;
+  return Result;
+}
+
+llvm::StringRef toSourceCode(const SourceManager , SourceRange R) {
+  assert(isValidFileRange(SM, R));
+  bool Invalid = false;
+  auto *Buf = SM.getBuffer(SM.getFileID(R.getBegin()), );
+  assert(!Invalid);
+
+  size_t BeginOffset = SM.getFileOffset(R.getBegin());
+  size_t EndOffset = SM.getFileOffset(R.getEnd());
+  return Buf->getBuffer().substr(BeginOffset, EndOffset - BeginOffset);
+}
+
 llvm::Expected sourceLocationInMainFile(const SourceManager 
,
 Position P) {
   llvm::StringRef Code = SM.getBuffer(SM.getMainFileID())->getBuffer();
@@ -169,8 +234,7 @@ std::pair offsetToClangL
   return {Lines + 1, Offset - StartOfLine + 1};
 }
 
-std::pair
-splitQualifiedName(llvm::StringRef QName) {
+std::pair splitQualifiedName(StringRef QName) {
   size_t Pos = QName.rfind("::");
   if (Pos == llvm::StringRef::npos)
 return {llvm::StringRef(), QName};

Modified: clang-tools-extra/trunk/clangd/SourceCode.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/SourceCode.h?rev=352796=352795=352796=diff
==
--- clang-tools-extra/trunk/clangd/SourceCode.h (original)
+++ clang-tools-extra/trunk/clangd/SourceCode.h Thu Jan 31 13:30:05 2019
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SOURCECODE_H
 #include "Protocol.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
@@ -61,6 +62,46 @@ Position sourceLocToPosition(const Sourc
 llvm::Expected sourceLocationInMainFile(const 

[PATCH] D57345: Make clang/test/Index/pch-from-libclang.c pass in more places

2019-01-31 Thread Nico Weber via Phabricator via cfe-commits
thakis updated this revision to Diff 184593.
thakis edited the summary of this revision.
thakis added a comment.

shared function


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

https://reviews.llvm.org/D57345

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Index/pch-from-libclang.c
  clang/tools/libclang/CIndexer.cpp

Index: clang/tools/libclang/CIndexer.cpp
===
--- clang/tools/libclang/CIndexer.cpp
+++ clang/tools/libclang/CIndexer.cpp
@@ -14,6 +14,7 @@
 #include "CXString.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/Driver.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/MD5.h"
@@ -62,7 +63,7 @@
 #endif
 #endif
 
-  LibClangPath += llvm::sys::path::parent_path(path);
+  LibClangPath += path;
 #else
   // This silly cast below avoids a C++ warning.
   Dl_info info;
@@ -70,13 +71,11 @@
 llvm_unreachable("Call to dladdr() failed");
 
   // We now have the CIndex directory, locate clang relative to it.
-  LibClangPath += llvm::sys::path::parent_path(info.dli_fname);
+  LibClangPath += info.dli_fname;
 #endif
 
-  llvm::sys::path::append(LibClangPath, "clang", CLANG_VERSION_STRING);
-
   // Cache our result.
-  ResourcesPath = LibClangPath.str();
+  ResourcesPath = driver::Driver::GetResourcesPath(LibClangPath);
   return ResourcesPath;
 }
 
Index: clang/test/Index/pch-from-libclang.c
===
--- clang/test/Index/pch-from-libclang.c
+++ clang/test/Index/pch-from-libclang.c
@@ -1,7 +1,11 @@
 // Check that clang can use a PCH created from libclang.
 
-// FIXME: Non-darwin bots fail. Would need investigation using -module-file-info to see what is the difference in modules generated from libclang vs the compiler invocation, in those systems.
-// REQUIRES: system-darwin
+// This test doesn't use -fdisable-module-hash and hence requires that
+// CompilerInvocation::getModuleHash() computes exactly the same hash
+// for c-index-test and clang, which in turn requires that the both use
+// exactly the same resource-dir, even without calling realpath() on it:
+// - a/../b/ and b/ are not considered the same
+// - on Windows, c:\ and C:\ (only different in case) are not the same
 
 // RUN: %clang_cc1 -fsyntax-only %s -verify
 // RUN: c-index-test -write-pch %t.h.pch %s -fmodules -fmodules-cache-path=%t.mcp -Xclang -triple -Xclang x86_64-apple-darwin
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -26,6 +26,7 @@
 #include "clang/Basic/Visibility.h"
 #include "clang/Basic/XRayInstr.h"
 #include "clang/Config/config.h"
+#include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/CommandLineSourceLoc.h"
@@ -1893,18 +1894,7 @@
  void *MainAddr) {
   std::string ClangExecutable =
   llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
-  StringRef Dir = llvm::sys::path::parent_path(ClangExecutable);
-
-  // Compute the path to the resource directory.
-  StringRef ClangResourceDir(CLANG_RESOURCE_DIR);
-  SmallString<128> P(Dir);
-  if (ClangResourceDir != "")
-llvm::sys::path::append(P, ClangResourceDir);
-  else
-llvm::sys::path::append(P, "..", Twine("lib") + CLANG_LIBDIR_SUFFIX,
-"clang", CLANG_VERSION_STRING);
-
-  return P.str();
+  return Driver::GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
 }
 
 static void ParseHeaderSearchArgs(HeaderSearchOptions , ArgList ,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -89,6 +89,33 @@
 using namespace clang;
 using namespace llvm::opt;
 
+// static
+std::string Driver::GetResourcesPath(StringRef BinaryPath,
+ StringRef CustomResourceDir) {
+  // Since the resource directory is embedded in the module hash, it's important
+  // that all places that need it call this function, so that they get the
+  // exact same string ("a/../b/" and "b/" get different hashes, for example).
+
+  // Dir is bin/ or lib/, depending on where BinaryPath is.
+  std::string Dir = llvm::sys::path::parent_path(BinaryPath);
+
+  SmallString<128> P(Dir);
+  if (CustomResourceDir != "") {
+llvm::sys::path::append(P, CustomResourceDir);
+  } else {
+// On Windows, libclang.dll is in bin/.
+// On non-Windows, libclang.so/.dylib is in lib/.
+// With a static-library build of libclang, LibClangPath will contain the
+// path of the embedding binary, which for LLVM binaries will be in 

[PATCH] D57488: [CUDA] add support for the new kernel launch API in CUDA-9.2+.

2019-01-31 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 184592.
tra added a comment.

Updated ASTMatchers unit test.


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

https://reviews.llvm.org/D57488

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGCUDANV.cpp
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCUDA/Inputs/cuda.h
  clang/test/CodeGenCUDA/device-stub.cu
  clang/test/CodeGenCUDA/kernel-args-alignment.cu
  clang/test/CodeGenCUDA/kernel-call.cu
  clang/test/Driver/cuda-simple.cu
  clang/test/SemaCUDA/Inputs/cuda.h
  clang/test/SemaCUDA/config-type.cu
  clang/unittests/ASTMatchers/ASTMatchersTest.h

Index: clang/unittests/ASTMatchers/ASTMatchersTest.h
===
--- clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -183,7 +183,9 @@
   "typedef struct cudaStream *cudaStream_t;"
   "int cudaConfigureCall(dim3 gridSize, dim3 blockSize,"
   "  size_t sharedSize = 0,"
-  "  cudaStream_t stream = 0);";
+  "  cudaStream_t stream = 0);"
+  "extern \"C\" unsigned __cudaPushCallConfiguration("
+  "dim3 gridDim, dim3 blockDim, size_t sharedMem = 0, void *stream = 0);";
 
   bool Found = false, DynamicFound = false;
   MatchFinder Finder;
Index: clang/test/SemaCUDA/config-type.cu
===
--- clang/test/SemaCUDA/config-type.cu
+++ clang/test/SemaCUDA/config-type.cu
@@ -1,3 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -target-sdk-version=8.0 -fsyntax-only -verify=legacy-launch %s
+// RUN: %clang_cc1 -target-sdk-version=9.2 -fsyntax-only -verify=new-launch %s
 
-void cudaConfigureCall(unsigned gridSize, unsigned blockSize); // expected-error {{must have scalar return type}}
+// legacy-launch-error@+1 {{must have scalar return type}}
+void cudaConfigureCall(unsigned gridSize, unsigned blockSize);
+// new-launch-error@+1 {{must have scalar return type}}
+void __cudaPushCallConfiguration(unsigned gridSize, unsigned blockSize);
Index: clang/test/SemaCUDA/Inputs/cuda.h
===
--- clang/test/SemaCUDA/Inputs/cuda.h
+++ clang/test/SemaCUDA/Inputs/cuda.h
@@ -18,9 +18,17 @@
 };
 
 typedef struct cudaStream *cudaStream_t;
+typedef enum cudaError {} cudaError_t;
 
-int cudaConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
-  cudaStream_t stream = 0);
+extern "C" int cudaConfigureCall(dim3 gridSize, dim3 blockSize,
+ size_t sharedSize = 0,
+ cudaStream_t stream = 0);
+extern "C" int __cudaPushCallConfiguration(dim3 gridSize, dim3 blockSize,
+   size_t sharedSize = 0,
+   cudaStream_t stream = 0);
+extern "C" cudaError_t cudaLaunchKernel(const void *func, dim3 gridDim,
+dim3 blockDim, void **args,
+size_t sharedMem, cudaStream_t stream);
 
 // Host- and device-side placement new overloads.
 void *operator new(__SIZE_TYPE__, void *p) { return p; }
Index: clang/test/Driver/cuda-simple.cu
===
--- clang/test/Driver/cuda-simple.cu
+++ clang/test/Driver/cuda-simple.cu
@@ -2,7 +2,7 @@
 // http://llvm.org/PR22936
 // RUN: %clang -nocudainc -nocudalib -Werror -fsyntax-only -c %s
 //
-// Verify that we pass -x cuda-cpp-output to compiler after 
+// Verify that we pass -x cuda-cpp-output to compiler after
 // preprocessing a CUDA file
 // RUN: %clang  -Werror -### -save-temps -c %s 2>&1 | FileCheck %s
 // CHECK: "-cc1"
@@ -14,7 +14,9 @@
 // Verify that compiler accepts CUDA syntax with "-x cuda-cpp-output".
 // RUN: %clang -Werror -fsyntax-only -x cuda-cpp-output -c %s
 
-int cudaConfigureCall(int, int);
+extern "C" int cudaConfigureCall(int, int);
+extern "C" int __cudaPushCallConfiguration(int, int);
+
 __attribute__((global)) void kernel() {}
 
 void func() {
Index: clang/test/CodeGenCUDA/kernel-call.cu
===
--- clang/test/CodeGenCUDA/kernel-call.cu
+++ clang/test/CodeGenCUDA/kernel-call.cu
@@ -1,5 +1,9 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s --check-prefixes=CUDA,CHECK
-// RUN: %clang_cc1 -x hip -emit-llvm %s -o - | FileCheck %s --check-prefixes=HIP,CHECK
+// RUN: %clang_cc1 -target-sdk-version=8.0 -emit-llvm %s -o - \
+// RUN: | FileCheck %s --check-prefixes=CUDA-OLD,CHECK
+// RUN: %clang_cc1 -target-sdk-version=9.2  -emit-llvm %s -o - \
+// RUN: | FileCheck %s --check-prefixes=CUDA-NEW,CHECK
+// RUN: %clang_cc1 -x hip -emit-llvm %s -o - \
+// RUN: | 

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

2019-01-31 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete created this revision.
Rakete added a reviewer: rsmith.

This fixes PR40552 by not showing the diagnostic that complains about different 
access specifiers, since the template does not have one.


Repository:
  rC Clang

https://reviews.llvm.org/D57540

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/cxx1z-class-template-argument-deduction.cpp


Index: test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -353,6 +353,13 @@
 template Protected(T) -> Protected; // expected-error 
{{different access}}
 template Private(T) -> Private; // expected-error 
{{different access}}
   };
+
+  // PR40552
+  template  struct Typo {}; // expected-note{{template is declared 
here}}
+  struct Type {
+Typo(); // expected-error{{deduction guide must be declared in the same 
scope}}
+// expected-error@-1{{deduction guide declaration without trailing return 
type}}
+  };
 }
 
 namespace rdar41903969 {
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -3175,7 +3175,7 @@
 //   declared] with the same access [as the template].
 if (auto *DG = dyn_cast(NonTemplateMember)) {
   auto *TD = DG->getDeducedTemplate();
-  if (AS != TD->getAccess()) {
+  if (AS != TD->getAccess() && TD->getAccess() != AS_none) {
 Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
 Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
 << TD->getAccess();


Index: test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -353,6 +353,13 @@
 template Protected(T) -> Protected; // expected-error {{different access}}
 template Private(T) -> Private; // expected-error {{different access}}
   };
+
+  // PR40552
+  template  struct Typo {}; // expected-note{{template is declared here}}
+  struct Type {
+Typo(); // expected-error{{deduction guide must be declared in the same scope}}
+// expected-error@-1{{deduction guide declaration without trailing return type}}
+  };
 }
 
 namespace rdar41903969 {
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -3175,7 +3175,7 @@
 //   declared] with the same access [as the template].
 if (auto *DG = dyn_cast(NonTemplateMember)) {
   auto *TD = DG->getDeducedTemplate();
-  if (AS != TD->getAccess()) {
+  if (AS != TD->getAccess() && TD->getAccess() != AS_none) {
 Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
 Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
 << TD->getAccess();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 184588.
ilya-biryukov marked 8 inline comments as done.
ilya-biryukov added a comment.
Herald added a project: clang.
Herald added a subscriber: llvm-commits.

- Remove Dummy.cpp
- Add halfOpenRangeTouches
- Add a comment about file vs expansion locations
- Move range manipulations with else and then to apply()
- Remove test fixture, turn test member functions into free functions
- Add checkTransform
- Replace a null check for getCond() with an isValid() check for the 
corresponding location.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56611

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/Dummy.cpp
  clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp
  clang-tools-extra/unittests/clangd/CMakeLists.txt
  clang-tools-extra/unittests/clangd/TweakTests.cpp

Index: clang-tools-extra/unittests/clangd/TweakTests.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clangd/TweakTests.cpp
@@ -0,0 +1,158 @@
+//===-- TweakTests.cpp --*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "Annotations.h"
+#include "SourceCode.h"
+#include "TestTU.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/Expr.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using llvm::Failed;
+using llvm::HasValue;
+using llvm::Succeeded;
+using ::testing::IsEmpty;
+using ::testing::Not;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+std::string markRange(llvm::StringRef Code, Range R) {
+  size_t Begin = llvm::cantFail(positionToOffset(Code, R.start));
+  size_t End = llvm::cantFail(positionToOffset(Code, R.end));
+  assert(Begin <= End);
+  if (Begin == End) // Mark a single point.
+return (Code.substr(0, Begin) + "^" + Code.substr(Begin)).str();
+  // Mark a range.
+  return (Code.substr(0, Begin) + "[[" + Code.substr(Begin, End - Begin) +
+  "]]" + Code.substr(End))
+  .str();
+}
+
+void checkAvailable(TweakID ID, llvm::StringRef Input, bool Available) {
+  Annotations Code(Input);
+  ASSERT_TRUE(0 < Code.points().size() || 0 < Code.ranges().size())
+  << "no points of interest specified";
+  TestTU TU;
+  TU.Filename = "foo.cpp";
+  TU.Code = Code.code();
+
+  ParsedAST AST = TU.build();
+
+  auto CheckOver = [&](Range Selection) {
+auto CursorLoc = llvm::cantFail(sourceLocationInMainFile(
+AST.getASTContext().getSourceManager(), Selection.start));
+auto T = prepareTweak(ID, Tweak::Selection{Code.code(), AST, CursorLoc});
+if (Available)
+  EXPECT_THAT_EXPECTED(T, Succeeded())
+  << "code is " << markRange(Code.code(), Selection);
+else
+  EXPECT_THAT_EXPECTED(T, Failed())
+  << "code is " << markRange(Code.code(), Selection);
+  };
+  for (auto P : Code.points())
+CheckOver(Range{P, P});
+  for (auto R : Code.ranges())
+CheckOver(R);
+}
+
+/// Checks action is available at every point and range marked in \p Input.
+void checkAvailable(TweakID ID, llvm::StringRef Input) {
+  return checkAvailable(ID, Input, /*Available=*/true);
+}
+
+/// Same as checkAvailable, but checks the action is not available.
+void checkNotAvailable(TweakID ID, llvm::StringRef Input) {
+  return checkAvailable(ID, Input, /*Available=*/false);
+}
+llvm::Expected apply(TweakID ID, llvm::StringRef Input) {
+  Annotations Code(Input);
+  Range SelectionRng;
+  if (Code.points().size() != 0) {
+assert(Code.ranges().size() == 0 &&
+   "both a cursor point and a selection range were specified");
+SelectionRng = Range{Code.point(), Code.point()};
+  } else {
+SelectionRng = Code.range();
+  }
+  TestTU TU;
+  TU.Filename = "foo.cpp";
+  TU.Code = Code.code();
+
+  ParsedAST AST = TU.build();
+  auto CursorLoc = llvm::cantFail(sourceLocationInMainFile(
+  AST.getASTContext().getSourceManager(), SelectionRng.start));
+  Tweak::Selection S = {Code.code(), AST, CursorLoc};
+
+  auto T = prepareTweak(ID, S);
+  if (!T)
+return T.takeError();
+  auto Replacements = (*T)->apply(S);
+  if (!Replacements)
+return Replacements.takeError();
+  return applyAllReplacements(Code.code(), *Replacements);
+}
+
+void checkTransform(llvm::StringRef ID, llvm::StringRef Input,
+llvm::StringRef Output) {
+  

[PATCH] D56611: [clangd] A code action to swap branches of an if statement

2019-01-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/SourceCode.h:63
 
+/// Turns a token range into a half-open range and checks its correctness.
+/// The resulting range will have only valid source location on both sides, 
both

sammccall wrote:
> I think the semantics of the locations (expansion vs spelling) need to be 
> spelled out here, at least in the comment.
Added a small comment, but it could probably be improved. Let me know what's 
missing.



Comment at: clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp:60
+Ctx.getSourceManager(), Ctx.getLangOpts(),
+SourceRange(If->getIfLoc(), If->getCond() ? If->getCond()->getEndLoc()
+  : If->getIfLoc()));

sammccall wrote:
> what's the case where the condition is null?
I initially thought of invalid parse trees (i.e. `if() {}`), but it turns out 
this never happens. 

From experience, it's better to assume everything can be null in the AST. This 
saves a lot of time chasing rare null dereferences later and a lot of time 
investigating whether something is null in a particular case we're facing.

In our particular case `IfStmt` seems to always have a condition, but the 
condition will have an invalid location when it's empty. I've added a test that 
the action still works (I see no reason why it shouldn't if we assume the 
parser recovery is good). Happy to discuss and adjust, though, let me know what 
you think.



Comment at: clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp:63
+if (R && (halfOpenRangeContains(Ctx.getSourceManager(), *R, CursorLoc) ||
+  R->getEnd() == CursorLoc)) {
+  Result = If;

sammccall wrote:
> the explicit checks for equality at the endpoint seem... odd
> do you need a halfOpenRangeTouches() or so?
Done. Thanks for the suggestion, this does make the code much clearer.



Comment at: clang-tools-extra/clangd/refactor/tweaks/SwapIfBranches.cpp:101
+
+  auto ThenRng = toHalfOpenFileRange(SrcMgr, Ctx.getLangOpts(),
+ If->getThen()->getSourceRange());

sammccall wrote:
> do this in apply()?
> 
> This is an example refactoring, if we have to add a bunch of checks because 
> it fires too often then we should try to solve that systematically.
Done.

This goes back to a similar comment about precomputing the replacements... 
Doing this in advance means we're not showing the check in some cases where it 
would later fail because of macros.

However, macros support is poor in the current state of the checks anyway, 
we'll need to invest some more time to make it better.



Comment at: clang-tools-extra/unittests/clangd/TweakTests.cpp:116
+TEST_F(TweakTest, SwapIfBranches) {
+  llvm::StringLiteral ID = "SwapIfBranches";
+

sammccall wrote:
> why StringLiteral here?
Seems like a good default for a constant string, i.e. it can compute the size 
at compile time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56611



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


[PATCH] D55782: Fix isInSystemMacro to handle pasted token

2019-01-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: include/clang/Basic/SourceManager.h:1466
+// its spelling is the scratch memory, so we take the parent context.
+if(isWrittenInScratchSpace(getSpellingLoc(loc))) {
+  return isInSystemHeader(getSpellingLoc(getImmediateMacroCallerLoc(loc)));

Please add a space after `if`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D55782



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


Re: r352793 - [WebAssembly] Add bulk memory target feature

2019-01-31 Thread Roman Lebedev via cfe-commits
And another review that omitted lists.


On Fri, Feb 1, 2019 at 12:02 AM Thomas Lively via cfe-commits
 wrote:
>
> Author: tlively
> Date: Thu Jan 31 13:02:19 2019
> New Revision: 352793
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352793=rev
> Log:
> [WebAssembly] Add bulk memory target feature
>
> Summary: Also clean up some preexisting target feature code.
>
> Reviewers: aheejin
>
> Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, jfb
>
> Differential Revision: https://reviews.llvm.org/D57495
>
> Modified:
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
> cfe/trunk/lib/Basic/Targets/WebAssembly.h
> cfe/trunk/test/Preprocessor/wasm-target-features.c
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=352793=352792=352793=diff
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Thu Jan 31 13:02:19 2019
> @@ -2155,6 +2155,8 @@ def msign_ext : Flag<["-"], "msign-ext">
>  def mno_sign_ext : Flag<["-"], "mno-sign-ext">, Group;
>  def mexception_handing : Flag<["-"], "mexception-handling">, 
> Group;
>  def mno_exception_handing : Flag<["-"], "mno-exception-handling">, 
> Group;
> +def mbulk_memory : Flag<["-"], "mbulk-memory">, Group;
> +def mno_bulk_memory : Flag<["-"], "mno-bulk-memory">, 
> Group;
>
>  def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
>Flags<[HelpHidden]>,
>
> Modified: cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/WebAssembly.cpp?rev=352793=352792=352793=diff
> ==
> --- cfe/trunk/lib/Basic/Targets/WebAssembly.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets/WebAssembly.cpp Thu Jan 31 13:02:19 2019
> @@ -40,6 +40,7 @@ bool WebAssemblyTargetInfo::hasFeature(S
>.Case("nontrapping-fptoint", HasNontrappingFPToInt)
>.Case("sign-ext", HasSignExt)
>.Case("exception-handling", HasExceptionHandling)
> +  .Case("bulk-memory", HasBulkMemory)
>.Default(false);
>  }
>
> @@ -59,6 +60,14 @@ void WebAssemblyTargetInfo::getTargetDef
>  Builder.defineMacro("__wasm_simd128__");
>if (SIMDLevel >= UnimplementedSIMD128)
>  Builder.defineMacro("__wasm_unimplemented_simd128__");
> +  if (HasNontrappingFPToInt)
> +Builder.defineMacro("__wasm_nontrapping_fptoint__");
> +  if (HasSignExt)
> +Builder.defineMacro("__wasm_sign_ext__");
> +  if (HasExceptionHandling)
> +Builder.defineMacro("__wasm_exception_handling__");
> +  if (HasBulkMemory)
> +Builder.defineMacro("__wasm_bulk_memory__");
>  }
>
>  void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap ,
> @@ -93,6 +102,8 @@ bool WebAssemblyTargetInfo::initFeatureM
>  Features["sign-ext"] = true;
>if (HasExceptionHandling)
>  Features["exception-handling"] = true;
> +  if (HasBulkMemory)
> +Features["bulk-memory"] = true;
>
>return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
>  }
> @@ -140,6 +151,14 @@ bool WebAssemblyTargetInfo::handleTarget
>HasExceptionHandling = false;
>continue;
>  }
> +if (Feature == "+bulk-memory") {
> +  HasBulkMemory = true;
> +  continue;
> +}
> +if (Feature == "-bulk-memory") {
> +  HasBulkMemory = false;
> +  continue;
> +}
>
>  Diags.Report(diag::err_opt_not_valid_with_opt)
>  << Feature << "-target-feature";
>
> Modified: cfe/trunk/lib/Basic/Targets/WebAssembly.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/WebAssembly.h?rev=352793=352792=352793=diff
> ==
> --- cfe/trunk/lib/Basic/Targets/WebAssembly.h (original)
> +++ cfe/trunk/lib/Basic/Targets/WebAssembly.h Thu Jan 31 13:02:19 2019
> @@ -30,14 +30,14 @@ class LLVM_LIBRARY_VISIBILITY WebAssembl
>  UnimplementedSIMD128,
>} SIMDLevel = NoSIMD;
>
> -  bool HasNontrappingFPToInt;
> -  bool HasSignExt;
> -  bool HasExceptionHandling;
> +  bool HasNontrappingFPToInt = false;
> +  bool HasSignExt = false;
> +  bool HasExceptionHandling = false;
> +  bool HasBulkMemory = false;
>
>  public:
>explicit WebAssemblyTargetInfo(const llvm::Triple , const TargetOptions 
> &)
> -  : TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false),
> -HasSignExt(false), HasExceptionHandling(false) {
> +  : TargetInfo(T) {
>  NoAsmVariants = true;
>  SuitableAlign = 128;
>  LargeArrayMinWidth = 128;
>
> Modified: cfe/trunk/test/Preprocessor/wasm-target-features.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/wasm-target-features.c?rev=352793=352792=352793=diff
> 

[PATCH] D56924: Handle ObjCCategoryDecl class extensions for print

2019-01-31 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman requested changes to this revision.
arphaman added a comment.
This revision now requires changes to proceed.

Do you know if this have an effect on the output of completion results or other 
tooling-based output?

A couple of requests:

- This behavior should be controlled by a printing policy flag 
`SupressUnwrittenScope` (specifically for the '::(class extension)').
- I also agree with Sam's comment. The property should still be qualified by 
the class name as well, e.g. `Obj::(class extension)::property`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924



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


[PATCH] D57527: Do not copy long double and 128-bit fp format from aux target for AMDGPU

2019-01-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D57527#1379287 , @rjmccall wrote:

> Explanatory comment, please.  Otherwise LGTM.


will do when committing.


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

https://reviews.llvm.org/D57527



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


r352793 - [WebAssembly] Add bulk memory target feature

2019-01-31 Thread Thomas Lively via cfe-commits
Author: tlively
Date: Thu Jan 31 13:02:19 2019
New Revision: 352793

URL: http://llvm.org/viewvc/llvm-project?rev=352793=rev
Log:
[WebAssembly] Add bulk memory target feature

Summary: Also clean up some preexisting target feature code.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, jfb

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
cfe/trunk/lib/Basic/Targets/WebAssembly.h
cfe/trunk/test/Preprocessor/wasm-target-features.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=352793=352792=352793=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Jan 31 13:02:19 2019
@@ -2155,6 +2155,8 @@ def msign_ext : Flag<["-"], "msign-ext">
 def mno_sign_ext : Flag<["-"], "mno-sign-ext">, Group;
 def mexception_handing : Flag<["-"], "mexception-handling">, 
Group;
 def mno_exception_handing : Flag<["-"], "mno-exception-handling">, 
Group;
+def mbulk_memory : Flag<["-"], "mbulk-memory">, Group;
+def mno_bulk_memory : Flag<["-"], "mno-bulk-memory">, 
Group;
 
 def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">,
   Flags<[HelpHidden]>,

Modified: cfe/trunk/lib/Basic/Targets/WebAssembly.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/WebAssembly.cpp?rev=352793=352792=352793=diff
==
--- cfe/trunk/lib/Basic/Targets/WebAssembly.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/WebAssembly.cpp Thu Jan 31 13:02:19 2019
@@ -40,6 +40,7 @@ bool WebAssemblyTargetInfo::hasFeature(S
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("sign-ext", HasSignExt)
   .Case("exception-handling", HasExceptionHandling)
+  .Case("bulk-memory", HasBulkMemory)
   .Default(false);
 }
 
@@ -59,6 +60,14 @@ void WebAssemblyTargetInfo::getTargetDef
 Builder.defineMacro("__wasm_simd128__");
   if (SIMDLevel >= UnimplementedSIMD128)
 Builder.defineMacro("__wasm_unimplemented_simd128__");
+  if (HasNontrappingFPToInt)
+Builder.defineMacro("__wasm_nontrapping_fptoint__");
+  if (HasSignExt)
+Builder.defineMacro("__wasm_sign_ext__");
+  if (HasExceptionHandling)
+Builder.defineMacro("__wasm_exception_handling__");
+  if (HasBulkMemory)
+Builder.defineMacro("__wasm_bulk_memory__");
 }
 
 void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap ,
@@ -93,6 +102,8 @@ bool WebAssemblyTargetInfo::initFeatureM
 Features["sign-ext"] = true;
   if (HasExceptionHandling)
 Features["exception-handling"] = true;
+  if (HasBulkMemory)
+Features["bulk-memory"] = true;
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
@@ -140,6 +151,14 @@ bool WebAssemblyTargetInfo::handleTarget
   HasExceptionHandling = false;
   continue;
 }
+if (Feature == "+bulk-memory") {
+  HasBulkMemory = true;
+  continue;
+}
+if (Feature == "-bulk-memory") {
+  HasBulkMemory = false;
+  continue;
+}
 
 Diags.Report(diag::err_opt_not_valid_with_opt)
 << Feature << "-target-feature";

Modified: cfe/trunk/lib/Basic/Targets/WebAssembly.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/WebAssembly.h?rev=352793=352792=352793=diff
==
--- cfe/trunk/lib/Basic/Targets/WebAssembly.h (original)
+++ cfe/trunk/lib/Basic/Targets/WebAssembly.h Thu Jan 31 13:02:19 2019
@@ -30,14 +30,14 @@ class LLVM_LIBRARY_VISIBILITY WebAssembl
 UnimplementedSIMD128,
   } SIMDLevel = NoSIMD;
 
-  bool HasNontrappingFPToInt;
-  bool HasSignExt;
-  bool HasExceptionHandling;
+  bool HasNontrappingFPToInt = false;
+  bool HasSignExt = false;
+  bool HasExceptionHandling = false;
+  bool HasBulkMemory = false;
 
 public:
   explicit WebAssemblyTargetInfo(const llvm::Triple , const TargetOptions &)
-  : TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false),
-HasSignExt(false), HasExceptionHandling(false) {
+  : TargetInfo(T) {
 NoAsmVariants = true;
 SuitableAlign = 128;
 LargeArrayMinWidth = 128;

Modified: cfe/trunk/test/Preprocessor/wasm-target-features.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/wasm-target-features.c?rev=352793=352792=352793=diff
==
--- cfe/trunk/test/Preprocessor/wasm-target-features.c (original)
+++ cfe/trunk/test/Preprocessor/wasm-target-features.c Thu Jan 31 13:02:19 2019
@@ -17,6 +17,42 @@
 // SIMD128-UNIMPLEMENTED:#define __wasm_unimplemented_simd128__ 1{{$}}
 //
 // RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: 

[PATCH] D57345: Make clang/test/Index/pch-from-libclang.c pass in more places

2019-01-31 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Yes, that should work.


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

https://reviews.llvm.org/D57345



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


[PATCH] D57438: [Sema][ObjC] Allow declaring ObjC pointer members in C++ unions under ARC

2019-01-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:7033
+  // member of an ObjC pointer type, except when it has an in-class 
initializer,
+  // it doesn't make the defaulted default constructor defined as deleted.
+  if (!FieldType.hasNonTrivialObjCLifetime() ||

This comment should be talking about non-trivial ownership rather than just 
general ObjC pointer-ish-ness.



Comment at: lib/Sema/SemaDeclCXX.cpp:7036
+  (CSM == Sema::CXXDefaultConstructor && FD->hasInClassInitializer()))
+return false;
+

I feel like this would be clearer as separate `if` statements; you can put 
separate comments on each.



Comment at: lib/Sema/SemaDeclCXX.cpp:7084
 
+  if (FD->getParent()->isUnion() &&
+  shouldDeleteForVariantObjCPtrMember(FD, FieldType))

I believe the right check for variant-ness is `inUnion()`, not 
`FD->getParent()->isUnion()`, since the latter can miss cases with e.g. 
anonymous `struct`s.



Comment at: test/SemaObjCXX/arc-0x.mm:164
+union {
+  union { // expected-note 2 {{'S1' is implicitly deleted because variant 
field '' has a non-trivial}} expected-note 4 {{'S1' is implicitly deleted 
because field '' has a deleted}}
+id f0; // expected-note 2 {{'' is implicitly deleted because variant 
field 'f0' is an ObjC pointer}}

ahatanak wrote:
> The diagnostic message here should say the special function is deleted 
> because the anonymous union's corresponding special function is deleted, but 
> when diagnosing a deleted copy assignment operator, it says the anonymous 
> union's special function is non-trivial. I'm not sure this is a bug, but I 
> see the same diagnostic message when I compile the following non-ObjC code:
> 
> ```
> struct S0 {
>   S0(const S0 &);
>   S0 =(const S0 &);
>   int *p;
> };
> 
> struct S1 {
>   union {
> union { // copy assignment operator of 'S1' is implicitly deleted because 
> variant field '' has a non-trivial copy assignment operator
>   S0 s10;
>   int b;
> };
> int c;
>   };
>   ~S1();
> };
> 
> S1 *x0;
> 
> void testC1(S1 *a0) {
>   *a0 = *x0; // error: object of type 'S1' cannot be assigned because its 
> copy assignment operator is implicitly deleted
>   *a0 = static_cast(*x0); // error: object of type 'S1' cannot be 
> assigned because its copy assignment operator is implicitly deleted
> }
> ```
> 
> It seems that this happens because the following code in 
> `Sema::ShouldDeleteSpecialMember` is preventing the method declaration from 
> being marked as deleted:
> 
> ```
>   // For an anonymous struct or union, the copy and assignment special members
>   // will never be used, so skip the check. For an anonymous union declared at
>   // namespace scope, the constructor and destructor are used.
>   if (CSM != CXXDefaultConstructor && CSM != CXXDestructor &&
>   RD->isAnonymousStructOrUnion())
> return false;
> ```
Well, if it's not different from the ordinary C++ treatment, I think we can 
justify just improving QoI there separately.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57438



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


[PATCH] D57315: [opaque pointer types] Add a FunctionCallee wrapper type, and use it.

2019-01-31 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352791: [opaque pointer types] Add a FunctionCallee wrapper 
type, and use it. (authored by jyknight, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57315?vs=183795=184576#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57315

Files:
  lib/CodeGen/CGExpr.cpp


Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -3056,7 +3056,7 @@
   bool WithDiag = !CGM.getCodeGenOpts().SanitizeTrap.has(Kind);
 
   llvm::CallInst *CheckCall;
-  llvm::Constant *SlowPathFn;
+  llvm::FunctionCallee SlowPathFn;
   if (WithDiag) {
 llvm::Constant *Info = llvm::ConstantStruct::getAnon(StaticArgs);
 auto *InfoPtr =
@@ -3078,7 +3078,8 @@
 CheckCall = Builder.CreateCall(SlowPathFn, {TypeId, Ptr});
   }
 
-  CGM.setDSOLocal(cast(SlowPathFn->stripPointerCasts()));
+  CGM.setDSOLocal(
+  cast(SlowPathFn.getCallee()->stripPointerCasts()));
   CheckCall->setDoesNotThrow();
 
   EmitBlock(Cont);


Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -3056,7 +3056,7 @@
   bool WithDiag = !CGM.getCodeGenOpts().SanitizeTrap.has(Kind);
 
   llvm::CallInst *CheckCall;
-  llvm::Constant *SlowPathFn;
+  llvm::FunctionCallee SlowPathFn;
   if (WithDiag) {
 llvm::Constant *Info = llvm::ConstantStruct::getAnon(StaticArgs);
 auto *InfoPtr =
@@ -3078,7 +3078,8 @@
 CheckCall = Builder.CreateCall(SlowPathFn, {TypeId, Ptr});
   }
 
-  CGM.setDSOLocal(cast(SlowPathFn->stripPointerCasts()));
+  CGM.setDSOLocal(
+  cast(SlowPathFn.getCallee()->stripPointerCasts()));
   CheckCall->setDoesNotThrow();
 
   EmitBlock(Cont);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57527: Do not copy long double and 128-bit fp format from aux target for AMDGPU

2019-01-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Explanatory comment, please.  Otherwise LGTM.


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

https://reviews.llvm.org/D57527



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


r352791 - [opaque pointer types] Add a FunctionCallee wrapper type, and use it.

2019-01-31 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Thu Jan 31 12:35:56 2019
New Revision: 352791

URL: http://llvm.org/viewvc/llvm-project?rev=352791=rev
Log:
[opaque pointer types] Add a FunctionCallee wrapper type, and use it.

The FunctionCallee type is effectively a {FunctionType*,Value*} pair,
and is a useful convenience to enable code to continue passing the
result of getOrInsertFunction() through to EmitCall, even once pointer
types lose their pointee-type.

Then:
- update the CallInst/InvokeInst instruction creation functions to
  take a Callee,
- modify getOrInsertFunction to return FunctionCallee, and
- update all callers appropriately.

One area of particular note is the change to the sanitizer
code. Previously, they had been casting the result of
`getOrInsertFunction` to a `Function*` via
`checkSanitizerInterfaceFunction`, and storing that. That would report
an error if someone had already inserted a function declaraction with
a mismatching signature.

However, in general, LLVM allows for such mismatches, as
`getOrInsertFunction` will automatically insert a bitcast if
needed. As part of this cleanup, cause the sanitizer code to do the
same. (It will call its functions using the expected signature,
however they may have been declared.)

Finally, in a small number of locations, callers of
`getOrInsertFunction` actually were expecting/requiring that a brand
new function was being created. In such cases, I've switched them to
Function::Create instead.

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

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

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=352791=352790=352791=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Thu Jan 31 12:35:56 2019
@@ -3056,7 +3056,7 @@ void CodeGenFunction::EmitCfiSlowPathChe
   bool WithDiag = !CGM.getCodeGenOpts().SanitizeTrap.has(Kind);
 
   llvm::CallInst *CheckCall;
-  llvm::Constant *SlowPathFn;
+  llvm::FunctionCallee SlowPathFn;
   if (WithDiag) {
 llvm::Constant *Info = llvm::ConstantStruct::getAnon(StaticArgs);
 auto *InfoPtr =
@@ -3078,7 +3078,8 @@ void CodeGenFunction::EmitCfiSlowPathChe
 CheckCall = Builder.CreateCall(SlowPathFn, {TypeId, Ptr});
   }
 
-  CGM.setDSOLocal(cast(SlowPathFn->stripPointerCasts()));
+  CGM.setDSOLocal(
+  cast(SlowPathFn.getCallee()->stripPointerCasts()));
   CheckCall->setDoesNotThrow();
 
   EmitBlock(Cont);


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


[PATCH] D54429: [analyzer] Creating standard Sphinx documentation

2019-01-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

I think let's get this up and running and slowly redirect links from the front 
page to the new docs until only the front page is left?




Comment at: docs/analyzer/checkers.rst:36-37
+
+.. literalinclude:: checkers/callandmessage_example.c
+:language: objc
+

Wow, that's pretty cool. Can we actually merge documentation with regression 
tests somehow, so that to automatically ensure that the documentation is 
correct?



Comment at: docs/analyzer/checkers.rst:2003
+View Exploded Graphs using GraphViz.
+

Szelethus wrote:
> While I would argue very strongly against the current website's every effort 
> at hiding implicit checkers, when we deliberately call this site a 
> documentation site, I definitely think that we should most include them here.
> 
> Although, don't sweat it too much just yet, while the structure is still 
> being decided upon.
Well, i mean, it's a good idea to make a distinction between a user guide from 
a developer guide. We should totally document these checkers, but we want to 
keep the user part of the guide user-comprehendable and, ideally, as short as 
possible. It's like people don't usually combine code comments with man pages; 
both are "documentation", but there's a huge difference between them driven by 
different target audience.

At the same time, we already have a better "Debug Checks" page.


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

https://reviews.llvm.org/D54429



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


[PATCH] D57527: Do not copy long double and 128-bit fp format from aux target for AMDGPU

2019-01-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D57527#1379159 , @rjmccall wrote:

> In D57527#1379088 , @yaxunl wrote:
>
> > In D57527#1379065 , @rjmccall 
> > wrote:
> >
> > > Okay, so you silently have an incompatible ABI for anything in the system 
> > > headers that mentions `long double`.  Do you have any plans to address or 
> > > work around that, or is the hope that it just doesn't matter?
> > >
> > > I feel like this should be a special case for AMDGPU rather than a 
> > > general behavior with aux targets.
> >
> >
> > If host do not pass long double to device we will be fine. So we need to 
> > diagnose long double kernel arguments. However I'd like to do it in 
> > separate patch since we want to fix the regression first.
>
>
> Okay.  Do you also need to look for global structs and other way that 
> information might be passed?  I suppose at some level you just have to 
> document it as a danger and treat further diagnostics as QoI.


I created a pull request to document long double usage in HIP 
https://github.com/ROCm-Developer-Tools/HIP/pull/890


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

https://reviews.llvm.org/D57527



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


[PATCH] D57527: Do not copy long double and 128-bit fp format from aux target for AMDGPU

2019-01-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 184569.
yaxunl retitled this revision from "Do not copy floating pointer format from 
aux target" to "Do not copy long double and 128-bit fp format from aux target 
for AMDGPU".
yaxunl edited the summary of this revision.
yaxunl added a comment.
Herald added subscribers: t-tye, tpr, dstuttard, nhaehnle, wdng, jvesely, 
kzhuravl.

Fix in AMDGPUTargetInfo.


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

https://reviews.llvm.org/D57527

Files:
  lib/Basic/Targets/AMDGPU.cpp
  test/CodeGenCUDA/types.cu


Index: test/CodeGenCUDA/types.cu
===
--- /dev/null
+++ test/CodeGenCUDA/types.cu
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple amdgcn -aux-triple x86_64 -fcuda-is-device 
-emit-llvm %s -o - | FileCheck -check-prefix=DEV %s
+// RUN: %clang_cc1 -triple x86_64 -aux-triple amdgcn -emit-llvm %s -o - | 
FileCheck -check-prefix=HOST %s
+
+#include "Inputs/cuda.h"
+
+// HOST: @ld_host = global x86_fp80 0xK
+long double ld_host;
+
+// DEV: @ld_device = addrspace(1) externally_initialized global double 
0.00e+00
+__device__ long double ld_device;
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -307,5 +307,12 @@
 }
 
 void AMDGPUTargetInfo::setAuxTarget(const TargetInfo *Aux) {
+  assert(HalfFormat == Aux->HalfFormat);
+  assert(FloatFormat == Aux->FloatFormat);
+  assert(DoubleFormat == Aux->DoubleFormat);
+  auto SaveLongDoubleFormat = LongDoubleFormat;
+  auto SaveFloat128Format = Float128Format;
   copyAuxTarget(Aux);
+  LongDoubleFormat = SaveLongDoubleFormat;
+  Float128Format = SaveFloat128Format;
 }


Index: test/CodeGenCUDA/types.cu
===
--- /dev/null
+++ test/CodeGenCUDA/types.cu
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple amdgcn -aux-triple x86_64 -fcuda-is-device -emit-llvm %s -o - | FileCheck -check-prefix=DEV %s
+// RUN: %clang_cc1 -triple x86_64 -aux-triple amdgcn -emit-llvm %s -o - | FileCheck -check-prefix=HOST %s
+
+#include "Inputs/cuda.h"
+
+// HOST: @ld_host = global x86_fp80 0xK
+long double ld_host;
+
+// DEV: @ld_device = addrspace(1) externally_initialized global double 0.00e+00
+__device__ long double ld_device;
Index: lib/Basic/Targets/AMDGPU.cpp
===
--- lib/Basic/Targets/AMDGPU.cpp
+++ lib/Basic/Targets/AMDGPU.cpp
@@ -307,5 +307,12 @@
 }
 
 void AMDGPUTargetInfo::setAuxTarget(const TargetInfo *Aux) {
+  assert(HalfFormat == Aux->HalfFormat);
+  assert(FloatFormat == Aux->FloatFormat);
+  assert(DoubleFormat == Aux->DoubleFormat);
+  auto SaveLongDoubleFormat = LongDoubleFormat;
+  auto SaveFloat128Format = Float128Format;
   copyAuxTarget(Aux);
+  LongDoubleFormat = SaveLongDoubleFormat;
+  Float128Format = SaveFloat128Format;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r352788 - [CodeComplete] Propagate preferred types through parser in more cases

2019-01-31 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Thu Jan 31 12:20:32 2019
New Revision: 352788

URL: http://llvm.org/viewvc/llvm-project?rev=352788=rev
Log:
[CodeComplete] Propagate preferred types through parser in more cases

Preferred types are used by code completion for ranking. This commit
considerably increases the number of points in code where those types
are propagated.

In order to avoid complicating signatures of Parser's methods, a
preferred type is kept as a member variable in the parser and updated
during parsing.

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

Modified:
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/unittests/Sema/CodeCompleteTest.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=352788=352787=352788=diff
==
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Thu Jan 31 12:20:32 2019
@@ -74,6 +74,10 @@ class Parser : public CodeCompletionHand
   // a statement).
   SourceLocation PrevTokLocation;
 
+  /// Tracks an expected type for the current token when parsing an expression.
+  /// Used by code completion for ranking.
+  PreferredTypeBuilder PreferredType;
+
   unsigned short ParenCount = 0, BracketCount = 0, BraceCount = 0;
   unsigned short MisplacedModuleBeginCount = 0;
 
@@ -840,6 +844,7 @@ private:
   ///
   class TentativeParsingAction {
 Parser 
+PreferredTypeBuilder PrevPreferredType;
 Token PrevTok;
 size_t PrevTentativelyDeclaredIdentifierCount;
 unsigned short PrevParenCount, PrevBracketCount, PrevBraceCount;
@@ -847,6 +852,7 @@ private:
 
   public:
 explicit TentativeParsingAction(Parser& p) : P(p) {
+  PrevPreferredType = P.PreferredType;
   PrevTok = P.Tok;
   PrevTentativelyDeclaredIdentifierCount =
   P.TentativelyDeclaredIdentifiers.size();
@@ -866,6 +872,7 @@ private:
 void Revert() {
   assert(isActive && "Parsing action was finished!");
   P.PP.Backtrack();
+  P.PreferredType = PrevPreferredType;
   P.Tok = PrevTok;
   P.TentativelyDeclaredIdentifiers.resize(
   PrevTentativelyDeclaredIdentifierCount);

Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=352788=352787=352788=diff
==
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Thu Jan 31 12:20:32 2019
@@ -380,6 +380,7 @@ public:
   /// if the expression is a variable initializer or a function argument, the
   /// type of the corresponding variable or function parameter.
   QualType getPreferredType() const { return PreferredType; }
+  void setPreferredType(QualType T) { PreferredType = T; }
 
   /// Retrieve the type of the base object in a member-access
   /// expression.

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=352788=352787=352788=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jan 31 12:20:32 2019
@@ -273,6 +273,41 @@ public:
   }
 };
 
+/// Keeps track of expected type during expression parsing. The type is tied to
+/// a particular token, all functions that update or consume the type take a
+/// start location of the token they are looking at as a parameter. This allows
+/// to avoid updating the type on hot paths in the parser.
+class PreferredTypeBuilder {
+public:
+  PreferredTypeBuilder() = default;
+  explicit PreferredTypeBuilder(QualType Type) : Type(Type) {}
+
+  void enterCondition(Sema , SourceLocation Tok);
+  void enterReturn(Sema , SourceLocation Tok);
+  void enterVariableInit(SourceLocation Tok, Decl *D);
+
+  void enterParenExpr(SourceLocation Tok, SourceLocation LParLoc);
+  void enterUnary(Sema , SourceLocation Tok, tok::TokenKind OpKind,
+  SourceLocation OpLoc);
+  void enterBinary(Sema , SourceLocation Tok, Expr *LHS, tok::TokenKind Op);
+  void enterMemAccess(Sema , SourceLocation Tok, Expr *Base);
+  void enterSubscript(Sema , SourceLocation Tok, Expr *LHS);
+  /// Handles all type casts, including C-style cast, C++ casts, etc.
+  void enterTypeCast(SourceLocation Tok, QualType CastType);
+
+  QualType get(SourceLocation Tok) const {
+if (Tok == ExpectedLoc)
+  return Type;
+return QualType();
+  }
+

[PATCH] D56723: [CodeComplete] Propagate preferred types through parser in more cases

2019-01-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC352788: [CodeComplete] Propagate preferred types through 
parser in more cases (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56723?vs=184038=184568#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D56723

Files:
  include/clang/Parse/Parser.h
  include/clang/Sema/CodeCompleteConsumer.h
  include/clang/Sema/Sema.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Parse/ParseStmt.cpp
  lib/Sema/SemaCodeComplete.cpp
  unittests/Sema/CodeCompleteTest.cpp

Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -273,6 +273,41 @@
   }
 };
 
+/// Keeps track of expected type during expression parsing. The type is tied to
+/// a particular token, all functions that update or consume the type take a
+/// start location of the token they are looking at as a parameter. This allows
+/// to avoid updating the type on hot paths in the parser.
+class PreferredTypeBuilder {
+public:
+  PreferredTypeBuilder() = default;
+  explicit PreferredTypeBuilder(QualType Type) : Type(Type) {}
+
+  void enterCondition(Sema , SourceLocation Tok);
+  void enterReturn(Sema , SourceLocation Tok);
+  void enterVariableInit(SourceLocation Tok, Decl *D);
+
+  void enterParenExpr(SourceLocation Tok, SourceLocation LParLoc);
+  void enterUnary(Sema , SourceLocation Tok, tok::TokenKind OpKind,
+  SourceLocation OpLoc);
+  void enterBinary(Sema , SourceLocation Tok, Expr *LHS, tok::TokenKind Op);
+  void enterMemAccess(Sema , SourceLocation Tok, Expr *Base);
+  void enterSubscript(Sema , SourceLocation Tok, Expr *LHS);
+  /// Handles all type casts, including C-style cast, C++ casts, etc.
+  void enterTypeCast(SourceLocation Tok, QualType CastType);
+
+  QualType get(SourceLocation Tok) const {
+if (Tok == ExpectedLoc)
+  return Type;
+return QualType();
+  }
+
+private:
+  /// Start position of a token for which we store expected type.
+  SourceLocation ExpectedLoc;
+  /// Expected type for a token starting at ExpectedLoc.
+  QualType Type;
+};
+
 /// Sema - This implements semantic analysis and AST building for C.
 class Sema {
   Sema(const Sema &) = delete;
@@ -10371,11 +10406,14 @@
   struct CodeCompleteExpressionData;
   void CodeCompleteExpression(Scope *S,
   const CodeCompleteExpressionData );
-  void CodeCompleteExpression(Scope *S, QualType PreferredType);
+  void CodeCompleteExpression(Scope *S, QualType PreferredType,
+  bool IsParenthesized = false);
   void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase,
SourceLocation OpLoc, bool IsArrow,
-   bool IsBaseExprStatement);
-  void CodeCompletePostfixExpression(Scope *S, ExprResult LHS);
+   bool IsBaseExprStatement,
+   QualType PreferredType);
+  void CodeCompletePostfixExpression(Scope *S, ExprResult LHS,
+ QualType PreferredType);
   void CodeCompleteTag(Scope *S, unsigned TagSpec);
   void CodeCompleteTypeQualifiers(DeclSpec );
   void CodeCompleteFunctionQualifiers(DeclSpec , Declarator ,
@@ -10397,9 +10435,7 @@
   IdentifierInfo *II,
   SourceLocation OpenParLoc);
   void CodeCompleteInitializer(Scope *S, Decl *D);
-  void CodeCompleteReturn(Scope *S);
   void CodeCompleteAfterIf(Scope *S);
-  void CodeCompleteBinaryRHS(Scope *S, Expr *LHS, tok::TokenKind Op);
 
   void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec ,
bool EnteringContext, QualType BaseType);
Index: include/clang/Sema/CodeCompleteConsumer.h
===
--- include/clang/Sema/CodeCompleteConsumer.h
+++ include/clang/Sema/CodeCompleteConsumer.h
@@ -380,6 +380,7 @@
   /// if the expression is a variable initializer or a function argument, the
   /// type of the corresponding variable or function parameter.
   QualType getPreferredType() const { return PreferredType; }
+  void setPreferredType(QualType T) { PreferredType = T; }
 
   /// Retrieve the type of the base object in a member-access
   /// expression.
Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -74,6 +74,10 @@
   // a statement).
   SourceLocation PrevTokLocation;
 
+  /// Tracks an expected type for the current token when parsing an expression.
+  /// Used by code completion for ranking.
+  PreferredTypeBuilder 

[PATCH] D57472: [AST] Extract ASTDumpTraverser class from ASTDumper

2019-01-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/AST/ASTDumpTraverser.h:31
+
+ASTDumpTraverser traverses the Clang AST for dumping purposes
+

Missing full stop at the end of the sentence.



Comment at: include/clang/AST/ASTDumpTraverser.h:38
+struct
+{
+  template 

Format this with the usual LLVM style.

Also, I'd remove a bit of the vertical whitespace between the `Visit()` 
functions.



Comment at: include/clang/AST/ASTDumpTraverser.h:83
+
+  NodeVisitorType () { return getDerived().doGetNodeVisitor(); }
+  Derived () { return *static_cast(this); }

Given that `ASTDumpTraverser` is itself a visitor of nodes, I wonder if a 
better name for this would be `getNodeDumper()` or something (and similarly 
renaming the template parameter)?



Comment at: include/clang/AST/ASTDumpTraverser.h:91-92
+  void Visit(const Decl *D) {
+getNodeVisitor().AddChild([=] {
+  getNodeVisitor().Visit(D);
+  if (!D)

I wonder how often we will spot calls to `Visit()` that were meant to go to 
`getNodeVisitor().Visit()`? Probably not too many because the output would be 
wrong except if you got unlucky, but I do wonder if the naming similarities 
will cause confusion as people do new development.

Not certain there's anything to be changed here, but wanted to raise the point 
in case it sparked discussion.



Comment at: lib/AST/ASTDumper.cpp:63
 
-  if (const auto *C = dyn_cast(D))
-for (const auto *I : C->inits())
-  Visit(I);
-
-  if (D->doesThisDeclarationHaveABody())
-Visit(D->getBody());
-}
-
-void VisitFieldDecl(const FieldDecl *D) {
-  if (D->isBitField())
-Visit(D->getBitWidth());
-  if (Expr *Init = D->getInClassInitializer())
-Visit(Init);
-}
-
-void VisitVarDecl(const VarDecl *D) {
-  if (D->hasInit())
-Visit(D->getInit());
-}
-
-void VisitDecompositionDecl(const DecompositionDecl *D) {
-  VisitVarDecl(D);
-  for (const auto *B : D->bindings())
-Visit(B);
-}
-
-void VisitBindingDecl(const BindingDecl *D) {
-  if (const auto *E = D->getBinding())
-Visit(E);
-}
-
-void VisitFileScopeAsmDecl(const FileScopeAsmDecl *D) {
-  Visit(D->getAsmString());
-}
-
-void VisitCapturedDecl(const CapturedDecl *D) { Visit(D->getBody()); }
-
-void VisitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D) {
-  for (const auto *E : D->varlists())
-Visit(E);
-}
-
-void VisitOMPDeclareReductionDecl(const OMPDeclareReductionDecl *D) {
-  Visit(D->getCombiner());
-  if (const auto *Initializer = D->getInitializer())
-Visit(Initializer);
-}
-
-void VisitOMPCapturedExprDecl(const OMPCapturedExprDecl *D) {
-  Visit(D->getInit());
-}
-
-template 
-void dumpTemplateDeclSpecialization(const SpecializationDecl *D,
-bool DumpExplicitInst,
-bool DumpRefOnly);
-template 
-void dumpTemplateDecl(const TemplateDecl *D, bool DumpExplicitInst);
-
-void VisitTypeAliasDecl(const TypeAliasDecl *D) {
-  Visit(D->getUnderlyingType());
-}
-
-void VisitTypeAliasTemplateDecl(const TypeAliasTemplateDecl *D) {
-  dumpTemplateParameters(D->getTemplateParameters());
-  Visit(D->getTemplatedDecl());
-}
-
-void VisitStaticAssertDecl(const StaticAssertDecl *D) {
-  Visit(D->getAssertExpr());
-  Visit(D->getMessage());
-}
-void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D);
-void VisitClassTemplateDecl(const ClassTemplateDecl *D);
-
-void VisitClassTemplateSpecializationDecl(
-const ClassTemplateSpecializationDecl *D) {
-  dumpTemplateArgumentList(D->getTemplateArgs());
-}
-
-void VisitClassTemplatePartialSpecializationDecl(
-const ClassTemplatePartialSpecializationDecl *D) {
-  VisitClassTemplateSpecializationDecl(D);
-  dumpTemplateParameters(D->getTemplateParameters());
-}
-
-void VisitClassScopeFunctionSpecializationDecl(
-const ClassScopeFunctionSpecializationDecl *D) {
-  Visit(D->getSpecialization());
-  if (D->hasExplicitTemplateArgs())
-dumpTemplateArgumentListInfo(D->templateArgs());
-}
-void VisitVarTemplateDecl(const VarTemplateDecl *D);
-
-void VisitBuiltinTemplateDecl(const BuiltinTemplateDecl *D) {
-  dumpTemplateParameters(D->getTemplateParameters());
-}
-
-void
-VisitVarTemplateSpecializationDecl(const VarTemplateSpecializationDecl *D) 
{
-  dumpTemplateArgumentList(D->getTemplateArgs());
-  VisitVarDecl(D);
-}
-
-void VisitVarTemplatePartialSpecializationDecl(
-const VarTemplatePartialSpecializationDecl *D) {
-  dumpTemplateParameters(D->getTemplateParameters());
-  

[PATCH] D57345: Make clang/test/Index/pch-from-libclang.c pass in more places

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

Could it be somewhere in lib/Driver? libclang depends on lib/Frontend which 
depends on lib/Driver -- is there any reason libclang can't depend on 
lib/Driver?


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

https://reviews.llvm.org/D57345



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


[PATCH] D57532: [Index] Make sure c-index-test finds libc++ on Mac

2019-01-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

I'm not sure who the owners of c-index-test are, so adding people who touched 
the file recently or might be interested in this landing.
Suggestions for other reviewers are **very** welcome.

Still struggling to make one test pass: `Index/index-file.cu` fails with:

  .../index-file.cu:8:20: error: CHECK-HOST-NOT: excluded string found in input
  // CHECK-HOST-NOT: macro definition=__CUDA_ARCH__
 ^
  :3631:48: note: found here
  // CHECK: __clang_cuda_runtime_wrapper.h:77:9: macro definition=__CUDA_ARCH__ 
Extent=[77:9 - 77:26]

The catch is that I see this line both after and **before** my change when I 
run the corresponding invocation of `c-index-test` with `--cuda-host-only` by 
hand.
Any ideas why this might be happening? How do I emulate the environment of 
`llvm-lit` completely to get a repro?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57532



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


[PATCH] D57532: [Index] Make sure c-index-test finds libc++ on Mac

2019-01-31 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added reviewers: thakis, ioeric.
Herald added a reviewer: EricWF.
Herald added subscribers: llvm-commits, arphaman.
Herald added a project: clang.

Specifically, the version of libc++ that lives alongside the c-index-test
binary. After r348365 driver relies on a correct value of argv[0] to find
libc++ and 'c-index-test' did not pass proper argv[0] when calling the
driver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D57532

Files:
  clang/test/Index/record-completion-invocation.c
  clang/test/Index/record-parsing-invocation.c
  clang/tools/c-index-test/c-index-test.c

Index: clang/tools/c-index-test/c-index-test.c
===
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -1,15 +1,16 @@
 /* c-index-test.c */
 
-#include "clang/Config/config.h"
-#include "clang-c/Index.h"
-#include "clang-c/CXCompilationDatabase.h"
 #include "clang-c/BuildSystem.h"
+#include "clang-c/CXCompilationDatabase.h"
 #include "clang-c/Documentation.h"
+#include "clang-c/Index.h"
+#include "clang/Config/config.h"
+#include 
 #include 
-#include 
+#include 
 #include 
+#include 
 #include 
-#include 
 
 #ifdef CLANG_HAVE_LIBXML
 #include 
@@ -64,6 +65,15 @@
 extern char *dirname(char *);
 #endif
 
+static void PrependArgv0(const char *argv0, int argc, const char **argv,
+ const char **Out) {
+  int I;
+  assert(Out != 0);
+  Out[0] = argv0;
+  for (I = 1; I < argc + 1; ++I)
+Out[I] = argv[I - 1];
+}
+
 /** Return the default parsing options. */
 static unsigned getDefaultParsingOptions() {
   unsigned options = CXTranslationUnit_DetailedPreprocessingRecord;
@@ -1834,7 +1844,7 @@
 /* Target information testing.*/
 /**/
 
-static int print_target_info(int argc, const char **argv) {
+static int print_target_info(const char *argv0, int argc, const char **argv) {
   CXIndex Idx;
   CXTranslationUnit TU;
   CXTargetInfo TargetInfo;
@@ -1842,6 +1852,8 @@
   const char *FileName;
   enum CXErrorCode Err;
   int PointerWidth;
+  const char **ParseArgv;
+  int ParseArgc;
 
   if (argc == 0) {
 fprintf(stderr, "No filename specified\n");
@@ -1850,13 +1862,19 @@
 
   FileName = argv[1];
 
+  ParseArgc = argc + 1;
+  ParseArgv = malloc(sizeof(char *) * ParseArgc);
+  PrependArgv0(argv0, ParseArgc - 1, argv, ParseArgv);
+
   Idx = clang_createIndex(0, 1);
-  Err = clang_parseTranslationUnit2(Idx, FileName, argv, argc, NULL, 0,
-getDefaultParsingOptions(), );
+  Err = clang_parseTranslationUnit2FullArgv(Idx, FileName, ParseArgv, ParseArgc,
+NULL, 0, getDefaultParsingOptions(),
+);
   if (Err != CXError_Success) {
 fprintf(stderr, "Couldn't parse translation unit!\n");
 describeLibclangFailure(Err);
 clang_disposeIndex(Idx);
+free(ParseArgv);
 return 1;
   }
 
@@ -1872,6 +1890,7 @@
   clang_TargetInfo_dispose(TargetInfo);
   clang_disposeTranslationUnit(TU);
   clang_disposeIndex(Idx);
+  free(ParseArgv);
   return 0;
 }
 
@@ -1956,7 +1975,7 @@
   return result;
 }
 
-int perform_test_load_source(int argc, const char **argv,
+int perform_test_load_source(const char *argv0, int argc, const char **argv,
  const char *filter, CXCursorVisitor Visitor,
  PostVisitTU PV) {
   CXIndex Idx;
@@ -1969,6 +1988,8 @@
   unsigned Repeats = 0;
   unsigned I;
   const char *InvocationPath;
+  const char **ParseArgv;
+  int ParseArgc;
 
   Idx = clang_createIndex(/* excludeDeclsFromPCH */
   (!strcmp(filter, "local") ||
@@ -1994,16 +2015,19 @@
   if (getenv("CINDEXTEST_EDITING"))
 Repeats = 5;
 
-  Err = clang_parseTranslationUnit2(Idx, 0,
-argv + num_unsaved_files,
-argc - num_unsaved_files,
-unsaved_files, num_unsaved_files,
-getDefaultParsingOptions(), );
+  ParseArgc = argc - num_unsaved_files + 1;
+  ParseArgv = malloc(sizeof(char *) * ParseArgc);
+  PrependArgv0(argv0, ParseArgc - 1, argv + num_unsaved_files, ParseArgv);
+
+  Err = clang_parseTranslationUnit2FullArgv(Idx, 0, ParseArgv, ParseArgc,
+unsaved_files, num_unsaved_files,
+getDefaultParsingOptions(), );
   if (Err != CXError_Success) {
 fprintf(stderr, "Unable to load translation unit!\n");
 describeLibclangFailure(Err);
 free_remapped_files(unsaved_files, num_unsaved_files);
 clang_disposeIndex(Idx);
+free(ParseArgv);
 return 1;
   }
 
@@ -2020,6 +2044,7 @@
 describeLibclangFailure(Err);

[PATCH] D57527: Do not copy floating pointer format from aux target

2019-01-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D57527#1379088 , @yaxunl wrote:

> In D57527#1379065 , @rjmccall wrote:
>
> > Okay, so you silently have an incompatible ABI for anything in the system 
> > headers that mentions `long double`.  Do you have any plans to address or 
> > work around that, or is the hope that it just doesn't matter?
> >
> > I feel like this should be a special case for AMDGPU rather than a general 
> > behavior with aux targets.
>
>
> If host do not pass long double to device we will be fine. So we need to 
> diagnose long double kernel arguments. However I'd like to do it in separate 
> patch since we want to fix the regression first.


Okay.  Do you also need to look for global structs and other way that 
information might be passed?  I suppose at some level you just have to document 
it as a danger and treat further diagnostics as QoI.

> Since this maybe a special case for AMDGPU, I will fix it in AMDGPUTargetInfo.

Alright.  That should be as easy as saving the old value and restoring it after 
the overwrite.


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

https://reviews.llvm.org/D57527



___
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-01-31 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore updated this revision to Diff 184553.
stephanemoore marked an inline comment as done.
stephanemoore added a comment.

Add comment explaining that builtin function call generates implicit function 
declaration and update calling function name for improved clarity.


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: 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; }
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))
___
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-01-31 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore marked 3 inline comments as done.
stephanemoore added a comment.

Thanks for the review!


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


[PATCH] D57527: Do not copy floating pointer format from aux target

2019-01-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D57527#1379065 , @rjmccall wrote:

> Okay, so you silently have an incompatible ABI for anything in the system 
> headers that mentions `long double`.  Do you have any plans to address or 
> work around that, or is the hope that it just doesn't matter?
>
> I feel like this should be a special case for AMDGPU rather than a general 
> behavior with aux targets.


If host do not pass long double to device we will be fine. So we need to 
diagnose long double kernel arguments. However I'd like to do it in separate 
patch since we want to fix the regression first.

Since this maybe a special case for AMDGPU, I will fix it in AMDGPUTargetInfo.


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

https://reviews.llvm.org/D57527



___
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-01-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with a commenting request.




Comment at: test/clang-tidy/google-objc-function-naming.m:5-8
+static void TestImplicitlyDefinedFunction(int a) {
+  printf("%d", a);
+}
+

stephanemoore wrote:
> aaron.ballman wrote:
> > Excuse my ignorance, but I don't see what about this function definition is 
> > testing an implicitly-defined function. Doesn't the `#import` above bring 
> > in the declaration for `printf()`, while `TestImplicitlyDefinedFunction()` 
> > itself is explicitly defined?
> **tl;dr**: Yes, we have an explicit function declaration but clang generates 
> an implicit function declaration as well.
> 
> I found this surprising as well but the AST generated from this includes an 
> implicit function declaration. Even though we have an explicit function 
> declaration for `printf` from , clang still generates an implicit 
> declaration of `printf` 廊 Similar behavior occurs with other functions, e.g., 
> `memset` and various C11 atomic functions.
> 
> I have been spelunking in search of the reason but I do not have a full 
> understanding yet. I believe I have insight into the underlying mechanism 
> though: the behavior seems linked to builtin functions (e.g., `printf` is 
> declared as a builtin function 
> [here](https://github.com/llvm/llvm-project/blob/2946cd7/clang/include/clang/Basic/Builtins.def#L889)).
>  I have attached a small sample program and an associated AST dump below to 
> demonstrate the behavior.
> 
> ❧
> 
> ```
> $ cat /tmp/test.c
> extern int printf(const char *format, ...);
> 
> int main(int argc, const char **argv) {
>   printf("%d", argc);
>   return 0;
> }
> ```
> 
> ```
> $ clang -cc1 -ast-dump /tmp/test.c 
> TranslationUnitDecl 0x561b9f7fe570 <> 
> |-TypedefDecl 0x561b9f7feac0 <>  implicit 
> __int128_t '__int128'
> | `-BuiltinType 0x561b9f7fe7e0 '__int128'
> |-TypedefDecl 0x561b9f7feb28 <>  implicit 
> __uint128_t 'unsigned __int128'
> | `-BuiltinType 0x561b9f7fe800 'unsigned __int128'
> |-TypedefDecl 0x561b9f7fedf8 <>  implicit 
> __NSConstantString 'struct __NSConstantString_tag'
> | `-RecordType 0x561b9f7fec00 'struct __NSConstantString_tag'
> |   `-Record 0x561b9f7feb78 '__NSConstantString_tag'
> |-TypedefDecl 0x561b9f7fee90 <>  implicit 
> __builtin_ms_va_list 'char *'
> | `-PointerType 0x561b9f7fee50 'char *'
> |   `-BuiltinType 0x561b9f7fe600 'char'
> |-TypedefDecl 0x561b9f7ff158 <>  implicit 
> __builtin_va_list 'struct __va_list_tag [1]'
> | `-ConstantArrayType 0x561b9f7ff100 'struct __va_list_tag [1]' 1 
> |   `-RecordType 0x561b9f7fef70 'struct __va_list_tag'
> | `-Record 0x561b9f7feee0 '__va_list_tag'
> |-FunctionDecl 0x561b9f851860  col:12 implicit used printf 
> 'int (const char *, ...)' extern
> | |-ParmVarDecl 0x561b9f8518f8 <>  'const char *'
> | `-FormatAttr 0x561b9f851960  Implicit printf 1 2
> |-FunctionDecl 0x561b9f8519b8 prev 0x561b9f851860  col:12 used 
> printf 'int (const char *, ...)' extern
> | |-ParmVarDecl 0x561b9f7ff1c0  col:31 format 'const char *'
> | `-FormatAttr 0x561b9f851a90  Inherited printf 1 2
> `-FunctionDecl 0x561b9f851c48  line:3:5 main 'int (int, 
> const char **)'
>   |-ParmVarDecl 0x561b9f851ac8  col:14 used argc 'int'
>   |-ParmVarDecl 0x561b9f851b70  col:33 argv 'const char **'
>   `-CompoundStmt 0x561b9f851f08 
> |-CallExpr 0x561b9f851e50  'int'
> | |-ImplicitCastExpr 0x561b9f851e38  'int (*)(const char *, ...)' 
> 
> | | `-DeclRefExpr 0x561b9f851d58  'int (const char *, ...)' 
> Function 0x561b9f8519b8 'printf' 'int (const char *, ...)'
> | |-ImplicitCastExpr 0x561b9f851ea0  'const char *' 
> | | `-ImplicitCastExpr 0x561b9f851e88  'char *' 
> 
> | |   `-StringLiteral 0x561b9f851db8  'char [3]' lvalue "%d"
> | `-ImplicitCastExpr 0x561b9f851eb8  'int' 
> |   `-DeclRefExpr 0x561b9f851de8  'int' lvalue ParmVar 
> 0x561b9f851ac8 'argc' 'int'
> `-ReturnStmt 0x561b9f851ef0 
>   `-IntegerLiteral 0x561b9f851ed0  'int' 0
> ```
> 
> Note the presence of implicit and explicit declarations of `printf` in the 
> AST dump 樂
Well that certainly is neat; I didn't know that! Can you add some comments 
above the function call to explain that to the next person reading the test?


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


[PATCH] D45978: dllexport const variables must have external linkage.

2019-01-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: majnemer.
aaron.ballman added a subscriber: majnemer.
aaron.ballman added inline comments.



Comment at: test/Sema/dllexport.c:70
+// const variables
+__declspec(dllexport) int const x = 3;
 

zahiraam wrote:
> aaron.ballman wrote:
> > Can you think of any redeclaration scenarios we should also test? e.g., 
> > weird cases like this:
> > ```
> > extern int const x;
> > __declspec(dllexport) int const x = 3;
> > ```
> > which brings up an interesting question -- does MSVC truly treat it as 
> > though it were extern, or just only-kinda-sorta treat it like it was 
> > extern? e.g., can you do this:
> > ```
> > __declspec(dllexport) const int j;
> > ```
> > Regardless, having some codegen tests demonstrating that the variable has 
> > the correct semantics that we're emulating would be nice.
> With MSVC:
> 
> ksh-3.2$ cat t2.cpp
> __declspec(dllexport) const int j;
> ksh-3.2$
> 
> ksh-3.2$ cl -c t2.cpp
> Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
> Copyright (C) Microsoft Corporation.  All rights reserved.
> 
> t2.cpp
> t2.cpp(1): error C2734: 'j': 'const' object must be initialized if not 
> 'extern'
> 
> ksh-3.2$ cat t3.cpp
> __declspec(dllexport) int const x = 3;
> int main ()
> {
>   int y = x + 10;
> 
>   return y;
> }
> 
> ksh-3.2$ cl -c t3.cpp
> Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
> Copyright (C) Microsoft Corporation.  All rights reserved.
> 
> t3.cpp
> ksh-3.2$ dumpbin /symbols t3.obj | grep External
> **008  SECT3  notype ()External | main**
> ksh-3.2$
> ksh-3.2$ cat t4.cpp
> extern int const x = 3;
> int main ()
> {
>   int y = x + 10;
> 
>   return y;
> }
> 
> ksh-3.2$ cl -c t4.cpp
> Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
> Copyright (C) Microsoft Corporation.  All rights reserved.
> 
> t4.cpp
> ksh-3.2$ dumpbin /symbols t4.obj | grep External
> **008  SECT3  notype   External | ?x@@3HB (int const x)
> 00B  SECT4  notype ()External | main**
> ksh-3.2$
> 
> So we see that with dllexport, the ony symbol marked with "External" is main. 
> With "extern" both main and x are marked as External.
> 
> With clang without the patch:
> ksh-3.2$ clang -c t2.cpp
> t2.cpp:1:33: error: default initialization of an object of const type 'const 
> int'
> __declspec(dllexport) const int j;
> ^
>   = 0
> t2.cpp:1:33: error: 'j' must have external linkage when declared 'dllexport'
> 2 errors generated.
> ksh-3.2$
> ksh-3.2$ clang -c t3.cpp
> t3.cpp:1:33: error: 'x' must have external linkage when declared 'dllexport'
> __declspec(dllexport) int const x = 3;
> ^
> 1 error generated.
> ksh-3.2$ clang -c t4.cpp
> ksh-3.2$ dumpbin /symbols t4.o | grep External
> **00F  SECT1  notype ()External | main
> 010  SECT5  notype   External | ?x@@3HB (int const x)**
> ksh-3.2$
> 
> Clang with patch above at the right place (I am thinking in  
> Sema::AddInitializerToDecl):
> 
> ksh-3.2$ clang -c t3.cpp
> ksh-3.2$ dumpbin /symbols t3.o | grep External
> **00E  SECT1  notype ()External | main
> 00F  SECT5  notype   External | ?x@@3HB (int const x)**
> ksh-3.2$
> ksh-3.2$ clang -c t4.cpp
> ksh-3.2$ dumpbin /symbols t4.o | grep External
> 00C  SECT1  notype ()External | main
> 00D  SECT5  notype   External | ?x@@3HB (int const x)
> ksh-3.2$
> 
> Both MSVC and clang have the same behavior with t2.cpp.
> With the patch clang will have the same beahvior than MSVC when extern and 
> dllexport are used. That's not  quite what MSVC's behavior is!
> What are your thoughts?
> Thanks.
> 
> 
Neat, so MSVC treats it as sort-of-extern-but-sort-of-not. I can't tell whether 
this is intentional and we want to be compatible, or whether this is a bug in 
MSVC (and if so, is it one uses are relying on and we need to emulate). I'm not 
certain what the best answer is here. Perhaps @rnk or @majnemer have opinions?


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

https://reviews.llvm.org/D45978



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


[PATCH] D57527: Do not copy floating pointer format from aux target

2019-01-31 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay, so you silently have an incompatible ABI for anything in the system 
headers that mentions `long double`.  Do you have any plans to address or work 
around that, or is the hope that it just doesn't matter?

I feel like this should be a special case for AMDGPU rather than a general 
behavior with aux targets.


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

https://reviews.llvm.org/D57527



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


  1   2   >