[PATCH] D58321: [WIP] Support for relative vtables

2019-02-15 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
Herald added subscribers: cfe-commits, jdoerfert.
Herald added a project: clang.

This is a revisit to D20749  which introduces 
a flag that enables the relative ABI described in 
https://bugs.llvm.org/show_bug.cgi?id=26723.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58321

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/VTableBuilder.h
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclCXX.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CGVTables.h
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenCXX/debug-info-virtual-fn-relative.cpp
  clang/test/CodeGenCXX/type-metadata.cpp
  clang/test/CodeGenCXX/vtable-relative-abi.cpp
  clang/test/Driver/unstable-cxx-abi-vtables.cpp
  clang/test/SemaCXX/unstable-cxx-abi.cpp

Index: clang/test/SemaCXX/unstable-cxx-abi.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/unstable-cxx-abi.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 %s -w -std=c++11 -fsyntax-only -verify -flto-relative-c++-abi-vtables -fvisibility hidden
+
+struct __attribute__((visibility("default"))) platform { // expected-note 2{{base 'platform' uses the platform ABI}}
+  virtual void f();
+};
+struct relative { // expected-note 2{{base 'relative' uses the relative ABI}}
+  virtual void f();
+};
+
+struct mixed_bases : platform, relative {}; // expected-error {{inconsistent ABI for class 'mixed_bases'}}
+struct mixed_base_vbase : platform, virtual relative {}; // expected-error {{inconsistent ABI for class 'mixed_base_vbase'}}
+
+void f() {
+  struct relative2 {
+virtual void f();
+  };
+  struct relative_derived : relative, relative2 {};
+}
+
+struct __attribute__((visibility("default"))) platform2 {
+  void mf() {
+struct platform3 {
+  virtual void f();
+};
+struct platform_derived : platform, platform3 {};
+  }
+};
+
+struct __attribute__((visibility("default"))) non_dynamic {};
+
+struct relative_derived : non_dynamic, relative {};
+struct platform_derived : non_dynamic, platform {};
+
+struct relative_derived2 : relative_derived, relative {};
+struct platform_derived2 : platform_derived, platform {};
Index: clang/test/Driver/unstable-cxx-abi-vtables.cpp
===
--- /dev/null
+++ clang/test/Driver/unstable-cxx-abi-vtables.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang -flto-relative-c++-abi-vtables -### %s 2>&1 | FileCheck -check-prefix=CLASSES %s
+// CLASSES: '-fwhole-program-vtables' only allowed with '-flto'
+//
+// RUN: %clang -flto -flto-relative-c++-abi-vtables -### %s 2>&1 | FileCheck -check-prefix=LTO-CLASSES %s
+// LTO-CLASSES: "-flto-relative-c++-abi-vtables"
Index: clang/test/CodeGenCXX/vtable-relative-abi.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/vtable-relative-abi.cpp
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 %s -flto -flto-unit -triple x86_64-unknown-linux-gnu -fvisibility hidden -flto-relative-c++-abi-vtables -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ITANIUM %s
+// RUN: %clang_cc1 %s -flto -flto-unit -triple x86_64-unknown-windows-msvc -flto-relative-c++-abi-vtables -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MS %s
+// RUN: %clang_cc1 %s -flto -flto-unit -triple x86_64-unknown-linux-gnu -fvisibility hidden -emit-llvm -o - | FileCheck --check-prefix=CHECK-NOABI %s
+
+// CHECK-ITANIUM: @_ZTV1S = hidden unnamed_addr constant { { i8*, i8*, i32, i32 } } { { i8*, i8*, i32, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1S to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32, i32 } }, { { i8*, i8*, i32, i32 } }* @_ZTV1S, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32, i32 } }, { { i8*, i8*, i32, i32 } }* @_ZTV1S, i32 0, i32 0, i32 3) to i64)) to i32) } }, align 8
+// CHECK-MS: @anon.[[NUM:[a-z0-9]+]].0 = private unnamed_addr constant { { i8*, i32, i32 } } { { i8*, i32, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"??_R4S@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"?f1@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i32, i32 } }, { { i8*, i32, i32 } }* @anon.[[NUM]].0, i32

[PATCH] D58320: [Darwin] Introduce a new flag, -flink-builtins-rt that forces linking of the builtins library.

2019-02-15 Thread Amara Emerson via Phabricator via cfe-commits
aemerson created this revision.
aemerson added reviewers: peter.smith, dexonsmith, ab.
aemerson added a project: clang.
Herald added subscribers: jdoerfert, jfb.

This driver flag is useful when users want to link against the compiler's 
builtins, but nothing else, and so use flags like -nostdlib.

Implemented only for Darwin at the moment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58320

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/test/Driver/darwin-flink-builtins-rt.c

Index: clang/test/Driver/darwin-flink-builtins-rt.c
===
--- /dev/null
+++ clang/test/Driver/darwin-flink-builtins-rt.c
@@ -0,0 +1,6 @@
+// RUN: %clang -target arm64-apple-ios12.0 %s -nostdlib -flink-builtins-rt -### 2>&1 | FileCheck %s
+// RUN: %clang -target arm64-apple-ios12.0 %s -static -flink-builtins-rt -### 2>&1 | FileCheck %s
+// RUN: %clang -target arm64-apple-ios12.0 %s -flink-builtins-rt -### 2>&1 | FileCheck %s --check-prefix=DEFAULT
+// CHECK-NOT: "-lSystem"
+// DEFAULT: "-lSystem"
+// CHECK: libclang_rt.ios.a
Index: clang/lib/Driver/ToolChains/Darwin.h
===
--- clang/lib/Driver/ToolChains/Darwin.h
+++ clang/lib/Driver/ToolChains/Darwin.h
@@ -157,7 +157,8 @@
   /// FIXME: This API is intended for use with embedded libraries only, and is
   /// misleadingly named.
   virtual void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const;
+ llvm::opt::ArgStringList &CmdArgs,
+ bool ForceLinkBuiltinRT = false) const;
 
   virtual void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) const {
@@ -495,7 +496,8 @@
   RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const override;
 
   void AddLinkRuntimeLibArgs(const llvm::opt::ArgList &Args,
- llvm::opt::ArgStringList &CmdArgs) const override;
+ llvm::opt::ArgStringList &CmdArgs,
+ bool ForceLinkBuiltinRT = false) const override;
 
   void AddClangCXXStdlibIncludeArgs(
   const llvm::opt::ArgList &DriverArgs,
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -568,15 +568,26 @@
 
   if (getToolChain().ShouldLinkCXXStdlib(Args))
 getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+
+  bool NoStdOrDefaultLibs =
+  Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs);
+  bool ForceLinkBuiltins = Args.hasArg(options::OPT_flink_builtins_rt);
+  if (!NoStdOrDefaultLibs || ForceLinkBuiltins) {
 // link_ssp spec is empty.
 
-// Let the tool chain choose which runtime library to link.
-getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
+// If we have both -nostdlib/nodefaultlibs and -flink-builtins-rt then
+// we just want to link the builtins, not the other libs like libSystem.
+if (NoStdOrDefaultLibs && ForceLinkBuiltins) {
+  getMachOToolChain().AddLinkRuntimeLib(Args, CmdArgs, "builtins");
+} else {
+  // Let the tool chain choose which runtime library to link.
+  getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs,
+ForceLinkBuiltins);
 
-// No need to do anything for pthreads. Claim argument to avoid warning.
-Args.ClaimAllArgs(options::OPT_pthread);
-Args.ClaimAllArgs(options::OPT_pthreads);
+  // No need to do anything for pthreads. Claim argument to avoid warning.
+  Args.ClaimAllArgs(options::OPT_pthread);
+  Args.ClaimAllArgs(options::OPT_pthreads);
+}
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
@@ -1074,7 +1085,8 @@
 }
 
 void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
-ArgStringList &CmdArgs) const {
+ArgStringList &CmdArgs,
+bool ForceLinkBuiltinRT) const {
   // Call once to ensure diagnostic is printed if wrong value was specified
   GetRuntimeLibType(Args);
 
@@ -1082,8 +1094,11 @@
   // libraries with -static.
   if (Args.hasArg(options::OPT_static) ||
   Args.hasArg(options::OPT_fapple_kext) ||
-  Args.hasArg(options::OPT_mkernel))
+  Args.hasArg(options::OPT_mkernel)) {
+if (ForceLinkBuiltinRT)
+  AddLinkRuntimeLib(Args, CmdArgs, "builtins");
 return;
+  }
 
   // Reject -static-libgcc for now, we can deal with this when and if someone
   // cares. This is

[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-02-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay, but it's not great design to have a kind of overloading that can't be 
resolved to an exact intended declaration even by an explicit cast.  That's why 
I think making *optional* host/device typing is a good idea.  And I strongly 
want to caution you against doing language design by just incrementally hacking 
at the compiler to progressively make more test-cases work, which is what it 
feels like you're doing.


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

https://reviews.llvm.org/D56411



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-02-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56411#1400251 , @rjmccall wrote:

> It is totally unreasonable, at the time you are resolving a template 
> argument, to investigate how the corresponding template parameter is used 
> within the template and use that to shape how the template argument is 
> resolved.  That is simply not how the C++ template model works.  Given that 
> CODA doesn't distinguish between host and device functions in the type 
> system, if you are going to have a rule here, it has to be based on, at most, 
> (1) the current semantic context (which may not even be a function), (2) the 
> template being specialized, and (3) the declarations in the template-argument 
> set.
>
> As I've said before on a previous patch, I think the *best* rule would be to 
> recognize a hard difference between host and device function types, probably 
> by making function types default to being host function types and requiring 
> function pointers that can store device function pointers to be explicitly 
> annotated.  However, that would not be source-compatible with ordinary CUDA, 
> which is presumably unacceptable.
>
> The second-best rule would be to preserve compatibility by making an 
> unannotated function type still be "unknown whether host or device", but to 
> also allow the creation of explicitly host-only and device-only function 
> types.  For source compatibility, DREs to functions would formally have the 
> unknown function type.  Converting a pointer to an unknown function into a 
> pointer to a host function would do some basic checking on the operand 
> expression (basically to verify that it's not obviously a device function), 
> and resolving an overload set in the context of a host-only function pointer 
> type would do the obvious filtering.
>
> Otherwise, you're going to be stuck where you are right now, which is that 
> you're messing around with heuristics because somebody added a language 
> extension that isn't actually very well thought out.  But if that's what you 
> have to do, it's what you have to do.  For this specific question, where you 
> are trying to resolve an overloaded template argument, I think there are 
> basically two sensible options.
>
> - You can filter the overloads by the host-ness of the template.  This makes 
> some sense, because it's probably most likely that a function template that 
> takes a function as a template argument is going to call it — but not 
> necessarily, because it very well might decide instead to call over to the 
> device to invoke the function.  Also, not all templates have a "host-ness"; 
> that's pretty much exclusive to function templates.
> - You can filter the overload by the host-ness of the current context.  
> Again, this makes some sense because it's likely that a host function is 
> trying to pass down a host function — but again, it's not hard to think of 
> exceptions.  And again, this has the problem that the context isn't always a 
> function and so doesn't necessarily have a host-ness. Any sort of additional 
> template-specific guidance seems doomed to gradually turn into the second 
> design I mentioned above where you have the ability to be more specific about 
> function types.
>
>   For the time being, this is still a Clang extension, and while Artem 
> mentioned that NVIDIA is investigating it, that's presumably still an 
> investigation and we still have an opportunity to shape their thinking.  So I 
> would really recommend taking the second approach, or maybe even trying to 
> convince them to take the first.  (How common is higher-order programming on 
> the device, anyway, that you can't break source compatibility for it?)  For 
> this specific line of inquiry, that would probably mean not trying to 
> automatically use any particular filter on the overload set but instead just 
> relying on the programmer to annotation what kind of function they want.


I have seen important machine learning frameworks heavily using function type 
template parameters. If we make host-ness part of type system. Those templates 
expecting device function template parameters have to be rewritten, otherwise 
they won't compile. I don't think it is an easy task to persuade developers to 
make that change, since nvcc does not require that.

However, since this host-ness based overloading resolution is already in place 
and used by existing code, I do not want to break it. I consider your 
suggestion about host-ness based heuristic overloading resolution most viable 
for the current situation: take the host-ness of function templates as the 
first heuristic if the function under resolution is a function template 
argument, otherwise take the host-ness of the current context as the next 
heuristic.


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

https://reviews.llvm.org/D56411



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https:

[PATCH] D57080: [clang-tidy] Delete obsolete objc-property-declaration options ✂️

2019-02-15 Thread Stephane Moore via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354195: [clang-tidy] Delete obsolete 
objc-property-declaration options ✂️ (authored by stephanemoore, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57080?vs=186572&id=187128#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57080

Files:
  clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
  clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst


Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.h
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.h
@@ -10,8 +10,6 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_PROPERTY_DECLARATION_H
 
 #include "../ClangTidy.h"
-#include 
-#include 
 
 namespace clang {
 namespace tidy {
@@ -27,15 +25,10 @@
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/objc-property-declaration.html
 class PropertyDeclarationCheck : public ClangTidyCheck {
 public:
-  PropertyDeclarationCheck(StringRef Name, ClangTidyContext *Context);
+  PropertyDeclarationCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-  void storeOptions(ClangTidyOptions::OptionMap &Options) override;
-
-private:
-  const std::vector SpecialAcronyms;
-  const bool IncludeDefaultAcronyms;
-  std::vector EscapedAcronyms;
 };
 
 } // namespace objc
Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -97,14 +97,6 @@
 }
 }  // namespace
 
-PropertyDeclarationCheck::PropertyDeclarationCheck(StringRef Name,
-   ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context),
-  SpecialAcronyms(
-  utils::options::parseStringList(Options.get("Acronyms", ""))),
-  IncludeDefaultAcronyms(Options.get("IncludeDefaultAcronyms", true)),
-  EscapedAcronyms() {}
-
 void PropertyDeclarationCheck::registerMatchers(MatchFinder *Finder) {
   // this check should only be applied to ObjC sources.
   if (!getLangOpts().ObjC) return;
@@ -145,12 +137,6 @@
   << generateFixItHint(MatchedDecl, StandardProperty);
 }
 
-void PropertyDeclarationCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) 
{
-  Options.store(Opts, "Acronyms",
-utils::options::serializeStringList(SpecialAcronyms));
-  Options.store(Opts, "IncludeDefaultAcronyms", IncludeDefaultAcronyms);
-}
-
 }  // namespace objc
 }  // namespace tidy
 }  // namespace clang
Index: 
clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/objc-property-declaration.rst
@@ -40,15 +40,3 @@
@property(nonatomic, assign) int abc_lowerCamelCase;
 
 The corresponding style rule: 
https://developer.apple.com/library/content/qa/qa1908/_index.html
-
-
-Options

-
-.. option:: Acronyms
-
-   This option is deprecated and ignored.
-
-.. option:: IncludeDefaultAcronyms
-
-   This option is deprecated and ignored.
Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -98,6 +98,10 @@
   `CommentUserDefiniedLiterals`, `CommentStringLiterals`,
   `CommentCharacterLiterals` & `CommentNullPtrs` options.
 
+- The `Acronyms` and `IncludeDefaultAcronyms` options for the
+  :doc:`objc-property-declaration 
`
+  check have been removed.
+
 Improvements to include-fixer
 -
 


Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.h
+++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.h
@@ -10,8 +10,6 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_OBJC_PROPERTY_DECLARATION_H
 
 #include "../ClangTidy.h"
