[PATCH] D62638: [analyzer] A Python script to prettify the ExplodedGraph dumps.

2019-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 202092.
NoQ added a comment.

Remove outdated comment.


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

https://reviews.llvm.org/D62638

Files:
  clang/test/Analysis/exploded-graph-rewriter/edge.dot
  clang/test/Analysis/exploded-graph-rewriter/empty.dot
  clang/test/Analysis/exploded-graph-rewriter/environment.dot
  clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  clang/test/Analysis/exploded-graph-rewriter/program_points.dot
  clang/test/Analysis/exploded-graph-rewriter/store.dot
  clang/utils/analyzer/exploded-graph-rewriter.py

Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- /dev/null
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -0,0 +1,386 @@
+#!/usr/bin/env python3
+
+import argparse
+import collections
+import json as json_module  # 'json' is a great name for a variable
+import logging
+import re
+
+
+# A deserialized source location.
+class SourceLocation(object):
+def __init__(self, json):
+super(SourceLocation, self).__init__()
+self.line = json['line']
+self.col = json['column']
+self.filename = json['filename'] \
+if 'filename' in json else '(main file)'
+
+
+# A deserialized program point.
+class ProgramPoint(object):
+def __init__(self, json):
+super(ProgramPoint, self).__init__()
+self.kind = json['kind']
+self.tag = json['tag']
+if self.kind == 'Edge':
+self.src_id = json['src_id']
+self.dst_id = json['dst_id']
+elif self.kind == 'Statement':
+self.stmt_kind = json['stmt_kind']
+self.pointer = json['pointer']
+self.pretty = json['pretty']
+self.sloc = SourceLocation(json['location']) \
+if json['location'] is not None else None
+elif self.kind == 'BlockEntrance':
+self.block_id = json['block_id']
+
+
+# A value of a single expression in a deserialized Environment.
+class EnvironmentBinding(object):
+def __init__(self, json):
+super(EnvironmentBinding, self).__init__()
+self.lctx_id = json['lctx_id']
+self.stmt_id = json['stmt_id']
+self.pretty = json['pretty']
+self.value = json['value']
+
+
+# Deserialized description of a location context.
+class LocationContext(object):
+def __init__(self, caption, decl, line):
+super(LocationContext, self).__init__()
+self.caption = caption
+self.decl = decl
+self.line = line
+
+
+# A group of deserialized Environment bindings that correspond to a specific
+# location context.
+class EnvironmentFrame(object):
+def __init__(self, json):
+super(EnvironmentFrame, self).__init__()
+self.location_context = LocationContext(json['location_context'],
+json['calling'],
+json['call_line'])
+self.bindings = [EnvironmentBinding(b) for b in json['items']]
+
+
+# A deserialized Environment.
+class Environment(object):
+def __init__(self, json):
+super(Environment, self).__init__()
+self.frames = [EnvironmentFrame(f) for f in json]
+
+
+# A single binding in a deserialized RegionStore cluster.
+class StoreBinding(object):
+def __init__(self, json):
+super(StoreBinding, self).__init__()
+self.kind = json['kind']
+self.offset = json['offset']
+self.value = json['value']
+
+
+# A single cluster of the deserialized RegionStore.
+class StoreCluster(object):
+def __init__(self, json):
+super(StoreCluster, self).__init__()
+self.base_region = json['cluster']
+self.bindings = [StoreBinding(b) for b in json['items']]
+
+
+# A deserialized RegionStore.
+class Store(object):
+def __init__(self, json):
+super(Store, self).__init__()
+self.clusters = [StoreCluster(c) for c in json]
+
+
+# A deserialized program state.
+class ProgramState(object):
+def __init__(self, state_id, json):
+super(ProgramState, self).__init__()
+logging.debug('Adding ProgramState ' + str(state_id))
+
+self.state_id = state_id
+self.store = Store(json['store']) \
+if json['store'] is not None else None
+self.environment = Environment(json['environment']) \
+if json['environment'] is not None else None
+# TODO: Objects under construction.
+# TODO: Constraint ranges.
+# TODO: Dynamic types of objects.
+# TODO: Checker messages.
+
+
+# A deserialized exploded graph node. Has a default constructor because it
+# may be referenced as part of an edge before its contents are deserialized,
+# and in this moment we already need a room for parents and children.
+class ExplodedNode(object):
+def __init__(self):
+super(ExplodedNode, self).__init__()
+se

[PATCH] D62638: [analyzer] A Python script to prettify the ExplodedGraph dumps.

2019-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ updated this revision to Diff 202094.
NoQ added a comment.

Use `os.path.join` for discovering the utility in tests.


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

https://reviews.llvm.org/D62638

Files:
  clang/test/Analysis/exploded-graph-rewriter/edge.dot
  clang/test/Analysis/exploded-graph-rewriter/empty.dot
  clang/test/Analysis/exploded-graph-rewriter/environment.dot
  clang/test/Analysis/exploded-graph-rewriter/lit.local.cfg
  clang/test/Analysis/exploded-graph-rewriter/program_points.dot
  clang/test/Analysis/exploded-graph-rewriter/store.dot
  clang/utils/analyzer/exploded-graph-rewriter.py

Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- /dev/null
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -0,0 +1,386 @@
+#!/usr/bin/env python3
+
+import argparse
+import collections
+import json as json_module  # 'json' is a great name for a variable.
+import logging
+import re
+
+
+# A deserialized source location.
+class SourceLocation(object):
+def __init__(self, json):
+super(SourceLocation, self).__init__()
+self.line = json['line']
+self.col = json['column']
+self.filename = json['filename'] \
+if 'filename' in json else '(main file)'
+
+
+# A deserialized program point.
+class ProgramPoint(object):
+def __init__(self, json):
+super(ProgramPoint, self).__init__()
+self.kind = json['kind']
+self.tag = json['tag']
+if self.kind == 'Edge':
+self.src_id = json['src_id']
+self.dst_id = json['dst_id']
+elif self.kind == 'Statement':
+self.stmt_kind = json['stmt_kind']
+self.pointer = json['pointer']
+self.pretty = json['pretty']
+self.sloc = SourceLocation(json['location']) \
+if json['location'] is not None else None
+elif self.kind == 'BlockEntrance':
+self.block_id = json['block_id']
+
+
+# A value of a single expression in a deserialized Environment.
+class EnvironmentBinding(object):
+def __init__(self, json):
+super(EnvironmentBinding, self).__init__()
+self.lctx_id = json['lctx_id']
+self.stmt_id = json['stmt_id']
+self.pretty = json['pretty']
+self.value = json['value']
+
+
+# Deserialized description of a location context.
+class LocationContext(object):
+def __init__(self, caption, decl, line):
+super(LocationContext, self).__init__()
+self.caption = caption
+self.decl = decl
+self.line = line
+
+
+# A group of deserialized Environment bindings that correspond to a specific
+# location context.
+class EnvironmentFrame(object):
+def __init__(self, json):
+super(EnvironmentFrame, self).__init__()
+self.location_context = LocationContext(json['location_context'],
+json['calling'],
+json['call_line'])
+self.bindings = [EnvironmentBinding(b) for b in json['items']]
+
+
+# A deserialized Environment.
+class Environment(object):
+def __init__(self, json):
+super(Environment, self).__init__()
+self.frames = [EnvironmentFrame(f) for f in json]
+
+
+# A single binding in a deserialized RegionStore cluster.
+class StoreBinding(object):
+def __init__(self, json):
+super(StoreBinding, self).__init__()
+self.kind = json['kind']
+self.offset = json['offset']
+self.value = json['value']
+
+
+# A single cluster of the deserialized RegionStore.
+class StoreCluster(object):
+def __init__(self, json):
+super(StoreCluster, self).__init__()
+self.base_region = json['cluster']
+self.bindings = [StoreBinding(b) for b in json['items']]
+
+
+# A deserialized RegionStore.
+class Store(object):
+def __init__(self, json):
+super(Store, self).__init__()
+self.clusters = [StoreCluster(c) for c in json]
+
+
+# A deserialized program state.
+class ProgramState(object):
+def __init__(self, state_id, json):
+super(ProgramState, self).__init__()
+logging.debug('Adding ProgramState ' + str(state_id))
+
+self.state_id = state_id
+self.store = Store(json['store']) \
+if json['store'] is not None else None
+self.environment = Environment(json['environment']) \
+if json['environment'] is not None else None
+# TODO: Objects under construction.
+# TODO: Constraint ranges.
+# TODO: Dynamic types of objects.
+# TODO: Checker messages.
+
+
+# A deserialized exploded graph node. Has a default constructor because it
+# may be referenced as part of an edge before its contents are deserialized,
+# and in this moment we already need a room for parents and children.
+class ExplodedNode(object):
+def __init__(self):
+super(ExplodedN

[PATCH] D62606: [Driver] -static-pie: add -z text

2019-05-29 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362050: [Driver] -static-pie: add -z text (authored by 
MaskRay, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62606

Files:
  cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
  cfe/trunk/test/Driver/linux-ld.c


Index: cfe/trunk/test/Driver/linux-ld.c
===
--- cfe/trunk/test/Driver/linux-ld.c
+++ cfe/trunk/test/Driver/linux-ld.c
@@ -190,6 +190,8 @@
 // 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: "-z"
+// CHECK-CLANG-LD-STATIC-PIE: "text"
 // 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"
@@ -203,6 +205,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "text"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"
@@ -216,6 +220,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "text"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"
Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -382,6 +382,8 @@
 CmdArgs.push_back("-static");
 CmdArgs.push_back("-pie");
 CmdArgs.push_back("--no-dynamic-linker");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("text");
   }
 
   if (ToolChain.isNoExecStackDefault()) {


Index: cfe/trunk/test/Driver/linux-ld.c
===
--- cfe/trunk/test/Driver/linux-ld.c
+++ cfe/trunk/test/Driver/linux-ld.c
@@ -190,6 +190,8 @@
 // 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: "-z"
+// CHECK-CLANG-LD-STATIC-PIE: "text"
 // 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"
@@ -203,6 +205,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "text"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
@@ -216,6 +220,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "text"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
Index: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
@@ -382,6 +382,8 @@
 CmdArgs.push_back("-static");
 CmdArgs.push_back("-pie");
 CmdArgs.push_back("--no-dynamic-linker");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("text");
   }
 
   if (ToolChain.isNoExecStackDefault()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r362050 - [Driver] -static-pie: add -z text

2019-05-29 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed May 29 18:55:43 2019
New Revision: 362050

URL: http://llvm.org/viewvc/llvm-project?rev=362050&view=rev
Log:
[Driver] -static-pie: add -z text

This matches gcc -static-pie. The intention is to prevent dynamic
relocations in read-only segments.

In ld.bfd and gold, -z notext is the default. If text relocations are needed:

* -z notext: allow and emit DF_TEXTREL.
  DF_TEXTREL is not emitted if there is no text relocation.
* -z text: error

In lld, -z text is the default (this change is a no-op).

* -z text: error on text relocations
* -z notext: allow text relocations, and emit DF_TEXTREL no matter whether
  text relocations exist.

Reviewed By: sivachandra

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/linux-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=362050&r1=362049&r2=362050&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed May 29 18:55:43 2019
@@ -382,6 +382,8 @@ void tools::gnutools::Linker::ConstructJ
 CmdArgs.push_back("-static");
 CmdArgs.push_back("-pie");
 CmdArgs.push_back("--no-dynamic-linker");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("text");
   }
 
   if (ToolChain.isNoExecStackDefault()) {

Modified: cfe/trunk/test/Driver/linux-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=362050&r1=362049&r2=362050&view=diff
==
--- cfe/trunk/test/Driver/linux-ld.c (original)
+++ cfe/trunk/test/Driver/linux-ld.c Wed May 29 18:55:43 2019
@@ -190,6 +190,8 @@
 // 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: "-z"
+// CHECK-CLANG-LD-STATIC-PIE: "text"
 // 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"
@@ -203,6 +205,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "text"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"
@@ -216,6 +220,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "text"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"


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


[PATCH] D62638: [analyzer] A Python script to prettify the ExplodedGraph dumps.

2019-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> I wrote some tests but i'm not really sure they're worth it.

Mmm, on second thought, they probably won't work out of the box, because they 
might require installing python modules in order to work. I'm actually not sure 
if all machines have python3. I'll try but it'll most likely fail. I guess i 
could try excluding them from `make check-all`.


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

https://reviews.llvm.org/D62638



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


[PATCH] D62619: [analyzer][Dominators] Add a control dependency tree builder + a new debug checker

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

I seem to have made good progress on this, although it did require a lot of 
code changes on LLVM side (basically turning `BasicBlock *` to template 
arguments). Here's a sample:

  //   <--
  //  /  <-   \
  // /  /  \   \
  // [B12 (ENTRY)] -> [B11] -> [B10]-> [B9] -> [B8] ---> [B7] -> [B6]  |
  // |  \\ /
  // |   \-> [B2] /
  // |\  /
  // |  -> [B5] -> [B4] -> [B3]
  // |   \  /
  // |<
  //  \
  //   -> [B1] -> [B0 (EXIT)]
  
  Control dependencies  (Node, Dependency):
  (2,10)
  (3,5)
  (3,9)
  (3,10)
  (4,5)
  (4,9)
  (4,10)
  (5,9)
  (5,5)
  (5,10)
  (6,8)
  (6,9)
  (6,10)
  (7,8)
  (7,9)
  (7,10)
  (8,9)
  (8,8)
  (8,10)
  (9,10)
  (10,10)

My solution is inspired by

In D62619#1521824 , @kuhar wrote:

> - 
> https://github.com/seahorn/seahorn/blob/deep-dev-5.0/include/seahorn/Analysis/ControlDependenceAnalysis.hh
> - 
> https://github.com/seahorn/seahorn/blob/deep-dev-5.0/lib/Analysis/ControlDependenceAnalysis.cc


, and I really like where this is going. I am yet to figure out how to deal 
with Clang's CFG containing null pointers in a not-too-invasive way (will 
probably end up doing something similar to `ChildrenGetter`), as it currently 
crashes.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62619



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


r362051 - [PowerPC] Set the default PLT mode on musl to Secure PLT

2019-05-29 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed May 29 19:13:15 2019
New Revision: 362051

URL: http://llvm.org/viewvc/llvm-project?rev=362051&view=rev
Log:
[PowerPC] Set the default PLT mode on musl to Secure PLT

The musl libc only supports Secure PLT.

Patch by A. Wilcox!

Reviewed By: jhibbits

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp?rev=362051&r1=362050&r2=362051&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp Wed May 29 19:13:15 2019
@@ -115,7 +115,7 @@ ppc::ReadGOTPtrMode ppc::getPPCReadGOTPt
   const ArgList &Args) {
   if (Args.getLastArg(options::OPT_msecure_plt))
 return ppc::ReadGOTPtrMode::SecurePlt;
-  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD())
+  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
 return ppc::ReadGOTPtrMode::SecurePlt;
   else
 return ppc::ReadGOTPtrMode::Bss;


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


[PATCH] D62619: [analyzer][Dominators] Add a control dependency tree builder + a new debug checker

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

Also, I read some of the article you showed as well as the one I found on the 
dominance frontier file documentation[1], and I feel a lot more enlightened 
about the subject, thanks! I'll spend more time on them before wrapping this up.

[1]
Sreedhar and Gao. A linear time algorithm for placing phi-nodes.
In Proceedings of the 22nd ACM SIGPLAN-SIGACT Symposium on Principles of 
Programming Languages
POPL '95. ACM, New York, NY, 62-73.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62619



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


[PATCH] D59185: [PowerPC] Set the default PLT mode on musl to Secure PLT

2019-05-29 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL362051: [PowerPC] Set the default PLT mode on musl to Secure 
PLT (authored by MaskRay, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D59185?vs=190003&id=202100#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D59185

Files:
  cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp


Index: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -115,7 +115,7 @@
   const ArgList &Args) {
   if (Args.getLastArg(options::OPT_msecure_plt))
 return ppc::ReadGOTPtrMode::SecurePlt;
-  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD())
+  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
 return ppc::ReadGOTPtrMode::SecurePlt;
   else
 return ppc::ReadGOTPtrMode::Bss;


Index: cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -115,7 +115,7 @@
   const ArgList &Args) {
   if (Args.getLastArg(options::OPT_msecure_plt))
 return ppc::ReadGOTPtrMode::SecurePlt;
-  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD())
+  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
 return ppc::ReadGOTPtrMode::SecurePlt;
   else
 return ppc::ReadGOTPtrMode::Bss;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62509: [Driver] Render target options (e.g. -fuse-init-array) for -fembed-bitcode

2019-05-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 202103.
MaskRay retitled this revision from "[Driver] Render -fuse-init-array for 
-fembed-bitcode" to "[Driver] Render target options (e.g. -fuse-init-array) for 
-fembed-bitcode".
MaskRay edited the summary of this revision.
MaskRay added a comment.

Add hexagon test


Repository:
  rC Clang

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

https://reviews.llvm.org/D62509

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/fembed-bitcode.c


Index: test/Driver/fembed-bitcode.c
===
--- test/Driver/fembed-bitcode.c
+++ test/Driver/fembed-bitcode.c
@@ -26,3 +26,11 @@
 // CHECK-AARCH64: "darwinpcs"
 // CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
 
+// RUN: %clang -target x86_64-pc-freebsd12 -fembed-bitcode=all -c %s -o 
/dev/null -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-INITARRAY %s
+// CHECK-INITARRAY: "-fuse-init-array"
+
+// RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c 
%s -o /dev/null -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s
+// CHECK-HEXAGON: "-target-feature"
+// CHECK-HEXAGON: "+reserved-r19"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3666,6 +3666,9 @@
 // Disable all llvm IR level optimizations.
 CmdArgs.push_back("-disable-llvm-passes");
 
