[PATCH] D57664: [opaque pointer types] Fix the CallInfo passed to EmitCall in some edge cases.

2019-02-03 Thread James Y Knight via Phabricator via cfe-commits
jyknight created this revision.
jyknight added reviewers: dblaikie, rsmith.
Herald added a subscriber: Anastasia.
Herald added a project: clang.

Currently, EmitCall emits a call instruction with a function type
derived from the pointee-type of the callee. This *should* be the same
as the type created from the CallInfo parameter, but in some cases an
incorrect CallInfo was being passed.

All of these fixes were discovered by the addition of the assert in
EmitCall which verifies that the passed-in CallInfo matches the
Callee's function type.

As far as I know, these issues caused no bugs at the moment, as the
correct types were ultimately being emitted. But, some would become
problematic when pointee types are removed.

List of fixes:

- arrangeCXXConstructorCall was passing an incorrect value for the number of 
Required args, when calling an inheriting constructor where the inherited 
constructor is variadic. (The inheriting constructor doesn't actually get 
passed any of the user's args, but the code was calculating it as if it did).

- arrangeFreeFunctionLikeCall was not including the count of the 
pass_object_size arguments in the count of required args.

- OpenCL uses other address spaces for the "this" pointer. However, 
commonEmitCXXMemberOrOperatorCall was not annotating the address space on the 
"this" argument of the call.

- Destructor calls were being created with EmitCXXMemberOrOperatorCall instead 
of EmitCXXDestructorCall in a few places. This was a problem because the 
calling convention sometimes has destructors returning "this" rather than void, 
and the latter function knows about that, and sets up the types properly 
(through calling arrangeCXXStructorDeclaration), while the former does not.

- generateObjCGetterBody: the 'objc_getProperty' function returns type 'id', 
but was being called as if it returned the particular property's type. (That is 
of course the *dynamic* return type, and there's a downcast immediately after.)

- OpenMP user-defined reduction functions (#pragma omp declare reduction) can 
be called with a subclass of the declared type. In such case, the call was 
being setup as if the function had been actually declared to take the subtype, 
rather than the base type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D57664

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CodeGenTypes.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/CodeGenObjC/getter-property-mismatch.m

Index: clang/test/CodeGenObjC/getter-property-mismatch.m
===
--- clang/test/CodeGenObjC/getter-property-mismatch.m
+++ clang/test/CodeGenObjC/getter-property-mismatch.m
@@ -15,6 +15,4 @@
 
 // CHECK:  [[CALL:%.*]] = tail call i8* @objc_getProperty
 // CHECK:  [[ONE:%.*]] = bitcast i8* [[CALL:%.*]] to [[T1:%.*]]*
-// CHECK:  [[TWO:%.*]] = bitcast [[T1]]* [[ONE]] to [[T2:%.*]]*
-// CHECK:  ret [[T2]]* [[TWO]]
-
+// CHECK:  ret [[T1]]* [[ONE]]
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -10747,7 +10747,8 @@
   return D;
 return nullptr;
   }))
-return SemaRef.BuildDeclRefExpr(VD, Ty, VK_LValue, Loc);
+return SemaRef.BuildDeclRefExpr(VD, VD->getType().getNonReferenceType(),
+VK_LValue, Loc);
   if (auto *VD = filterLookupForUDR(
   Lookups, [, Ty, Loc](ValueDecl *D) -> ValueDecl * {
 if (!D->isInvalidDecl() &&
@@ -10765,7 +10766,8 @@
  /*DiagID=*/0) !=
 Sema::AR_inaccessible) {
   SemaRef.BuildBasePathArray(Paths, BasePath);
-  return SemaRef.BuildDeclRefExpr(VD, Ty, VK_LValue, Loc);
+  return SemaRef.BuildDeclRefExpr(
+  VD, VD->getType().getNonReferenceType(), VK_LValue, Loc);
 }
   }
 }
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -1566,9 +1566,8 @@
 Callee = CGCallee::forDirect(
 CGM.getAddrOfCXXStructor(DD, getFromDtorType(Type)), GD);
 
-  CGF.EmitCXXMemberOrOperatorCall(DD, Callee, ReturnValueSlot(),
-  This.getPointer(), VTT, VTTTy,
-  nullptr, nullptr);
+  CGF.EmitCXXDestructorCall(DD, Callee, This.getPointer(), VTT, VTTTy, nullptr,
+getFromDtorType(Type));
 }
 
 void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables ,
@@ -1766,9 +1765,8 @@
   CGCallee Callee =
   CGCallee::forVirtual(CE, GlobalDecl(Dtor, DtorType), This, Ty);
 
-  CGF.EmitCXXMemberOrOperatorCall(Dtor, Callee, ReturnValueSlot(),
-  

[PATCH] D57665: [clang-tidy] Handle unions with existing default-member-init

2019-02-03 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons created this revision.
malcolm.parsons added reviewers: aaron.ballman, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

clang-tidy's modernize-use-default-member-init was crashing for unions
with an existing default member initializer.

Fixes PR40492


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D57665

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tools-extra/test/clang-tidy/modernize-use-default-member-init.cpp


Index: clang-tools-extra/test/clang-tidy/modernize-use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-use-default-member-init.cpp
@@ -382,6 +382,16 @@
   const char *e4 = "bar";
 };
 