-#include 
-#include 
 
 namespace clang {
 namespace tidy {
@@ -27,15 +25,10 @@
 /// http://clang.llvm.org/extra/clang-

[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-15 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 187124.
jyu2 marked 5 inline comments as done.
jyu2 added a comment.
Herald added a subscriber: rnkovacs.

Review comments addressed.


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

https://reviews.llvm.org/D56571

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTImporter.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Analysis/CFG.cpp
  lib/CodeGen/CGStmt.cpp
  lib/Parse/ParseStmtAsm.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/SemaStmtAsm.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Analysis/asm-goto.cpp
  test/CodeGen/asm-goto.c
  test/CodeGen/asm.c
  test/CodeGen/inline-asm-mixed-style.c
  test/Coverage/c-language-features.inc
  test/PCH/asm.h
  test/Parser/asm.c
  test/Parser/asm.cpp
  test/Sema/asm-goto.cpp
  test/Sema/asm.c
  test/Sema/inline-asm-validate-tmpl.cpp
  test/Sema/scope-check.c

Index: test/Sema/scope-check.c
===
--- test/Sema/scope-check.c
+++ test/Sema/scope-check.c
@@ -232,3 +232,19 @@
 
 // rdar://9024687
 int test16(int [sizeof &&z]); // expected-error {{use of address-of-label extension outside of a function body}}
+
+//Asm goto:
+int test16(int n)
+{
+  // expected-error@+2 {{cannot jump from this asm goto statement to one of its possible targets}}
+  // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm volatile goto("testl %0, %0; jne %l1;" :: "r"(n)::label_true, loop);
+  // expected-note@+2 {{jump bypasses initialization of variable length array}}
+  // expected-note@+1 {{possible target of asm goto statement}}
+  return ({int a[n];label_true: 2;});
+  // expected-note@+1 {{jump bypasses initialization of variable length array}}
+  int b[n];
+// expected-note@+1 {{possible target of asm goto statement}}
+loop:
+  return 0;
+}
Index: test/Sema/inline-asm-validate-tmpl.cpp
===
--- test/Sema/inline-asm-validate-tmpl.cpp
+++ test/Sema/inline-asm-validate-tmpl.cpp
@@ -23,3 +23,13 @@
 	asm("rol %1, %0" :"=r"(value): "I"(N + 1));
 }
 int	foo() { testc<2>(10); }
+
+// these should compile without error
+template  bool testd()
+{
+  __asm goto ("" : : : : lab);
+  return true;
+lab:
+  return false;
+}
+bool foox() { return testd<0> (); }
Index: test/Sema/asm.c
===
--- test/Sema/asm.c
+++ test/Sema/asm.c
@@ -295,3 +295,24 @@
   return r0 + r1;
 }
 
+void test18()
+{
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm goto ("" : : : : lab, lab, lab2, lab);
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm goto ("xorw %[lab], %[lab]; je %l[lab]" : : [lab] "i" (0) : : lab);
+lab:;
+lab2:;
+  int x,x1;
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm ("" : [lab] "=r" (x),[lab] "+r" (x) : [lab1] "r" (x));
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm ("" : [lab] "=r" (x1) : [lab] "r" (x));
+  // expected-error@+1 {{invalid operand number in inline asm string}}
+  asm ("jne %l0":::);
+  asm goto ("jne %l0"lab);
+}
Index: test/Sema/asm-goto.cpp
===
--- /dev/null
+++ test/Sema/asm-goto.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -triple i386-pc-linux-gnu -verify -fsyntax-only
+
+struct NonTrivial {
+  ~NonTrivial();
+  int f(int);
+private:
+  int k;
+};
+void JumpDiagnostics(int n) {
+// expected-error@+1 {{cannot jump from this goto statement to its label}}
+  goto DirectJump;
+// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
+  NonTrivial tnp1;
+
+DirectJump:
+// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm goto("jmp %l0;" Later);
+// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
+  NonTrivial tnp2;
+// expected-note@+1 {{possible target of asm goto statement}}
+Later:
+  return;
+}
+
+struct S { ~S(); };
+void foo(int a) {
+  if (a) {
+FOO:
+// expected-note@+2 {{jump exits scope of variable with non-trivial destructor}}
+// expected-note@+1 {{jump exits scope of variable with non-trivial destructor}}
+S s;
+void *p = &&BAR;
+// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm goto("jmp %l0;" BAR);
+// expected-error@+1 {{cannot jump from this indirect got

[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-15 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: lib/AST/StmtProfile.cpp:324
 VisitStringLiteral(S->getClobberStringLiteral(I));
+  ID.AddInteger(S->getNumLabels());
 }

rsmith wrote:
> Don't we also need to profile the labels themselves?
How this can be lost? :-( 

Changed.



Comment at: lib/Analysis/CFG.cpp:1472
+  continue;
+addSuccessor(B, JT.block);
+  }

rsmith wrote:
> It looks like we're not modeling the destructors for local variables as 
> running on these CFG edges any more. Is that intentional?
Yes.  That it is my intention.  Since clean up code are not generated for 
asm-goto.



Comment at: lib/Sema/JumpDiagnostics.cpp:810
 return;
-  S.Diag(Jump->getGotoLoc(), diag::err_indirect_goto_in_protected_scope);
-  S.Diag(Target->getStmt()->getIdentLoc(), diag::note_indirect_goto_target);
+  bool IsAsmGoto = dyn_cast(Jump) != nullptr;
+  S.Diag(Jump->getBeginLoc(), diag::err_indirect_goto_in_protected_scope)

rsmith wrote:
> `isa(Jump)`
Yes!! changed. 



Comment at: lib/Sema/JumpDiagnostics.cpp:857
   if (!Diagnosed && !ToScopesCXX98Compat.empty()) {
-S.Diag(Jump->getGotoLoc(),
-   diag::warn_cxx98_compat_indirect_goto_in_protected_scope);
-S.Diag(Target->getStmt()->getIdentLoc(), diag::note_indirect_goto_target);
+bool IsAsmGoto = dyn_cast(Jump) != nullptr;
+S.Diag(Jump->getBeginLoc(),

rsmith wrote:
> Use `isa` here too.
changed



Comment at: lib/Sema/SemaStmtAsm.cpp:656-657
+  // Check for duplicate asm operand name between input, output and label 
lists.
+  typedef std::pair MyItemType;
+  SmallVector MyList;
+  for (unsigned i = 0, e = NumOutputs + NumInputs + NumLabels; i != e; ++i)

rsmith wrote:
> `MyItemType` and `MyList` aren't useful names for a reader of this code. 
> Please use a better name. Maybe `NamedOperand` and `NamedOperandList`?
Changed.


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

https://reviews.llvm.org/D56571



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-02-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

It is totally unreasonable, at the time you are resolving a template argument, 
to investigate how the corresponding template parameter is used within the 
template and use that to shape how the template argument is resolved.  That is 
simply not how the C++ template model works.  Given that CODA doesn't 
distinguish between host and device functions in the type system, if you are 
going to have a rule here, it has to be based on, at most, (1) the current 
semantic context (which may not even be a function), (2) the template being 
specialized, and (3) the declarations in the template-argument set.

As I've said before on a previous patch, I think the *best* rule would be to 
recognize a hard difference between host and device function types, probably by 
making function types default to being host function types and requiring 
function pointers that can store device function pointers to be explicitly 
annotated.  However, that would not be source-compatible with ordinary CUDA, 
which is presumably unacceptable.

The second-best rule would be to preserve compatibility by making an 
unannotated function type still be "unknown whether host or device", but to 
also allow the creation of explicitly host-only and device-only function types. 
 For source compatibility, DREs to functions would formally have the unknown 
function type.  Converting a pointer to an unknown function into a pointer to a 
host function would do some basic checking on the operand expression (basically 
to verify that it's not obviously a device function), and resolving an overload 
set in the context of a host-only function pointer type would do the obvious 
filtering.

Otherwise, you're going to be stuck where you are right now, which is that 
you're messing around with heuristics because somebody added a language 
extension that isn't actually very well thought out.  But if that's what you 
have to do, it's what you have to do.  For this specific question, where you 
are trying to resolve an overloaded template argument, I think there are 
basically two sensible options.

- You can filter the overloads by the host-ness of the template.  This makes 
some sense, because it's probably most likely that a function template that 
takes a function as a template argument is going to call it — but not 
necessarily, because it very well might decide instead to call over to the 
device to invoke the function.  Also, not all templates have a "host-ness"; 
that's pretty much exclusive to function templates.
- You can filter the overload by the host-ness of the current context.  Again, 
this makes some sense because it's likely that a host function is trying to 
pass down a host function — but again, it's not hard to think of exceptions.  
And again, this has the problem that the context isn't always a function and so 
doesn't necessarily have a host-ness.

Any sort of additional template-specific guidance seems doomed to gradually 
turn into the second design I mentioned above where you have the ability to be 
more specific about function types.

For the time being, this is still a Clang extension, and while Artem mentioned 
that NVIDIA is investigating it, that's presumably still an investigation and 
we still have an opportunity to shape their thinking.  So I would really 
recommend taking the second approach, or maybe even trying to convince them to 
take the first.  (How common is higher-order programming on the device, anyway, 
that you can't break source compatibility for it?)  For this specific line of 
inquiry, that would probably mean not trying to automatically use any 
particular filter on the overload set but instead just relying on the 
programmer to annotation what kind of function they want.


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

https://reviews.llvm.org/D56411



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


[PATCH] D58289: [clang] Only provide C11 features in starting with C++17

2019-02-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D58289



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


[PATCH] D57850: [analyzer] Emit an error rather than assert on invalid checker option input

2019-02-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.
Herald added a subscriber: jdoerfert.



Comment at: lib/StaticAnalyzer/Checkers/PaddingChecker.cpp:352-355
+  if (Checker->AllowedPad < 0)
+
Mgr.getDiagnostics().Report(diag::err_analyzer_checker_option_invalid_input)
+<< (llvm::Twine() + Checker->getTagDescription() + ":AllowedPad").str()
+<< "a non-negative";

Szelethus wrote:
> NoQ wrote:
> > 
> > I passively wish for a certain amount of de-duplication that wouldn't 
> > require every checker to obtain a diagnostics engine every time it tries to 
> > read an option. Eg.,
> > ```lang=c++
> >   auto *Checker = Mgr.registerChecker();
> >   Checker->AllowedPad = Mgr.getAnalyzerOptions()
> >   .getCheckerIntegerOption(Checker, "AllowedPad", 24);
> >   if (Checker->AllowedPad < 0)
> > Mgr.reportInvalidOptionValue(Checker, "AllowedPad", "a non-negative");
> > ```
> > 
> > Or maybe even something like that:
> > 
> > ```lang=c++
> >   auto *Checker = Mgr.registerChecker();
> >   Checker->AllowedPad = Mgr.getAnalyzerOptions()
> >   .getCheckerIntegerOption(Checker, "AllowedPad", 24,
> >   [](int x) -> Option {
> >   if (x < 0) {
> > // Makes getCheckerIntegerOption() emit a diagnostic
> > // and return the default value.
> > return "a non-negative";
> >   }
> >   // Makes getCheckerIntegerOption() successfully return
> >   // the user-specified value.
> >   return None;
> >   });
> > ```
> > I.e., a validator lambda.
> First one, sure. I'm a little unsure about the second: No other 
> "options"-like classes have access to a `DiagnosticsEngine` in clang, as far 
> as I'm aware, and I guess keeping `AnalyzerOptions` as simple is possible is 
> preferred. Not only that, but a validator lambda seems an to be an overkill 
> (though really-really cool) solution. Your first bit of code is far more 
> readable IMO.
Hmm, in the first example we'll also have to manually reset the option to the 
default value if it is invalid, which is also annoying - even if easy to 
understand, it's also easy to forget.

And with that and a bit of polish, the lambda approach isn't really much more 
verbose, and definitely involves less duplication:

```lang=c++
auto *Checker = Mgr.registerChecker();
Checker->AllowedPad = Mgr.getAnalyzerOptions()
.getCheckerIntegerOption(Checker, "AllowedPad", 24);
if (Checker->AllowedPad < 0) {
  Mgr.reportInvalidOptionValue(Checker, "AllowedPad", "a non-negative value");
  Checker->AllowedPad = 24;
}
```
vs.
```lang=c++
auto *Checker = Mgr.registerChecker();
Checker->AllowedPad = Mgr.getAnalyzerOptions()
.getCheckerIntegerOption(Checker, "AllowedPad", /*Default=*/ 24,
 /*Validate=*/ [](int x) { return x >= 0; },
 /*ValidMsg=*/ "a non-negative value");
```


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

https://reviews.llvm.org/D57850



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


[PATCH] D58121: [analyzer][WIP] Attempt to fix traversing bindings of non-base regions in ClusterAnalysis

2019-02-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

After staring at this for an hour or two, i didn't manage to force myself to 
understand how our cluster analysis works here, but i totally agree that it's 
most likely broken; i guess, we should eventually move away from the idea that 
everything works through base regions, but for now this idea seems to be 
hardcoded in a lot of places.

That said, the patch does fix the test case that i provided, but it doesn't fix 
my original regression :( so i'll run the reduce again to see if i have more to 
say. And i'll also try harder to understand what's going on.




Comment at: lib/StaticAnalyzer/Core/RegionStore.cpp:1039
   B = B.remove(baseR);
-  }
+  } 
 

The patch introduces a whitespace error here :p


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

https://reviews.llvm.org/D58121



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


r354192 - Fix some tests I broke in r354190

2019-02-15 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Fri Feb 15 17:51:19 2019
New Revision: 354192

URL: http://llvm.org/viewvc/llvm-project?rev=354192&view=rev
Log:
Fix some tests I broke in r354190

This was breaking on MSVC, since long double and double have the same
semantics there.

Modified:
cfe/trunk/test/Misc/warn-in-system-macro-def.c
cfe/trunk/test/Sema/warn-double-promotion.c

Modified: cfe/trunk/test/Misc/warn-in-system-macro-def.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/warn-in-system-macro-def.c?rev=354192&r1=354191&r2=354192&view=diff
==
--- cfe/trunk/test/Misc/warn-in-system-macro-def.c (original)
+++ cfe/trunk/test/Misc/warn-in-system-macro-def.c Fri Feb 15 17:51:19 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -isystem %S -Wdouble-promotion -fsyntax-only %s  2>&1 | 
FileCheck -allow-empty %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -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'

Modified: cfe/trunk/test/Sema/warn-double-promotion.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-double-promotion.c?rev=354192&r1=354191&r2=354192&view=diff
==
--- cfe/trunk/test/Sema/warn-double-promotion.c (original)
+++ cfe/trunk/test/Sema/warn-double-promotion.c Fri Feb 15 17:51:19 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s -Wdouble-promotion
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -verify -fsyntax-only %s 
-Wdouble-promotion
 
 float ReturnFloatFromDouble(double d) {
   return d;


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


[PATCH] D58317: [clang] Add install targets for development headers

2019-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

I'm not entirely happy with the name clang-dev-headers, and am open to 
suggestions. It's unfortunate clang-headers was already taken for something 
different, but renaming that target or increasing its scope seems bad for 
existing users. Other possibilities I thought of include clang-tooling-headers, 
though that might be confused with the headers for libTooling specifically, and 
clang-library-headers. I'm open to suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58317



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


[PATCH] D58317: [clang] Add install targets for development headers

2019-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: beanz, phosek.
Herald added subscribers: jdoerfert, mgorny.
Herald added a project: clang.
smeenai added a comment.

I'm not entirely happy with the name clang-dev-headers, and am open to 
suggestions. It's unfortunate clang-headers was already taken for something 
different, but renaming that target or increasing its scope seems bad for 
existing users. Other possibilities I thought of include clang-tooling-headers, 
though that might be confused with the headers for libTooling specifically, and 
clang-library-headers. I'm open to suggestions.


Add an install target for clang's development headers, which allows them
to be included in distributions. The install rules already existed, but
they lacked a component and a target, making them only accessible via a
full install. These headers are useful for writing clang-based tooling,
for example. They're the clang equivalent to the llvm-headers target and
complement the clang-libraries target. This differs from the existing
clang-headers target in that clang-headers is for clang's resource
directory headers, whereas the new target is for clang's development
headers (corresponding to its libraries).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58317

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -383,6 +383,7 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/clang include/clang-c
 DESTINATION include
+COMPONENT clang-dev-headers
 FILES_MATCHING
 PATTERN "*.def"
 PATTERN "*.h"
@@ -392,12 +393,23 @@
 
   install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang
 DESTINATION include
+COMPONENT clang-dev-headers
 FILES_MATCHING
 PATTERN "CMakeFiles" EXCLUDE
 PATTERN "*.inc"
 PATTERN "*.h"
 )
 
+  # Installing the headers needs to depend on generating any public
+  # tablegen'd headers.
+  add_custom_target(clang-dev-headers DEPENDS clang-tablegen-targets)
+  set_target_properties(clang-dev-headers PROPERTIES FOLDER "Misc")
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-clang-dev-headers
+ DEPENDS clang-dev-headers
+ COMPONENT clang-dev-headers)
+  endif()
+
   install(PROGRAMS utils/bash-autocomplete.sh
 DESTINATION share/clang
 )


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -383,6 +383,7 @@
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/clang include/clang-c
 DESTINATION include
+COMPONENT clang-dev-headers
 FILES_MATCHING
 PATTERN "*.def"
 PATTERN "*.h"
@@ -392,12 +393,23 @@
 
   install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang
 DESTINATION include
+COMPONENT clang-dev-headers
 FILES_MATCHING
 PATTERN "CMakeFiles" EXCLUDE
 PATTERN "*.inc"
 PATTERN "*.h"
 )
 
+  # Installing the headers needs to depend on generating any public
+  # tablegen'd headers.
+  add_custom_target(clang-dev-headers DEPENDS clang-tablegen-targets)
+  set_target_properties(clang-dev-headers PROPERTIES FOLDER "Misc")
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-clang-dev-headers
+ DEPENDS clang-dev-headers
+ COMPONENT clang-dev-headers)
+  endif()
+
   install(PROGRAMS utils/bash-autocomplete.sh
 DESTINATION share/clang
 )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.
Herald added a reviewer: martong.



Comment at: lib/AST/StmtProfile.cpp:324
 VisitStringLiteral(S->getClobberStringLiteral(I));
+  ID.AddInteger(S->getNumLabels());
 }

Don't we also need to profile the labels themselves?



Comment at: lib/Analysis/CFG.cpp:1472
+  continue;
+addSuccessor(B, JT.block);
+  }

It looks like we're not modeling the destructors for local variables as running 
on these CFG edges any more. Is that intentional?



Comment at: lib/Sema/JumpDiagnostics.cpp:810
 return;
-  S.Diag(Jump->getGotoLoc(), diag::err_indirect_goto_in_protected_scope);
-  S.Diag(Target->getStmt()->getIdentLoc(), diag::note_indirect_goto_target);
+  bool IsAsmGoto = dyn_cast(Jump) != nullptr;
+  S.Diag(Jump->getBeginLoc(), diag::err_indirect_goto_in_protected_scope)

`isa(Jump)`



Comment at: lib/Sema/JumpDiagnostics.cpp:857
   if (!Diagnosed && !ToScopesCXX98Compat.empty()) {
-S.Diag(Jump->getGotoLoc(),
-   diag::warn_cxx98_compat_indirect_goto_in_protected_scope);
-S.Diag(Target->getStmt()->getIdentLoc(), diag::note_indirect_goto_target);
+bool IsAsmGoto = dyn_cast(Jump) != nullptr;
+S.Diag(Jump->getBeginLoc(),

Use `isa` here too.



Comment at: lib/Sema/SemaStmtAsm.cpp:656-657
+  // Check for duplicate asm operand name between input, output and label 
lists.
+  typedef std::pair MyItemType;
+  SmallVector MyList;
+  for (unsigned i = 0, e = NumOutputs + NumInputs + NumLabels; i != e; ++i)

`MyItemType` and `MyList` aren't useful names for a reader of this code. Please 
use a better name. Maybe `NamedOperand` and `NamedOperandList`?


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

https://reviews.llvm.org/D56571



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


[PATCH] D58254: [Sema] Diagnose floating point conversions based on target semantics

2019-02-15 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354190: [Sema] Diagnose floating point conversions based on 
target semantics (authored by epilk, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D58254?vs=186919&id=187119#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58254

Files:
  include/clang/AST/ASTContext.h
  lib/AST/ASTContext.cpp
  lib/Sema/SemaChecking.cpp
  test/Sema/conversion-target-dep.c

Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -5608,6 +5608,12 @@
   return -1;
 }
 
+int ASTContext::getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const {
+  if (&getFloatTypeSemantics(LHS) == &getFloatTypeSemantics(RHS))
+return 0;
+  return getFloatingTypeOrder(LHS, RHS);
+}
+
 /// getIntegerRank - Return an integer conversion rank (C99 6.3.1.1p1). This
 /// routine will assert if passed a built-in type that isn't an integer or enum,
 /// or if it is not canonicalized.
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -10626,14 +10626,16 @@
 
   // If source is floating point but target is an integer.
   if (ResultBT->isInteger())
-DiagnoseImpCast(S, E, E->getRHS()->getType(), E->getLHS()->getType(),
-E->getExprLoc(), diag::warn_impcast_float_integer);
-  // If both source and target are floating points. Builtin FP kinds are ordered
-  // by increasing FP rank. FIXME: except _Float16, we currently emit a bogus
-  // warning.
-  else if (ResultBT->isFloatingPoint() && ResultBT->getKind() < RBT->getKind() &&
-   // We don't want to warn for system macro.
-   !S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
+return DiagnoseImpCast(S, E, E->getRHS()->getType(), E->getLHS()->getType(),
+   E->getExprLoc(), diag::warn_impcast_float_integer);
+
+  if (!ResultBT->isFloatingPoint())
+return;
+
+  // If both source and target are floating points, warn about losing precision.
+  int Order = S.getASTContext().getFloatingTypeSemanticOrder(
+  QualType(ResultBT, 0), QualType(RBT, 0));
+  if (Order < 0 && !S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
 // warn about dropping FP rank.
 DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(), E->getOperatorLoc(),
 diag::warn_impcast_float_result_precision);
@@ -10952,8 +10954,9 @@
 if (TargetBT && TargetBT->isFloatingPoint()) {
   // ...then warn if we're dropping FP rank.
 
-  // Builtin FP kinds are ordered by increasing FP rank.
-  if (SourceBT->getKind() > TargetBT->getKind()) {
+  int Order = S.getASTContext().getFloatingTypeSemanticOrder(
+  QualType(SourceBT, 0), QualType(TargetBT, 0));
+  if (Order > 0) {
 // Don't warn about float constants that are precisely
 // representable in the target type.
 Expr::EvalResult result;
@@ -10971,7 +10974,7 @@
 DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_float_precision);
   }
   // ... or possibly if we're increasing rank, too
-  else if (TargetBT->getKind() > SourceBT->getKind()) {
+  else if (Order < 0) {
 if (S.SourceMgr.isInSystemMacro(CC))
   return;
 
Index: include/clang/AST/ASTContext.h
===
--- include/clang/AST/ASTContext.h
+++ include/clang/AST/ASTContext.h
@@ -2501,6 +2501,11 @@
   /// \p LHS < \p RHS, return -1.
   int getFloatingTypeOrder(QualType LHS, QualType RHS) const;
 
+  /// Compare the rank of two floating point types as above, but compare equal
+  /// if both types have the same floating-point semantics on the target (i.e.
+  /// long double and double on AArch64 will return 0).
+  int getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const;
+
   /// Return a real floating point or a complex type (based on
   /// \p typeDomain/\p typeSize).
   ///
Index: test/Sema/conversion-target-dep.c
===
--- test/Sema/conversion-target-dep.c
+++ test/Sema/conversion-target-dep.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -Wdouble-promotion -Wimplicit-float-conversion %s -triple x86_64-apple-macosx10.12 -verify=x86,expected
+// RUN: %clang_cc1 -Wdouble-promotion -Wimplicit-float-conversion %s -triple armv7-apple-ios9.0 -verify=arm,expected
+
+// On ARM, long double and double both map to double precision 754s, so there
+// isn't any reason to warn on conversions back and forth.
+
+long double ld;
+double d;
+_Float16 f16; // x86-error {{_Float16 is not supported on this target}}
+
+int main() {
+  ld = d; // x86-warning {{implicit conversion increases floating-point precision: 'double' t

r354190 - [Sema] Diagnose floating point conversions based on target semantics

2019-02-15 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Fri Feb 15 17:11:47 2019
New Revision: 354190

URL: http://llvm.org/viewvc/llvm-project?rev=354190&view=rev
Log:
[Sema] Diagnose floating point conversions based on target semantics

...instead of just comparing rank. Also, fix a bad warning about
_Float16, since its declared out of order in BuiltinTypes.def,
meaning comparing rank using BuiltinType::getKind() is incorrect.

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

Added:
cfe/trunk/test/Sema/conversion-target-dep.c
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354190&r1=354189&r2=354190&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Fri Feb 15 17:11:47 2019
@@ -2501,6 +2501,11 @@ public:
   /// \p LHS < \p RHS, return -1.
   int getFloatingTypeOrder(QualType LHS, QualType RHS) const;
 
+  /// Compare the rank of two floating point types as above, but compare equal
+  /// if both types have the same floating-point semantics on the target (i.e.
+  /// long double and double on AArch64 will return 0).
+  int getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const;
+
   /// Return a real floating point or a complex type (based on
   /// \p typeDomain/\p typeSize).
   ///

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354190&r1=354189&r2=354190&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Fri Feb 15 17:11:47 2019
@@ -5608,6 +5608,12 @@ int ASTContext::getFloatingTypeOrder(Qua
   return -1;
 }
 
+int ASTContext::getFloatingTypeSemanticOrder(QualType LHS, QualType RHS) const 
{
+  if (&getFloatTypeSemantics(LHS) == &getFloatTypeSemantics(RHS))
+return 0;
+  return getFloatingTypeOrder(LHS, RHS);
+}
+
 /// getIntegerRank - Return an integer conversion rank (C99 6.3.1.1p1). This
 /// routine will assert if passed a built-in type that isn't an integer or 
enum,
 /// or if it is not canonicalized.

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=354190&r1=354189&r2=354190&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Feb 15 17:11:47 2019
@@ -10626,14 +10626,16 @@ static void AnalyzeCompoundAssignment(Se
 
   // If source is floating point but target is an integer.
   if (ResultBT->isInteger())
-DiagnoseImpCast(S, E, E->getRHS()->getType(), E->getLHS()->getType(),
-E->getExprLoc(), diag::warn_impcast_float_integer);
-  // If both source and target are floating points. Builtin FP kinds are 
ordered
-  // by increasing FP rank. FIXME: except _Float16, we currently emit a bogus
-  // warning.
-  else if (ResultBT->isFloatingPoint() && ResultBT->getKind() < RBT->getKind() 
&&
-   // We don't want to warn for system macro.
-   !S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
+return DiagnoseImpCast(S, E, E->getRHS()->getType(), 
E->getLHS()->getType(),
+   E->getExprLoc(), diag::warn_impcast_float_integer);
+
+  if (!ResultBT->isFloatingPoint())
+return;
+
+  // If both source and target are floating points, warn about losing 
precision.
+  int Order = S.getASTContext().getFloatingTypeSemanticOrder(
+  QualType(ResultBT, 0), QualType(RBT, 0));
+  if (Order < 0 && !S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
 // warn about dropping FP rank.
 DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(), 
E->getOperatorLoc(),
 diag::warn_impcast_float_result_precision);
@@ -10952,8 +10954,9 @@ CheckImplicitConversion(Sema &S, Expr *E
 if (TargetBT && TargetBT->isFloatingPoint()) {
   // ...then warn if we're dropping FP rank.
 
-  // Builtin FP kinds are ordered by increasing FP rank.
-  if (SourceBT->getKind() > TargetBT->getKind()) {
+  int Order = S.getASTContext().getFloatingTypeSemanticOrder(
+  QualType(SourceBT, 0), QualType(TargetBT, 0));
+  if (Order > 0) {
 // Don't warn about float constants that are precisely
 // representable in the target type.
 Expr::EvalResult result;
@@ -10971,7 +10974,7 @@ CheckImplicitConversion(Sema &S, Expr *E
 DiagnoseImpCast(S, E, T, CC, diag::warn_impcast_float_precision);
   }
   // ... or possibly if we're increasing rank, too
-  else if (TargetBT->getKind() > SourceBT->getKind()) {
+  else if (Order < 0) {
 if (S.Sour

[PATCH] D57075: [ObjC] For type substitution in generics use a regular recursive type visitor.

2019-02-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the review, Erik.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57075



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


[PATCH] D57076: [ObjC generics] Fix applying `__kindof` to the type parameter.

2019-02-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
vsapsai marked an inline comment as done.
Closed by commit rC354189: [ObjC generics] Fix applying `__kindof` to the type 
parameter. (authored by vsapsai, committed by ).
Herald added a subscriber: jdoerfert.
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D57076?vs=183338&id=187117#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57076

Files:
  lib/AST/Type.cpp
  test/SemaObjC/kindof.m

Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -1297,6 +1297,42 @@
 
 return BaseType::VisitObjCObjectType(objcObjectType);
   }
+
+  QualType VisitAttributedType(const AttributedType *attrType) {
+QualType newType = BaseType::VisitAttributedType(attrType);
+if (newType.isNull())
+  return {};
+
+const auto *newAttrType = dyn_cast(newType.getTypePtr());
+if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
+  return newType;
+
+// Find out if it's an Objective-C object or object pointer type;
+QualType newEquivType = newAttrType->getEquivalentType();
+const ObjCObjectPointerType *ptrType =
+newEquivType->getAs();
+const ObjCObjectType *objType = ptrType
+? ptrType->getObjectType()
+: newEquivType->getAs();
+if (!objType)
+  return newType;
+
+// Rebuild the "equivalent" type, which pushes __kindof down into
+// the object type.
+newEquivType = Ctx.getObjCObjectType(
+objType->getBaseType(), objType->getTypeArgsAsWritten(),
+objType->getProtocols(),
+// There is no need to apply kindof on an unqualified id type.
+/*isKindOf=*/objType->isObjCUnqualifiedId() ? false : true);
+
+// If we started with an object pointer type, rebuild it.
+if (ptrType)
+  newEquivType = Ctx.getObjCObjectPointerType(newEquivType);
+
+// Rebuild the attributed type.
+return Ctx.getAttributedType(newAttrType->getAttrKind(),
+ newAttrType->getModifiedType(), newEquivType);
+  }
 };
 
 struct StripObjCKindOfTypeVisitor
Index: test/SemaObjC/kindof.m
===
--- test/SemaObjC/kindof.m
+++ test/SemaObjC/kindof.m
@@ -384,9 +384,17 @@
 }
 @end
 
+// ---
+// __kindof on type parameters
+// ---
+
 @interface NSGeneric : NSObject
 - (void)test:(__kindof ObjectType)T; // expected-note{{passing argument to parameter 'T' here}}
 - (void)mapUsingBlock:(id (^)(__kindof ObjectType))block;
+@property (copy) ObjectType object;
+@property (copy) __kindof ObjectType kindof_object;
+
+@property (copy) __kindof ObjectType _Nonnull nonnull_kindof_object;
 @end
 @implementation NSGeneric
 - (void)test:(id)T {
@@ -395,6 +403,11 @@
 }
 @end
 
+@interface NSDefaultGeneric : NSObject
+@property (copy) ObjectType object;
+@property (copy) __kindof ObjectType kindof_object;
+@end
+
 void testGeneric(NSGeneric *generic) {
   NSObject *NSObject_obj;
   // Assign from NSObject_obj to __kindof NSString*.
@@ -403,6 +416,45 @@
   [generic test:NSString_str];
 }
 
+void testGenericAssignment() {
+  NSMutableString *NSMutableString_str;
+  NSNumber *NSNumber_obj;
+
+  NSGeneric *generic;
+  NSMutableString_str = generic.object; // expected-warning{{incompatible pointer types}}
+  NSNumber_obj = generic.object; // expected-warning{{incompatible pointer types}}
+  NSMutableString_str = generic.kindof_object;
+  NSNumber_obj = generic.kindof_object; // expected-warning{{incompatible pointer types assigning to 'NSNumber *' from '__kindof NSString *'}}
+
+  NSGeneric<__kindof NSString*> *kindof_generic;
+  NSMutableString_str = kindof_generic.object;
+  NSNumber_obj = kindof_generic.object; // expected-warning{{incompatible pointer types assigning to 'NSNumber *' from '__kindof NSString *'}}
+  NSMutableString_str = kindof_generic.kindof_object;
+  NSNumber_obj = kindof_generic.kindof_object; // expected-warning{{incompatible pointer types assigning to 'NSNumber *' from '__kindof __kindof NSString *'}}
+
+  NSDefaultGeneric *default_generic;
+  NSMutableString_str = default_generic.object;
+  NSNumber_obj = default_generic.object; // expected-warning{{incompatible pointer types}}
+  NSMutableString_str = default_generic.kindof_object;
+  NSNumber_obj = default_generic.kindof_object; // expected-warning{{incompatible pointer types assigning to 'NSNumber *' from '__kindof __kindof NSString *'}}
+
+  typedef NSString *Typedef_NSString;
+  NSGeneric *typedef_generic;
+  NSMutableString_str = typedef_generic.object; // expected-warning{{incompatible pointer types}}
+  NSNumber_obj =

r354189 - [ObjC generics] Fix applying `__kindof` to the type parameter.

2019-02-15 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Fri Feb 15 17:01:08 2019
New Revision: 354189

URL: http://llvm.org/viewvc/llvm-project?rev=354189&view=rev
Log:
[ObjC generics] Fix applying `__kindof` to the type parameter.

Fixes the warning about incompatible pointer types on assigning to a
subclass of type argument an expression of type `__kindof TypeParam`.

We already have a mechanism in `ASTContext::canAssignObjCInterfaces`
that handles `ObjCObjectType` with `__kindof`. But it wasn't triggered
because during type substitution `__kindof TypeParam` was represented as
`AttributedType` with attribute `ObjCKindOf` and equivalent type
`TypeArg`. For assignment type checking we use canonical types so
attributed type was desugared and the attribute was ignored.

The fix is in checking transformed `AttributedType` and pushing
`__kindof` down into `ObjCObjectType` when necessary.

rdar://problem/38514910

Reviewers: ahatanak, erik.pilkington, doug.gregor

Reviewed By: doug.gregor

Subscribers: jkorous, dexonsmith, manmanren, jordan_rose, doug.gregor, 
cfe-commits

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


Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/test/SemaObjC/kindof.m

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=354189&r1=354188&r2=354189&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Fri Feb 15 17:01:08 2019
@@ -1297,6 +1297,42 @@ struct SubstObjCTypeArgsVisitor
 
 return BaseType::VisitObjCObjectType(objcObjectType);
   }
+
+  QualType VisitAttributedType(const AttributedType *attrType) {
+QualType newType = BaseType::VisitAttributedType(attrType);
+if (newType.isNull())
+  return {};
+
+const auto *newAttrType = dyn_cast(newType.getTypePtr());
+if (!newAttrType || newAttrType->getAttrKind() != attr::ObjCKindOf)
+  return newType;
+
+// Find out if it's an Objective-C object or object pointer type;
+QualType newEquivType = newAttrType->getEquivalentType();
+const ObjCObjectPointerType *ptrType =
+newEquivType->getAs();
+const ObjCObjectType *objType = ptrType
+? ptrType->getObjectType()
+: 
newEquivType->getAs();
+if (!objType)
+  return newType;
+
+// Rebuild the "equivalent" type, which pushes __kindof down into
+// the object type.
+newEquivType = Ctx.getObjCObjectType(
+objType->getBaseType(), objType->getTypeArgsAsWritten(),
+objType->getProtocols(),
+// There is no need to apply kindof on an unqualified id type.
+/*isKindOf=*/objType->isObjCUnqualifiedId() ? false : true);
+
+// If we started with an object pointer type, rebuild it.
+if (ptrType)
+  newEquivType = Ctx.getObjCObjectPointerType(newEquivType);
+
+// Rebuild the attributed type.
+return Ctx.getAttributedType(newAttrType->getAttrKind(),
+ newAttrType->getModifiedType(), newEquivType);
+  }
 };
 
 struct StripObjCKindOfTypeVisitor

Modified: cfe/trunk/test/SemaObjC/kindof.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/kindof.m?rev=354189&r1=354188&r2=354189&view=diff
==
--- cfe/trunk/test/SemaObjC/kindof.m (original)
+++ cfe/trunk/test/SemaObjC/kindof.m Fri Feb 15 17:01:08 2019
@@ -384,9 +384,17 @@ void testNullability() {
 }
 @end
 
+// ---
+// __kindof on type parameters
+// ---
+
 @interface NSGeneric : NSObject
 - (void)test:(__kindof ObjectType)T; // expected-note{{passing argument to 
parameter 'T' here}}
 - (void)mapUsingBlock:(id (^)(__kindof ObjectType))block;
+@property (copy) ObjectType object;
+@property (copy) __kindof ObjectType kindof_object;
+
+@property (copy) __kindof ObjectType _Nonnull nonnull_kindof_object;
 @end
 @implementation NSGeneric
 - (void)test:(id)T {
@@ -395,6 +403,11 @@ void testNullability() {
 }
 @end
 
+@interface NSDefaultGeneric : NSObject
+@property (copy) ObjectType object;
+@property (copy) __kindof ObjectType kindof_object;
+@end
+
 void testGeneric(NSGeneric *generic) {
   NSObject *NSObject_obj;
   // Assign from NSObject_obj to __kindof NSString*.
@@ -403,6 +416,45 @@ void testGeneric(NSGeneric *g
   [generic test:NSString_str];
 }
 
+void testGenericAssignment() {
+  NSMutableString *NSMutableString_str;
+  NSNumber *NSNumber_obj;
+
+  NSGeneric *generic;
+  NSMutableString_str = generic.object; // expected-warning{{incompatible 
pointer types}}
+  NSNumber_obj = generic.object; // expected-warning{{incompatible pointer 
types}}
+  NSMutableString_str = generic.kindof_object;
+  NSNumber_obj = generic.kindof_object; // expected-warning{{incompatibl

[PATCH] D58314: [Driver] Sync ARM behavior between clang-as and gas.

2019-02-15 Thread Dan Albert via Phabricator via cfe-commits
danalbert created this revision.
danalbert added reviewers: peter.smith, kristof.beyls, srhines, pirama.
Herald added a subscriber: javed.absar.
Herald added a project: clang.

The ARM gas driver previously enabled NEON for ARMv7 and up, and a
handful of other extensions for ARMv8 and up (although only if the
architecture version was a part of the triple; the -march flag was
not honored). Neither of these are actually guaranteed, and the
behavior does not match the integrated assembler.

Note that I've elected to always pass an explicit -march flag to gas
if the user has not specified one. I'm not certain if Clang's default
ARM version matches GNU's, so being explicit allows us to keep the
same behavior if that isn't the case. This also makes it clear that
the correct architecture is passed to gas based on -mcpu.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58314

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-as.c

Index: clang/test/Driver/linux-as.c
===
--- clang/test/Driver/linux-as.c
+++ clang/test/Driver/linux-as.c
@@ -3,17 +3,17 @@
 // RUN: %clang -target arm-linux -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM %s
-// CHECK-ARM: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft"
+// CHECK-ARM: as{{(.exe)?}}" "-EL" "-march=armv4t" "-mfloat-abi=soft"
 //
 // RUN: %clang -target arm-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MCPU %s
-// CHECK-ARM-MCPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARM-MCPU: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target arm-linux -mfpu=neon -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-MFPU %s
-// CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-mfloat-abi=soft" "-mfpu=neon"
+// CHECK-ARM-MFPU: as{{(.exe)?}}" "-EL" "-march=armv4t" "-mfloat-abi=soft" "-mfpu=neon"
 //
 // RUN: %clang -target arm-linux -march=armv7-a -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
@@ -63,62 +63,72 @@
 // RUN: %clang -target armv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-TARGET %s
-// CHECK-ARM-TARGET: as{{(.exe)?}}" "-EL" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARM-TARGET: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target armebv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARMEB-TARGET %s
-// CHECK-ARMEB-TARGET: as{{(.exe)?}}" "-EB" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-ARMEB-TARGET: as{{(.exe)?}}" "-EB" "-march=armebv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target thumbv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMB-TARGET %s
-// CHECK-THUMB-TARGET: as{{(.exe)?}}" "-EL" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-THUMB-TARGET: as{{(.exe)?}}" "-EL" "-march=armv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target thumbebv7-linux -mcpu=cortex-a8 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMBEB-TARGET %s
-// CHECK-THUMBEB-TARGET: as{{(.exe)?}}" "-EB" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8"
+// CHECK-THUMBEB-TARGET: as{{(.exe)?}}" "-EB" "-march=armebv7" "-mfloat-abi=soft" "-mcpu=cortex-a8"
 //
 // RUN: %clang -target armv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARM-TARGET-V8 %s
-// CHECK-ARM-TARGET-V8: as{{(.exe)?}}" "-EL" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-ARM-TARGET-V8: as{{(.exe)?}}" "-EL" "-march=armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target armebv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ARMEB-TARGET-V8 %s
-// CHECK-ARMEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-ARMEB-TARGET-V8: as{{(.exe)?}}" "-EB" "-march=armebv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target thumbv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-THUMB-TARGET-V8 %s
-// CHECK-THUMB-TARGET-V8: as{{(.exe)?}}" "-EL" "-mfpu=crypto-neon-fp-armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
+// CHECK-THUMB-TARGET-V8: as{{(.exe)?}}" "-EL" "-march=armv8" "-mfloat-abi=soft" "-mcpu=cortex-a53"
 //
 // RUN: %clang -target thumbebv8-linux -mcpu=cortex-a53 -### \
 // RUN:   -no-integrated-as -c %s 2>&1 \
 // RUN:   | FileCheck -check-pr

[PATCH] D58065: [analyzer] Document the frontend library

2019-02-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Had a look. Great stuff, just as planned :) Old fanboy wisdom: Try to avoid 
documenting bugs you want to fix! But i don't have many high-level comments 
here - only appreciation of the effort.

In D58065#1394864 , @Szelethus wrote:

> Please, in the first round of reviews, if you could make high level comments 
> about what should or should not be here would be great, perfectly wrapping 
> around the 80 column limit and finding typos don't concern me as much before 
> the actual content is ready.


This should actually be sticked on top of every phabricator page (:




Comment at: docs/analyzer/developer-docs/FrontendLibrary.rst:11-13
+This document will describe the frontend of the Static Analyzer, basically
+everything from compiling the analyzer from source, through it's invocation up
+to the beginning of the analysis. It will touch on topics such as

First of all, "frontend" is, as far as i understand, a weird word to use with 
respect to this library in general. I think what they were trying to say was 
something like "The Static Analyzer-specific part of the C Front End's 
command-line flags" (as opposed to Driver flags), but calling this UI "The 
Frontend" is a bit weird. We probablyshould try to somehow avoid confusion with 
the "compiler frontend" concept throughout this document.



Comment at: docs/analyzer/developer-docs/FrontendLibrary.rst:15-16
+
+* How the analyzer is compiled, how tools such as TableGen are used to generate
+  some of the code,
+* How to invoke the analyzer,

Eg., we're talking about TableGen because in our case it's all about providing 
values for frontend flags (Checkers.td provides values for the 
-analyzer-checker flag, etc.). It's not because the process of compiling the 
Analyzer is an essential part of the very idea of the "Frontend". So it sounds 
a bit strange. Across the whole Clang there are many other uses of TableGen.



Comment at: docs/analyzer/developer-docs/FrontendLibrary.rst:57-88
+Following this, the compilation goes on as usual. The fastest way of obtaining
+the analyzer for development is by configuring CMake with the following 
options:
+
+* Use the `Ninja` build system
+* Build in `Release` with asserts enabled (Only recommended for slower
+  computers!)
+* Build shared libraries

For the above reason i think this text deserves a better document to be put 
into; this is definitely important to know for a much wider audience than 
developers of libStaticAnalyzerFrontend.



Comment at: docs/analyzer/developer-docs/FrontendLibrary.rst:216-220
+As the analyzer matured over the years, specific terms that described one
+specific function can now mean a variety of different things. For example, in
+the early 2010s, we used the term "checks" (similarly to clang-tidy) instead of
+"checkers", and there still are some remnants of this in class/object names and
+documentation. Among the most commonly misused words is "registration".

I think originally the whole Static Analyzer was referred to as "The Checker" - 
and was, essentially, just one checker :)



Comment at: docs/analyzer/developer-docs/FrontendLibrary.rst:638-643
+Model injector
+--
+
+Work in progress
+
+.. TODO

I really need to refresh my knowledge on this one. Why is it not on by default? 
Why did we need ASTImporter for cross-translation-unit analysis when we already 
had this? Why do we need this when we already have ASTImporter? Etc.

CTU is, besides everything else, a great alternative to body farming. We can 
write down models as normal code and load them via CTU and in fact it'll help 
us avoid ASTImporter imperfections by simply only writing models that 
ASTImporter is able to understand.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58065



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


[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-15 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder updated this revision to Diff 187113.
tmroeder added a comment.

Updated Registry.cpp, regenerated the documentation, and added direct tests for 
the matcher.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58292

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTImporter.cpp
  lib/ASTMatchers/ASTMatchersInternal.cpp
  lib/ASTMatchers/Dynamic/Registry.cpp
  test/ASTMerge/choose-expr/Inputs/choose1.c
  test/ASTMerge/choose-expr/Inputs/choose2.c
  test/ASTMerge/choose-expr/test.c
  unittests/AST/ASTImporterTest.cpp
  unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -754,6 +754,28 @@
   EXPECT_TRUE(matches("int* i = nullptr;", cxxNullPtrLiteralExpr()));
 }
 
+TEST(Matcher, ChooseExpr) {
+  EXPECT_TRUE(matchesC("void f() { (void)__builtin_choose_expr(1, 2, 3); }",
+   chooseExpr()));
+
+  // The __builtin_choose_expr construction in the following test is closer to
+  // the way that builtin is used in macros in real programs, even though it is
+  // unnecessary when written out directly in the code like this.
+  EXPECT_TRUE(matchesC(R"(
+  void f() {
+int x = -10;
+int abs_x = __builtin_choose_expr(
+  __builtin_types_compatible_p(__typeof(x), unsigned int),
+  x,
+  __builtin_choose_expr(
+__builtin_types_compatible_p(__typeof(x), int),
+x < 0 ? -x : x,
+(void)0));
+(void)abs_x;
+  }
+  )", chooseExpr(hasDescendant(chooseExpr();
+}
+
 TEST(Matcher, GNUNullExpr) {
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -563,6 +563,15 @@
   stringLiteral(hasType(asString("const char [7]"));
 }
 
+TEST_P(ImportExpr, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  testImport(
+"void declToImport() { __builtin_choose_expr(1, 2, 3); }",
+Lang_C, "", Lang_C, Verifier,
+functionDecl(hasDescendant(chooseExpr(;
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1082,6 +1091,38 @@
   EXPECT_EQ(To, nullptr);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  // The macro in this TuDecl violates standard rules of macros (like not
+  // using a variable more than once), but it's only used to test a realistic
+  // __builtin_choose_expr construction.
+  Decl *FromTU = getTuDecl(
+  R"(
+  #define abs_int(x) __builtin_choose_expr(\
+ __builtin_types_compatible_p(__typeof(x), unsigned int),  \
+ x,\
+ __builtin_choose_expr(\
+   __builtin_types_compatible_p(__typeof(x), int), \
+   x < 0 ? -x : x, \
+   (void)0))
+  void declToImport() {
+int x = -10;
+int abs_x = abs_int(x);
+(void)abs_x;
+  }
+  )",
+  Lang_C, "input.c");
+  auto *From = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
+  ASSERT_TRUE(From);
+  auto *To = Import(From, Lang_C);
+  ASSERT_TRUE(To);
+  EXPECT_TRUE(MatchVerifier().match(
+  To, functionDecl(hasName("declToImport"),
+   hasDescendant(chooseExpr(hasDescendant(chooseExpr()));
+}
+
 const internal::VariadicDynCastAllOfMatcher
 cxxPseudoDestructorExpr;
 
Index: test/ASTMerge/choose-expr/test.c
===
--- /dev/null
+++ test/ASTMerge/choose-expr/test.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/choose1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/choose2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1
Index: test/ASTMerge/choose-expr/Inputs/choose2.c
===
--- /dev/null
+++ test/ASTMerge/choose-expr/Inputs/choose2.c
@@ -0,0 +1,12 @@
+#define abs_int(x) __builtin_choose_expr( \
+__builtin_types_compatible_p(__typeof(x), unsigned int),  \
+x,\
+__builtin_choose_expr(\
+__builtin_types_compatible_p(__typeof(x), int),   \
+x < 0 ? -x : x,   \
+(void)0))
+void declToImport() {
+  int x = -10;
+  int abs_x = abs_int(x);
+  (void)abs_x;
+}
Index: test/ASTMerge/choose-expr/Inputs/choose1.c
=

[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-15 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder added a comment.

In D58292#1399774 , @shafik wrote:

> This looks reasonable, I will wait for @martong and/or @a_sidorin to review.
>
> FYI LLDB is the other big user of ASTImpoter so it is helpful if you can run 
> `check-lldb` especially on MacOS so you can to catch regressions before 
> committing. After committing please make sure to monitor the GreenDragon 
> build bots:


I don't currently have a macOS machine to try this on, but I'll see what I can 
do next week.

I ran check-lldb with and without my change, and I don't seem to have broken 
anything new. However, check-lldb fails in a few ways at head (at least in my 
configuration; maybe I did something wrong):

   RESULT: FAILED (0 passes, 2 failures, 0 errors, 2 skipped, 0 



 
   expected failures, 0 unexpected successes)   



 




 
    



 
  Testing Time: 59.67s  



 
    



 
  Unexpected Passing Tests (2): 



 
  lldb-Suite :: functionalities/asan/TestMemoryHistory.py   



 
  lldb-Suite :: functionalities/asan/TestReportData.py  



 




 
    



 
  Failing Tests (3):



 
  lldb-Suite :: 



 
  
functionalities/data-formatt

[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-02-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56411#1398586 , @rjmccall wrote:

> But what we've just been talking about is not a validity rule, it's an 
> overload-resolution rule.  It's not *invalid* to use a device function as a 
> template argument to a host function template (or to a class template, which 
> of course is neither host nor device).  All you need to do is to resolve 
> otherwise-intractable overload ambiguities by matching with the host-ness of 
> the current context, which there's probably already code to do for when an 
> overload set is used as e.g. a function argument.


OK I found the code for resolving the function type template argument. 
Basically CheckTemplateArgument calls ResolveAddressOfOverloadedFunction, which 
creates an AddressOfFunctionResolver. The constructor of 
AddressOfFunctionResolver calls AddMatchingNonTemplateFunctions to the 
candidate set, where host-ness of CUDA function is checked to decide whether a 
function is added as candidate

https://github.com/llvm-mirror/clang/blob/master/lib/Sema/SemaOverload.cpp#L11174

However, as shown in the above link, there is one issue on that line, which is 
better demonstrated by the follow testcase

  __host__ int f() { return 1;}
  __device__ int f() { return 2;}
  template __kernel__ void t() { F(); }
  __host__ void g() { t<<<1,1>>>(); } 

In t, f should resolve to `__device__ f` since the true user of f is not g, 
but template t, or whatever is in t. Since t is a kernel, and kernel can only 
call device function, therefore we know that f should resolve to `__device__ f` 
instead of `__host__ f`.

However, currently clang resolves f to `__host__ f`, because it thinks the 
caller is S.CurContext, whereas S.CurContext is g.

The problem is that although f is reference in g, but it is not called by g. In 
this case, f is passed to a kernel template, and a kernel template can call 
device function, therefore f can be a device function.

The issue is that S.CurContext is not conveying the real caller or user of f in 
AddressOfFunctionResolver. To convey that information, a new member 
TemplateUser may need to be added to AddressOfFunctionResolver so that it knows 
that it is resolving a template argument and which template is using that 
argument.


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

https://reviews.llvm.org/D56411



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


[PATCH] D57579: [analyzer][WIP] Enable subcheckers to possess checker options

2019-02-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
Herald added a subscriber: jdoerfert.

> since I couldn't reproduce the error

Me neither, actually :/ This patch does provide a backup plan and it makes the 
code prettier, so we should definitely land it and i'm really greatful for it, 
but the option seems to work correctly in all possible ways even without it. 
Long-term, i guess, we could try to unlock ourselves the capability to rename 
checkers as much as we want by introducing checker aliases (which would work 
both for the purposes of enabling/disabling checkers and for checker options).




Comment at: unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp:67
 
   // Checker true has no option specified. It should get the default value when
   // search in parents turned off and false when search in parents turned on.

"`CheckerTwo`" was probably meant here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57579



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-15 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

I hacked around the run_experiments.py to set CMAKE_C_FLAGS and now I see the 
following error in stats.html. Note: I see the same error with an existing 
checker like PointerArithmChecker. And I do not hit this assert when I run the 
checker outside of csa-testbench.

  Assertion `CheckerTags.count(tag) != 0 && "Requested checker is not 
registered! Maybe you should add it as a " "dependency in Checkers.td?"'

Here's my config file:

  {
"projects": [
  {
"name": "TinyXML2",
"url": "https://github.com/leethomason/tinyxml2.git";,
"clang_sa_args": "-target x86_64-linux-gnu -L /usr/lib/x86_64-linux-gnu 
-B /usr/lib/x86_64-linux-gnu -B /usr/lib/gcc/x86_64-linux-gnu/5 -L 
/usr/lib/gcc/x86_64-linux-gnu/5 --analyze -Xanalyzer -analyzer-checker=core 
-Xanalyzer -analyzer-checker=alpha.core.PointerArithm -Xclang -analyzer-stats",
"clang_path": "path/install/bin",
"binary_dir": "build"
  }
],
  
"CodeChecker": {
  "url": "http://localhost:8001/Default";,
  "analyze_args": "",
  "store_args": ""
}
  }


Repository:
  rC Clang

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

https://reviews.llvm.org/D50488



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


Re: r354091 - Fix implementation of [temp.local]p4.

2019-02-15 Thread Francis Visoiu Mistrih via cfe-commits


> On Feb 15, 2019, at 1:53 PM, Richard Smith  wrote:
> 
> On Fri, 15 Feb 2019 at 09:56, Richard Smith  > wrote:
>> 
>> On Thu, 14 Feb 2019, 18:35 Francis Visoiu Mistrih via cfe-commits, 
>>  wrote:
>>> 
>>> Hi Richard,
>>> 
>>> This seems to now emit an error when building the sanitizer tests: 
>>> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/53965/consoleFull.
>>> 
>>> I managed to reproduce it locally and when reverting your commit the error 
>>> goes away.
>>> 
>>> I am not sure if the error is in the sanitizer test’s code or actually a 
>>> compiler error. Can you please take a look?
>> 
>> 
>> It's an error in the sanitizer test's code.
> 
> lldb bug fixed in r354173, sanitizer test bug fixed in r354174,
> re-committed as r354176.

Thanks Richard!

> 
>>> Thanks,
>>> 
>>> --
>>> Francis
>>> 
>>> On Feb 14, 2019, at 4:29 PM, Richard Smith via cfe-commits 
>>>  wrote:
>>> 
>>> Author: rsmith
>>> Date: Thu Feb 14 16:29:04 2019
>>> New Revision: 354091
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=354091&view=rev
>>> Log:
>>> Fix implementation of [temp.local]p4.
>>> 
>>> When a template-name is looked up, we need to give injected-class-name
>>> declarations of class templates special treatment, as they denote a
>>> template rather than a type.
>>> 
>>> Previously we achieved this by applying a filter to the lookup results
>>> after completing name lookup, but that is incorrect in various ways, not
>>> least of which is that it lost all information about access and how
>>> members were named, and the filtering caused us to generally lose
>>> all ambiguity errors between templates and non-templates.
>>> 
>>> We now preserve the lookup results exactly, and the few places that need
>>> to map from a declaration found by name lookup into a declaration of a
>>> template do so explicitly. Deduplication of repeated lookup results of
>>> the same injected-class-name declaration is done by name lookup instead
>>> of after the fact.
>>> 
>>> Modified:
>>>   cfe/trunk/include/clang/Sema/Lookup.h
>>>   cfe/trunk/include/clang/Sema/Sema.h
>>>   cfe/trunk/lib/Sema/SemaDecl.cpp
>>>   cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>>   cfe/trunk/lib/Sema/SemaLookup.cpp
>>>   cfe/trunk/lib/Sema/SemaTemplate.cpp
>>>   cfe/trunk/test/CXX/class.access/p4.cpp
>>>   cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
>>>   cfe/trunk/test/SemaTemplate/temp.cpp
>>> 
>>> Modified: cfe/trunk/include/clang/Sema/Lookup.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=354091&r1=354090&r2=354091&view=diff
>>> ==
>>> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
>>> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Feb 14 16:29:04 2019
>>> @@ -172,7 +172,8 @@ public:
>>>  : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
>>>LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl),
>>>ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
>>> -AllowHidden(Other.AllowHidden) {}
>>> +AllowHidden(Other.AllowHidden),
>>> +TemplateNameLookup(Other.TemplateNameLookup) {}
>>> 
>>>  // FIXME: Remove these deleted methods once the default build includes
>>>  // -Wdeprecated.
>>> @@ -193,7 +194,8 @@ public:
>>>HideTags(std::move(Other.HideTags)),
>>>Diagnose(std::move(Other.Diagnose)),
>>>AllowHidden(std::move(Other.AllowHidden)),
>>> -Shadowed(std::move(Other.Shadowed)) {
>>> +Shadowed(std::move(Other.Shadowed)),
>>> +TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
>>>Other.Paths = nullptr;
>>>Other.Diagnose = false;
>>>  }
>>> @@ -216,6 +218,7 @@ public:
>>>Diagnose = std::move(Other.Diagnose);
>>>AllowHidden = std::move(Other.AllowHidden);
>>>Shadowed = std::move(Other.Shadowed);
>>> +TemplateNameLookup = std::move(Other.TemplateNameLookup);
>>>Other.Paths = nullptr;
>>>Other.Diagnose = false;
>>>return *this;
>>> @@ -286,6 +289,15 @@ public:
>>>HideTags = Hide;
>>>  }
>>> 
>>> +  /// Sets whether this is a template-name lookup. For template-name 
>>> lookups,
>>> +  /// injected-class-names are treated as naming a template rather than a
>>> +  /// template specialization.
>>> +  void setTemplateNameLookup(bool TemplateName) {
>>> +TemplateNameLookup = TemplateName;
>>> +  }
>>> +
>>> +  bool isTemplateNameLookup() const { return TemplateNameLookup; }
>>> +
>>>  bool isAmbiguous() const {
>>>return getResultKind() == Ambiguous;
>>>  }
>>> @@ -739,6 +751,9 @@ private:
>>>  /// declaration that we skipped. This only happens when \c LookupKind
>>>  /// is \c LookupRedeclarationWithLinkage.
>>>  bool Shadowed = false;
>>> +
>>> +  /// True if we're looking up a template-name.
>>> +  bool TemplateNameLookup = false;
>>> };
>>> 
>>> /// Consumes visible declarations found when searching for
>>> 
>>> Modified: c

[PATCH] D58236: Make address space conversions a bit stricter.

2019-02-15 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaCast.cpp:2306
+ SrcPPointee.getAddressSpace()) ||
+  !DestPPtr->isAddressSpaceOverlapping(*SrcPPtr)) {
+Self.Diag(OpRange.getBegin(),

This should `if (Nested ? DestPPointee.getAddressSpace() != 
SrcPPointee.getAddressSpace() : 
!DestPPtr->isAddressSpaceOverlapping(*SrcPtr))`, I think.



Comment at: lib/Sema/SemaExpr.cpp:7706
   if (!lhq.compatiblyIncludes(rhq)) {
 // Treat address-space mismatches as fatal.  TODO: address subspaces
 if (!lhq.isAddressSpaceSupersetOf(rhq))

The TODO here is fixed as much as anything else is.



Comment at: lib/Sema/SemaExpr.cpp:7781
   do {
+// Inconsistent address spaces at this point is invalid, even if the
+// address spaces would be compatible.

Please extract variables for `cast(lhptee)->getPointeeType()` (and 
for `rhptee`).



Comment at: lib/Sema/SemaExpr.cpp:14206
+// XXX: Should this be a different variation of the error, like
+// 'changes address space in nested pointer qualifiers'?
+DiagKind = diag::err_typecheck_incompatible_address_space;

Yeah, I think that would be more straightforward.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58236



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


[PATCH] D57662: [clang-tidy] Parallelise clang-tidy-diff.py

2019-02-15 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: clang-tidy/tool/clang-tidy-diff.py:98
 
+  parser.add_argument('-j', type=int, default=0,
+  help='number of tidy instances to be run in parallel.')

zinovy.nis wrote:
> alexfh wrote:
> > The "clang-tidy runs are independent" assumption is unfortunately not valid 
> > for our internal compilation database integration, so making `-j0` the 
> > default will break it. Let's make it `1`.
> Do you mean you run it with `-fix` or like this?
Nope, our CompilationDatabase implementation doesn't support concurrent use 
(regardless of whether it's the same process or different ones).


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

https://reviews.llvm.org/D57662



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


[PATCH] D58074: [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier

2019-02-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

In D58074#1399881 , @lildmh wrote:

> Thanks for the catch! I also change the name from `OMPMappableExprListLocTy` 
> to `OMPVarListLocTy` to be more accurate. We can potentially factorize other 
> varlist clause code with this. But it will be too large for this patch.


Thanks for fixing this. Yes, if you can think we improve something in the code, 
please, go ahead in the next patches. LGTM!


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

https://reviews.llvm.org/D58074



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


[PATCH] D57112: [ASTTypeTraits] OMPClause handling

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

In D57112#1399516 , @lebedev.ri wrote:

> Ping @hokein / @alexfh (as per git blame).
>  Not sure who is best suited to review this.


I only made a couple of random fixes to these files, so I don't feel 
particularly competent to review them. Though overall the changes in this patch 
seem reasonable to me. No concerns from me ;)


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



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


[PATCH] D57655: clang-format with UseTab: Always sometimes doesn't insert the right amount of tabs.

2019-02-15 Thread Alexander Kornienko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354183: clang-format with UseTab: Always sometimes 
doesn't insert the right amount of… (authored by alexfh, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57655?vs=186629&id=187096#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57655

Files:
  lib/Format/WhitespaceManager.cpp
  unittests/Format/FormatTest.cpp


Index: lib/Format/WhitespaceManager.cpp
===
--- lib/Format/WhitespaceManager.cpp
+++ lib/Format/WhitespaceManager.cpp
@@ -679,11 +679,15 @@
   case FormatStyle::UT_Always: {
 unsigned FirstTabWidth =
 Style.TabWidth - WhitespaceStartColumn % Style.TabWidth;
-// Indent with tabs only when there's at least one full tab.
-if (FirstTabWidth + Style.TabWidth <= Spaces) {
-  Spaces -= FirstTabWidth;
-  Text.append("\t");
+// Insert only spaces when we want to end up before the next tab.
+if (Spaces < FirstTabWidth || Spaces == 1) {
+  Text.append(Spaces, ' ');
+  break;
 }
+// Align to the next tab.
+Spaces -= FirstTabWidth;
+Text.append("\t");
+
 Text.append(Spaces / Style.TabWidth, '\t');
 Text.append(Spaces % Style.TabWidth, ' ');
 break;
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -8751,6 +8751,9 @@
"\t\tparameter2); \\\n"
"\t}",
Tab);
+  verifyFormat("int a;\t  // x\n"
+   "int ; // x\n",
+   Tab);
 
   Tab.TabWidth = 4;
   Tab.IndentWidth = 8;


Index: lib/Format/WhitespaceManager.cpp
===
--- lib/Format/WhitespaceManager.cpp
+++ lib/Format/WhitespaceManager.cpp
@@ -679,11 +679,15 @@
   case FormatStyle::UT_Always: {
 unsigned FirstTabWidth =
 Style.TabWidth - WhitespaceStartColumn % Style.TabWidth;
-// Indent with tabs only when there's at least one full tab.
-if (FirstTabWidth + Style.TabWidth <= Spaces) {
-  Spaces -= FirstTabWidth;
-  Text.append("\t");
+// Insert only spaces when we want to end up before the next tab.
+if (Spaces < FirstTabWidth || Spaces == 1) {
+  Text.append(Spaces, ' ');
+  break;
 }
+// Align to the next tab.
+Spaces -= FirstTabWidth;
+Text.append("\t");
+
 Text.append(Spaces / Style.TabWidth, '\t');
 Text.append(Spaces % Style.TabWidth, ' ');
 break;
Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -8751,6 +8751,9 @@
"\t\tparameter2); \\\n"
"\t}",
Tab);
+  verifyFormat("int a;\t  // x\n"
+   "int ; // x\n",
+   Tab);
 
   Tab.TabWidth = 4;
   Tab.IndentWidth = 8;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354183 - clang-format with UseTab: Always sometimes doesn't insert the right amount of tabs.

2019-02-15 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Feb 15 15:07:43 2019
New Revision: 354183

URL: http://llvm.org/viewvc/llvm-project?rev=354183&view=rev
Log:
clang-format with UseTab: Always sometimes doesn't insert the right amount of 
tabs.

Trailing comments are not always aligned properly when UseTab is set to Always.

Consider:

int a;// x
int ; // x
With .clang-format:

---
Language:Cpp
BasedOnStyle: LLVM
UseTab: Always
...
The trailing comments of this code block should be aligned, but aren't

To align the first trailing comment it needs to insert 8 spaces. This should be
one tab plus six spaces. It skips the logic of the first partial tab in
FirstTabWidth (=2) + Style.TabWidth (=8) <= Spaces (=8) and only inserts one
tab. Proposed fix and test is attached.

Patch by Hylke Kleve.

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

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

Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=354183&r1=354182&r2=354183&view=diff
==
--- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp Fri Feb 15 15:07:43 2019
@@ -679,11 +679,15 @@ void WhitespaceManager::appendIndentText
   case FormatStyle::UT_Always: {
 unsigned FirstTabWidth =
 Style.TabWidth - WhitespaceStartColumn % Style.TabWidth;
-// Indent with tabs only when there's at least one full tab.
-if (FirstTabWidth + Style.TabWidth <= Spaces) {
-  Spaces -= FirstTabWidth;
-  Text.append("\t");
+// Insert only spaces when we want to end up before the next tab.
+if (Spaces < FirstTabWidth || Spaces == 1) {
+  Text.append(Spaces, ' ');
+  break;
 }
+// Align to the next tab.
+Spaces -= FirstTabWidth;
+Text.append("\t");
+
 Text.append(Spaces / Style.TabWidth, '\t');
 Text.append(Spaces % Style.TabWidth, ' ');
 break;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=354183&r1=354182&r2=354183&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Feb 15 15:07:43 2019
@@ -8751,6 +8751,9 @@ TEST_F(FormatTest, ConfigurableUseOfTab)
"\t\tparameter2); \\\n"
"\t}",
Tab);
+  verifyFormat("int a;\t  // x\n"
+   "int ; // x\n",
+   Tab);
 
   Tab.TabWidth = 4;
   Tab.IndentWidth = 8;


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


[PATCH] D58307: [Clang Driver] Add support for "-static-pie" argument to the Clang driver.

2019-02-15 Thread Siva Chandra via Phabricator via cfe-commits
sivachandra created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change mimics GCC's support for the "-static-pie" argument.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58307

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -176,6 +176,19 @@
 // CHECK-CLANG-NO-LIBGCC-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-CLANG-NO-LIBGCC-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
 //
+// RUN: %clang -static-pie -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=platform \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANG-LD-STATIC-PIE %s
+// CHECK-CLANG-LD-STATIC-PIE: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-CLANG-LD-STATIC-PIE: "-static"
+// CHECK-CLANG-LD-STATIC-PIE: "-pie"
+// CHECK-CLANG-LD-STATIC-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE: "-m" "elf_x86_64"
+// CHECK-CLANG-LD-STATIC-PIE: "{{.*}}rcrt1.o"
+// CHECK-CLANG-LD-STATIC-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
+//
 // RUN: %clang -dynamic -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=x86_64-unknown-linux -rtlib=platform \
 // RUN: --gcc-toolchain="" \
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -333,6 +333,7 @@
   const bool isAndroid = ToolChain.getTriple().isAndroid();
   const bool IsIAMCU = ToolChain.getTriple().isOSIAMCU();
   const bool IsPIE = getPIE(Args, ToolChain);
+  const bool IsStaticPIE = Args.hasArg(options::OPT_static_pie);
   const bool HasCRTBeginEndFiles =
   ToolChain.getTriple().hasEnvironment() ||
   (ToolChain.getTriple().getVendor() != llvm::Triple::MipsTechnologies);
@@ -353,6 +354,12 @@
   if (IsPIE)
 CmdArgs.push_back("-pie");
 
+  if (IsStaticPIE) {
+CmdArgs.push_back("-static");
+CmdArgs.push_back("-pie");
+CmdArgs.push_back("--no-dynamic-linker");
+  }
+
   if (Args.hasArg(options::OPT_rdynamic))
 CmdArgs.push_back("-export-dynamic");
 
@@ -402,7 +409,7 @@
 if (Args.hasArg(options::OPT_rdynamic))
   CmdArgs.push_back("-export-dynamic");
 
-if (!Args.hasArg(options::OPT_shared)) {
+if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) {
   const std::string Loader =
   D.DyldPrefix + ToolChain.getDynamicLinker(Args);
   CmdArgs.push_back("-dynamic-linker");
@@ -421,6 +428,8 @@
   crt1 = "gcrt1.o";
 else if (IsPIE)
   crt1 = "Scrt1.o";
+else if (IsStaticPIE)
+  crt1 = "rcrt1.o";
 else
   crt1 = "crt1.o";
   }
@@ -438,14 +447,14 @@
 crtbegin = isAndroid ? "crtbegin_static.o" : "crtbeginT.o";
   else if (Args.hasArg(options::OPT_shared))
 crtbegin = isAndroid ? "crtbegin_so.o" : "crtbeginS.o";
-  else if (IsPIE)
+  else if (IsPIE || IsStaticPIE)
 crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbeginS.o";
   else
 crtbegin = isAndroid ? "crtbegin_dynamic.o" : "crtbegin.o";
 
   if (HasCRTBeginEndFiles)
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
-}
+	}
 
 // Add crtfastmath.o if available and fast math is enabled.
 ToolChain.AddFastMathRuntimeIfAvailable(Args, CmdArgs);
@@ -489,7 +498,7 @@
 
   if (!Args.hasArg(options::OPT_nostdlib)) {
 if (!Args.hasArg(options::OPT_nodefaultlibs)) {
-  if (Args.hasArg(options::OPT_static))
+  if (Args.hasArg(options::OPT_static) || IsStaticPIE)
 CmdArgs.push_back("--start-group");
 
   if (NeedsSanitizerDeps)
@@ -524,7 +533,7 @@
   if (IsIAMCU)
 CmdArgs.push_back("-lgloss");
 
-  if (Args.hasArg(options::OPT_static))
+  if (Args.hasArg(options::OPT_static) || IsStaticPIE)
 CmdArgs.push_back("--end-group");
   else
 AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
@@ -541,7 +550,7 @@
   const char *crtend;
   if (Args.hasArg(options::OPT_shared))
 crtend = isAndroid ? "crtend_so.o" : "crtendS.o";
-  else if (IsPIE)
+  else if (IsPIE || IsStaticPIE)
 crtend = isAndroid ? "crtend_android.o" : "crtendS.o";
   else
 crtend = isAndroid ? "crtend_android.o" : "crtend.o";
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1137,19 +1137,22 @@
   bool isCygMing = Triple.i

Re: [PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

2019-02-15 Thread Martin Storsjö via cfe-commits

It broke on the first commit and is broken even after all of them.

// Martin

On Fri, 15 Feb 2019, Yitzhak Mandelbaum wrote:


Was it the complete diff or one of the intermediate commits? I accidentally
committed the diff as a series of commits rather than one (squashed)
commit. 

On Fri, Feb 15, 2019 at 4:51 PM Martin Storsjö via Phabricator
 wrote:
  mstorsjo added a comment.

  This broke compilation with GCC 5.4 on Ubuntu 16.04:

   
  ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:243:
  warning: missing terminating " character
   
  ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:3:
  error: missing terminating " character
       EXPECT_TRUE(matches(
       ^
   
  ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:480:7:
  error: stray ‘\’ in program
             void z(X x) { x.m(); }
           ^


  Repository:
    rL LLVM

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

  https://reviews.llvm.org/D56850




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


[PATCH] D57659: [Sema] SequenceChecker: Add some comments + related small NFCs in preparation of the following patches

2019-02-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 187090.
riccibruno marked an inline comment as done.
riccibruno added a comment.

Rebased and fixed a comment.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57659

Files:
  lib/Sema/SemaChecking.cpp

Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -11733,20 +11733,38 @@
 UK_Count = UK_ModAsSideEffect + 1
   };
 
+  /// Bundle together a sequencing region and the expression corresponding
+  /// to a specific usage. One Usage is stored for each usage kind in UsageInfo.
   struct Usage {
-Expr *Use;
+Expr *UsageExpr = nullptr;
 SequenceTree::Seq Seq;
-
-Usage() : Use(nullptr), Seq() {}
+Usage() = default;
+Usage(Expr *UsageExpr, SequenceTree::Seq Seq)
+: UsageExpr(UsageExpr), Seq(Seq) {}
   };
 
-  struct UsageInfo {
-Usage Uses[UK_Count];
+  class UsageInfo {
+/// The expressions corresponding to each usage kind.
+Expr *UsageExprs[UK_Count]{};
+
+/// The sequencing regions corresponding to each usage kind.
+SequenceTree::Seq Seqs[UK_Count]{};
 
-/// Have we issued a diagnostic for this variable already?
-bool Diagnosed;
+/// Have we issued a diagnostic for this object already?
+bool Diagnosed = false;
 
-UsageInfo() : Uses(), Diagnosed(false) {}
+  public:
+Usage getUsage(UsageKind UK) const {
+  assert(UK < UK_Count && "Invalid UsageKind!");
+  return Usage{UsageExprs[UK], Seqs[UK]};
+}
+void setUsage(UsageKind UK, Usage U) {
+  assert(UK < UK_Count && "Invalid UsageKind!");
+  UsageExprs[UK] = U.UsageExpr;
+  Seqs[UK] = U.Seq;
+}
+void markDiagnosed() { Diagnosed = true; }
+bool alreadyDiagnosed() const { return Diagnosed; }
   };
   using UsageInfoMap = llvm::SmallDenseMap;
 
@@ -11781,11 +11799,14 @@
 }
 
 ~SequencedSubexpression() {
-  for (auto &M : llvm::reverse(ModAsSideEffect)) {
-UsageInfo &U = Self.UsageMap[M.first];
-auto &SideEffectUsage = U.Uses[UK_ModAsSideEffect];
-Self.addUsage(U, M.first, SideEffectUsage.Use, UK_ModAsValue);
-SideEffectUsage = M.second;
+  for (std::pair &M : llvm::reverse(ModAsSideEffect)) {
+// Add a new usage with usage kind UK_ModAsValue, and then restore
+// the previous usage with UK_ModAsSideEffect (thus clearing it if
+// the previous one was empty).
+UsageInfo &UI = Self.UsageMap[M.first];
+Usage SideEffectUsage = UI.getUsage(UK_ModAsSideEffect);
+Self.addUsage(M.first, UI, SideEffectUsage.UsageExpr, UK_ModAsValue);
+UI.setUsage(UK_ModAsSideEffect, M.second);
   }
   Self.ModAsSideEffect = OldModAsSideEffect;
 }
@@ -11848,28 +11869,34 @@
   }
 
   /// Note that an object was modified or used by an expression.
-  void addUsage(UsageInfo &UI, Object O, Expr *Ref, UsageKind UK) {
-Usage &U = UI.Uses[UK];
-if (!U.Use || !Tree.isUnsequenced(Region, U.Seq)) {
+  /// UI is the UsageInfo for the object O as obtained via the UsageMap.
+  void addUsage(Object O, UsageInfo &UI, Expr *UsageExpr, UsageKind UK) {
+// Get the old usage for the given object and usage kind.
+Usage U = UI.getUsage(UK);
+if (!U.UsageExpr || !Tree.isUnsequenced(Region, U.Seq)) {
+  // If we have a modification as side effect and are in a sequenced
+  // subexpression, save the old Usage so that we can restore it later
+  // in SequencedSubexpression::~SequencedSubexpression.
   if (UK == UK_ModAsSideEffect && ModAsSideEffect)
 ModAsSideEffect->push_back(std::make_pair(O, U));
-  U.Use = Ref;
-  U.Seq = Region;
+  // Then record the new usage with the current sequencing region.
+  UI.setUsage(UK, Usage(UsageExpr, Region));
 }
   }
 
   /// Check whether a modification or use conflicts with a prior usage.
-  void checkUsage(Object O, UsageInfo &UI, Expr *Ref, UsageKind OtherKind,
+  /// UI is the UsageInfo for the object O as obtained via the UsageMap.
+  void checkUsage(Object O, UsageInfo &UI, Expr *UsageExpr, UsageKind OtherKind,
   bool IsModMod) {
-if (UI.Diagnosed)
+if (UI.alreadyDiagnosed())
   return;
 
-const Usage &U = UI.Uses[OtherKind];
-if (!U.Use || !Tree.isUnsequenced(Region, U.Seq))
+Usage U = UI.getUsage(OtherKind);
+if (!U.UsageExpr || !Tree.isUnsequenced(Region, U.Seq))
   return;
 
-Expr *Mod = U.Use;
-Expr *ModOrUse = Ref;
+Expr *Mod = U.UsageExpr;
+Expr *ModOrUse = UsageExpr;
 if (OtherKind == UK_Use)
   std::swap(Mod, ModOrUse);
 
@@ -11877,32 +11904,60 @@
  IsModMod ? diag::warn_unsequenced_mod_mod
   : diag::warn_unsequenced_mod_use)
   << O << SourceRange(ModOrUse->getExprLoc());
-UI.Diagnosed = true;
+UI.markDiagnosed();
   }
 
-  void 

[PATCH] D58297: [Sema] SequenceChecker: C++17 sequencing rules for built-in operators <<, >>, .*, ->*, =, op=

2019-02-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 187089.
riccibruno added a comment.

1. Only call `note{Pre,Post}{Use, Mod}` if we have a valid memory location.
2. Fixed 2 tests in `CXX/drs` which I initially missed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58297

Files:
  lib/Sema/SemaChecking.cpp
  test/CXX/drs/dr2xx.cpp
  test/CXX/drs/dr6xx.cpp
  test/SemaCXX/warn-unsequenced.cpp

Index: test/SemaCXX/warn-unsequenced.cpp
===
--- test/SemaCXX/warn-unsequenced.cpp
+++ test/SemaCXX/warn-unsequenced.cpp
@@ -24,7 +24,6 @@
   a + a++; // cxx11-warning {{unsequenced modification and access to 'a'}}
// cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   a = a++; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
-   // TODO cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   ++ ++a; // ok
   (a++, a++); // ok
   ++a + ++a; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
@@ -34,13 +33,10 @@
   (a++, a) = 0; // ok, increment is sequenced before value computation of LHS
   a = xs[++a]; // ok
   a = xs[a++]; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
-   // TODO cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   (a ? xs[0] : xs[1]) = ++a; // cxx11-warning {{unsequenced modification and access to 'a'}}
- // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   a = (++a, ++a); // ok
   a = (a++, ++a); // ok
   a = (a++, a++); // cxx11-warning {{multiple unsequenced modifications to 'a'}}
-  // TODO cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   f(a, a); // ok
   f(a = 0, a); // cxx11-warning {{unsequenced modification and access to 'a'}}
// cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
@@ -59,7 +55,6 @@
   (++a, a) += 1; // ok
   a = ++a; // ok
   a += ++a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-// TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
   A agg1 = { a++, a++ }; // ok
   A agg2 = { a++ + a, a++ }; // cxx11-warning {{unsequenced modification and access to 'a'}}
@@ -75,7 +70,6 @@
   a = S { ++a, a++ }.n; // ok
   A { ++a, a++ }.x; // ok
   a = A { ++a, a++ }.x; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
-// TODO cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   A { ++a, a++ }.x + A { ++a, a++ }.y; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
// cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
 
@@ -110,14 +104,10 @@
   a += (a++, a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
-  int *p = xs;
-  a = *(a++, p); // ok
   a = a++ && a; // ok
-  p[(long long unsigned)(p = 0)]; // cxx11-warning {{unsequenced modification and access to 'p'}}
 
   A *q = &agg1;
   (q = &agg2)->y = q->x; // cxx11-warning {{unsequenced modification and access to 'q'}}
- // TODO cxx17-warning@-1 {{unsequenced modification and access to 'q'}}
 
   // This has undefined behavior if a == 0; otherwise, the side-effect of the
   // increment is sequenced before the value computation of 'f(a, a)', which is
@@ -145,20 +135,14 @@
   xs[8] ? ++a : a++; // no-warning
   xs[8] ? a+=1 : a+= 2; // no-warning
   (xs[8] ? a+=1 : a+= 2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (xs[8] ? a+=1 : a) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (xs[8] ? a : a+= 2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-   // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   a = (xs[8] ? a+=1 : a+= 2); // no-warning
   a += (xs[8] ? a+=1 : a+= 2); // cxx11-warning {{unsequenced modification and access to 'a'}}
-   // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
   (false ? a+=1 : a) = a; // no-warning
   (true ? a+=1 : a) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
- // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (false ? a : a+=2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (true ? a : a+=2) = a; // no-warning
 
   xs[8] && (++a + a++); // cxx11-warning {{multiple unsequenced modifications to 'a'}}
@

r354180 - [ObjC] For type substitution in generics use a regular recursive type visitor.

2019-02-15 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Fri Feb 15 14:14:58 2019
New Revision: 354180

URL: http://llvm.org/viewvc/llvm-project?rev=354180&view=rev
Log:
[ObjC] For type substitution in generics use a regular recursive type visitor.

Switch to the inheritance-based visitor from the lambda-based visitor to
allow both preorder and postorder customizations during type
transformation. NFC intended.

Reviewers: ahatanak, erik.pilkington

Reviewed By: erik.pilkington

Subscribers: jkorous, dexonsmith, cfe-commits

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


Modified:
cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=354180&r1=354179&r2=354180&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Fri Feb 15 14:14:58 2019
@@ -723,25 +723,30 @@ const ObjCObjectPointerType *ObjCObjectP
   return ctx.getObjCObjectPointerType(obj)->castAs();
 }
 
-template
-static QualType simpleTransform(ASTContext &ctx, QualType type, F &&f);
-
 namespace {
 
-/// Visitor used by simpleTransform() to perform the transformation.
-template
-struct SimpleTransformVisitor
- : public TypeVisitor, QualType> {
+/// Visitor used to perform a simple type transformation that does not change
+/// the semantics of the type.
+template 
+struct SimpleTransformVisitor : public TypeVisitor {
   ASTContext &Ctx;
-  F &&TheFunc;
 
   QualType recurse(QualType type) {
-return simpleTransform(Ctx, type, std::move(TheFunc));
+// Split out the qualifiers from the type.
+SplitQualType splitType = type.split();
+
+// Visit the type itself.
+QualType result = static_cast(this)->Visit(splitType.Ty);
+if (result.isNull())
+  return result;
+
+// Reconstruct the transformed type by applying the local qualifiers
+// from the split type.
+return Ctx.getQualifiedType(result, splitType.Quals);
   }
 
 public:
-  SimpleTransformVisitor(ASTContext &ctx, F &&f)
-  : Ctx(ctx), TheFunc(std::move(f)) {}
+  explicit SimpleTransformVisitor(ASTContext &ctx) : Ctx(ctx) {}
 
   // None of the clients of this transformation can occur where
   // there are dependent types, so skip dependent types.
@@ -1121,220 +1126,205 @@ public:
 #undef SUGARED_TYPE_CLASS
 };
 
-} // namespace
-
-/// Perform a simple type transformation that does not change the
-/// semantics of the type.
-template
-static QualType simpleTransform(ASTContext &ctx, QualType type, F &&f) {
-  // Transform the type. If it changed, return the transformed result.
-  QualType transformed = f(type);
-  if (transformed.getAsOpaquePtr() != type.getAsOpaquePtr())
-return transformed;
-
-  // Split out the qualifiers from the type.
-  SplitQualType splitType = type.split();
-
-  // Visit the type itself.
-  SimpleTransformVisitor visitor(ctx, std::forward(f));
-  QualType result = visitor.Visit(splitType.Ty);
-  if (result.isNull())
-return result;
-
-  // Reconstruct the transformed type by applying the local qualifiers
-  // from the split type.
-  return ctx.getQualifiedType(result, splitType.Quals);
-}
-
-/// Substitute the given type arguments for Objective-C type
-/// parameters within the given type, recursively.
-QualType QualType::substObjCTypeArgs(
-   ASTContext &ctx,
-   ArrayRef typeArgs,
-   ObjCSubstitutionContext context) const {
-  return simpleTransform(ctx, *this,
- [&](QualType type) -> QualType {
-SplitQualType splitType = type.split();
+struct SubstObjCTypeArgsVisitor
+: public SimpleTransformVisitor {
+  using BaseType = SimpleTransformVisitor;
+
+  ArrayRef TypeArgs;
+  ObjCSubstitutionContext SubstContext;
+
+  SubstObjCTypeArgsVisitor(ASTContext &ctx, ArrayRef typeArgs,
+   ObjCSubstitutionContext context)
+  : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
 
+  QualType VisitObjCTypeParamType(const ObjCTypeParamType *OTPTy) {
 // Replace an Objective-C type parameter reference with the corresponding
 // type argument.
-if (const auto *OTPTy = dyn_cast(splitType.Ty)) {
-  ObjCTypeParamDecl *typeParam = OTPTy->getDecl();
-  // If we have type arguments, use them.
-  if (!typeArgs.empty()) {
-QualType argType = typeArgs[typeParam->getIndex()];
-if (OTPTy->qual_empty())
-  return ctx.getQualifiedType(argType, splitType.Quals);
-
-// Apply protocol lists if exists.
-bool hasError;
-SmallVector protocolsVec;
-protocolsVec.append(OTPTy->qual_begin(),
-OTPTy->qual_end());
-ArrayRef protocolsToApply = protocolsVec;
-QualType resultTy = ctx.applyObjCProtocolQualifiers(argType,
-protocolsToApply, hasError, true/*allowOnPointerType*/);
+ObjCTypeParamDecl *typeParam = OTPTy->getDecl();
+// If we have type arguments, use

[PATCH] D57075: [ObjC] For type substitution in generics use a regular recursive type visitor.

2019-02-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354180: [ObjC] For type substitution in generics use a 
regular recursive type visitor. (authored by vsapsai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57075?vs=183668&id=187086#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57075

Files:
  cfe/trunk/lib/AST/Type.cpp

Index: cfe/trunk/lib/AST/Type.cpp
===
--- cfe/trunk/lib/AST/Type.cpp
+++ cfe/trunk/lib/AST/Type.cpp
@@ -723,25 +723,30 @@
   return ctx.getObjCObjectPointerType(obj)->castAs();
 }
 
-template
-static QualType simpleTransform(ASTContext &ctx, QualType type, F &&f);
-
 namespace {
 
-/// Visitor used by simpleTransform() to perform the transformation.
-template
-struct SimpleTransformVisitor
- : public TypeVisitor, QualType> {
+/// Visitor used to perform a simple type transformation that does not change
+/// the semantics of the type.
+template 
+struct SimpleTransformVisitor : public TypeVisitor {
   ASTContext &Ctx;
-  F &&TheFunc;
 
   QualType recurse(QualType type) {
-return simpleTransform(Ctx, type, std::move(TheFunc));
+// Split out the qualifiers from the type.
+SplitQualType splitType = type.split();
+
+// Visit the type itself.
+QualType result = static_cast(this)->Visit(splitType.Ty);
+if (result.isNull())
+  return result;
+
+// Reconstruct the transformed type by applying the local qualifiers
+// from the split type.
+return Ctx.getQualifiedType(result, splitType.Quals);
   }
 
 public:
-  SimpleTransformVisitor(ASTContext &ctx, F &&f)
-  : Ctx(ctx), TheFunc(std::move(f)) {}
+  explicit SimpleTransformVisitor(ASTContext &ctx) : Ctx(ctx) {}
 
   // None of the clients of this transformation can occur where
   // there are dependent types, so skip dependent types.
@@ -1121,220 +1126,205 @@
 #undef SUGARED_TYPE_CLASS
 };
 
-} // namespace
-
-/// Perform a simple type transformation that does not change the
-/// semantics of the type.
-template
-static QualType simpleTransform(ASTContext &ctx, QualType type, F &&f) {
-  // Transform the type. If it changed, return the transformed result.
-  QualType transformed = f(type);
-  if (transformed.getAsOpaquePtr() != type.getAsOpaquePtr())
-return transformed;
-
-  // Split out the qualifiers from the type.
-  SplitQualType splitType = type.split();
-
-  // Visit the type itself.
-  SimpleTransformVisitor visitor(ctx, std::forward(f));
-  QualType result = visitor.Visit(splitType.Ty);
-  if (result.isNull())
-return result;
-
-  // Reconstruct the transformed type by applying the local qualifiers
-  // from the split type.
-  return ctx.getQualifiedType(result, splitType.Quals);
-}
-
-/// Substitute the given type arguments for Objective-C type
-/// parameters within the given type, recursively.
-QualType QualType::substObjCTypeArgs(
-   ASTContext &ctx,
-   ArrayRef typeArgs,
-   ObjCSubstitutionContext context) const {
-  return simpleTransform(ctx, *this,
- [&](QualType type) -> QualType {
-SplitQualType splitType = type.split();
+struct SubstObjCTypeArgsVisitor
+: public SimpleTransformVisitor {
+  using BaseType = SimpleTransformVisitor;
+
+  ArrayRef TypeArgs;
+  ObjCSubstitutionContext SubstContext;
+
+  SubstObjCTypeArgsVisitor(ASTContext &ctx, ArrayRef typeArgs,
+   ObjCSubstitutionContext context)
+  : BaseType(ctx), TypeArgs(typeArgs), SubstContext(context) {}
 
+  QualType VisitObjCTypeParamType(const ObjCTypeParamType *OTPTy) {
 // Replace an Objective-C type parameter reference with the corresponding
 // type argument.
-if (const auto *OTPTy = dyn_cast(splitType.Ty)) {
-  ObjCTypeParamDecl *typeParam = OTPTy->getDecl();
-  // If we have type arguments, use them.
-  if (!typeArgs.empty()) {
-QualType argType = typeArgs[typeParam->getIndex()];
-if (OTPTy->qual_empty())
-  return ctx.getQualifiedType(argType, splitType.Quals);
-
-// Apply protocol lists if exists.
-bool hasError;
-SmallVector protocolsVec;
-protocolsVec.append(OTPTy->qual_begin(),
-OTPTy->qual_end());
-ArrayRef protocolsToApply = protocolsVec;
-QualType resultTy = ctx.applyObjCProtocolQualifiers(argType,
-protocolsToApply, hasError, true/*allowOnPointerType*/);
+ObjCTypeParamDecl *typeParam = OTPTy->getDecl();
+// If we have type arguments, use them.
+if (!TypeArgs.empty()) {
+  QualType argType = TypeArgs[typeParam->getIndex()];
+  if (OTPTy->qual_empty())
+return argType;
+
+  // Apply protocol lists if exists.
+  bool hasError;
+  SmallVector protocolsVec;
+  protocolsV

[PATCH] D53633: [AArch64] Implement FP16FML intrinsics

2019-02-15 Thread Ahmed Bougacha via Phabricator via cfe-commits
ab added inline comments.



Comment at: cfe/trunk/test/CodeGen/aarch64-neon-fp16fml.c:12
+
+float32x2_t test_vfmlal_low_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlal_low_u32(<2 x float> %a, <4 x 
half> %b, <4 x half> %c)

SjoerdMeijer wrote:
> SjoerdMeijer wrote:
> > ab wrote:
> > > Hey folks, I'm curious: where does the "_u32" suffix come from? Should it 
> > > be _f16?
> > > 
> > > Also, are there any new ACLE/intrinsic list documents? As far as I can 
> > > tell there hasn't been any release since IHI0073B/IHI0053D.
> > > Also, are there any new ACLE/intrinsic list documents? As far as I can 
> > > tell there hasn't been any release since IHI0073B/IHI0053D.
> > 
> > I've checked, and an updated ACLE that includes these FP16FML intrinsics is 
> > coming soon.
> > 
> > > where does the "_u32" suffix come from? Should it be _f16?
> > 
> > Good question. It could probably be _f32 or _f16, but _u32 doesn't seem to 
> > make much sense. Looks like the spec says _u32, and that's also what GCC 
> > has implemented. I think we want to update the spec and fix the name before 
> > the updated spec is available. Will chase this, and let you know once I 
> > know more.
> An update on this: we should change this to _f32 (because the first suffixes 
> were refering to the ouput type). The ACLE will be updated accordingly, and 
> also GCC will change its current implementation (from _u32 to _f32).  Many 
> thanks for raising this issue.
> Is there a volunteer to prepare a patch? Or do you have one already? :-) I 
> could look at it, but that will be towards the end of next week.
> I've checked, and an updated ACLE that includes these FP16FML intrinsics is 
> coming soon.

Great, thanks!

> An update on this: we should change this to _f32 (because the first suffixes 
> were refering to the ouput type).

Hmm, I was thinking _f16 based on the vmlal intrinsics: they seem to be named 
after the multiplication type rather than that of the accumulator/output.

Either way seems fine to me though, I'll defer to you folks.

> The ACLE will be updated accordingly, and also GCC will change its current 
> implementation (from _u32 to _f32). Many thanks for raising this issue.
Is there a volunteer to prepare a patch? Or do you have one already? :-) I 
could look at it, but that will be towards the end of next week.

Sure: D58306 (with _f16 though, let me know what you think of vmlal)

Thanks for checking!


Repository:
  rL LLVM

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

https://reviews.llvm.org/D53633



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


Re: [PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

2019-02-15 Thread Yitzhak Mandelbaum via cfe-commits
Was it the complete diff or one of the intermediate commits? I accidentally
committed the diff as a series of commits rather than one (squashed)
commit.

On Fri, Feb 15, 2019 at 4:51 PM Martin Storsjö via Phabricator <
revi...@reviews.llvm.org> wrote:

> mstorsjo added a comment.
>
> This broke compilation with GCC 5.4 on Ubuntu 16.04:
>
>
> ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:243:
> warning: missing terminating " character
>   ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:3:
> error: missing terminating " character
>  EXPECT_TRUE(matches(
>  ^
>   ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:480:7:
> error: stray ‘\’ in program
>void z(X x) { x.m(); }
>  ^
>
>
> Repository:
>   rL LLVM
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D56850/new/
>
> https://reviews.llvm.org/D56850
>
>
>
>


smime.p7s
Description: S/MIME Cryptographic Signature
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58306: [AArch64] Change size suffix for FP16FML intrinsics.

2019-02-15 Thread Ahmed Bougacha via Phabricator via cfe-commits
ab created this revision.
ab added reviewers: SjoerdMeijer, bryanpkc.
ab added a project: clang.
Herald added a subscriber: javed.absar.

These currently use _u32, but they should instead use _f32 or _f16, the types 
of the accumulator, and of the multiplication.

I'm starting with _f16 (because that seems to match the various integer vmlal 
variants), but either seems fine.


Repository:
  rC Clang

https://reviews.llvm.org/D58306

Files:
  include/clang/Basic/arm_neon.td
  test/CodeGen/aarch64-neon-fp16fml.c

Index: test/CodeGen/aarch64-neon-fp16fml.c
===
--- test/CodeGen/aarch64-neon-fp16fml.c
+++ test/CodeGen/aarch64-neon-fp16fml.c
@@ -9,188 +9,188 @@
 
 // Vector form
 
-float32x2_t test_vfmlal_low_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlal_low_u32(<2 x float> %a, <4 x half> %b, <4 x half> %c)
+float32x2_t test_vfmlal_low_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlal_low_f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> @llvm.aarch64.neon.fmlal.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlal_low_u32(a, b, c);
+  return vfmlal_low_f16(a, b, c);
 }
 
-float32x2_t test_vfmlsl_low_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlsl_low_u32(<2 x float> %a, <4 x half> %b, <4 x half> %c)
+float32x2_t test_vfmlsl_low_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlsl_low_f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> @llvm.aarch64.neon.fmlsl.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlsl_low_u32(a, b, c);
+  return vfmlsl_low_f16(a, b, c);
 }
 
-float32x2_t test_vfmlal_high_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlal_high_u32(<2 x float> %a, <4 x half> %b, <4 x half> %c)
+float32x2_t test_vfmlal_high_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlal_high_f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> @llvm.aarch64.neon.fmlal2.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlal_high_u32(a, b, c);
+  return vfmlal_high_f16(a, b, c);
 }
 
-float32x2_t test_vfmlsl_high_u32(float32x2_t a, float16x4_t b, float16x4_t c) {
-// CHECK-LABEL: define <2 x float> @test_vfmlsl_high_u32(<2 x float> %a, <4 x half> %b, <4 x half> %c)
+float32x2_t test_vfmlsl_high_f16(float32x2_t a, float16x4_t b, float16x4_t c) {
+// CHECK-LABEL: define <2 x float> @test_vfmlsl_high_f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <2 x float> @llvm.aarch64.neon.fmlsl2.v2f32.v4f16(<2 x float> %a, <4 x half> %b, <4 x half> %c)
 // CHECK: ret <2 x float> [[RESULT]]
-  return vfmlsl_high_u32(a, b, c);
+  return vfmlsl_high_f16(a, b, c);
 }
 
-float32x4_t test_vfmlalq_low_u32(float32x4_t a, float16x8_t b, float16x8_t c) {
-// CHECK-LABEL: define <4 x float> @test_vfmlalq_low_u32(<4 x float> %a, <8 x half> %b, <8 x half> %c)
+float32x4_t test_vfmlalq_low_f16(float32x4_t a, float16x8_t b, float16x8_t c) {
+// CHECK-LABEL: define <4 x float> @test_vfmlalq_low_f16(<4 x float> %a, <8 x half> %b, <8 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <4 x float> @llvm.aarch64.neon.fmlal.v4f32.v8f16(<4 x float> %a, <8 x half> %b, <8 x half> %c)
 // CHECK: ret <4 x float> [[RESULT]]
-  return vfmlalq_low_u32(a, b, c);
+  return vfmlalq_low_f16(a, b, c);
 }
 
-float32x4_t test_vfmlslq_low_u32(float32x4_t a, float16x8_t b, float16x8_t c) {
-// CHECK-LABEL: define <4 x float> @test_vfmlslq_low_u32(<4 x float> %a, <8 x half> %b, <8 x half> %c)
+float32x4_t test_vfmlslq_low_f16(float32x4_t a, float16x8_t b, float16x8_t c) {
+// CHECK-LABEL: define <4 x float> @test_vfmlslq_low_f16(<4 x float> %a, <8 x half> %b, <8 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <4 x float> @llvm.aarch64.neon.fmlsl.v4f32.v8f16(<4 x float> %a, <8 x half> %b, <8 x half> %c)
 // CHECK: ret <4 x float> [[RESULT]]
-  return vfmlslq_low_u32(a, b, c);
+  return vfmlslq_low_f16(a, b, c);
 }
 
-float32x4_t test_vfmlalq_high_u32(float32x4_t a, float16x8_t b, float16x8_t c) {
-// CHECK-LABEL: define <4 x float> @test_vfmlalq_high_u32(<4 x float> %a, <8 x half> %b, <8 x half> %c)
+float32x4_t test_vfmlalq_high_f16(float32x4_t a, float16x8_t b, float16x8_t c) {
+// CHECK-LABEL: define <4 x float> @test_vfmlalq_high_f16(<4 x float> %a, <8 x half> %b, <8 x half> %c)
 // CHECK: [[RESULT:%.*]] = call <4 x float> @llvm.aarch64.neon.fmlal2.v4f32.v8f16(<4 x float> %a, <8 x half> %b, <8 x half> %c)
 // CHECK: ret <4 x float> [[RESULT]]
-  return vfmlalq_high_u32(a, b, c);
+  re

[PATCH] D57910: [ASTImporter] Find previous friend function template

2019-02-15 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM, I just ran `check-lldb` and I don't see any regressions.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57910



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


Re: r354091 - Fix implementation of [temp.local]p4.

2019-02-15 Thread Richard Smith via cfe-commits
On Fri, 15 Feb 2019 at 09:56, Richard Smith  wrote:
>
> On Thu, 14 Feb 2019, 18:35 Francis Visoiu Mistrih via cfe-commits, 
>  wrote:
>>
>> Hi Richard,
>>
>> This seems to now emit an error when building the sanitizer tests: 
>> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/53965/consoleFull.
>>
>> I managed to reproduce it locally and when reverting your commit the error 
>> goes away.
>>
>> I am not sure if the error is in the sanitizer test’s code or actually a 
>> compiler error. Can you please take a look?
>
>
> It's an error in the sanitizer test's code.

lldb bug fixed in r354173, sanitizer test bug fixed in r354174,
re-committed as r354176.

>> Thanks,
>>
>> --
>> Francis
>>
>> On Feb 14, 2019, at 4:29 PM, Richard Smith via cfe-commits 
>>  wrote:
>>
>> Author: rsmith
>> Date: Thu Feb 14 16:29:04 2019
>> New Revision: 354091
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=354091&view=rev
>> Log:
>> Fix implementation of [temp.local]p4.
>>
>> When a template-name is looked up, we need to give injected-class-name
>> declarations of class templates special treatment, as they denote a
>> template rather than a type.
>>
>> Previously we achieved this by applying a filter to the lookup results
>> after completing name lookup, but that is incorrect in various ways, not
>> least of which is that it lost all information about access and how
>> members were named, and the filtering caused us to generally lose
>> all ambiguity errors between templates and non-templates.
>>
>> We now preserve the lookup results exactly, and the few places that need
>> to map from a declaration found by name lookup into a declaration of a
>> template do so explicitly. Deduplication of repeated lookup results of
>> the same injected-class-name declaration is done by name lookup instead
>> of after the fact.
>>
>> Modified:
>>cfe/trunk/include/clang/Sema/Lookup.h
>>cfe/trunk/include/clang/Sema/Sema.h
>>cfe/trunk/lib/Sema/SemaDecl.cpp
>>cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>cfe/trunk/lib/Sema/SemaLookup.cpp
>>cfe/trunk/lib/Sema/SemaTemplate.cpp
>>cfe/trunk/test/CXX/class.access/p4.cpp
>>cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
>>cfe/trunk/test/SemaTemplate/temp.cpp
>>
>> Modified: cfe/trunk/include/clang/Sema/Lookup.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=354091&r1=354090&r2=354091&view=diff
>> ==
>> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
>> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Feb 14 16:29:04 2019
>> @@ -172,7 +172,8 @@ public:
>>   : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
>> LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl),
>> ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
>> -AllowHidden(Other.AllowHidden) {}
>> +AllowHidden(Other.AllowHidden),
>> +TemplateNameLookup(Other.TemplateNameLookup) {}
>>
>>   // FIXME: Remove these deleted methods once the default build includes
>>   // -Wdeprecated.
>> @@ -193,7 +194,8 @@ public:
>> HideTags(std::move(Other.HideTags)),
>> Diagnose(std::move(Other.Diagnose)),
>> AllowHidden(std::move(Other.AllowHidden)),
>> -Shadowed(std::move(Other.Shadowed)) {
>> +Shadowed(std::move(Other.Shadowed)),
>> +TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
>> Other.Paths = nullptr;
>> Other.Diagnose = false;
>>   }
>> @@ -216,6 +218,7 @@ public:
>> Diagnose = std::move(Other.Diagnose);
>> AllowHidden = std::move(Other.AllowHidden);
>> Shadowed = std::move(Other.Shadowed);
>> +TemplateNameLookup = std::move(Other.TemplateNameLookup);
>> Other.Paths = nullptr;
>> Other.Diagnose = false;
>> return *this;
>> @@ -286,6 +289,15 @@ public:
>> HideTags = Hide;
>>   }
>>
>> +  /// Sets whether this is a template-name lookup. For template-name 
>> lookups,
>> +  /// injected-class-names are treated as naming a template rather than a
>> +  /// template specialization.
>> +  void setTemplateNameLookup(bool TemplateName) {
>> +TemplateNameLookup = TemplateName;
>> +  }
>> +
>> +  bool isTemplateNameLookup() const { return TemplateNameLookup; }
>> +
>>   bool isAmbiguous() const {
>> return getResultKind() == Ambiguous;
>>   }
>> @@ -739,6 +751,9 @@ private:
>>   /// declaration that we skipped. This only happens when \c LookupKind
>>   /// is \c LookupRedeclarationWithLinkage.
>>   bool Shadowed = false;
>> +
>> +  /// True if we're looking up a template-name.
>> +  bool TemplateNameLookup = false;
>> };
>>
>> /// Consumes visible declarations found when searching for
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354091&r1=354090&r2=354091&view=diff
>> 

r354176 - Fix implementation of [temp.local]p4.

2019-02-15 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 15 13:53:07 2019
New Revision: 354176

URL: http://llvm.org/viewvc/llvm-project?rev=354176&view=rev
Log:
Fix implementation of [temp.local]p4.

When a template-name is looked up, we need to give injected-class-name
declarations of class templates special treatment, as they denote a
template rather than a type.

Previously we achieved this by applying a filter to the lookup results
after completing name lookup, but that is incorrect in various ways, not
least of which is that it lost all information about access and how
members were named, and the filtering caused us to generally lose
all ambiguity errors between templates and non-templates.

We now preserve the lookup results exactly, and the few places that need
to map from a declaration found by name lookup into a declaration of a
template do so explicitly. Deduplication of repeated lookup results of
the same injected-class-name declaration is done by name lookup instead
of after the fact.

This reinstates r354091, which was previously reverted in r354097
because it exposed bugs in lldb and compiler-rt. Those bugs were fixed
in r354173 and r354174 respectively.

Modified:
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/class.access/p4.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
cfe/trunk/test/SemaTemplate/temp.cpp

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=354176&r1=354175&r2=354176&view=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Fri Feb 15 13:53:07 2019
@@ -172,7 +172,8 @@ public:
   : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
 LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl),
 ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
-AllowHidden(Other.AllowHidden) {}
+AllowHidden(Other.AllowHidden),
+TemplateNameLookup(Other.TemplateNameLookup) {}
 
   // FIXME: Remove these deleted methods once the default build includes
   // -Wdeprecated.
@@ -193,7 +194,8 @@ public:
 HideTags(std::move(Other.HideTags)),
 Diagnose(std::move(Other.Diagnose)),
 AllowHidden(std::move(Other.AllowHidden)),
-Shadowed(std::move(Other.Shadowed)) {
+Shadowed(std::move(Other.Shadowed)),
+TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
 Other.Paths = nullptr;
 Other.Diagnose = false;
   }
@@ -216,6 +218,7 @@ public:
 Diagnose = std::move(Other.Diagnose);
 AllowHidden = std::move(Other.AllowHidden);
 Shadowed = std::move(Other.Shadowed);
+TemplateNameLookup = std::move(Other.TemplateNameLookup);
 Other.Paths = nullptr;
 Other.Diagnose = false;
 return *this;
@@ -286,6 +289,15 @@ public:
 HideTags = Hide;
   }
 
+  /// Sets whether this is a template-name lookup. For template-name lookups,
+  /// injected-class-names are treated as naming a template rather than a
+  /// template specialization.
+  void setTemplateNameLookup(bool TemplateName) {
+TemplateNameLookup = TemplateName;
+  }
+
+  bool isTemplateNameLookup() const { return TemplateNameLookup; }
+
   bool isAmbiguous() const {
 return getResultKind() == Ambiguous;
   }
@@ -739,6 +751,9 @@ private:
   /// declaration that we skipped. This only happens when \c LookupKind
   /// is \c LookupRedeclarationWithLinkage.
   bool Shadowed = false;
+
+  /// True if we're looking up a template-name.
+  bool TemplateNameLookup = false;
 };
 
 /// Consumes visible declarations found when searching for

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354176&r1=354175&r2=354176&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Feb 15 13:53:07 2019
@@ -6212,9 +6212,21 @@ public:
   // C++ Templates [C++ 14]
   //
   void FilterAcceptableTemplateNames(LookupResult &R,
- bool AllowFunctionTemplates = true);
+ bool AllowFunctionTemplates = true,
+ bool AllowDependent = true);
   bool hasAnyAcceptableTemplateNames(LookupResult &R,
- bool AllowFunctionTemplates = true);
+ bool AllowFunctionTemplates = true,
+ bool AllowDependent = true);
+  /// Try to interpret the lookup result D as a template-name.
+  ///
+  /// \param D A declaration found by name lookup.
+  

[PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.

2019-02-15 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

This broke compilation with GCC 5.4 on Ubuntu 16.04:

  ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:243: 
warning: missing terminating " character
  ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:3: 
error: missing terminating " character
 EXPECT_TRUE(matches(
 ^
  ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:480:7: 
error: stray ‘\’ in program
   void z(X x) { x.m(); }
 ^


Repository:
  rL LLVM

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

https://reviews.llvm.org/D56850



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


[PATCH] D58294: [clangd] Enable indexing of template type parameters

2019-02-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, ioeric.
Herald added a project: clang.

Fixes https://bugs.llvm.org/show_bug.cgi?id=36285


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58294

Files:
  clangd/XRefs.cpp
  clangd/index/FileIndex.cpp
  unittests/clangd/SymbolInfoTests.cpp
  unittests/clangd/XRefsTests.cpp


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -285,11 +285,10 @@
 }
   )cpp",
 
-  /* FIXME: clangIndex doesn't handle template type parameters
   R"cpp(// Template type parameter
-template <[[typename T]]>
+template 
 void foo() { ^T t; }
-  )cpp", */
+  )cpp",
 
   R"cpp(// Namespace
 namespace $decl[[ns]] {
Index: unittests/clangd/SymbolInfoTests.cpp
===
--- unittests/clangd/SymbolInfoTests.cpp
+++ unittests/clangd/SymbolInfoTests.cpp
@@ -213,14 +213,14 @@
 T^T t;
   };
 )cpp",
-  {/* not implemented */}},
+  {CreateExpectedSymbolDetails("TT", "bar::", "c:TestTU.cpp@65")}},
   {
   R"cpp( // Template parameter reference - type param
   template struct bar {
 int a = N^N;
   };
 )cpp",
-  {/* not implemented */}},
+  {CreateExpectedSymbolDetails("NN", "bar::", "c:TestTU.cpp@65")}},
   {
   R"cpp( // Class member reference - objec
   struct foo {
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp
@@ -42,6 +42,7 @@
   IndexOpts.SystemSymbolFilter =
   index::IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly;
   IndexOpts.IndexFunctionLocals = false;
+  IndexOpts.IndexTemplateParmDecls = true;
   if (IsIndexMainAST) {
 // We only collect refs when indexing main AST.
 CollectorOpts.RefFilter = RefKind::All;
Index: clangd/XRefs.cpp
===
--- clangd/XRefs.cpp
+++ clangd/XRefs.cpp
@@ -39,7 +39,7 @@
   if (const auto *FD = dyn_cast(D))
 return FD->getDefinition();
   // Only a single declaration is allowed.
-  if (isa(D)) // except cases above
+  if (isa(D) || isa(D)) // except cases above
 return D;
   // Multiple definitions are allowed.
   return nullptr; // except cases above
@@ -243,6 +243,7 @@
   index::IndexingOptions::SystemSymbolFilterKind::All;
   IndexOpts.IndexFunctionLocals = true;
   IndexOpts.IndexParametersInDeclarations = true;
+  IndexOpts.IndexTemplateParmDecls = true;
   indexTopLevelDecls(AST.getASTContext(), AST.getPreprocessor(),
  AST.getLocalTopLevelDecls(), DeclMacrosFinder, IndexOpts);
 
@@ -441,6 +442,7 @@
   index::IndexingOptions::SystemSymbolFilterKind::All;
   IndexOpts.IndexFunctionLocals = true;
   IndexOpts.IndexParametersInDeclarations = true;
+  IndexOpts.IndexTemplateParmDecls = true;
   indexTopLevelDecls(AST.getASTContext(), AST.getPreprocessor(),
  AST.getLocalTopLevelDecls(), RefFinder, IndexOpts);
   return std::move(RefFinder).take();


Index: unittests/clangd/XRefsTests.cpp
===
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -285,11 +285,10 @@
 }
   )cpp",
 
-  /* FIXME: clangIndex doesn't handle template type parameters
   R"cpp(// Template type parameter
-template <[[typename T]]>
+template 
 void foo() { ^T t; }
-  )cpp", */
+  )cpp",
 
   R"cpp(// Namespace
 namespace $decl[[ns]] {
Index: unittests/clangd/SymbolInfoTests.cpp
===
--- unittests/clangd/SymbolInfoTests.cpp
+++ unittests/clangd/SymbolInfoTests.cpp
@@ -213,14 +213,14 @@
 T^T t;
   };
 )cpp",
-  {/* not implemented */}},
+  {CreateExpectedSymbolDetails("TT", "bar::", "c:TestTU.cpp@65")}},
   {
   R"cpp( // Template parameter reference - type param
   template struct bar {
 int a = N^N;
   };
 )cpp",
-  {/* not implemented */}},
+  {CreateExpectedSymbolDetails("NN", "bar::", "c:TestTU.cpp@65")}},
   {
   R"cpp( // Class member reference - objec
   struct foo {
Index: clangd/index/FileIndex.cpp
===
--- clangd/index/FileIndex.cpp
+++ clangd/index/FileIndex.cpp
@@ -42,6 +42,7 @@
   IndexOpts.SystemSymbolFilter =
   index::IndexingOptions::SystemSymbolFilterKind::DeclarationsOnly;
  

[PATCH] D58291: [clangd] Include textual diagnostic ID as Diagnostic.code.

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, jdoerfert, arphaman, jkorous, MaskRay, 
ioeric, ilya-biryukov.
Herald added a project: clang.

Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58291

Files:
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/compile-commands-path-in-initialize.test
  test/clangd/diagnostic-category.test
  test/clangd/diagnostics.test
  test/clangd/did-change-configuration-params.test
  test/clangd/execute-command.test
  test/clangd/fixits-codeaction.test
  test/clangd/fixits-command.test
  test/clangd/fixits-embed-in-diagnostic.test

Index: test/clangd/fixits-embed-in-diagnostic.test
===
--- test/clangd/fixits-embed-in-diagnostic.test
+++ test/clangd/fixits-embed-in-diagnostic.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "err_use_with_wrong_tag",
 # CHECK-NEXT:"codeActions": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"edit": {
Index: test/clangd/fixits-command.test
===
--- test/clangd/fixits-command.test
+++ test/clangd/fixits-command.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "warn_condition_is_assignment",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/fixits-codeaction.test
===
--- test/clangd/fixits-codeaction.test
+++ test/clangd/fixits-codeaction.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "warn_condition_is_assignment",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
@@ -23,13 +24,14 @@
 # CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
 # CHECK-NEXT:  }
 ---
-{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":0,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses (fixes available)"}]}}}
+{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":0,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses (fixes available)", "code": "warn_condition_is_assignment"}]}}}
 #  CHECK:  "id": 2,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": [
 # CHECK-NEXT:{
 # CHECK-NEXT:  "diagnostics": [
 # CHECK-NEXT:{
+# CHECK-NEXT:  "code": "warn_condition_is_assignment",
 # CHECK-NEXT:  "message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
@@ -82,6 +84,7 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "diagnostics": [
 # CHECK-NEXT:{
+# CHECK-NEXT:  "code": "warn_condition_is_assignment",
 # CHECK-NEXT:  "message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
Index: test/clangd/execute-command.test
===
--- test/clangd/execute-command.test
+++ test/clangd/execute-command.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "warn_condition_is_assignment",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/did-change-configuration-params.test
===
--- test/clangd/did-change-configuration-params.test
+++ test/clangd/did-change-configuration-params.test
@@ -24,6 +24,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "warn_uninit_var",
 # CHECK-NEXT:"message": "Variable 'i' is uninitialized when used here (fix available)

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

2019-02-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:11370
 
+// In Microsoft C++ mode, a const variable defined in namespace scope has
+// external linkage by default if the variable is declared with

zahiraam wrote:
> aaron.ballman wrote:
> > thakis wrote:
> > > Even in unnamed namespaces?
> > That would definitely be good to test.
> It looks like not. 
> 
> ksh-3.2$ cat test4.cpp
> namespace {
> __declspec(dllexport) int const x = 3;
> }
> 
> int main ()
> {
>   int y = x + 10;
> 
>   return y;
> }
> 
> ksh-3.2$ cl -c test4.cpp
> Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24210 for x64
> Copyright (C) Microsoft Corporation.  All rights reserved.
> 
> test4.cpp
> ksh-3.2$ dumpbin /symbols test4.obj | grep External
> **008  SECT3  notype ()External | main**
> ksh-3.2$
> 
> ksh-3.2$ clang -c test4.cpp
> test4.cpp:2:33: error: '(anonymous namespace)::x' must have external linkage 
> when declared 'dllexport'
> __declspec(dllexport) int const x = 3;
> ^
> 1 error generated.
> ksh-3.2$
> 
> So the diag shouldn't go off when the variable is in an anonymous namespace? 
> Do you agree?
> 
> So the diag shouldn't go off when the variable is in an anonymous namespace? 
> Do you agree?

Correct.



Comment at: test/Sema/dllexport-2.cpp:5
+
+__declspec(dllexport) int const j; // expected-error {{default initialization 
of an object of const type 'const int'}} // expected-error {{'j' must have 
external linkage when declared 'dllexport'}}

Another test I'd like to see is using a typedef to apply the const 
qualification. e.g.,
```
typedef const int CInt;
__declspec(dllexport) CInt j2;
__declspec(dllexport) CInt j3 = 3;
```
We should match the MSVC behavior here as well (I wonder if your use of 
`isLocalConstQualified()` should actually be `isConstQualified()` instead).


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] D57948: [Sema] Fix a regression introduced in "[AST][Sema] Remove CallExpr::setNumArgs"

2019-02-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Done, thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D57948



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


[PATCH] D58074: [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier

2019-02-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: include/clang/Sema/Sema.h:9347
   ArrayRef MapTypeModifiersLoc,
+  CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId,
   OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,

ABataev wrote:
> Also would be good to pack some of the params into structure
What about this function?


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

https://reviews.llvm.org/D58074



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


[PATCH] D50488: [Analyzer] Checker for non-determinism caused by sorting of pointer-like elements

2019-02-15 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

The error I now get is:

  clang is not able to compile a simple test program.
  /usr/bin/ld: unrecognised emulation mode: armelf_linux_eabi
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386linux
elf_l1om elf_k1om i386pep i386pe

This is because I need to pass the correct -target and -L options to config. I 
see that there is a configure_command option that can be set. However, 
different projects use different build systems (make, cmake, bake, etc). How do 
we then pass flags to their respective configures?


Repository:
  rC Clang

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

https://reviews.llvm.org/D50488



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


r354169 - Revert r354075 "[clang][FileManager] fillRealPathName even if we aren't opening the file"

2019-02-15 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Feb 15 12:48:12 2019
New Revision: 354169

URL: http://llvm.org/viewvc/llvm-project?rev=354169&view=rev
Log:
Revert r354075 "[clang][FileManager] fillRealPathName even if we aren't opening 
the file"

The new test doesn't pass on Windows.

Modified:
cfe/trunk/lib/Basic/FileManager.cpp
cfe/trunk/unittests/Basic/FileManagerTest.cpp

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354169&r1=354168&r2=354169&view=diff
==
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Fri Feb 15 12:48:12 2019
@@ -267,9 +267,6 @@ const FileEntry *FileManager::getFile(St
   if (UFE.File) {
 if (auto PathName = UFE.File->getName())
   fillRealPathName(&UFE, *PathName);
-  } else if (!openFile) {
-// We should still fill the path even if we aren't opening the file.
-fillRealPathName(&UFE, InterndFileName);
   }
   return &UFE;
 }

Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354169&r1=354168&r2=354169&view=diff
==
--- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Fri Feb 15 12:48:12 2019
@@ -346,18 +346,4 @@ TEST_F(FileManagerTest, getVirtualFileFi
   EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
 }
 
-TEST_F(FileManagerTest, getFileDontOpenRealPath) {
-  auto statCache = llvm::make_unique();
-  statCache->InjectDirectory("/tmp/abc", 42);
-  SmallString<64> Path("/tmp/abc/foo.cpp");
-  statCache->InjectFile(Path.str().str().c_str(), 43);
-  manager.setStatCache(std::move(statCache));
-
-  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
-
-  ASSERT_TRUE(file != nullptr);
-
-  ASSERT_EQ(file->tryGetRealPathName(), Path);
-}
-
 } // anonymous namespace


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


Re: r354075 - [clang][FileManager] fillRealPathName even if we aren't opening the file

2019-02-15 Thread Reid Kleckner via cfe-commits
Reverted:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/4351

On Fri, Feb 15, 2019 at 11:07 AM Galina Kistanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello Jan,
>
> It looks like this commit broke tests on couple of win builders:
>
> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/23655
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win
> . . .
> Failing Tests (1):
> Clang-Unit ::
> Basic/./BasicTests.exe/FileManagerTest.getFileDontOpenRealPath
>
> Please have a look ASAP?
>
> Thanks
>
> Galina
>
> On Thu, Feb 14, 2019 at 3:02 PM Jan Korous via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: jkorous
>> Date: Thu Feb 14 15:02:35 2019
>> New Revision: 354075
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=354075&view=rev
>> Log:
>> [clang][FileManager] fillRealPathName even if we aren't opening the file
>>
>> The pathname wasn't previously filled when the getFile() method was
>> called with openFile = false.
>> We are caching FileEntry-s in ParsedAST::Includes in clangd and this
>> caused the problem.
>>
>> This fixes an internal test failure in clangd -
>> ClangdTests.GoToInclude.All
>>
>> rdar://47536127
>>
>> Differential Revision: https://reviews.llvm.org/D58213
>>
>> Modified:
>> cfe/trunk/lib/Basic/FileManager.cpp
>> cfe/trunk/unittests/Basic/FileManagerTest.cpp
>>
>> Modified: cfe/trunk/lib/Basic/FileManager.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075&r1=354074&r2=354075&view=diff
>>
>> ==
>> --- cfe/trunk/lib/Basic/FileManager.cpp (original)
>> +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Feb 14 15:02:35 2019
>> @@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
>>if (UFE.File) {
>>  if (auto PathName = UFE.File->getName())
>>fillRealPathName(&UFE, *PathName);
>> +  } else if (!openFile) {
>> +// We should still fill the path even if we aren't opening the file.
>> +fillRealPathName(&UFE, InterndFileName);
>>}
>>return &UFE;
>>  }
>>
>> Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075&r1=354074&r2=354075&view=diff
>>
>> ==
>> --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
>> +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Feb 14 15:02:35 2019
>> @@ -346,4 +346,18 @@ TEST_F(FileManagerTest, getVirtualFileFi
>>EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
>>  }
>>
>> +TEST_F(FileManagerTest, getFileDontOpenRealPath) {
>> +  auto statCache = llvm::make_unique();
>> +  statCache->InjectDirectory("/tmp/abc", 42);
>> +  SmallString<64> Path("/tmp/abc/foo.cpp");
>> +  statCache->InjectFile(Path.str().str().c_str(), 43);
>> +  manager.setStatCache(std::move(statCache));
>> +
>> +  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
>> +
>> +  ASSERT_TRUE(file != nullptr);
>> +
>> +  ASSERT_EQ(file->tryGetRealPathName(), Path);
>> +}
>> +
>>  } // anonymous namespace
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://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
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58153: [Driver] Default all Android ARM targets to NEON.

2019-02-15 Thread Dan Albert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354166: [Driver] Default all Android ARM targets to NEON. 
(authored by danalbert, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58153?vs=186553&id=187066#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58153

Files:
  cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
  cfe/trunk/test/Driver/arm-mfpu.c


Index: cfe/trunk/test/Driver/arm-mfpu.c
===
--- cfe/trunk/test/Driver/arm-mfpu.c
+++ cfe/trunk/test/Driver/arm-mfpu.c
@@ -376,55 +376,23 @@
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+neon"
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
 
-// RUN: %clang -target arm-linux-androideabi21 -march=armv7-a %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MARCH-ARM7-ANDROID-FP %s
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+soft-float"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+soft-float-abi"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+d16"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+vfp3"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+vfp4"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+fp-armv8"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+neon"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+crypto"
-
 // RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+d16"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi21 -mfpu=neon %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-NEON %s
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi23 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi23 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-D16 %s
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+d16"
-// CHECK-ARM-ANDROID-M-FP-D16: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-M-FP-D16-NOT: "-target-feature" "+crypto"
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID-FP-DEFAULT %s
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+soft-float-abi"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+vfp3"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "+neon"
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+
+// RUN: %clang -target armv7-linux-androideabi21 %s -mfpu=vfp3-d16 -### -c 
2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID-FP-D16 %s
+// CHECK-ARM7-ANDROID-FP-D16-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID-FP-D16: "-target-feature" "+soft-float-abi"
+// CHECK-ARM7-ANDROID-FP-D16: "-target-feature" "+d16"
+// C

r354166 - [Driver] Default all Android ARM targets to NEON.

2019-02-15 Thread Dan Albert via cfe-commits
Author: danalbert
Date: Fri Feb 15 12:31:54 2019
New Revision: 354166

URL: http://llvm.org/viewvc/llvm-project?rev=354166&view=rev
Log:
[Driver] Default all Android ARM targets to NEON.

Summary:
There are an insignificant number of ARM Android devices that don't
support NEON. Default to using NEON since that will improve
performance on the majority of devices. Users that need to target
non-NEON devices can still explicitly disable NEON.

Reviewers: srhines, pirama, kristof.beyls

Reviewed By: pirama

Subscribers: efriedma, javed.absar, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
cfe/trunk/test/Driver/arm-mfpu.c

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp?rev=354166&r1=354165&r2=354166&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/ARM.cpp Fri Feb 15 12:31:54 2019
@@ -378,9 +378,7 @@ void arm::getARMTargetFeatures(const Too
   } else if (FPUArg) {
 getARMFPUFeatures(D, FPUArg, Args, FPUArg->getValue(), Features);
   } else if (Triple.isAndroid() && getARMSubArchVersionNumber(Triple) >= 7) {
-// Android mandates minimum FPU requirements based on OS version.
-const char *AndroidFPU =
-Triple.isAndroidVersionLT(23) ? "vfpv3-d16" : "neon";
+const char *AndroidFPU = "neon";
 if (!llvm::ARM::getFPUFeatures(llvm::ARM::parseFPU(AndroidFPU), Features))
   D.Diag(clang::diag::err_drv_clang_unsupported)
   << std::string("-mfpu=") + AndroidFPU;

Modified: cfe/trunk/test/Driver/arm-mfpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-mfpu.c?rev=354166&r1=354165&r2=354166&view=diff
==
--- cfe/trunk/test/Driver/arm-mfpu.c (original)
+++ cfe/trunk/test/Driver/arm-mfpu.c Fri Feb 15 12:31:54 2019
@@ -376,55 +376,23 @@
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+neon"
 // CHECK-ARM5-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+crypto"
 
-// RUN: %clang -target arm-linux-androideabi21 -march=armv7-a %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MARCH-ARM7-ANDROID-FP %s
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+soft-float"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+soft-float-abi"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+d16"
-// CHECK-MARCH-ARM7-ANDROID-FP: "-target-feature" "+vfp3"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+vfp4"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+fp-armv8"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+neon"
-// CHECK-MARCH-ARM7-ANDROID-FP-NOT: "-target-feature" "+crypto"
-
 // RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+d16"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-DEFAULT-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi21 -mfpu=neon %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-L-FP-NEON %s
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-L-FP-NEON: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-L-FP-NEON-NOT: "-target-feature" "+crypto"
-
-// RUN: %clang -target armv7-linux-androideabi23 %s -### -c 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-ARM-ANDROID-M-FP-DEFAULT %s
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+soft-float-abi"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+vfp3"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+vfp4"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+fp-armv8"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT: "-target-feature" "+neon"
-// CHECK-ARM-ANDROID-M-FP-DEFAULT-NOT: "-target-feature" "+crypto"
+// RUN:   | FileCheck --check-prefix=CHECK-ARM7-ANDROID-FP-DEFAULT %s
+// CHECK-ARM7-ANDROID-FP-DEFAULT-NOT: "-target-feature" "+soft-float"
+// CHECK-ARM7-ANDROID-FP-DEFAULT: "-target-feature" "

r354165 - Relax assertion to account for private framework modules, too.

2019-02-15 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Fri Feb 15 12:24:26 2019
New Revision: 354165

URL: http://llvm.org/viewvc/llvm-project?rev=354165&view=rev
Log:
Relax assertion to account for private framework modules, too.

rdar://problem/48116069

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/Modules/DebugInfo-fmodule-name.c

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=354165&r1=354164&r2=354165&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Feb 15 12:24:26 2019
@@ -2299,8 +2299,8 @@ CGDebugInfo::getOrCreateModuleRef(Extern
   // When a module name is specified as -fmodule-name, that module gets a
   // clang::Module object, but it won't actually be built or imported; it will
   // be textual.
-  if (CreateSkeletonCU && IsRootModule && Mod.getASTFile().empty())
-assert((!M || (M->Name == CGM.getLangOpts().ModuleName)) &&
+  if (CreateSkeletonCU && IsRootModule && Mod.getASTFile().empty() && M)
+assert(StringRef(M->Name).startswith(CGM.getLangOpts().ModuleName) &&
"clang module without ASTFile must be specified by -fmodule-name");
 
   if (CreateSkeletonCU && IsRootModule && !Mod.getASTFile().empty()) {

Modified: cfe/trunk/test/Modules/DebugInfo-fmodule-name.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/DebugInfo-fmodule-name.c?rev=354165&r1=354164&r2=354165&view=diff
==
--- cfe/trunk/test/Modules/DebugInfo-fmodule-name.c (original)
+++ cfe/trunk/test/Modules/DebugInfo-fmodule-name.c Fri Feb 15 12:24:26 2019
@@ -1,16 +1,16 @@
 // RUN: rm -rf %t
-// RUN: %clang_cc1 -fmodules -fmodule-format=obj -fmodule-name=F \
+// RUN: %clang_cc1 -fmodules -fmodule-format=obj -fmodule-name=MainA \
 // RUN: -debug-info-kind=limited -dwarf-ext-refs \
 // RUN: -fimplicit-module-maps -x c -fmodules-cache-path=%t -F %S/Inputs \
 // RUN: %s -S -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s
 
-#include "F/F.h"
+#include "MainA/MainPriv.h"
 
 // CHECK: !DICompileUnit
 // CHECK-NOT: dwoId:
 
 // We still want the import, but no skeleton CU, since no PCM was built.
 
-// CHECK: !DIModule({{.*}}, name: "F"
+// CHECK: !DIModule({{.*}}, name: "APriv"
 // CHECK-NOT: !DICompileUnit
 // CHECK-NOT: dwoId:


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


[PATCH] D57270: [ObjC] Fix non-canonical types preventing type arguments substitution.

2019-02-15 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354164: [ObjC] Fix non-canonical types preventing type 
arguments substitution. (authored by vsapsai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57270?vs=183664&id=187063#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57270

Files:
  cfe/trunk/lib/AST/Type.cpp
  cfe/trunk/test/SemaObjC/parameterized_classes_subst.m

Index: cfe/trunk/test/SemaObjC/parameterized_classes_subst.m
===
--- cfe/trunk/test/SemaObjC/parameterized_classes_subst.m
+++ cfe/trunk/test/SemaObjC/parameterized_classes_subst.m
@@ -104,6 +104,12 @@
 @property (nonatomic,retain) ViewType view;
 @end
 
+@interface TypedefTypeParam : NSObject
+typedef T AliasT;
+- (void)test:(AliasT)object;
+// expected-note@-1 {{parameter 'object' here}}
+@end
+
 // --
 // Nullability
 // --
@@ -190,6 +196,7 @@
MutableSetOfArrays *mutStringArraySet,
NSMutableSet *mutSet,
MutableSetOfArrays *mutArraySet,
+   TypedefTypeParam *typedefTypeParam,
void (^block)(void)) {
   Window *window;
 
@@ -199,6 +206,7 @@
   [mutStringArraySet addObject: window]; // expected-warning{{parameter of type 'NSArray *'}}
   [mutSet addObject: window]; // expected-warning{{parameter of incompatible type 'id'}}
   [mutArraySet addObject: window]; // expected-warning{{parameter of incompatible type 'id'}}
+  [typedefTypeParam test: window]; // expected-warning{{parameter of type 'NSString *'}}
   [block addObject: window]; // expected-warning{{parameter of incompatible type 'id'}}
 }
 
Index: cfe/trunk/lib/AST/Type.cpp
===
--- cfe/trunk/lib/AST/Type.cpp
+++ cfe/trunk/lib/AST/Type.cpp
@@ -752,6 +752,17 @@
 
 #define TRIVIAL_TYPE_CLASS(Class) \
   QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
+#define SUGARED_TYPE_CLASS(Class) \
+  QualType Visit##Class##Type(const Class##Type *T) { \
+if (!T->isSugared()) \
+  return QualType(T, 0); \
+QualType desugaredType = recurse(T->desugar()); \
+if (desugaredType.isNull()) \
+  return {}; \
+if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
+  return QualType(T, 0); \
+return desugaredType; \
+  }
 
   TRIVIAL_TYPE_CLASS(Builtin)
 
@@ -955,8 +966,8 @@
 return Ctx.getParenType(innerType);
   }
 
-  TRIVIAL_TYPE_CLASS(Typedef)
-  TRIVIAL_TYPE_CLASS(ObjCTypeParam)
+  SUGARED_TYPE_CLASS(Typedef)
+  SUGARED_TYPE_CLASS(ObjCTypeParam)
 
   QualType VisitAdjustedType(const AdjustedType *T) {
 QualType originalType = recurse(T->getOriginalType());
@@ -987,15 +998,15 @@
 return Ctx.getDecayedType(originalType);
   }
 
-  TRIVIAL_TYPE_CLASS(TypeOfExpr)
-  TRIVIAL_TYPE_CLASS(TypeOf)
-  TRIVIAL_TYPE_CLASS(Decltype)
-  TRIVIAL_TYPE_CLASS(UnaryTransform)
+  SUGARED_TYPE_CLASS(TypeOfExpr)
+  SUGARED_TYPE_CLASS(TypeOf)
+  SUGARED_TYPE_CLASS(Decltype)
+  SUGARED_TYPE_CLASS(UnaryTransform)
   TRIVIAL_TYPE_CLASS(Record)
   TRIVIAL_TYPE_CLASS(Enum)
 
   // FIXME: Non-trivial to implement, but important for C++
-  TRIVIAL_TYPE_CLASS(Elaborated)
+  SUGARED_TYPE_CLASS(Elaborated)
 
   QualType VisitAttributedType(const AttributedType *T) {
 QualType modifiedType = recurse(T->getModifiedType());
@@ -1030,7 +1041,7 @@
   }
 
   // FIXME: Non-trivial to implement, but important for C++
-  TRIVIAL_TYPE_CLASS(TemplateSpecialization)
+  SUGARED_TYPE_CLASS(TemplateSpecialization)
 
   QualType VisitAutoType(const AutoType *T) {
 if (!T->isDeduced())
@@ -1049,7 +1060,7 @@
   }
 
   // FIXME: Non-trivial to implement, but important for C++
-  TRIVIAL_TYPE_CLASS(PackExpansion)
+  SUGARED_TYPE_CLASS(PackExpansion)
 
   QualType VisitObjCObjectType(const ObjCObjectType *T) {
 QualType baseType = recurse(T->getBaseType());
@@ -1107,6 +1118,7 @@
   }
 
 #undef TRIVIAL_TYPE_CLASS
+#undef SUGARED_TYPE_CLASS
 };
 
 } // namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354164 - [ObjC] Fix non-canonical types preventing type arguments substitution.

2019-02-15 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Fri Feb 15 12:17:45 2019
New Revision: 354164

URL: http://llvm.org/viewvc/llvm-project?rev=354164&view=rev
Log:
[ObjC] Fix non-canonical types preventing type arguments substitution.

`QualType::substObjCTypeArgs` doesn't go past non-canonical types and as
the result misses some of the substitutions like `ObjCTypeParamType`.

Update `SimpleTransformVisitor` to traverse past the type sugar.

Reviewers: ahatanak, erik.pilkington

Reviewed By: erik.pilkington

Subscribers: jkorous, dexonsmith, cfe-commits

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


Modified:
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/test/SemaObjC/parameterized_classes_subst.m

Modified: cfe/trunk/lib/AST/Type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=354164&r1=354163&r2=354164&view=diff
==
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Fri Feb 15 12:17:45 2019
@@ -752,6 +752,17 @@ public:
 
 #define TRIVIAL_TYPE_CLASS(Class) \
   QualType Visit##Class##Type(const Class##Type *T) { return QualType(T, 0); }
+#define SUGARED_TYPE_CLASS(Class) \
+  QualType Visit##Class##Type(const Class##Type *T) { \
+if (!T->isSugared()) \
+  return QualType(T, 0); \
+QualType desugaredType = recurse(T->desugar()); \
+if (desugaredType.isNull()) \
+  return {}; \
+if (desugaredType.getAsOpaquePtr() == T->desugar().getAsOpaquePtr()) \
+  return QualType(T, 0); \
+return desugaredType; \
+  }
 
   TRIVIAL_TYPE_CLASS(Builtin)
 
@@ -955,8 +966,8 @@ public:
 return Ctx.getParenType(innerType);
   }
 
-  TRIVIAL_TYPE_CLASS(Typedef)
-  TRIVIAL_TYPE_CLASS(ObjCTypeParam)
+  SUGARED_TYPE_CLASS(Typedef)
+  SUGARED_TYPE_CLASS(ObjCTypeParam)
 
   QualType VisitAdjustedType(const AdjustedType *T) {
 QualType originalType = recurse(T->getOriginalType());
@@ -987,15 +998,15 @@ public:
 return Ctx.getDecayedType(originalType);
   }
 
-  TRIVIAL_TYPE_CLASS(TypeOfExpr)
-  TRIVIAL_TYPE_CLASS(TypeOf)
-  TRIVIAL_TYPE_CLASS(Decltype)
-  TRIVIAL_TYPE_CLASS(UnaryTransform)
+  SUGARED_TYPE_CLASS(TypeOfExpr)
+  SUGARED_TYPE_CLASS(TypeOf)
+  SUGARED_TYPE_CLASS(Decltype)
+  SUGARED_TYPE_CLASS(UnaryTransform)
   TRIVIAL_TYPE_CLASS(Record)
   TRIVIAL_TYPE_CLASS(Enum)
 
   // FIXME: Non-trivial to implement, but important for C++
-  TRIVIAL_TYPE_CLASS(Elaborated)
+  SUGARED_TYPE_CLASS(Elaborated)
 
   QualType VisitAttributedType(const AttributedType *T) {
 QualType modifiedType = recurse(T->getModifiedType());
@@ -1030,7 +1041,7 @@ public:
   }
 
   // FIXME: Non-trivial to implement, but important for C++
-  TRIVIAL_TYPE_CLASS(TemplateSpecialization)
+  SUGARED_TYPE_CLASS(TemplateSpecialization)
 
   QualType VisitAutoType(const AutoType *T) {
 if (!T->isDeduced())
@@ -1049,7 +1060,7 @@ public:
   }
 
   // FIXME: Non-trivial to implement, but important for C++
-  TRIVIAL_TYPE_CLASS(PackExpansion)
+  SUGARED_TYPE_CLASS(PackExpansion)
 
   QualType VisitObjCObjectType(const ObjCObjectType *T) {
 QualType baseType = recurse(T->getBaseType());
@@ -1107,6 +1118,7 @@ public:
   }
 
 #undef TRIVIAL_TYPE_CLASS
+#undef SUGARED_TYPE_CLASS
 };
 
 } // namespace

Modified: cfe/trunk/test/SemaObjC/parameterized_classes_subst.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/parameterized_classes_subst.m?rev=354164&r1=354163&r2=354164&view=diff
==
--- cfe/trunk/test/SemaObjC/parameterized_classes_subst.m (original)
+++ cfe/trunk/test/SemaObjC/parameterized_classes_subst.m Fri Feb 15 12:17:45 
2019
@@ -104,6 +104,12 @@ __attribute__((objc_root_class))
 @property (nonatomic,retain) ViewType view;
 @end
 
+@interface TypedefTypeParam : NSObject
+typedef T AliasT;
+- (void)test:(AliasT)object;
+// expected-note@-1 {{parameter 'object' here}}
+@end
+
 // --
 // Nullability
 // --
@@ -190,6 +196,7 @@ void test_message_send_param(
MutableSetOfArrays *mutStringArraySet,
NSMutableSet *mutSet,
MutableSetOfArrays *mutArraySet,
+   TypedefTypeParam *typedefTypeParam,
void (^block)(void)) {
   Window *window;
 
@@ -199,6 +206,7 @@ void test_message_send_param(
   [mutStringArraySet addObject: window]; // expected-warning{{parameter of 
type 'NSArray *'}}
   [mutSet addObject: window]; // expected-warning{{parameter of incompatible 
type 'id'}}
   [mutArraySet addObject: window]; // expected-warning{{parameter of 
incompatible type 'id'}}
+  [typedefTypeParam test: window]; // expected-warning{{parameter of type 
'NSString *'}}
   [block addObject: window]; // expected-warning{{parameter of incompatible 
type 'id'}}
 }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.or

[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

Please be sure to update Registry.cpp to expose the new AST matcher to the 
dynamic matcher infrastructure, regenerate the AST matcher documentation (run 
clang\docs\tools\dump_ast_matchers.py), and add tests for the matcher.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58292



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


[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-15 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

This looks reasonable, I will wait for @martong and/or @a_sidorin to review.

FYI LLDB is the other big user of ASTImpoter so it is helpful if you can run 
`check-lldb` especially on MacOS so you can to catch regressions before 
committing. After committing please make sure to monitor the GreenDragon build 
bots:

  http://lab.llvm.org:8080/green/view/LLDB/

Thank you!


Repository:
  rC Clang

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

https://reviews.llvm.org/D58292



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


[PATCH] D58074: [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier

2019-02-15 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: include/clang/AST/OpenMPClause.h:3666
+  OMPMappableExprListClause(
+  OpenMPClauseKind K, OMPMappableExprListLocTy Locs,
+  OMPMappableExprListSizeTy Sizes,

Pass those new structures by const reference, not by value. Do this for all the 
functions.


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

https://reviews.llvm.org/D58074



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


[PATCH] D17444: [MSVC] Recognize "static_assert" keyword in C mode

2019-02-15 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354162: [MSVC] Recognize `static_assert` keyword in C and 
C++98 (authored by rnk, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D17444?vs=186741&id=187061#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D17444

Files:
  include/clang/Basic/TokenKinds.def
  lib/Basic/IdentifierTable.cpp
  test/Lexer/keywords_test.c
  test/Lexer/keywords_test.cpp


Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -243,6 +243,7 @@
 //are enabled.
 //   KEYGNU   - This is a keyword if GNU extensions are enabled
 //   KEYMS- This is a keyword if Microsoft extensions are enabled
+//   KEYMSCOMPAT - This is a keyword if Microsoft compatibility mode is enabled
 //   KEYNOMS18 - This is a keyword that must never be enabled under
 //   MSVC <= v18.
 //   KEYOPENCLC   - This is a keyword in OpenCL C
@@ -363,7 +364,7 @@
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , 0)
-CXX11_KEYWORD(static_assert , 0)
+CXX11_KEYWORD(static_assert , KEYMSCOMPAT)
 CXX11_KEYWORD(thread_local  , 0)
 
 // C++2a / concepts TS keywords
Index: test/Lexer/keywords_test.cpp
===
--- test/Lexer/keywords_test.cpp
+++ test/Lexer/keywords_test.cpp
@@ -11,9 +11,9 @@
 // RUN: %clang_cc1 -std=c++03 -fdeclspec -fno-declspec -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fms-extensions -fno-declspec -fdeclspec 
-DDECLSPEC -fsyntax-only %s
 // RUN: %clang_cc1 -std=c++03 -fms-extensions -fdeclspec -fno-declspec 
-fsyntax-only %s
-// RUN: %clang -std=c++03 -target i686-windows-msvc -DDECLSPEC -fsyntax-only %s
+// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -DDECLSPEC 
-fsyntax-only %s
 // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -DDECLSPEC -fsyntax-only %s
-// RUN: %clang -std=c++03 -target i686-windows-msvc -fno-declspec 
-fsyntax-only %s
+// RUN: %clang -std=c++03 -target i686-windows-msvc -DMS -fno-declspec 
-fsyntax-only %s
 // RUN: %clang -std=c++03 -target x86_64-scei-ps4 -fno-declspec -fsyntax-only 
%s
 
 #define IS_KEYWORD(NAME) _Static_assert(!__is_identifier(NAME), #NAME)
@@ -51,7 +51,12 @@
 CXX11_TYPE(char32_t);
 CXX11_KEYWORD(constexpr);
 CXX11_KEYWORD(noexcept);
+#ifndef MS
 CXX11_KEYWORD(static_assert);
+#else
+// MS compiler recognizes static_assert in all modes. So should we.
+IS_KEYWORD(static_assert);
+#endif
 CXX11_KEYWORD(thread_local);
 
 // Concepts TS keywords
Index: test/Lexer/keywords_test.c
===
--- test/Lexer/keywords_test.c
+++ test/Lexer/keywords_test.c
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -std=gnu89 -fno-gnu-keywords -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-NONE %s
 
-// RUN: %clang_cc1 -std=c99 -fms-extensions -E %s -o - \
+// RUN: %clang_cc1 -std=c99 -fms-extensions -fms-compatibility -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-MS-KEYWORDS %s
 // RUN: %clang_cc1 -std=c99 -fdeclspec -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-DECLSPEC-KEYWORD %s
@@ -42,3 +42,13 @@
 #else
 void has_declspec();
 #endif
+
+// CHECK-NONE: no_static_assert
+// CHECK-GNU-KEYWORDS: no_static_assert
+// CHECK-MS-KEYWORDS: has_static_assert
+// CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC: no_static_assert
+#if __is_identifier(static_assert)
+void no_static_assert();
+#else
+void has_static_assert();
+#endif
Index: lib/Basic/IdentifierTable.cpp
===
--- lib/Basic/IdentifierTable.cpp
+++ lib/Basic/IdentifierTable.cpp
@@ -99,6 +99,7 @@
 KEYMODULES= 0x10,
 KEYCXX2A  = 0x20,
 KEYOPENCLCXX  = 0x40,
+KEYMSCOMPAT   = 0x80,
 KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX2A,
 KEYALL = (0xff & ~KEYNOMS18 &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
@@ -125,6 +126,7 @@
   if (LangOpts.C99 && (Flags & KEYC99)) return KS_Enabled;
   if (LangOpts.GNUKeywords && (Flags & KEYGNU)) return KS_Extension;
   if (LangOpts.MicrosoftExt && (Flags & KEYMS)) return KS_Extension;
+  if (LangOpts.MSVCCompat && (Flags & KEYMSCOMPAT)) return KS_Enabled;
   if (LangOpts.Borland && (Flags & KEYBORLAND)) return KS_Extension;
   if (LangOpts.Bool && (Flags & BOOLSUPPORT)) return KS_Enabled;
   if (LangOpts.Half && (Flags & HALFSUPPORT)) return KS_Enabled;


Index: include/clang/Basic/TokenKinds.def
===
--- include/clang/Basic/TokenKinds.def
+++ include/clang/Basic/TokenKinds.def
@@ -243,6 +243,7 @@
 //are enabled.
 //   KEYGNU   - This is a keyword 

r354162 - [MSVC] Recognize `static_assert` keyword in C and C++98

2019-02-15 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Fri Feb 15 11:59:45 2019
New Revision: 354162

URL: http://llvm.org/viewvc/llvm-project?rev=354162&view=rev
Log:
[MSVC] Recognize `static_assert` keyword in C and C++98

Summary:
The main effect is that clang now accepts the following conforming C11
code with MSVC headers:
  #include 
  static_assert(1, "true");

This is a non-conforming extension (the keyword is outside the
implementer's namespace), so it is placed under -fms-compatibility
instead of -fms-extensions like most MSVC-specific keyword extensions.

Normally, in C11, the compiler is supposed to provide the _Static_assert
keyword, and assert.h should define static_assert to _Static_assert.
However, that is not what MSVC does, and MSVC doesn't even provide
_Static_assert.

This also has the less important side effect of enabling static_assert
in C++98 mode with -fms-compatibility. It's exceptionally difficult to
use modern MSVC headers without C++14 even, so this is relatively
unimportant.

Fixes PR26672

Patch by Andrey Bokhanko!

Reviewers: rsmith, thakis

Subscribers: cfe-commits, STL_MSFT

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

Modified:
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/lib/Basic/IdentifierTable.cpp
cfe/trunk/test/Lexer/keywords_test.c
cfe/trunk/test/Lexer/keywords_test.cpp

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=354162&r1=354161&r2=354162&view=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Fri Feb 15 11:59:45 2019
@@ -243,6 +243,7 @@ PUNCTUATOR(caretcaret,"^^")
 //are enabled.
 //   KEYGNU   - This is a keyword if GNU extensions are enabled
 //   KEYMS- This is a keyword if Microsoft extensions are enabled
+//   KEYMSCOMPAT - This is a keyword if Microsoft compatibility mode is enabled
 //   KEYNOMS18 - This is a keyword that must never be enabled under
 //   MSVC <= v18.
 //   KEYOPENCLC   - This is a keyword in OpenCL C
@@ -363,7 +364,7 @@ CXX11_KEYWORD(constexpr , 0)
 CXX11_KEYWORD(decltype  , 0)
 CXX11_KEYWORD(noexcept  , 0)
 CXX11_KEYWORD(nullptr   , 0)
-CXX11_KEYWORD(static_assert , 0)
+CXX11_KEYWORD(static_assert , KEYMSCOMPAT)
 CXX11_KEYWORD(thread_local  , 0)
 
 // C++2a / concepts TS keywords

Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=354162&r1=354161&r2=354162&view=diff
==
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Fri Feb 15 11:59:45 2019
@@ -99,6 +99,7 @@ namespace {
 KEYMODULES= 0x10,
 KEYCXX2A  = 0x20,
 KEYOPENCLCXX  = 0x40,
+KEYMSCOMPAT   = 0x80,
 KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX2A,
 KEYALL = (0xff & ~KEYNOMS18 &
   ~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
@@ -125,6 +126,7 @@ static KeywordStatus getKeywordStatus(co
   if (LangOpts.C99 && (Flags & KEYC99)) return KS_Enabled;
   if (LangOpts.GNUKeywords && (Flags & KEYGNU)) return KS_Extension;
   if (LangOpts.MicrosoftExt && (Flags & KEYMS)) return KS_Extension;
+  if (LangOpts.MSVCCompat && (Flags & KEYMSCOMPAT)) return KS_Enabled;
   if (LangOpts.Borland && (Flags & KEYBORLAND)) return KS_Extension;
   if (LangOpts.Bool && (Flags & BOOLSUPPORT)) return KS_Enabled;
   if (LangOpts.Half && (Flags & HALFSUPPORT)) return KS_Enabled;

Modified: cfe/trunk/test/Lexer/keywords_test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/keywords_test.c?rev=354162&r1=354161&r2=354162&view=diff
==
--- cfe/trunk/test/Lexer/keywords_test.c (original)
+++ cfe/trunk/test/Lexer/keywords_test.c Fri Feb 15 11:59:45 2019
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -std=gnu89 -fno-gnu-keywords -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-NONE %s
 
-// RUN: %clang_cc1 -std=c99 -fms-extensions -E %s -o - \
+// RUN: %clang_cc1 -std=c99 -fms-extensions -fms-compatibility -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-MS-KEYWORDS %s
 // RUN: %clang_cc1 -std=c99 -fdeclspec -E %s -o - \
 // RUN: | FileCheck --check-prefix=CHECK-DECLSPEC-KEYWORD %s
@@ -42,3 +42,13 @@ void no_declspec();
 #else
 void has_declspec();
 #endif
+
+// CHECK-NONE: no_static_assert
+// CHECK-GNU-KEYWORDS: no_static_assert
+// CHECK-MS-KEYWORDS: has_static_assert
+// CHECK-MS-KEYWORDS-WITHOUT-DECLSPEC: no_static_assert
+#if __is_identifier(static_assert)
+void no_static_assert();
+#else
+void has_static_assert();
+#endif

Modified: cfe/trunk/test/Lexer/keywords_test.cpp
URL:

[PATCH] D57747: [Sema] SequenceChecker: Fix handling of operator ||, && and ?:

2019-02-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 187057.
riccibruno marked an inline comment as done.
riccibruno added a comment.
Herald added a subscriber: jdoerfert.

Rebased


Repository:
  rC Clang

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

https://reviews.llvm.org/D57747

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/warn-unsequenced.c
  test/SemaCXX/warn-unsequenced.cpp

Index: test/SemaCXX/warn-unsequenced.cpp
===
--- test/SemaCXX/warn-unsequenced.cpp
+++ test/SemaCXX/warn-unsequenced.cpp
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 -fsyntax-only -verify=cxx17 -std=c++17 -Wno-unused -Wno-uninitialized -Wunsequenced %s
 
 int f(int, int = 0);
+int g1();
+int g2(int);
 
 struct A {
   int x, y;
@@ -77,24 +79,28 @@
   A { ++a, a++ }.x + A { ++a, a++ }.y; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
// cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
 
-  (xs[2] && (a = 0)) + a; // ok
+  (xs[2] && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 && (a = 0)) + a; // ok
   (1 && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
-  (xs[3] || (a = 0)) + a; // ok
+  (xs[3] || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (1 || (a = 0)) + a; // ok
 
-  (xs[4] ? a : ++a) + a; // ok
+  (xs[4] ? a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+ // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 ? a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (1 ? a : ++a) + a; // ok
   (0 ? a : a++) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (1 ? a : a++) + a; // ok
-  (xs[5] ? ++a : ++a) + a; // FIXME: warn here
+  (xs[5] ? ++a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
   (++a, xs[6] ? ++a : 0) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
@@ -120,10 +126,13 @@
   // unconditional.
   a = a++ && f(a, a);
 
-  // This has undefined behavior if a != 0. FIXME: We should diagnose this.
-  (a && a++) + a;
+  // This has undefined behavior if a != 0.
+  (a && a++) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
-  (xs[7] && ++a) * (!xs[7] && ++a); // ok
+  // FIXME: Don't warn here.
+  (xs[7] && ++a) * (!xs[7] && ++a); // cxx11-warning {{multiple unsequenced modifications to 'a'}}
+// cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
 
   xs[0] = (a = 1, a); // ok
   (a -= 128) &= 128; // ok
@@ -133,13 +142,64 @@
  // cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   xs[8] ? 0 : ++a + a++; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
  // cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
-  xs[8] ? ++a : a++; // ok
+  xs[8] ? ++a : a++; // no-warning
+  xs[8] ? a+=1 : a+= 2; // no-warning
+  (xs[8] ? a+=1 : a+= 2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  (xs[8] ? a+=1 : a) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  (xs[8] ? a : a+= 2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+   // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  a = (xs[8] ? a+=1 : a+= 2); // no-warning
+  a += (xs[8] ? a+=1 : a+= 2); // cxx11-warning {{unsequenced modification and access to 'a'}}
+   // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+
+  (false ? a+=1 : a) = a; // no-warning
+  (true ? a+=1 : a) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+

[PATCH] D58297: [Sema] SequenceChecker: C++17 sequencing rules for built-in operators <<, >>, .*, ->*, =, op=

2019-02-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added reviewers: rsmith, rjmccall, aaron.ballman.
riccibruno added a project: clang.
Herald added subscribers: cfe-commits, jdoerfert.

Implement the C++17 sequencing rules for the built-in operators `<<`, `>>`, 
`.*`, `->*`, `=` and `op=`.


Repository:
  rC Clang

https://reviews.llvm.org/D58297

Files:
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/warn-unsequenced.cpp

Index: test/SemaCXX/warn-unsequenced.cpp
===
--- test/SemaCXX/warn-unsequenced.cpp
+++ test/SemaCXX/warn-unsequenced.cpp
@@ -24,7 +24,6 @@
   a + a++; // cxx11-warning {{unsequenced modification and access to 'a'}}
// cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   a = a++; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
-   // TODO cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   ++ ++a; // ok
   (a++, a++); // ok
   ++a + ++a; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
@@ -34,13 +33,10 @@
   (a++, a) = 0; // ok, increment is sequenced before value computation of LHS
   a = xs[++a]; // ok
   a = xs[a++]; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
-   // TODO cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   (a ? xs[0] : xs[1]) = ++a; // cxx11-warning {{unsequenced modification and access to 'a'}}
- // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   a = (++a, ++a); // ok
   a = (a++, ++a); // ok
   a = (a++, a++); // cxx11-warning {{multiple unsequenced modifications to 'a'}}
-  // TODO cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   f(a, a); // ok
   f(a = 0, a); // cxx11-warning {{unsequenced modification and access to 'a'}}
// cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
@@ -59,7 +55,6 @@
   (++a, a) += 1; // ok
   a = ++a; // ok
   a += ++a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-// TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
   A agg1 = { a++, a++ }; // ok
   A agg2 = { a++ + a, a++ }; // cxx11-warning {{unsequenced modification and access to 'a'}}
@@ -75,7 +70,6 @@
   a = S { ++a, a++ }.n; // ok
   A { ++a, a++ }.x; // ok
   a = A { ++a, a++ }.x; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
-// TODO cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   A { ++a, a++ }.x + A { ++a, a++ }.y; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
// cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
 
@@ -110,14 +104,10 @@
   a += (a++, a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
-  int *p = xs;
-  a = *(a++, p); // ok
   a = a++ && a; // ok
-  p[(long long unsigned)(p = 0)]; // cxx11-warning {{unsequenced modification and access to 'p'}}
 
   A *q = &agg1;
   (q = &agg2)->y = q->x; // cxx11-warning {{unsequenced modification and access to 'q'}}
- // TODO cxx17-warning@-1 {{unsequenced modification and access to 'q'}}
 
   // This has undefined behavior if a == 0; otherwise, the side-effect of the
   // increment is sequenced before the value computation of 'f(a, a)', which is
@@ -145,20 +135,14 @@
   xs[8] ? ++a : a++; // no-warning
   xs[8] ? a+=1 : a+= 2; // no-warning
   (xs[8] ? a+=1 : a+= 2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (xs[8] ? a+=1 : a) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (xs[8] ? a : a+= 2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-   // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   a = (xs[8] ? a+=1 : a+= 2); // no-warning
   a += (xs[8] ? a+=1 : a+= 2); // cxx11-warning {{unsequenced modification and access to 'a'}}
-   // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
 
   (false ? a+=1 : a) = a; // no-warning
   (true ? a+=1 : a) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
- // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (false ? a : a+=2) = a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-  // TODO cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (true ? a : a+=2) = a; // no-warning
 
   xs[8] && (++a + a++); // cxx11-warning {{multiple unsequenced modifications to 'a'}}
@@ -178,19 +162,15 @@
   a = ((a++, false

[PATCH] D58074: [OpenMP 5.0] Parsing/sema support for map clause with mapper modifier

2019-02-15 Thread Lingda Li via Phabricator via cfe-commits
lildmh added inline comments.



Comment at: include/clang/AST/OpenMPClause.h:3682-3685
+  OpenMPClauseKind K, SourceLocation StartLoc, SourceLocation LParenLoc,
+  SourceLocation EndLoc, OMPMappableExprListSizeTy Sizes,
+  NestedNameSpecifierLoc *MapperQualifierLocP = nullptr,
+  DeclarationNameInfo *MapperIdInfoP = nullptr)

ABataev wrote:
> I think it is worth to add `SourceLocation StartLoc`, `SourceLocation 
> LParenLoc`, `SourceLocation EndLoc`, to `OMPMappableExprListSizeTy`. Of 
> course, you need to rename the structure, something like 
> `OMPMappableClauseData` is good enough. Or you can pack them into a different 
> structure.
I put `StartLoc`, `LParenLoc`, `EndLoc` into another struct 
`OMPMappableExprListLocTy`. I didn't combine them with 
`OMPMappableExprListSizeTy`, because some fuctions only use one of them, and 
some other functions use both of them.

Also modify `to`, `from`, `is_device`, and `use_device` clauses to use the same 
interfaces.


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

https://reviews.llvm.org/D58074



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-02-15 Thread Khem Raj via Phabricator via cfe-commits
raj.khem added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:476
   for (const auto &Entry : DebugPrefixMap)
-if (Path.startswith(Entry.first))
-  return (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
-  return Path.str();
+if (llvm::sys::path::replace_path_prefix(p, Entry.first, Entry.second))
+  break;

raj.khem wrote:
> looking at llvm/lib/Support/Path.cpp replace_path_prefix() returns void but 
> here inside if() it will expect a bool return value 
nm I guess I needed to look into https://reviews.llvm.org/D56769 as well.


Repository:
  rC Clang

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

https://reviews.llvm.org/D49466



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-02-15 Thread Khem Raj via Phabricator via cfe-commits
raj.khem added inline comments.



Comment at: lib/CodeGen/CGDebugInfo.cpp:476
   for (const auto &Entry : DebugPrefixMap)
-if (Path.startswith(Entry.first))
-  return (Twine(Entry.second) + Path.substr(Entry.first.size())).str();
-  return Path.str();
+if (llvm::sys::path::replace_path_prefix(p, Entry.first, Entry.second))
+  break;

looking at llvm/lib/Support/Path.cpp replace_path_prefix() returns void but 
here inside if() it will expect a bool return value 


Repository:
  rC Clang

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

https://reviews.llvm.org/D49466



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


Re: r354075 - [clang][FileManager] fillRealPathName even if we aren't opening the file

2019-02-15 Thread Galina Kistanova via cfe-commits
Hello Jan,

It looks like this commit broke tests on couple of win builders:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/23655
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win
. . .
Failing Tests (1):
Clang-Unit ::
Basic/./BasicTests.exe/FileManagerTest.getFileDontOpenRealPath

Please have a look ASAP?

Thanks

Galina

On Thu, Feb 14, 2019 at 3:02 PM Jan Korous via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: jkorous
> Date: Thu Feb 14 15:02:35 2019
> New Revision: 354075
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354075&view=rev
> Log:
> [clang][FileManager] fillRealPathName even if we aren't opening the file
>
> The pathname wasn't previously filled when the getFile() method was called
> with openFile = false.
> We are caching FileEntry-s in ParsedAST::Includes in clangd and this
> caused the problem.
>
> This fixes an internal test failure in clangd - ClangdTests.GoToInclude.All
>
> rdar://47536127
>
> Differential Revision: https://reviews.llvm.org/D58213
>
> Modified:
> cfe/trunk/lib/Basic/FileManager.cpp
> cfe/trunk/unittests/Basic/FileManagerTest.cpp
>
> Modified: cfe/trunk/lib/Basic/FileManager.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=354075&r1=354074&r2=354075&view=diff
>
> ==
> --- cfe/trunk/lib/Basic/FileManager.cpp (original)
> +++ cfe/trunk/lib/Basic/FileManager.cpp Thu Feb 14 15:02:35 2019
> @@ -267,6 +267,9 @@ const FileEntry *FileManager::getFile(St
>if (UFE.File) {
>  if (auto PathName = UFE.File->getName())
>fillRealPathName(&UFE, *PathName);
> +  } else if (!openFile) {
> +// We should still fill the path even if we aren't opening the file.
> +fillRealPathName(&UFE, InterndFileName);
>}
>return &UFE;
>  }
>
> Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354075&r1=354074&r2=354075&view=diff
>
> ==
> --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
> +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Thu Feb 14 15:02:35 2019
> @@ -346,4 +346,18 @@ TEST_F(FileManagerTest, getVirtualFileFi
>EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
>  }
>
> +TEST_F(FileManagerTest, getFileDontOpenRealPath) {
> +  auto statCache = llvm::make_unique();
> +  statCache->InjectDirectory("/tmp/abc", 42);
> +  SmallString<64> Path("/tmp/abc/foo.cpp");
> +  statCache->InjectFile(Path.str().str().c_str(), 43);
> +  manager.setStatCache(std::move(statCache));
> +
> +  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
> +
> +  ASSERT_TRUE(file != nullptr);
> +
> +  ASSERT_EQ(file->tryGetRealPathName(), Path);
> +}
> +
>  } // anonymous namespace
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://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] D58291: [clangd] Include textual diagnostic ID as Diagnostic.code.

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 187048.
sammccall added a comment.

Unit test.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58291

Files:
  clangd/Diagnostics.cpp
  clangd/Diagnostics.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  test/clangd/compile-commands-path-in-initialize.test
  test/clangd/diagnostic-category.test
  test/clangd/diagnostics.test
  test/clangd/did-change-configuration-params.test
  test/clangd/execute-command.test
  test/clangd/fixits-codeaction.test
  test/clangd/fixits-command.test
  test/clangd/fixits-embed-in-diagnostic.test
  unittests/clangd/DiagnosticsTests.cpp

Index: unittests/clangd/DiagnosticsTests.cpp
===
--- unittests/clangd/DiagnosticsTests.cpp
+++ unittests/clangd/DiagnosticsTests.cpp
@@ -12,6 +12,7 @@
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
+#include "clang/Basic/DiagnosticSema.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -216,6 +217,7 @@
 
 TEST(DiagnosticsTest, ToLSP) {
   clangd::Diag D;
+  D.ID = clang::diag::err_enum_class_reference;
   D.Message = "something terrible happened";
   D.Range = {pos(1, 2), pos(3, 4)};
   D.InsideMainFile = true;
@@ -284,6 +286,8 @@
   LSPDiags,
   ElementsAre(Pair(EqualToLSPDiag(MainLSP), ElementsAre(EqualToFix(F))),
   Pair(EqualToLSPDiag(NoteInMainLSP), IsEmpty(;
+  EXPECT_EQ(LSPDiags[0].first.code, "err_enum_class_reference");
+  EXPECT_EQ(LSPDiags[1].first.code, "");
 }
 
 struct SymbolWithHeader {
Index: test/clangd/fixits-embed-in-diagnostic.test
===
--- test/clangd/fixits-embed-in-diagnostic.test
+++ test/clangd/fixits-embed-in-diagnostic.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "err_use_with_wrong_tag",
 # CHECK-NEXT:"codeActions": [
 # CHECK-NEXT:  {
 # CHECK-NEXT:"edit": {
Index: test/clangd/fixits-command.test
===
--- test/clangd/fixits-command.test
+++ test/clangd/fixits-command.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "warn_condition_is_assignment",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: test/clangd/fixits-codeaction.test
===
--- test/clangd/fixits-codeaction.test
+++ test/clangd/fixits-codeaction.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"diagnostics": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"code": "warn_condition_is_assignment",
 # CHECK-NEXT:"message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
@@ -23,13 +24,14 @@
 # CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
 # CHECK-NEXT:  }
 ---
-{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":0,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses (fixes available)"}]}}}
+{"jsonrpc":"2.0","id":2,"method":"textDocument/codeAction","params":{"textDocument":{"uri":"test:///foo.c"},"range":{"start":{"line":0,"character":13},"end":{"line":0,"character":35}},"context":{"diagnostics":[{"range":{"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 37}},"severity":2,"message":"Using the result of an assignment as a condition without parentheses (fixes available)", "code": "warn_condition_is_assignment"}]}}}
 #  CHECK:  "id": 2,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": [
 # CHECK-NEXT:{
 # CHECK-NEXT:  "diagnostics": [
 # CHECK-NEXT:{
+# CHECK-NEXT:  "code": "warn_condition_is_assignment",
 # CHECK-NEXT:  "message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
@@ -82,6 +84,7 @@
 # CHECK-NEXT:{
 # CHECK-NEXT:  "diagnostics": [
 # CHECK-NEXT:{
+# CHECK-NEXT:  "code": "warn_condition_is_assignment",
 # CHECK-NEXT:  "message": "Using the result of an assignment as a condition without parentheses (fixes available)",
 # CHECK-NEXT:  "range": {
 # CHECK-NEXT:"end": {
Index: test/clangd/execute-command.test

[PATCH] D58293: [clang][Index] Enable indexing of Template Type Parameters behind a flag

2019-02-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: ilya-biryukov, akyrtzi.
Herald added subscribers: cfe-commits, arphaman, ioeric, kristof.beyls, 
javed.absar.
Herald added a project: clang.

clangd uses indexing api to provide references and it was not possible
to perform symbol information for template parameters. This patch enables
visiting of TemplateTypeParmTypeLocs.


Repository:
  rC Clang

https://reviews.llvm.org/D58293

Files:
  include/clang/Index/IndexingAction.h
  lib/Index/IndexTypeSourceInfo.cpp
  lib/Index/IndexingContext.cpp
  lib/Index/IndexingContext.h
  unittests/Index/IndexTests.cpp

Index: unittests/Index/IndexTests.cpp
===
--- unittests/Index/IndexTests.cpp
+++ unittests/Index/IndexTests.cpp
@@ -93,6 +93,7 @@
   IndexingOptions Opts;
 };
 
+using testing::AllOf;
 using testing::Contains;
 using testing::Not;
 using testing::UnorderedElementsAre;
@@ -134,6 +135,25 @@
   EXPECT_THAT(Index->Symbols, Not(Contains(QName("bar";
 }
 
+TEST(IndexTest, IndexTypeParmDecls) {
+  std::string Code = R"cpp(
+template  struct Foo {
+  T t = I;
+};
+  )cpp";
+  auto Index = std::make_shared();
+  IndexingOptions Opts;
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols, AllOf(Not(Contains(QName("Foo::T"))),
+Not(Contains(QName("Foo::I");
+
+  Opts.IndexTemplateParmDecls = true;
+  Index->Symbols.clear();
+  tooling::runToolOnCode(new IndexAction(Index, Opts), Code);
+  EXPECT_THAT(Index->Symbols,
+  AllOf(Contains(QName("Foo::T")), Contains(QName("Foo::I";
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: lib/Index/IndexingContext.h
===
--- lib/Index/IndexingContext.h
+++ lib/Index/IndexingContext.h
@@ -63,6 +63,8 @@
 
   bool shouldIndexParametersInDeclarations() const;
 
+  bool shouldIndexTemplateParmDecls() const;
+
   static bool isTemplateImplicitInstantiation(const Decl *D);
 
   bool handleDecl(const Decl *D, SymbolRoleSet Roles = SymbolRoleSet(),
Index: lib/Index/IndexingContext.cpp
===
--- lib/Index/IndexingContext.cpp
+++ lib/Index/IndexingContext.cpp
@@ -44,6 +44,10 @@
   return IndexOpts.IndexParametersInDeclarations;
 }
 
+bool IndexingContext::shouldIndexTemplateParmDecls() const {
+  return IndexOpts.IndexTemplateParmDecls;
+}
+
 bool IndexingContext::handleDecl(const Decl *D,
  SymbolRoleSet Roles,
  ArrayRef Relations) {
@@ -76,8 +80,10 @@
   if (!shouldIndexFunctionLocalSymbols() && isFunctionLocalSymbol(D))
 return true;
 
-  if (isa(D) || isa(D))
+  if (!shouldIndexTemplateParmDecls() &&
+  (isa(D) || isa(D))) {
 return true;
+  }
 
   return handleDeclOccurrence(D, Loc, /*IsRef=*/true, Parent, Roles, Relations,
   RefE, RefD, DC);
Index: lib/Index/IndexTypeSourceInfo.cpp
===
--- lib/Index/IndexTypeSourceInfo.cpp
+++ lib/Index/IndexTypeSourceInfo.cpp
@@ -45,6 +45,13 @@
   return false;\
   } while (0)
 
+  bool VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TTPL) {
+SourceLocation Loc = TTPL.getNameLoc();
+TemplateTypeParmDecl *TTPD = TTPL.getDecl();
+return IndexCtx.handleReference(TTPD, Loc, Parent, ParentDC,
+SymbolRoleSet());
+  }
+
   bool VisitTypedefTypeLoc(TypedefTypeLoc TL) {
 SourceLocation Loc = TL.getNameLoc();
 TypedefNameDecl *ND = TL.getTypedefNameDecl();
Index: include/clang/Index/IndexingAction.h
===
--- include/clang/Index/IndexingAction.h
+++ include/clang/Index/IndexingAction.h
@@ -46,6 +46,7 @@
   bool IndexMacrosInPreprocessor = false;
   // Has no effect if IndexFunctionLocals are false.
   bool IndexParametersInDeclarations = false;
+  bool IndexTemplateParmDecls = false;
 };
 
 /// Creates a frontend action that indexes all symbols (macros and AST decls).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58292: Add support for importing ChooseExpr AST nodes.

2019-02-15 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder created this revision.
Herald added a reviewer: shafik.
Herald added subscribers: cfe-commits, jdoerfert.
Herald added a project: clang.

This allows ASTs to be merged when they contain ChooseExpr (the GNU
__builtin_choose_expr construction). This is needed, for example, for
cross-CTU analysis of C code that makes use of __builtin_choose_expr.

The node is already supported in the AST, but it didn't have a matcher
in ASTMatchers. So, this change adds the matcher and adds support to
ASTImporter.


Repository:
  rC Clang

https://reviews.llvm.org/D58292

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  lib/AST/ASTImporter.cpp
  lib/ASTMatchers/ASTMatchersInternal.cpp
  test/ASTMerge/choose-expr/Inputs/choose1.c
  test/ASTMerge/choose-expr/Inputs/choose2.c
  test/ASTMerge/choose-expr/test.c
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -563,6 +563,15 @@
   stringLiteral(hasType(asString("const char [7]"));
 }
 
+TEST_P(ImportExpr, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  testImport(
+"void declToImport() { __builtin_choose_expr(1, 2, 3); }",
+Lang_C, "", Lang_C, Verifier,
+functionDecl(hasDescendant(chooseExpr(;
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1082,6 +1091,38 @@
   EXPECT_EQ(To, nullptr);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  // The macro in this TuDecl violates standard rules of macros (like not
+  // using a variable more than once), but it's only used to test a realistic
+  // __builtin_choose_expr construction.
+  Decl *FromTU = getTuDecl(
+  R"(
+  #define abs_int(x) __builtin_choose_expr(\
+ __builtin_types_compatible_p(__typeof(x), unsigned int),  \
+ x,\
+ __builtin_choose_expr(\
+   __builtin_types_compatible_p(__typeof(x), int), \
+   x < 0 ? -x : x, \
+   (void)0))
+  void declToImport() {
+int x = -10;
+int abs_x = abs_int(x);
+(void)abs_x;
+  }
+  )",
+  Lang_C, "input.c");
+  auto *From = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
+  ASSERT_TRUE(From);
+  auto *To = Import(From, Lang_C);
+  ASSERT_TRUE(To);
+  EXPECT_TRUE(MatchVerifier().match(
+  To, functionDecl(hasName("declToImport"),
+   hasDescendant(chooseExpr(hasDescendant(chooseExpr()));
+}
+
 const internal::VariadicDynCastAllOfMatcher
 cxxPseudoDestructorExpr;
 
Index: test/ASTMerge/choose-expr/test.c
===
--- /dev/null
+++ test/ASTMerge/choose-expr/test.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/choose1.c
+// RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/choose2.c
+// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1
Index: test/ASTMerge/choose-expr/Inputs/choose2.c
===
--- /dev/null
+++ test/ASTMerge/choose-expr/Inputs/choose2.c
@@ -0,0 +1,12 @@
+#define abs_int(x) __builtin_choose_expr( \
+__builtin_types_compatible_p(__typeof(x), unsigned int),  \
+x,\
+__builtin_choose_expr(\
+__builtin_types_compatible_p(__typeof(x), int),   \
+x < 0 ? -x : x,   \
+(void)0))
+void declToImport() {
+  int x = -10;
+  int abs_x = abs_int(x);
+  (void)abs_x;
+}
Index: test/ASTMerge/choose-expr/Inputs/choose1.c
===
--- /dev/null
+++ test/ASTMerge/choose-expr/Inputs/choose1.c
@@ -0,0 +1,12 @@
+#define abs_int(x) __builtin_choose_expr( \
+__builtin_types_compatible_p(__typeof(x), unsigned int),  \
+x,\
+__builtin_choose_expr(\
+__builtin_types_compatible_p(__typeof(x), int),   \
+x < 0 ? -x : x,   \
+(void)0))
+void declToImport() {
+  int x = -10;
+  int abs_x = abs_int(x);
+  (void)abs_x;
+}
Index: lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- lib/ASTMatchers/ASTMatchersInternal.cpp
+++ lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -727,6 +727,7 @@
 compoundLiteralExpr;
 const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
+const internal::VariadicDynCastAllOfMatcher chooseExpr;
 const internal::V

[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-15 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: lib/Sema/JumpDiagnostics.cpp:675
+  // asm-goto.
+  //if (!IsAsmGoto && IndirectJumpTargets.empty()) {
+  if (JumpTargets.empty()) {

efriedma wrote:
> Commented-out code?
> 
> We probably don't need a diagnostic for an asm goto which doesn't have any 
> labels.  If we do, it shouldn't be here.
:-(

Yes, you are right!  We don't need a diagnostic for asm goto.  The error will 
be giving during parser.  I changed.

Thank you so much for your review.
  



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

https://reviews.llvm.org/D56571



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


[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-02-15 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 187036.
jyu2 marked an inline comment as done.
jyu2 added a comment.

Review comment addressed


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

https://reviews.llvm.org/D56571

Files:
  include/clang/AST/Stmt.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTImporter.cpp
  lib/AST/Stmt.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Analysis/CFG.cpp
  lib/CodeGen/CGStmt.cpp
  lib/Parse/ParseStmtAsm.cpp
  lib/Sema/JumpDiagnostics.cpp
  lib/Sema/SemaStmtAsm.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Analysis/asm-goto.cpp
  test/CodeGen/asm-goto.c
  test/CodeGen/asm.c
  test/CodeGen/inline-asm-mixed-style.c
  test/Coverage/c-language-features.inc
  test/PCH/asm.h
  test/Parser/asm.c
  test/Parser/asm.cpp
  test/Sema/asm-goto.cpp
  test/Sema/asm.c
  test/Sema/inline-asm-validate-tmpl.cpp
  test/Sema/scope-check.c

Index: test/Sema/scope-check.c
===
--- test/Sema/scope-check.c
+++ test/Sema/scope-check.c
@@ -232,3 +232,19 @@
 
 // rdar://9024687
 int test16(int [sizeof &&z]); // expected-error {{use of address-of-label extension outside of a function body}}
+
+//Asm goto:
+int test16(int n)
+{
+  // expected-error@+2 {{cannot jump from this asm goto statement to one of its possible targets}}
+  // expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm volatile goto("testl %0, %0; jne %l1;" :: "r"(n)::label_true, loop);
+  // expected-note@+2 {{jump bypasses initialization of variable length array}}
+  // expected-note@+1 {{possible target of asm goto statement}}
+  return ({int a[n];label_true: 2;});
+  // expected-note@+1 {{jump bypasses initialization of variable length array}}
+  int b[n];
+// expected-note@+1 {{possible target of asm goto statement}}
+loop:
+  return 0;
+}
Index: test/Sema/inline-asm-validate-tmpl.cpp
===
--- test/Sema/inline-asm-validate-tmpl.cpp
+++ test/Sema/inline-asm-validate-tmpl.cpp
@@ -23,3 +23,13 @@
 	asm("rol %1, %0" :"=r"(value): "I"(N + 1));
 }
 int	foo() { testc<2>(10); }
+
+// these should compile without error
+template  bool testd()
+{
+  __asm goto ("" : : : : lab);
+  return true;
+lab:
+  return false;
+}
+bool foox() { return testd<0> (); }
Index: test/Sema/asm.c
===
--- test/Sema/asm.c
+++ test/Sema/asm.c
@@ -295,3 +295,24 @@
   return r0 + r1;
 }
 
+void test18()
+{
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm goto ("" : : : : lab, lab, lab2, lab);
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm goto ("xorw %[lab], %[lab]; je %l[lab]" : : [lab] "i" (0) : : lab);
+lab:;
+lab2:;
+  int x,x1;
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm ("" : [lab] "=r" (x),[lab] "+r" (x) : [lab1] "r" (x));
+  // expected-error@+2 {{duplicate use of asm operand name "lab"}}
+  // expected-note@+1 {{asm operand name "lab" first referenced here}}
+  asm ("" : [lab] "=r" (x1) : [lab] "r" (x));
+  // expected-error@+1 {{invalid operand number in inline asm string}}
+  asm ("jne %l0":::);
+  asm goto ("jne %l0"lab);
+}
Index: test/Sema/asm-goto.cpp
===
--- /dev/null
+++ test/Sema/asm-goto.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 %s -triple i386-pc-linux-gnu -verify -fsyntax-only
+
+struct NonTrivial {
+  ~NonTrivial();
+  int f(int);
+private:
+  int k;
+};
+void JumpDiagnostics(int n) {
+// expected-error@+1 {{cannot jump from this goto statement to its label}}
+  goto DirectJump;
+// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
+  NonTrivial tnp1;
+
+DirectJump:
+// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm goto("jmp %l0;" Later);
+// expected-note@+1 {{jump bypasses variable with a non-trivial destructor}}
+  NonTrivial tnp2;
+// expected-note@+1 {{possible target of asm goto statement}}
+Later:
+  return;
+}
+
+struct S { ~S(); };
+void foo(int a) {
+  if (a) {
+FOO:
+// expected-note@+2 {{jump exits scope of variable with non-trivial destructor}}
+// expected-note@+1 {{jump exits scope of variable with non-trivial destructor}}
+S s;
+void *p = &&BAR;
+// expected-error@+1 {{cannot jump from this asm goto statement to one of its possible targets}}
+  asm goto("jmp %l0;" BAR);
+// expected-error@+1 {{cannot jump from this indirect goto statement to one of its possible targ

[PATCH] D57948: [Sema] Fix a regression introduced in "[AST][Sema] Remove CallExpr::setNumArgs"

2019-02-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: hansw.
aaron.ballman added a comment.

In D57948#1399403 , @riccibruno wrote:

> (Following up on a discussion on IRC) I have looked at what would be needed 
> to revert the set of patches which introduced this change, but this results 
> in a >1k lines diff which do not apply cleanly. I think it might be safer to 
> just merge this fix. Unless @aaron.ballman disagree, @hans  could you please 
> merge this into the release branch ?


Thank you for looking into the 8.0 revert approach, @riccibruno! I'm okay with 
putting this patch on 8.0 instead -- you should file a new bug, mark it as 
blocking https://bugs.llvm.org/show_bug.cgi?id=40331, and make sure @hansw is 
CCed on the bug.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57948



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


[PATCH] D57660: [Sema] SequenceChecker: Handle references and members

2019-02-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 187035.
riccibruno added a comment.
Herald added a subscriber: jdoerfert.

Rebased. Does this implementation make sense ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57660

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/SemaCXX/warn-unsequenced.cpp

Index: test/SemaCXX/warn-unsequenced.cpp
===
--- test/SemaCXX/warn-unsequenced.cpp
+++ test/SemaCXX/warn-unsequenced.cpp
@@ -161,16 +161,17 @@
 void S1::member_f(S1 &s) {
   int xs[10];
 
-  ++a + ++a; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
- // cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
-  a + ++a; // cxx11-warning {{unsequenced modification and access to 'a'}}
-   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  ++a + ++a; // cxx11-warning {{multiple unsequenced modifications to member 'a'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'a'}}
+  a + ++a; // cxx11-warning {{unsequenced modification and access to member 'a'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'a'}}
   ++a + ++b; // no-warning
   a + ++b; // no-warning
 
-  // TODO: Warn here.
-  ++s.a + ++s.a; // no-warning TODO {{multiple unsequenced modifications to}}
-  s.a + ++s.a; // no-warning TODO {{unsequenced modification and access to}}
+  ++s.a + ++s.a; // cxx11-warning {{multiple unsequenced modifications to member 'a' of 's'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'a' of 's'}}
+  s.a + ++s.a; // cxx11-warning {{unsequenced modification and access to member 'a' of 's'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'a' of 's'}}
   ++s.a + ++s.b; // no-warning
   s.a + ++s.b; // no-warning
 
@@ -180,16 +181,18 @@
   a + ++s.b; // no-warning
 
   // TODO Warn here for bit-fields in the same memory location.
-  ++bf1 + ++bf1; // cxx11-warning {{multiple unsequenced modifications to 'bf1'}}
- // cxx17-warning@-1 {{multiple unsequenced modifications to 'bf1'}}
-  bf1 + ++bf1; // cxx11-warning {{unsequenced modification and access to 'bf1'}}
-   // cxx17-warning@-1 {{unsequenced modification and access to 'bf1'}}
+  ++bf1 + ++bf1; // cxx11-warning {{multiple unsequenced modifications to member 'bf1'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'bf1'}}
+  bf1 + ++bf1; // cxx11-warning {{unsequenced modification and access to member 'bf1'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'bf1'}}
   ++bf1 + ++bf2; // no-warning TODO {{multiple unsequenced modifications to}}
   bf1 + ++bf2; // no-warning TODO {{unsequenced modification and access to}}
 
   // TODO Warn here for bit-fields in the same memory location.
-  ++s.bf1 + ++s.bf1; // no-warning TODO {{multiple unsequenced modifications to}}
-  s.bf1 + ++s.bf1; // no-warning TODO {{unsequenced modification and access to}}
+  ++s.bf1 + ++s.bf1; // cxx11-warning {{multiple unsequenced modifications to member 'bf1' of 's'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'bf1' of 's'}}
+  s.bf1 + ++s.bf1; // cxx11-warning {{unsequenced modification and access to member 'bf1' of 's'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'bf1' of 's'}}
   ++s.bf1 + ++s.bf2; // no-warning TODO {{multiple unsequenced modifications to}}
   s.bf1 + ++s.bf2; // no-warning TODO {{unsequenced modification and access to}}
 
@@ -205,15 +208,19 @@
 };
 
 void S2::f2() {
-  ++x + ++x; // no-warning TODO {{multiple unsequenced modifications to}}
-  x + ++x; // no-warning TODO {{unsequenced modification and access to}}
+  ++x + ++x; // cxx11-warning {{multiple unsequenced modifications to member 'x'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'x'}}
+  x + ++x; // cxx11-warning {{unsequenced modification and access to member 'x'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'x'}}
   ++x + ++y; // no-warning
   x + ++y; // no-warning
 }
 
 void f2(S2 &s) {
-  ++s.x + ++s.x; // no-warning TODO {{multiple unsequenced modifications to}}
-  s.x + ++s.x; // no-warning TODO {{unsequenced modification and access to}}
+  ++s.x + ++s.x; // cxx11-warning {{multiple unsequenced modifications to member 'x' of 's'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to member 'x' of 's'}}
+  s.x + ++s.x; // cxx11-warning {{unsequenced modification and access to member 'x' of 's'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to member 'x' of 's'}}
   ++s.x + ++s.y; // no-warning
   s.x + ++s.y; // no-warning
 }
@@ -229,

r354151 - [Sema][NFC] SequenceChecker: Add tests for references/members, and prepare for the C++17 tests

2019-02-15 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Fri Feb 15 10:12:58 2019
New Revision: 354151

URL: http://llvm.org/viewvc/llvm-project?rev=354151&view=rev
Log:
[Sema][NFC] SequenceChecker: Add tests for references/members, and prepare for 
the C++17 tests

Add some tests for unsequenced operations with members and references.
For now most of it is unhandled but it shows what work needs to be done.

Also merge the tests for the C++17 sequencing rules in warn-unsequenced.cpp
since we want to make sure that the appropriate warnings are still present
in C++17 without duplicating the whole content of warn-unsequenced.cpp.


Removed:
cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp
Modified:
cfe/trunk/test/SemaCXX/warn-unsequenced.cpp

Removed: cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp?rev=354150&view=auto
==
--- cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unsequenced-cxx17.cpp (removed)
@@ -1,8 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wno-unused %s
-
-void test() {
-  int xs[10];
-  int *p = xs;
-  // expected-no-diagnostics
-  p[(long long unsigned)(p = 0)]; // ok
-}

Modified: cfe/trunk/test/SemaCXX/warn-unsequenced.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-unsequenced.cpp?rev=354151&r1=354150&r2=354151&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-unsequenced.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-unsequenced.cpp Fri Feb 15 10:12:58 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wno-unused %s
+// RUN: %clang_cc1 -fsyntax-only -verify=cxx11 -std=c++11 -Wno-unused 
-Wno-uninitialized -Wunsequenced %s
+// RUN: %clang_cc1 -fsyntax-only -verify=cxx17 -std=c++17 -Wno-unused 
-Wno-uninitialized -Wunsequenced %s
 
 int f(int, int = 0);
 
@@ -10,81 +11,107 @@ struct S {
   int n;
 };
 
+// TODO: Implement the C++17 sequencing rules.
 void test() {
   int a;
   int xs[10];
   ++a = 0; // ok
-  a + ++a; // expected-warning {{unsequenced modification and access to 'a'}}
+  a + ++a; // cxx11-warning {{unsequenced modification and access to 'a'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   a = ++a; // ok
-  a + a++; // expected-warning {{unsequenced modification and access to 'a'}}
-  a = a++; // expected-warning {{multiple unsequenced modifications to 'a'}}
+  a + a++; // cxx11-warning {{unsequenced modification and access to 'a'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  a = a++; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
+   // TODO cxx17-warning@-1 {{multiple unsequenced modifications to 
'a'}}
   ++ ++a; // ok
   (a++, a++); // ok
-  ++a + ++a; // expected-warning {{multiple unsequenced modifications to 'a'}}
-  a++ + a++; // expected-warning {{multiple unsequenced modifications}}
+  ++a + ++a; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
+  a++ + a++; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
+ // cxx17-warning@-1 {{multiple unsequenced modifications to 'a'}}
   (a++, a) = 0; // ok, increment is sequenced before value computation of LHS
   a = xs[++a]; // ok
-  a = xs[a++]; // expected-warning {{multiple unsequenced modifications}}
-  (a ? xs[0] : xs[1]) = ++a; // expected-warning {{unsequenced modification 
and access}}
+  a = xs[a++]; // cxx11-warning {{multiple unsequenced modifications to 'a'}}
+   // TODO cxx17-warning@-1 {{multiple unsequenced modifications 
to 'a'}}
+  (a ? xs[0] : xs[1]) = ++a; // cxx11-warning {{unsequenced modification and 
access to 'a'}}
+ // TODO cxx17-warning@-1 {{unsequenced 
modification and access to 'a'}}
   a = (++a, ++a); // ok
   a = (a++, ++a); // ok
-  a = (a++, a++); // expected-warning {{multiple unsequenced modifications}}
+  a = (a++, a++); // cxx11-warning {{multiple unsequenced modifications to 
'a'}}
+  // TODO cxx17-warning@-1 {{multiple unsequenced 
modifications to 'a'}}
   f(a, a); // ok
-  f(a = 0, a); // expected-warning {{unsequenced modification and access}}
-  f(a, a += 0); // expected-warning {{unsequenced modification and access}}
-  f(a = 0, a = 0); // expected-warning {{multiple unsequenced modifications}}
+  f(a = 0, a); // cxx11-warning {{unsequenced modification and access to 'a'}}
+   // cxx17-warning@-1 {{unsequenced modification and access to 
'a'}}
+  f(a, a += 0); // cxx11-warning {{unsequenced modification and access to 'a'}}
+// cxx17-warning@-1 {{unsequenced modification and access to 
'a'}}
+  f(a = 0, a = 0); // cxx11-warning {{multiple unsequenced modificatio

Re: r354091 - Fix implementation of [temp.local]p4.

2019-02-15 Thread Richard Smith via cfe-commits
On Thu, 14 Feb 2019, 18:35 Francis Visoiu Mistrih via cfe-commits, <
cfe-commits@lists.llvm.org> wrote:

> Hi Richard,
>
> This seems to now emit an error when building the sanitizer tests:
> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/53965/consoleFull
> .
>
> I managed to reproduce it locally and when reverting your commit the error
> goes away.
>
> I am not sure if the error is in the sanitizer test’s code or actually a
> compiler error. Can you please take a look?
>

It's an error in the sanitizer test's code.

Thanks,
>
> --
> Francis
>
> On Feb 14, 2019, at 4:29 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: rsmith
> Date: Thu Feb 14 16:29:04 2019
> New Revision: 354091
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354091&view=rev
> Log:
> Fix implementation of [temp.local]p4.
>
> When a template-name is looked up, we need to give injected-class-name
> declarations of class templates special treatment, as they denote a
> template rather than a type.
>
> Previously we achieved this by applying a filter to the lookup results
> after completing name lookup, but that is incorrect in various ways, not
> least of which is that it lost all information about access and how
> members were named, and the filtering caused us to generally lose
> all ambiguity errors between templates and non-templates.
>
> We now preserve the lookup results exactly, and the few places that need
> to map from a declaration found by name lookup into a declaration of a
> template do so explicitly. Deduplication of repeated lookup results of
> the same injected-class-name declaration is done by name lookup instead
> of after the fact.
>
> Modified:
>cfe/trunk/include/clang/Sema/Lookup.h
>cfe/trunk/include/clang/Sema/Sema.h
>cfe/trunk/lib/Sema/SemaDecl.cpp
>cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>cfe/trunk/lib/Sema/SemaLookup.cpp
>cfe/trunk/lib/Sema/SemaTemplate.cpp
>cfe/trunk/test/CXX/class.access/p4.cpp
>cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
>cfe/trunk/test/SemaTemplate/temp.cpp
>
> Modified: cfe/trunk/include/clang/Sema/Lookup.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=354091&r1=354090&r2=354091&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Feb 14 16:29:04 2019
> @@ -172,7 +172,8 @@ public:
>   : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
> LookupKind(Other.LookupKind), IDNS(Other.IDNS),
> Redecl(Other.Redecl),
> ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
> -AllowHidden(Other.AllowHidden) {}
> +AllowHidden(Other.AllowHidden),
> +TemplateNameLookup(Other.TemplateNameLookup) {}
>
>   // FIXME: Remove these deleted methods once the default build includes
>   // -Wdeprecated.
> @@ -193,7 +194,8 @@ public:
> HideTags(std::move(Other.HideTags)),
> Diagnose(std::move(Other.Diagnose)),
> AllowHidden(std::move(Other.AllowHidden)),
> -Shadowed(std::move(Other.Shadowed)) {
> +Shadowed(std::move(Other.Shadowed)),
> +TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
> Other.Paths = nullptr;
> Other.Diagnose = false;
>   }
> @@ -216,6 +218,7 @@ public:
> Diagnose = std::move(Other.Diagnose);
> AllowHidden = std::move(Other.AllowHidden);
> Shadowed = std::move(Other.Shadowed);
> +TemplateNameLookup = std::move(Other.TemplateNameLookup);
> Other.Paths = nullptr;
> Other.Diagnose = false;
> return *this;
> @@ -286,6 +289,15 @@ public:
> HideTags = Hide;
>   }
>
> +  /// Sets whether this is a template-name lookup. For template-name
> lookups,
> +  /// injected-class-names are treated as naming a template rather than a
> +  /// template specialization.
> +  void setTemplateNameLookup(bool TemplateName) {
> +TemplateNameLookup = TemplateName;
> +  }
> +
> +  bool isTemplateNameLookup() const { return TemplateNameLookup; }
> +
>   bool isAmbiguous() const {
> return getResultKind() == Ambiguous;
>   }
> @@ -739,6 +751,9 @@ private:
>   /// declaration that we skipped. This only happens when \c LookupKind
>   /// is \c LookupRedeclarationWithLinkage.
>   bool Shadowed = false;
> +
> +  /// True if we're looking up a template-name.
> +  bool TemplateNameLookup = false;
> };
>
> /// Consumes visible declarations found when searching for
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354091&r1=354090&r2=354091&view=diff
>
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Feb 14 16:29:04 2019
> @@ -6212,9 +6212,21 @@ public:
>   // C++ Templates [C++ 14]
>   //
>   void F

[PATCH] D58149: [clang] Make sure C99/C11 features in are provided in C++11

2019-02-15 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

I agree with the comments. I think we should strive to be strictly conforming. 
I make that argument all the time for libc++, so I'll be consistent :-).

https://reviews.llvm.org/D58289


Repository:
  rC Clang

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

https://reviews.llvm.org/D58149



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


[PATCH] D58062: Support framework import/include auto-completion

2019-02-15 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D58062#1399499 , @sammccall wrote:

> Great, thank you! Want me to land this?
>
> (You can certainly get your own commit access at this point if you like: 
> https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access and point 
> at a couple of your patches)


Sure, you can land this one, I''ll try to get commit access in the meantime.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58062



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


[PATCH] D58218: Variable auto-init of blocks capturing self after init bugfix

2019-02-15 Thread JF Bastien via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354147: Variable auto-init of blocks capturing self after 
init bugfix (authored by jfb, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58218

Files:
  cfe/trunk/lib/CodeGen/CGDecl.cpp
  cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp


Index: cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
===
--- cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
+++ cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
@@ -45,14 +45,35 @@
 // PATTERN:   %captured1 = getelementptr inbounds 
%struct.__block_byref_captured, %struct.__block_byref_captured* %captured, i32 
0, i32 4
 // PATTERN-NEXT:  store %struct.XYZ* inttoptr (i64 -6148914691236517206 to 
%struct.XYZ*), %struct.XYZ** %captured1, align 8
 // PATTERN:   %call = call %struct.XYZ* @create(
+using Block = void (^)();
+typedef struct XYZ {
+  Block block;
+} * xyz_t;
 void test_block_self_init() {
-  using Block = void (^)();
-  typedef struct XYZ {
-Block block;
-  } * xyz_t;
   extern xyz_t create(Block block);
   __block xyz_t captured = create(^() {
-(void)captured;
+used(captured);
+  });
+}
+
+// Capturing with escape after initialization is also an edge case.
+//
+// UNINIT-LABEL:  test_block_captures_self_after_init(
+// ZERO-LABEL:test_block_captures_self_after_init(
+// ZERO:  %block = alloca <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i8* }>, align 8
+// ZERO:  %captured1 = getelementptr inbounds 
%struct.__block_byref_captured.1, %struct.__block_byref_captured.1* %captured, 
i32 0, i32 4
+// ZERO-NEXT: store %struct.XYZ* null, %struct.XYZ** %captured1, align 8
+// ZERO:  %call = call %struct.XYZ* @create(
+// PATTERN-LABEL: test_block_captures_self_after_init(
+// PATTERN:   %block = alloca <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i8* }>, align 8
+// PATTERN:   %captured1 = getelementptr inbounds 
%struct.__block_byref_captured.1, %struct.__block_byref_captured.1* %captured, 
i32 0, i32 4
+// PATTERN-NEXT:  store %struct.XYZ* inttoptr (i64 -6148914691236517206 to 
%struct.XYZ*), %struct.XYZ** %captured1, align 8
+// PATTERN:   %call = call %struct.XYZ* @create(
+void test_block_captures_self_after_init() {
+  extern xyz_t create(Block block);
+  __block xyz_t captured;
+  captured = create(^() {
+used(captured);
   });
 }
 
Index: cfe/trunk/lib/CodeGen/CGDecl.cpp
===
--- cfe/trunk/lib/CodeGen/CGDecl.cpp
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp
@@ -1620,8 +1620,9 @@
   bool capturedByInit =
   Init && emission.IsEscapingByRef && isCapturedBy(D, Init);
 
-  Address Loc =
-  capturedByInit ? emission.Addr : emission.getObjectAddress(*this);
+  bool locIsByrefHeader = !capturedByInit;
+  const Address Loc =
+  locIsByrefHeader ? emission.getObjectAddress(*this) : emission.Addr;
 
   // Note: constexpr already initializes everything correctly.
   LangOptions::TrivialAutoVarInitKind trivialAutoVarInit =
@@ -1637,7 +1638,7 @@
   return;
 
 // Only initialize a __block's storage: we always initialize the header.
-if (emission.IsEscapingByRef)
+if (emission.IsEscapingByRef && !locIsByrefHeader)
   Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false);
 
 CharUnits Size = getContext().getTypeSizeInChars(type);
@@ -1744,10 +1745,9 @@
   }
 
   llvm::Type *BP = CGM.Int8Ty->getPointerTo(Loc.getAddressSpace());
-  if (Loc.getType() != BP)
-Loc = Builder.CreateBitCast(Loc, BP);
-
-  emitStoresForConstant(CGM, D, Loc, isVolatile, Builder, constant);
+  emitStoresForConstant(
+  CGM, D, (Loc.getType() == BP) ? Loc : Builder.CreateBitCast(Loc, BP),
+  isVolatile, Builder, constant);
 }
 
 /// Emit an expression as an initializer for an object (variable, field, etc.)


Index: cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
===
--- cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
+++ cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
@@ -45,14 +45,35 @@
 // PATTERN:   %captured1 = getelementptr inbounds %struct.__block_byref_captured, %struct.__block_byref_captured* %captured, i32 0, i32 4
 // PATTERN-NEXT:  store %struct.XYZ* inttoptr (i64 -6148914691236517206 to %struct.XYZ*), %struct.XYZ** %captured1, align 8
 // PATTERN:   %call = call %struct.XYZ* @create(
+using Block = void (^)();
+typedef struct XYZ {
+  Block block;
+} * xyz_t;
 void test_block_self_init() {
-  using Block = void (^)();
-  typedef struct XYZ {
-Block block;
-  } * xyz_t;
   extern xyz_t create(Block block);
   __block xyz_t captured = create(^() {
-(void)captured;
+used(captured);
+  });
+}
+
+//

r354147 - Variable auto-init of blocks capturing self after init bugfix

2019-02-15 Thread JF Bastien via cfe-commits
Author: jfb
Date: Fri Feb 15 09:26:29 2019
New Revision: 354147

URL: http://llvm.org/viewvc/llvm-project?rev=354147&view=rev
Log:
Variable auto-init of blocks capturing self after init bugfix

Summary:
Blocks that capture themselves (and escape) after initialization currently 
codegen wrong because this:

  bool capturedByInit =
  Init && emission.IsEscapingByRef && isCapturedBy(D, Init);

  Address Loc =
  capturedByInit ? emission.Addr : emission.getObjectAddress(*this);

Already adjusts Loc from thr alloca to a GEP. This code:

if (emission.IsEscapingByRef)
  Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false);

Was trying to do the same adjustment, and a GEP on a GEP (returning an int) 
triggers an assertion.



Reviewers: ahatanak

Subscribers: jkorous, dexonsmith, cfe-commits, rjmccall

Tags: #clang

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

Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=354147&r1=354146&r2=354147&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Feb 15 09:26:29 2019
@@ -1620,8 +1620,9 @@ void CodeGenFunction::EmitAutoVarInit(co
   bool capturedByInit =
   Init && emission.IsEscapingByRef && isCapturedBy(D, Init);
 
-  Address Loc =
-  capturedByInit ? emission.Addr : emission.getObjectAddress(*this);
+  bool locIsByrefHeader = !capturedByInit;
+  const Address Loc =
+  locIsByrefHeader ? emission.getObjectAddress(*this) : emission.Addr;
 
   // Note: constexpr already initializes everything correctly.
   LangOptions::TrivialAutoVarInitKind trivialAutoVarInit =
@@ -1637,7 +1638,7 @@ void CodeGenFunction::EmitAutoVarInit(co
   return;
 
 // Only initialize a __block's storage: we always initialize the header.
-if (emission.IsEscapingByRef)
+if (emission.IsEscapingByRef && !locIsByrefHeader)
   Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false);
 
 CharUnits Size = getContext().getTypeSizeInChars(type);
@@ -1744,10 +1745,9 @@ void CodeGenFunction::EmitAutoVarInit(co
   }
 
   llvm::Type *BP = CGM.Int8Ty->getPointerTo(Loc.getAddressSpace());
-  if (Loc.getType() != BP)
-Loc = Builder.CreateBitCast(Loc, BP);
-
-  emitStoresForConstant(CGM, D, Loc, isVolatile, Builder, constant);
+  emitStoresForConstant(
+  CGM, D, (Loc.getType() == BP) ? Loc : Builder.CreateBitCast(Loc, BP),
+  isVolatile, Builder, constant);
 }
 
 /// Emit an expression as an initializer for an object (variable, field, etc.)

Modified: cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp?rev=354147&r1=354146&r2=354147&view=diff
==
--- cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/trivial-auto-var-init.cpp Fri Feb 15 09:26:29 2019
@@ -45,14 +45,35 @@ void test_block() {
 // PATTERN:   %captured1 = getelementptr inbounds 
%struct.__block_byref_captured, %struct.__block_byref_captured* %captured, i32 
0, i32 4
 // PATTERN-NEXT:  store %struct.XYZ* inttoptr (i64 -6148914691236517206 to 
%struct.XYZ*), %struct.XYZ** %captured1, align 8
 // PATTERN:   %call = call %struct.XYZ* @create(
+using Block = void (^)();
+typedef struct XYZ {
+  Block block;
+} * xyz_t;
 void test_block_self_init() {
-  using Block = void (^)();
-  typedef struct XYZ {
-Block block;
-  } * xyz_t;
   extern xyz_t create(Block block);
   __block xyz_t captured = create(^() {
-(void)captured;
+used(captured);
+  });
+}
+
+// Capturing with escape after initialization is also an edge case.
+//
+// UNINIT-LABEL:  test_block_captures_self_after_init(
+// ZERO-LABEL:test_block_captures_self_after_init(
+// ZERO:  %block = alloca <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i8* }>, align 8
+// ZERO:  %captured1 = getelementptr inbounds 
%struct.__block_byref_captured.1, %struct.__block_byref_captured.1* %captured, 
i32 0, i32 4
+// ZERO-NEXT: store %struct.XYZ* null, %struct.XYZ** %captured1, align 8
+// ZERO:  %call = call %struct.XYZ* @create(
+// PATTERN-LABEL: test_block_captures_self_after_init(
+// PATTERN:   %block = alloca <{ i8*, i32, i32, i8*, 
%struct.__block_descriptor*, i8* }>, align 8
+// PATTERN:   %captured1 = getelementptr inbounds 
%struct.__block_byref_captured.1, %struct.__block_byref_captured.1* %captured, 
i32 0, i32 4
+// PATTERN-NEXT:  store %struct.XYZ* inttoptr (i64 -6148914691236517206 to 
%struct.XYZ*), %struct.XYZ** %captured1, align 8
+// PATTERN:   %call = call %struct.XYZ* @create(
+void test_block_captures_self_after_init() {
+  extern xyz_t create(Block blo

[PATCH] D57112: [ASTTypeTraits] OMPClause handling

2019-02-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a subscriber: alexfh.
lebedev.ri added a comment.
Herald added a subscriber: jdoerfert.

Ping @hokein / @alexfh (as per git blame).
Not sure who is best suited to review this.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57112



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


[PATCH] D58062: Support framework import/include auto-completion

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Great, thank you! Want me to land this?

(You can certainly get your own commit access at this point if you like: 
https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access and point at 
a couple of your patches)


Repository:
  rC Clang

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

https://reviews.llvm.org/D58062



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


[PATCH] D58239: [clangd] Cache include fixes for diagnostics caused by the same unresolved name or incomplete type.

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

(big thumbs up to the caching overall of course!)


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58239



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


[PATCH] D58179: [OpenCL][PR40707] Allow OpenCL C types in C++ mode

2019-02-15 Thread Ronan Keryell via Phabricator via cfe-commits
keryell added a comment.

LGTM.


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

https://reviews.llvm.org/D58179



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


[PATCH] D58239: [clangd] Cache include fixes for diagnostics caused by the same unresolved name or incomplete type.

2019-02-15 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clangd/IncludeFixer.cpp:130
+  // FIXME: consider batching the requests for all diagnostics.
   llvm::Optional Matched;
   Index.lookup(Req, [&](const Symbol &Sym) {

oops - this seems broken (in both the old and new form). Symbol is a shallow 
reference, and it's not valid after lookup() returns.

We can fix here or separately... one option to fix is the ResolvedSymbol struct 
suggested above.

(The fuzzyFind case looks ok)



Comment at: clangd/IncludeFixer.h:85
+  // name or incomplete type in one parse, especially when code is
+  // copy-and-pasted without #includes. As fixes are purely dependent on index
+  // requests and index results at this point, we can cache fixes by index

This seems pretty messy (the assumption that Fix depends only on the index 
lookup).
It saves some code now at the expense of being magic. If we want to e.g. insert 
qualifiers too, I worry it's going to (stop us || return incorrect cached 
results || lead to unneccesary cache misses) depending on what we do.

What would we need to store to calculate Fix?
Maybe a struct ResolvedSymbol with {scope, name, inserted header}? (or even the 
edit to insert the header)
If it's not hugely complicated, that seems both cleaner and more extensible - 
wdyt?



Comment at: clangd/IncludeFixer.h:90
+  mutable llvm::StringMap> FuzzyReqToFixesCache;
+  mutable llvm::StringMap> LookupIDToFixesCache;
 };

DenseMap?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58239



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


[PATCH] D58284: [clang] Switch to LLVM_ENABLE_IDE

2019-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D58284#1399446 , @lebedev.ri wrote:

> In D58284#1399443 , @smeenai wrote:
>
> > CC @lebedev.ri, since I believe you raised some issues during the 
> > corresponding LLVM change but those were addressed.
>
>
> Yeah, i don't think i have any comments here.
>  The logic to pick the default of `LLVM_ENABLE_IDE` (based on the existence 
> of `CMAKE_CONFIGURATION_TYPES`) seems hacky,
>  but it indeed does not currently detect QtCreator's CMake integration as 
> "IDE", so i don't have any additional concerns,
>  this looks like a straight-forward cleanup.
>
> What i do have concerns about, is that `LLVM_ENABLE_IDE` is not documented in 
> https://llvm.org/docs/CMake.html


Good point. Added documentation in D58286 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58284



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


[PATCH] D57855: [analyzer] Reimplement checker options

2019-02-15 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

I guess removing some of the checker option descriptions from 
`lib/StataicAnalyzer/Checkers/` would be nice too, to easy on maintenance. One 
could always just use `-analyzer-checker-option-help` whenever in doubt.


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

https://reviews.llvm.org/D57855



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


[PATCH] D58284: [clang] Switch to LLVM_ENABLE_IDE

2019-02-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D58284#1399443 , @smeenai wrote:

> CC @lebedev.ri, since I believe you raised some issues during the 
> corresponding LLVM change but those were addressed.


Yeah, i don't think i have any comments here.
The logic to pick the default of `LLVM_ENABLE_IDE` (based on the existence of 
`CMAKE_CONFIGURATION_TYPES`) seems hacky,
but it indeed does not currently detect QtCreator's CMake integration as "IDE", 
so i don't have any additional concerns,
this looks like a straight-forward cleanup.

What i do have concerns about, is that `LLVM_ENABLE_IDE` is not documented in 
https://llvm.org/docs/CMake.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58284



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


[PATCH] D58284: [clang] Switch to LLVM_ENABLE_IDE

2019-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a subscriber: lebedev.ri.
smeenai added a comment.

CC @lebedev.ri, since I believe you raised some issues during the corresponding 
LLVM change but those were addressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58284



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


[PATCH] D58284: [clang] Switch to LLVM_ENABLE_IDE

2019-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: beanz, phosek.
Herald added subscribers: jdoerfert, arphaman, mgorny.
Herald added a project: clang.

r344555 switched LLVM to guarding install targets with LLVM_ENABLE_IDE
instead of CMAKE_CONFIGURATION_TYPES, which expresses the intent more
directly and can be overridden by a user. Make the corresponding change
in clang. LLVM_ENABLE_IDE is computed by HandleLLVMOptions, so it should
be available for both standalone and integrated builds.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58284

Files:
  clang/CMakeLists.txt
  clang/cmake/modules/AddClang.cmake
  clang/lib/Headers/CMakeLists.txt
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/diagtool/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt

Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -149,7 +149,7 @@
 add_custom_target(libclang-headers)
 set_target_properties(libclang-headers PROPERTIES FOLDER "Misc")
 
-if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-libclang-headers
COMPONENT libclang-headers)
 endif()
@@ -165,7 +165,7 @@
   DESTINATION
 "lib${LLVM_LIBDIR_SUFFIX}/python${PythonVersion}/site-packages")
 endforeach()
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_custom_target(libclang-python-bindings)
   add_llvm_install_targets(install-libclang-python-bindings
COMPONENT
Index: clang/tools/diagtool/CMakeLists.txt
===
--- clang/tools/diagtool/CMakeLists.txt
+++ clang/tools/diagtool/CMakeLists.txt
@@ -23,7 +23,7 @@
 COMPONENT diagtool
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-diagtool
   DEPENDS diagtool
   COMPONENT diagtool)
Index: clang/tools/c-index-test/CMakeLists.txt
===
--- clang/tools/c-index-test/CMakeLists.txt
+++ clang/tools/c-index-test/CMakeLists.txt
@@ -61,7 +61,7 @@
 RUNTIME DESTINATION "${INSTALL_DESTINATION}"
 COMPONENT c-index-test)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-c-index-test
  DEPENDS c-index-test
  COMPONENT c-index-test)
Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -178,7 +178,7 @@
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
   DESTINATION lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
-if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-headers
DEPENDS clang-headers
COMPONENT clang-headers)
Index: clang/cmake/modules/AddClang.cmake
===
--- clang/cmake/modules/AddClang.cmake
+++ clang/cmake/modules/AddClang.cmake
@@ -103,7 +103,7 @@
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})
@@ -147,7 +147,7 @@
   RUNTIME DESTINATION bin
   COMPONENT ${name})
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -547,7 +547,7 @@
 add_custom_target(clang-libraries)
 set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-libraries
DEPENDS clang-libraries
COMPONENT clang-libraries)
@@ -558,7 +558,7 @@
   list(REMOVE_DUPLICATES CLANG_LIBS)
   foreach(lib ${CLANG_LIBS})
 add_dependencies(clang-libraries ${lib})
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_dependencies(install-clang-libraries install-${lib})
 endif()
   endforeach()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58269: [clang] Add build and install targets for clang libraries

2019-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354141: [clang] Add build and install targets for clang 
libraries (authored by smeenai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58269?vs=186957&id=187019#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58269

Files:
  CMakeLists.txt
  cmake/modules/AddClang.cmake


Index: cmake/modules/AddClang.cmake
===
--- cmake/modules/AddClang.cmake
+++ cmake/modules/AddClang.cmake
@@ -108,6 +108,8 @@
  DEPENDS ${name}
  COMPONENT ${name})
   endif()
+
+  set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   else()
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -543,6 +543,27 @@
   add_subdirectory(docs)
 endif()
 
+# Custom target to install all clang libraries.
+add_custom_target(clang-libraries)
+set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
+
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_llvm_install_targets(install-clang-libraries
+   DEPENDS clang-libraries
+   COMPONENT clang-libraries)
+endif()
+
+get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_LIBS)
+if(CLANG_LIBS)
+  list(REMOVE_DUPLICATES CLANG_LIBS)
+  foreach(lib ${CLANG_LIBS})
+add_dependencies(clang-libraries ${lib})
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_dependencies(install-clang-libraries install-${lib})
+endif()
+  endforeach()
+endif()
+
 add_subdirectory(cmake/modules)
 
 if(CLANG_STAGE)


Index: cmake/modules/AddClang.cmake
===
--- cmake/modules/AddClang.cmake
+++ cmake/modules/AddClang.cmake
@@ -108,6 +108,8 @@
  DEPENDS ${name}
  COMPONENT ${name})
   endif()
+
+  set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   else()
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -543,6 +543,27 @@
   add_subdirectory(docs)
 endif()
 
+# Custom target to install all clang libraries.
+add_custom_target(clang-libraries)
+set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
+
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_llvm_install_targets(install-clang-libraries
+   DEPENDS clang-libraries
+   COMPONENT clang-libraries)
+endif()
+
+get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_LIBS)
+if(CLANG_LIBS)
+  list(REMOVE_DUPLICATES CLANG_LIBS)
+  foreach(lib ${CLANG_LIBS})
+add_dependencies(clang-libraries ${lib})
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_dependencies(install-clang-libraries install-${lib})
+endif()
+  endforeach()
+endif()
+
 add_subdirectory(cmake/modules)
 
 if(CLANG_STAGE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58268: [clang] Create install targets for non-shared libraries

2019-02-15 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354140: [clang] Create install targets for non-shared 
libraries (authored by smeenai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58268?vs=186955&id=187018#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58268

Files:
  cmake/modules/AddClang.cmake


Index: cmake/modules/AddClang.cmake
===
--- cmake/modules/AddClang.cmake
+++ cmake/modules/AddClang.cmake
@@ -103,7 +103,7 @@
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT CMAKE_CONFIGURATION_TYPES)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})


Index: cmake/modules/AddClang.cmake
===
--- cmake/modules/AddClang.cmake
+++ cmake/modules/AddClang.cmake
@@ -103,7 +103,7 @@
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT CMAKE_CONFIGURATION_TYPES)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354141 - [clang] Add build and install targets for clang libraries

2019-02-15 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Fri Feb 15 07:59:04 2019
New Revision: 354141

URL: http://llvm.org/viewvc/llvm-project?rev=354141&view=rev
Log:
[clang] Add build and install targets for clang libraries

This is modeled after the existing llvm-libraries target. It's a
convenient way to include all clang libraries in a distribution.

This differs slightly from the llvm-libraries target in that it adds any
library added via add_clang_library, whereas llvm-libraries only
includes targets added via add_llvm_library that didn't use the MODULE
or BUILDTREE_ONLY arguments. add_clang_library doesn't appear to have
any equivalents of those arguments, so the conditions don't apply.

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/cmake/modules/AddClang.cmake

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=354141&r1=354140&r2=354141&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Feb 15 07:59:04 2019
@@ -543,6 +543,27 @@ if( CLANG_INCLUDE_DOCS )
   add_subdirectory(docs)
 endif()
 
+# Custom target to install all clang libraries.
+add_custom_target(clang-libraries)
+set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
+
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_llvm_install_targets(install-clang-libraries
+   DEPENDS clang-libraries
+   COMPONENT clang-libraries)
+endif()
+
+get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_LIBS)
+if(CLANG_LIBS)
+  list(REMOVE_DUPLICATES CLANG_LIBS)
+  foreach(lib ${CLANG_LIBS})
+add_dependencies(clang-libraries ${lib})
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_dependencies(install-clang-libraries install-${lib})
+endif()
+  endforeach()
+endif()
+
 add_subdirectory(cmake/modules)
 
 if(CLANG_STAGE)

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=354141&r1=354140&r2=354141&view=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Fri Feb 15 07:59:04 2019
@@ -108,6 +108,8 @@ macro(add_clang_library name)
  DEPENDS ${name}
  COMPONENT ${name})
   endif()
+
+  set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   else()


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


r354140 - [clang] Create install targets for non-shared libraries

2019-02-15 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Fri Feb 15 07:59:02 2019
New Revision: 354140

URL: http://llvm.org/viewvc/llvm-project?rev=354140&view=rev
Log:
[clang] Create install targets for non-shared libraries

I don't see a reason for these to not have install targets created,
which in turn allows them to be bundled in distributions. This doesn't
affect the "install" target, since that just runs all CMake install
rules (and we were already creating install rules for these).

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

Modified:
cfe/trunk/cmake/modules/AddClang.cmake

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=354140&r1=354139&r2=354140&view=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Fri Feb 15 07:59:02 2019
@@ -103,7 +103,7 @@ macro(add_clang_library name)
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (${ARG_SHARED} AND NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT CMAKE_CONFIGURATION_TYPES)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})


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


[PATCH] D57948: [Sema] Fix a regression introduced in "[AST][Sema] Remove CallExpr::setNumArgs"

2019-02-15 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a subscriber: hans.
riccibruno added a comment.

(Following up on a discussion on IRC) I have looked at what would be needed to 
revert the set of patches which introduced this change, but this results in a 
>1k lines diff which do not apply cleanly. I think it might be safer to just 
merge this fix. Unless @aaron.ballman disagree, @hans  could you please merge 
this into the release branch ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57948



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


[PATCH] D56851: [ASTMatchers] Adds `CXXMemberCallExpr` matcher `invokedAtType`.

2019-02-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 3 inline comments as done.
ymandel added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3300
+///   matches `x.m()` and `p->m()`.
+AST_MATCHER_P_OVERLOAD(clang::CXXMemberCallExpr, invokedAtType,
+   clang::ast_matchers::internal::Matcher,

aaron.ballman wrote:
> ymandel wrote:
> > alexfh wrote:
> > > ymandel wrote:
> > > > aaron.ballman wrote:
> > > > > ymandel wrote:
> > > > > > aaron.ballman wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > ymandel wrote:
> > > > > > > > > ymandel wrote:
> > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > alexfh wrote:
> > > > > > > > > > > > The name of the matcher doesn't tell me much. I had to 
> > > > > > > > > > > > carefully read the documentation to understand what is 
> > > > > > > > > > > > it about. I don't have a name that would raise no 
> > > > > > > > > > > > questions and wouldn't be too verbose at the same time, 
> > > > > > > > > > > > but a bit of verbosity wouldn't hurt I guess. How about 
> > > > > > > > > > > > `objectTypeAsWritten`?
> > > > > > > > > > > Yeah, I think this would be a better name. Also, having 
> > > > > > > > > > > some examples that demonstrate where this behavior 
> > > > > > > > > > > differs from `thisPointerType` would be helpful.
> > > > > > > > > > Agreed that it needs a new name, but I'm having trouble 
> > > > > > > > > > finding one I'm satisfied with.  Here's the full 
> > > > > > > > > > description: "the type of the written implicit object 
> > > > > > > > > > argument".  I base this phrasing on the class 
> > > > > > > > > > CXXMemberCallExpr's terminology.  In `x.f(5)`, `x` is the 
> > > > > > > > > > implicit object argument, whether or not it is also 
> > > > > > > > > > implicitly surrounded by a cast.  That is, "implicit" has 
> > > > > > > > > > two different meanings in this context.
> > > > > > > > > > 
> > > > > > > > > > So, with that, how about `writtenObjectType`? It's close to 
> > > > > > > > > > `objectTypeAsWritten` but I'm hoping it makes more clear 
> > > > > > > > > > that the "written" part is the object not the type.
> > > > > > > > > I've contrasted the behavior with thisPointerType in both of 
> > > > > > > > > the examples. Do you think this helps or do you want 
> > > > > > > > > something more explicit?
> > > > > > > > Here's a totally different direction: `onOrPointsToType()`
> > > > > > > > ```
> > > > > > > > cxxMemberCallExpr(onOrPointsToType(hasDeclaration(cxxRecordDecl(hasName("Y")
> > > > > > > > ```
> > > > > > > > 
> > > > > > > I think more explicit would be better. e.g.,
> > > > > > > ```
> > > > > > > cxxMemberCallExpr(invokedAtType(hasDeclaration(cxxRecordDecl(hasName("X")
> > > > > > > matches 'x.m()' and 'p->m()'.
> > > > > > > cxxMemberCallExpr(on(thisPointerType(hasDeclaration(cxxRecordDecl(hasName("X"))
> > > > > > > matches nothing because the type of 'this' is 'Y' in both cases.
> > > > > > > ```
> > > > > > But, what about even simpler: onType? I think this parallels the 
> > > > > > intuition of the name thisPointerType.  onType(T) should match x.f 
> > > > > > and x->f, where x is type T.  
> > > > > You've pointed out why I don't think `onType` works -- it doesn't 
> > > > > match on type T -- it matches on type T, or a pointer/reference to 
> > > > > type T, which is pretty different. Someone reading the matcher may 
> > > > > expect an exact type match and insert a `pointerType()` or something 
> > > > > there thinking they need to do that to match a call through a pointer.
> > > > > 
> > > > > @alexfh, opinions?
> > > > True.  I should have explained more.  
> > > > 
> > > > 1. Ultimately, I think that none of these names really make sense on 
> > > > their own and the user will need some familiarity with the 
> > > > documentation. I spent quite a while trying to come up with better 
> > > > names and didn't find anything compelling.  I think that `onType` 
> > > > benefits from not carrying much information -- reducing the likelihood 
> > > > of misunderstanding it (they'll have to read the documentation) while 
> > > > paralleling the meaning of the matcher `on` and the behavior of 
> > > > `thisPointerType` (which also allows either the type or the pointer to 
> > > > that type).  
> > > > 
> > > > 2. My particular concern with `onOrPointsToType` is that it sounds like 
> > > > the "or" applies to the `on` but it really means "on (type or points to 
> > > > type)".  
> > > So far, my observations are:
> > > 1. three engineers quite familiar with the topic can't come up with a 
> > > name that would explain the concept behind this matcher
> > > 2. anyone reading that name would have to look up the documentation
> > > 3. the implementation of the matcher is straightforward and even shorter 
> > > than the documentation
> > > 
> > > Should we give up and let users just type `on(anyOf(hasType(Q), 
> > > hasType(pointsTo(Q`?
> > > 
> > >

  1   2   >