+// Render target options such as -fuse-init-array on modern ELF platforms.
+TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
+
 // reject options that shouldn't be supported in bitcode
 // also reject kernel/kext
 static const constexpr unsigned kBitcodeOptionBlacklist[] = {


Index: test/Driver/fembed-bitcode.c
===
--- test/Driver/fembed-bitcode.c
+++ test/Driver/fembed-bitcode.c
@@ -26,3 +26,11 @@
 // CHECK-AARCH64: "darwinpcs"
 // CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
 
+// RUN: %clang -target x86_64-pc-freebsd12 -fembed-bitcode=all -c %s -o /dev/null -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-INITARRAY %s
+// CHECK-INITARRAY: "-fuse-init-array"
+
+// RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c %s -o /dev/null -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s
+// CHECK-HEXAGON: "-target-feature"
+// CHECK-HEXAGON: "+reserved-r19"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3666,6 +3666,9 @@
 // Disable all llvm IR level optimizations.
 CmdArgs.push_back("-disable-llvm-passes");
 
+// Render target options such as -fuse-init-array on modern ELF platforms.
+TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
+
 // reject options that shouldn't be supported in bitcode
 // also reject kernel/kext
 static const constexpr unsigned kBitcodeOptionBlacklist[] = {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r362052 - [Driver] Render target options (e.g. -fuse-init-array) for -fembed-bitcode

2019-05-29 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed May 29 19:30:04 2019
New Revision: 362052

URL: http://llvm.org/viewvc/llvm-project?rev=362052&view=rev
Log:
[Driver] Render target options (e.g. -fuse-init-array) for -fembed-bitcode

Modern ELF platforms use -fuse-init-array to emit .init_array instead of
.ctors .  ld.bfd and gold --ctors-in-init-array merge .init_array and
.ctors into .init_array but lld doesn't do that.

If crtbegin*.o crtend*.o don't provide .ctors/.dtors, such .ctors in
user object files can lead to crash (see PR42002. The first and the last
elements in .ctors/.dtors are ignored - they are traditionally provided
by crtbegin*.o crtend*.o).

Call addClangTargetOptions() to ensure -fuse-init-array is rendered on
modern ELF platforms. On Hexagon, this renders -target-feature
+reserved-r19 for -ffixed-r19.

Reviewed By: compnerd

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/fembed-bitcode.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=362052&r1=362051&r2=362052&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed May 29 19:30:04 2019
@@ -3666,6 +3666,9 @@ void Clang::ConstructJob(Compilation &C,
 // Disable all llvm IR level optimizations.
 CmdArgs.push_back("-disable-llvm-passes");
 
+// Render target options such as -fuse-init-array on modern ELF platforms.
+TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
+
 // reject options that shouldn't be supported in bitcode
 // also reject kernel/kext
 static const constexpr unsigned kBitcodeOptionBlacklist[] = {

Modified: cfe/trunk/test/Driver/fembed-bitcode.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fembed-bitcode.c?rev=362052&r1=362051&r2=362052&view=diff
==
--- cfe/trunk/test/Driver/fembed-bitcode.c (original)
+++ cfe/trunk/test/Driver/fembed-bitcode.c Wed May 29 19:30:04 2019
@@ -26,3 +26,11 @@
 // CHECK-AARCH64: "darwinpcs"
 // CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
 
+// RUN: %clang -target x86_64-pc-freebsd12 -fembed-bitcode=all -c %s -### 2>&1 
\
+// RUN: | FileCheck --check-prefix=CHECK-INITARRAY %s
+// CHECK-INITARRAY: "-fuse-init-array"
+
+// RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c 
%s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s
+// CHECK-HEXAGON: "-target-feature"
+// CHECK-HEXAGON: "+reserved-r19"


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


[PATCH] D62509: [Driver] Render target options (e.g. -fuse-init-array) for -fembed-bitcode

2019-05-29 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC362052: [Driver] Render target options (e.g. 
-fuse-init-array) for -fembed-bitcode (authored by MaskRay, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62509?vs=202103&id=202105#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62509

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/fembed-bitcode.c


Index: test/Driver/fembed-bitcode.c
===
--- test/Driver/fembed-bitcode.c
+++ test/Driver/fembed-bitcode.c
@@ -26,3 +26,11 @@
 // CHECK-AARCH64: "darwinpcs"
 // CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
 
+// RUN: %clang -target x86_64-pc-freebsd12 -fembed-bitcode=all -c %s -### 2>&1 
\
+// RUN: | FileCheck --check-prefix=CHECK-INITARRAY %s
+// CHECK-INITARRAY: "-fuse-init-array"
+
+// RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c 
%s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s
+// CHECK-HEXAGON: "-target-feature"
+// CHECK-HEXAGON: "+reserved-r19"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3666,6 +3666,9 @@
 // Disable all llvm IR level optimizations.
 CmdArgs.push_back("-disable-llvm-passes");
 
+// Render target options such as -fuse-init-array on modern ELF platforms.
+TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
+
 // reject options that shouldn't be supported in bitcode
 // also reject kernel/kext
 static const constexpr unsigned kBitcodeOptionBlacklist[] = {


Index: test/Driver/fembed-bitcode.c
===
--- test/Driver/fembed-bitcode.c
+++ test/Driver/fembed-bitcode.c
@@ -26,3 +26,11 @@
 // CHECK-AARCH64: "darwinpcs"
 // CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
 
+// RUN: %clang -target x86_64-pc-freebsd12 -fembed-bitcode=all -c %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-INITARRAY %s
+// CHECK-INITARRAY: "-fuse-init-array"
+
+// RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s
+// CHECK-HEXAGON: "-target-feature"
+// CHECK-HEXAGON: "+reserved-r19"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3666,6 +3666,9 @@
 // Disable all llvm IR level optimizations.
 CmdArgs.push_back("-disable-llvm-passes");
 
+// Render target options such as -fuse-init-array on modern ELF platforms.
+TC.addClangTargetOptions(Args, CmdArgs, JA.getOffloadingDeviceKind());
+
 // reject options that shouldn't be supported in bitcode
 // also reject kernel/kext
 static const constexpr unsigned kBitcodeOptionBlacklist[] = {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62045: Revise the google-objc-global-variable-declaration check to match the style guide.

2019-05-29 Thread Stephane Moore via Phabricator via cfe-commits
stephanemoore accepted this revision.
stephanemoore marked an inline comment as done.
stephanemoore added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang-tools-extra/test/clang-tidy/google-objc-global-variable-declaration.m:46
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: non-const global variable 'Y2Bad' 
must have a name which starts with 'g[A-Z]' 
[google-objc-global-variable-declaration]
+// CHECK-FIXES: extern NSString* gY2Bad;
+

This is interesting as it respects the Google Objective-C Style Guide as it is 
currently written. I think the truth might actually be that there are no 
guidelines for non-const extern variables as they are incredibly rare and 
presumably ubiquitously discouraged. In that respect, I am not sure that the 
fix here represents what would actually be recommended for Google Objective-C. 
With that said, the fix might be reasonable to emit based on the expectation 
that it would be exceedingly rare and it's unclear what better guidance we 
would provide. I think it's fine to continue allowing this existing behavior 
and continue monitoring.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62045



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


r362054 - Add the `objc_class_stub` attribute.

2019-05-29 Thread John McCall via cfe-commits
Author: rjmccall
Date: Wed May 29 21:09:01 2019
New Revision: 362054

URL: http://llvm.org/viewvc/llvm-project?rev=362054&view=rev
Log:
Add the `objc_class_stub` attribute.

Swift requires certain classes to be not just initialized lazily on first
use, but actually allocated lazily using information that is only available
at runtime.  This is incompatible with ObjC class initialization, or at least
not efficiently compatible, because there is no meaningful class symbol
that can be put in a class-ref variable at load time.  This leaves ObjC
code unable to access such classes, which is undesirable.

objc_class_stub says that class references should be resolved by calling
a new ObjC runtime function with a pointer to a new "class stub" structure.
Non-ObjC compilers (like Swift) can simply emit this structure when ObjC
interop is required for a class that cannot be statically allocated,
then apply this attribute to the `@interface` in the generated ObjC header
for the class.

This attribute can be thought of as a generalization of the existing
`objc_runtime_visible` attribute which permits more efficient class
resolution as well as supporting the additon of categories to the class.
Subclassing these classes from ObjC is currently not allowed.

Patch by Slava Pestov!

Added:
cfe/trunk/test/CodeGenObjC/class-stubs.m
cfe/trunk/test/SemaObjC/class-stub-attr-unsupported.m
cfe/trunk/test/SemaObjC/class-stub-attr.m
Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/ObjCRuntime.h
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=362054&r1=362053&r2=362054&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Wed May 29 21:09:01 2019
@@ -284,20 +284,25 @@ class SubjectList subj
   string CustomDiag = customDiag;
 }
 
-class LangOpt {
+class LangOpt {
   string Name = name;
-  bit Negated = negated;
+
+  // A custom predicate, written as an expression evaluated in a context with
+  // "LangOpts" bound.
+  code CustomCode = customCode;
 }
 def MicrosoftExt : LangOpt<"MicrosoftExt">;
 def Borland : LangOpt<"Borland">;
 def CUDA : LangOpt<"CUDA">;
-def COnly : LangOpt<"CPlusPlus", 1>;
+def COnly : LangOpt<"COnly", "!LangOpts.CPlusPlus">;
 def CPlusPlus : LangOpt<"CPlusPlus">;
 def OpenCL : LangOpt<"OpenCL">;
 def RenderScript : LangOpt<"RenderScript">;
 def ObjC : LangOpt<"ObjC">;
 def BlocksSupported : LangOpt<"Blocks">;
 def ObjCAutoRefCount : LangOpt<"ObjCAutoRefCount">;
+def ObjCNonFragileRuntime : LangOpt<"ObjCNonFragileRuntime",
+"LangOpts.ObjCRuntime.allowsClassStubs()">;
 
 // Language option for CMSE extensions
 def Cmse : LangOpt<"Cmse">;
@@ -1806,6 +1811,13 @@ def ObjCRuntimeVisible : Attr {
   let Documentation = [ObjCRuntimeVisibleDocs];
 }
 
+def ObjCClassStub : Attr {
+  let Spellings = [Clang<"objc_class_stub">];
+  let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
+  let Documentation = [ObjCClassStubDocs];
+  let LangOpts = [ObjCNonFragileRuntime];
+}
+
 def ObjCBoxable : Attr {
   let Spellings = [Clang<"objc_boxable">];
   let Subjects = SubjectList<[Record], ErrorDiag>;

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=362054&r1=362053&r2=362054&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Wed May 29 21:09:01 2019
@@ -1085,6 +1085,25 @@ them.
 }];
 }
 
+def ObjCClassStubDocs : Documentation {
+let Category = DocCatType;
+let Content = [{
+This attribute specifies that the Objective-C class to which it applies is
+instantiated at runtime.
+
+Unlike ``__attribute__((objc_runtime_visible))``, a class having this attribute
+still has a "class stub" that is visible to the linker. This allows categories
+to be defined. Static message sends with the class as a receiver use a special
+access pattern to ensure the class is lazily instantiated from the class stub.
+
+Classes annotated with this attribute cannot be subclassed and cannot have
+implementations defined for them. This attribute is intended for use in
+Swift-generated headers for classes defined in Swift.
+
+Adding or removing this attribute to a class is an ABI-breaking change.
+}];
+}
+
 def ObjCBoxableDocs : Documentation {
 let Category = DocCatDecl;
 let 

[PATCH] D62584: [OpenCL][PR42033] Deducing addr space of pointer/reference with template parameter types

2019-05-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I think the right approach here is probably to make sure you're applying 
deduction during instantiation as well.


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

https://reviews.llvm.org/D62584



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


[PATCH] D62299: [PR41567][Sema] Fixed cast kind in addr space conversions

2019-05-29 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Seems reasonable.


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

https://reviews.llvm.org/D62299



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


[libunwind] r362055 - [runtimes] Check if pragma comment(lib, ...) is supported first

2019-05-29 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed May 29 21:40:21 2019
New Revision: 362055

URL: http://llvm.org/viewvc/llvm-project?rev=362055&view=rev
Log:
[runtimes] Check if pragma comment(lib, ...) is supported first

This fixes the issue introduced by r362048 where we always use
pragma comment(lib, ...) for dependent libraries when the compiler
is Clang, but older Clang versions don't support this pragma so
we need to check first if it's supported before using it.

Modified:
libunwind/trunk/CMakeLists.txt
libunwind/trunk/cmake/config-ix.cmake
libunwind/trunk/src/AddressSpace.hpp
libunwind/trunk/src/RWMutex.hpp

Modified: libunwind/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/CMakeLists.txt?rev=362055&r1=362054&r2=362055&view=diff
==
--- libunwind/trunk/CMakeLists.txt (original)
+++ libunwind/trunk/CMakeLists.txt Wed May 29 21:40:21 2019
@@ -362,6 +362,10 @@ if (WIN32 AND LIBUNWIND_ENABLE_STATIC AN
   add_definitions(-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS)
 endif()
 
+if (LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+  add_definitions(-D_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+endif()
+
 
#===
 # Setup Source Code
 
#===

Modified: libunwind/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/cmake/config-ix.cmake?rev=362055&r1=362054&r2=362055&view=diff
==
--- libunwind/trunk/cmake/config-ix.cmake (original)
+++ libunwind/trunk/cmake/config-ix.cmake Wed May 29 21:40:21 2019
@@ -1,7 +1,7 @@
-
 include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
 include(CheckLibraryExists)
+include(CheckCSourceCompiles)
 
 check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)
 
@@ -55,6 +55,14 @@ if (LIBUNWIND_HAS_NODEFAULTLIBS_FLAG)
   endif ()
 endif ()
 
+# Check compiler pragmas
+if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  check_c_source_compiles("
+#pragma comment(lib, \"c\")
+int main() { return 0; }
+" LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+endif()
+
 # Check compiler flags
 check_c_compiler_flag(-funwind-tables LIBUNWIND_HAS_FUNWIND_TABLES)
 check_cxx_compiler_flag(-fno-exceptions   LIBUNWIND_HAS_NO_EXCEPTIONS_FLAG)
@@ -96,4 +104,3 @@ endif()
 
 check_library_exists(dl dladdr "" LIBUNWIND_HAS_DL_LIB)
 check_library_exists(pthread pthread_once "" LIBUNWIND_HAS_PTHREAD_LIB)
-

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=362055&r1=362054&r2=362055&view=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Wed May 29 21:40:21 2019
@@ -27,7 +27,7 @@
 
 #if _LIBUNWIND_USE_DLADDR
 #include 
-#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) &&  defined(__ELF__) && 
defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
 #pragma comment(lib, "dl")
 #endif
 #endif

Modified: libunwind/trunk/src/RWMutex.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/RWMutex.hpp?rev=362055&r1=362054&r2=362055&view=diff
==
--- libunwind/trunk/src/RWMutex.hpp (original)
+++ libunwind/trunk/src/RWMutex.hpp Wed May 29 21:40:21 2019
@@ -17,7 +17,7 @@
 #include 
 #elif !defined(_LIBUNWIND_HAS_NO_THREADS)
 #include 
-#if defined(__unix__) &&  defined(__ELF__) && defined(__clang__)
+#if defined(__unix__) &&  defined(__ELF__) && 
defined(_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
 #pragma comment(lib, "pthread")
 #endif
 #endif


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


[PATCH] D58321: Support for relative vtables

2019-05-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.def:329
+"Whether to use clang's relative C++ ABI "
+"for classes with vtables")
+

leonardchan wrote:
> rjmccall wrote:
> > Yeah, see, this plays into the question above.  I would not want to provide 
> > this as a language option for general use.  The attribute seems good enough 
> > for testing, and if you want a -cc1 option to apply the attribute by 
> > default for experimentation during Fuchsia bring-up that's fair, but I 
> > don't want something that suggests to users that it's okay to pass this 
> > attribute and change the system default.
> Ok. So is this the reason for the white list approach mentioned in D17893? As 
> an alternative, would you also be ok with creating a `FuchsiaCXXABI` that 
> subclasses `ItaniumCXXABI`, similar to the ARM and WebAssembly ones? This way 
> it doesn't change the system default.
That design for relative v-tables was intended (at least as it was described to 
me) as an optimization for certain classes in a project that still needed to 
interoperate with system and other non-project C++ code.  It was initially 
attempting to apply the optimization eagerly to all classes that didn't match a 
blacklist of classes (and namespaces of classes) that needed to follow the 
system ABI, which I objected to, which is why I asked for it to be redesigned 
around applying the optimization only to whitelisted classes/namespaces.  None 
of that applies if you're changing the system ABI rule unless you decide you 
want to allow classes to opt into standard Itanium v-tables.

If introducing a `FuchsiaCXXABI` class makes the code easier, go for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321



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


[PATCH] D62643: [CodeGen][ObjC] Convert '[self alloc]' in a class method to 'objc_alloc(self)'

2019-05-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rjmccall, pete, erik.pilkington.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.

In a class method, 'self' points to the class object, so it should be safe to 
pass it to `objc_alloc`. Also, convert '[[self alloc] init]' in a class method 
to 'objc_alloc_init(self)'.

rdar://problem/50855121


Repository:
  rC Clang

https://reviews.llvm.org/D62643

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjC/convert-messages-to-runtime-calls.m
  test/CodeGenObjC/objc-alloc-init.m

Index: test/CodeGenObjC/objc-alloc-init.m
===
--- test/CodeGenObjC/objc-alloc-init.m
+++ test/CodeGenObjC/objc-alloc-init.m
@@ -23,14 +23,20 @@
 
 @interface Y : X
 +(void)meth;
+-(void)instanceMeth;
 @end
 
 @implementation Y
 +(void)meth {
   [[self alloc] init];
+  // OPTIMIZED: call i8* @objc_alloc_init(
+  // NOT_OPTIMIZED: call i8* @objc_alloc(
+}
+-(void)instanceMeth {
   // EITHER-NOT: call i8* @objc_alloc
   // EITHER: call {{.*}} @objc_msgSend
   // EITHER: call {{.*}} @objc_msgSend
+  [[self alloc] init];
 }
 @end
 
Index: test/CodeGenObjC/convert-messages-to-runtime-calls.m
===
--- test/CodeGenObjC/convert-messages-to-runtime-calls.m
+++ test/CodeGenObjC/convert-messages-to-runtime-calls.m
@@ -150,6 +150,34 @@
   return [c retain];
 }
 
+@interface TestSelf
++ (instancetype)alloc;
++ (instancetype)allocWithZone:(void*)zone;
++ (id)classMeth;
+- (id)instanceMeth;
+@end
+
+@implementation TestSelf
+// CHECK-LABEL: define internal i8* @"\01+[TestSelf classMeth]"(
++ (id)classMeth {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_allocWithZone\(}}
+  // CALLS: {{call.*@objc_alloc\(}}
+  [self allocWithZone:nil];
+  return [self alloc];
+}
+// CHECK-LABEL: define internal i8* @"\01-[TestSelf instanceMeth]"(
+- (id)instanceMeth {
+  // MSGS: {{call.*@objc_msgSend}}
+  // MSGS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  // CALLS: {{call.*@objc_msgSend}}
+  [self allocWithZone:nil];
+  return [self alloc];
+}
+@end
+
 @interface NSString : NSObject
 + (void)retain_self;
 - (void)retain_super;
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -372,7 +372,8 @@
   llvm::Value *Receiver,
   const CallArgList& Args, Selector Sel,
   const ObjCMethodDecl *method,
-  bool isClassMessage) {
+  bool isClassMessage,
+  bool isSelfReceiverInClassMethod) {
   auto &CGM = CGF.CGM;
   if (!CGM.getCodeGenOpts().ObjCConvertMessagesToRuntimeCalls)
 return None;
@@ -380,13 +381,15 @@
   auto &Runtime = CGM.getLangOpts().ObjCRuntime;
   switch (Sel.getMethodFamily()) {
   case OMF_alloc:
-if (isClassMessage &&
+if ((isClassMessage || isSelfReceiverInClassMethod) &&
 Runtime.shouldUseRuntimeFunctionsForAlloc() &&
 ResultType->isObjCObjectPointerType()) {
-// [Foo alloc] -> objc_alloc(Foo)
+// [Foo alloc] -> objc_alloc(Foo) or
+// [self alloc] -> objc_alloc(self)
 if (Sel.isUnarySelector() && Sel.getNameForSlot(0) == "alloc")
   return CGF.EmitObjCAlloc(Receiver, CGF.ConvertType(ResultType));
-// [Foo allocWithZone:nil] -> objc_allocWithZone(Foo)
+// [Foo allocWithZone:nil] -> objc_allocWithZone(Foo) or
+// [self allocWithZone:nil] -> objc_allocWithZone(self)
 if (Sel.isKeywordSelector() && Sel.getNumArgs() == 1 &&
 Args.size() == 1 && Args.front().getType()->isPointerType() &&
 Sel.getNameForSlot(0) == "allocWithZone") {
@@ -444,22 +447,38 @@
   Sel.getNameForSlot(0) != "init")
 return None;
 
-  // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]'.
+  // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]' or
+  // we are in an ObjC class method and 'receiver' is '[self alloc]'.
   auto *SubOME =
-  dyn_cast(OME->getInstanceReceiver()->IgnoreParens());
+  dyn_cast(OME->getInstanceReceiver()->IgnoreParenCasts());
   if (!SubOME)
 return None;
   Selector SubSel = SubOME->getSelector();
-  if (SubOME->getReceiverKind() != ObjCMessageExpr::Class ||
-  !SubOME->getType()->isObjCObjectPointerType() ||
+
+  // Check if we are in an ObjC class method and the receiver expression is
+  // 'self'.
+  const Expr *SelfInClassMethod = nullptr;
+  if (const auto *CurMD = dyn_cast(CGF.CurFuncDecl))
+if (CurMD->isClassMethod())
+  if ((SelfInClassMethod = SubOME->getInstanceReceiver()))
+if (!SelfInClassMethod->isObjCSelfExpr())
+  SelfInClassMethod = nullptr;
+
+  if ((SubOME->getReceiv

[PATCH] D62643: [CodeGen][ObjC] Convert '[self alloc]' in a class method to 'objc_alloc(self)'

2019-05-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGObjC.cpp:376
+  bool isClassMessage,
+  bool isSelfReceiverInClassMethod) {
   auto &CGM = CGF.CGM;

I think it's fine to just call this a class message, unless I'm missing a 
reason to distinguish them in this function.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62643



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


[PATCH] D62645: [Sema] Resolve placeholder types before type deduction to silence spurious `-Warc-repeated-use-of-weak` warnings

2019-05-29 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.
ahatanak added reviewers: rsmith, rjmccall.
ahatanak added a project: clang.
Herald added subscribers: dexonsmith, jkorous.

The spurious `-Warc-repeated-use-of-weak` warnings are issued when an 
initializer expression uses a weak ObjC pointer.

My first attempt to silence the warnings (r350917) caused clang to reject code 
that is legal in C++17. The patch is based on the feedback I received from 
Richard when the patch was reverted.

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190422/268945.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190422/268943.html


Repository:
  rC Clang

https://reviews.llvm.org/D62645

Files:
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  test/SemaObjC/arc-repeated-weak.mm


Index: test/SemaObjC/arc-repeated-weak.mm
===
--- test/SemaObjC/arc-repeated-weak.mm
+++ test/SemaObjC/arc-repeated-weak.mm
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks 
-Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks 
-Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks 
-Wno-objc-root-class -std=c++14 -Warc-repeated-use-of-weak -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks 
-Wno-objc-root-class -std=c++14 -Warc-repeated-use-of-weak -verify %s
 
 @interface Test {
 @public
@@ -467,6 +467,18 @@
   __typeof__(NSBundle2.foo2.weakProp) t5;
 }
 
+void testAuto() {
+  auto __weak wp = NSBundle2.foo2.weakProp;
+}
+
+void testLambdaCaptureInit() {
+  [capture(NSBundle2.foo2.weakProp)] {} ();
+}
+
+void testAutoNew() {
+  auto p = new auto(NSBundle2.foo2.weakProp);
+}
+
 // This used to crash in the constructor of WeakObjectProfileTy when a
 // DeclRefExpr was passed that didn't reference a VarDecl.
 
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -1826,6 +1826,15 @@
 NumInits = List->getNumExprs();
   }
 
+  for (unsigned I = 0, E = NumInits; I != E; ++I)
+if (auto *PlaceholderType = Inits[I]->getType()->getAsPlaceholderType())
+  if (PlaceholderType->getKind() == BuiltinType::PseudoObject) {
+ExprResult Result = CheckPlaceholderExpr(Inits[I]);
+if (!Result.isUsable())
+  return ExprError();
+Inits[I] = Result.get();
+  }
+
   // C++11 [expr.new]p15:
   //   A new-expression that creates an object of type T initializes that
   //   object as follows:
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -6623,6 +6623,15 @@
 ExprResult Sema::ActOnParenListExpr(SourceLocation L,
 SourceLocation R,
 MultiExprArg Val) {
+  for (size_t I = 0, E = Val.size(); I != E; ++I)
+if (auto *PlaceholderType = Val[I]->getType()->getAsPlaceholderType())
+  if (PlaceholderType->getKind() == BuiltinType::PseudoObject) {
+ExprResult Result = CheckPlaceholderExpr(Val[I]);
+if (!Result.isUsable())
+  return ExprError();
+Val[I] = Result.get();
+  }
+
   return ParenListExpr::Create(Context, L, Val, R);
 }
 
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -11096,6 +11096,15 @@
 }
 Init = Res.get();
 
+if (!Init->getType().isNull())
+  if (auto *placeholderType = Init->getType()->getAsPlaceholderType())
+if (placeholderType->getKind() == BuiltinType::PseudoObject) {
+  Res = CheckPlaceholderExpr(Init).get();
+  if (!Res.isUsable())
+return;
+  Init = Res.get();
+}
+
 if (DeduceVariableDeclarationType(VDecl, DirectInit, Init))
   return;
   }


Index: test/SemaObjC/arc-repeated-weak.mm
===
--- test/SemaObjC/arc-repeated-weak.mm
+++ test/SemaObjC/arc-repeated-weak.mm
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wno-objc-root-class -std=c++14 -Warc-repeated-use-of-weak -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks -Wno-objc-root-class -std=c++14 -Warc-repeated-use-of-weak -verify %s
 
 @interface Test {
 @public

Re: r350917 - [Sema] If CheckPlaceholderExpr rewrites the initializer of an auto

2019-05-29 Thread Akira Hatanaka via cfe-commits
Hi Richard,

Thank you for the feedback. Please review my new patch: 
https://reviews.llvm.org/D62645 .

> On Apr 23, 2019, at 7:21 PM, Richard Smith  wrote:
> 
> Hi Akira,
> 
> I've reverted this in r359066. This subtly breaks the semantics of C++
> initializers by strripping off an outer level of parentheses / braces
> in some cases. Testcase:
> 
>  struct A {
>A();
>A(const A&) = delete;
>  };
>  auto x = [a{A()}] {};
> 
> (This should be accepted in C++17 mode onwards, but this patch rejects
> it by losing the braces around the A() expression.)
> 
> Moreover, I think this is fundamentally the wrong approach:
> DeduceAutoType should not ever be changing the initializer expression
> (and it certainly shouldn't expect those changes to stick around).
> Instead, we should check for a placeholder type before attempting
> deduction, just like we correct typos in the initializer before
> attempting deduction.
> 
> On Thu, 10 Jan 2019 at 21:01, Akira Hatanaka via cfe-commits
>  wrote:
>> 
>> Author: ahatanak
>> Date: Thu Jan 10 20:57:34 2019
>> New Revision: 350917
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=350917&view=rev
>> Log:
>> [Sema] If CheckPlaceholderExpr rewrites the initializer of an auto
>> variable during auto type deduction, use the rewritten initializer when
>> performing initialization of the variable.
>> 
>> This silences spurious -Warc-repeated-use-of-weak warnings that are
>> issued when the initializer uses a weak ObjC pointer.
>> 
>> Differential Revision: https://reviews.llvm.org/D55662
>> 
>> Modified:
>>cfe/trunk/include/clang/Sema/Sema.h
>>cfe/trunk/lib/Sema/SemaDecl.cpp
>>cfe/trunk/lib/Sema/SemaExprCXX.cpp
>>cfe/trunk/lib/Sema/SemaLambda.cpp
>>cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
>> 
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=350917&r1=350916&r2=350917&view=diff
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Jan 10 20:57:34 2019
>> @@ -1960,7 +1960,7 @@ public:
>>   bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous);
>>   void CheckVariableDeclarationType(VarDecl *NewVD);
>>   bool DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit,
>> - Expr *Init);
>> + Expr *&Init);
>>   void CheckCompleteVariableDeclaration(VarDecl *VD);
>>   void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD);
>>   void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D);
>> @@ -7095,7 +7095,7 @@ public:
>>   QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name,
>> QualType Type, TypeSourceInfo *TSI,
>> SourceRange Range, bool DirectInit,
>> -Expr *Init);
>> +Expr *&Init);
>> 
>>   TypeLoc getReturnTypeLoc(FunctionDecl *FD) const;
>> 
>> 
>> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=350917&r1=350916&r2=350917&view=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jan 10 20:57:34 2019
>> @@ -10812,7 +10812,7 @@ QualType Sema::deduceVarTypeFromInitiali
>> DeclarationName Name, QualType 
>> Type,
>> TypeSourceInfo *TSI,
>> SourceRange Range, bool 
>> DirectInit,
>> -Expr *Init) {
>> +Expr *&Init) {
>>   bool IsInitCapture = !VDecl;
>>   assert((!VDecl || !VDecl->isInitCapture()) &&
>>  "init captures are expected to be deduced prior to initialization");
>> @@ -10928,7 +10928,8 @@ QualType Sema::deduceVarTypeFromInitiali
>>   << (DeduceInit->getType().isNull() ? TSI->getType()
>>  : DeduceInit->getType())
>>   << DeduceInit->getSourceRange();
>> -  }
>> +  } else
>> +Init = DeduceInit;
>> 
>>   // Warn if we deduced 'id'. 'auto' usually implies type-safety, but using
>>   // 'id' instead of a specific object type prevents most of our usual
>> @@ -10945,7 +10946,7 @@ QualType Sema::deduceVarTypeFromInitiali
>> }
>> 
>> bool Sema::DeduceVariableDeclarationType(VarDecl *VDecl, bool DirectInit,
>> - Expr *Init) {
>> + Expr *&Init) {
>>   QualType DeducedType = deduceVarTypeFromInitializer(
>>   VDecl, VDecl->getDeclName(), VDecl->getType(), 
>> VD

[PATCH] D62645: [Sema] Resolve placeholder types before type deduction to silence spurious `-Warc-repeated-use-of-weak` warnings

2019-05-29 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:11101
+  if (auto *placeholderType = Init->getType()->getAsPlaceholderType())
+if (placeholderType->getKind() == BuiltinType::PseudoObject) {
+  Res = CheckPlaceholderExpr(Init).get();

`if (Init->hasPlaceholderType(BuiltinType::PseudoObject))`

Although maybe this should just be `isNonOverloadPlaceholderType()`, since it's 
the syntactic-only placeholders that we're trying to cover.  (Feel free to add 
`Expr::hasNonOverloadPlaceholderType()` for convenience.)


Repository:
  rC Clang

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

https://reviews.llvm.org/D62645



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


[libunwind] r362057 - [runtimes] Use -Wunknown-pragmas for the pragma check

2019-05-29 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed May 29 22:38:06 2019
New Revision: 362057

URL: http://llvm.org/viewvc/llvm-project?rev=362057&view=rev
Log:
[runtimes] Use -Wunknown-pragmas for the pragma check

This is a follow up to r362055, we need -Wunknown-pragmas otherwise
the check is going to succeed it the pragma isn't supported.

Modified:
libunwind/trunk/cmake/config-ix.cmake

Modified: libunwind/trunk/cmake/config-ix.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/cmake/config-ix.cmake?rev=362057&r1=362056&r2=362057&view=diff
==
--- libunwind/trunk/cmake/config-ix.cmake (original)
+++ libunwind/trunk/cmake/config-ix.cmake Wed May 29 22:38:06 2019
@@ -1,3 +1,4 @@
+include(CMakePushCheckState)
 include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
 include(CheckLibraryExists)
@@ -57,10 +58,13 @@ endif ()
 
 # Check compiler pragmas
 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  cmake_push_check_state()
+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror=unknown-pragmas")
   check_c_source_compiles("
 #pragma comment(lib, \"c\")
 int main() { return 0; }
 " LIBUNWIND_HAS_COMMENT_LIB_PRAGMA)
+  cmake_pop_check_state()
 endif()
 
 # Check compiler flags


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


r362059 - Mark CodeGen/asm-goto.c as x86 specific after r362045

2019-05-29 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed May 29 23:48:13 2019
New Revision: 362059

URL: http://llvm.org/viewvc/llvm-project?rev=362059&view=rev
Log:
Mark CodeGen/asm-goto.c as x86 specific after r362045

Modified:
cfe/trunk/test/CodeGen/asm-goto.c

Modified: cfe/trunk/test/CodeGen/asm-goto.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asm-goto.c?rev=362059&r1=362058&r2=362059&view=diff
==
--- cfe/trunk/test/CodeGen/asm-goto.c (original)
+++ cfe/trunk/test/CodeGen/asm-goto.c Wed May 29 23:48:13 2019
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -O0 -emit-llvm  %s -o - | FileCheck %s
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64 -O0 -emit-llvm %s -o - | FileCheck %s
 
 int foo(int cond)
 {


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


[PATCH] D62005: [libunwind] [test] Fix inferring source paths

2019-05-29 Thread Michał Górny via Phabricator via cfe-commits
mgorny marked 2 inline comments as done.
mgorny added inline comments.



Comment at: libunwind/test/libunwind/test/config.py:27
+self.libcxx_src_root = (self.get_lit_conf('libcxx_src_root')
+or os.path.join(self.libunwind_src_root, '../libcxx'))
 

phosek wrote:
> Can you use `os.path.join(self.libunwind_src_root, '..', 'libcxx')` to make 
> it compatible with systems that don't use `/` as path separators?
Good catch. Will do.


Repository:
  rUNW libunwind

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

https://reviews.llvm.org/D62005



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


[libunwind] r361931 - [libunwind] [test] Fix inferring source paths

2019-05-29 Thread Michal Gorny via cfe-commits
Author: mgorny
Date: Wed May 29 00:20:30 2019
New Revision: 361931

URL: http://llvm.org/viewvc/llvm-project?rev=361931&view=rev
Log:
[libunwind] [test] Fix inferring source paths

Fix two issues that caused libcxx source path not to be inferred
correctly when not specified explicitly:

1. get_lit_conf() uses default value only if the lit variable is set
   to None.  Due to the mehod of substituting lit.site.cfg, they were
   "" rather than None when unset, effectively causing the default never
   to apply.  Instead, use 'or' construct to use the default whenever
   get_lit_conf() returns a false value.

2. If os.path.join() is given a component starting with '/', it takes
   it to be an absolute path and ignores everything preceding it.
   Remove the slash to correctly append subdirectory.

With these two fixes, libunwind tests start working on NetBSD buildbot
again.

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

Modified:
libunwind/trunk/test/libunwind/test/config.py

Modified: libunwind/trunk/test/libunwind/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/test/libunwind/test/config.py?rev=361931&r1=361930&r2=361931&view=diff
==
--- libunwind/trunk/test/libunwind/test/config.py (original)
+++ libunwind/trunk/test/libunwind/test/config.py Wed May 29 00:20:30 2019
@@ -21,12 +21,10 @@ class Configuration(LibcxxConfiguration)
 self.libcxx_src_root = None
 
 def configure_src_root(self):
-self.libunwind_src_root = self.get_lit_conf(
-'libunwind_src_root',
-os.path.dirname(self.config.test_source_root))
-self.libcxx_src_root = self.get_lit_conf(
-'libcxx_src_root',
-os.path.join(self.libunwind_src_root, '/../libcxx'))
+self.libunwind_src_root = (self.get_lit_conf('libunwind_src_root')
+or os.path.dirname(self.config.test_source_root))
+self.libcxx_src_root = (self.get_lit_conf('libcxx_src_root')
+or os.path.join(self.libunwind_src_root, '..', 'libcxx'))
 
 def configure_obj_root(self):
 self.libunwind_obj_root = self.get_lit_conf('libunwind_obj_root')


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


[PATCH] D62571: Implement codegen for MSVC unions with reference members

2019-05-29 Thread Dominic Ferreira via Phabricator via cfe-commits
domdom created this revision.
domdom added a reviewer: asl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently, clang accepts a union with a reference member when given the 
-fms-extensions flag. This change fixes the codegen for this case.


Repository:
  rC Clang

https://reviews.llvm.org/D62571

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/test/CodeGenCXX/ms-union-member-ref.cpp


Index: clang/test/CodeGenCXX/ms-union-member-ref.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ms-union-member-ref.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fms-extensions %s -emit-llvm -o- | FileCheck %s
+
+union A {
+int *&ref;
+int **ptr;
+};
+
+int *f1(A *a) {
+return a->ref;
+}
+// CHECK-LABEL: define {{.*}}i32* @_Z2f1P1A(%union.A* %a)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   ret i32* [[IP]]
+
+void f2(A *a) {
+*a->ref = 1;
+}
+// CHECK-LABEL: define {{.*}}void @_Z2f2P1A(%union.A* %a)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   store i32 1, i32* [[IP]]
+
+bool f3(A *a, int *b) {
+  return a->ref != b;
+}
+// CHECK-LABEL: define {{.*}}i1 @_Z2f3P1APi(%union.A* %a, i32* %b)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   [[IP2:%[^[:space:]]+]]  = load i32*, i32** %b.addr
+// CHECK:   icmp ne i32* [[IP]], [[IP2]]
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -3929,29 +3929,32 @@
   unsigned RecordCVR = base.getVRQualifiers();
   if (rec->isUnion()) {
 // For unions, there is no pointer adjustment.
-assert(!FieldType->isReferenceType() && "union has reference member");
 if (CGM.getCodeGenOpts().StrictVTablePointers &&
 hasAnyVptr(FieldType, getContext()))
   // Because unions can easily skip invariant.barriers, we need to add
   // a barrier every time CXXRecord field with vptr is referenced.
   addr = Address(Builder.CreateLaunderInvariantGroup(addr.getPointer()),
  addr.getAlignment());
+
+if (FieldType->isReferenceType())
+  addr = Builder.CreateElementBitCast(
+  addr, CGM.getTypes().ConvertTypeForMem(FieldType), field->getName());
   } else {
 // For structs, we GEP to the field that the record layout suggests.
 addr = emitAddrOfFieldStorage(*this, addr, field);
+  }
 
-// If this is a reference field, load the reference right now.
-if (FieldType->isReferenceType()) {
-  LValue RefLVal = MakeAddrLValue(addr, FieldType, FieldBaseInfo,
-  FieldTBAAInfo);
-  if (RecordCVR & Qualifiers::Volatile)
-RefLVal.getQuals().addVolatile();
-  addr = EmitLoadOfReference(RefLVal, &FieldBaseInfo, &FieldTBAAInfo);
-
-  // Qualifiers on the struct don't apply to the referencee.
-  RecordCVR = 0;
-  FieldType = FieldType->getPointeeType();
-}
+  // If this is a reference field, load the reference right now.
+  if (FieldType->isReferenceType()) {
+LValue RefLVal = MakeAddrLValue(addr, FieldType, FieldBaseInfo,
+FieldTBAAInfo);
+if (RecordCVR & Qualifiers::Volatile)
+  RefLVal.getQuals().addVolatile();
+addr = EmitLoadOfReference(RefLVal, &FieldBaseInfo, &FieldTBAAInfo);
+
+// Qualifiers on the struct don't apply to the referencee.
+RecordCVR = 0;
+FieldType = FieldType->getPointeeType();
   }
 
   // Make sure that the address is pointing to the right type.  This is 
critical


Index: clang/test/CodeGenCXX/ms-union-member-ref.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ms-union-member-ref.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fms-extensions %s -emit-llvm -o- | FileCheck %s
+
+union A {
+int *&ref;
+int **ptr;
+};
+
+int *f1(A *a) {
+return a->ref;
+}
+// CHECK-LABEL: define {{.*}}i32* @_Z2f1P1A(%union.A* %a)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
+// CHECK:   [[IP:%[^[:space:]]+]]  = load i32*, i32** [[IPP]]
+// CHECK:   ret i32* [[IP]]
+
+void f2(A *a) {
+*a->ref = 1;
+}
+// CHECK-LABEL: define {{.*}}void @_Z2f2P1A(%union.A* %a)
+// CHECK:   [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
+// CHECK:   [[IPP:%[^[:space:]]+]] = load i32**, i32*

[PATCH] D62005: [libunwind] [test] Fix inferring source paths

2019-05-29 Thread Michał Górny via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
mgorny marked an inline comment as done.
Closed by commit rL361931: [libunwind] [test] Fix inferring source paths 
(authored by mgorny, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62005?vs=199799&id=201834#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62005

Files:
  libunwind/trunk/test/libunwind/test/config.py


Index: libunwind/trunk/test/libunwind/test/config.py
===
--- libunwind/trunk/test/libunwind/test/config.py
+++ libunwind/trunk/test/libunwind/test/config.py
@@ -21,12 +21,10 @@
 self.libcxx_src_root = None
 
 def configure_src_root(self):
-self.libunwind_src_root = self.get_lit_conf(
-'libunwind_src_root',
-os.path.dirname(self.config.test_source_root))
-self.libcxx_src_root = self.get_lit_conf(
-'libcxx_src_root',
-os.path.join(self.libunwind_src_root, '/../libcxx'))
+self.libunwind_src_root = (self.get_lit_conf('libunwind_src_root')
+or os.path.dirname(self.config.test_source_root))
+self.libcxx_src_root = (self.get_lit_conf('libcxx_src_root')
+or os.path.join(self.libunwind_src_root, '..', 'libcxx'))
 
 def configure_obj_root(self):
 self.libunwind_obj_root = self.get_lit_conf('libunwind_obj_root')


Index: libunwind/trunk/test/libunwind/test/config.py
===
--- libunwind/trunk/test/libunwind/test/config.py
+++ libunwind/trunk/test/libunwind/test/config.py
@@ -21,12 +21,10 @@
 self.libcxx_src_root = None
 
 def configure_src_root(self):
-self.libunwind_src_root = self.get_lit_conf(
-'libunwind_src_root',
-os.path.dirname(self.config.test_source_root))
-self.libcxx_src_root = self.get_lit_conf(
-'libcxx_src_root',
-os.path.join(self.libunwind_src_root, '/../libcxx'))
+self.libunwind_src_root = (self.get_lit_conf('libunwind_src_root')
+or os.path.dirname(self.config.test_source_root))
+self.libcxx_src_root = (self.get_lit_conf('libcxx_src_root')
+or os.path.join(self.libunwind_src_root, '..', 'libcxx'))
 
 def configure_obj_root(self):
 self.libunwind_obj_root = self.get_lit_conf('libunwind_obj_root')
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60499: [ASTImporter] Various source location and range import fixes.

2019-05-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

There is a test for the SourceLocation import in 
https://reviews.llvm.org/D60463 (after this patch is applied that test should 
not fail and the "return" statement is to be removed).


Repository:
  rC Clang

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

https://reviews.llvm.org/D60499



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


[PATCH] D61601: [clangd] Represent Hover result using FormattedString

2019-05-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Ping, D61497  has landed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61601



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


[PATCH] D62573: [Index] Correctly set symbol kind of IndirectFieldDecl

2019-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: kadircet.
Herald added subscribers: arphaman, jkorous.
Herald added a project: clang.

The kind has been 'unknown' before, now it is 'field'.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62573

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Index/IndexSymbol.cpp
  clang/test/Index/index-anonymous-union-fields.cpp


Index: clang/test/Index/index-anonymous-union-fields.cpp
===
--- /dev/null
+++ clang/test/Index/index-anonymous-union-fields.cpp
@@ -0,0 +1,10 @@
+struct X {
+  union {
+void *a;
+  };
+};
+
+// RUN: c-index-test -index-file %s > %t
+// RUN: FileCheck %s -input-file=%t
+
+// CHECK: [indexDeclaration]: kind: field | name: a | {{.*}} | loc: 3:11
Index: clang/lib/Index/IndexSymbol.cpp
===
--- clang/lib/Index/IndexSymbol.cpp
+++ clang/lib/Index/IndexSymbol.cpp
@@ -168,6 +168,7 @@
   Info.Kind = SymbolKind::Function;
   break;
 case Decl::Field:
+case Decl::IndirectField:
   Info.Kind = SymbolKind::Field;
   if (const CXXRecordDecl *
 CXXRec = dyn_cast(D->getDeclContext())) {
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -449,6 +449,20 @@
   Results = completions("nam^");
   EXPECT_THAT(Results.Completions,
   Has("namespace", CompletionItemKind::Snippet));
+
+  // Members of anonymous unions are of kind 'field'.
+  Results = completions(
+  R"cpp(
+struct X{
+union {
+  void *a;
+};
+};
+auto u = X().^
+  )cpp");
+  EXPECT_THAT(
+  Results.Completions,
+  UnorderedElementsAre(AllOf(Named("a"), 
Kind(CompletionItemKind::Field;
 }
 
 TEST(CompletionTest, NoDuplicates) {


Index: clang/test/Index/index-anonymous-union-fields.cpp
===
--- /dev/null
+++ clang/test/Index/index-anonymous-union-fields.cpp
@@ -0,0 +1,10 @@
+struct X {
+  union {
+void *a;
+  };
+};
+
+// RUN: c-index-test -index-file %s > %t
+// RUN: FileCheck %s -input-file=%t
+
+// CHECK: [indexDeclaration]: kind: field | name: a | {{.*}} | loc: 3:11
Index: clang/lib/Index/IndexSymbol.cpp
===
--- clang/lib/Index/IndexSymbol.cpp
+++ clang/lib/Index/IndexSymbol.cpp
@@ -168,6 +168,7 @@
   Info.Kind = SymbolKind::Function;
   break;
 case Decl::Field:
+case Decl::IndirectField:
   Info.Kind = SymbolKind::Field;
   if (const CXXRecordDecl *
 CXXRec = dyn_cast(D->getDeclContext())) {
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -449,6 +449,20 @@
   Results = completions("nam^");
   EXPECT_THAT(Results.Completions,
   Has("namespace", CompletionItemKind::Snippet));
+
+  // Members of anonymous unions are of kind 'field'.
+  Results = completions(
+  R"cpp(
+struct X{
+union {
+  void *a;
+};
+};
+auto u = X().^
+  )cpp");
+  EXPECT_THAT(
+  Results.Completions,
+  UnorderedElementsAre(AllOf(Named("a"), Kind(CompletionItemKind::Field;
 }
 
 TEST(CompletionTest, NoDuplicates) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62573: [Index] Correctly set symbol kind of IndirectFieldDecl

2019-05-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM thanks!

Do you think it would be beneficial to add some logging for the default case of 
that switch statement ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62573



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


[PATCH] D60748: Fix i386 struct and union parameter alignment

2019-05-29 Thread Pengfei Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361934: [X86] Fix i386 struct and union parameter alignment 
(authored by pengfei, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D60748

Files:
  lib/CodeGen/TargetInfo.cpp
  test/CodeGen/x86_32-align-linux.c
  test/CodeGen/x86_32-arguments-linux.c

Index: lib/CodeGen/TargetInfo.cpp
===
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -1010,6 +1010,7 @@
   bool IsWin32StructABI;
   bool IsSoftFloatABI;
   bool IsMCUABI;
+  bool IsLinuxABI;
   unsigned DefaultNumRegisterParameters;
 
   static bool isRegisterSize(unsigned Size) {
@@ -1076,6 +1077,7 @@
   IsWin32StructABI(Win32StructABI),
   IsSoftFloatABI(SoftFloatABI),
   IsMCUABI(CGT.getTarget().getTriple().isOSIAMCU()),
+  IsLinuxABI(CGT.getTarget().getTriple().isOSLinux()),
   DefaultNumRegisterParameters(NumRegisterParameters) {}
 
   bool shouldPassIndirectlyForSwift(ArrayRef scalars,
@@ -1492,8 +1494,15 @@
   if (Align <= MinABIStackAlignInBytes)
 return 0; // Use default alignment.
 
-  // On non-Darwin, the stack type alignment is always 4.
-  if (!IsDarwinVectorABI) {
+  if (IsLinuxABI) {
+// i386 System V ABI 2.1: Structures and unions assume the alignment of their
+// most strictly aligned component.
+//
+// Exclude other System V OS (e.g Darwin, PS4 and FreeBSD) since we don't
+// want to spend any effort dealing with the ramifications of ABI breaks.
+return Align;
+  } else if (!IsDarwinVectorABI) {
+// On non-Darwin and non-Linux, the stack type alignment is always 4.
 // Set explicit alignment, since we may need to realign the top.
 return MinABIStackAlignInBytes;
   }
Index: test/CodeGen/x86_32-align-linux.c
===
--- test/CodeGen/x86_32-align-linux.c
+++ test/CodeGen/x86_32-align-linux.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu -emit-llvm -o %t %s
+// RUN: FileCheck < %t %s
+
+#include 
+
+typedef union {
+int d[4];
+__m128 m;
+} M128;
+
+extern void foo(int, ...);
+
+M128 a;
+
+// CHECK-LABEL: define void @test
+// CHECK: entry:
+// CHECK: call void (i32, ...) @foo(i32 1, %union.M128* byval align 16
+// CHECK: call void (i32, ...) @foo(i32 1, <4 x float>
+
+void test(void)
+{
+  foo(1, a);
+  foo(1, a.m);
+}
+
Index: test/CodeGen/x86_32-arguments-linux.c
===
--- test/CodeGen/x86_32-arguments-linux.c
+++ test/CodeGen/x86_32-arguments-linux.c
@@ -3,21 +3,21 @@
 
 // CHECK-LABEL: define void @f56(
 // CHECK: i8 signext %a0, %struct.s56_0* byval align 4 %a1,
-// CHECK: i64 %a2.coerce, %struct.s56_1* byval align 4,
-// CHECK: <1 x double> %a4, %struct.s56_2* byval align 4,
-// CHECK: <4 x i32> %a6, %struct.s56_3* byval align 4,
-// CHECK: <2 x double> %a8, %struct.s56_4* byval align 4,
-// CHECK: <8 x i32> %a10, %struct.s56_5* byval align 4,
-// CHECK: <4 x double> %a12, %struct.s56_6* byval align 4)
+// CHECK: i64 %a2.coerce, %struct.s56_1* byval align 8 %a3,
+// CHECK: <1 x double> %a4, %struct.s56_2* byval align 8 %a5,
+// CHECK: <4 x i32> %a6, %struct.s56_3* byval align 16 %a7,
+// CHECK: <2 x double> %a8, %struct.s56_4* byval align 16 %a9,
+// CHECK: <8 x i32> %a10, %struct.s56_5* byval align 32 %a11,
+// CHECK: <4 x double> %a12, %struct.s56_6* byval align 32 %a13)
 
 // CHECK: call void (i32, ...) @f56_0(i32 1,
 // CHECK: i32 %{{.*}}, %struct.s56_0* byval align 4 %{{[^ ]*}},
-// CHECK: i64 %{{[^ ]*}}, %struct.s56_1* byval align 4 %{{[^ ]*}},
-// CHECK: <1 x double> %{{[^ ]*}}, %struct.s56_2* byval align 4 %{{[^ ]*}},
-// CHECK: <4 x i32> %{{[^ ]*}}, %struct.s56_3* byval align 4 %{{[^ ]*}},
-// CHECK: <2 x double> %{{[^ ]*}}, %struct.s56_4* byval align 4 %{{[^ ]*}},
-// CHECK: <8 x i32> %{{[^ ]*}}, %struct.s56_5* byval align 4 %{{[^ ]*}},
-// CHECK: <4 x double> %{{[^ ]*}}, %struct.s56_6* byval align 4 %{{[^ ]*}})
+// CHECK: i64 %{{[^ ]*}}, %struct.s56_1* byval align 8 %{{[^ ]*}},
+// CHECK: <1 x double> %{{[^ ]*}}, %struct.s56_2* byval align 8 %{{[^ ]*}},
+// CHECK: <4 x i32> %{{[^ ]*}}, %struct.s56_3* byval align 16 %{{[^ ]*}},
+// CHECK: <2 x double> %{{[^ ]*}}, %struct.s56_4* byval align 16 %{{[^ ]*}},
+// CHECK: <8 x i32> %{{[^ ]*}}, %struct.s56_5* byval align 32 %{{[^ ]*}},
+// CHECK: <4 x double> %{{[^ ]*}}, %struct.s56_6* byval align 32 %{{[^ ]*}})
 // CHECK: }
 //
 //  [i386] clang misaligns long double in structures
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60499: [ASTImporter] Various source location and range import fixes.

2019-05-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 3 inline comments as done.
balazske added inline comments.



Comment at: lib/AST/ASTImporter.cpp:6129
 if (Error Err =
-ImportTemplateArgumentListInfo(E->template_arguments(), ToTAInfo))
+ImportTemplateArgumentListInfo(E->getLAngleLoc(), 
E->getRAngleLoc(),
+   E->template_arguments(), ToTAInfo))

shafik wrote:
> Curious why you decided to add the new arguments to the front as opposed to 
> the end?
This overload of `ImportTemplateArgumentListInfo` already exists before the 
patch. It looks like that the last argument is the output value and the 
arguments before are input values.



Comment at: lib/AST/ASTImporter.cpp:7150
+  auto Imp = importSeq(E->getQualifierLoc(), E->getTemplateKeywordLoc(),
+   E->getDeclName(), E->getNameInfo().getLoc(),
+   E->getLAngleLoc(), E->getRAngleLoc());

shafik wrote:
> Can you explain why `E->getNameInfo().getLoc()` is more correct than 
> `E->getExprLoc()`?
The getExprLoc returns (if I am correct) the begin location and 
`getNameInfo().getLoc()` returns in "X::value" location of "value" (this 
should not be the same as BeginLoc, may be it is the EndLoc?). (The begin and 
end location is not imported explicitly, it is obtained from other location 
values in the expression object.) I just observed that `E->getLocation()` can 
be used instead of `E->getNameInfo().getLoc()`.
(The reason why this is correct that the test in D60463 indicates failure if 
getExprLoc is used, the begin and end locations are the same. That test works 
only in our Ericsson fork because Decl reordering issue.)



Comment at: lib/AST/ASTImporter.cpp:7225
 
-  if (E->hasExplicitTemplateArgs() && E->getTemplateKeywordLoc().isValid()) {
+  if (E->hasExplicitTemplateArgs()) {
 TemplateArgumentListInfo ToTAInfo;

shafik wrote:
> We still want to import a few lines down even if 
> `!E->getTemplateKeywordLoc().isValid()`?
The TemplateKeywordLoc can be invalid if the optional `template` keyword is 
missing. The import function can import an invalid SourceLocation (as invalid 
but not error).


Repository:
  rC Clang

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

https://reviews.llvm.org/D60499



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


[PATCH] D62574: Initial draft of target-configurable address spaces.

2019-05-29 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan created this revision.
ebevhan added reviewers: Anastasia, rjmccall.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is an initial draft of the support for target-configurable
address spaces.

Original RFC: http://lists.llvm.org/pipermail/cfe-dev/2019-March/061541.html

After thinking about Anastasia's input on the RFC regarding
the superspace/subspace model, I decided to go a different
route with the design of the interface. Instead of having
accessors for implicit casts and explicit casts, I kept the
subspace accessor and added an accessor for overriding
the behavior of explicit casts only.

This lets us keep the overlap model and support the default
Embedded-C functionality while still letting targets
configure their behavior reasonably.

This patch does not address the issue with the accessors
on Qualifiers (isAddressSpaceSupersetOf, compatiblyIncludes),
because I don't know how to solve it without breaking a ton of
rather nice encapsulation. Either, every mention of compatiblyIncludes
must be replaced with a call to a corresponding ASTContext method,
Qualifiers must have a handle to ASTContext, or ASTContext must be
passed to every such call. This revision mentions the issue in a comment:
https://reviews.llvm.org/D49294


Repository:
  rC Clang

https://reviews.llvm.org/D62574

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/Type.h
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaOverload.cpp
  test/Sema/address_space_print_macro.c
  test/Sema/address_spaces.c

Index: test/Sema/address_spaces.c
===
--- test/Sema/address_spaces.c
+++ test/Sema/address_spaces.c
@@ -71,7 +71,8 @@
 
 // Clang extension doesn't forbid operations on pointers to different address spaces.
 char* cmp(_AS1 char *x,  _AS2 char *y) {
-  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('_AS1 char *' and '_AS2 char *') which are pointers to non-overlapping address spaces}}
+  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('_AS1 char *' and '_AS2 char *') which are pointers to non-overlapping address spaces}} \
+// expected-error{{comparison between  ('_AS1 char *' and '_AS2 char *') which are pointers to non-overlapping address spaces}}
 }
 
 struct SomeStruct {
Index: test/Sema/address_space_print_macro.c
===
--- test/Sema/address_space_print_macro.c
+++ test/Sema/address_space_print_macro.c
@@ -14,7 +14,8 @@
 }
 
 char *cmp(AS1 char *x, AS2 char *y) {
-  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('AS1 char *' and 'AS2 char *') which are pointers to non-overlapping address spaces}}
+  return x < y ? x : y; // expected-error{{conditional operator with the second and third operands of type  ('AS1 char *' and 'AS2 char *') which are pointers to non-overlapping address spaces}} \
+// expected-error{{comparison between  ('AS1 char *' and 'AS2 char *') which are pointers to non-overlapping address spaces}}
 }
 
 __attribute__((address_space(1))) char test_array[10];
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -3161,12 +3161,17 @@
   = PreviousToQualsIncludeConst && ToQuals.hasConst();
   }
 
-  // Allows address space promotion by language rules implemented in
-  // Type::Qualifiers::isAddressSpaceSupersetOf.
+  // FIXME: This should *really* be testing implicit conversions with
+  // 'isAddressSpaceSupersetOf' and explicit conversions with
+  // 'isExplicitAddrSpaceConversionLegal', but IsQualificationConversion isn't
+  // aware of whether the conversion is implicit or explicit. Add that?
+  //
+  // Also, I don't really understand why we do this. How does preventing
+  // qualification conversion for disjoint address spaces make address space
+  // casts *work*?
   Qualifiers FromQuals = FromType.getQualifiers();
   Qualifiers ToQuals = ToType.getQualifiers();
-  if (!ToQuals.isAddressSpaceSupersetOf(FromQuals) &&
-  !FromQuals.isAddressSpaceSupersetOf(ToQuals)) {
+  if (!Context.isAddressSpaceOverlapping(ToQuals, FromQuals)) {
 return false;
   }
 
@@ -5142,10 +5147,14 @@
 return ICS;
   }
 
+  // FIXME: hasAddressSpace is wrong; this check will be skipped if FromType is
+  // not qualified with an address space, but if there's no implicit conversion
+  // from Default to ImplicitParamType's AS, that's an error.
   if (FromTypeCanon.getQualifiers().hasAddressSpace()) {
 Qualifiers QualsImplicitParamType = ImplicitParamType.getQualifiers();
 Qualifiers QualsFromType = FromTypeCanon.getQualifiers()

r361937 - Fix test added in r361903 to work on Windows.

2019-05-29 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Wed May 29 02:20:01 2019
New Revision: 361937

URL: http://llvm.org/viewvc/llvm-project?rev=361937&view=rev
Log:
Fix test added in r361903 to work on Windows.

Modified:
cfe/trunk/test/Driver/print-file-name.c

Modified: cfe/trunk/test/Driver/print-file-name.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/print-file-name.c?rev=361937&r1=361936&r2=361937&view=diff
==
--- cfe/trunk/test/Driver/print-file-name.c (original)
+++ cfe/trunk/test/Driver/print-file-name.c Wed May 29 02:20:01 2019
@@ -4,16 +4,16 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir \
 // RUN: --target=x86_64-linux-gnu \
 // RUN:   | FileCheck --check-prefix=CHECK-RESOURCE-DIR %s
-// CHECK-RESOURCE-DIR: resource_dir{{/|}}share{{/|}}asan_blacklist.txt
+// CHECK-RESOURCE-DIR: resource_dir{{/|\\}}share{{/|\\}}asan_blacklist.txt
 
 // RUN: %clang -print-file-name=libclang_rt.builtins.a 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --target=x86_64-linux-gnu \
 // RUN:   | FileCheck --check-prefix=CHECK-COMPILER-RT %s
-// CHECK-COMPILER-RT: 
resource_dir_with_per_target_subdir{{/|}}lib{{/|}}x86_64-linux-gnu{{/|}}libclang_rt.builtins.a
+// CHECK-COMPILER-RT: 
resource_dir_with_per_target_subdir{{/|\\}}lib{{/|\\}}x86_64-linux-gnu{{/|\\}}libclang_rt.builtins.a
 
 // RUN: %clang -print-file-name=include/c++/v1 2>&1 \
 // RUN: -ccc-install-dir %S/Inputs/basic_linux_libcxx_tree/usr/bin \
 // RUN: --target=x86_64-linux-gnu \
 // RUN:   | FileCheck --check-prefix=CHECK-INSTALL-DIR %s
-// CHECK-INSTALL-DIR: 
basic_linux_libcxx_tree{{/|}}usr{{/|}}bin{{/|}}..{{/|}}include{{/|}}c++{{/|}}v1
+// CHECK-INSTALL-DIR: 
basic_linux_libcxx_tree{{/|\\}}usr{{/|\\}}bin{{/|\\}}..{{/|\\}}include{{/|\\}}c++{{/|\\}}v1


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


[PATCH] D61601: [clangd] Represent Hover result using FormattedString

2019-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 201844.
ilya-biryukov added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61601

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -893,7 +893,10 @@
   int test1 = bonjour;
 }
   )cpp",
-  "Declared in main\n\nint bonjour",
+  "text[Declared in]code[main]\n"
+  "codeblock(cpp) [\n"
+  "int bonjour\n"
+  "]",
   },
   {
   R"cpp(// Local variable in method
@@ -904,7 +907,10 @@
   }
 };
   )cpp",
-  "Declared in s::method\n\nint bonjour",
+  "text[Declared in]code[s::method]\n"
+  "codeblock(cpp) [\n"
+  "int bonjour\n"
+  "]",
   },
   {
   R"cpp(// Struct
@@ -915,7 +921,10 @@
   ns1::My^Class* Params;
 }
   )cpp",
-  "Declared in ns1\n\nstruct MyClass {}",
+  "text[Declared in]code[ns1]\n"
+  "codeblock(cpp) [\n"
+  "struct MyClass {}\n"
+  "]",
   },
   {
   R"cpp(// Class
@@ -926,7 +935,10 @@
   ns1::My^Class* Params;
 }
   )cpp",
-  "Declared in ns1\n\nclass MyClass {}",
+  "text[Declared in]code[ns1]\n"
+  "codeblock(cpp) [\n"
+  "class MyClass {}\n"
+  "]",
   },
   {
   R"cpp(// Union
@@ -937,7 +949,10 @@
   ns1::My^Union Params;
 }
   )cpp",
-  "Declared in ns1\n\nunion MyUnion {}",
+  "text[Declared in]code[ns1]\n"
+  "codeblock(cpp) [\n"
+  "union MyUnion {}\n"
+  "]",
   },
   {
   R"cpp(// Function definition via pointer
@@ -946,7 +961,10 @@
   auto *X = &^foo;
 }
   )cpp",
-  "Declared in global namespace\n\nint foo(int)",
+  "text[Declared in global namespace]\n"
+  "codeblock(cpp) [\n"
+  "int foo(int)\n"
+  "]",
   },
   {
   R"cpp(// Function declaration via call
@@ -955,7 +973,10 @@
   return ^foo(42);
 }
   )cpp",