+struct UnionExisting {
+  UnionExisting() : e(5.0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: member initializer for 'e' is 
redundant
+  // CHECK-FIXES: UnionExisting()  {}
+  union {
+int i;
+double e = 5.0;
+  };
+};
+
 template 
 struct NegativeTemplateExisting {
   NegativeTemplateExisting(int) : t(0) {}
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -273,7 +273,7 @@
 
 void UseDefaultMemberInitCheck::checkExistingInit(
 const MatchFinder::MatchResult , const CXXCtorInitializer *Init) {
-  const FieldDecl *Field = Init->getMember();
+  const FieldDecl *Field = Init->getAnyMember();
 
   if (!sameValue(Field->getInClassInitializer(), Init->getInit()))
 return;


Index: clang-tools-extra/test/clang-tidy/modernize-use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-use-default-member-init.cpp
@@ -382,6 +382,16 @@
   const char *e4 = "bar";
 };
 
+struct UnionExisting {
+  UnionExisting() : e(5.0) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: member initializer for 'e' is redundant
+  // CHECK-FIXES: UnionExisting()  {}
+  union {
+int i;
+double e = 5.0;
+  };
+};
+
 template 
 struct NegativeTemplateExisting {
   NegativeTemplateExisting(int) : t(0) {}
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -273,7 +273,7 @@
 
 void UseDefaultMemberInitCheck::checkExistingInit(
 const MatchFinder::MatchResult , const CXXCtorInitializer *Init) {
-  const FieldDecl *Field = Init->getMember();
+  const FieldDecl *Field = Init->getAnyMember();
 
   if (!sameValue(Field->getInClassInitializer(), Init->getInit()))
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

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

I don't see -plugin-opt=-riscv-ssection-threshold=.. being passed.
tools::gnutools::Linker::ConstructJob is being invoked with target 
riscv32-unknown-linux-gnu
It has to work for riscv32-unknown-linux-gnu and riscv32-unknown-elf


Repository:
  rC Clang

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

https://reviews.llvm.org/D57497



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


[PATCH] D57649: [ASTDump] Add a flag indicating whether a CXXThisExpr is implicit

2019-02-03 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added a comment.

I have no objection to this, but I wonder whether all state accessible from all 
nodes should be part of the AST dump. Where do you think the line is? Is there 
anything else missing currently from other nodes?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57649



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


[PATCH] D57649: [ASTDump] Add a flag indicating whether a CXXThisExpr is implicit

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

Thanks for the review !


Repository:
  rC Clang

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

https://reviews.llvm.org/D57649



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


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

2019-02-03 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis created this revision.
zinovy.nis added reviewers: alexfh, ehsan.
zinovy.nis added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a reviewer: serge-sans-paille.
Herald added a project: clang.

This patch has 2 rationales:

- large patches lead to long command lines and often cause max command line 
length restrictions imposed by OS;
- clang-tidy runs are independent and can be done in parallel, the same as done 
for run-clang-tidy.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D57662

Files:
  clang-tidy/tool/clang-tidy-diff.py

Index: clang-tidy/tool/clang-tidy-diff.py
===
--- clang-tidy/tool/clang-tidy-diff.py
+++ clang-tidy/tool/clang-tidy-diff.py
@@ -25,9 +25,50 @@
 
 import argparse
 import json
+import multiprocessing
+import os
 import re
 import subprocess
 import sys
+import threading
+
+is_py2 = sys.version[0] == '2'
+
+if is_py2:
+import Queue as queue
+else:
+import queue as queue
+
+def run_tidy(task_queue, lock, timeout):
+  while True:
+command = task_queue.get()
+proc = subprocess.Popen(command,
+stdout=subprocess.PIPE,
+stderr=subprocess.PIPE)
+if not timeout is None:
+  watchdog = threading.Timer(timeout, proc.kill)
+try:
+  if not timeout is None:
+watchdog.start()
+  stdout, stderr = proc.communicate()
+  with lock:
+sys.stdout.write(command + '\n' + stdout.decode('utf-8') + '\n')
+if len(stderr) > 0:
+  sys.stderr.write(stderr.decode('utf-8') + '\n')
+finally:
+  if not timeout is None:
+if not watchdog.is_alive():
+  with lock:
+sys.stderr.write(command + "\tterminated after timeout\n")
+watchdog.cancel()
+  task_queue.task_done()
+
+
+def run_workers(max_tasks, tidy_caller, task_queue, lock, timeout):
+  for _ in range(max_tasks):
+t = threading.Thread(target=tidy_caller, args=(task_queue, lock, timeout))
+t.daemon = True
+t.start()
 
 
 def main():
@@ -48,6 +89,10 @@
   help='custom pattern selecting file paths to check '
   '(case insensitive, overridden by -regex)')
 
+  parser.add_argument('-j', type=int, default=0,
+  help='number of tidy instances to be run in parallel.')
+  parser.add_argument('-timeout', type=int, default=None,
+  help='timeout per each file in seconds.')
   parser.add_argument('-fix', action='store_true', default=False,
   help='apply suggested fixes')
   parser.add_argument('-checks',
@@ -84,7 +129,7 @@
 match = re.search('^\+\+\+\ \"?(.*?/){%s}([^ \t\n\"]*)' % args.p, line)
 if match:
   filename = match.group(2)
-if filename == None:
+if filename is None:
   continue
 
 if args.regex is not None:
@@ -102,44 +147,68 @@
 line_count = int(match.group(3))
   if line_count == 0:
 continue
-  end_line = start_line + line_count - 1;
+  end_line = start_line + line_count - 1
   lines_by_file.setdefault(filename, []).append([start_line, end_line])
 
-  if len(lines_by_file) == 0:
+  if not any(lines_by_file):
 print("No relevant changes found.")
 sys.exit(0)
 
-  line_filter_json = json.dumps(
-[{"name" : name, "lines" : lines_by_file[name]} for name in lines_by_file],
-separators = (',', ':'))
+  max_task = args.j
+  if max_task == 0:
+  max_task = multiprocessing.cpu_count()
+  max_task = min(len(lines_by_file), max_task)
 
-  quote = "";
-  if sys.platform == 'win32':
-line_filter_json=re.sub(r'"', r'"""', line_filter_json)
-  else:
-quote = "'";
+  # Tasks for clang-tidy.
+  task_queue = queue.Queue(max_task)
+  # A lock for console output.
+  lock = threading.Lock()
 
-  # Run clang-tidy on files containing changes.
-  command = [args.clang_tidy_binary]
-  command.append('-line-filter=' + quote + line_filter_json + quote)
+  # Run a pool of clang-tidy workers.
+  run_workers(max_task, run_tidy, task_queue, lock, args.timeout)
+
+  # Run a watchdog.
+  quote = ""
+  if sys.platform != 'win32':
+quote = "'"
+
+  # Form the common args list.
+  common_clang_tidy_args = []
   if args.fix:
-command.append('-fix')
+common_clang_tidy_args.append('-fix')
   if args.export_fixes:
-command.append('-export-fixes=' + args.export_fixes)
+common_clang_tidy_args.append('-export-fixes=' + args.export_fixes)
   if args.checks != '':
-command.append('-checks=' + quote + args.checks + quote)
+common_clang_tidy_args.append('-checks=' + quote + args.checks + quote)
   if args.quiet:
-command.append('-quiet')
+common_clang_tidy_args.append('-quiet')
   if args.build_path is not None:
-command.append('-p=%s' % args.build_path)
-  command.extend(lines_by_file.keys())
+common_clang_tidy_args.append('-p=%s' % args.build_path)
   for 

r353006 - [AST] Update the comments of the various Expr::Ignore* + Related cleanups

2019-02-03 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Sun Feb  3 11:50:56 2019
New Revision: 353006

URL: http://llvm.org/viewvc/llvm-project?rev=353006=rev
Log:
[AST] Update the comments of the various Expr::Ignore* + Related cleanups

The description of what the various Expr::Ignore* do has drifted from the
actual implementation.

Inspection reveals that IgnoreParenImpCasts() is not equivalent to doing
IgnoreParens() + IgnoreImpCasts() until reaching a fixed point, but
IgnoreParenCasts() is equivalent to doing IgnoreParens() + IgnoreCasts()
until reaching a fixed point. There is also a fair amount of duplication
in the various Expr::Ignore* functions which increase the chance of further
future inconsistencies. In preparation for the next patch which will factor
out the implementation of the various Expr::Ignore*, do the following cleanups:

Remove Stmt::IgnoreImplicit, in favor of Expr::IgnoreImplicit. IgnoreImplicit
is the only function among all of the Expr::Ignore* which is available in Stmt.
There are only a few users of Stmt::IgnoreImplicit. They can just use instead
Expr::IgnoreImplicit like they have to do for the other Ignore*.

Move Expr::IgnoreImpCasts() from Expr.h to Expr.cpp. This made no difference
in the run-time with my usual benchmark (-fsyntax-only on all of Boost).

While we are at it, make IgnoreParenNoopCasts take a const reference to the
ASTContext for const correctness.

Update the comments to match what the Expr::Ignore* are actually doing.
I am not sure that listing exactly what each Expr::Ignore* do is optimal,
but it certainly looks better than the current state which is in my opinion
between misleading and just plain wrong.

The whole patch is NFC (if you count removing Stmt::IgnoreImplicit as NFC).

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

Reviewed By: aaron.ballman


Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
cfe/trunk/lib/ARCMigrate/TransformActions.cpp
cfe/trunk/lib/ARCMigrate/Transforms.cpp
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/Analysis/ReachableCode.cpp
cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=353006=353005=353006=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sun Feb  3 11:50:56 2019
@@ -746,67 +746,110 @@ public:
   /// member expression.
   static QualType findBoundMemberType(const Expr *expr);
 
-  /// IgnoreImpCasts - Skip past any implicit casts which might
-  /// surround this expression.  Only skips ImplicitCastExprs.
+  /// Skip past any implicit casts which might surround this expression until
+  /// reaching a fixed point. Skips:
+  /// * ImplicitCastExpr
+  /// * FullExpr
   Expr *IgnoreImpCasts() LLVM_READONLY;
-
-  /// IgnoreImplicit - Skip past any implicit AST nodes which might
-  /// surround this expression.
-  Expr *IgnoreImplicit() LLVM_READONLY {
-return cast(Stmt::IgnoreImplicit());
+  const Expr *IgnoreImpCasts() const {
+return const_cast(this)->IgnoreImpCasts();
   }
 
-  const Expr *IgnoreImplicit() const LLVM_READONLY {
-return const_cast(this)->IgnoreImplicit();
+  /// Skip past any casts which might surround this expression until reaching
+  /// a fixed point. Skips:
+  /// * CastExpr
+  /// * FullExpr
+  /// * MaterializeTemporaryExpr
+  /// * SubstNonTypeTemplateParmExpr
+  Expr *IgnoreCasts() LLVM_READONLY;
+  const Expr *IgnoreCasts() const {
+return const_cast(this)->IgnoreCasts();
   }
 
-  /// IgnoreParens - Ignore parentheses.  If this Expr is a ParenExpr, return
-  ///  its subexpression.  If that subexpression is also a ParenExpr,
-  ///  then this method recursively returns its subexpression, and so forth.
-  ///  Otherwise, the method returns the current Expr.
+  /// Skip past any implicit AST nodes which might surround this expression
+  /// until reaching a fixed point. Skips:
+  /// * What IgnoreImpCasts() skips
+  /// * MaterializeTemporaryExpr
+  /// * CXXBindTemporaryExpr
+  Expr *IgnoreImplicit() LLVM_READONLY;
+  const Expr *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
+
+  /// Skip past any parentheses which might surround this expression until
+  /// reaching a fixed point. Skips:
+  /// * ParenExpr
+  /// * UnaryOperator if `UO_Extension`
+  /// * GenericSelectionExpr if `!isResultDependent()`
+  /// * ChooseExpr if `!isConditionDependent()`
+  /// * ConstantExpr
   Expr *IgnoreParens() LLVM_READONLY;
+  const Expr *IgnoreParens() const {
+return const_cast(this)->IgnoreParens();
+  }
 
-  /// IgnoreParenCasts - Ignore parentheses and casts.  Strip off any ParenExpr
-  /// or CastExprs, returning their operand.
-  Expr *IgnoreParenCasts() LLVM_READONLY;
-
-  /// Ignore casts.  

[PATCH] D57266: [AST] Update the comments of the various Expr::Ignore* + Related cleanups

2019-02-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL353006: [AST] Update the comments of the various 
Expr::Ignore* + Related cleanups (authored by brunoricci, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57266?vs=184945=184971#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57266

Files:
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/lib/ARCMigrate/TransRetainReleaseDealloc.cpp
  cfe/trunk/lib/ARCMigrate/TransformActions.cpp
  cfe/trunk/lib/ARCMigrate/Transforms.cpp
  cfe/trunk/lib/AST/Expr.cpp
  cfe/trunk/lib/AST/Stmt.cpp
  cfe/trunk/lib/Analysis/ReachableCode.cpp
  cfe/trunk/lib/Tooling/ASTDiff/ASTDiff.cpp

Index: cfe/trunk/include/clang/AST/Expr.h
===
--- cfe/trunk/include/clang/AST/Expr.h
+++ cfe/trunk/include/clang/AST/Expr.h
@@ -746,67 +746,110 @@
   /// member expression.
   static QualType findBoundMemberType(const Expr *expr);
 
-  /// IgnoreImpCasts - Skip past any implicit casts which might
-  /// surround this expression.  Only skips ImplicitCastExprs.
+  /// Skip past any implicit casts which might surround this expression until
+  /// reaching a fixed point. Skips:
+  /// * ImplicitCastExpr
+  /// * FullExpr
   Expr *IgnoreImpCasts() LLVM_READONLY;
-
-  /// IgnoreImplicit - Skip past any implicit AST nodes which might
-  /// surround this expression.
-  Expr *IgnoreImplicit() LLVM_READONLY {
-return cast(Stmt::IgnoreImplicit());
+  const Expr *IgnoreImpCasts() const {
+return const_cast(this)->IgnoreImpCasts();
   }
 
-  const Expr *IgnoreImplicit() const LLVM_READONLY {
-return const_cast(this)->IgnoreImplicit();
+  /// Skip past any casts which might surround this expression until reaching
+  /// a fixed point. Skips:
+  /// * CastExpr
+  /// * FullExpr
+  /// * MaterializeTemporaryExpr
+  /// * SubstNonTypeTemplateParmExpr
+  Expr *IgnoreCasts() LLVM_READONLY;
+  const Expr *IgnoreCasts() const {
+return const_cast(this)->IgnoreCasts();
   }
 
-  /// IgnoreParens - Ignore parentheses.  If this Expr is a ParenExpr, return
-  ///  its subexpression.  If that subexpression is also a ParenExpr,
-  ///  then this method recursively returns its subexpression, and so forth.
-  ///  Otherwise, the method returns the current Expr.
+  /// Skip past any implicit AST nodes which might surround this expression
+  /// until reaching a fixed point. Skips:
+  /// * What IgnoreImpCasts() skips
+  /// * MaterializeTemporaryExpr
+  /// * CXXBindTemporaryExpr
+  Expr *IgnoreImplicit() LLVM_READONLY;
+  const Expr *IgnoreImplicit() const {
+return const_cast(this)->IgnoreImplicit();
+  }
+
+  /// Skip past any parentheses which might surround this expression until
+  /// reaching a fixed point. Skips:
+  /// * ParenExpr
+  /// * UnaryOperator if `UO_Extension`
+  /// * GenericSelectionExpr if `!isResultDependent()`
+  /// * ChooseExpr if `!isConditionDependent()`
+  /// * ConstantExpr
   Expr *IgnoreParens() LLVM_READONLY;
+  const Expr *IgnoreParens() const {
+return const_cast(this)->IgnoreParens();
+  }
 
-  /// IgnoreParenCasts - Ignore parentheses and casts.  Strip off any ParenExpr
-  /// or CastExprs, returning their operand.
-  Expr *IgnoreParenCasts() LLVM_READONLY;
-
-  /// Ignore casts.  Strip off any CastExprs, returning their operand.
-  Expr *IgnoreCasts() LLVM_READONLY;
-
-  /// IgnoreParenImpCasts - Ignore parentheses and implicit casts.  Strip off
-  /// any ParenExpr or ImplicitCastExprs, returning their operand.
+  /// Skip past any parentheses and implicit casts which might surround this
+  /// expression until reaching a fixed point.
+  /// FIXME: IgnoreParenImpCasts really ought to be equivalent to
+  /// IgnoreParens() + IgnoreImpCasts() until reaching a fixed point. However
+  /// this is currently not the case. Instead IgnoreParenImpCasts() skips:
+  /// * What IgnoreParens() skips
+  /// * ImplicitCastExpr
+  /// * MaterializeTemporaryExpr
+  /// * SubstNonTypeTemplateParmExpr
   Expr *IgnoreParenImpCasts() LLVM_READONLY;
+  const Expr *IgnoreParenImpCasts() const {
+return const_cast(this)->IgnoreParenImpCasts();
+  }
 
-  /// IgnoreConversionOperator - Ignore conversion operator. If this Expr is a
-  /// call to a conversion operator, return the argument.
-  Expr *IgnoreConversionOperator() LLVM_READONLY;
-
-  const Expr *IgnoreConversionOperator() const LLVM_READONLY {
-return const_cast(this)->IgnoreConversionOperator();
+  /// Skip past any parentheses and casts which might surround this expression
+  /// until reaching a fixed point. Skips:
+  /// * What IgnoreParens() skips
+  /// * What IgnoreCasts() skips
+  Expr *IgnoreParenCasts() LLVM_READONLY;
+  const Expr *IgnoreParenCasts() const {
+return 

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

2019-02-03 Thread Hylke Kleve via Phabricator via cfe-commits
hyklv created this revision.
hyklv added reviewers: alexfh, djasper.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Hi,

I'm trying to get clang-format suited for our code layout. I've set it up to 
align declarations and trailing comments. Tab size is 4; UseTab is set to 
Always. Configuration file is pasted below. I see that it misaligns the 
trailing comment for a file with this code:

  struct NavOffMeshGraphEdge
  {
pcRTTIRefObject mObject;  ///< 
The object NPC's will end up using to traverse this edge.
pNavMeshObject  mNavMeshObject{ nullptr };///< The navmesh 
object assigning costs for path finding over this edge.
  };

To align the second trailing comment it needs to insert 4 spaces. This should 
be one tab plus two spaces. It skips the logic of the first partial tab in 
`FirstTabWidth (=2) + Style.TabWidth (=4) <= Spaces (=4)` while it shouldn't. 
Proposed fix is attached.

Our .clang-format is setup with:

  ---
  Language:Cpp
  AccessModifierOffset: -4
  AlignAfterOpenBracket: Align
  AlignConsecutiveAssignments: true
  AlignConsecutiveDeclarations: true
  AlignEscapedNewlines: Right
  AlignOperands:   true
  AlignTrailingComments: true
  AllowAllParametersOfDeclarationOnNextLine: false
  AllowShortBlocksOnASingleLine: true
  AllowShortCaseLabelsOnASingleLine: true
  AllowShortFunctionsOnASingleLine: Inline
  AllowShortIfStatementsOnASingleLine: false
  AllowShortLoopsOnASingleLine: false
  AlwaysBreakAfterDefinitionReturnType: None
  AlwaysBreakAfterReturnType: None
  AlwaysBreakBeforeMultilineStrings: false
  AlwaysBreakTemplateDeclarations: true
  BinPackArguments: true
  BinPackParameters: true
  BraceWrapping:   
AfterClass:  true
AfterControlStatement: true
AfterEnum:   true
AfterFunction:   true
AfterNamespace:  true
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion:  true
BeforeCatch: true
BeforeElse:  true
IndentBraces:false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
  BreakBeforeBinaryOperators: None
  BreakBeforeBraces: Custom
  BreakBeforeInheritanceComma: false
  BreakBeforeTernaryOperators: false
  BreakConstructorInitializersBeforeComma: false
  BreakConstructorInitializers: AfterColon
  BreakAfterJavaFieldAnnotations: false
  BreakStringLiterals: false
  ColumnLimit: 5000
  CommentPragmas:  '^ IWYU pragma:'
  CompactNamespaces: false
  ConstructorInitializerAllOnOneLineOrOnePerLine: true
  ConstructorInitializerIndentWidth: 4
  ContinuationIndentWidth: 4
  Cpp11BracedListStyle: false
  DerivePointerAlignment: false
  DisableFormat:   false
  ExperimentalAutoDetectBinPacking: false
  FixNamespaceComments: false
  ForEachMacros:   
- foreach
- Q_FOREACH
- BOOST_FOREACH
  IncludeCategories: 
- Regex:   '^".*\.h"'
  Priority:1
- Regex:   '^'
  Priority:2
- Regex:   '^<.*\.h>'
  Priority:1
- Regex:   '^<.*'
  Priority:2
- Regex:   '.*'
  Priority:3
  IncludeIsMainRegex: '([-_](test|unittest))?$'
  IndentCaseLabels: false
  IndentWidth: 4
  IndentWrappedFunctionNames: true
  IndentPPDirectives: None
  JavaScriptQuotes: Leave
  JavaScriptWrapImports: true
  KeepEmptyLinesAtTheStartOfBlocks: false
  MacroBlockBegin: "^RTTI_START_"
  MacroBlockEnd: "^\
  RTTI_END"
  MaxEmptyLinesToKeep: 3
  NamespaceIndentation: None
  ObjCBlockIndentWidth: 2
  ObjCSpaceAfterProperty: false
  ObjCSpaceBeforeProtocolList: false
  PenaltyBreakAssignment: 2
  PenaltyBreakBeforeFirstCallParameter: 1
  PenaltyBreakComment: 300
  PenaltyBreakFirstLessLess: 120
  PenaltyBreakString: 1000
  PenaltyExcessCharacter: 100
  PenaltyReturnTypeOnItsOwnLine: 200
  PointerAlignment: Left
  ReflowComments:  true
  SortIncludes:true
  SortUsingDeclarations: true
  SpaceAfterCStyleCast: true
  SpaceAfterTemplateKeyword: true
  SpaceBeforeAssignmentOperators: true
  SpaceBeforeParens: ControlStatements
  SpaceInEmptyParentheses: false
  SpacesBeforeTrailingComments: 4
  SpacesInAngles:  false
  SpacesInContainerLiterals: false
  SpacesInCStyleCastParentheses: false
  SpacesInParentheses: false
  SpacesInSquareBrackets: false
  Standard:Auto
  TabWidth:4
  UseTab:  Always
  ...




Repository:
  rC Clang

https://reviews.llvm.org/D57655

Files:
  WhitespaceManager.cpp


Index: WhitespaceManager.cpp
===
--- WhitespaceManager.cpp
+++ WhitespaceManager.cpp
@@ -1,9 +1,10 @@
 //===--- WhitespaceManager.cpp - Format C++ code 
--===//
 //
-// 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
+//   

r353003 - [ASTDump] Add a flag indicating whether a CXXThisExpr is implicit

2019-02-03 Thread Bruno Ricci via cfe-commits
Author: brunoricci
Date: Sun Feb  3 10:20:27 2019
New Revision: 353003

URL: http://llvm.org/viewvc/llvm-project?rev=353003=rev
Log:
[ASTDump] Add a flag indicating whether a CXXThisExpr is implicit

There is currently no way to distinguish implicit from explicit
CXXThisExpr in the AST dump output.

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

Reviewed By: steveire


Modified:
cfe/trunk/lib/AST/TextNodeDumper.cpp
cfe/trunk/test/AST/ast-dump-expr.cpp
cfe/trunk/test/AST/dump.cpp
cfe/trunk/test/AST/float16.cpp

Modified: cfe/trunk/lib/AST/TextNodeDumper.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TextNodeDumper.cpp?rev=353003=353002=353003=diff
==
--- cfe/trunk/lib/AST/TextNodeDumper.cpp (original)
+++ cfe/trunk/lib/AST/TextNodeDumper.cpp Sun Feb  3 10:20:27 2019
@@ -854,6 +854,8 @@ void TextNodeDumper::VisitCXXBoolLiteral
 }
 
 void TextNodeDumper::VisitCXXThisExpr(const CXXThisExpr *Node) {
+  if (Node->isImplicit())
+OS << " implicit";
   OS << " this";
 }
 

Modified: cfe/trunk/test/AST/ast-dump-expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/ast-dump-expr.cpp?rev=353003=353002=353003=diff
==
--- cfe/trunk/test/AST/ast-dump-expr.cpp (original)
+++ cfe/trunk/test/AST/ast-dump-expr.cpp Sun Feb  3 10:20:27 2019
@@ -255,7 +255,7 @@ void PrimaryExpressions(Ts... a) {
   // CHECK-NEXT: FieldDecl 0x{{[^ ]*}}  col:8 implicit 'V *'
   // CHECK-NEXT: CXXMethodDecl
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' this
+  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' implicit this
 
   [*this]{};
   // CHECK: LambdaExpr 0x{{[^ ]*}} 
@@ -272,7 +272,7 @@ void PrimaryExpressions(Ts... a) {
   // CHECK-NEXT: CompoundStmt
   // CHECK-NEXT: ParenListExpr 0x{{[^ ]*}}  'NULL TYPE'
   // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}}  '' 
prefix '*' cannot overflow
-  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' this
+  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' implicit this
 }
   };
 

Modified: cfe/trunk/test/AST/dump.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/dump.cpp?rev=353003=353002=353003=diff
==
--- cfe/trunk/test/AST/dump.cpp (original)
+++ cfe/trunk/test/AST/dump.cpp Sun Feb  3 10:20:27 2019
@@ -56,7 +56,7 @@ struct S {
 // CHECK-NEXT: |   | `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} 'a' 'int &'
 // CHECK-NEXT: |   |-OMPSharedClause {{.+}} 
 // CHECK-NEXT: |   | `-MemberExpr {{.+}}  'int' lvalue ->b
-// CHECK-NEXT: |   |   `-CXXThisExpr {{.+}}  'S *' this
+// CHECK-NEXT: |   |   `-CXXThisExpr {{.+}}  'S *' implicit this
 // CHECK-NEXT: |   |-OMPScheduleClause {{.+}} 
 // CHECK-NEXT: |   | `-ImplicitCastExpr {{.+}}  'int' 

 // CHECK-NEXT: |   |   `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} '.capture_expr.' 'int'

Modified: cfe/trunk/test/AST/float16.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/AST/float16.cpp?rev=353003=353002=353003=diff
==
--- cfe/trunk/test/AST/float16.cpp (original)
+++ cfe/trunk/test/AST/float16.cpp Sun Feb  3 10:20:27 2019
@@ -132,7 +132,7 @@ public:
 //CHECK-NEXT: | | `-BinaryOperator {{.*}} '_Float16' '+'
 //CHECK-NEXT: | |   |-ImplicitCastExpr {{.*}} '_Float16' 
 //CHECK-NEXT: | |   | `-MemberExpr {{.*}} '_Float16' lvalue ->f1c 0x{{.*}}
-//CHECK-NEXT: | |   |   `-CXXThisExpr {{.*}} 'C1 *' this
+//CHECK-NEXT: | |   |   `-CXXThisExpr {{.*}} 'C1 *' implicit this
 //CHECK-NEXT: | |   `-ImplicitCastExpr {{.*}} '_Float16' 
 //CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 
0x{{.*}} 'arg' '_Float16'
 //CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func2c '_Float16 (_Float16)' static


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


[PATCH] D57649: [ASTDump] Add a flag indicating whether a CXXThisExpr is implicit

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

In D57649#1382470 , @riccibruno wrote:

> Though it is a subjective distinction and in the end if someone need a flag 
> it is going to be added I guess.


That's the crux of how we've decided what information to expose in the past. 
Some folks will expose the information when adding it to an AST node, but not 
always. More often what happens is that someone finds they need that 
information to help make an AST dump more readable, then the information gets 
exposed at that point because there's a use case for it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57649



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


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

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

Do the following NFCs, before doing anything more substantial:

1. Add some comments to hopefully reduce the amount of code staring for the 
next guy.
2. Pack `UsageInfo` by storing the using expressions and sequencing regions 
separately. There is no point in wasting space here.


Repository:
  rC Clang

https://reviews.llvm.org/D57659

Files:
  lib/Sema/SemaChecking.cpp

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

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

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

Teach the unsequenced operation checker about references and members. To do 
this introduce a class `MemoryLocation` which will approximate C++ memory 
locations.

We don't handle bit-fields for now but I plan to do this later. I also plan to 
teach it about the C++17 sequencing rules, and fix a number of corner cases 
around `||`, `&&` and `?:`.


Repository:
  rC Clang

https://reviews.llvm.org/D57660

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

Index: test/SemaCXX/warn-unsequenced.cpp
===
--- test/SemaCXX/warn-unsequenced.cpp
+++ test/SemaCXX/warn-unsequenced.cpp
@@ -131,54 +131,53 @@
 
   // Operations with a single member of the implicit object.
   ++a = 0; // no-warning
-  a + ++a; // expected-warning {{unsequenced modification and access to 'a'}}
+  a + ++a; // expected-warning {{unsequenced modification and access to member 'a'}}
   a = ++a; // no-warning
-  a + a++; // expected-warning {{unsequenced modification and access to 'a'}}
-  a = a++; // expected-warning {{multiple unsequenced modifications to 'a'}}
+  a + a++; // expected-warning {{unsequenced modification and access to member 'a'}}
+  a = a++; // expected-warning {{multiple unsequenced modifications to member 'a'}}
   ++ ++a; // no-warning
   (a++, a++); // no-warning
-  ++a + ++a; // expected-warning {{multiple unsequenced modifications to 'a'}}
-  a++ + a++; // expected-warning {{multiple unsequenced modifications to 'a'}}
+  ++a + ++a; // expected-warning {{multiple unsequenced modifications to member 'a'}}
+  a++ + a++; // expected-warning {{multiple unsequenced modifications to member 'a'}}
   (a++, a) = 0; // no-warning
   a = xs[++a]; // no-warning
-  a = xs[a++]; // expected-warning {{multiple unsequenced modifications to 'a'}}
-  (a ? xs[0] : xs[1]) = ++a; // expected-warning {{unsequenced modification and access to 'a'}}
+  a = xs[a++]; // expected-warning {{multiple unsequenced modifications to member 'a'}}
+  (a ? xs[0] : xs[1]) = ++a; // expected-warning {{unsequenced modification and access to member 'a'}}
   a = (++a, ++a); // no-warning
   a = (a++, ++a); // no-warning
-  a = (a++, a++); // expected-warning {{multiple unsequenced modifications to 'a'}}
+  a = (a++, a++); // expected-warning {{multiple unsequenced modifications to member 'a'}}
   f(a, a); // no-warning
-  f(a = 0, a); // expected-warning {{unsequenced modification and access to 'a'}}
-  f(a, a += 0); // expected-warning {{unsequenced modification and access to 'a'}}
-  f(a = 0, a = 0); // expected-warning {{multiple unsequenced modifications to 'a'}}
+  f(a = 0, a); // expected-warning {{unsequenced modification and access to member 'a'}}
+  f(a, a += 0); // expected-warning {{unsequenced modification and access to member 'a'}}
+  f(a = 0, a = 0); // expected-warning {{multiple unsequenced modifications to member 'a'}}
   a = f(++a); // no-warning
   a = f(a++); // no-warning
-  a = f(++a, a++); // expected-warning {{multiple unsequenced modifications to 'a'}}
+  a = f(++a, a++); // expected-warning {{multiple unsequenced modifications to member 'a'}}
 
   // Operations with a single member of the other object 's'.
-  // TODO: For now this is completely unhandled.
   ++s.a = 0; // no-warning
-  s.a + ++s.a; // no-warning TODO {{unsequenced modification and access to }}
+  s.a + ++s.a; // expected-warning {{unsequenced modification and access to member 'a' of 's'}}
   s.a = ++s.a; // no-warning
-  s.a + s.a++; // no-warning TODO {{unsequenced modification and access to }}
-  s.a = s.a++; // no-warning TODO {{multiple unsequenced modifications to }}
+  s.a + s.a++; // expected-warning {{unsequenced modification and access to member 'a' of 's'}}
+  s.a = s.a++; // expected-warning {{multiple unsequenced modifications to member 'a' of 's'}}
   ++ ++s.a; // no-warning
   (s.a++, s.a++); // no-warning
-  ++s.a + ++s.a; // no-warning TODO {{multiple unsequenced modifications to }}
-  s.a++ + s.a++; // no-warning TODO {{multiple unsequenced modifications to }}
+  ++s.a + ++s.a; // expected-warning {{multiple unsequenced modifications to member 'a' of 's'}}
+  s.a++ + s.a++; // expected-warning {{multiple unsequenced modifications to member 'a' of 's'}}
   (s.a++, s.a) = 0; // no-warning
   s.a = xs[++s.a]; // no-warning
-  s.a = xs[s.a++]; // no-warning TODO {{multiple unsequenced modifications to }}
-  (s.a ? xs[0] : xs[1]) = ++s.a; // no-warning TODO {{unsequenced modification and access to }}
+  s.a = xs[s.a++]; // expected-warning {{multiple unsequenced modifications to member 'a' of 's'}}
+  (s.a ? xs[0] : xs[1]) = ++s.a; // expected-warning {{unsequenced modification and access to member 'a' of 's'}}
   s.a = (++s.a, ++s.a); // no-warning
   s.a = (s.a++, ++s.a); 

[PATCH] D57634: Support for GCC's `__builtin_va_arg_pack{,_len}`

2019-02-03 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington abandoned this revision.
erik.pilkington added a comment.

Tentatively marking as abandoned, Eli suggested a different approach in the 
LLVM review which I'm going to look into.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57634



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


[PATCH] D57649: [ASTDump] Add a flag indicating whether a CXXThisExpr is implicit

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

In D57649#1382477 , @aaron.ballman 
wrote:

> In D57649#1382470 , @riccibruno 
> wrote:
>
> > Though it is a subjective distinction and in the end if someone need a flag 
> > it is going to be added I guess.
>
>
> That's the crux of how we've decided what information to expose in the past. 
> Some folks will expose the information when adding it to an AST node, but not 
> always. More often what happens is that someone finds they need that 
> information to help make an AST dump more readable, then the information gets 
> exposed at that point because there's a use case for it.


Which is exactly why I added this flag. From what I understand the AST dump is 
mostly a tool used by people hacking on clang, and so this make sense.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57649



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


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

2019-02-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri requested changes to this revision.
lebedev.ri added a comment.
This revision now requires changes to proceed.

Test?
Is this a fix, or a new formatting style?




Comment at: WhitespaceManager.cpp:3-6
+// The LLVM Compiler Infrastructure
 //
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.

That is incorrect.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57655



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


[PATCH] D57649: [ASTDump] Add a flag indicating whether a CXXThisExpr is implicit

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

In D57649#1382453 , @steveire wrote:

> I have no objection to this, but I wonder whether all state accessible from 
> all nodes should be part of the AST dump. Where do you think the line is? Is 
> there anything else missing currently from other nodes?


I think that this depends on the specific node. It seem that there should be a 
distinction between state that is "generally useful" (whatever that means) to 
the average clang developer/user and internal state which is there for a narrow 
specific purpose. For example (looking at the statement/expression hierarchy):

`NullStmt` has a flag `HasLeadingEmptyMacro` => probably not useful to expose.
`SwitchStmt` has a flag `AllEnumCasesCovered` which is used for diagnostics => 
probably not useful to expose.

Additionally some flags are there only to remember which trailing objects are 
there. I don't think that exposing these is useful (as long as the AST dump 
output is unambiguous).

Though it is a subjective distinction and in the end if someone need a flag it 
is going to be added I guess.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57649



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


[PATCH] D57649: [ASTDump] Add a flag indicating whether a CXXThisExpr is implicit

2019-02-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC353003: [ASTDump] Add a flag indicating whether a 
CXXThisExpr is implicit (authored by brunoricci, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D57649

Files:
  lib/AST/TextNodeDumper.cpp
  test/AST/ast-dump-expr.cpp
  test/AST/dump.cpp
  test/AST/float16.cpp


Index: test/AST/ast-dump-expr.cpp
===
--- test/AST/ast-dump-expr.cpp
+++ test/AST/ast-dump-expr.cpp
@@ -255,7 +255,7 @@
   // CHECK-NEXT: FieldDecl 0x{{[^ ]*}}  col:8 implicit 'V *'
   // CHECK-NEXT: CXXMethodDecl
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' this
+  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' implicit this
 
   [*this]{};
   // CHECK: LambdaExpr 0x{{[^ ]*}} 
@@ -272,7 +272,7 @@
   // CHECK-NEXT: CompoundStmt
   // CHECK-NEXT: ParenListExpr 0x{{[^ ]*}}  'NULL TYPE'
   // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}}  '' 
prefix '*' cannot overflow
-  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' this
+  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' implicit this
 }
   };
 
Index: test/AST/float16.cpp
===
--- test/AST/float16.cpp
+++ test/AST/float16.cpp
@@ -132,7 +132,7 @@
 //CHECK-NEXT: | | `-BinaryOperator {{.*}} '_Float16' '+'
 //CHECK-NEXT: | |   |-ImplicitCastExpr {{.*}} '_Float16' 
 //CHECK-NEXT: | |   | `-MemberExpr {{.*}} '_Float16' lvalue ->f1c 0x{{.*}}
-//CHECK-NEXT: | |   |   `-CXXThisExpr {{.*}} 'C1 *' this
+//CHECK-NEXT: | |   |   `-CXXThisExpr {{.*}} 'C1 *' implicit this
 //CHECK-NEXT: | |   `-ImplicitCastExpr {{.*}} '_Float16' 
 //CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 
0x{{.*}} 'arg' '_Float16'
 //CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func2c '_Float16 (_Float16)' static
Index: test/AST/dump.cpp
===
--- test/AST/dump.cpp
+++ test/AST/dump.cpp
@@ -56,7 +56,7 @@
 // CHECK-NEXT: |   | `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} 'a' 'int &'
 // CHECK-NEXT: |   |-OMPSharedClause {{.+}} 
 // CHECK-NEXT: |   | `-MemberExpr {{.+}}  'int' lvalue ->b
-// CHECK-NEXT: |   |   `-CXXThisExpr {{.+}}  'S *' this
+// CHECK-NEXT: |   |   `-CXXThisExpr {{.+}}  'S *' implicit this
 // CHECK-NEXT: |   |-OMPScheduleClause {{.+}} 
 // CHECK-NEXT: |   | `-ImplicitCastExpr {{.+}}  'int' 

 // CHECK-NEXT: |   |   `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} '.capture_expr.' 'int'
Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -854,6 +854,8 @@
 }
 
 void TextNodeDumper::VisitCXXThisExpr(const CXXThisExpr *Node) {
+  if (Node->isImplicit())
+OS << " implicit";
   OS << " this";
 }
 


Index: test/AST/ast-dump-expr.cpp
===
--- test/AST/ast-dump-expr.cpp
+++ test/AST/ast-dump-expr.cpp
@@ -255,7 +255,7 @@
   // CHECK-NEXT: FieldDecl 0x{{[^ ]*}}  col:8 implicit 'V *'
   // CHECK-NEXT: CXXMethodDecl
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' this
+  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' implicit this
 
   [*this]{};
   // CHECK: LambdaExpr 0x{{[^ ]*}} 
@@ -272,7 +272,7 @@
   // CHECK-NEXT: CompoundStmt
   // CHECK-NEXT: ParenListExpr 0x{{[^ ]*}}  'NULL TYPE'
   // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}}  '' prefix '*' cannot overflow
-  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' this
+  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' implicit this
 }
   };
 
Index: test/AST/float16.cpp
===
--- test/AST/float16.cpp
+++ test/AST/float16.cpp
@@ -132,7 +132,7 @@
 //CHECK-NEXT: | | `-BinaryOperator {{.*}} '_Float16' '+'
 //CHECK-NEXT: | |   |-ImplicitCastExpr {{.*}} '_Float16' 
 //CHECK-NEXT: | |   | `-MemberExpr {{.*}} '_Float16' lvalue ->f1c 0x{{.*}}
-//CHECK-NEXT: | |   |   `-CXXThisExpr {{.*}} 'C1 *' this
+//CHECK-NEXT: | |   |   `-CXXThisExpr {{.*}} 'C1 *' implicit this
 //CHECK-NEXT: | |   `-ImplicitCastExpr {{.*}} '_Float16' 
 //CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
 //CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func2c '_Float16 (_Float16)' static
Index: test/AST/dump.cpp
===
--- test/AST/dump.cpp
+++ test/AST/dump.cpp
@@ -56,7 +56,7 @@
 // CHECK-NEXT: |   | `-DeclRefExpr {{.+}}  'int' lvalue OMPCapturedExpr {{.+}} 'a' 'int &'
 // CHECK-NEXT: |   |-OMPSharedClause {{.+}} 
 // CHECK-NEXT: | 

[PATCH] D57661: [Sema] SequenceChecker: Add tests for references and members.

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

Tests for D57660 .


Repository:
  rC Clang

https://reviews.llvm.org/D57661

Files:
  test/SemaCXX/warn-unsequenced.cpp

Index: test/SemaCXX/warn-unsequenced.cpp
===
--- test/SemaCXX/warn-unsequenced.cpp
+++ test/SemaCXX/warn-unsequenced.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wno-unused %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wno-unused -Wno-uninitialized -Wunsequenced %s
 
 int f(int, int = 0);
 
@@ -21,62 +21,62 @@
   ++ ++a; // ok
   (a++, a++); // ok
   ++a + ++a; // expected-warning {{multiple unsequenced modifications to 'a'}}
-  a++ + a++; // expected-warning {{multiple unsequenced modifications}}
+  a++ + a++; // expected-warning {{multiple unsequenced modifications to 'a'}}
   (a++, a) = 0; // ok, increment is sequenced before value computation of LHS
   a = xs[++a]; // ok
-  a = xs[a++]; // expected-warning {{multiple unsequenced modifications}}
-  (a ? xs[0] : xs[1]) = ++a; // expected-warning {{unsequenced modification and access}}
+  a = xs[a++]; // expected-warning {{multiple unsequenced modifications to 'a'}}
+  (a ? xs[0] : xs[1]) = ++a; // expected-warning {{unsequenced modification and access to 'a'}}
   a = (++a, ++a); // ok
   a = (a++, ++a); // ok
-  a = (a++, a++); // expected-warning {{multiple unsequenced modifications}}
+  a = (a++, a++); // expected-warning {{multiple unsequenced modifications to 'a'}}
   f(a, a); // ok
-  f(a = 0, a); // expected-warning {{unsequenced modification and access}}
-  f(a, a += 0); // expected-warning {{unsequenced modification and access}}
-  f(a = 0, a = 0); // expected-warning {{multiple unsequenced modifications}}
+  f(a = 0, a); // expected-warning {{unsequenced modification and access to 'a'}}
+  f(a, a += 0); // expected-warning {{unsequenced modification and access to 'a'}}
+  f(a = 0, a = 0); // expected-warning {{multiple unsequenced modifications to 'a'}}
   a = f(++a); // ok
   a = f(a++); // ok
-  a = f(++a, a++); // expected-warning {{multiple unsequenced modifications}}
+  a = f(++a, a++); // expected-warning {{multiple unsequenced modifications to 'a'}}
 
   // Compound assignment "A OP= B" is equivalent to "A = A OP B" except that A
   // is evaluated only once.
   (++a, a) = 1; // ok
   (++a, a) += 1; // ok
   a = ++a; // ok
-  a += ++a; // expected-warning {{unsequenced modification and access}}
+  a += ++a; // expected-warning {{unsequenced modification and access to 'a'}}
 
   A agg1 = { a++, a++ }; // ok
-  A agg2 = { a++ + a, a++ }; // expected-warning {{unsequenced modification and access}}
+  A agg2 = { a++ + a, a++ }; // expected-warning {{unsequenced modification and access to 'a'}}
 
-  S str1(a++, a++); // expected-warning {{multiple unsequenced modifications}}
+  S str1(a++, a++); // expected-warning {{multiple unsequenced modifications to 'a'}}
   S str2 = { a++, a++ }; // ok
-  S str3 = { a++ + a, a++ }; // expected-warning {{unsequenced modification and access}}
+  S str3 = { a++ + a, a++ }; // expected-warning {{unsequenced modification and access to 'a'}}
 
   struct Z { A a; S s; } z = { { ++a, ++a }, { ++a, ++a } }; // ok
   a = S { ++a, a++ }.n; // ok
   A { ++a, a++ }.x; // ok
-  a = A { ++a, a++ }.x; // expected-warning {{unsequenced modifications}}
-  A { ++a, a++ }.x + A { ++a, a++ }.y; // expected-warning {{unsequenced modifications}}
+  a = A { ++a, a++ }.x; // expected-warning {{unsequenced modifications to 'a'}}
+  A { ++a, a++ }.x + A { ++a, a++ }.y; // expected-warning {{unsequenced modifications to 'a'}}
 
   (xs[2] && (a = 0)) + a; // ok
   (0 && (a = 0)) + a; // ok
-  (1 && (a = 0)) + a; // expected-warning {{unsequenced modification and access}}
+  (1 && (a = 0)) + a; // expected-warning {{unsequenced modification and access to 'a'}}
 
   (xs[3] || (a = 0)) + a; // ok
-  (0 || (a = 0)) + a; // expected-warning {{unsequenced modification and access}}
+  (0 || (a = 0)) + a; // expected-warning {{unsequenced modification and access to 'a'}}
   (1 || (a = 0)) + a; // ok
 
   (xs[4] ? a : ++a) + a; // ok
-  (0 ? a : ++a) + a; // expected-warning {{unsequenced modification and access}}
+  (0 ? a : ++a) + a; // expected-warning {{unsequenced modification and access to 'a'}}
   (1 ? a : ++a) + a; // ok
-  (0 ? a : a++) + a; // expected-warning {{unsequenced modification and access}}
+  (0 ? a : a++) + a; // expected-warning {{unsequenced modification and access to 'a'}}
   (1 ? a : a++) + a; // ok
   (xs[5] ? ++a : ++a) + a; // FIXME: warn here
 
-  (++a, xs[6] ? ++a : 0) + a; // expected-warning {{unsequenced modification and access}}
+  (++a, xs[6] ? ++a : 0) + a; // expected-warning {{unsequenced modification and access to 'a'}}
 
   // Here, the read of the fourth 'a' might happen before or after 

r353009 - [opaque pointer types] Trivial changes towards CallInst requiring

2019-02-03 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Sun Feb  3 13:53:49 2019
New Revision: 353009

URL: http://llvm.org/viewvc/llvm-project?rev=353009=rev
Log:
[opaque pointer types] Trivial changes towards CallInst requiring
explicit function types.

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/CGCoroutine.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=353009=353008=353009=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sun Feb  3 13:53:49 2019
@@ -305,7 +305,7 @@ static Value *emitUnaryBuiltin(CodeGenFu
unsigned IntrinsicID) {
   llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
 
-  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
   return CGF.Builder.CreateCall(F, Src0);
 }
 
@@ -316,7 +316,7 @@ static Value *emitBinaryBuiltin(CodeGenF
   llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
   llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
 
-  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
   return CGF.Builder.CreateCall(F, { Src0, Src1 });
 }
 
@@ -328,7 +328,7 @@ static Value *emitTernaryBuiltin(CodeGen
   llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
   llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
 
-  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
   return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 });
 }
 
@@ -339,13 +339,13 @@ static Value *emitFPIntBuiltin(CodeGenFu
   llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
   llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
 
-  Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+  Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
   return CGF.Builder.CreateCall(F, {Src0, Src1});
 }
 
 /// EmitFAbs - Emit a call to @llvm.fabs().
 static Value *EmitFAbs(CodeGenFunction , Value *V) {
-  Value *F = CGF.CGM.getIntrinsic(Intrinsic::fabs, V->getType());
+  Function *F = CGF.CGM.getIntrinsic(Intrinsic::fabs, V->getType());
   llvm::CallInst *Call = CGF.Builder.CreateCall(F, V);
   Call->setDoesNotAccessMemory();
   return Call;
@@ -406,7 +406,7 @@ static llvm::Value *EmitOverflowIntrinsi
  "Arguments must be the same type. (Did you forget to make sure both "
  "arguments have the same integer width?)");
 
-  llvm::Value *Callee = CGF.CGM.getIntrinsic(IntrinsicID, X->getType());
+  Function *Callee = CGF.CGM.getIntrinsic(IntrinsicID, X->getType());
   llvm::Value *Tmp = CGF.Builder.CreateCall(Callee, {X, Y});
   Carry = CGF.Builder.CreateExtractValue(Tmp, 1);
   return CGF.Builder.CreateExtractValue(Tmp, 0);
@@ -417,7 +417,7 @@ static Value *emitRangedBuiltin(CodeGenF
 int low, int high) {
 llvm::MDBuilder MDHelper(CGF.getLLVMContext());
 llvm::MDNode *RNode = MDHelper.createRange(APInt(32, low), APInt(32, 
high));
-Value *F = CGF.CGM.getIntrinsic(IntrinsicID, {});
+Function *F = CGF.CGM.getIntrinsic(IntrinsicID, {});
 llvm::Instruction *Call = CGF.Builder.CreateCall(F);
 Call->setMetadata(llvm::LLVMContext::MD_range, RNode);
 return Call;
@@ -544,7 +544,8 @@ CodeGenFunction::emitBuiltinObjectSize(c
   assert(Ptr->getType()->isPointerTy() &&
  "Non-pointer passed to __builtin_object_size?");
 
-  Value *F = CGM.getIntrinsic(Intrinsic::objectsize, {ResType, 
Ptr->getType()});
+  Function *F =
+  CGM.getIntrinsic(Intrinsic::objectsize, {ResType, Ptr->getType()});
 
   // LLVM only supports 0 and 2, make sure that we pass along that as a 
boolean.
   Value *Min = Builder.getInt1((Type & 2) != 0);
@@ -876,7 +877,7 @@ Value *CodeGenFunction::EmitMSVCBuiltinE
 Address IndexAddress = EmitPointerWithAlignment(E->getArg(0));
 
 if (BuiltinID == MSVCIntrin::_BitScanForward) {
-  Value *F = CGM.getIntrinsic(Intrinsic::cttz, ArgType);
+  Function *F = CGM.getIntrinsic(Intrinsic::cttz, ArgType);
   Value *ZeroCount = Builder.CreateCall(F, {ArgValue, Builder.getTrue()});
   ZeroCount = Builder.CreateIntCast(ZeroCount, IndexType, false);
   Builder.CreateStore(ZeroCount, IndexAddress, false);
@@ -884,7 +885,7 @@ Value *CodeGenFunction::EmitMSVCBuiltinE
   unsigned ArgWidth = cast(ArgType)->getBitWidth();
   Value *ArgTypeLastIndex = llvm::ConstantInt::get(IndexType, 

[libunwind] r353010 - Provide a placement new definition for the SEH version of UnwindCursor

2019-02-03 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Sun Feb  3 14:16:53 2019
New Revision: 353010

URL: http://llvm.org/viewvc/llvm-project?rev=353010=rev
Log:
Provide a placement new definition for the SEH version of UnwindCursor

This fixes compilation after SVN r352966 in SEH mode.

Modified:
libunwind/trunk/src/UnwindCursor.hpp

Modified: libunwind/trunk/src/UnwindCursor.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindCursor.hpp?rev=353010=353009=353010=diff
==
--- libunwind/trunk/src/UnwindCursor.hpp (original)
+++ libunwind/trunk/src/UnwindCursor.hpp Sun Feb  3 14:16:53 2019
@@ -482,6 +482,10 @@ public:
   DISPATCHER_CONTEXT *getDispatcherContext() { return &_dispContext; }
   void setDispatcherContext(DISPATCHER_CONTEXT *disp) { _dispContext = *disp; }
 
+  // libunwind does not and should not depend on C++ library which means that 
we
+  // need our own defition of inline placement new.
+  static void *operator new(size_t, UnwindCursor *p) { return p; }
+
 private:
 
   pint_t getLastPC() const { return _dispContext.ControlPc; }


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


[PATCH] D57665: [clang-tidy] Handle unions with existing default-member-init

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

Just to make sure I understand the issue correctly (and so please correct me if 
I am wrong):

The union member `e` leads to an `IndirectFieldDecl` in the record for 
`UnionExisting`. Then `CXXCtorInitializer::getMember` returns null since the 
initialized member is not a `FieldDecl`, but an `IndirectFieldDecl`. Using 
`CXXCtorInitializer::getAnyMember` handles both `FieldDecl`s and 
`IndirectFieldDecl`s, which solves the issue.

Looks OK but probably better to wait for someone else to give the OK ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57665



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


[PATCH] D57661: [Sema] SequenceChecker: Add tests for references and members.

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

I realized I need to add tests for (at least) anonymous unions/structs and 
local classes, but I am sure I missing lots of interesting cases. Feel free to 
suggest anything you might think of.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57661



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


[PATCH] D57665: [clang-tidy] Handle unions with existing default-member-init

2019-02-03 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth accepted this revision.
JonasToth added a comment.
This revision is now accepted and ready to land.

LGTM, please close the bug report and notify for the fix with the request to 
check in the real-project if it actually fixes the issue. Thanks :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57665



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


[PATCH] D56370: [clangd] Add support for type hierarchy (super types only for now)

2019-02-03 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 184984.
nridge edited the summary of this revision.
nridge added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This completes the implementation of the revised spec (for supertypes only)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56370

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/FindSymbols.cpp
  clang-tools-extra/clangd/FindSymbols.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/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/tool/CMakeLists.txt
  clang-tools-extra/unittests/clangd/Matchers.h
  clang-tools-extra/unittests/clangd/XRefsTests.cpp

Index: clang-tools-extra/unittests/clangd/XRefsTests.cpp
===
--- clang-tools-extra/unittests/clangd/XRefsTests.cpp
+++ clang-tools-extra/unittests/clangd/XRefsTests.cpp
@@ -25,9 +25,11 @@
 namespace {
 
 using testing::ElementsAre;
+using testing::Eq;
 using testing::Field;
 using testing::IsEmpty;
 using testing::Matcher;
+using testing::Pointee;
 using testing::UnorderedElementsAreArray;
 
 class IgnoreDiagnostics : public DiagnosticsConsumer {
@@ -39,6 +41,15 @@
   return Location{URIForFile::canonicalize(File, testRoot()), Range} == arg;
 }
 
+// GMock helpers for matching TypeHierarchyItem.
+MATCHER_P(WithName, N, "") { return arg.name == N; }
+MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
+MATCHER_P(SelectionRangeIs, R, "") { return arg.selectionRange == R; }
+template 
+testing::Matcher Parents(ParentMatchers... ParentsM) {
+  return Field(::parents, HasValue(ElementsAre(ParentsM...)));
+}
+
 // Extracts ranges from an annotated example, and constructs a matcher for a
 // highlight set. Ranges should be named $read/$write as appropriate.
 Matcher &>
@@ -1339,6 +1350,160 @@
   }
 }
 
+TEST(SuperTypes, SimpleInheritanceOnTypeOrVariable) {
+  Annotations Source(R"cpp(
+struct $ParentDef[[Parent]]
+{
+  int a;
+};
+
+struct $Child1Def[[Child1]] : Parent
+{
+  int b;
+};
+
+struct Ch$p1^ild2 : Child1
+{
+  int c;
+};
+
+struct Child3 : Child2
+{
+  int d;
+};
+
+int main()
+{
+  Ch$p2^ild2 ch$p3^ild2;
+
+  parent.a = 1;
+  ch$p4^ild2.c = 1;
+}
+)cpp");
+
+  TestTU TU = TestTU::withCode(Source.code());
+  auto AST = TU.build();
+
+  for (auto Pt : {"p1", "p2", "p3", "p4"}) {
+llvm::Optional Result = getTypeHierarchy(
+AST, Source.point(Pt), 10, TypeHierarchyDirection::Parents);
+ASSERT_TRUE(bool(Result));
+EXPECT_THAT(
+*Result,
+AllOf(
+WithName("Child2"), WithKind(SymbolKind::Struct),
+Parents(AllOf(
+WithName("Child1"), WithKind(SymbolKind::Struct),
+SelectionRangeIs(Source.range("Child1Def")),
+Parents(AllOf(WithName("Parent"), WithKind(SymbolKind::Struct),
+  SelectionRangeIs(Source.range("ParentDef")),
+  Parents()));
+  }
+}
+
+TEST(SuperTypes, MultipleInheritanceOnTypeOrVariable) {
+  Annotations Source(R"cpp(
+struct $Parent1Def[[Parent1]]
+{
+  int a;
+};
+
+struct $Parent2Def[[Parent2]]
+{
+  int b;
+};
+
+struct $Parent3Def[[Parent3]] : Parent2
+{
+  int c;
+};
+
+struct Ch$c1^ild : Parent1, Parent3
+{
+  int d;
+};
+
+int main()
+{
+  Ch$c2^ild  ch$c3^ild;
+
+  ch$c4^ild.a = 1;
+}
+)cpp");
+
+  TestTU TU = TestTU::withCode(Source.code());
+  auto AST = TU.build();
+
+  for (auto Pt : {"c1", "c2", "c3", "c4"}) {
+llvm::Optional Result = getTypeHierarchy(
+AST, Source.point(Pt), 10, TypeHierarchyDirection::Parents);
+ASSERT_TRUE(bool(Result));
+EXPECT_THAT(
+*Result,
+AllOf(
+WithName("Child"), WithKind(SymbolKind::Struct),
+Parents(AllOf(WithName("Parent1"), WithKind(SymbolKind::Struct),
+  SelectionRangeIs(Source.range("Parent1Def")),
+  Parents()),
+AllOf(WithName("Parent3"), WithKind(SymbolKind::Struct),
+  SelectionRangeIs(Source.range("Parent3Def")),
+  Parents(AllOf(
+  WithName("Parent2"), WithKind(SymbolKind::Struct),
+  SelectionRangeIs(Source.range("Parent2Def")),
+  Parents()));
+  }
+}
+
+TEST(SuperTypes, OnMethod) {
+  Annotations Source(R"cpp(
+struct $ParentDef[[Parent]]
+{
+  void method ();
+  void method () const;
+  void method (int x);
+  void method (char x);
+};
+
+struct $Child1Def[[Child1]] : Parent
+{
+  void method 

[PATCH] D56370: [clangd] Add support for type hierarchy (super types only for now)

2019-02-03 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 184985.
nridge added a comment.

remove unrelated file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56370

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/FindSymbols.cpp
  clang-tools-extra/clangd/FindSymbols.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/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/unittests/clangd/Matchers.h
  clang-tools-extra/unittests/clangd/XRefsTests.cpp

Index: clang-tools-extra/unittests/clangd/XRefsTests.cpp
===
--- clang-tools-extra/unittests/clangd/XRefsTests.cpp
+++ clang-tools-extra/unittests/clangd/XRefsTests.cpp
@@ -25,9 +25,11 @@
 namespace {
 
 using testing::ElementsAre;
+using testing::Eq;
 using testing::Field;
 using testing::IsEmpty;
 using testing::Matcher;
+using testing::Pointee;
 using testing::UnorderedElementsAreArray;
 
 class IgnoreDiagnostics : public DiagnosticsConsumer {
@@ -39,6 +41,15 @@
   return Location{URIForFile::canonicalize(File, testRoot()), Range} == arg;
 }
 
+// GMock helpers for matching TypeHierarchyItem.
+MATCHER_P(WithName, N, "") { return arg.name == N; }
+MATCHER_P(WithKind, Kind, "") { return arg.kind == Kind; }
+MATCHER_P(SelectionRangeIs, R, "") { return arg.selectionRange == R; }
+template 
+testing::Matcher Parents(ParentMatchers... ParentsM) {
+  return Field(::parents, HasValue(ElementsAre(ParentsM...)));
+}
+
 // Extracts ranges from an annotated example, and constructs a matcher for a
 // highlight set. Ranges should be named $read/$write as appropriate.
 Matcher &>
@@ -1339,6 +1350,160 @@
   }
 }
 
+TEST(SuperTypes, SimpleInheritanceOnTypeOrVariable) {
+  Annotations Source(R"cpp(
+struct $ParentDef[[Parent]]
+{
+  int a;
+};
+
+struct $Child1Def[[Child1]] : Parent
+{
+  int b;
+};
+
+struct Ch$p1^ild2 : Child1
+{
+  int c;
+};
+
+struct Child3 : Child2
+{
+  int d;
+};
+
+int main()
+{
+  Ch$p2^ild2 ch$p3^ild2;
+
+  parent.a = 1;
+  ch$p4^ild2.c = 1;
+}
+)cpp");
+
+  TestTU TU = TestTU::withCode(Source.code());
+  auto AST = TU.build();
+
+  for (auto Pt : {"p1", "p2", "p3", "p4"}) {
+llvm::Optional Result = getTypeHierarchy(
+AST, Source.point(Pt), 10, TypeHierarchyDirection::Parents);
+ASSERT_TRUE(bool(Result));
+EXPECT_THAT(
+*Result,
+AllOf(
+WithName("Child2"), WithKind(SymbolKind::Struct),
+Parents(AllOf(
+WithName("Child1"), WithKind(SymbolKind::Struct),
+SelectionRangeIs(Source.range("Child1Def")),
+Parents(AllOf(WithName("Parent"), WithKind(SymbolKind::Struct),
+  SelectionRangeIs(Source.range("ParentDef")),
+  Parents()));
+  }
+}
+
+TEST(SuperTypes, MultipleInheritanceOnTypeOrVariable) {
+  Annotations Source(R"cpp(
+struct $Parent1Def[[Parent1]]
+{
+  int a;
+};
+
+struct $Parent2Def[[Parent2]]
+{
+  int b;
+};
+
+struct $Parent3Def[[Parent3]] : Parent2
+{
+  int c;
+};
+
+struct Ch$c1^ild : Parent1, Parent3
+{
+  int d;
+};
+
+int main()
+{
+  Ch$c2^ild  ch$c3^ild;
+
+  ch$c4^ild.a = 1;
+}
+)cpp");
+
+  TestTU TU = TestTU::withCode(Source.code());
+  auto AST = TU.build();
+
+  for (auto Pt : {"c1", "c2", "c3", "c4"}) {
+llvm::Optional Result = getTypeHierarchy(
+AST, Source.point(Pt), 10, TypeHierarchyDirection::Parents);
+ASSERT_TRUE(bool(Result));
+EXPECT_THAT(
+*Result,
+AllOf(
+WithName("Child"), WithKind(SymbolKind::Struct),
+Parents(AllOf(WithName("Parent1"), WithKind(SymbolKind::Struct),
+  SelectionRangeIs(Source.range("Parent1Def")),
+  Parents()),
+AllOf(WithName("Parent3"), WithKind(SymbolKind::Struct),
+  SelectionRangeIs(Source.range("Parent3Def")),
+  Parents(AllOf(
+  WithName("Parent2"), WithKind(SymbolKind::Struct),
+  SelectionRangeIs(Source.range("Parent2Def")),
+  Parents()));
+  }
+}
+
+TEST(SuperTypes, OnMethod) {
+  Annotations Source(R"cpp(
+struct $ParentDef[[Parent]]
+{
+  void method ();
+  void method () const;
+  void method (int x);
+  void method (char x);
+};
+
+struct $Child1Def[[Child1]] : Parent
+{
+  void method ();
+  void method (char x);
+};
+
+struct Child2 : Child1
+{
+  void met$p1^hod ();
+  void met$p2^hod (int x);
+};
+
+struct Child3 : Child2
+{
+  void method (int x);
+};
+)cpp");
+
+  TestTU TU = 

[PATCH] D56370: [clangd] Add support for type hierarchy (super types only for now)

2019-02-03 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked 3 inline comments as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:820
 
+// TODO: Reduce duplication between this function and declToSym().
+static llvm::Optional

I am open to feedback on whether we want to reduce the duplication between 
these functions, and if so, suggestions for how.



Comment at: clang-tools-extra/clangd/XRefs.cpp:901
+
+  // TODO: Populate subtypes.
+}

I am deliberately leaving this part for a follow-up patch, as it will require 
index changes.



Comment at: clang-tools-extra/unittests/clangd/Matchers.h:130
 
+// Implements the HasValue(m) matcher for matching an Optional whose
+// value matches matcher m.

Should I split this out into a separate patch? It's used by the tests being 
added for this functionality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D56370



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


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2019-02-03 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 updated this revision to Diff 184936.
shiva0217 retitled this revision from "[RISCV] Passing -G value to RISCV 
backend" to "[RISCV] Passing small data limitation value to RISCV backend".
shiva0217 edited the summary of this revision.
shiva0217 added a comment.

1. Setting small data limitation to zero for PIC and RV64 with large code model.
2. Support passing small data limitation with LTO enabled.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57497

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/RISCVToolchain.cpp
  lib/Driver/ToolChains/RISCVToolchain.h
  test/Driver/riscv-features.c

Index: test/Driver/riscv-features.c
===
--- test/Driver/riscv-features.c
+++ test/Driver/riscv-features.c
@@ -11,3 +11,37 @@
 // NO-RELAX: "-target-feature" "-relax"
 // DEFAULT-NOT: "-target-feature" "+relax"
 // DEFAULT-NOT: "-target-feature" "-relax"
+
+/// Small data section limitaion setting.
+// RUN: %clang -target riscv32 -### -S %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32 %s
+// CHECK-RV32-NOT: "-mllvm" "-riscv-ssection-threshold"
+// RUN: %clang -target riscv64 -### -S %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64 %s
+// CHECK-RV64-NOT: "-mllvm" "-riscv-ssection-threshold"
+// RUN: %clang -target riscv32 -flto -### %s \
+// RUN: -G 16 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32-G16-LTO %s
+// CHECK-RV32-G16-LTO: "-plugin-opt=-riscv-ssection-threshold=16"
+// RUN: %clang -target riscv32 -### %s \
+// RUN: -G 0 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32-G0 %s
+// CHECK-RV32-G0: "-mllvm" "-riscv-ssection-threshold=0"
+// RUN: %clang -target riscv64 -mcmodel=large -### -S %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64-LARGE %s
+// CHECK-RV64-LARGE: "-mllvm" "-riscv-ssection-threshold=0"
+// RUN: %clang -target riscv32 -fpic -### -S %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32-PIC %s
+// CHECK-RV32-PIC: "-mllvm" "-riscv-ssection-threshold=0"
+// RUN: %clang -target riscv64 -fpic -### -S %s \
+// RUN: -G 16 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64-PIC-G16 %s
+// CHECK-RV64-PIC-G16: "-mllvm" "-riscv-ssection-threshold=16"
+// RUN: %clang -target riscv32 -### -S %s \
+// RUN: -G 16 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32-G16 %s
+// CHECK-RV32-G16: "-mllvm" "-riscv-ssection-threshold=16"
+// RUN: %clang -target riscv64 -mcmodel=large -### -S %s \
+// RUN: -G 16 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64-LARGE-G16 %s
+// CHECK-RV64-LARGE-G16: "-mllvm" "-riscv-ssection-threshold=16"
Index: lib/Driver/ToolChains/RISCVToolchain.h
===
--- lib/Driver/ToolChains/RISCVToolchain.h
+++ lib/Driver/ToolChains/RISCVToolchain.h
@@ -32,7 +32,11 @@
   addLibStdCxxIncludePaths(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
 
+  static StringRef getSmallDataThreshold(const llvm::opt::ArgList ,
+ const llvm::Triple );
+
 protected:
+  bool HasNativeLLVMSupport() const override { return true; }
   Tool *buildLinker() const override;
 
 private:
Index: lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- lib/Driver/ToolChains/RISCVToolchain.cpp
+++ lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -86,6 +86,24 @@
   return SysRootDir;
 }
 
+StringRef RISCVToolChain::getSmallDataThreshold(const ArgList ,
+const llvm::Triple ) {
+  StringRef Gn = "";
+  if (Arg *A = Args.getLastArg(options::OPT_G)) {
+Gn = A->getValue();
+  // Not support linker relaxation for PIC.
+  } else if (Args.getLastArg(options::OPT_shared, options::OPT_fpic,
+ options::OPT_fPIC)) {
+Gn = "0";
+  // Not support linker relaxation for RV64 with large code model.
+  } else if (Args.getLastArgValue(options::OPT_mcmodel_EQ).equals_lower("large") &&
+ (Triple.getArch() == llvm::Triple::riscv64)) {
+Gn = "0";
+  }
+
+  return Gn;
+}
+
 void RISCV::Linker::ConstructJob(Compilation , const JobAction ,
  const InputInfo ,
  const InputInfoList ,
@@ -114,6 +132,22 @@
   {options::OPT_T_Group, options::OPT_e, options::OPT_s,
options::OPT_t, options::OPT_Z_Flag, options::OPT_r});
 
+  if (D.isUsingLTO()) {
+assert(!Inputs.empty() && "Must have at least one input.");
+AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+  D.getLTOMode() == LTOK_Thin);
+
+// Passing small data section limitaion.
+StringRef G = toolchains::RISCVToolChain::getSmallDataThreshold(Args, ToolChain.getTriple());
+if (!G.empty()) {
+  if 

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

2019-02-03 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added a comment.

In D45978#1379901 , @rnk wrote:

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


Since it needs to fail for this:

__declspec(dllexport) const int j;

and pass for this:

__declspec(dllexport) int const x = 3;

I am proposing to add this code in Sema::AddInitializerToDecl(Decl *RealDecl, 
Expr *Init, bool DirectInit).


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

https://reviews.llvm.org/D45978



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


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2019-02-03 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 added a comment.

In D57497#1382206 , @apazos wrote:

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


Hi Ana, thanks for the tips!
I follow Hexagon and implement the passing code in 
`RISCV::Linker::ConstructJob`.
Could you help me to check whether it could work properly?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57497



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


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

2019-02-03 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: lib/AST/DeclCXX.cpp:2070
+  if (isDestroyingOperatorDelete()) {
+if (!getASTContext().getLangOpts().DestroyingDelete)
+  return false;

Just use the AST context you have above ?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57645



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


[PATCH] D45741: Python bindings: Fix handling of file bodies with multi-byte characters

2019-02-03 Thread Maximilian Heinzler via Phabricator via cfe-commits
mheinzler abandoned this revision.
mheinzler added a comment.
Herald added a subscriber: arphaman.
Herald added a reviewer: serge-sans-paille.
Herald added a project: clang.

I'm closing this because it has been fixed in master by:
https://reviews.llvm.org/D56429


Repository:
  rC Clang

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

https://reviews.llvm.org/D45741



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


[clang-tools-extra] r352991 - Remove trailing semicolon. NFCI.

2019-02-03 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sun Feb  3 06:11:32 2019
New Revision: 352991

URL: http://llvm.org/viewvc/llvm-project?rev=352991=rev
Log:
Remove trailing semicolon. NFCI.

Modified:
clang-tools-extra/trunk/clangd/refactor/tweaks/SwapIfBranches.cpp

Modified: clang-tools-extra/trunk/clangd/refactor/tweaks/SwapIfBranches.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/refactor/tweaks/SwapIfBranches.cpp?rev=352991=352990=352991=diff
==
--- clang-tools-extra/trunk/clangd/refactor/tweaks/SwapIfBranches.cpp (original)
+++ clang-tools-extra/trunk/clangd/refactor/tweaks/SwapIfBranches.cpp Sun Feb  
3 06:11:32 2019
@@ -44,7 +44,7 @@ private:
   const IfStmt *If = nullptr;
 };
 
-REGISTER_TWEAK(SwapIfBranches);
+REGISTER_TWEAK(SwapIfBranches)
 
 bool SwapIfBranches::prepare(const Selection ) {
   for (const SelectionTree::Node *N = Inputs.ASTSelection.commonAncestor();


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


r352995 - [objc-gnustep] Fix encoding of ivar size for _Bool.

2019-02-03 Thread David Chisnall via cfe-commits
Author: theraven
Date: Sun Feb  3 07:05:52 2019
New Revision: 352995

URL: http://llvm.org/viewvc/llvm-project?rev=352995=rev
Log:
[objc-gnustep] Fix encoding of ivar size for _Bool.

Modified:
cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
cfe/trunk/test/CodeGenObjC/gnustep2-ivar-offset.m

Modified: cfe/trunk/lib/CodeGen/CGObjCGNU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCGNU.cpp?rev=352995=352994=352995=diff
==
--- cfe/trunk/lib/CodeGen/CGObjCGNU.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCGNU.cpp Sun Feb  3 07:05:52 2019
@@ -1728,7 +1728,6 @@ class CGObjCGNUstep2 : public CGObjCGNUs
   CGM.getContext().getCharWidth());
   // struct objc_ivar ivars[]
   auto ivarArrayBuilder = ivarListBuilder.beginArray();
-  CodeGenTypes  = CGM.getTypes();
   for (const ObjCIvarDecl *IVD = classDecl->all_declared_ivar_begin(); IVD;
IVD = IVD->getNextIvar()) {
 auto ivarTy = IVD->getType();
@@ -1762,8 +1761,7 @@ class CGObjCGNUstep2 : public CGObjCGNUs
 ivarBuilder.add(OffsetVar);
 // Ivar size
 ivarBuilder.addInt(Int32Ty,
-td.getTypeSizeInBits(Types.ConvertType(ivarTy)) /
-  CGM.getContext().getCharWidth());
+CGM.getContext().getTypeSizeInChars(ivarTy).getQuantity());
 // Alignment will be stored as a base-2 log of the alignment.
 int align = 
llvm::Log2_32(Context.getTypeAlignInChars(ivarTy).getQuantity());
 // Objects that require more than 2^64-byte alignment should be 
impossible!

Modified: cfe/trunk/test/CodeGenObjC/gnustep2-ivar-offset.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/gnustep2-ivar-offset.m?rev=352995=352994=352995=diff
==
--- cfe/trunk/test/CodeGenObjC/gnustep2-ivar-offset.m (original)
+++ cfe/trunk/test/CodeGenObjC/gnustep2-ivar-offset.m Sun Feb  3 07:05:52 2019
@@ -19,10 +19,12 @@
 @package
 // CHECK: @__objc_ivar_offset_ANObject._intIvar.i = hidden global i32 16
   int _intIvar;
+  _Bool   boolIvar;
 }
 @end
 @implementation ANObject @end
 
 // Check that the ivar metadata contains 3 entries of the correct form and 
correctly sets the size.
-// CHECK: @.objc_ivar_list = private global { i32, i64, [3 x { i8*, i8*, i32*, 
i32, i32 }] } { i32 3, i64 32,
-// Check that we're emitting the extended type encoding for the string ivar.
+// CHECK: @.objc_ivar_list = private global { i32, i64, [4 x { i8*, i8*, i32*, 
i32, i32 }] } { i32 4, i64 32,
+// Check that we emit 1 as the size of _Bool, not 0.
+// CHECK-SAME:  @__objc_ivar_offset_ANObject.boolIvar.B, i32 1, i32 4


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


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

2019-02-03 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

The NetBSD buildbot breaks in these tests now:

http://lab.llvm.org:8011/builders/lldb-amd64-ninja-netbsd8/builds/18721

Both tests break in a similar way:

  Command Output (stderr):
  --
  + : 'RUN: at line 1'
  + not /home/motus/netbsd8/netbsd8/build/bin/clang -cc1 -internal-isystem 
/home/motus/netbsd8/netbsd8/build/lib/clang/9.0.0/include -nostdsysteminc 
-emit-llvm -o 
/home/motus/netbsd8/netbsd8/build/tools/clang/test/Frontend/Output/output-failures.c.tmp/doesnotexist/somename
 /home/motus/netbsd8/netbsd8/llvm/tools/clang/test/Frontend/output-failures.c
  + : 'RUN: at line 2'
  + /home/motus/netbsd8/netbsd8/build/bin/FileCheck -check-prefix=OUTPUTFAIL 
-input-file=/home/motus/netbsd8/netbsd8/build/tools/clang/test/Frontend/Output/output-failures.c.tmp
 /home/motus/netbsd8/netbsd8/llvm/tools/clang/test/Frontend/output-failures.c
  
/home/motus/netbsd8/netbsd8/llvm/tools/clang/test/Frontend/output-failures.c:4:16:
 error: OUTPUTFAIL: expected string not found in input
  // OUTPUTFAIL: error: unable to open output file 
'{{.*}}doesnotexist{{.}}somename': '{{[nN]}}o such file or directory'
 ^
  
/home/motus/netbsd8/netbsd8/build/tools/clang/test/Frontend/Output/output-failures.c.tmp:1:1:
 note: scanning from here
  error: unable to open output file 
'/home/motus/netbsd8/netbsd8/build/tools/clang/test/Frontend/Output/output-failures.c.tmp/doesnotexist/somename':
 'Not a directory'
  ^
  
/home/motus/netbsd8/netbsd8/build/tools/clang/test/Frontend/Output/output-failures.c.tmp:1:86:
 note: possible intended match here
  error: unable to open output file 
'/home/motus/netbsd8/netbsd8/build/tools/clang/test/Frontend/Output/output-failures.c.tmp/doesnotexist/somename':
 'Not a directory'

   ^
  
  --

Please fix.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57592



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


[PATCH] D57649: [ASTDump] Add a flag indicating whether a CXXThisExpr is implicit

2019-02-03 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno created this revision.
riccibruno added a reviewer: steveire.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.

There is current no way to distinguish implicit from explicit `CXXThisExpr` in 
the AST dump output.


Repository:
  rC Clang

https://reviews.llvm.org/D57649

Files:
  lib/AST/TextNodeDumper.cpp
  test/AST/ast-dump-expr.cpp
  test/AST/dump.cpp
  test/AST/float16.cpp


Index: test/AST/float16.cpp
===
--- test/AST/float16.cpp
+++ test/AST/float16.cpp
@@ -132,7 +132,7 @@
 //CHECK-NEXT: | | `-BinaryOperator {{.*}} '_Float16' '+'
 //CHECK-NEXT: | |   |-ImplicitCastExpr {{.*}} '_Float16' 
 //CHECK-NEXT: | |   | `-MemberExpr {{.*}} '_Float16' lvalue ->f1c 0x{{.*}}
-//CHECK-NEXT: | |   |   `-CXXThisExpr {{.*}} 'C1 *' this
+//CHECK-NEXT: | |   |   `-CXXThisExpr {{.*}} 'C1 *' implicit this
 //CHECK-NEXT: | |   `-ImplicitCastExpr {{.*}} '_Float16' 
 //CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 
0x{{.*}} 'arg' '_Float16'
 //CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func2c '_Float16 (_Float16)' static
Index: test/AST/dump.cpp
===
--- test/AST/dump.cpp
+++ test/AST/dump.cpp
@@ -56,7 +56,7 @@
 // CHECK-NEXT: |   | `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} 'a' 'int &'
 // CHECK-NEXT: |   |-OMPSharedClause {{.+}} 
 // CHECK-NEXT: |   | `-MemberExpr {{.+}}  'int' lvalue ->b
-// CHECK-NEXT: |   |   `-CXXThisExpr {{.+}}  'S *' this
+// CHECK-NEXT: |   |   `-CXXThisExpr {{.+}}  'S *' implicit this
 // CHECK-NEXT: |   |-OMPScheduleClause {{.+}} 
 // CHECK-NEXT: |   | `-ImplicitCastExpr {{.+}}  'int' 

 // CHECK-NEXT: |   |   `-DeclRefExpr {{.+}}  'int' lvalue 
OMPCapturedExpr {{.+}} '.capture_expr.' 'int'
Index: test/AST/ast-dump-expr.cpp
===
--- test/AST/ast-dump-expr.cpp
+++ test/AST/ast-dump-expr.cpp
@@ -255,7 +255,7 @@
   // CHECK-NEXT: FieldDecl 0x{{[^ ]*}}  col:8 implicit 'V *'
   // CHECK-NEXT: CXXMethodDecl
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' this
+  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' implicit this
 
   [*this]{};
   // CHECK: LambdaExpr 0x{{[^ ]*}} 
@@ -272,7 +272,7 @@
   // CHECK-NEXT: CompoundStmt
   // CHECK-NEXT: ParenListExpr 0x{{[^ ]*}}  'NULL TYPE'
   // CHECK-NEXT: UnaryOperator 0x{{[^ ]*}}  '' 
prefix '*' cannot overflow
-  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' this
+  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' implicit this
 }
   };
 
Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -854,6 +854,8 @@
 }
 
 void TextNodeDumper::VisitCXXThisExpr(const CXXThisExpr *Node) {
+  if (Node->isImplicit())
+OS << " implicit";
   OS << " this";
 }
 


Index: test/AST/float16.cpp
===
--- test/AST/float16.cpp
+++ test/AST/float16.cpp
@@ -132,7 +132,7 @@
 //CHECK-NEXT: | | `-BinaryOperator {{.*}} '_Float16' '+'
 //CHECK-NEXT: | |   |-ImplicitCastExpr {{.*}} '_Float16' 
 //CHECK-NEXT: | |   | `-MemberExpr {{.*}} '_Float16' lvalue ->f1c 0x{{.*}}
-//CHECK-NEXT: | |   |   `-CXXThisExpr {{.*}} 'C1 *' this
+//CHECK-NEXT: | |   |   `-CXXThisExpr {{.*}} 'C1 *' implicit this
 //CHECK-NEXT: | |   `-ImplicitCastExpr {{.*}} '_Float16' 
 //CHECK-NEXT: | | `-DeclRefExpr {{.*}} '_Float16' lvalue ParmVar 0x{{.*}} 'arg' '_Float16'
 //CHECK-NEXT: | |-CXXMethodDecl {{.*}} used func2c '_Float16 (_Float16)' static
Index: test/AST/dump.cpp
===
--- test/AST/dump.cpp
+++ test/AST/dump.cpp
@@ -56,7 +56,7 @@
 // CHECK-NEXT: |   | `-DeclRefExpr {{.+}}  'int' lvalue OMPCapturedExpr {{.+}} 'a' 'int &'
 // CHECK-NEXT: |   |-OMPSharedClause {{.+}} 
 // CHECK-NEXT: |   | `-MemberExpr {{.+}}  'int' lvalue ->b
-// CHECK-NEXT: |   |   `-CXXThisExpr {{.+}}  'S *' this
+// CHECK-NEXT: |   |   `-CXXThisExpr {{.+}}  'S *' implicit this
 // CHECK-NEXT: |   |-OMPScheduleClause {{.+}} 
 // CHECK-NEXT: |   | `-ImplicitCastExpr {{.+}}  'int' 
 // CHECK-NEXT: |   |   `-DeclRefExpr {{.+}}  'int' lvalue OMPCapturedExpr {{.+}} '.capture_expr.' 'int'
Index: test/AST/ast-dump-expr.cpp
===
--- test/AST/ast-dump-expr.cpp
+++ test/AST/ast-dump-expr.cpp
@@ -255,7 +255,7 @@
   // CHECK-NEXT: FieldDecl 0x{{[^ ]*}}  col:8 implicit 'V *'
   // CHECK-NEXT: CXXMethodDecl
   // CHECK-NEXT: CompoundStmt
-  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' this
+  // CHECK-NEXT: CXXThisExpr 0x{{[^ ]*}}  'V *' implicit this
 
   [*this]{};
  

[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

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

Hi Shiva, I will check, but I think you need to also modify gnutools:Linker 
because riscv::Linker is called for baremetal. I think you need in both places.
The way I check is by invoking -flto -v from clang and look at the arguments 
passed to the compiler and linker


Repository:
  rC Clang

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

https://reviews.llvm.org/D57497



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


[PATCH] D57626: Disallow trivial_abi on a class if all copy and move constructors are deleted

2019-02-03 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

Can you give more intuition on why classes with no copy/move operations should 
be forced non-trivial-abi?  Let's take this specific example:

  struct [[clang::trivial_abi]] lock_guard {
  mutex *m;
  explicit lock_guard(mutex *m) : m(m) { m->lock(); }
  ~lock_guard() { m->unlock(); }
  lock_guard(const lock_guard&) = delete;
  lock_guard(lock_guard&&) = delete;
  };
  
  void foo(lock_guard g) { ... }
  void bar() { mutex m; foo(lock_guard()); }

With C++17 "guaranteed copy elision," there's no reason this code would 
//need// copy/move operations. But equally I can't see any reason that `g` 
should not be passed in a register when possible — it's just a pointer, after 
all.
I admit that this `lock_guard` example is contrived and generally ill-advised 
,
 but its ill-advisedness seems like a higher-level concern that shouldn't be 
"enforced" by fiddling with the rules of [[trivial_abi]], so I hope that's not 
what's going on here.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57626



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


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

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

> The NetBSD buildbot breaks in these tests now:

Pretty much every bot is red because of this patch 
(http://lab.llvm.org:8011/one_line_per_build) so yes, please fix.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57592



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


[PATCH] D57266: [AST] Update the comments of the various Expr::Ignore* + Related cleanups

2019-02-03 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 184945.
riccibruno marked 4 inline comments as done.
riccibruno added a comment.

Addressed Aaron's comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57266

Files:
  include/clang/AST/Expr.h
  include/clang/AST/Stmt.h
  lib/ARCMigrate/TransRetainReleaseDealloc.cpp
  lib/ARCMigrate/TransformActions.cpp
  lib/ARCMigrate/Transforms.cpp
  lib/AST/Expr.cpp
  lib/AST/Stmt.cpp
  lib/Analysis/ReachableCode.cpp
  lib/Tooling/ASTDiff/ASTDiff.cpp

Index: lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- lib/Tooling/ASTDiff/ASTDiff.cpp
+++ lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -237,8 +237,8 @@
 return true;
   }
   bool TraverseStmt(Stmt *S) {
-if (S)
-  S = S->IgnoreImplicit();
+if (auto *E = dyn_cast_or_null(S))
+  S = E->IgnoreImplicit();
 if (isNodeExcluded(Tree.AST.getSourceManager(), S))
   return true;
 auto SavedState = PreTraverse(S);
Index: lib/Analysis/ReachableCode.cpp
===
--- lib/Analysis/ReachableCode.cpp
+++ lib/Analysis/ReachableCode.cpp
@@ -192,9 +192,10 @@
   if (!S)
 return false;
 
-  S = S->IgnoreImplicit();
+  if (const auto *Ex = dyn_cast(S))
+S = Ex->IgnoreImplicit();
 
-  if (const Expr *Ex = dyn_cast(S))
+  if (const auto *Ex = dyn_cast(S))
 S = Ex->IgnoreCasts();
 
   // Special case looking for the sigil '()' around an integer literal.
Index: lib/AST/Stmt.cpp
===
--- lib/AST/Stmt.cpp
+++ lib/AST/Stmt.cpp
@@ -117,30 +117,6 @@
   StatisticsEnabled = true;
 }
 
-Stmt *Stmt::IgnoreImplicit() {
-  Stmt *s = this;
-
-  Stmt *lasts = nullptr;
-
-  while (s != lasts) {
-lasts = s;
-
-if (auto *fe = dyn_cast(s))
-  s = fe->getSubExpr();
-
-if (auto *mte = dyn_cast(s))
-  s = mte->GetTemporaryExpr();
-
-if (auto *bte = dyn_cast(s))
-  s = bte->getSubExpr();
-
-if (auto *ice = dyn_cast(s))
-  s = ice->getSubExpr();
-  }
-
-  return s;
-}
-
 /// Skip no-op (attributed, compound) container stmts and skip captured
 /// stmt at the top, if \a IgnoreCaptured is true.
 Stmt *Stmt::IgnoreContainers(bool IgnoreCaptured) {
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2556,32 +2556,66 @@
   return QualType();
 }
 
-Expr* Expr::IgnoreParens() {
-  Expr* E = this;
+Expr *Expr::IgnoreImpCasts() {
+  Expr *E = this;
   while (true) {
-if (ParenExpr* P = dyn_cast(E)) {
-  E = P->getSubExpr();
+if (auto *ICE = dyn_cast(E))
+  E = ICE->getSubExpr();
+else if (auto *FE = dyn_cast(E))
+  E = FE->getSubExpr();
+else
+  break;
+  }
+  return E;
+}
+
+Expr *Expr::IgnoreImplicit() {
+  Expr *E = this;
+  Expr *LastE = nullptr;
+  while (E != LastE) {
+LastE = E;
+
+if (auto *ICE = dyn_cast(E))
+  E = ICE->getSubExpr();
+
+if (auto *FE = dyn_cast(E))
+  E = FE->getSubExpr();
+
+if (auto *MTE = dyn_cast(E))
+  E = MTE->GetTemporaryExpr();
+
+if (auto *BTE = dyn_cast(E))
+  E = BTE->getSubExpr();
+  }
+  return E;
+}
+
+Expr *Expr::IgnoreParens() {
+  Expr *E = this;
+  while (true) {
+if (auto *PE = dyn_cast(E)) {
+  E = PE->getSubExpr();
   continue;
 }
-if (UnaryOperator* P = dyn_cast(E)) {
-  if (P->getOpcode() == UO_Extension) {
-E = P->getSubExpr();
+if (auto *UO = dyn_cast(E)) {
+  if (UO->getOpcode() == UO_Extension) {
+E = UO->getSubExpr();
 continue;
   }
 }
-if (GenericSelectionExpr* P = dyn_cast(E)) {
-  if (!P->isResultDependent()) {
-E = P->getResultExpr();
+if (auto *GSE = dyn_cast(E)) {
+  if (!GSE->isResultDependent()) {
+E = GSE->getResultExpr();
 continue;
   }
 }
-if (ChooseExpr* P = dyn_cast(E)) {
-  if (!P->isConditionDependent()) {
-E = P->getChosenSubExpr();
+if (auto *CE = dyn_cast(E)) {
+  if (!CE->isConditionDependent()) {
+E = CE->getChosenSubExpr();
 continue;
   }
 }
-if (ConstantExpr *CE = dyn_cast(E)) {
+if (auto *CE = dyn_cast(E)) {
   E = CE->getSubExpr();
   continue;
 }
@@ -2595,21 +2629,19 @@
   Expr *E = this;
   while (true) {
 E = E->IgnoreParens();
-if (CastExpr *P = dyn_cast(E)) {
-  E = P->getSubExpr();
+if (auto *CE = dyn_cast(E)) {
+  E = CE->getSubExpr();
   continue;
 }
-if (MaterializeTemporaryExpr *Materialize
-  = dyn_cast(E)) {
-  E = Materialize->GetTemporaryExpr();
+if (auto *MTE = dyn_cast(E)) {
+  E = MTE->GetTemporaryExpr();
   continue;
 }
-if (SubstNonTypeTemplateParmExpr *NTTP
-  = dyn_cast(E)) {
+if (auto *NTTP = dyn_cast(E)) {
   E 

r352996 - Hot fix two test regressions (%T vs %t)

2019-02-03 Thread David Zarzycki via cfe-commits
Author: davezarzycki
Date: Sun Feb  3 07:49:11 2019
New Revision: 352996

URL: http://llvm.org/viewvc/llvm-project?rev=352996=rev
Log:
Hot fix two test regressions (%T vs %t)

Different Unix "errno" values are returned for the following scenarios:

$ echo test > /tmp/existingFile/impossibleDir/impossibleFile
"Not a directory"
$ echo test > /tmp/nonexistentDir/impossibleFile
"No such file or directory"

This fixes the regression introduced by r352971 / D57592.

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

Modified: cfe/trunk/test/Frontend/output-failures.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/output-failures.c?rev=352996=352995=352996=diff
==
--- cfe/trunk/test/Frontend/output-failures.c (original)
+++ cfe/trunk/test/Frontend/output-failures.c Sun Feb  3 07:49:11 2019
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -emit-llvm -o %t/doesnotexist/somename %s 2> %t
+// RUN: not %clang_cc1 -emit-llvm -o %t.doesnotexist/somename %s 2> %t
 // RUN: FileCheck -check-prefix=OUTPUTFAIL -input-file=%t %s
 
 // OUTPUTFAIL: error: unable to open output file 
'{{.*}}doesnotexist{{.}}somename': '{{[nN]}}o such file or directory'

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


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


[PATCH] D57267: [AST] Factor out the logic of the various Expr::Ignore*

2019-02-03 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: lib/AST/Expr.cpp:2562
+return ICE->getSubExpr();
+
+  else if (auto *FE = dyn_cast_or_null(E))

It is something that is actually possible to audit. I did look at where each of 
the skipped node are created and it *seems* that a null child is not possible. 
However it is very easy to miss a case and adding the null check give the 
various `Expr::Ignore*` the following nice property:

Regardless of the state of the AST, for every expression `E` (null or not). 
`Ignore*(E)` produces the correct result (which may be null).

But perhaps the correct invariant to maintain is that these nodes have always a 
non-null child ?

I re-ran the benchmarks more carefully and here are the results I got (on my 
usual benchmark: `-fyntax-only` on all of Boost, 20 iterations with `perf 
stat`):

8.2117 +- 0.0131 seconds (with the null check)
8.2028 +- 0.0058 seconds (without the null check)



Comment at: lib/AST/Expr.cpp:2695
+/// Note that a null E is valid; in this case nothing is done.
+template  Expr *IgnoreExprNodes(Expr *E, FnTys &&... Fns) {
   Expr *LastE = nullptr;

aaron.ballman wrote:
> Formatting looks off here, did clang-format produce this?
It did, though with the `static` specifier `clang-format` adds a new line.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57267



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


[PATCH] D57267: [AST] Factor out the logic of the various Expr::Ignore*

2019-02-03 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 184944.
riccibruno marked 6 inline comments as done.
riccibruno added a comment.

Rebased and addressed Aaron's comments, except for the null check issue on 
which I am still undecided.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57267

Files:
  include/clang/AST/Expr.h
  lib/AST/Expr.cpp

Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -2556,185 +2556,173 @@
   return QualType();
 }
 
-Expr *Expr::IgnoreImpCasts() {
-  Expr *E = this;
-  while (true) {
-if (auto *ICE = dyn_cast(E))
-  E = ICE->getSubExpr();
-else if (auto *FE = dyn_cast(E))
-  E = FE->getSubExpr();
-else
-  break;
-  }
+static Expr *IgnoreImpCastsSingleStep(Expr *E) {
+  if (auto *ICE = dyn_cast_or_null(E))
+return ICE->getSubExpr();
+
+  if (auto *FE = dyn_cast_or_null(E))
+return FE->getSubExpr();
+
   return E;
 }
 
-Expr *Expr::IgnoreImplicit() {
-  Expr *E = this;
-  Expr *LastE = nullptr;
-  while (E != LastE) {
-LastE = E;
+static Expr *IgnoreImpCastsExtraSingleStep(Expr *E) {
+  // FIXME: Skip MaterializeTemporaryExpr and SubstNonTypeTemplateParmExpr in
+  // addition to what IgnoreImpCasts() skips to account for the current
+  // behaviour of IgnoreParenImpCasts().
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
 
-if (auto *ICE = dyn_cast(E))
-  E = ICE->getSubExpr();
+  if (auto *MTE = dyn_cast_or_null(E))
+return MTE->GetTemporaryExpr();
 
-if (auto *FE = dyn_cast(E))
-  E = FE->getSubExpr();
+  if (auto *NTTP = dyn_cast_or_null(E))
+return NTTP->getReplacement();
 
-if (auto *MTE = dyn_cast(E))
-  E = MTE->GetTemporaryExpr();
+  return E;
+}
+
+static Expr *IgnoreCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast_or_null(E))
+return CE->getSubExpr();
+
+  if (auto *FE = dyn_cast_or_null(E))
+return FE->getSubExpr();
+
+  if (auto *MTE = dyn_cast_or_null(E))
+return MTE->GetTemporaryExpr();
+
+  if (auto *NTTP = dyn_cast_or_null(E))
+return NTTP->getReplacement();
 
-if (auto *BTE = dyn_cast(E))
-  E = BTE->getSubExpr();
-  }
   return E;
 }
 
-Expr *Expr::IgnoreParens() {
-  Expr *E = this;
-  while (true) {
-if (auto *PE = dyn_cast(E)) {
-  E = PE->getSubExpr();
-  continue;
-}
-if (auto *UO = dyn_cast(E)) {
-  if (UO->getOpcode() == UO_Extension) {
-E = UO->getSubExpr();
-continue;
-  }
-}
-if (auto *GSE = dyn_cast(E)) {
-  if (!GSE->isResultDependent()) {
-E = GSE->getResultExpr();
-continue;
-  }
-}
-if (auto *CE = dyn_cast(E)) {
-  if (!CE->isConditionDependent()) {
-E = CE->getChosenSubExpr();
-continue;
-  }
-}
-if (auto *CE = dyn_cast(E)) {
-  E = CE->getSubExpr();
-  continue;
-}
-return E;
-  }
+static Expr *IgnoreLValueCastsSingleStep(Expr *E) {
+  // Skip what IgnoreCastsSingleStep skips, except that only
+  // lvalue-to-rvalue casts are skipped.
+  if (auto *CE = dyn_cast_or_null(E))
+if (CE->getCastKind() != CK_LValueToRValue)
+  return E;
+
+  return IgnoreCastsSingleStep(E);
 }
 
-/// IgnoreParenCasts - Ignore parentheses and casts.  Strip off any ParenExpr
-/// or CastExprs or ImplicitCastExprs, returning their operand.
-Expr *Expr::IgnoreParenCasts() {
-  Expr *E = this;
-  while (true) {
-E = E->IgnoreParens();
-if (auto *CE = dyn_cast(E)) {
-  E = CE->getSubExpr();
-  continue;
-}
-if (auto *MTE = dyn_cast(E)) {
-  E = MTE->GetTemporaryExpr();
-  continue;
-}
-if (auto *NTTP = dyn_cast(E)) {
-  E = NTTP->getReplacement();
-  continue;
-}
-if (auto *FE = dyn_cast(E)) {
-  E = FE->getSubExpr();
-  continue;
-}
-return E;
-  }
+static Expr *IgnoreBaseCastsSingleStep(Expr *E) {
+  if (auto *CE = dyn_cast_or_null(E))
+if (CE->getCastKind() == CK_DerivedToBase ||
+CE->getCastKind() == CK_UncheckedDerivedToBase ||
+CE->getCastKind() == CK_NoOp)
+  return CE->getSubExpr();
+
+  return E;
 }
 
-Expr *Expr::IgnoreCasts() {
-  Expr *E = this;
-  while (true) {
-if (auto *CE = dyn_cast(E)) {
-  E = CE->getSubExpr();
-  continue;
-}
-if (auto *MTE = dyn_cast(E)) {
-  E = MTE->GetTemporaryExpr();
-  continue;
-}
-if (auto *NTTP = dyn_cast(E)) {
-  E = NTTP->getReplacement();
-  continue;
-}
-if (auto *FE = dyn_cast(E)) {
-  E = FE->getSubExpr();
-  continue;
-}
-return E;
+static Expr *IgnoreImplicitSingleStep(Expr *E) {
+  Expr *SubE = IgnoreImpCastsSingleStep(E);
+  if (SubE != E)
+return SubE;
+
+  if (auto *MTE = dyn_cast_or_null(E))
+return MTE->GetTemporaryExpr();
+
+  if (auto *BTE = dyn_cast_or_null(E))
+return BTE->getSubExpr();
+
+  return E;
+}
+
+static Expr 

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

2019-02-03 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL352989: [AST] Extract ASTNodeTraverser class from ASTDumper 
(authored by steveire, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D57472?vs=184616=184946#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D57472

Files:
  cfe/trunk/include/clang/AST/ASTNodeTraverser.h
  cfe/trunk/lib/AST/ASTDumper.cpp

Index: cfe/trunk/include/clang/AST/ASTNodeTraverser.h
===
--- cfe/trunk/include/clang/AST/ASTNodeTraverser.h
+++ cfe/trunk/include/clang/AST/ASTNodeTraverser.h
@@ -0,0 +1,621 @@
+//===--- ASTNodeTraverser.h - Traversal of AST nodes --===//
+//
+// 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
+//
+//===--===//
+//
+// This file implements the AST traversal facilities.  Other users
+// of this class may make use of the same traversal logic by inheriting it,
+// similar to RecursiveASTVisitor.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_ASTNODETRAVERSER_H
+#define LLVM_CLANG_AST_ASTNODETRAVERSER_H
+
+#include "clang/AST/AttrVisitor.h"
+#include "clang/AST/CommentVisitor.h"
+#include "clang/AST/DeclVisitor.h"
+#include "clang/AST/LocInfoType.h"
+#include "clang/AST/StmtVisitor.h"
+#include "clang/AST/TemplateArgumentVisitor.h"
+#include "clang/AST/TypeVisitor.h"
+
+namespace clang {
+
+/**
+
+ASTNodeTraverser traverses the Clang AST for dumping purposes.
+
+The `Derived::doGetNodeDelegate()` method is required to be an accessible member
+which returns a reference of type `NodeDelegateType &` which implements the
+following interface:
+
+struct {
+  template  void AddChild(Fn DoAddChild);
+  template  void AddChild(StringRef Label, Fn DoAddChild);
+
+  void Visit(const comments::Comment *C, const comments::FullComment *FC);
+  void Visit(const Attr *A);
+  void Visit(const TemplateArgument , SourceRange R = {},
+ const Decl *From = nullptr, StringRef Label = {});
+  void Visit(const Stmt *Node);
+  void Visit(const Type *T);
+  void Visit(QualType T);
+  void Visit(const Decl *D);
+  void Visit(const CXXCtorInitializer *Init);
+  void Visit(const OMPClause *C);
+  void Visit(const BlockDecl::Capture );
+  void Visit(const GenericSelectionExpr::ConstAssociation );
+};
+*/
+template 
+class ASTNodeTraverser
+: public ConstDeclVisitor,
+  public ConstStmtVisitor,
+  public comments::ConstCommentVisitor,
+  public TypeVisitor,
+  public ConstAttrVisitor,
+  public ConstTemplateArgumentVisitor {
+
+  /// Indicates whether we should trigger deserialization of nodes that had
+  /// not already been loaded.
+  bool Deserialize = false;
+
+  NodeDelegateType () {
+return getDerived().doGetNodeDelegate();
+  }
+  Derived () { return *static_cast(this); }
+
+public:
+  void setDeserialize(bool D) { Deserialize = D; }
+  bool getDeserialize() const { return Deserialize; }
+
+  void Visit(const Decl *D) {
+getNodeDelegate().AddChild([=] {
+  getNodeDelegate().Visit(D);
+  if (!D)
+return;
+
+  ConstDeclVisitor::Visit(D);
+
+  for (const auto  : D->attrs())
+Visit(A);
+
+  if (const comments::FullComment *Comment =
+  D->getASTContext().getLocalCommentForDeclUncached(D))
+Visit(Comment, Comment);
+
+  // Decls within functions are visited by the body.
+  if (!isa(*D) && !isa(*D)) {
+if (const auto *DC = dyn_cast(D))
+  dumpDeclContext(DC);
+  }
+});
+  }
+
+  void Visit(const Stmt *S, StringRef Label = {}) {
+getNodeDelegate().AddChild(Label, [=] {
+  getNodeDelegate().Visit(S);
+
+  if (!S) {
+return;
+  }
+
+  ConstStmtVisitor::Visit(S);
+
+  // Some statements have custom mechanisms for dumping their children.
+  if (isa(S) || isa(S)) {
+return;
+  }
+
+  for (const Stmt *SubStmt : S->children())
+Visit(SubStmt);
+});
+  }
+
+  void Visit(QualType T) {
+SplitQualType SQT = T.split();
+if (!SQT.Quals.hasQualifiers())
+  return Visit(SQT.Ty);
+
+getNodeDelegate().AddChild([=] {
+  getNodeDelegate().Visit(T);
+  Visit(T.split().Ty);
+});
+  }
+
+  void Visit(const Type *T) {
+getNodeDelegate().AddChild([=] {
+  getNodeDelegate().Visit(T);
+  if (!T)
+return;
+  TypeVisitor::Visit(T);
+
+  QualType SingleStepDesugar =
+  T->getLocallyUnqualifiedSingleStepDesugaredType();
+  if (SingleStepDesugar != QualType(T, 0))
+Visit(SingleStepDesugar);
+ 

r352989 - [AST] Extract ASTNodeTraverser class from ASTDumper

2019-02-03 Thread Stephen Kelly via cfe-commits
Author: steveire
Date: Sun Feb  3 06:06:54 2019
New Revision: 352989

URL: http://llvm.org/viewvc/llvm-project?rev=352989=rev
Log:
[AST] Extract ASTNodeTraverser class from ASTDumper

Summary:
This new traverser class allows clients to re-use the traversal logic
which was previously part of ASTDumper.  This means that alternative
visit logic may be implemented, such as

* Dump to alternative data formats such as JSON
* Implement AST Matcher parent/child visitation matching AST dumps

Reviewers: aaron.ballman

Subscribers: jfb, cfe-commits

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

Added:
cfe/trunk/include/clang/AST/ASTNodeTraverser.h
Modified:
cfe/trunk/lib/AST/ASTDumper.cpp

Added: cfe/trunk/include/clang/AST/ASTNodeTraverser.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTNodeTraverser.h?rev=352989=auto
==
--- cfe/trunk/include/clang/AST/ASTNodeTraverser.h (added)
+++ cfe/trunk/include/clang/AST/ASTNodeTraverser.h Sun Feb  3 06:06:54 2019
@@ -0,0 +1,621 @@
+//===--- ASTNodeTraverser.h - Traversal of AST nodes 
--===//
+//
+// 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
+//
+//===--===//
+//
+// This file implements the AST traversal facilities.  Other users
+// of this class may make use of the same traversal logic by inheriting it,
+// similar to RecursiveASTVisitor.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_AST_ASTNODETRAVERSER_H
+#define LLVM_CLANG_AST_ASTNODETRAVERSER_H
+
+#include "clang/AST/AttrVisitor.h"
+#include "clang/AST/CommentVisitor.h"
+#include "clang/AST/DeclVisitor.h"
+#include "clang/AST/LocInfoType.h"
+#include "clang/AST/StmtVisitor.h"
+#include "clang/AST/TemplateArgumentVisitor.h"
+#include "clang/AST/TypeVisitor.h"
+
+namespace clang {
+
+/**
+
+ASTNodeTraverser traverses the Clang AST for dumping purposes.
+
+The `Derived::doGetNodeDelegate()` method is required to be an accessible 
member
+which returns a reference of type `NodeDelegateType &` which implements the
+following interface:
+
+struct {
+  template  void AddChild(Fn DoAddChild);
+  template  void AddChild(StringRef Label, Fn DoAddChild);
+
+  void Visit(const comments::Comment *C, const comments::FullComment *FC);
+  void Visit(const Attr *A);
+  void Visit(const TemplateArgument , SourceRange R = {},
+ const Decl *From = nullptr, StringRef Label = {});
+  void Visit(const Stmt *Node);
+  void Visit(const Type *T);
+  void Visit(QualType T);
+  void Visit(const Decl *D);
+  void Visit(const CXXCtorInitializer *Init);
+  void Visit(const OMPClause *C);
+  void Visit(const BlockDecl::Capture );
+  void Visit(const GenericSelectionExpr::ConstAssociation );
+};
+*/
+template 
+class ASTNodeTraverser
+: public ConstDeclVisitor,
+  public ConstStmtVisitor,
+  public comments::ConstCommentVisitor,
+  public TypeVisitor,
+  public ConstAttrVisitor,
+  public ConstTemplateArgumentVisitor {
+
+  /// Indicates whether we should trigger deserialization of nodes that had
+  /// not already been loaded.
+  bool Deserialize = false;
+
+  NodeDelegateType () {
+return getDerived().doGetNodeDelegate();
+  }
+  Derived () { return *static_cast(this); }
+
+public:
+  void setDeserialize(bool D) { Deserialize = D; }
+  bool getDeserialize() const { return Deserialize; }
+
+  void Visit(const Decl *D) {
+getNodeDelegate().AddChild([=] {
+  getNodeDelegate().Visit(D);
+  if (!D)
+return;
+
+  ConstDeclVisitor::Visit(D);
+
+  for (const auto  : D->attrs())
+Visit(A);
+
+  if (const comments::FullComment *Comment =
+  D->getASTContext().getLocalCommentForDeclUncached(D))
+Visit(Comment, Comment);
+
+  // Decls within functions are visited by the body.
+  if (!isa(*D) && !isa(*D)) {
+if (const auto *DC = dyn_cast(D))
+  dumpDeclContext(DC);
+  }
+});
+  }
+
+  void Visit(const Stmt *S, StringRef Label = {}) {
+getNodeDelegate().AddChild(Label, [=] {
+  getNodeDelegate().Visit(S);
+
+  if (!S) {
+return;
+  }
+
+  ConstStmtVisitor::Visit(S);
+
+  // Some statements have custom mechanisms for dumping their children.
+  if (isa(S) || isa(S)) {
+return;
+  }
+
+  for (const Stmt *SubStmt : S->children())
+Visit(SubStmt);
+});
+  }
+
+  void Visit(QualType T) {
+SplitQualType SQT = T.split();
+if (!SQT.Quals.hasQualifiers())
+  return Visit(SQT.Ty);
+
+getNodeDelegate().AddChild([=] {
+  getNodeDelegate().Visit(T);
+  Visit(T.split().Ty);
+});
+  }
+
+  void Visit(const Type *T) {
+

[clang-tools-extra] r352990 - Remove trailing semicolon. NFCI.

2019-02-03 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Sun Feb  3 06:08:30 2019
New Revision: 352990

URL: http://llvm.org/viewvc/llvm-project?rev=352990=rev
Log:
Remove trailing semicolon. NFCI.

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

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=352990=352989=352990=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Sun Feb  3 06:08:30 2019
@@ -53,7 +53,7 @@ CodeAction toCodeAction(const ClangdServ
   CA.command->tweakArgs->tweakID = T.ID;
   CA.command->tweakArgs->selection = Selection;
   return CA;
-};
+}
 
 void adjustSymbolKinds(llvm::MutableArrayRef Syms,
SymbolKindBitset Kinds) {


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


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

2019-02-03 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

Hot fix: r352996


Repository:
  rL LLVM

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

https://reviews.llvm.org/D57592



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


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2019-02-03 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 updated this revision to Diff 184988.
shiva0217 added a comment.

Support passing small data limitation for target riscv32-unknown-linux-gnu with 
LTO enabled.


Repository:
  rC Clang

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

https://reviews.llvm.org/D57497

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Gnu.cpp
  lib/Driver/ToolChains/RISCVToolchain.cpp
  lib/Driver/ToolChains/RISCVToolchain.h
  test/Driver/riscv-features.c

Index: test/Driver/riscv-features.c
===
--- test/Driver/riscv-features.c
+++ test/Driver/riscv-features.c
@@ -11,3 +11,41 @@
 // NO-RELAX: "-target-feature" "-relax"
 // DEFAULT-NOT: "-target-feature" "+relax"
 // DEFAULT-NOT: "-target-feature" "-relax"
+
+/// Small data section limitaion setting.
+// RUN: %clang -target riscv32 -### -S %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32 %s
+// CHECK-RV32-NOT: "-mllvm" "-riscv-ssection-threshold"
+// RUN: %clang -target riscv64 -### -S %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64 %s
+// CHECK-RV64-NOT: "-mllvm" "-riscv-ssection-threshold"
+// RUN: %clang -target riscv32 -flto -### %s \
+// RUN: -G 16 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32-G16-LTO %s
+// CHECK-RV32-G16-LTO: "-plugin-opt=-riscv-ssection-threshold=16"
+// RUN: %clang -target riscv32-unknown-linux-gnu -flto -### %s \
+// RUN: -G 16 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32-LINUX-G16-LTO %s
+// CHECK-RV32-LINUX-G16-LTO: "-plugin-opt=-riscv-ssection-threshold=16"
+// RUN: %clang -target riscv32 -### %s \
+// RUN: -G 0 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32-G0 %s
+// CHECK-RV32-G0: "-mllvm" "-riscv-ssection-threshold=0"
+// RUN: %clang -target riscv64 -mcmodel=large -### -S %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64-LARGE %s
+// CHECK-RV64-LARGE: "-mllvm" "-riscv-ssection-threshold=0"
+// RUN: %clang -target riscv32 -fpic -### -S %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32-PIC %s
+// CHECK-RV32-PIC: "-mllvm" "-riscv-ssection-threshold=0"
+// RUN: %clang -target riscv64 -fpic -### -S %s \
+// RUN: -G 16 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64-PIC-G16 %s
+// CHECK-RV64-PIC-G16: "-mllvm" "-riscv-ssection-threshold=16"
+// RUN: %clang -target riscv32 -### -S %s \
+// RUN: -G 16 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV32-G16 %s
+// CHECK-RV32-G16: "-mllvm" "-riscv-ssection-threshold=16"
+// RUN: %clang -target riscv64 -mcmodel=large -### -S %s \
+// RUN: -G 16 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-RV64-LARGE-G16 %s
+// CHECK-RV64-LARGE-G16: "-mllvm" "-riscv-ssection-threshold=16"
Index: lib/Driver/ToolChains/RISCVToolchain.h
===
--- lib/Driver/ToolChains/RISCVToolchain.h
+++ lib/Driver/ToolChains/RISCVToolchain.h
@@ -32,7 +32,11 @@
   addLibStdCxxIncludePaths(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const override;
 
+  static StringRef getSmallDataThreshold(const llvm::opt::ArgList ,
+ const llvm::Triple );
+
 protected:
+  bool HasNativeLLVMSupport() const override { return true; }
   Tool *buildLinker() const override;
 
 private:
Index: lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- lib/Driver/ToolChains/RISCVToolchain.cpp
+++ lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -86,6 +86,25 @@
   return SysRootDir;
 }
 
+StringRef RISCVToolChain::getSmallDataThreshold(const ArgList ,
+const llvm::Triple ) {
+  StringRef Gn = "";
+  if (Arg *A = Args.getLastArg(options::OPT_G)) {
+Gn = A->getValue();
+  // Not support linker relaxation for PIC.
+  } else if (Args.getLastArg(options::OPT_shared, options::OPT_fpic,
+ options::OPT_fPIC)) {
+Gn = "0";
+  // Not support linker relaxation for RV64 with large code model.
+  } else if (Args.getLastArgValue(options::OPT_mcmodel_EQ)
+ .equals_lower("large") &&
+ (Triple.getArch() == llvm::Triple::riscv64)) {
+Gn = "0";
+  }
+
+  return Gn;
+}
+
 void RISCV::Linker::ConstructJob(Compilation , const JobAction ,
  const InputInfo ,
  const InputInfoList ,
@@ -114,6 +133,25 @@
   {options::OPT_T_Group, options::OPT_e, options::OPT_s,
options::OPT_t, options::OPT_Z_Flag, options::OPT_r});
 
+  if (D.isUsingLTO()) {
+assert(!Inputs.empty() && "Must have at least one input.");
+AddGoldPlugin(ToolChain, Args, CmdArgs, Output, Inputs[0],
+  D.getLTOMode() == LTOK_Thin);
+
+// Passing small data section limitaion.
+StringRef G = toolchains::RISCVToolChain::getSmallDataThreshold(
+Args, ToolChain.getTriple());
+if 

[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2019-02-03 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 added a comment.

In D57497#1382393 , @apazos wrote:

> I don't see -plugin-opt=-riscv-ssection-threshold=.. being passed.
>  tools::gnutools::Linker::ConstructJob is being invoked with target 
> riscv32-unknown-linux-gnu
>  It has to work for riscv32-unknown-linux-gnu and riscv32-unknown-elf


Hi Ana, I've added the passing code in `tools::gnutools::Linker::ConstructJob` 
for non-baremetal target.
Thanks for pointing me out the missing part. :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D57497



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


[PATCH] D57220: Test fix for isViableInline remark message

2019-02-03 Thread Yevgeny Rouban via Phabricator via cfe-commits
yrouban closed this revision.
yrouban added a comment.

Landed along with D57089  (see rC352849 
).


Repository:
  rC Clang

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

https://reviews.llvm.org/D57220



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


[PATCH] D57220: Test fix for isViableInline remark message

2019-02-03 Thread Yevgeny Rouban via Phabricator via cfe-commits
yrouban marked an inline comment as done.
yrouban added inline comments.



Comment at: test/Frontend/optimization-remark-with-hotness.c:63
   // NO_PGO: '-fdiagnostics-hotness-threshold=' requires profile-guided 
optimization information
   // expected-remark@+1 {{foo inlined into bar with (cost=always): always 
inliner (hotness:}}
   sum += foo(x, x - 2);

xbolva00 wrote:
> What about this line?
positive inlining remarks did not change. I did not see tests failure, did you?


Repository:
  rC Clang

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

https://reviews.llvm.org/D57220



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


r353018 - [OpenMP] Adding support to the mutexinoutset dep-type

2019-02-03 Thread Sergi Mateo Bellido via cfe-commits
Author: smateo
Date: Sun Feb  3 23:33:19 2019
New Revision: 353018

URL: http://llvm.org/viewvc/llvm-project?rev=353018=rev
Log:
[OpenMP] Adding support to the mutexinoutset dep-type

Summary: this commit adds support to a new dependence type introduced in OpenMP
5.0. The LLVM OpenMP RTL already supports this feature, so we  only need to
modify CLANG to take advantage of them.


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



Modified:
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
cfe/trunk/test/OpenMP/target_depend_messages.cpp
cfe/trunk/test/OpenMP/target_enter_data_depend_messages.cpp
cfe/trunk/test/OpenMP/target_exit_data_depend_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_depend_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_depend_messages.cpp
cfe/trunk/test/OpenMP/target_parallel_for_simd_depend_messages.cpp
cfe/trunk/test/OpenMP/target_simd_depend_messages.cpp
cfe/trunk/test/OpenMP/target_teams_depend_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_depend_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp

cfe/trunk/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
cfe/trunk/test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
cfe/trunk/test/OpenMP/target_update_depend_messages.cpp
cfe/trunk/test/OpenMP/task_codegen.cpp
cfe/trunk/test/OpenMP/task_depend_messages.cpp

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.def?rev=353018=353017=353018=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.def (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.def Sun Feb  3 23:33:19 2019
@@ -386,6 +386,7 @@ OPENMP_DEFAULTMAP_MODIFIER(tofrom)
 OPENMP_DEPEND_KIND(in)
 OPENMP_DEPEND_KIND(out)
 OPENMP_DEPEND_KIND(inout)
+OPENMP_DEPEND_KIND(mutexinoutset)
 OPENMP_DEPEND_KIND(source)
 OPENMP_DEPEND_KIND(sink)
 

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp?rev=353018=353017=353018=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntime.cpp Sun Feb  3 23:33:19 2019
@@ -5087,7 +5087,7 @@ void CGOpenMPRuntime::emitTaskCall(CodeG
   unsigned NumDependencies = Data.Dependences.size();
   if (NumDependencies) {
 // Dependence kind for RTL.
-enum RTLDependenceKindTy { DepIn = 0x01, DepInOut = 0x3 };
+enum RTLDependenceKindTy { DepIn = 0x01, DepInOut = 0x3, DepMutexInOutSet 
= 0x4 };
 enum RTLDependInfoFieldsTy { BaseAddr, Len, Flags };
 RecordDecl *KmpDependInfoRD;
 QualType FlagsTy =
@@ -5154,6 +5154,9 @@ void CGOpenMPRuntime::emitTaskCall(CodeG
   case OMPC_DEPEND_inout:
 DepKind = DepInOut;
 break;
+  case OMPC_DEPEND_mutexinoutset:
+DepKind = DepMutexInOutSet;
+break;
   case OMPC_DEPEND_source:
   case OMPC_DEPEND_sink:
   case OMPC_DEPEND_unknown:

Modified: cfe/trunk/test/OpenMP/target_depend_messages.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_depend_messages.cpp?rev=353018=353017=353018=diff
==
--- cfe/trunk/test/OpenMP/target_depend_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/target_depend_messages.cpp Sun Feb  3 23:33:19 2019
@@ -24,13 +24,13 @@ int main(int argc, char **argv, char *en
 
   #pragma omp target depend // expected-error {{expected '(' after 'depend'}}
   foo();
-  #pragma omp target depend ( // expected-error {{expected 'in', 'out' or 
'inout' in OpenMP clause 'depend'}} expected-error {{expected ')'}} 
expected-note {{to match this '('}} expected-warning {{missing ':' after 
dependency type - ignoring}}
+  #pragma omp target depend ( // expected-error {{expected 'in', 'out', 
'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} expected-error 
{{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing 
':' after dependency type - ignoring}}
   foo();
-  #pragma omp target depend () // expected-error {{expected 'in', 'out' or 
'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after 
dependency type - ignoring}}
+  #pragma omp target depend () // expected-error {{expected 'in', 'out', 
'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} expected-warning 
{{missing ':' after dependency type - ignoring}}
   foo();
-  #pragma omp target depend (argc // expected-error {{expected 'in', 'out' or 
'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after 
dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to 
match this '('}}
+  #pragma 

[PATCH] D57576: Adding support to the OpenMP mutexinoutset dependency type

2019-02-03 Thread Sergi Mateo Bellido via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC353018: [OpenMP] Adding support to the mutexinoutset 
dep-type (authored by smateo, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D57576

Files:
  include/clang/Basic/OpenMPKinds.def
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/target_depend_messages.cpp
  test/OpenMP/target_enter_data_depend_messages.cpp
  test/OpenMP/target_exit_data_depend_messages.cpp
  test/OpenMP/target_parallel_depend_messages.cpp
  test/OpenMP/target_parallel_for_depend_messages.cpp
  test/OpenMP/target_parallel_for_simd_depend_messages.cpp
  test/OpenMP/target_simd_depend_messages.cpp
  test/OpenMP/target_teams_depend_messages.cpp
  test/OpenMP/target_teams_distribute_depend_messages.cpp
  test/OpenMP/target_teams_distribute_parallel_for_depend_messages.cpp
  test/OpenMP/target_teams_distribute_parallel_for_simd_depend_messages.cpp
  test/OpenMP/target_teams_distribute_simd_depend_messages.cpp
  test/OpenMP/target_update_depend_messages.cpp
  test/OpenMP/task_codegen.cpp
  test/OpenMP/task_depend_messages.cpp

Index: test/OpenMP/target_parallel_for_depend_messages.cpp
===
--- test/OpenMP/target_parallel_for_depend_messages.cpp
+++ test/OpenMP/target_parallel_for_depend_messages.cpp
@@ -25,13 +25,13 @@
 
   #pragma omp target parallel for depend // expected-error {{expected '(' after 'depend'}}
   for (i = 0; i < argc; ++i) foo();
-  #pragma omp target parallel for depend ( // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}}
+  #pragma omp target parallel for depend ( // expected-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}}
   for (i = 0; i < argc; ++i) foo();
-  #pragma omp target parallel for depend () // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}}
+  #pragma omp target parallel for depend () // expected-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}}
   for (i = 0; i < argc; ++i) foo();
-  #pragma omp target parallel for depend (argc // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target parallel for depend (argc // expected-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (i = 0; i < argc; ++i) foo();
-  #pragma omp target parallel for depend (source : argc) // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}}
+  #pragma omp target parallel for depend (source : argc) // expected-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}}
   for (i = 0; i < argc; ++i) foo();
   #pragma omp target parallel for depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}}
   for (i = 0; i < argc; ++i) foo();
Index: test/OpenMP/target_teams_distribute_depend_messages.cpp
===
--- test/OpenMP/target_teams_distribute_depend_messages.cpp
+++ test/OpenMP/target_teams_distribute_depend_messages.cpp
@@ -25,13 +25,13 @@
 
 #pragma omp target teams distribute depend // expected-error {{expected '(' after 'depend'}}
   for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute depend ( // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}}
+#pragma omp target teams distribute depend ( // expected-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}}
   for (i = 0; i < argc; ++i) foo();
-#pragma omp target teams distribute depend () // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}}
+#pragma omp target teams distribute depend () // expected-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}}