-  "Declared in global namespace\n\nint foo(int)",
+  "text[Declared in global namespace]\n"
+  "codeblock(cpp) [\n"
+  "int foo(int)\n"
+  "]",
   },
   {
   R"cpp(// Field
@@ -965,7 +986,10 @@
   bar.^x;
 }
   )cpp",
-  "Declared in Foo\n\nint x",
+  "text[Declared in]code[Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x\n"
+  "]",
   },
   {
   R"cpp(// Field with initialization
@@ -975,7 +999,10 @@
   bar.^x;
 }
   )cpp",
-  "Declared in Foo\n\nint x = 5",
+  "text[Declared in]code[Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x = 5\n"
+  "]",
   },
   {
   R"cpp(// Static field
@@ -984,7 +1011,10 @@
   Foo::^x;
 }
   )cpp",
-  "Declared in Foo\n\nstatic int x",
+  "text[Declared in]code[Foo]\n"
+  "codeblock(cpp) [\n"
+  "static int x\n"
+  "]",
   },
   {
   R"cpp(// Field, member initializer
@@ -993,7 +1023,10 @@
   Foo() : ^x(0) {}
 };
   )cpp",
-  "Declared in Foo\n\nint x",
+  "text[Declared in]code[Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x\n"
+  "]",
   },
   {
   R"cpp(// Field, GNU old-style field designator
@@ -1002,7 +1035,10 @@
   Foo bar = { ^x : 1 };
 }
   )cpp",
-  "Declared in Foo\n\nint x",
+  "text[Declared in]code[Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x\n"
+  "]",
   },
   {
   R"cpp(// Field, field designator
@@ -1011,7 +1047,10 @@
   Foo bar = { .^x = 2 };
 }
   )cpp",
-  "Declared in Foo\n\nint x",
+  "text[Declared in]code[Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x\n"
+  "]",
   },
   {
   R"cpp(// Method call
@@ -1021,7 +1060,10 @@
   

[PATCH] D61601: [clangd] Represent Hover result using FormattedString

2019-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

This is ready for review now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61601



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


[PATCH] D60748: Fix i386 struct and union parameter alignment

2019-05-29 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added subscribers: mgorny, joerg.
krytarowski added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:1501
+//
+// Exclude other System V OS (e.g Darwin, PS4 and FreeBSD) since we don't
+// want to spend any effort dealing with the ramifications of ABI breaks.

Darwin and BSD are not System V.

CC: @joerg @mgorny for NetBSD. Do we need to do something here?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60748



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


[PATCH] D61601: [clangd] Represent Hover result using FormattedString

2019-05-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!




Comment at: clang-tools-extra/clangd/XRefs.cpp:1170
 else if (NamespaceScope->empty())
-  Out << "global namespace";
+  Output.appendText(" global namespace");
 else

Should this also be `inlinecode`, for consistency? I know it is not exactly 
code as the other two cases, but it might still be better to look similar in 
all cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61601



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


[PATCH] D61601: [clangd] Represent Hover result using FormattedString

2019-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 201847.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

- Create an inline code block for 'global namespace' too


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61601

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -893,7 +893,10 @@
   int test1 = bonjour;
 }
   )cpp",
-  "Declared in main\n\nint bonjour",
+  "text[Declared in]code[main]\n"
+  "codeblock(cpp) [\n"
+  "int bonjour\n"
+  "]",
   },
   {
   R"cpp(// Local variable in method
@@ -904,7 +907,10 @@
   }
 };
   )cpp",
-  "Declared in s::method\n\nint bonjour",
+  "text[Declared in]code[s::method]\n"
+  "codeblock(cpp) [\n"
+  "int bonjour\n"
+  "]",
   },
   {
   R"cpp(// Struct
@@ -915,7 +921,10 @@
   ns1::My^Class* Params;
 }
   )cpp",
-  "Declared in ns1\n\nstruct MyClass {}",
+  "text[Declared in]code[ns1]\n"
+  "codeblock(cpp) [\n"
+  "struct MyClass {}\n"
+  "]",
   },
   {
   R"cpp(// Class
@@ -926,7 +935,10 @@
   ns1::My^Class* Params;
 }
   )cpp",
-  "Declared in ns1\n\nclass MyClass {}",
+  "text[Declared in]code[ns1]\n"
+  "codeblock(cpp) [\n"
+  "class MyClass {}\n"
+  "]",
   },
   {
   R"cpp(// Union
@@ -937,7 +949,10 @@
   ns1::My^Union Params;
 }
   )cpp",
-  "Declared in ns1\n\nunion MyUnion {}",
+  "text[Declared in]code[ns1]\n"
+  "codeblock(cpp) [\n"
+  "union MyUnion {}\n"
+  "]",
   },
   {
   R"cpp(// Function definition via pointer
@@ -946,7 +961,10 @@
   auto *X = &^foo;
 }
   )cpp",
-  "Declared in global namespace\n\nint foo(int)",
+  "text[Declared in]code[global namespace]\n"
+  "codeblock(cpp) [\n"
+  "int foo(int)\n"
+  "]",
   },
   {
   R"cpp(// Function declaration via call
@@ -955,7 +973,10 @@
   return ^foo(42);
 }
   )cpp",
-  "Declared in global namespace\n\nint foo(int)",
+  "text[Declared in]code[global namespace]\n"
+  "codeblock(cpp) [\n"
+  "int foo(int)\n"
+  "]",
   },
   {
   R"cpp(// Field
@@ -965,7 +986,10 @@
   bar.^x;
 }
   )cpp",
-  "Declared in Foo\n\nint x",
+  "text[Declared in]code[Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x\n"
+  "]",
   },
   {
   R"cpp(// Field with initialization
@@ -975,7 +999,10 @@
   bar.^x;
 }
   )cpp",
-  "Declared in Foo\n\nint x = 5",
+  "text[Declared in]code[Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x = 5\n"
+  "]",
   },
   {
   R"cpp(// Static field
@@ -984,7 +1011,10 @@
   Foo::^x;
 }
   )cpp",
-  "Declared in Foo\n\nstatic int x",
+  "text[Declared in]code[Foo]\n"
+  "codeblock(cpp) [\n"
+  "static int x\n"
+  "]",
   },
   {
   R"cpp(// Field, member initializer
@@ -993,7 +1023,10 @@
   Foo() : ^x(0) {}
 };
   )cpp",
-  "Declared in Foo\n\nint x",
+  "text[Declared in]code[Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x\n"
+  "]",
   },
   {
   R"cpp(// Field, GNU old-style field designator
@@ -1002,7 +1035,10 @@
   Foo bar = { ^x : 1 };
 }
   )cpp",
-  "Declared in Foo\n\nint x",
+  "text[Declared in]code[Foo]\n"
+  "codeblock(cpp) [\n"
+  "int x\n"
+  "]",
   },
   {
   R"cpp(// Field, field designator
@@ -1011,7 +1047,10 @@
   Foo bar = { .^x = 2 };
 }
   )cpp",
-  "Declared in Foo\n\nint x",
+  "text[Declared in]code[Foo]\n"
+  "codeblock(cpp) [\n"
+  "

[PATCH] D61601: [clangd] Represent Hover result using FormattedString

2019-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1170
 else if (NamespaceScope->empty())
-  Out << "global namespace";
+  Output.appendText(" global namespace");
 else

kadircet wrote:
> Should this also be `inlinecode`, for consistency? I know it is not exactly 
> code as the other two cases, but it might still be better to look similar in 
> all cases
Yeah, wasn't sure. Turned into inline code, could tweak later if needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61601



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


[clang-tools-extra] r361940 - [clangd] Represent Hover result using FormattedString

2019-05-29 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed May 29 03:01:00 2019
New Revision: 361940

URL: http://llvm.org/viewvc/llvm-project?rev=361940&view=rev
Log:
[clangd] Represent Hover result using FormattedString

Reviewers: sammccall, kadircet

Reviewed By: kadircet

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/FormattedString.cpp
clang-tools-extra/trunk/clangd/FormattedString.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/clangd/XRefs.h
clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=361940&r1=361939&r2=361940&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed May 29 03:01:00 2019
@@ -8,6 +8,7 @@
 
 #include "ClangdLSPServer.h"
 #include "Diagnostics.h"
+#include "FormattedString.h"
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "Trace.h"
@@ -358,6 +359,7 @@ void ClangdLSPServer::onInitialize(const
   SupportsHierarchicalDocumentSymbol =
   Params.capabilities.HierarchicalDocumentSymbol;
   SupportFileStatus = Params.initializationOptions.FileStatus;
+  HoverContentFormat = Params.capabilities.HoverContentFormat;
   llvm::json::Object Result{
   {{"capabilities",
 llvm::json::Object{
@@ -843,17 +845,27 @@ void ClangdLSPServer::onHover(const Text
   Callback> Reply) {
   Server->findHover(Params.textDocument.uri.file(), Params.position,
 Bind(
-[](decltype(Reply) Reply,
-   llvm::Expected> HIorErr) {
-  if (!HIorErr)
-return Reply(HIorErr.takeError());
-  const auto &HI = HIorErr.get();
-  if (!HI)
+[this](decltype(Reply) Reply,
+   llvm::Expected> H) {
+  if (!H)
+return Reply(H.takeError());
+  if (!*H)
 return Reply(llvm::None);
-  Hover H;
-  H.range = HI->SymRange;
-  H.contents = HI->render();
-  return Reply(H);
+
+  Hover R;
+  R.contents.kind = HoverContentFormat;
+  R.range = (*H)->SymRange;
+  switch (HoverContentFormat) {
+  case MarkupKind::PlainText:
+R.contents.value =
+(*H)->present().renderAsPlainText();
+return Reply(std::move(R));
+  case MarkupKind::Markdown:
+R.contents.value =
+(*H)->present().renderAsMarkdown();
+return Reply(std::move(R));
+  };
+  llvm_unreachable("unhandled MarkupKind");
 },
 std::move(Reply)));
 }

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=361940&r1=361939&r2=361940&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Wed May 29 03:01:00 2019
@@ -154,7 +154,10 @@ private:
   bool SupportsHierarchicalDocumentSymbol = false;
   /// Whether the client supports showing file status.
   bool SupportFileStatus = false;
-  // Store of the current versions of the open documents.
+  /// Which kind of markup should we use in textDocument/hover responses.
+  MarkupKind HoverContentFormat = MarkupKind::PlainText;
+
+  /// Store of the current versions of the open documents.
   DraftStore DraftMgr;
 
   // The CDB is created by the "initialize" LSP method.

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=361940&r1=361939&r2=361940&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (ori

[PATCH] D61601: [clangd] Represent Hover result using FormattedString

2019-05-29 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361940: [clangd] Represent Hover result using 
FormattedString (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61601?vs=201847&id=201848#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61601

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdLSPServer.h
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/FormattedString.cpp
  clang-tools-extra/trunk/clangd/FormattedString.h
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/XRefs.cpp
  clang-tools-extra/trunk/clangd/XRefs.h
  clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/trunk/clangd/Protocol.cpp
===
--- clang-tools-extra/trunk/clangd/Protocol.cpp
+++ clang-tools-extra/trunk/clangd/Protocol.cpp
@@ -303,6 +303,17 @@
   DocumentSymbol->getBoolean("hierarchicalDocumentSymbolSupport"))
 R.HierarchicalDocumentSymbol = *HierarchicalSupport;
 }
+if (auto *Hover = TextDocument->getObject("hover")) {
+  if (auto *ContentFormat = Hover->getArray("contentFormat")) {
+for (const auto &Format : *ContentFormat) {
+  MarkupKind K = MarkupKind::PlainText;
+  if (fromJSON(Format, K)) {
+R.HoverContentFormat = K;
+break;
+  }
+}
+  }
+}
   }
   if (auto *Workspace = O->getObject("workspace")) {
 if (auto *Symbol = Workspace->getObject("symbol")) {
@@ -684,6 +695,27 @@
   llvm_unreachable("Invalid MarkupKind");
 }
 
+bool fromJSON(const llvm::json::Value &V, MarkupKind &K) {
+  auto Str = V.getAsString();
+  if (!Str) {
+elog("Failed to parse markup kind: expected a string");
+return false;
+  }
+  if (*Str == "plaintext")
+K = MarkupKind::PlainText;
+  else if (*Str == "markdown")
+K = MarkupKind::Markdown;
+  else {
+elog("Unknown markup kind: {0}", *Str);
+return false;
+  }
+  return true;
+}
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, MarkupKind K) {
+  return OS << toTextKind(K);
+}
+
 llvm::json::Value toJSON(const MarkupContent &MC) {
   if (MC.value.empty())
 return nullptr;
Index: clang-tools-extra/trunk/clangd/XRefs.h
===
--- clang-tools-extra/trunk/clangd/XRefs.h
+++ clang-tools-extra/trunk/clangd/XRefs.h
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_XREFS_H
 
 #include "ClangdUnit.h"
+#include "FormattedString.h"
 #include "Protocol.h"
 #include "index/Index.h"
 #include "index/SymbolLocation.h"
@@ -103,8 +104,8 @@
   /// Set for all templates(function, class, variable).
   llvm::Optional> TemplateParameters;
 
-  /// Lower to LSP struct.
-  MarkupContent render() const;
+  /// Produce a user-readable information.
+  FormattedString present() const;
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const HoverInfo::Param &);
 inline bool operator==(const HoverInfo::Param &LHS,
Index: clang-tools-extra/trunk/clangd/FormattedString.h
===
--- clang-tools-extra/trunk/clangd/FormattedString.h
+++ clang-tools-extra/trunk/clangd/FormattedString.h
@@ -35,6 +35,7 @@
 
   std::string renderAsMarkdown() const;
   std::string renderAsPlainText() const;
+  std::string renderForTests() const;
 
 private:
   enum class ChunkKind {
Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -10,11 +10,13 @@
 #include "ClangdUnit.h"
 #include "CodeComplete.h"
 #include "FindSymbols.h"
+#include "FormattedString.h"
 #include "Headers.h"
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "TUScheduler.h"
 #include "Trace.h"
+#include "XRefs.h"
 #include "index/CanonicalIncludes.h"
 #include "index/FileIndex.h"
 #include "index/Merge.h"
@@ -462,7 +464,7 @@
 
 void ClangdServer::findHover(PathRef File, Position Pos,
  Callback> CB) {
-  auto Action = [Pos](Callback> CB, Path File,
+  auto Action = [Pos](decltype(CB) CB, Path File,
   llvm::Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
Index: clang-tools-extra/trunk/clangd/XRefs.cpp
===
--- clang-tools-extra/trunk/clangd/XRefs.cpp
+++ clang-tools-extra/trunk/clangd/XRefs.cpp
@@ -9,6 +9,7 @@
 #include "AST.h"
 #include "CodeCompletionStrings.h"
 #include "FindSymbol

[PATCH] D62575: [clangd] Another improvement for std include mapping.

2019-05-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

Improve the way of checking a symbol name is in the first cell. The previous way
is not very robost for cases where a cell lists multiple symbols (e.g. int8_t).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62575

Files:
  clang-tools-extra/clangd/StdSymbolMap.inc
  clang-tools-extra/clangd/include-mapping/gen_std.py
  clang-tools-extra/clangd/include-mapping/test.py

Index: clang-tools-extra/clangd/include-mapping/test.py
===
--- clang-tools-extra/clangd/include-mapping/test.py
+++ clang-tools-extra/clangd/include-mapping/test.py
@@ -85,7 +85,11 @@
 
   
   
-void foo()
+
+  void
+  foo
+  ()
+
 this is matched
   
 
@@ -108,7 +112,11 @@
 
 
 
-  void foo()
+  
+void
+foo
+()
+  
   this is matched
 
 
@@ -116,6 +124,32 @@
 self.assertEqual(ParseSymbolPage(html, "foo"),
  set(['', '']))
 
+  def testParseSymbolPage_MulSymbolsInSameTd(self):
+# defined in header 
+#   int8_t
+#   int16_t
+html = """
+
+
+
+ Defined in header 
+
+
+
+
+  
+int8_t
+int16_t
+  
+  this is matched
+
+
+"""
+self.assertEqual(ParseSymbolPage(html, "int8_t"),
+ set(['']))
+self.assertEqual(ParseSymbolPage(html, "int16_t"),
+ set(['']))
+
 
 if __name__ == '__main__':
   unittest.main()
Index: clang-tools-extra/clangd/include-mapping/gen_std.py
===
--- clang-tools-extra/clangd/include-mapping/gen_std.py
+++ clang-tools-extra/clangd/include-mapping/gen_std.py
@@ -84,10 +84,9 @@
 for row in table.select('tr'):
   if HasClass(row, 't-dcl', 't-dsc'):
 was_decl = True
-# Declaration is in the first cell.
-text = row.find('td').text
-# Decl may not be for the symbol name we're looking for.
-if not re.search("\\b%s\\b" % symbol_name, text):
+# Symbols are in the first cell.
+found_symbols = row.find('td').stripped_strings
+if not symbol_name in found_symbols:
   continue
 headers.update(current_headers)
   elif HasClass(row, 't-dsc-header'):
Index: clang-tools-extra/clangd/StdSymbolMap.inc
===
--- clang-tools-extra/clangd/StdSymbolMap.inc
+++ clang-tools-extra/clangd/StdSymbolMap.inc
@@ -454,11 +454,24 @@
 SYMBOL(inclusive_scan, std::, )
 SYMBOL(independent_bits_engine, std::, )
 SYMBOL(indirect_array, std::, )
+SYMBOL(initializer_list, std::, )
 SYMBOL(inner_product, std::, )
 SYMBOL(inplace_merge, std::, )
 SYMBOL(input_iterator_tag, std::, )
 SYMBOL(insert_iterator, std::, )
 SYMBOL(inserter, std::, )
+SYMBOL(int16_t, std::, )
+SYMBOL(int32_t, std::, )
+SYMBOL(int64_t, std::, )
+SYMBOL(int8_t, std::, )
+SYMBOL(int_fast16_t, std::, )
+SYMBOL(int_fast32_t, std::, )
+SYMBOL(int_fast64_t, std::, )
+SYMBOL(int_fast8_t, std::, )
+SYMBOL(int_least16_t, std::, )
+SYMBOL(int_least32_t, std::, )
+SYMBOL(int_least64_t, std::, )
+SYMBOL(int_least8_t, std::, )
 SYMBOL(integer_sequence, std::, )
 SYMBOL(integral_constant, std::, )
 SYMBOL(internal, std::, )
@@ -1150,6 +1163,18 @@
 SYMBOL(u32streampos, std::, )
 SYMBOL(u32string, std::, )
 SYMBOL(u32string_view, std::, )
+SYMBOL(uint16_t, std::, )
+SYMBOL(uint32_t, std::, )
+SYMBOL(uint64_t, std::, )
+SYMBOL(uint8_t, std::, )
+SYMBOL(uint_fast16_t, std::, )
+SYMBOL(uint_fast32_t, std::, )
+SYMBOL(uint_fast64_t, std::, )
+SYMBOL(uint_fast8_t, std::, )
+SYMBOL(uint_least16_t, std::, )
+SYMBOL(uint_least32_t, std::, )
+SYMBOL(uint_least64_t, std::, )
+SYMBOL(uint_least8_t, std::, )
 SYMBOL(uintmax_t, std::, )
 SYMBOL(uintptr_t, std::, )
 SYMBOL(uncaught_exceptions, std::, )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62573: [Index] Correctly set symbol kind of IndirectFieldDecl

2019-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D62573#1520641 , @kadircet wrote:

> Do you think it would be beneficial to add some logging for the default case 
> of that switch statement ?


We should replace `default` with all cases it covers to make sure we get a 
warning when adding a new kind.
But I'm not sure it's going to be a big improvement, maybe it would be even 
nicer to replace this with some macro magic involving `#include 
"DeclKinds.inc"`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62573



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


[clang-tools-extra] r361941 - [Index] Correctly set symbol kind of IndirectFieldDecl

2019-05-29 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed May 29 03:11:14 2019
New Revision: 361941

URL: http://llvm.org/viewvc/llvm-project?rev=361941&view=rev
Log:
[Index] Correctly set symbol kind of IndirectFieldDecl

Summary: The kind has been 'unknown' before, now it is 'field'.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp?rev=361941&r1=361940&r2=361941&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/CodeCompleteTests.cpp Wed May 29 
03:11:14 2019
@@ -449,6 +449,20 @@ TEST(CompletionTest, Kinds) {
   Results = completions("nam^");
   EXPECT_THAT(Results.Completions,
   Has("namespace", CompletionItemKind::Snippet));
+
+  // Members of anonymous unions are of kind 'field'.
+  Results = completions(
+  R"cpp(
+struct X{
+union {
+  void *a;
+};
+};
+auto u = X().^
+  )cpp");
+  EXPECT_THAT(
+  Results.Completions,
+  UnorderedElementsAre(AllOf(Named("a"), 
Kind(CompletionItemKind::Field;
 }
 
 TEST(CompletionTest, NoDuplicates) {


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


r361941 - [Index] Correctly set symbol kind of IndirectFieldDecl

2019-05-29 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed May 29 03:11:14 2019
New Revision: 361941

URL: http://llvm.org/viewvc/llvm-project?rev=361941&view=rev
Log:
[Index] Correctly set symbol kind of IndirectFieldDecl

Summary: The kind has been 'unknown' before, now it is 'field'.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/Index/index-anonymous-union-fields.cpp
Modified:
cfe/trunk/lib/Index/IndexSymbol.cpp

Modified: cfe/trunk/lib/Index/IndexSymbol.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexSymbol.cpp?rev=361941&r1=361940&r2=361941&view=diff
==
--- cfe/trunk/lib/Index/IndexSymbol.cpp (original)
+++ cfe/trunk/lib/Index/IndexSymbol.cpp Wed May 29 03:11:14 2019
@@ -168,6 +168,7 @@ SymbolInfo index::getSymbolInfo(const De
   Info.Kind = SymbolKind::Function;
   break;
 case Decl::Field:
+case Decl::IndirectField:
   Info.Kind = SymbolKind::Field;
   if (const CXXRecordDecl *
 CXXRec = dyn_cast(D->getDeclContext())) {

Added: cfe/trunk/test/Index/index-anonymous-union-fields.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-anonymous-union-fields.cpp?rev=361941&view=auto
==
--- cfe/trunk/test/Index/index-anonymous-union-fields.cpp (added)
+++ cfe/trunk/test/Index/index-anonymous-union-fields.cpp Wed May 29 03:11:14 
2019
@@ -0,0 +1,10 @@
+struct X {
+  union {
+void *a;
+  };
+};
+
+// RUN: c-index-test -index-file %s > %t
+// RUN: FileCheck %s -input-file=%t
+
+// CHECK: [indexDeclaration]: kind: field | name: a | {{.*}} | loc: 3:11


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


[PATCH] D62573: [Index] Correctly set symbol kind of IndirectFieldDecl

2019-05-29 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE361941: [Index] Correctly set symbol kind of 
IndirectFieldDecl (authored by ibiryukov, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62573?vs=201837&id=201851#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62573

Files:
  clangd/unittests/CodeCompleteTests.cpp


Index: clangd/unittests/CodeCompleteTests.cpp
===
--- clangd/unittests/CodeCompleteTests.cpp
+++ clangd/unittests/CodeCompleteTests.cpp
@@ -449,6 +449,20 @@
   Results = completions("nam^");
   EXPECT_THAT(Results.Completions,
   Has("namespace", CompletionItemKind::Snippet));
+
+  // Members of anonymous unions are of kind 'field'.
+  Results = completions(
+  R"cpp(
+struct X{
+union {
+  void *a;
+};
+};
+auto u = X().^
+  )cpp");
+  EXPECT_THAT(
+  Results.Completions,
+  UnorderedElementsAre(AllOf(Named("a"), 
Kind(CompletionItemKind::Field;
 }
 
 TEST(CompletionTest, NoDuplicates) {


Index: clangd/unittests/CodeCompleteTests.cpp
===
--- clangd/unittests/CodeCompleteTests.cpp
+++ clangd/unittests/CodeCompleteTests.cpp
@@ -449,6 +449,20 @@
   Results = completions("nam^");
   EXPECT_THAT(Results.Completions,
   Has("namespace", CompletionItemKind::Snippet));
+
+  // Members of anonymous unions are of kind 'field'.
+  Results = completions(
+  R"cpp(
+struct X{
+union {
+  void *a;
+};
+};
+auto u = X().^
+  )cpp");
+  EXPECT_THAT(
+  Results.Completions,
+  UnorderedElementsAre(AllOf(Named("a"), Kind(CompletionItemKind::Field;
 }
 
 TEST(CompletionTest, NoDuplicates) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: [PATCH] D62483: [CUDA][HIP] Emit dependent libs for host only

2019-05-29 Thread Liu, Yaxun (Sam) via cfe-commits
Fixed by 361905.

Sam

-Original Message-
From: Petr Hosek via Phabricator  
Sent: Tuesday, May 28, 2019 9:54 PM
To: Liu, Yaxun (Sam) ; t...@google.com
Cc: pho...@google.com; cfe-commits@lists.llvm.org; mlek...@skidmore.edu; 
blitzrak...@gmail.com; shen...@google.com; jle...@google.com; 
zjturner0...@gmail.com
Subject: [PATCH] D62483: [CUDA][HIP] Emit dependent libs for host only

[CAUTION: External Email]

phosek added a comment.

This seems to be failing on macOS bots with the following error:

  FAIL: Clang :: CodeGenCUDA/dependent-libs.cu (3052 of 14933)
   TEST 'Clang :: CodeGenCUDA/dependent-libs.cu' FAILED 

  Script:
  --
  : 'RUN: at line 1';   
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/lib/clang/9.0.0/include 
-nostdsysteminc -emit-llvm -o - -fcuda-is-device -x hip 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu | 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/FileCheck 
--check-prefix=DEV 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu
  : 'RUN: at line 2';   
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/lib/clang/9.0.0/include 
-nostdsysteminc -emit-llvm -o - -x hip 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu | 
/b/s/w/ir/k/recipe_cleanup/clangAoYUvt/llvm_build_dir/bin/FileCheck 
--check-prefix=HOST 
/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu
  --
  Exit Code: 1

  Command Output (stderr):
  --
  /b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu:5:10: 
error: HOST: expected string not found in input
  // HOST: llvm.dependent-libraries
   ^
  :1:1: note: scanning from here
  ; ModuleID = 
'/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu'
  ^
  :1:58: note: possible intended match here
  ; ModuleID = 
'/b/s/w/ir/k/llvm-project/clang/test/CodeGenCUDA/dependent-libs.cu'
   ^

  --

The full test log is here: 
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket.appspot.com/8912171419117598448/+/steps/clang/0/steps/test/0/stdout


Repository:
  rC Clang

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

https://reviews.llvm.org/D62483



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


[PATCH] D37035: Implement __builtin_LINE() et. al. to support source location capture.

2019-05-29 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

As of r361920, the SystemZ build bots are green again.   Thanks, Eric!


Repository:
  rC Clang

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

https://reviews.llvm.org/D37035



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


[clang-tools-extra] r361951 - [clangd] Another improvement for std include mapping.

2019-05-29 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed May 29 05:03:41 2019
New Revision: 361951

URL: http://llvm.org/viewvc/llvm-project?rev=361951&view=rev
Log:
[clangd] Another improvement for std include mapping.

Summary:
Improve the way of checking a symbol name is in the first cell. The previous way
is not very robost for cases where a cell lists multiple symbols (e.g. int8_t).

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/StdSymbolMap.inc
clang-tools-extra/trunk/clangd/include-mapping/gen_std.py
clang-tools-extra/trunk/clangd/include-mapping/test.py

Modified: clang-tools-extra/trunk/clangd/StdSymbolMap.inc
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/StdSymbolMap.inc?rev=361951&r1=361950&r2=361951&view=diff
==
--- clang-tools-extra/trunk/clangd/StdSymbolMap.inc (original)
+++ clang-tools-extra/trunk/clangd/StdSymbolMap.inc Wed May 29 05:03:41 2019
@@ -454,11 +454,24 @@ SYMBOL(includes, std::, )
 SYMBOL(inclusive_scan, std::, )
 SYMBOL(independent_bits_engine, std::, )
 SYMBOL(indirect_array, std::, )
+SYMBOL(initializer_list, std::, )
 SYMBOL(inner_product, std::, )
 SYMBOL(inplace_merge, std::, )
 SYMBOL(input_iterator_tag, std::, )
 SYMBOL(insert_iterator, std::, )
 SYMBOL(inserter, std::, )
+SYMBOL(int16_t, std::, )
+SYMBOL(int32_t, std::, )
+SYMBOL(int64_t, std::, )
+SYMBOL(int8_t, std::, )
+SYMBOL(int_fast16_t, std::, )
+SYMBOL(int_fast32_t, std::, )
+SYMBOL(int_fast64_t, std::, )
+SYMBOL(int_fast8_t, std::, )
+SYMBOL(int_least16_t, std::, )
+SYMBOL(int_least32_t, std::, )
+SYMBOL(int_least64_t, std::, )
+SYMBOL(int_least8_t, std::, )
 SYMBOL(integer_sequence, std::, )
 SYMBOL(integral_constant, std::, )
 SYMBOL(internal, std::, )
@@ -1150,6 +1163,18 @@ SYMBOL(u16string_view, std::, )
 SYMBOL(u32string, std::, )
 SYMBOL(u32string_view, std::, )
+SYMBOL(uint16_t, std::, )
+SYMBOL(uint32_t, std::, )
+SYMBOL(uint64_t, std::, )
+SYMBOL(uint8_t, std::, )
+SYMBOL(uint_fast16_t, std::, )
+SYMBOL(uint_fast32_t, std::, )
+SYMBOL(uint_fast64_t, std::, )
+SYMBOL(uint_fast8_t, std::, )
+SYMBOL(uint_least16_t, std::, )
+SYMBOL(uint_least32_t, std::, )
+SYMBOL(uint_least64_t, std::, )
+SYMBOL(uint_least8_t, std::, )
 SYMBOL(uintmax_t, std::, )
 SYMBOL(uintptr_t, std::, )
 SYMBOL(uncaught_exceptions, std::, )

Modified: clang-tools-extra/trunk/clangd/include-mapping/gen_std.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/include-mapping/gen_std.py?rev=361951&r1=361950&r2=361951&view=diff
==
--- clang-tools-extra/trunk/clangd/include-mapping/gen_std.py (original)
+++ clang-tools-extra/trunk/clangd/include-mapping/gen_std.py Wed May 29 
05:03:41 2019
@@ -84,10 +84,9 @@ def ParseSymbolPage(symbol_page_html, sy
 for row in table.select('tr'):
   if HasClass(row, 't-dcl', 't-dsc'):
 was_decl = True
-# Declaration is in the first cell.
-text = row.find('td').text
-# Decl may not be for the symbol name we're looking for.
-if not re.search("\\b%s\\b" % symbol_name, text):
+# Symbols are in the first cell.
+found_symbols = row.find('td').stripped_strings
+if not symbol_name in found_symbols:
   continue
 headers.update(current_headers)
   elif HasClass(row, 't-dsc-header'):

Modified: clang-tools-extra/trunk/clangd/include-mapping/test.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/include-mapping/test.py?rev=361951&r1=361950&r2=361951&view=diff
==
--- clang-tools-extra/trunk/clangd/include-mapping/test.py (original)
+++ clang-tools-extra/trunk/clangd/include-mapping/test.py Wed May 29 05:03:41 
2019
@@ -85,7 +85,11 @@ class TestStdGen(unittest.TestCase):
 
   
   
-void foo()
+
+  void
+  foo
+  ()
+
 this is matched
   
 
@@ -108,7 +112,11 @@ class TestStdGen(unittest.TestCase):
 
 
 
-  void foo()
+  
+void
+foo
+()
+  
   this is matched
 
 
@@ -116,6 +124,32 @@ class TestStdGen(unittest.TestCase):
 self.assertEqual(ParseSymbolPage(html, "foo"),
  set(['', '']))
 
+  def testParseSymbolPage_MulSymbolsInSameTd(self):
+# defined in header 
+#   int8_t
+#   int16_t
+html = """
+
+
+
+ Defined in header 
+
+
+
+
+  
+int8_t
+int16_t
+  
+  this is matched
+
+
+"""
+self.assertEqual(ParseSymbolPage(html, "int8_t"),
+ set(['']))
+self.assertEqual(ParseSymbolPage(html, "int16_t"),
+ set(['']))
+
 
 if __name__ == '__main__':
   unittest.main()


___
cfe-commits mailing list
cfe-com

[PATCH] D62490: clang-cl: Fix mangling of catchable types with names longer than 4kiB

2019-05-29 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D62490



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


[PATCH] D62575: [clangd] Another improvement for std include mapping.

2019-05-29 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361951: [clangd] Another improvement for std include 
mapping. (authored by hokein, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62575?vs=201850&id=201867#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62575

Files:
  clang-tools-extra/trunk/clangd/StdSymbolMap.inc
  clang-tools-extra/trunk/clangd/include-mapping/gen_std.py
  clang-tools-extra/trunk/clangd/include-mapping/test.py

Index: clang-tools-extra/trunk/clangd/include-mapping/gen_std.py
===
--- clang-tools-extra/trunk/clangd/include-mapping/gen_std.py
+++ clang-tools-extra/trunk/clangd/include-mapping/gen_std.py
@@ -84,10 +84,9 @@
 for row in table.select('tr'):
   if HasClass(row, 't-dcl', 't-dsc'):
 was_decl = True
-# Declaration is in the first cell.
-text = row.find('td').text
-# Decl may not be for the symbol name we're looking for.
-if not re.search("\\b%s\\b" % symbol_name, text):
+# Symbols are in the first cell.
+found_symbols = row.find('td').stripped_strings
+if not symbol_name in found_symbols:
   continue
 headers.update(current_headers)
   elif HasClass(row, 't-dsc-header'):
Index: clang-tools-extra/trunk/clangd/include-mapping/test.py
===
--- clang-tools-extra/trunk/clangd/include-mapping/test.py
+++ clang-tools-extra/trunk/clangd/include-mapping/test.py
@@ -85,7 +85,11 @@
 
   
   
-void foo()
+
+  void
+  foo
+  ()
+
 this is matched
   
 
@@ -108,7 +112,11 @@
 
 
 
-  void foo()
+  
+void
+foo
+()
+  
   this is matched
 
 
@@ -116,6 +124,32 @@
 self.assertEqual(ParseSymbolPage(html, "foo"),
  set(['', '']))
 
+  def testParseSymbolPage_MulSymbolsInSameTd(self):
+# defined in header 
+#   int8_t
+#   int16_t
+html = """
+
+
+
+ Defined in header 
+
+
+
+
+  
+int8_t
+int16_t
+  
+  this is matched
+
+
+"""
+self.assertEqual(ParseSymbolPage(html, "int8_t"),
+ set(['']))
+self.assertEqual(ParseSymbolPage(html, "int16_t"),
+ set(['']))
+
 
 if __name__ == '__main__':
   unittest.main()
Index: clang-tools-extra/trunk/clangd/StdSymbolMap.inc
===
--- clang-tools-extra/trunk/clangd/StdSymbolMap.inc
+++ clang-tools-extra/trunk/clangd/StdSymbolMap.inc
@@ -454,11 +454,24 @@
 SYMBOL(inclusive_scan, std::, )
 SYMBOL(independent_bits_engine, std::, )
 SYMBOL(indirect_array, std::, )
+SYMBOL(initializer_list, std::, )
 SYMBOL(inner_product, std::, )
 SYMBOL(inplace_merge, std::, )
 SYMBOL(input_iterator_tag, std::, )
 SYMBOL(insert_iterator, std::, )
 SYMBOL(inserter, std::, )
+SYMBOL(int16_t, std::, )
+SYMBOL(int32_t, std::, )
+SYMBOL(int64_t, std::, )
+SYMBOL(int8_t, std::, )
+SYMBOL(int_fast16_t, std::, )
+SYMBOL(int_fast32_t, std::, )
+SYMBOL(int_fast64_t, std::, )
+SYMBOL(int_fast8_t, std::, )
+SYMBOL(int_least16_t, std::, )
+SYMBOL(int_least32_t, std::, )
+SYMBOL(int_least64_t, std::, )
+SYMBOL(int_least8_t, std::, )
 SYMBOL(integer_sequence, std::, )
 SYMBOL(integral_constant, std::, )
 SYMBOL(internal, std::, )
@@ -1150,6 +1163,18 @@
 SYMBOL(u32streampos, std::, )
 SYMBOL(u32string, std::, )
 SYMBOL(u32string_view, std::, )
+SYMBOL(uint16_t, std::, )
+SYMBOL(uint32_t, std::, )
+SYMBOL(uint64_t, std::, )
+SYMBOL(uint8_t, std::, )
+SYMBOL(uint_fast16_t, std::, )
+SYMBOL(uint_fast32_t, std::, )
+SYMBOL(uint_fast64_t, std::, )
+SYMBOL(uint_fast8_t, std::, )
+SYMBOL(uint_least16_t, std::, )
+SYMBOL(uint_least32_t, std::, )
+SYMBOL(uint_least64_t, std::, )
+SYMBOL(uint_least8_t, std::, )
 SYMBOL(uintmax_t, std::, )
 SYMBOL(uintptr_t, std::, )
 SYMBOL(uncaught_exceptions, std::, )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62527: [clangd] Remove the whitelist std symbols in CanonicalIncludes.

2019-05-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 201869.
hokein added a comment.

Remove more symbols.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62527

Files:
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp


Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -87,31 +87,14 @@
 }
 
 void addSystemHeadersMapping(CanonicalIncludes *Includes) {
-  static const std::vector> SymbolMap = {
-  // Map symbols in  to their preferred includes.
-  {"std::basic_filebuf", ""},
-  {"std::filebuf", ""},
-  {"std::wfilebuf", ""},
-  {"std::basic_istream", ""},
-  {"std::istream", ""},
-  {"std::wistream", ""},
-  {"std::basic_ostream", ""},
-  {"std::ostream", ""},
-  {"std::wostream", ""},
-  {"std::uint_least16_t", ""}, //  redeclares these
-  {"std::uint_least32_t", ""},
 #define SYMBOL(Name, NameSpace, Header) { #NameSpace#Name, #Header },
   #include "StdSymbolMap.inc"
 #undef SYMBOL
   };
-  for (const auto &Pair : SymbolMap)
-Includes->addSymbolMapping(Pair.first, Pair.second);
 
   // FIXME: remove the std header mapping once we support ambiguous symbols, 
now
   // it serves as a fallback to disambiguate:
   //   - symbols with mulitiple headers (e.g. std::move)
-  //   - symbols with a primary template in one header and a specialization in
-  // another (std::abs)
   static const std::vector>
   SystemHeaderMap = {
   {"include/__stddef_max_align_t.h", ""},


Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -87,31 +87,14 @@
 }
 
 void addSystemHeadersMapping(CanonicalIncludes *Includes) {
-  static const std::vector> SymbolMap = {
-  // Map symbols in  to their preferred includes.
-  {"std::basic_filebuf", ""},
-  {"std::filebuf", ""},
-  {"std::wfilebuf", ""},
-  {"std::basic_istream", ""},
-  {"std::istream", ""},
-  {"std::wistream", ""},
-  {"std::basic_ostream", ""},
-  {"std::ostream", ""},
-  {"std::wostream", ""},
-  {"std::uint_least16_t", ""}, //  redeclares these
-  {"std::uint_least32_t", ""},
 #define SYMBOL(Name, NameSpace, Header) { #NameSpace#Name, #Header },
   #include "StdSymbolMap.inc"
 #undef SYMBOL
   };
-  for (const auto &Pair : SymbolMap)
-Includes->addSymbolMapping(Pair.first, Pair.second);
 
   // FIXME: remove the std header mapping once we support ambiguous symbols, now
   // it serves as a fallback to disambiguate:
   //   - symbols with mulitiple headers (e.g. std::move)
-  //   - symbols with a primary template in one header and a specialization in
-  // another (std::abs)
   static const std::vector>
   SystemHeaderMap = {
   {"include/__stddef_max_align_t.h", ""},
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r361952 - [clangd] Remove the whitelist std symbols in CanonicalIncludes.

2019-05-29 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed May 29 05:08:11 2019
New Revision: 361952

URL: http://llvm.org/viewvc/llvm-project?rev=361952&view=rev
Log:
[clangd] Remove the whitelist std symbols in CanonicalIncludes.

Summary: These symbols have been included via StdSymbolMap.inc.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp

Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp?rev=361952&r1=361951&r2=361952&view=diff
==
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp Wed May 29 
05:08:11 2019
@@ -87,31 +87,14 @@ collectIWYUHeaderMaps(CanonicalIncludes
 }
 
 void addSystemHeadersMapping(CanonicalIncludes *Includes) {
-  static const std::vector> SymbolMap = {
-  // Map symbols in  to their preferred includes.
-  {"std::basic_filebuf", ""},
-  {"std::filebuf", ""},
-  {"std::wfilebuf", ""},
-  {"std::basic_istream", ""},
-  {"std::istream", ""},
-  {"std::wistream", ""},
-  {"std::basic_ostream", ""},
-  {"std::ostream", ""},
-  {"std::wostream", ""},
-  {"std::uint_least16_t", ""}, //  redeclares these
-  {"std::uint_least32_t", ""},
 #define SYMBOL(Name, NameSpace, Header) { #NameSpace#Name, #Header },
   #include "StdSymbolMap.inc"
 #undef SYMBOL
   };
-  for (const auto &Pair : SymbolMap)
-Includes->addSymbolMapping(Pair.first, Pair.second);
 
   // FIXME: remove the std header mapping once we support ambiguous symbols, 
now
   // it serves as a fallback to disambiguate:
   //   - symbols with mulitiple headers (e.g. std::move)
-  //   - symbols with a primary template in one header and a specialization in
-  // another (std::abs)
   static const std::vector>
   SystemHeaderMap = {
   {"include/__stddef_max_align_t.h", ""},


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


[PATCH] D62527: [clangd] Remove the whitelist std symbols in CanonicalIncludes.

2019-05-29 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE361952: [clangd] Remove the whitelist std symbols in 
CanonicalIncludes. (authored by hokein, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62527?vs=201869&id=201870#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D62527

Files:
  clangd/index/CanonicalIncludes.cpp


Index: clangd/index/CanonicalIncludes.cpp
===
--- clangd/index/CanonicalIncludes.cpp
+++ clangd/index/CanonicalIncludes.cpp
@@ -87,31 +87,14 @@
 }
 
 void addSystemHeadersMapping(CanonicalIncludes *Includes) {
-  static const std::vector> SymbolMap = {
-  // Map symbols in  to their preferred includes.
-  {"std::basic_filebuf", ""},
-  {"std::filebuf", ""},
-  {"std::wfilebuf", ""},
-  {"std::basic_istream", ""},
-  {"std::istream", ""},
-  {"std::wistream", ""},
-  {"std::basic_ostream", ""},
-  {"std::ostream", ""},
-  {"std::wostream", ""},
-  {"std::uint_least16_t", ""}, //  redeclares these
-  {"std::uint_least32_t", ""},
 #define SYMBOL(Name, NameSpace, Header) { #NameSpace#Name, #Header },
   #include "StdSymbolMap.inc"
 #undef SYMBOL
   };
-  for (const auto &Pair : SymbolMap)
-Includes->addSymbolMapping(Pair.first, Pair.second);
 
   // FIXME: remove the std header mapping once we support ambiguous symbols, 
now
   // it serves as a fallback to disambiguate:
   //   - symbols with mulitiple headers (e.g. std::move)
-  //   - symbols with a primary template in one header and a specialization in
-  // another (std::abs)
   static const std::vector>
   SystemHeaderMap = {
   {"include/__stddef_max_align_t.h", ""},


Index: clangd/index/CanonicalIncludes.cpp
===
--- clangd/index/CanonicalIncludes.cpp
+++ clangd/index/CanonicalIncludes.cpp
@@ -87,31 +87,14 @@
 }
 
 void addSystemHeadersMapping(CanonicalIncludes *Includes) {
-  static const std::vector> SymbolMap = {
-  // Map symbols in  to their preferred includes.
-  {"std::basic_filebuf", ""},
-  {"std::filebuf", ""},
-  {"std::wfilebuf", ""},
-  {"std::basic_istream", ""},
-  {"std::istream", ""},
-  {"std::wistream", ""},
-  {"std::basic_ostream", ""},
-  {"std::ostream", ""},
-  {"std::wostream", ""},
-  {"std::uint_least16_t", ""}, //  redeclares these
-  {"std::uint_least32_t", ""},
 #define SYMBOL(Name, NameSpace, Header) { #NameSpace#Name, #Header },
   #include "StdSymbolMap.inc"
 #undef SYMBOL
   };
-  for (const auto &Pair : SymbolMap)
-Includes->addSymbolMapping(Pair.first, Pair.second);
 
   // FIXME: remove the std header mapping once we support ambiguous symbols, now
   // it serves as a fallback to disambiguate:
   //   - symbols with mulitiple headers (e.g. std::move)
-  //   - symbols with a primary template in one header and a specialization in
-  // another (std::abs)
   static const std::vector>
   SystemHeaderMap = {
   {"include/__stddef_max_align_t.h", ""},
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62579: [Index] Compute correct symbol kind for variable templates

2019-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: kadircet.
Herald added subscribers: arphaman, jkorous.
Herald added a project: clang.

The index library itself seems to never pass variable templates as
input, however clangd does.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62579

Files:
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/lib/Index/IndexSymbol.cpp


Index: clang/lib/Index/IndexSymbol.cpp
===
--- clang/lib/Index/IndexSymbol.cpp
+++ clang/lib/Index/IndexSymbol.cpp
@@ -96,6 +96,13 @@
 Info.Properties |= (SymbolPropertySet)SymbolProperty::ProtocolInterface;
   }
 
+  if (auto *VT = dyn_cast(D)) {
+Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+Info.Lang = SymbolLanguage::CXX;
+// All other fields are filled from the templated decl.
+D = VT->getTemplatedDecl();
+  }
+
   if (const TagDecl *TD = dyn_cast(D)) {
 switch (TD->getTagKind()) {
 case TTK_Struct:
@@ -333,6 +340,23 @@
   Info.Lang = SymbolLanguage::CXX;
   }
   break;
+case Decl::ClassTemplatePartialSpecialization:
+case Decl::ClassScopeFunctionSpecialization:
+case Decl::ClassTemplateSpecialization:
+case Decl::CXXRecord:
+case Decl::Enum:
+case Decl::Record:
+  llvm_unreachable("records handled before");
+  break;
+case Decl::VarTemplateSpecialization:
+case Decl::VarTemplatePartialSpecialization:
+case Decl::ImplicitParam:
+case Decl::ParmVar:
+case Decl::Var:
+case Decl::VarTemplate:
+  llvm_unreachable("variables handled before");
+  break;
+// Other decls get the 'unknown' kind.
 default:
   break;
 }
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -463,6 +463,26 @@
   EXPECT_THAT(
   Results.Completions,
   UnorderedElementsAre(AllOf(Named("a"), 
Kind(CompletionItemKind::Field;
+
+  // Completion kinds for templates should not be unknown.
+  Results = completions(
+  R"cpp(
+template  struct complete_class {};
+template  void complete_function();
+template  using complete_type_alias = int;
+template  int complete_variable = 10;
+
+auto x = complete_^
+  )cpp");
+  EXPECT_THAT(
+  Results.Completions,
+  UnorderedElementsAre(
+  AllOf(Named("complete_class"), Kind(CompletionItemKind::Class)),
+  AllOf(Named("complete_function"), 
Kind(CompletionItemKind::Function)),
+  AllOf(Named("complete_type_alias"),
+Kind(CompletionItemKind::Reference)),
+  AllOf(Named("complete_variable"),
+Kind(CompletionItemKind::Variable;
 }
 
 TEST(CompletionTest, NoDuplicates) {


Index: clang/lib/Index/IndexSymbol.cpp
===
--- clang/lib/Index/IndexSymbol.cpp
+++ clang/lib/Index/IndexSymbol.cpp
@@ -96,6 +96,13 @@
 Info.Properties |= (SymbolPropertySet)SymbolProperty::ProtocolInterface;
   }
 
+  if (auto *VT = dyn_cast(D)) {
+Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+Info.Lang = SymbolLanguage::CXX;
+// All other fields are filled from the templated decl.
+D = VT->getTemplatedDecl();
+  }
+
   if (const TagDecl *TD = dyn_cast(D)) {
 switch (TD->getTagKind()) {
 case TTK_Struct:
@@ -333,6 +340,23 @@
   Info.Lang = SymbolLanguage::CXX;
   }
   break;
+case Decl::ClassTemplatePartialSpecialization:
+case Decl::ClassScopeFunctionSpecialization:
+case Decl::ClassTemplateSpecialization:
+case Decl::CXXRecord:
+case Decl::Enum:
+case Decl::Record:
+  llvm_unreachable("records handled before");
+  break;
+case Decl::VarTemplateSpecialization:
+case Decl::VarTemplatePartialSpecialization:
+case Decl::ImplicitParam:
+case Decl::ParmVar:
+case Decl::Var:
+case Decl::VarTemplate:
+  llvm_unreachable("variables handled before");
+  break;
+// Other decls get the 'unknown' kind.
 default:
   break;
 }
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -463,6 +463,26 @@
   EXPECT_THAT(
   Results.Completions,
   UnorderedElementsAre(AllOf(Named("a"), Kind(CompletionItemKind::Field;
+
+  // Completion kinds for templates should not be unknown.
+  Results = completions(
+  R"cpp(
+template  struct complete_class {};
+template  void complete_function();
+template  using complete_type_alias = int;
+template  int complete_

r361955 - [LibTooling] Add `before` and `after` selectors for selecting point-ranges relative to nodes.

2019-05-29 Thread Yitzhak Mandelbaum via cfe-commits
Author: ymandel
Date: Wed May 29 05:40:36 2019
New Revision: 361955

URL: http://llvm.org/viewvc/llvm-project?rev=361955&view=rev
Log:
[LibTooling] Add `before` and `after` selectors for selecting point-ranges 
relative to nodes.

Summary:
The `before` and `after` selectors allow users to specify a zero-length range --
a point -- at the relevant location in an AST-node's source.  Point ranges can
be useful, for example, to insert a change using an API that takes a range to be
modified (e.g. `tooling::change()`).

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h
cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp

Modified: cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h?rev=361955&r1=361954&r2=361955&view=diff
==
--- cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h (original)
+++ cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h Wed May 29 
05:40:36 2019
@@ -37,6 +37,15 @@ RangeSelector range(RangeSelector Begin,
 /// Convenience version of \c range where end-points are bound nodes.
 RangeSelector range(std::string BeginID, std::string EndID);
 
+/// Selects the (empty) range [B,B) when \p Selector selects the range [B,E).
+RangeSelector before(RangeSelector Selector);
+
+/// Selects the the point immediately following \p Selector. That is, the
+/// (empty) range [E,E), when \p Selector selects either
+/// * the CharRange [B,E) or
+/// * the TokenRange [B,E'] where the token at E' spans the range [E,E').
+RangeSelector after(RangeSelector Selector);
+
 /// Selects a node, including trailing semicolon (for non-expression
 /// statements). \p ID is the node's binding in the match result.
 RangeSelector node(std::string ID);

Modified: cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp?rev=361955&r1=361954&r2=361955&view=diff
==
--- cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp Wed May 29 05:40:36 2019
@@ -104,6 +104,28 @@ static SourceLocation findOpenParen(cons
   return findPreviousTokenKind(EndLoc, SM, LangOpts, tok::TokenKind::l_paren);
 }
 
+RangeSelector tooling::before(RangeSelector Selector) {
+  return [Selector](const MatchResult &Result) -> Expected {
+Expected SelectedRange = Selector(Result);
+if (!SelectedRange)
+  return SelectedRange.takeError();
+return CharSourceRange::getCharRange(SelectedRange->getBegin());
+  };
+}
+
+RangeSelector tooling::after(RangeSelector Selector) {
+  return [Selector](const MatchResult &Result) -> Expected {
+Expected SelectedRange = Selector(Result);
+if (!SelectedRange)
+  return SelectedRange.takeError();
+if (SelectedRange->isCharRange())
+  return CharSourceRange::getCharRange(SelectedRange->getEnd());
+return CharSourceRange::getCharRange(Lexer::getLocForEndOfToken(
+SelectedRange->getEnd(), 0, Result.Context->getSourceManager(),
+Result.Context->getLangOpts()));
+  };
+}
+
 RangeSelector tooling::node(std::string ID) {
   return [ID](const MatchResult &Result) -> Expected {
 Expected Node = getNode(Result.Nodes, ID);

Modified: cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp?rev=361955&r1=361954&r2=361955&view=diff
==
--- cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp Wed May 29 05:40:36 2019
@@ -21,13 +21,15 @@ using namespace tooling;
 using namespace ast_matchers;
 
 namespace {
-using ::testing::AllOf;
-using ::testing::HasSubstr;
-using MatchResult = MatchFinder::MatchResult;
 using ::llvm::Expected;
 using ::llvm::Failed;
 using ::llvm::HasValue;
 using ::llvm::StringError;
+using ::testing::AllOf;
+using ::testing::HasSubstr;
+using ::testing::Property;
+
+using MatchResult = MatchFinder::MatchResult;
 
 struct TestMatch {
   // The AST unit from which `result` is built. We bundle it because it backs
@@ -117,6 +119,55 @@ TEST(RangeSelectorTest, UnboundNode) {
Failed(withUnboundNodeMessage()));
 }
 
+MATCHER_P(EqualsCharSourceRange, Range, "") {
+  return Range.getAsRange() == arg.getAsRange() &&
+ Range.isTokenRange() == arg.isTokenRange();
+}
+
+// FIXME: here and elsewhere: use llvm::Annotations library to explicitly mark
+// points and ranges of interest, enabling more readab

[PATCH] D62419: [LibTooling] Add `before` and `after` selectors for selecting point-ranges relative to nodes.

2019-05-29 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ymandel marked 2 inline comments as done.
Closed by commit rL361955: [LibTooling] Add `before` and `after` selectors for 
selecting point-ranges… (authored by ymandel, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62419?vs=201315&id=201877#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62419

Files:
  cfe/trunk/include/clang/Tooling/Refactoring/RangeSelector.h
  cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
  cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp

Index: cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
===
--- cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
+++ cfe/trunk/lib/Tooling/Refactoring/RangeSelector.cpp
@@ -104,6 +104,28 @@
   return findPreviousTokenKind(EndLoc, SM, LangOpts, tok::TokenKind::l_paren);
 }
 
+RangeSelector tooling::before(RangeSelector Selector) {
+  return [Selector](const MatchResult &Result) -> Expected {
+Expected SelectedRange = Selector(Result);
+if (!SelectedRange)
+  return SelectedRange.takeError();
+return CharSourceRange::getCharRange(SelectedRange->getBegin());
+  };
+}
+
+RangeSelector tooling::after(RangeSelector Selector) {
+  return [Selector](const MatchResult &Result) -> Expected {
+Expected SelectedRange = Selector(Result);
+if (!SelectedRange)
+  return SelectedRange.takeError();
+if (SelectedRange->isCharRange())
+  return CharSourceRange::getCharRange(SelectedRange->getEnd());
+return CharSourceRange::getCharRange(Lexer::getLocForEndOfToken(
+SelectedRange->getEnd(), 0, Result.Context->getSourceManager(),
+Result.Context->getLangOpts()));
+  };
+}
+
 RangeSelector tooling::node(std::string ID) {
   return [ID](const MatchResult &Result) -> Expected {
 Expected Node = getNode(Result.Nodes, ID);
Index: cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp
===
--- cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp
+++ cfe/trunk/unittests/Tooling/RangeSelectorTest.cpp
@@ -21,13 +21,15 @@
 using namespace ast_matchers;
 
 namespace {
-using ::testing::AllOf;
-using ::testing::HasSubstr;
-using MatchResult = MatchFinder::MatchResult;
 using ::llvm::Expected;
 using ::llvm::Failed;
 using ::llvm::HasValue;
 using ::llvm::StringError;
+using ::testing::AllOf;
+using ::testing::HasSubstr;
+using ::testing::Property;
+
+using MatchResult = MatchFinder::MatchResult;
 
 struct TestMatch {
   // The AST unit from which `result` is built. We bundle it because it backs
@@ -117,6 +119,55 @@
Failed(withUnboundNodeMessage()));
 }
 
+MATCHER_P(EqualsCharSourceRange, Range, "") {
+  return Range.getAsRange() == arg.getAsRange() &&
+ Range.isTokenRange() == arg.isTokenRange();
+}
+
+// FIXME: here and elsewhere: use llvm::Annotations library to explicitly mark
+// points and ranges of interest, enabling more readable tests.
+TEST(RangeSelectorTest, BeforeOp) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
+  )cc";
+  StringRef Call = "call";
+  TestMatch Match = matchCode(Code, callExpr().bind(Call));
+  const auto* E = Match.Result.Nodes.getNodeAs(Call);
+  assert(E != nullptr);
+  auto ExprBegin = E->getSourceRange().getBegin();
+  EXPECT_THAT_EXPECTED(
+  before(node(Call))(Match.Result),
+  HasValue(EqualsCharSourceRange(
+  CharSourceRange::getCharRange(ExprBegin, ExprBegin;
+}
+
+TEST(RangeSelectorTest, AfterOp) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
+  )cc";
+  StringRef Call = "call";
+  TestMatch Match = matchCode(Code, callExpr().bind(Call));
+  const auto* E = Match.Result.Nodes.getNodeAs(Call);
+  assert(E != nullptr);
+  const SourceRange Range = E->getSourceRange();
+  // The end token, a right paren, is one character wide, so advance by one,
+  // bringing us to the semicolon.
+  const SourceLocation SemiLoc = Range.getEnd().getLocWithOffset(1);
+  const auto ExpectedAfter = CharSourceRange::getCharRange(SemiLoc, SemiLoc);
+
+  // Test with a char range.
+  auto CharRange = CharSourceRange::getCharRange(Range.getBegin(), SemiLoc);
+  EXPECT_THAT_EXPECTED(after(charRange(CharRange))(Match.Result),
+   HasValue(EqualsCharSourceRange(ExpectedAfter)));
+
+  // Test with a token range.
+  auto TokenRange = CharSourceRange::getTokenRange(Range);
+  EXPECT_THAT_EXPECTED(after(charRange(TokenRange))(Match.Result),
+   HasValue(EqualsCharSourceRange(ExpectedAfter)));
+}
+
 TEST(RangeSelectorTest, RangeOp) {
   StringRef Code = R"cc(
 int f(int x, int y, 

[PATCH] D62582: [CodeComplete] Improve overload handling for C++ qualified and ref-qualified methods.

2019-05-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- when a method is not available because of the target value kind (e.g. an && 
method on a Foo& variable), then don't offer it.
- when a method is effectively shadowed by another method from the same class 
with a) an identical argument list and b) superior qualifiers, then don't offer 
it.


Repository:
  rC Clang

https://reviews.llvm.org/D62582

Files:
  lib/Sema/SemaCodeComplete.cpp
  test/CodeCompletion/member-access.cpp

Index: test/CodeCompletion/member-access.cpp
===
--- test/CodeCompletion/member-access.cpp
+++ test/CodeCompletion/member-access.cpp
@@ -210,3 +210,54 @@
 // CHECK-CC9: memfun2 (InBase) : [#void#][#Base3::#]memfun2(<#int#>) (requires fix-it: {181:4-181:5} to "->")
 // CHECK-CC9: memfun3 : [#int#]memfun3(<#int#>) (requires fix-it: {181:4-181:5} to "->")
 // CHECK-CC9: operator-> : [#Derived *#]operator->()[# const#]
+
+// These overload sets differ only by return type and this-qualifiers.
+// So for any given callsite, only one is available.
+struct Overloads {
+  int ConstOverload(char) const;
+  double ConstOverload(char);
+
+  int RefOverload(char) &;
+  double RefOverload(char) const&;
+  char RefOverload(char) &&;
+};
+void testLValue(Overloads& Ref) {
+  Ref.
+}
+void testConstLValue(const Overloads& ConstRef) {
+  ConstRef.
+}
+void testRValue() {
+  Overloads().
+}
+void testXValue(Overloads& X) {
+  static_cast(X).
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:225:7 %s -o - | FileCheck -check-prefix=CHECK-LVALUE %s \
+// RUN: --implicit-check-not="[#int#]ConstOverload(" \
+// RUN: --implicit-check-not="[#double#]RefOverload(" \
+// RUN: --implicit-check-not="[#char#]RefOverload("
+// CHECK-LVALUE-DAG: [#double#]ConstOverload(
+// CHECK-LVALUE-DAG: [#int#]RefOverload(
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:228:12 %s -o - | FileCheck -check-prefix=CHECK-CONSTLVALUE %s \
+// RUN: --implicit-check-not="[#double#]ConstOverload(" \
+// RUN: --implicit-check-not="[#int#]RefOverload(" \
+// RUN: --implicit-check-not="[#char#]RefOverload("
+// CHECK-CONSTLVALUE: [#int#]ConstOverload(
+// CHECK-CONSTLVALUE: [#double#]RefOverload(
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:231:15 %s -o - | FileCheck -check-prefix=CHECK-PRVALUE %s \
+// RUN: --implicit-check-not="[#int#]ConstOverload(" \
+// RUN: --implicit-check-not="[#int#]RefOverload(" \
+// RUN: --implicit-check-not="[#double#]RefOverload("
+// CHECK-PRVALUE: [#double#]ConstOverload(
+// CHECK-PRVALUE: [#char#]RefOverload(
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:234:31 %s -o - | FileCheck -check-prefix=CHECK-XVALUE %s \
+// RUN: --implicit-check-not="[#int#]ConstOverload(" \
+// RUN: --implicit-check-not="[#int#]RefOverload(" \
+// RUN: --implicit-check-not="[#double#]RefOverload("
+// CHECK-XVALUE: [#double#]ConstOverload(
+// CHECK-XVALUE: [#char#]RefOverload(
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -16,7 +16,9 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/QualTypeNames.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/Preprocessor.h"
@@ -152,9 +154,16 @@
   /// different levels of, e.g., the inheritance hierarchy.
   std::list ShadowMaps;
 
+  /// Overloaded C++ member functions found by SemaLookup.
+  /// Used to determine when one overload is dominated by another.
+  llvm::DenseMap, ShadowMapEntry>
+  OverloadMap;
+
   /// If we're potentially referring to a C++ member function, the set
   /// of qualifiers applied to the object type.
   Qualifiers ObjectTypeQualifiers;
+  /// The kind of the object expression, for rvalue/lvalue overloads.
+  ExprValueKind ObjectKind;
 
   /// Whether the \p ObjectTypeQualifiers field is active.
   bool HasObjectTypeQualifiers;
@@ -230,8 +239,9 @@
   /// out member functions that aren't available (because there will be a
   /// cv-qualifier mismatch) or prefer functions with an exact qualifier
   /// match.
-  void setObjectTypeQualifiers(Qualifiers Quals) {
+  void setObjectTypeQualifiers(Qualifiers Quals, ExprValueKind Kind) {
 ObjectTypeQualifiers = Quals;
+ObjectKind = Kind;
 HasObjectTypeQualifiers = true;
   }
 
@@ -1157,6 +1167,47 @@
   R.InBaseClass = true;
 }
 
+// Will Object.Candidate() always be called instead of Object.Incumbent()?
+// Precondition: must have the same name, and not be a template.
+static bool overloadDominates(const CXXMethodDecl &Candidate,
+  const CXXMethodDecl &Incumbent,
+  const Qualifiers &Ob

[PATCH] D62584: [OpenCL][PR42033] Deducing addr space of pointer/reference with template parameter types

2019-05-29 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: rjmccall, mantognini.
Herald added subscribers: ebevhan, yaxunl.

If dependent types appear in pointers or references we have to allow the addr 
space deduction because the addr space in template argument will belong to the 
pointee and not the pointer or reference itself. Hence we end up with 
un-deduced i.e. `Default` address space.


https://reviews.llvm.org/D62584

Files:
  lib/Sema/SemaType.cpp
  test/SemaOpenCLCXX/address-space-deduction.cl


Index: test/SemaOpenCLCXX/address-space-deduction.cl
===
--- test/SemaOpenCLCXX/address-space-deduction.cl
+++ test/SemaOpenCLCXX/address-space-deduction.cl
@@ -10,3 +10,16 @@
   //CHECK: `-VarDecl {{.*}} foo2 'const __global int' static constexpr cinit
   static constexpr int foo2 = 0;
 };
+
+template 
+void xxx(T *in) {
+  // This pointer can't be deduced to generic because addr space
+  // will be taken from the template argument.
+  //CHECK: `-VarDecl {{.*}} i 'T *' cinit
+  T *i = in;
+}
+
+__kernel void test() {
+  int foo[10];
+  xxx(&foo[0]);
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7360,7 +7360,9 @@
   (T->isVoidType() && !IsPointee) ||
   // Do not deduce addr spaces for dependent types because they might end
   // up instantiating to a type with an explicit address space qualifier.
-  T->isDependentType() ||
+  // Expect for pointer or reference types because the addr space in
+  // template argument can only belong to a pointee.
+  (T->isDependentType() && !T->isPointerType() && !T->isReferenceType()) ||
   // Do not deduce addr space of decltype because it will be taken from
   // its argument.
   T->isDecltypeType() ||


Index: test/SemaOpenCLCXX/address-space-deduction.cl
===
--- test/SemaOpenCLCXX/address-space-deduction.cl
+++ test/SemaOpenCLCXX/address-space-deduction.cl
@@ -10,3 +10,16 @@
   //CHECK: `-VarDecl {{.*}} foo2 'const __global int' static constexpr cinit
   static constexpr int foo2 = 0;
 };
+
+template 
+void xxx(T *in) {
+  // This pointer can't be deduced to generic because addr space
+  // will be taken from the template argument.
+  //CHECK: `-VarDecl {{.*}} i 'T *' cinit
+  T *i = in;
+}
+
+__kernel void test() {
+  int foo[10];
+  xxx(&foo[0]);
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7360,7 +7360,9 @@
   (T->isVoidType() && !IsPointee) ||
   // Do not deduce addr spaces for dependent types because they might end
   // up instantiating to a type with an explicit address space qualifier.
-  T->isDependentType() ||
+  // Expect for pointer or reference types because the addr space in
+  // template argument can only belong to a pointee.
+  (T->isDependentType() && !T->isPointerType() && !T->isReferenceType()) ||
   // Do not deduce addr space of decltype because it will be taken from
   // its argument.
   T->isDecltypeType() ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r361959 - clang-cl: Fix mangling of catchable types with names longer than 4kiB

2019-05-29 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed May 29 06:48:19 2019
New Revision: 361959

URL: http://llvm.org/viewvc/llvm-project?rev=361959&view=rev
Log:
clang-cl: Fix mangling of catchable types with names longer than 4kiB

The mangling used to contain the MD5 name of both the RTTI type
descriptor and the name of the copy ctor in MSVC2013, but it changed
to just the former in 2015. It looks like it changed back to the old
mangling in VS2017 version 15.7 and onwards, including VS2019 (version
16.0). VS2017 version 15.0 still has the VS2015 mangling. Versions
between 15.0 and 15.7 are't on godbolt. I found 15.4 (_MSC_VER 1911)
locally and that uses the 15.0 mangling still, but I didn't find 15.5 or
15.6, so I'm not sure where exactly it changed back.

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

Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/test/CodeGenCXX/mangle-ms-md5.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=361959&r1=361958&r2=361959&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Wed May 29 06:48:19 2019
@@ -109,7 +109,8 @@ public:
 MSVC2013 = 1800,
 MSVC2015 = 1900,
 MSVC2017 = 1910,
-MSVC2017_5 = 1912
+MSVC2017_5 = 1912,
+MSVC2017_7 = 1914,
   };
 
   /// Clang versions with different platform ABI conformance.

Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=361959&r1=361958&r2=361959&view=diff
==
--- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Wed May 29 06:48:19 2019
@@ -3151,12 +3151,18 @@ void MicrosoftMangleContextImpl::mangleC
   }
   Mangler.getStream() << RTTIMangling;
 
-  // VS2015 CTP6 omits the copy-constructor in the mangled name.  This name is,
-  // in fact, superfluous but I'm not sure the change was made consciously.
+  // VS2015 and VS2017.1 omit the copy-constructor in the mangled name but
+  // both older and newer versions include it.
+  // FIXME: It is known that the Ctor is present in 2013, and in 2017.7
+  // (_MSC_VER 1914) and newer, and that it's omitted in 2015 and 2017.4
+  // (_MSC_VER 1911), but it's unknown when exactly it reappeared (1914?
+  // Or 1912, 1913 aleady?).
+  bool OmitCopyCtor = getASTContext().getLangOpts().isCompatibleWithMSVC(
+  LangOptions::MSVC2015) &&
+  !getASTContext().getLangOpts().isCompatibleWithMSVC(
+  LangOptions::MSVC2017_7);
   llvm::SmallString<64> CopyCtorMangling;
-  if (!getASTContext().getLangOpts().isCompatibleWithMSVC(
-  LangOptions::MSVC2015) &&
-  CD) {
+  if (!OmitCopyCtor && CD) {
 llvm::raw_svector_ostream Stream(CopyCtorMangling);
 msvc_hashing_ostream MHO(Stream);
 mangleCXXCtor(CD, CT, MHO);

Modified: cfe/trunk/test/CodeGenCXX/mangle-ms-md5.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms-md5.cpp?rev=361959&r1=361958&r2=361959&view=diff
==
--- cfe/trunk/test/CodeGenCXX/mangle-ms-md5.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-ms-md5.cpp Wed May 29 06:48:19 2019
@@ -9,3 +9,18 @@ struct y
 
yyy

[PATCH] D62121: [PowerPC] [Clang] Port SSE intrinsics to PowerPC

2019-05-29 Thread Jinsong Ji via Phabricator via cfe-commits
jsji reopened this revision.
jsji added a comment.
This revision is now accepted and ready to land.

This has been reverted in https://reviews.llvm.org/rL361930 .


Repository:
  rC Clang

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

https://reviews.llvm.org/D62121



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


[PATCH] D62588: [OpenCL] Support logical vector operators in C++ mode

2019-05-29 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
Herald added subscribers: cfe-commits, yaxunl.
Herald added a project: clang.

Support logical operators on vectors in C++ for OpenCL mode, to
preserve backwards compatibility with OpenCL C.


Repository:
  rC Clang

https://reviews.llvm.org/D62588

Files:
  lib/Sema/SemaExpr.cpp
  test/CodeGenOpenCL/logical-ops.cl


Index: test/CodeGenOpenCL/logical-ops.cl
===
--- test/CodeGenOpenCL/logical-ops.cl
+++ test/CodeGenOpenCL/logical-ops.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL1.2 -O1 -triple 
x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=c++ -O1 -triple 
x86_64-unknown-linux-gnu | FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -10902,7 +10902,7 @@
   if (vType.isNull())
 return InvalidOperands(Loc, LHS, RHS);
   if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
-  vType->hasFloatingRepresentation())
+  !getLangOpts().OpenCLCPlusPlus && vType->hasFloatingRepresentation())
 return InvalidOperands(Loc, LHS, RHS);
   // FIXME: The check for C++ here is for GCC compatibility. GCC rejects the
   //usage of the logical operators && and || with vectors in C. This
@@ -13165,7 +13165,8 @@
   }
 } else if (resultType->isExtVectorType()) {
   if (Context.getLangOpts().OpenCL &&
-  Context.getLangOpts().OpenCLVersion < 120) {
+  Context.getLangOpts().OpenCLVersion < 120 &&
+  !Context.getLangOpts().OpenCLCPlusPlus) {
 // OpenCL v1.1 6.3.h: The logical operator not (!) does not
 // operate on vector float types.
 QualType T = resultType->getAs()->getElementType();


Index: test/CodeGenOpenCL/logical-ops.cl
===
--- test/CodeGenOpenCL/logical-ops.cl
+++ test/CodeGenOpenCL/logical-ops.cl
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=CL1.2 -O1 -triple x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -cl-std=c++ -O1 -triple x86_64-unknown-linux-gnu | FileCheck %s
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -10902,7 +10902,7 @@
   if (vType.isNull())
 return InvalidOperands(Loc, LHS, RHS);
   if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
-  vType->hasFloatingRepresentation())
+  !getLangOpts().OpenCLCPlusPlus && vType->hasFloatingRepresentation())
 return InvalidOperands(Loc, LHS, RHS);
   // FIXME: The check for C++ here is for GCC compatibility. GCC rejects the
   //usage of the logical operators && and || with vectors in C. This
@@ -13165,7 +13165,8 @@
   }
 } else if (resultType->isExtVectorType()) {
   if (Context.getLangOpts().OpenCL &&
-  Context.getLangOpts().OpenCLVersion < 120) {
+  Context.getLangOpts().OpenCLVersion < 120 &&
+  !Context.getLangOpts().OpenCLCPlusPlus) {
 // OpenCL v1.1 6.3.h: The logical operator not (!) does not
 // operate on vector float types.
 QualType T = resultType->getAs()->getElementType();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62121: [PowerPC] [Clang] Port SSE intrinsics to PowerPC

2019-05-29 Thread Jinsong Ji via Phabricator via cfe-commits
jsji requested changes to this revision.
jsji added a comment.
This revision now requires changes to proceed.

   TEST 'Clang :: CodeGen/ppc-mm-malloc.c' FAILED 

  Script:
  --
  : 'RUN: at line 9';   
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/build/stage1/bin/clang -S 
-emit-llvm 
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/test/CodeGen/ppc-mm-malloc.c
 -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt | 
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/build/stage1/bin/FileCheck 
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/test/CodeGen/ppc-mm-malloc.c
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/test/CodeGen/ppc-mm-malloc.c:21:11:
 error: CHECK: expected string not found in input
  // CHECK: define internal i8* @_mm_malloc(i64 [[REG1:[0-9a-zA-Z_%.]+]], i64 
[[REG2:[0-9a-zA-Z_%.]+]])
^
  :7:38: note: scanning from here
  define dso_local void @test_mm_malloc() #0 {
   ^
  :18:1: note: possible intended match here
  define internal noalias i8* @_mm_malloc(i64 %__size, i64 %__align) #1 {
  ^
  
  --
  
  
  Testing: 0 .. 10..
  FAIL: Clang :: Headers/ppc-sse-intrinsics.c (9324 of 48401)
   TEST 'Clang :: Headers/ppc-sse-intrinsics.c' FAILED 

  Script:
  --
  : 'RUN: at line 10';   
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/build/stage1/bin/clang -S 
-emit-llvm -DNO_WARN_X86_INTRINSICS 
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/test/Headers/ppc-sse-intrinsics.c
 -mcpu=pwr7 -Xclang -verify
  : 'RUN: at line 11';   
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/build/stage1/bin/clang -S 
-emit-llvm -DNO_WARN_X86_INTRINSICS 
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/test/Headers/ppc-sse-intrinsics.c
 -mcpu=pwr7 -Xclang -verify -x c++
  : 'RUN: at line 14';   not 
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/build/stage1/bin/clang -S 
-emit-llvm 
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/test/Headers/ppc-sse-intrinsics.c
 -mcpu=pwr7 -o /dev/null 2>&1 | 
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/build/stage1/bin/FileCheck 
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/test/Headers/ppc-sse-intrinsics.c
 -check-prefix=SSE-ERROR
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  clang-9: warning: argument unused during compilation: '-mcpu=pwr7' 
[-Wunused-command-line-argument]
  clang-9: warning: argument unused during compilation: '-mcpu=pwr7' 
[-Wunused-command-line-argument]
  
/home/buildslave/buildslave1a/clang-with-lto-ubuntu/llvm.src/tools/clang/test/Headers/ppc-sse-intrinsics.c:20:15:
 error: SSE-ERROR: expected string not found in input
  // SSE-ERROR: xmmintrin.h:{{[0-9]+}}:{{[0-9]+}}: error: "Please read comment 
above. Use -DNO_WARN_X86_INTRINSICS to disable this error."
^
  :1:1: note: scanning from here
  clang-9: warning: argument unused during compilation: '-mcpu=pwr7' 
[-Wunused-command-line-argument]
  ^


Repository:
  rC Clang

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

https://reviews.llvm.org/D62121



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


[PATCH] D62490: clang-cl: Fix mangling of catchable types with names longer than 4kiB

2019-05-29 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361959: clang-cl: Fix mangling of catchable types with names 
longer than 4kiB (authored by nico, committed by ).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D62490?vs=201544&id=201904#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62490

Files:
  include/clang/Basic/LangOptions.h
  lib/AST/MicrosoftMangle.cpp
  test/CodeGenCXX/mangle-ms-md5.cpp


Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -3151,12 +3151,18 @@
   }
   Mangler.getStream() << RTTIMangling;
 
-  // VS2015 CTP6 omits the copy-constructor in the mangled name.  This name is,
-  // in fact, superfluous but I'm not sure the change was made consciously.
+  // VS2015 and VS2017.1 omit the copy-constructor in the mangled name but
+  // both older and newer versions include it.
+  // FIXME: It is known that the Ctor is present in 2013, and in 2017.7
+  // (_MSC_VER 1914) and newer, and that it's omitted in 2015 and 2017.4
+  // (_MSC_VER 1911), but it's unknown when exactly it reappeared (1914?
+  // Or 1912, 1913 aleady?).
+  bool OmitCopyCtor = getASTContext().getLangOpts().isCompatibleWithMSVC(
+  LangOptions::MSVC2015) &&
+  !getASTContext().getLangOpts().isCompatibleWithMSVC(
+  LangOptions::MSVC2017_7);
   llvm::SmallString<64> CopyCtorMangling;
-  if (!getASTContext().getLangOpts().isCompatibleWithMSVC(
-  LangOptions::MSVC2015) &&
-  CD) {
+  if (!OmitCopyCtor && CD) {
 llvm::raw_svector_ostream Stream(CopyCtorMangling);
 msvc_hashing_ostream MHO(Stream);
 mangleCXXCtor(CD, CT, MHO);
Index: include/clang/Basic/LangOptions.h
===
--- include/clang/Basic/LangOptions.h
+++ include/clang/Basic/LangOptions.h
@@ -109,7 +109,8 @@
 MSVC2013 = 1800,
 MSVC2015 = 1900,
 MSVC2017 = 1910,
-MSVC2017_5 = 1912
+MSVC2017_5 = 1912,
+MSVC2017_7 = 1914,
   };
 
   /// Clang versions with different platform ABI conformance.
Index: test/CodeGenCXX/mangle-ms-md5.cpp
===
--- test/CodeGenCXX/mangle-ms-md5.cpp
+++ test/CodeGenCXX/mangle-ms-md5.cpp
@@ -9,3 +9,18 @@
 
y

[PATCH] D62588: [OpenCL] Support logical vector operators in C++ mode

2019-05-29 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D62588



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


[PATCH] D62591: [OpenCL][PR42031] Prevent deducing addr space in type alias.

2019-05-29 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.
Anastasia added reviewers: rjmccall, mantognini.
Herald added subscribers: ebevhan, yaxunl.

Similar to typedefs we shouldn't deduce addr space in type alias.


https://reviews.llvm.org/D62591

Files:
  lib/Sema/SemaType.cpp
  test/SemaOpenCLCXX/address-space-deduction.cl


Index: test/SemaOpenCLCXX/address-space-deduction.cl
===
--- test/SemaOpenCLCXX/address-space-deduction.cl
+++ test/SemaOpenCLCXX/address-space-deduction.cl
@@ -23,3 +23,13 @@
   int foo[10];
   xxx(&foo[0]);
 }
+
+struct c1 {};
+
+// We don't deduce addr space in type alias.
+//CHECK: TypeAliasDecl {{.*}} referenced alias_c1 'c1'
+using alias_c1 = c1;
+
+struct c2 {
+  alias_c1 y;
+};
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7350,6 +7350,9 @@
   (D.getContext() == DeclaratorContext::MemberContext &&
(!IsPointee &&
 D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static)) ||
+  // Do not deduce if we are in type alias because it doesn't define any
+  // object.
+  (D.getContext() == DeclaratorContext::AliasDeclContext) ||
   // Do not deduce addr space for types used to define a typedef and the
   // typedef itself, except the pointee type of a pointer type which is 
used
   // to define the typedef.


Index: test/SemaOpenCLCXX/address-space-deduction.cl
===
--- test/SemaOpenCLCXX/address-space-deduction.cl
+++ test/SemaOpenCLCXX/address-space-deduction.cl
@@ -23,3 +23,13 @@
   int foo[10];
   xxx(&foo[0]);
 }
+
+struct c1 {};
+
+// We don't deduce addr space in type alias.
+//CHECK: TypeAliasDecl {{.*}} referenced alias_c1 'c1'
+using alias_c1 = c1;
+
+struct c2 {
+  alias_c1 y;
+};
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7350,6 +7350,9 @@
   (D.getContext() == DeclaratorContext::MemberContext &&
(!IsPointee &&
 D.getDeclSpec().getStorageClassSpec() != DeclSpec::SCS_static)) ||
+  // Do not deduce if we are in type alias because it doesn't define any
+  // object.
+  (D.getContext() == DeclaratorContext::AliasDeclContext) ||
   // Do not deduce addr space for types used to define a typedef and the
   // typedef itself, except the pointee type of a pointer type which is used
   // to define the typedef.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r361960 - [clangd] Fix buildbot error.

2019-05-29 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed May 29 07:11:53 2019
New Revision: 361960

URL: http://llvm.org/viewvc/llvm-project?rev=361960&view=rev
Log:
[clangd] Fix buildbot error.

Modified:
clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp

Modified: clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp?rev=361960&r1=361959&r2=361960&view=diff
==
--- clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/CanonicalIncludes.cpp Wed May 29 
07:11:53 2019
@@ -87,11 +87,15 @@ collectIWYUHeaderMaps(CanonicalIncludes
 }
 
 void addSystemHeadersMapping(CanonicalIncludes *Includes) {
+  static const std::vector> SymbolMap = {
 #define SYMBOL(Name, NameSpace, Header) { #NameSpace#Name, #Header },
   #include "StdSymbolMap.inc"
 #undef SYMBOL
   };
 
+  for (const auto &Pair : SymbolMap)
+Includes->addSymbolMapping(Pair.first, Pair.second);
+
   // FIXME: remove the std header mapping once we support ambiguous symbols, 
now
   // it serves as a fallback to disambiguate:
   //   - symbols with mulitiple headers (e.g. std::move)


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


[PATCH] D62582: [CodeComplete] Improve overload handling for C++ qualified and ref-qualified methods.

2019-05-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 201910.
sammccall added a comment.

Remove debug


Repository:
  rC Clang

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

https://reviews.llvm.org/D62582

Files:
  lib/Sema/SemaCodeComplete.cpp
  test/CodeCompletion/member-access.cpp

Index: test/CodeCompletion/member-access.cpp
===
--- test/CodeCompletion/member-access.cpp
+++ test/CodeCompletion/member-access.cpp
@@ -210,3 +210,54 @@
 // CHECK-CC9: memfun2 (InBase) : [#void#][#Base3::#]memfun2(<#int#>) (requires fix-it: {181:4-181:5} to "->")
 // CHECK-CC9: memfun3 : [#int#]memfun3(<#int#>) (requires fix-it: {181:4-181:5} to "->")
 // CHECK-CC9: operator-> : [#Derived *#]operator->()[# const#]
+
+// These overload sets differ only by return type and this-qualifiers.
+// So for any given callsite, only one is available.
+struct Overloads {
+  int ConstOverload(char) const;
+  double ConstOverload(char);
+
+  int RefOverload(char) &;
+  double RefOverload(char) const&;
+  char RefOverload(char) &&;
+};
+void testLValue(Overloads& Ref) {
+  Ref.
+}
+void testConstLValue(const Overloads& ConstRef) {
+  ConstRef.
+}
+void testRValue() {
+  Overloads().
+}
+void testXValue(Overloads& X) {
+  static_cast(X).
+}
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:225:7 %s -o - | FileCheck -check-prefix=CHECK-LVALUE %s \
+// RUN: --implicit-check-not="[#int#]ConstOverload(" \
+// RUN: --implicit-check-not="[#double#]RefOverload(" \
+// RUN: --implicit-check-not="[#char#]RefOverload("
+// CHECK-LVALUE-DAG: [#double#]ConstOverload(
+// CHECK-LVALUE-DAG: [#int#]RefOverload(
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:228:12 %s -o - | FileCheck -check-prefix=CHECK-CONSTLVALUE %s \
+// RUN: --implicit-check-not="[#double#]ConstOverload(" \
+// RUN: --implicit-check-not="[#int#]RefOverload(" \
+// RUN: --implicit-check-not="[#char#]RefOverload("
+// CHECK-CONSTLVALUE: [#int#]ConstOverload(
+// CHECK-CONSTLVALUE: [#double#]RefOverload(
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:231:15 %s -o - | FileCheck -check-prefix=CHECK-PRVALUE %s \
+// RUN: --implicit-check-not="[#int#]ConstOverload(" \
+// RUN: --implicit-check-not="[#int#]RefOverload(" \
+// RUN: --implicit-check-not="[#double#]RefOverload("
+// CHECK-PRVALUE: [#double#]ConstOverload(
+// CHECK-PRVALUE: [#char#]RefOverload(
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:234:31 %s -o - | FileCheck -check-prefix=CHECK-XVALUE %s \
+// RUN: --implicit-check-not="[#int#]ConstOverload(" \
+// RUN: --implicit-check-not="[#int#]RefOverload(" \
+// RUN: --implicit-check-not="[#double#]RefOverload("
+// CHECK-XVALUE: [#double#]ConstOverload(
+// CHECK-XVALUE: [#char#]RefOverload(
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -16,7 +16,9 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/QualTypeNames.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Basic/Specifiers.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/Preprocessor.h"
@@ -152,9 +154,16 @@
   /// different levels of, e.g., the inheritance hierarchy.
   std::list ShadowMaps;
 
+  /// Overloaded C++ member functions found by SemaLookup.
+  /// Used to determine when one overload is dominated by another.
+  llvm::DenseMap, ShadowMapEntry>
+  OverloadMap;
+
   /// If we're potentially referring to a C++ member function, the set
   /// of qualifiers applied to the object type.
   Qualifiers ObjectTypeQualifiers;
+  /// The kind of the object expression, for rvalue/lvalue overloads.
+  ExprValueKind ObjectKind;
 
   /// Whether the \p ObjectTypeQualifiers field is active.
   bool HasObjectTypeQualifiers;
@@ -230,8 +239,9 @@
   /// out member functions that aren't available (because there will be a
   /// cv-qualifier mismatch) or prefer functions with an exact qualifier
   /// match.
-  void setObjectTypeQualifiers(Qualifiers Quals) {
+  void setObjectTypeQualifiers(Qualifiers Quals, ExprValueKind Kind) {
 ObjectTypeQualifiers = Quals;
+ObjectKind = Kind;
 HasObjectTypeQualifiers = true;
   }
 
@@ -1157,6 +1167,45 @@
   R.InBaseClass = true;
 }
 
+// Will Object.Candidate() always be called instead of Object.Incumbent()?
+// Precondition: must have the same name, and not be a template.
+static bool overloadDominates(const CXXMethodDecl &Candidate,
+  const CXXMethodDecl &Incumbent,
+  const Qualifiers &ObjectQuals,
+  ExprValueKind ObjectKind) {
+  if (Candidate.isVariadic() != Incumbent.isVariadic() ||
+  Candidate.getNumParams() != Incumbent.getNumParams() ||
+  Candidate.getMinRequiredArguments() !=
+  Incumbent.getMinRequiredArguments())

[PATCH] D62579: [Index] Compute correct symbol kind for variable templates

2019-05-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/lib/Index/IndexSymbol.cpp:99
 
+  if (auto *VT = dyn_cast(D)) {
+Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;

what about function and class templates? Are they handled in somewhere else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62579



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


r361967 - [mips] Check argument for __builtin_msa_ctcmsa / __builtin_msa_cfcmsa

2019-05-29 Thread Simon Atanasyan via cfe-commits
Author: atanasyan
Date: Wed May 29 07:59:32 2019
New Revision: 361967

URL: http://llvm.org/viewvc/llvm-project?rev=361967&view=rev
Log:
[mips] Check argument for __builtin_msa_ctcmsa / __builtin_msa_cfcmsa

The `__builtin_msa_ctcmsa` and `__builtin_msa_cfcmsa` builtins are mapped
to the `ctcmsa` and `cfcmsa` instructions respectively. While MSA
control registers have indexes in 0..7 range, the instructions accept
register index in 0..31 range [1].

[1] MIPS Architecture for Programmers Volume IV-j:
The MIPS64 SIMD Architecture Module
https://www.mips.com/?do-download=the-mips64-simd-architecture-module

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/CodeGen/builtins-mips-msa-error.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=361967&r1=361966&r2=361967&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed May 29 07:59:32 2019
@@ -3034,6 +3034,8 @@ bool Sema::CheckMipsBuiltinFunctionCall(
   // These intrinsics take an unsigned 5 bit immediate.
   // The first block of intrinsics actually have an unsigned 5 bit field,
   // not a df/n field.
+  case Mips::BI__builtin_msa_cfcmsa:
+  case Mips::BI__builtin_msa_ctcmsa: i = 0; l = 0; u = 31; break;
   case Mips::BI__builtin_msa_clei_u_b:
   case Mips::BI__builtin_msa_clei_u_h:
   case Mips::BI__builtin_msa_clei_u_w:

Modified: cfe/trunk/test/CodeGen/builtins-mips-msa-error.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-mips-msa-error.c?rev=361967&r1=361966&r2=361967&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-mips-msa-error.c (original)
+++ cfe/trunk/test/CodeGen/builtins-mips-msa-error.c Wed May 29 07:59:32 2019
@@ -77,6 +77,8 @@ void test(void) {
   v4i32_r = __msa_ceqi_w(v4i32_a, 16);   // expected-error 
{{argument value 16 is outside the valid range [-16, 15]}}
   v2i64_r = __msa_ceqi_d(v2i64_a, 16);   // expected-error 
{{argument value 16 is outside the valid range [-16, 15]}}
 
+  int_r = __msa_cfcmsa(32);  // expected-error 
{{argument value 32 is outside the valid range [0, 31]}}
+
   v16i8_r = __msa_clei_s_b(v16i8_a, 16); // expected-error 
{{argument value 16 is outside the valid range [-16, 15]}}
   v8i16_r = __msa_clei_s_h(v8i16_a, 16); // expected-error 
{{argument value 16 is outside the valid range [-16, 15]}}
   v4i32_r = __msa_clei_s_w(v4i32_a, 16); // expected-error 
{{argument value 16 is outside the valid range [-16, 15]}}
@@ -107,6 +109,8 @@ void test(void) {
   int_r = __msa_copy_u_w(v4u32_a, 4);// expected-error 
{{argument value 4 is outside the valid range [0, 3]}}
   ll_r  = __msa_copy_u_d(v2i64_a, 2);// expected-error 
{{argument value 2 is outside the valid range [0, 1]}}
 
+  __builtin_msa_ctcmsa(32, 777); // expected-error 
{{argument value 32 is outside the valid range [0, 31]}}
+
   v16i8_r = __msa_insve_b(v16i8_r, 16, v16i8_a); // expected-error 
{{argument value 16 is outside the valid range [0, 15]}}
   v8i16_r = __msa_insve_h(v8i16_r, 8, v8i16_a);  // expected-error 
{{argument value 8 is outside the valid range [0, 7]}}
   v4i32_r = __msa_insve_w(v4i32_r, 4, v4i32_a);  // expected-error 
{{argument value 4 is outside the valid range [0, 3]}}


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


[PATCH] D62579: [Index] Compute correct symbol kind for variable templates

2019-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/lib/Index/IndexSymbol.cpp:99
 
+  if (auto *VT = dyn_cast(D)) {
+Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;

kadircet wrote:
> what about function and class templates? Are they handled in somewhere else?
Yeah, they're handled in ifs and a large switch below. I tried unifying those 
cases (matching a `TemplateDecl` here instead of `VarTemplateDecl`), but they 
start producing different results for template classes and this function is 
**mostly** not called for templates from withing the index library (only for 
the underlying declarations) and it's only clangd that cares about the returned 
value in that case.

So I decided to make a minimal change that fixes clangd, but does not change 
behavior of the index library to avoid potential fallout of a more general fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62579



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


[clang-tools-extra] r361969 - [clangd] Map typedefs to the same LSP completion kind as VSCode

2019-05-29 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed May 29 08:10:19 2019
New Revision: 361969

URL: http://llvm.org/viewvc/llvm-project?rev=361969&view=rev
Log:
[clangd] Map typedefs to the same LSP completion kind as VSCode

For consistency and, more importantly, to get a nicer icon for those in VSCode.

Modified:
clang-tools-extra/trunk/clangd/CodeComplete.cpp

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=361969&r1=361968&r2=361969&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Wed May 29 08:10:19 2019
@@ -92,8 +92,10 @@ CompletionItemKind toCompletionItemKind(
   case SK::Extension:
   case SK::Union:
 return CompletionItemKind::Class;
-  // FIXME(ioeric): figure out whether reference is the right type for aliases.
   case SK::TypeAlias:
+// We use the same kind as the VSCode C++ extension.
+// FIXME: pick a better option when we have one.
+return CompletionItemKind::Interface;
   case SK::Using:
 return CompletionItemKind::Reference;
   case SK::Function:
@@ -481,7 +483,8 @@ private:
 return EmptyArgs ? "()" : "($0)";
   return *Snippet; // Not an arg snippet?
 }
-if (Completion.Kind == CompletionItemKind::Reference ||
+// 'CompletionItemKind::Interface' matches template type aliases.
+if (Completion.Kind == CompletionItemKind::Interface ||
 Completion.Kind == CompletionItemKind::Class) {
   if (Snippet->front() != '<')
 return *Snippet; // Not an arg snippet?


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


r361972 - [analyzer] print() JSONify: Store implementation

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 08:25:19 2019
New Revision: 361972

URL: http://llvm.org/viewvc/llvm-project?rev=361972&view=rev
Log:
[analyzer] print() JSONify: Store implementation

Summary: -

Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus

Reviewed By: NoQ

Subscribers: szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy,
 dkrupp

Tags: #clang

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

Added:
cfe/trunk/include/clang/Basic/JsonSupport.h
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/test/Analysis/expr-inspection.c

Added: cfe/trunk/include/clang/Basic/JsonSupport.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/JsonSupport.h?rev=361972&view=auto
==
--- cfe/trunk/include/clang/Basic/JsonSupport.h (added)
+++ cfe/trunk/include/clang/Basic/JsonSupport.h Wed May 29 08:25:19 2019
@@ -0,0 +1,27 @@
+//===- JsonSupport.h - JSON Output Utilities *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_JSONSUPPORT_H
+#define LLVM_CLANG_BASIC_JSONSUPPORT_H
+
+#include "clang/Basic/LLVM.h"
+#include "llvm/Support/raw_ostream.h"
+
+
+namespace clang {
+
+inline raw_ostream &Indent(raw_ostream &Out, const unsigned int Space,
+   bool IsDot) {
+  for (unsigned int I = 0; I < Space * 2; ++I)
+Out << (IsDot ? " " : " ");
+  return Out;
+}
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_JSONSUPPORT_H

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=361972&r1=361971&r2=361972&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
Wed May 29 08:25:19 2019
@@ -424,10 +424,12 @@ public:
   }
 
   // Pretty-printing.
-  void print(raw_ostream &Out, const char *nl = "\n", const char *sep = "",
- const LocationContext *CurrentLC = nullptr) const;
-  void printDOT(raw_ostream &Out,
-const LocationContext *CurrentLC = nullptr) const;
+  void printJson(raw_ostream &Out, const LocationContext *LCtx = nullptr,
+ const char *NL = "\n", const char *Sep = "",
+ unsigned int Space = 0, bool IsDot = false) const;
+
+  void printDOT(raw_ostream &Out, const LocationContext *LCtx = nullptr,
+unsigned int Space = 0) const;
 
   void dump() const;
 

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h?rev=361972&r1=361971&r2=361972&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h Wed May 
29 08:25:19 2019
@@ -253,7 +253,8 @@ public:
   virtual bool scanReachableSymbols(Store S, const MemRegion *R,
 ScanReachableSymbols &Visitor) = 0;
 
-  virtual void print(Store store, raw_ostream &Out, const char* nl) = 0;
+  virtual void printJson(raw_ostream &Out, Store S, const char *NL,
+ unsigned int Space, bool IsDot) const = 0;
 
   class BindingsHandler {
   public:

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp?rev=361972&r1=361971&r2=361972&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Wed May 29 08:25:19 2019
@@ -440,16 +440,16 @@ void ProgramState::setStore(const StoreR
 //  State pretty-printing.
 
//===--===//
 
-void ProgramState::print(raw_ostream &Out,
- const char *NL, const char *Sep,
- const LocationContext *LC) const {
+void ProgramState::printJson(raw_ostream &Out, const LocationContext *LCtx,
+ const char *NL

[PATCH] D61912: [analyzer] print() JSONify: Store implementation

2019-05-29 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361972: [analyzer] print() JSONify: Store implementation 
(authored by Charusso, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61912?vs=201564&id=201925#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D61912

Files:
  include/clang/Basic/JsonSupport.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/RegionStore.cpp
  test/Analysis/expr-inspection.c

Index: include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
@@ -253,7 +253,8 @@
   virtual bool scanReachableSymbols(Store S, const MemRegion *R,
 ScanReachableSymbols &Visitor) = 0;
 
-  virtual void print(Store store, raw_ostream &Out, const char* nl) = 0;
+  virtual void printJson(raw_ostream &Out, Store S, const char *NL,
+ unsigned int Space, bool IsDot) const = 0;
 
   class BindingsHandler {
   public:
Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -424,10 +424,12 @@
   }
 
   // Pretty-printing.
-  void print(raw_ostream &Out, const char *nl = "\n", const char *sep = "",
- const LocationContext *CurrentLC = nullptr) const;
-  void printDOT(raw_ostream &Out,
-const LocationContext *CurrentLC = nullptr) const;
+  void printJson(raw_ostream &Out, const LocationContext *LCtx = nullptr,
+ const char *NL = "\n", const char *Sep = "",
+ unsigned int Space = 0, bool IsDot = false) const;
+
+  void printDOT(raw_ostream &Out, const LocationContext *LCtx = nullptr,
+unsigned int Space = 0) const;
 
   void dump() const;
 
Index: include/clang/Basic/JsonSupport.h
===
--- include/clang/Basic/JsonSupport.h
+++ include/clang/Basic/JsonSupport.h
@@ -0,0 +1,27 @@
+//===- JsonSupport.h - JSON Output Utilities *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_JSONSUPPORT_H
+#define LLVM_CLANG_BASIC_JSONSUPPORT_H
+
+#include "clang/Basic/LLVM.h"
+#include "llvm/Support/raw_ostream.h"
+
+
+namespace clang {
+
+inline raw_ostream &Indent(raw_ostream &Out, const unsigned int Space,
+   bool IsDot) {
+  for (unsigned int I = 0; I < Space * 2; ++I)
+Out << (IsDot ? " " : " ");
+  return Out;
+}
+
+} // namespace clang
+
+#endif // LLVM_CLANG_BASIC_JSONSUPPORT_H
Index: test/Analysis/expr-inspection.c
===
--- test/Analysis/expr-inspection.c
+++ test/Analysis/expr-inspection.c
@@ -1,4 +1,6 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s 2>&1 | FileCheck %s
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=debug.ExprInspection \
+// RUN:  -verify %s 2>&1 | FileCheck %s
 
 // Self-tests for the debug.ExprInspection checker.
 
@@ -10,16 +12,26 @@
   clang_analyzer_dump(x); // expected-warning{{reg_$0}}
   clang_analyzer_dump(x + (-1)); // expected-warning{{(reg_$0) + -1}}
   int y = 1;
-  clang_analyzer_printState();
-  for (; y < 3; ++y)
+  for (; y < 3; ++y) {
 clang_analyzer_numTimesReached(); // expected-warning{{2}}
+
+if (y == 2) {
+  int z = x > 13;
+  if (!z)
+clang_analyzer_printState();
+}
+  }
 }
 
-// CHECK: Store (direct and default bindings)
-// CHECK-NEXT: (y,0,direct) : 1 S32b
+// CHECK:  "store": [
+// CHECK-NEXT:   { "cluster": "y", "items": [
+// CHECK-NEXT: { "kind": "Direct", "offset": 0, "value": "2 S32b" }
+// CHECK-NEXT:   ]}
+// CHECK-NEXT: ]
 
-// CHECK: Expressions by stack frame:
+// CHECK:  Expressions by stack frame:
 // CHECK-NEXT: #0 Calling foo
-// CHECK-NEXT: clang_analyzer_printState : &code{clang_analyzer_printState}
+// CHECK-NEXT: (LC1, S847) clang_analyzer_printState : &code{clang_analyzer_printState}
 
-// CHECK: {{(Ranges are empty.)|(Constraints:[[:space:]]*$)}}
+// CHECK:  Ranges of symbol values:
+// CHECK-NEXT:  reg_$0 : { [-2147483648, 13] }
Index: lib/StaticAnalyzer/Core/ProgramState.cpp
==

r361974 - [CodeComplete] Add semicolon when completing patterns for 'static_assert' and 'typedef

2019-05-29 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed May 29 08:32:17 2019
New Revision: 361974

URL: http://llvm.org/viewvc/llvm-project?rev=361974&view=rev
Log:
[CodeComplete] Add semicolon when completing patterns for 'static_assert' and 
'typedef

This is a trivial follow-up to r360042, which added semicolons to other
pattern completions, so sending without review.

Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/CodeCompletion/keywords.cpp
cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
cfe/trunk/test/CodeCompletion/ordinary-name.cpp

Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=361974&r1=361973&r2=361974&view=diff
==
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Wed May 29 08:32:17 2019
@@ -1713,6 +1713,7 @@ static void AddTypedefResult(ResultBuild
   Builder.AddPlaceholderChunk("type");
   Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
   Builder.AddPlaceholderChunk("name");
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 
@@ -1826,6 +1827,7 @@ static void AddStaticAssertResult(CodeCo
   Builder.AddChunk(CodeCompletionString::CK_Comma);
   Builder.AddPlaceholderChunk("message");
   Builder.AddChunk(CodeCompletionString::CK_RightParen);
+  Builder.AddChunk(CodeCompletionString::CK_SemiColon);
   Results.AddResult(CodeCompletionResult(Builder.TakeString()));
 }
 

Modified: cfe/trunk/test/CodeCompletion/keywords.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/keywords.cpp?rev=361974&r1=361973&r2=361974&view=diff
==
--- cfe/trunk/test/CodeCompletion/keywords.cpp (original)
+++ cfe/trunk/test/CodeCompletion/keywords.cpp Wed May 29 08:32:17 2019
@@ -34,7 +34,7 @@ struct Struct {
 // RUN: %clang_cc1 -std=c++11 -code-completion-at=%s:11:1 %s | FileCheck 
--check-prefix=CHECK-TOP-LEVEL %s
 // CHECK-TOP-LEVEL: alignas(<#expression#>)
 // CHECK-TOP-LEVEL: constexpr
-// CHECK-TOP-LEVEL: static_assert(<#expression#>, <#message#>)
+// CHECK-TOP-LEVEL: static_assert(<#expression#>, <#message#>);
 // CHECK-TOP-LEVEL: thread_local
 // CHECK-TOP-LEVEL-NOT: final
 // CHECK-TOP-LEVEL-NOT: noexcept

Modified: cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp?rev=361974&r1=361973&r2=361974&view=diff
==
--- cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp (original)
+++ cfe/trunk/test/CodeCompletion/ordinary-name-cxx11.cpp Wed May 29 08:32:17 
2019
@@ -43,7 +43,7 @@ void foo() {
   // CHECK-CC1-NEXT: COMPLETION: Pattern : 
[#size_t#]sizeof(<#expression-or-type#>)
   // CHECK-CC1-NEXT: COMPLETION: Pattern : 
[#size_t#]sizeof...(<#parameter-pack#>)
   // CHECK-CC1-NEXT: COMPLETION: static
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : static_assert(<#expression#>, 
<#message#>)
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : static_assert(<#expression#>, 
<#message#>);
   // CHECK-CC1-NEXT: COMPLETION: Pattern : 
static_cast<<#type#>>(<#expression#>)
   // CHECK-CC1-NEXT: COMPLETION: struct
   // CHECK-CC1-NEXT: COMPLETION: Pattern : switch(<#condition#>){
@@ -55,7 +55,7 @@ void foo() {
   // CHECK-CC1-NEXT: <#statements#>
   // CHECK-CC1-NEXT: }
   // CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF
-  // CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>
+  // CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
   // CHECK-CC1-NEXT: COMPLETION: Pattern : 
[#std::type_info#]typeid(<#expression-or-type#>)
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
   // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof <#expression#>
@@ -99,14 +99,14 @@ void foo() {
   // CHECK-CC2-NEXT: COMPLETION: short
   // CHECK-CC2-NEXT: COMPLETION: signed
   // CHECK-CC2-NEXT: COMPLETION: static
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : static_assert(<#expression#>, 
<#message#>)
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : static_assert(<#expression#>, 
<#message#>);
   // CHECK-CC2-NEXT: COMPLETION: struct
   // CHECK-CC2-NEXT: COMPLETION: t : t
   // CHECK-CC2-NEXT: COMPLETION: Pattern : template <#declaration#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : template<<#parameters#>>
   // CHECK-CC2-NEXT: COMPLETION: thread_local
   // CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF
-  // CHECK-CC2-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>
+  // CHECK-CC2-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof <#expression#>
   // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#

r361976 - [analyzer] print() JSONify: Environment implementation

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 08:36:58 2019
New Revision: 361976

URL: http://llvm.org/viewvc/llvm-project?rev=361976&view=rev
Log:
[analyzer] print() JSONify: Environment implementation

Summary: -

Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus

Reviewed By: NoQ

Subscribers: szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy,
 dkrupp

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
cfe/trunk/lib/StaticAnalyzer/Core/Environment.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PrettyStackTraceLocationContext.h
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/trunk/test/Analysis/expr-inspection.c

Modified: cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h?rev=361976&r1=361975&r2=361976&view=diff
==
--- cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h (original)
+++ cfe/trunk/include/clang/Analysis/AnalysisDeclContext.h Wed May 29 08:36:58 
2019
@@ -274,11 +274,17 @@ public:
   virtual void Profile(llvm::FoldingSetNodeID &ID) = 0;
 
   void dumpStack(
-  raw_ostream &OS, StringRef Indent = {}, const char *NL = "\n",
-  const char *Sep = "",
+  raw_ostream &Out, const char *NL = "\n",
   std::function printMoreInfoPerContext =
   [](const LocationContext *) {}) const;
-  void dumpStack() const;
+
+  void printJson(
+  raw_ostream &Out, const char *NL = "\n", unsigned int Space = 0,
+  bool IsDot = false,
+  std::function printMoreInfoPerContext =
+  [](const LocationContext *) {}) const;
+
+  void dump() const;
 
 public:
   static void ProfileCommon(llvm::FoldingSetNodeID &ID,

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h?rev=361976&r1=361975&r2=361976&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/Environment.h Wed 
May 29 08:36:58 2019
@@ -91,9 +91,9 @@ public:
 return ExprBindings == RHS.ExprBindings;
   }
 
-  void print(raw_ostream &Out, const char *NL, const char *Sep,
- const ASTContext &Context,
- const LocationContext *WithLC = nullptr) const;
+  void printJson(raw_ostream &Out, const ASTContext &Ctx,
+ const LocationContext *LCtx = nullptr, const char *NL = "\n",
+ unsigned int Space = 0, bool IsDot = false) const;
 };
 
 class EnvironmentManager {

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=361976&r1=361975&r2=361976&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Wed 
May 29 08:36:58 2019
@@ -377,9 +377,9 @@ public:
const CallEvent *Call) override;
 
   /// printState - Called by ProgramStateManager to print checker-specific 
data.
-  void printState(raw_ostream &Out, ProgramStateRef State, const char *NL,
-  const char *Sep,
-  const LocationContext *LCtx = nullptr) override;
+  void printState(raw_ostream &Out, ProgramStateRef State,
+  const LocationContext *LCtx, const char *NL,
+  unsigned int Space, bool IsDot) const override;
 
   ProgramStateManager &getStateManager() override { return StateMgr; }
 

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h?rev=361976&r1=361975&r2=361976&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h Wed 
May 29 08:36:58 2019
@@ -160,8 +160,8 @@ public:
 
   /// printState - Called by ProgramStateManager to print checker-specific 
data.
   virtual void printState(raw_ostream &Out, ProgramStateRef S

r361978 - [analyzer] print() JSONify: Constraints implementation

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 08:43:26 2019
New Revision: 361978

URL: http://llvm.org/viewvc/llvm-project?rev=361978&view=rev
Log:
[analyzer] print() JSONify: Constraints implementation

Summary: -

Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus

Reviewed By: NoQ

Subscribers: szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy,
 dkrupp

Tags: #clang

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

Modified:

cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h

cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
cfe/trunk/test/Analysis/expr-inspection.c

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h?rev=361978&r1=361977&r2=361978&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h 
Wed May 29 08:43:26 2019
@@ -162,10 +162,9 @@ public:
   virtual ProgramStateRef removeDeadBindings(ProgramStateRef state,
  SymbolReaper& SymReaper) = 0;
 
-  virtual void print(ProgramStateRef state,
- raw_ostream &Out,
- const char* nl,
- const char *sep) = 0;
+  virtual void printJson(raw_ostream &Out, ProgramStateRef State,
+ const char *NL, unsigned int Space,
+ bool IsDot) const = 0;
 
   virtual void EndPath(ProgramStateRef state) {}
 

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h?rev=361978&r1=361977&r2=361978&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
 (original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
 Wed May 29 08:43:26 2019
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SMTCONSTRAINTMANAGER_H
 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_SMTCONSTRAINTMANAGER_H
 
+#include "clang/Basic/JsonSupport.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SMTConv.h"
 
@@ -208,17 +209,32 @@ public:
 return State->set(CZ);
   }
 
-  void print(ProgramStateRef St, raw_ostream &OS, const char *nl,
- const char *sep) override {
-
-auto CZ = St->get();
+  void printJson(raw_ostream &Out, ProgramStateRef State, const char *NL = 
"\n",
+ unsigned int Space = 0, bool IsDot = false) const override {
+ConstraintSMTType Constraints = State->get();
+
+Indent(Out, Space, IsDot) << "\"constraints\": ";
+if (Constraints.isEmpty()) {
+  Out << "null," << NL;
+  return;
+}
 
-OS << nl << sep << "Constraints:";
-for (auto I = CZ.begin(), E = CZ.end(); I != E; ++I) {
-  OS << nl << ' ' << I->first << " : ";
-  I->second->print(OS);
+++Space;
+Out << '[' << NL;
+for (ConstraintSMTType::iterator I = Constraints.begin();
+ I != Constraints.end(); ++I) {
+  Indent(Out, Space, IsDot)
+  << "{ \"symbol\": \"" << I->first << "\", \"range\": \"";
+  I->second->print(Out);
+  Out << "\" }";
+
+  if (std::next(I) != Constraints.end())
+Out << ',';
+  Out << NL;
 }
-OS << nl;
+
+--Space;
+Indent(Out, Space, IsDot) << "],";
   }
 
   bool haveEqualConstraints(ProgramStateRef S1,

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp?rev=361978&r1=361977&r2=361978&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Wed May 29 08:43:26 2019
@@ -452,7 +452,7 @@ void ProgramState::printJson(raw_ostream
   Env.printJson(Out, Context, LCtx, NL, Space, IsDot);
 
   // Print out the constraints.
-  Mgr.getConstraintManager().print(this, Out, NL, Sep);
+  Mgr.getConstraintManager().printJson(Out, this, NL, Space, IsDot);
 
   // Print out the tracked dynamic types.
   printDynamicTypeInfo(this, Out, NL, Sep);

Modified: cfe/trunk/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Co

[PATCH] D62580: [OpenCL] Use long instead of long long in x86 builtins

2019-05-29 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

'O' is an interesting choice.  Any real justification for it, or just "what was 
available"?  It definitely needs to be documented in the top of Builtins.def 
however.




Comment at: clang/lib/AST/ASTContext.cpp:9362
+case 'O':
+  assert(!IsSpecial && "Can't use two 'N', 'W', 'Z' or 'O' modifiers!");
+  assert(HowLong == 0 && "Can't use both 'L' and 'O' modifiers!");

Likely need to update the asserts in the other places this is used, such as 'Z'.

Also, add the 'O' to the documentation in Builtins.def


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62580



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


[PATCH] D62335: [OpenCL][PR41963] Add overloads of old atomics with generic pointer type in C++ mode

2019-05-29 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.
This revision is now accepted and ready to land.

LGTM, please address style issue before committing.




Comment at: test/Headers/opencl-c-header.cl:79
+{
+atomic_add(a, 1);
+}

Probably better to follow the style of the other tests above (i.e. indent and 
brace placement).


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

https://reviews.llvm.org/D62335



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


[PATCH] D37813: clang-format: better handle namespace macros

2019-05-29 Thread Francois Ferrand via Phabricator via cfe-commits
Typz updated this revision to Diff 201936.
Typz marked an inline comment as done.
Typz added a comment.

- Rebase
- Fix NamespaceEndCommentsFixerTest to match LLVM indent style


Repository:
  rC Clang

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

https://reviews.llvm.org/D37813

Files:
  docs/ClangFormatStyleOptions.rst
  include/clang/Format/Format.h
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/NamespaceEndCommentsFixer.cpp
  lib/Format/TokenAnnotator.cpp
  lib/Format/TokenAnnotator.h
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp
  unittests/Format/NamespaceEndCommentsFixerTest.cpp

Index: unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -52,6 +52,7 @@
 "  int i;\n"
 "  int j;\n"
 "}"));
+
   EXPECT_EQ("namespace {\n"
 "  int i;\n"
 "  int j;\n"
@@ -248,6 +249,85 @@
 "// unrelated"));
 }
 
+TEST_F(NamespaceEndCommentsFixerTest, AddsMacroEndComment) {
+  FormatStyle Style = getLLVMStyle();
+  Style.NamespaceMacros.push_back("TESTSUITE");
+
+  EXPECT_EQ("TESTSUITE() {\n"
+"int i;\n"
+"int j;\n"
+"}// TESTSUITE()",
+fixNamespaceEndComments("TESTSUITE() {\n"
+"int i;\n"
+"int j;\n"
+"}",
+Style));
+
+  EXPECT_EQ("TESTSUITE(A) {\n"
+"int i;\n"
+"int j;\n"
+"}// TESTSUITE(A)",
+fixNamespaceEndComments("TESTSUITE(A) {\n"
+"int i;\n"
+"int j;\n"
+"}",
+Style));
+  EXPECT_EQ("inline TESTSUITE(A) {\n"
+"int i;\n"
+"int j;\n"
+"}// TESTSUITE(A)",
+fixNamespaceEndComments("inline TESTSUITE(A) {\n"
+"int i;\n"
+"int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(::A) {\n"
+"int i;\n"
+"int j;\n"
+"}// TESTSUITE(::A)",
+fixNamespaceEndComments("TESTSUITE(::A) {\n"
+"int i;\n"
+"int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(::A::B) {\n"
+"int i;\n"
+"int j;\n"
+"}// TESTSUITE(::A::B)",
+fixNamespaceEndComments("TESTSUITE(::A::B) {\n"
+"int i;\n"
+"int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(/**/::/**/A/**/::/**/B/**/) {\n"
+"int i;\n"
+"int j;\n"
+"}// TESTSUITE(::A::B)",
+fixNamespaceEndComments("TESTSUITE(/**/::/**/A/**/::/**/B/**/) {\n"
+"int i;\n"
+"int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(A, B) {\n"
+"int i;\n"
+"int j;\n"
+"}// TESTSUITE(A)",
+fixNamespaceEndComments("TESTSUITE(A, B) {\n"
+"int i;\n"
+"int j;\n"
+"}",
+Style));
+  EXPECT_EQ("TESTSUITE(\"Test1\") {\n"
+"int i;\n"
+"int j;\n"
+"}// TESTSUITE(\"Test1\")",
+fixNamespaceEndComments("TESTSUITE(\"Test1\") {\n"
+"int i;\n"
+"int j;\n"
+"}",
+Style));
+}
+
 TEST_F(NamespaceEndCommentsFixerTest, AddsNewlineIfNeeded) {
   EXPECT_EQ("namespace A {\n"
 "  int i;\n"
@@ -380,6 +460,54 @@
 "}; /* unnamed namespace */"));
 }
 
+TEST_F(NamespaceEndCommentsFixerTest, KeepsValidMacroEndComment) {
+  FormatStyle Style = getLLVMStyle();
+  Style.NamespaceMacros.push_back("TESTSUITE");
+
+  EXPECT_EQ("TESTSUITE() {\n"
+"int i;\n"
+"} // end anonymous TESTSUITE()",
+fixNamespaceEndComments("TESTSUITE() {\n"
+"int i;\n"
+

[PATCH] D62603: [CUDA][HIP] Skip setting `externally_initialized` for static device variables.

2019-05-29 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added a reviewer: yaxunl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- By declaring device variables as `static`, we assume they won't be 
addressable from the host side. Thus, no `externally_initialized` is required.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62603

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCUDA/device-var-init.cu


Index: clang/test/CodeGenCUDA/device-var-init.cu
===
--- clang/test/CodeGenCUDA/device-var-init.cu
+++ clang/test/CodeGenCUDA/device-var-init.cu
@@ -33,6 +33,16 @@
 // DEVICE: @d_v_i = addrspace(1) externally_initialized global i32 1,
 // HOST:   @d_v_i = internal global i32 undef,
 
+// For `static` device variables, assume they won't be addressed from the host
+// side.
+static __device__ int d_s_v_i = 1;
+// DEVICE: @_ZL7d_s_v_i = internal addrspace(1) global i32 1,
+
+// Dummy function to keep static variables referenced.
+__device__ int foo() {
+  return d_s_v_i;
+}
+
 // trivial constructor -- allowed
 __device__ T d_t;
 // DEVICE: @d_t = addrspace(1) externally_initialized global %struct.T 
zeroinitializer
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -3869,7 +3869,8 @@
   // / cudaMemcpyToSymbol() / cudaMemcpyFromSymbol())."
   if (GV && LangOpts.CUDA) {
 if (LangOpts.CUDAIsDevice) {
-  if (D->hasAttr() || D->hasAttr())
+  if (Linkage != llvm::GlobalValue::InternalLinkage &&
+  (D->hasAttr() || D->hasAttr()))
 GV->setExternallyInitialized(true);
 } else {
   // Host-side shadows of external declarations of device-side


Index: clang/test/CodeGenCUDA/device-var-init.cu
===
--- clang/test/CodeGenCUDA/device-var-init.cu
+++ clang/test/CodeGenCUDA/device-var-init.cu
@@ -33,6 +33,16 @@
 // DEVICE: @d_v_i = addrspace(1) externally_initialized global i32 1,
 // HOST:   @d_v_i = internal global i32 undef,
 
+// For `static` device variables, assume they won't be addressed from the host
+// side.
+static __device__ int d_s_v_i = 1;
+// DEVICE: @_ZL7d_s_v_i = internal addrspace(1) global i32 1,
+
+// Dummy function to keep static variables referenced.
+__device__ int foo() {
+  return d_s_v_i;
+}
+
 // trivial constructor -- allowed
 __device__ T d_t;
 // DEVICE: @d_t = addrspace(1) externally_initialized global %struct.T zeroinitializer
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -3869,7 +3869,8 @@
   // / cudaMemcpyToSymbol() / cudaMemcpyFromSymbol())."
   if (GV && LangOpts.CUDA) {
 if (LangOpts.CUDAIsDevice) {
-  if (D->hasAttr() || D->hasAttr())
+  if (Linkage != llvm::GlobalValue::InternalLinkage &&
+  (D->hasAttr() || D->hasAttr()))
 GV->setExternallyInitialized(true);
 } else {
   // Host-side shadows of external declarations of device-side
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62082: [analyzer] print() JSONify: Constraints implementation

2019-05-29 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361978: [analyzer] print() JSONify: Constraints 
implementation (authored by Charusso, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62082?vs=201570&id=201939#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62082

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  test/Analysis/expr-inspection.c

Index: test/Analysis/expr-inspection.c
===
--- test/Analysis/expr-inspection.c
+++ test/Analysis/expr-inspection.c
@@ -33,6 +33,7 @@
 // CHECK-NEXT: { "lctx_id": 1, "stmt_id": 847, "pretty": "clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" }
 // CHECK-NEXT:   ]}
 // CHECK-NEXT: ],
+// CHECK-NEXT: "constraints": [
+// CHECK-NEXT:   { "symbol": "reg_$0", "range": "{ [-2147483648, 13] }" }
+// CHECK-NEXT: ],
 
-// CHECK:  Ranges of symbol values:
-// CHECK-NEXT:  reg_$0 : { [-2147483648, 13] }
Index: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -11,6 +11,7 @@
 //
 //===--===//
 
+#include "clang/Basic/JsonSupport.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
@@ -261,8 +262,8 @@
   ProgramStateRef removeDeadBindings(ProgramStateRef State,
  SymbolReaper &SymReaper) override;
 
-  void print(ProgramStateRef State, raw_ostream &Out, const char *nl,
- const char *sep) override;
+  void printJson(raw_ostream &Out, ProgramStateRef State, const char *NL = "\n",
+ unsigned int Space = 0, bool IsDot = false) const override;
 
   //===--===//
   // Implementation for interface from RangedConstraintManager.
@@ -754,25 +755,35 @@
   return New.isEmpty() ? nullptr : State->set(Sym, New);
 }
 
-//======
+//===--===//
 // Pretty-printing.
-//======/
-
-void RangeConstraintManager::print(ProgramStateRef St, raw_ostream &Out,
-   const char *nl, const char *sep) {
-
-  ConstraintRangeTy Ranges = St->get();
+//===--===//
 
-  if (Ranges.isEmpty()) {
-Out << nl << sep << "Ranges are empty." << nl;
+void RangeConstraintManager::printJson(raw_ostream &Out, ProgramStateRef State,
+   const char *NL, unsigned int Space,
+   bool IsDot) const {
+  ConstraintRangeTy Constraints = State->get();
+
+  Indent(Out, Space, IsDot) << "\"constraints\": ";
+  if (Constraints.isEmpty()) {
+Out << "null," << NL;
 return;
   }
 
-  Out << nl << sep << "Ranges of symbol values:";
-  for (ConstraintRangeTy::iterator I = Ranges.begin(), E = Ranges.end(); I != E;
-   ++I) {
-Out << nl << ' ' << I.getKey() << " : ";
+  ++Space;
+  Out << '[' << NL;
+  for (ConstraintRangeTy::iterator I = Constraints.begin();
+   I != Constraints.end(); ++I) {
+Indent(Out, Space, IsDot)
+<< "{ \"symbol\": \"" << I.getKey() << "\", \"range\": \"";
 I.getData().print(Out);
+Out << "\" }";
+
+if (std::next(I) != Constraints.end())
+  Out << ',';
+Out << NL;
   }
-  Out << nl;
+
+  --Space;
+  Indent(Out, Space, IsDot) << "]," << NL;
 }
Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -452,7 +452,7 @@
   Env.printJson(Out, Context, LCtx, NL, Space, IsDot);
 
   // Print out the constraints.
-  Mgr.getConstraintManager().print(this, Out, NL, Sep);
+  Mgr.getConstraintManager().printJson(Out, this, NL, Space, IsDot);
 
   // Print out the tracked dynamic types.
   printDynamicTypeInfo(this, Out, NL, Sep);
Index: include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/SMTConstraintManager.h
+++ include/clang/StaticA

r361979 - [analyzer] print() JSONify: Type information implementation

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 08:53:12 2019
New Revision: 361979

URL: http://llvm.org/viewvc/llvm-project?rev=361979&view=rev
Log:
[analyzer] print() JSONify: Type information implementation

Summary: -

Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus

Reviewed By: NoQ

Subscribers: szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy,
 dkrupp

Tags: #clang

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
cfe/trunk/lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/trunk/test/Analysis/expr-inspection.c

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h?rev=361979&r1=361978&r2=361979&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h 
Wed May 29 08:53:12 2019
@@ -29,12 +29,11 @@ class MemRegion;
 /// symbol to its most likely type.
 struct DynamicTypeMap {};
 
-using DynamicTypeMapImpl =
-llvm::ImmutableMap;
+using DynamicTypeMapTy = llvm::ImmutableMap;
 
 template <>
 struct ProgramStateTrait
-: public ProgramStatePartialTrait {
+: public ProgramStatePartialTrait {
   static void *GDMIndex();
 };
 
@@ -54,8 +53,9 @@ inline ProgramStateRef setDynamicTypeInf
 DynamicTypeInfo(NewTy, CanBeSubClassed));
 }
 
-void printDynamicTypeInfo(ProgramStateRef State, raw_ostream &Out,
-  const char *NL, const char *Sep);
+void printDynamicTypeInfoJson(raw_ostream &Out, ProgramStateRef State,
+  const char *NL = "\n", unsigned int Space = 0,
+  bool IsDot = false);
 
 } // namespace ento
 } // namespace clang

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp?rev=361979&r1=361978&r2=361979&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DynamicTypePropagation.cpp Wed May 29 
08:53:12 2019
@@ -114,8 +114,8 @@ public:
 void DynamicTypePropagation::checkDeadSymbols(SymbolReaper &SR,
   CheckerContext &C) const {
   ProgramStateRef State = C.getState();
-  DynamicTypeMapImpl TypeMap = State->get();
-  for (DynamicTypeMapImpl::iterator I = TypeMap.begin(), E = TypeMap.end();
+  DynamicTypeMapTy TypeMap = State->get();
+  for (DynamicTypeMapTy::iterator I = TypeMap.begin(), E = TypeMap.end();
I != E; ++I) {
 if (!SR.isLiveRegion(I->first)) {
   State = State->remove(I->first);

Modified: cfe/trunk/lib/StaticAnalyzer/Core/DynamicTypeMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/DynamicTypeMap.cpp?rev=361979&r1=361978&r2=361979&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/DynamicTypeMap.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/DynamicTypeMap.cpp Wed May 29 08:53:12 
2019
@@ -13,6 +13,7 @@
 
//===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
+#include "clang/Basic/JsonSupport.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -53,27 +54,38 @@ ProgramStateRef setDynamicTypeInfo(Progr
   return NewState;
 }
 
-void printDynamicTypeInfo(ProgramStateRef State, raw_ostream &Out,
-  const char *NL, const char *Sep) {
-  bool First = true;
-  for (const auto &I : State->get()) {
-if (First) {
-  Out << NL << "Dynamic types of regions:" << NL;
-  First = false;
-}
-const MemRegion *MR = I.first;
-const DynamicTypeInfo &DTI = I.second;
-Out << MR << " : ";
+void printDynamicTypeInfoJson(raw_ostream &Out, ProgramStateRef State,
+  const char *NL, unsigned int Space, bool IsDot) {
+  Indent(Out, Space, IsDot) << "\"dynamic_types\": ";
+
+  const DynamicTypeMapTy &DTM = State->get();
+  if (DTM.isEmpty()) {
+Out << "null," << NL;
+return;
+  }
+
+  ++Space;
+  Out << '[' << NL;
+  for (DynamicTypeMapTy::iterator I = DTM.begin(); I != DTM.end(); ++I) {
+const MemRegion *MR = I->first;
+const DynamicTypeInfo &DTI = I->seco

[PATCH] D62582: [CodeComplete] Improve overload handling for C++ qualified and ref-qualified methods.

2019-05-29 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: lib/Sema/SemaCodeComplete.cpp:1300
+auto &OverloadSet =
+OverloadMap[std::make_pair(CurContext, Method->getName())];
+for (const DeclIndexPair& Entry : OverloadSet) {

Won't this crash on `Method->getName()`? Could we add a test for that?
Completing in a class that has a user-defined `operator==()` would probably do 
the trick.



Comment at: lib/Sema/SemaCodeComplete.cpp:1308
+// should remove all. But two overloads is by far the common case.
+Incumbent = std::move(R);
+return;

Could you add a comment that we modify previously added results here?
It's obvious from the code, but not something I would normally expect so having 
a separate comment looks useful.


Repository:
  rC Clang

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

https://reviews.llvm.org/D62582



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


[PATCH] D62580: [OpenCL] Use long instead of long long in x86 builtins

2019-05-29 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

A different (perhaps silly) question is why 'W' isn't sufficient?  It 
represents int64_t, which I wonder if is sufficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62580



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


[PATCH] D62459: [clangd] Serialization support for RelationSlab

2019-05-29 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/index/Serialization.h:81
+// Used for serializing SymbolRole as used in Relation.
+enum class RelationKind : uint8_t { ChildOf = 1, BaseOf };
+llvm::Expected symbolRoleToRelationKind(index::SymbolRole);

kadircet wrote:
> kadircet wrote:
> > why not start from zero?
> > 
> > Also let's change the `index::SymbolRole` in `Relation` with this one.
> why not just store baseof ? do we need both directions for typehierarchy?
> Also let's change the index::SymbolRole in Relation with this one.

You previously asked for the opposite change in [this 
comment](https://reviews.llvm.org/D59407?id=190785#inline-525734) :)

Did your opinion change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62459



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


r361980 - [analyzer] print() JSONify: Constructing objects implementation

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 08:58:26 2019
New Revision: 361980

URL: http://llvm.org/viewvc/llvm-project?rev=361980&view=rev
Log:
[analyzer] print() JSONify: Constructing objects implementation

Summary: -

Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus

Reviewed By: NoQ

Subscribers: szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy,
 dkrupp

Tags: #clang

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/trunk/test/Analysis/dump_egraph.cpp
cfe/trunk/test/Analysis/expr-inspection.c

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h?rev=361980&r1=361979&r2=361980&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h Wed 
May 29 08:58:26 2019
@@ -376,10 +376,10 @@ public:
const LocationContext *LCtx,
const CallEvent *Call) override;
 
-  /// printState - Called by ProgramStateManager to print checker-specific 
data.
-  void printState(raw_ostream &Out, ProgramStateRef State,
-  const LocationContext *LCtx, const char *NL,
-  unsigned int Space, bool IsDot) const override;
+  /// printJson - Called by ProgramStateManager to print checker-specific data.
+  void printJson(raw_ostream &Out, ProgramStateRef State,
+ const LocationContext *LCtx, const char *NL,
+ unsigned int Space, bool IsDot) const override;
 
   ProgramStateManager &getStateManager() override { return StateMgr; }
 

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h?rev=361980&r1=361979&r2=361980&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h Wed 
May 29 08:58:26 2019
@@ -158,10 +158,10 @@ public:
const CallEvent *Call,
RegionAndSymbolInvalidationTraits &HTraits) = 0;
 
-  /// printState - Called by ProgramStateManager to print checker-specific 
data.
-  virtual void printState(raw_ostream &Out, ProgramStateRef State,
-  const LocationContext *LCtx, const char *NL,
-  unsigned int Space, bool IsDot) const = 0;
+  /// printJson - Called by ProgramStateManager to print checker-specific data.
+  virtual void printJson(raw_ostream &Out, ProgramStateRef State,
+ const LocationContext *LCtx, const char *NL,
+ unsigned int Space, bool IsDot) const = 0;
 
   /// Called by CoreEngine when the analysis worklist is either empty or the
   //  maximum number of analysis steps have been reached.

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=361980&r1=361979&r2=361980&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Wed May 29 08:58:26 2019
@@ -33,6 +33,7 @@
 #include "clang/Analysis/ConstructionContext.h"
 #include "clang/Analysis/ProgramPoint.h"
 #include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/JsonSupport.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/PrettyStackTrace.h"
@@ -141,21 +142,47 @@ public:
 return getLocationContext()->getDecl()->getASTContext();
   }
 
-  void print(llvm::raw_ostream &OS, PrinterHelper *Helper, PrintingPolicy &PP) 
{
-OS << "(LC" << getLocationContext()->getID() << ',';
-if (const Stmt *S = getItem().getStmtOrNull())
-  OS << 'S' << S->getID(getASTContext());
+  void printJson(llvm::raw_ostream &Out, PrinterHelper *Helper,
+ PrintingPolicy &PP) const {
+const Stmt *S = getItem().getStmtOrNull();
+const CXXCtorInitializer *I = nullptr;
+if (!S)
+  I = getItem().getCXXCtorInitializer();
+
+// IDs
+Out << "\"lctx_id\": " << getLocationContext()->getID() << ", ";
+
+if (S)
+  Out << "\"stmt_id\": " << S->getID(getASTContext());
 else
-  OS << 'I' << getItem().getCXXCtorInitialize

[PATCH] D62085: [analyzer] print() JSONify: Constructing objects implementation

2019-05-29 Thread Csaba Dabis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361980: [analyzer] print() JSONify: Constructing objects 
implementation (authored by Charusso, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D62085?vs=201572&id=201946#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D62085

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  include/clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  test/Analysis/dump_egraph.cpp
  test/Analysis/expr-inspection.c

Index: lib/StaticAnalyzer/Core/ProgramState.cpp
===
--- lib/StaticAnalyzer/Core/ProgramState.cpp
+++ lib/StaticAnalyzer/Core/ProgramState.cpp
@@ -458,7 +458,7 @@
   printDynamicTypeInfoJson(Out, this, NL, Space, IsDot);
 
   // Print checker-specific data.
-  Mgr.getOwningEngine().printState(Out, this, LCtx, NL, Space, IsDot);
+  Mgr.getOwningEngine().printJson(Out, this, LCtx, NL, Space, IsDot);
 }
 
 void ProgramState::printDOT(raw_ostream &Out, const LocationContext *LCtx,
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -33,6 +33,7 @@
 #include "clang/Analysis/ConstructionContext.h"
 #include "clang/Analysis/ProgramPoint.h"
 #include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/JsonSupport.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/PrettyStackTrace.h"
@@ -141,21 +142,47 @@
 return getLocationContext()->getDecl()->getASTContext();
   }
 
-  void print(llvm::raw_ostream &OS, PrinterHelper *Helper, PrintingPolicy &PP) {
-OS << "(LC" << getLocationContext()->getID() << ',';
-if (const Stmt *S = getItem().getStmtOrNull())
-  OS << 'S' << S->getID(getASTContext());
+  void printJson(llvm::raw_ostream &Out, PrinterHelper *Helper,
+ PrintingPolicy &PP) const {
+const Stmt *S = getItem().getStmtOrNull();
+const CXXCtorInitializer *I = nullptr;
+if (!S)
+  I = getItem().getCXXCtorInitializer();
+
+// IDs
+Out << "\"lctx_id\": " << getLocationContext()->getID() << ", ";
+
+if (S)
+  Out << "\"stmt_id\": " << S->getID(getASTContext());
 else
-  OS << 'I' << getItem().getCXXCtorInitializer()->getID(getASTContext());
-OS << ',' << getItem().getKindAsString();
+  Out << "\"init_id\": " << I->getID(getASTContext());
+
+// Kind
+Out << ", \"kind\": \"" << getItem().getKindAsString()
+<< "\", \"argument_index\": ";
+
 if (getItem().getKind() == ConstructionContextItem::ArgumentKind)
-  OS << " #" << getItem().getIndex();
-OS << ") ";
-if (const Stmt *S = getItem().getStmtOrNull()) {
-  S->printPretty(OS, Helper, PP);
+  Out << getItem().getIndex() << '\"';
+else
+  Out << "null";
+
+// Pretty-print
+Out << ", \"pretty\": \"";
+
+if (S) {
+  llvm::SmallString<256> TempBuf;
+  llvm::raw_svector_ostream TempOut(TempBuf);
+
+  // See whether the current statement is pretty-printable.
+  S->printPretty(TempOut, Helper, PP);
+  if (!TempBuf.empty()) {
+Out << TempBuf.str().trim() << '\"';
+TempBuf.clear();
+  } else {
+Out << "null";
+  }
 } else {
-  const CXXCtorInitializer *I = getItem().getCXXCtorInitializer();
-  OS << I->getAnyMember()->getNameAsString();
+  Out << I->getAnyMember()->getNameAsString() << '\"';
 }
   }
 
@@ -541,33 +568,69 @@
  LCtx, Call);
 }
 
-static void printObjectsUnderConstructionForContext(raw_ostream &Out,
-ProgramStateRef State,
-const char *NL,
-const LocationContext *LC) {
+static void
+printObjectsUnderConstructionJson(raw_ostream &Out, ProgramStateRef State,
+  const char *NL, const LocationContext *LCtx,
+  unsigned int Space = 0, bool IsDot = false) {
   PrintingPolicy PP =
-  LC->getAnalysisDeclContext()->getASTContext().getPrintingPolicy();
-  for (auto I : State->get()) {
-ConstructedObjectKey Key = I.first;
+  LCtx->getAnalysisDeclContext()->getASTContext().getPrintingPolicy();
+
+  ++Space;
+  bool HasItem = false;
+
+  // Store the last key.
+  const ConstructedObjectKey *LastKey = nullptr;
+  for (const auto &I : State->get()) {
+const ConstructedObjectKey &Key = I.first;
+if (Key.getLocationContext() != LCtx)
+  continue;
+
+if (!HasItem) {
+  Out << "[" << NL;
+  HasIte

r361982 - [analyzer] print() JSONify: Checker messages implementation

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 09:02:33 2019
New Revision: 361982

URL: http://llvm.org/viewvc/llvm-project?rev=361982&view=rev
Log:
[analyzer] print() JSONify: Checker messages implementation

Summary: -

Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus

Reviewed By: NoQ

Subscribers: szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy,
 dkrupp

Tags: #clang

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/expr-inspection.c
cfe/trunk/test/Analysis/use-after-move.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h?rev=361982&r1=361981&r2=361982&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/CheckerManager.h Wed May 29 
09:02:33 2019
@@ -406,16 +406,21 @@ public:
   ///
   /// Unlike most other callbacks, any checker can simply implement the virtual
   /// method CheckerBase::printState if it has custom data to print.
-  /// \param Out The output stream
+  ///
+  /// \param Out   The output stream
   /// \param State The state being printed
-  /// \param NL The preferred representation of a newline.
-  /// \param Sep The preferred separator between different kinds of data.
-  void runCheckersForPrintState(raw_ostream &Out, ProgramStateRef State,
-const char *NL, const char *Sep);
+  /// \param NLThe preferred representation of a newline.
+  /// \param Sep   The preferred separator between different messages.
+  /// \param Space The preferred space between the left side and the message.
+  /// \param IsDot Whether the message will be printed in 'dot' format.
+  void runCheckersForPrintStateJson(raw_ostream &Out, ProgramStateRef State,
+const char *NL = "\n",
+unsigned int Space = 0,
+bool IsDot = false) const;
 
-//===--===//
-// Internal registration functions for AST traversing.
-//===--===//
+  
//===--===//
+  // Internal registration functions for AST traversing.
+  
//===--===//
 
   // Functions used by the registration mechanism, checkers should not touch
   // these directly.

Modified: cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp?rev=361982&r1=361981&r2=361982&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/CheckerManager.cpp Wed May 29 09:02:33 
2019
@@ -14,6 +14,7 @@
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/Stmt.h"
 #include "clang/Analysis/ProgramPoint.h"
+#include "clang/Basic/JsonSupport.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
@@ -698,11 +699,73 @@ void CheckerManager::runCheckersOnEndOfT
 EndOfTranslationUnitChecker(TU, mgr, BR);
 }
 
-void CheckerManager::runCheckersForPrintState(raw_ostream &Out,
-  ProgramStateRef State,
-  const char *NL, const char *Sep) 
{
-  for (const auto &CheckerTag : CheckerTags)
-CheckerTag.second->printState(Out, State, NL, Sep);
+void CheckerManager::runCheckersForPrintStateJson(raw_ostream &Out,
+  ProgramStateRef State,
+  const char *NL,
+  unsigned int Space,
+  bool IsDot) const {
+  Indent(Out, Space, IsDot) << "\"checker_messages\": ";
+
+  // Create a temporary stream to see whether we have any message.
+  SmallString<1024> TempBuf;
+  llvm::raw_svector_ostream TempOut(TempBuf);
+  unsigned int InnerSpace = Space + 2;
+
+  // Create the new-line in JSON with enough space.
+  SmallString<128> NewLine;
+  llvm::raw_svector_ostream NLOut(NewLine);
+  NLOut << "\", " << NL; // Inject the ending and a new 
line
+  Indent(NLOut, InnerSpace, IsDot) << "\"";  // then begin the next message.
+
+  ++Space;
+  bool HasMessage = false;
+
+  // Store the last Check

[PATCH] D62603: [CUDA][HIP] Skip setting `externally_initialized` for static device variables.

2019-05-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

LGTM. The externally initializable attribute causes some optimizations 
disabled. For static device variables it seems reasonable to remove the 
externaly initializable attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62603



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


[PATCH] D61912: [analyzer] print() JSONify: Store implementation

2019-05-29 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

All these patches bypassed cfe-commits.

Why does this invent a yet another json formatter instead of using
`"llvm/Support/JSON.h"`, in particular it's lightweight `json::OStream` ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61912



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


[PATCH] D62606: [Driver] -static-pie: add -z text

2019-05-29 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: saugustine, sivachandra.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

gcc -static-pie adds -z text.

In ld.bfd and gold, default/-z text/-z notext are tri-state.
By default, text relocations (and DF_TEXTREL) are emitted on demand.
-z text disables that.

In lld, -z text (default) and -z notext are bi-state. This change is a no-op.


Repository:
  rC Clang

https://reviews.llvm.org/D62606

Files:
  lib/Driver/ToolChains/Gnu.cpp
  test/Driver/linux-ld.c


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -190,6 +190,8 @@
 // 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: "-z"
+// CHECK-CLANG-LD-STATIC-PIE: "text"
 // 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"
@@ -203,6 +205,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "text"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"
@@ -216,6 +220,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "text"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" 
"--end-group"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -382,6 +382,8 @@
 CmdArgs.push_back("-static");
 CmdArgs.push_back("-pie");
 CmdArgs.push_back("--no-dynamic-linker");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("text");
   }
 
   if (ToolChain.isNoExecStackDefault()) {


Index: test/Driver/linux-ld.c
===
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -190,6 +190,8 @@
 // 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: "-z"
+// CHECK-CLANG-LD-STATIC-PIE: "text"
 // 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"
@@ -203,6 +205,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-PIE: "text"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-PIE: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
@@ -216,6 +220,8 @@
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-static"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-pie"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--no-dynamic-linker"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "-z"
+// CHECK-CLANG-LD-STATIC-PIE-STATIC: "text"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "-m" "elf_x86_64"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "{{.*}}rcrt1.o"
 // CHECK-CLANG-LD-STATIC-PIE-STATIC: "--start-group" "-lgcc" "-lgcc_eh" "-lc" "--end-group"
Index: lib/Driver/ToolChains/Gnu.cpp
===
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -382,6 +382,8 @@
 CmdArgs.push_back("-static");
 CmdArgs.push_back("-pie");
 CmdArgs.push_back("--no-dynamic-linker");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("text");
   }
 
   if (ToolChain.isNoExecStackDefault()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61974: [ObjC] Fix encoding of ObjC pointer types that are pointers to typedefs

2019-05-29 Thread David Chisnall via Phabricator via cfe-commits
theraven accepted this revision.
theraven added a comment.
This revision is now accepted and ready to land.

LGTM.  I wonder if we have any other ugly GCC bug compatibility parts in 
clang's Objective-C implementation...


Repository:
  rC Clang

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

https://reviews.llvm.org/D61974



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


[PATCH] D61912: [analyzer] print() JSONify: Store implementation

2019-05-29 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Hey @lebedev.ri, thanks for the review!

In D61912#1521306 , @lebedev.ri wrote:

> All these patches bypassed cfe-commits.


Bypassed? It is only added when you push your stuff, which is happened as 
expected.

> Why does this invent a yet another json formatter instead of using
>  `"llvm/Support/JSON.h"`, in particular it's lightweight `json::OStream` ?

We are doing our own JSON representation which is not really the job of `json` 
namespace. Also it is my personal feeling to avoid writing::like::that for 
perfectly no reason.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61912



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


r361983 - [analyzer] print() JSONify: Program state implementation

2019-05-29 Thread Csaba Dabis via cfe-commits
Author: charusso
Date: Wed May 29 09:22:21 2019
New Revision: 361983

URL: http://llvm.org/viewvc/llvm-project?rev=361983&view=rev
Log:
[analyzer] print() JSONify: Program state implementation

Summary: -

Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus

Reviewed By: NoQ

Subscribers: szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy,
 dkrupp

Tags: #clang

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
cfe/trunk/test/Analysis/dump_egraph.cpp
cfe/trunk/test/Analysis/expr-inspection.c

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h?rev=361983&r1=361982&r2=361983&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h 
Wed May 29 09:22:21 2019
@@ -425,8 +425,8 @@ public:
 
   // Pretty-printing.
   void printJson(raw_ostream &Out, const LocationContext *LCtx = nullptr,
- const char *NL = "\n", const char *Sep = "",
- unsigned int Space = 0, bool IsDot = false) const;
+ const char *NL = "\n", unsigned int Space = 0,
+ bool IsDot = false) const;
 
   void printDOT(raw_ostream &Out, const LocationContext *LCtx = nullptr,
 unsigned int Space = 0) const;

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp?rev=361983&r1=361982&r2=361983&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ProgramState.cpp Wed May 29 09:22:21 2019
@@ -10,13 +10,14 @@
 //
 
//===--===//
 
-#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/Analysis/CFG.h"
+#include "clang/Basic/JsonSupport.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SubEngine.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicTypeMap.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
@@ -441,15 +442,18 @@ void ProgramState::setStore(const StoreR
 
//===--===//
 
 void ProgramState::printJson(raw_ostream &Out, const LocationContext *LCtx,
- const char *NL, const char *Sep,
- unsigned int Space, bool IsDot) const {
-  // Print the store.
+ const char *NL, unsigned int Space,
+ bool IsDot) const {
+  Indent(Out, Space, IsDot) << "\"program_state\": {" << NL;
+  ++Space;
+
   ProgramStateManager &Mgr = getStateManager();
-  const ASTContext &Context = getStateManager().getContext();
+
+  // Print the store.
   Mgr.getStoreManager().printJson(Out, getStore(), NL, Space, IsDot);
 
   // Print out the environment.
-  Env.printJson(Out, Context, LCtx, NL, Space, IsDot);
+  Env.printJson(Out, Mgr.getContext(), LCtx, NL, Space, IsDot);
 
   // Print out the constraints.
   Mgr.getConstraintManager().printJson(Out, this, NL, Space, IsDot);
@@ -459,11 +463,14 @@ void ProgramState::printJson(raw_ostream
 
   // Print checker-specific data.
   Mgr.getOwningEngine().printJson(Out, this, LCtx, NL, Space, IsDot);
+
+  --Space;
+  Indent(Out, Space, IsDot) << '}';
 }
 
 void ProgramState::printDOT(raw_ostream &Out, const LocationContext *LCtx,
 unsigned int Space) const {
-  printJson(Out, LCtx, "\\l", "\\|", Space, /*IsDot=*/true);
+  printJson(Out, LCtx, /*NL=*/"\\l", Space, /*IsDot=*/true);
 }
 
 LLVM_DUMP_METHOD void ProgramState::dump() const {

Modified: cfe/trunk/test/Analysis/dump_egraph.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.cpp?rev=361983&r1=361982&r2=361983&view=diff
==
--- cfe/trunk/test/Analysis/dump_egraph.cpp (original)
+++ cfe/trunk/test/Analysis/dump_egraph.cpp Wed May 29 09:22:21 2019
@@ -16,9 +16,9 @@ void foo() {
   T t;
 }
 
-// CHECK: \"constructing_objects\": [\l  \{ \"location_context\": 
\"#0 Call\", \"call

r361984 - [NFC] clang-format: Use LLVM style in NamespaceEndCommentsFixerTest

2019-05-29 Thread Francois Ferrand via cfe-commits
Author: typz
Date: Wed May 29 09:22:43 2019
New Revision: 361984

URL: http://llvm.org/viewvc/llvm-project?rev=361984&view=rev
Log:
[NFC] clang-format: Use LLVM style in NamespaceEndCommentsFixerTest

As pointed out in https://reviews.llvm.org/D37813#inline-555026, the
code which is formatted does not match LLVM formatting style.

Technically this is not a problem since these tests bypass most of the
formatter, but it can be misleading.

Modified:
cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp

Modified: cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp?rev=361984&r1=361983&r2=361984&view=diff
==
--- cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp (original)
+++ cfe/trunk/unittests/Format/NamespaceEndCommentsFixerTest.cpp Wed May 29 
09:22:43 2019
@@ -45,124 +45,124 @@ protected:
 
 TEST_F(NamespaceEndCommentsFixerTest, AddsEndComment) {
   EXPECT_EQ("namespace {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}// namespace",
 fixNamespaceEndComments("namespace {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}"));
   EXPECT_EQ("namespace {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}// namespace\n",
 fixNamespaceEndComments("namespace {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}\n"));
   EXPECT_EQ("namespace A {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}// namespace A",
 fixNamespaceEndComments("namespace A {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}"));
   EXPECT_EQ("inline namespace A {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}// namespace A",
 fixNamespaceEndComments("inline namespace A {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}"));
   EXPECT_EQ("namespace ::A {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}// namespace ::A",
 fixNamespaceEndComments("namespace ::A {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}"));
   EXPECT_EQ("namespace ::A::B {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}// namespace ::A::B",
 fixNamespaceEndComments("namespace ::A::B {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}"));
   EXPECT_EQ("namespace /**/::/**/A/**/::/**/B/**/ {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}// namespace ::A::B",
 fixNamespaceEndComments("namespace /**/::/**/A/**/::/**/B/**/ {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}"));
   EXPECT_EQ("namespace A {\n"
 "namespace B {\n"
-"  int i;\n"
+"int i;\n"
 "}\n"
 "}// namespace A",
 fixNamespaceEndComments("namespace A {\n"
 "namespace B {\n"
-"  int i;\n"
+"int i;\n"
 "}\n"
 "}"));
   EXPECT_EQ("namespace A {\n"
 "namespace B {\n"
-"  int i;\n"
-"  int j;\n"
+"int i;\n"
+"int j;\n"
 "}// na

  1   2   3   >