[PATCH] D83914: [clangd] Plan features for FoldingRanges

2020-07-19 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 279132.
kbobyrev marked 13 inline comments as done.
kbobyrev added a comment.

Resolve most comments, make sure everything builds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83914

Files:
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -234,6 +234,544 @@
   }
 }
 
+TEST(FoldingRanges, ControlFlow) {
+  const char *Tests[] = {
+  // If.
+  R"cpp(
+int main() {[[
+  bool B = true;
+  int I = 0;
+  char C = 'z';
+
+  if (B && I > 42 || ~(++I)) {[[
+++I;
+  ]]} else {[[
+B = false;
+  ]]}
+
+  if (B && (!B) || !((C == 'a'))) {[[
+++I;
+  ]]} else if ([[!B && true != false &&
+   2 * 2 == 4]]) {[[
+--I;
+  ]]} else {[[
+C = 'a';
+  ]]}
+
+  if (B && ([["subexpression" != "multi-line" &&
+1 > 0]]))
+B = false;
+
+  if ([[int Init = 0, Variable = 9000;
+  [[Init == 0 && Init > 0 ||
+  Init < 5000)
+Init = 42;
+]]}
+  )cpp",
+  // While.
+  R"cpp(
+int main() {[[
+  bool B;
+  while ([[B]]) {[[
+B = !B;
+  ]]}
+
+  do {[[
+B = !B;
+  ]]} while ([[B]]);
+]]}
+  )cpp",
+  // For.
+  R"cpp(
+int main() {[[
+  for ([[int I = 0;I < 42; ++I]]) {[[
+--I;
+  ]]}
+]]}
+  )cpp",
+  // Switch.
+  R"cpp(
+void noop();
+
+int main() {[[
+  int i = 2;
+  switch ([[i]]) {[[
+  case 1:[[ noop();]]
+  case 2:[[ noop(); //[[execution starts at this case label
+  case 3:[[ noop();]]
+  case 4:
+  case 5:[[ noop();
+  break;  //[[execution of subsequent statements is terminated
+  case 6:[[ noop();]]
+  ]]}
+]]}
+  )cpp",
+  };
+  for (const char *Test : Tests) {
+auto T = Annotations(Test);
+auto AST = TestTU::withCode(T.code()).build();
+EXPECT_THAT(gatherFoldingRanges(llvm::cantFail(getFoldingRanges(AST))),
+UnorderedElementsAreArray(T.ranges()))
+<< Test;
+  }
+}
+
+TEST(FoldingRanges, Misc) {
+  const char *Tests[] = {
+  // Statement groups.
+  R"cpp(
+int main() {[[
+  [[int X = 5;
+  int Y = 42;
+  bool B = 15;]]
+  if ([[B]]) {[[ ++X; ]]}
+  unsigned U = 9000;
+]]}
+  )cpp",
+  // Expressions (fold if they span multiple lines).
+  R"cpp(
+int main() {[[
+  bool B = 42 > 0;
+  B = (42 > 0);
+  B = (42 > 0 && 9000 > 2000);
+  B = 42 > 0 && (9000 > 2000 && 2000 > 1000);
+  B = [[42 > 0 && ([[9000 > 2000 &&
+ 2000 > 1000]])]];
+]]}
+  )cpp",
+  // Enum.
+  R"cpp(
+enum Color {[[
+  Green = 0,
+  YInMn,
+  Orange,
+]]};
+  )cpp",
+  // Argument lists.
+  R"cpp(
+int foo([[char C, bool B]]) {[[ return static_cast(C); ]]}
+
+foo([['z', true]]);
+
+struct Foo {
+  Foo([[int I, unsigned U, bool B=true]]) {}
+};
+
+Foo F = Foo([[/*[[I=]]*/1, /*[[U=]]*/2, /*[[B=]]false]]);
+F = Foo([[1, 2]]);
+  )cpp",
+  // Namespace.
+  R"cpp(
+namespace ns {[[
+int Variable = 42;
+namespace nested {[[
+int NestedVariable = 50;
+]]}
+]]}
+
+namespace a {[[
+namespace b {[[
+namespace c {[[
+
+]]} //[[ namespacee c]]
+]]} //[[ namespacee b]]
+]]} //[[ namespacee a]]
+
+namespace modern::ns::syntax {[[
+]]} //[[ namespace modern::ns::syntax]]
+
+namespace {[[
+]]} //[[ namespace]]
+
+extern "C" {[[
+  void Foo();
+]]}
+  )cpp",
+  // Strings.
+  R"cpp(
+std::string String = "[[ShortString]]";
+String = "[[Super Long String]]";
+String = u8"[[Super Long String]]";
+
+String = R"raw([[Super Looong String]])raw";
+
+const char *text =
+  "[[This"
+  "is a multiline"
+  "string]]";
+
+const char *text2 =
+  "[[Here is another \
+string \
+also \
+multilinee]]";
+  )cpp",
+  // Ar

[PATCH] D82845: [Analyzer][StreamChecker] Report every leak, clean up state.

2020-07-19 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 279131.
balazske added a comment.

Fixed formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82845

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-note.c

Index: clang/test/Analysis/stream-note.c
===
--- clang/test/Analysis/stream-note.c
+++ clang/test/Analysis/stream-note.c
@@ -46,3 +46,34 @@
 }
 // expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
 // expected-note@-2 {{Opened stream never closed. Potential resource leak}}
+
+void check_note_leak_2(int c) {
+  FILE *F1 = fopen("foo1.c", "r"); // expected-note {{Stream opened here}}
+  if (!F1)
+// expected-note@-1 {{'F1' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+// expected-note@-3 {{'F1' is non-null}}
+// expected-note@-4 {{Taking false branch}}
+return;
+  FILE *F2 = fopen("foo2.c", "r"); // expected-note {{Stream opened here}}
+  if (!F2) {
+// expected-note@-1 {{'F2' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+// expected-note@-3 {{'F2' is non-null}}
+// expected-note@-4 {{Taking false branch}}
+fclose(F1);
+return;
+  }
+  if (c)
+// expected-note@-1 {{Assuming 'c' is not equal to 0}}
+// expected-note@-2 {{Taking true branch}}
+// expected-note@-3 {{Assuming 'c' is not equal to 0}}
+// expected-note@-4 {{Taking true branch}}
+return;
+  // expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+  // expected-note@-2 {{Opened stream never closed. Potential resource leak}}
+  // expected-warning@-3 {{Opened stream never closed. Potential resource leak}}
+  // expected-note@-4 {{Opened stream never closed. Potential resource leak}}
+  fclose(F1);
+  fclose(F2);
+}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -337,6 +337,12 @@
   /// to ensure uniform handling.
   void reportFEofWarning(CheckerContext &C, ProgramStateRef State) const;
 
+  /// Emit resource leak warnings for the given symbols.
+  /// Createn a non-fatal error node for these, and returns it (if any warnings
+  /// were generated). Return value is non-null.
+  ExplodedNode *reportLeaks(const SmallVector &LeakedSyms,
+CheckerContext &C, ExplodedNode *Pred) const;
+
   /// Find the description data of the function called by a call event.
   /// Returns nullptr if no function is recognized.
   const FnDescription *lookupFn(const CallEvent &Call) const {
@@ -956,28 +962,19 @@
   C.addTransition(State);
 }
 
-void StreamChecker::checkDeadSymbols(SymbolReaper &SymReaper,
- CheckerContext &C) const {
-  ProgramStateRef State = C.getState();
-
-  // TODO: Clean up the state.
-  const StreamMapTy &Map = State->get();
-  for (const auto &I : Map) {
-SymbolRef Sym = I.first;
-const StreamState &SS = I.second;
-if (!SymReaper.isDead(Sym) || !SS.isOpened())
-  continue;
-
-ExplodedNode *N = C.generateErrorNode();
-if (!N)
-  continue;
+ExplodedNode *
+StreamChecker::reportLeaks(const SmallVector &LeakedSyms,
+   CheckerContext &C, ExplodedNode *Pred) const {
+  // Do not warn for non-closed stream at program exit.
+  // FIXME: Use BugType::SuppressOnSink instead.
+  if (Pred && Pred->getCFGBlock() && Pred->getCFGBlock()->hasNoReturnElement())
+return Pred;
 
-// Do not warn for non-closed stream at program exit.
-ExplodedNode *Pred = C.getPredecessor();
-if (Pred && Pred->getCFGBlock() &&
-Pred->getCFGBlock()->hasNoReturnElement())
-  continue;
+  ExplodedNode *Err = C.generateNonFatalErrorNode(C.getState(), Pred);
+  if (!Err)
+return Pred;
 
+  for (SymbolRef LeakSym : LeakedSyms) {
 // Resource leaks can result in multiple warning that describe the same kind
 // of programming error:
 //  void f() {
@@ -989,8 +986,7 @@
 // from a different kinds of errors), the reduction in redundant reports
 // makes this a worthwhile heuristic.
 // FIXME: Add a checker option to turn this uniqueing feature off.
-
-const ExplodedNode *StreamOpenNode = getAcquisitionSite(N, Sym, C);
+const ExplodedNode *StreamOpenNode = getAcquisitionSite(Err, LeakSym, C);
 assert(StreamOpenNode && "Could not find place of stream opening.");
 PathDiagnosticLocation LocUsedForUniqueing =
 PathDiagnosticLocation::createBegin(
@@ -1000,12 +996,38 @@
 std::unique_ptr R =
 std::make_unique(
 BT_ResourceLeak,
-"Opened stream never closed. Potential resource leak.", N,
+"Opened stream never closed. Potential resource leak.", Err

[Differential] D83629: [Utils] Check function attributes in update_test_checks

2020-07-19 Thread Stefan Stipanovic via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG937bad3594e7: [Utils] Check function attributes in 
update_test_checks (authored by sstefan1).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D83629?vs=278295&id=278988#toc

Repository:
  rG LLVM Github Monorepo

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


  https://reviews.llvm.org/D83629

Files:
  clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp
  
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
  
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.plain.expected
  clang/test/utils/update_cc_test_checks/check_attrs.test
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.plain.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/check_attrs.test
  llvm/utils/UpdateTestChecks/asm.py
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_analyze_test_checks.py
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_test_checks.py

Index: llvm/utils/update_test_checks.py
===
--- llvm/utils/update_test_checks.py
+++ llvm/utils/update_test_checks.py
@@ -52,6 +52,8 @@
   help='Keep function signature information around for the check line')
   parser.add_argument('--scrub-attributes', action='store_true',
   help='Remove attribute annotations (#0) from the end of check line')
+  parser.add_argument('--check-attributes', action='store_true',
+  help='Check "Function Attributes" for functions')
   parser.add_argument('tests', nargs='+')
   initial_args = common.parse_commandline_args(parser)
 
@@ -111,7 +113,7 @@
   common.build_function_body_dictionary(
   common.OPT_FUNCTION_RE, common.scrub_body, [],
   raw_tool_output, prefixes, func_dict, ti.args.verbose,
-  ti.args.function_signature)
+  ti.args.function_signature, ti.args.check_attributes)
 
 is_in_function = False
 is_in_function_start = False
Index: llvm/utils/update_cc_test_checks.py
===
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -131,6 +131,8 @@
   help='Use more regex for x86 matching to reduce diffs between various subtargets')
   parser.add_argument('--function-signature', action='store_true',
   help='Keep function signature information around for the check line')
+  parser.add_argument('--check-attributes', action='store_true',
+  help='Check "Function Attributes" for functions')
   parser.add_argument('tests', nargs='+')
   args = common.parse_commandline_args(parser)
 
@@ -189,7 +191,7 @@
   if '-emit-llvm' in clang_args:
 common.build_function_body_dictionary(
 common.OPT_FUNCTION_RE, common.scrub_body, [],
-raw_tool_output, prefixes, func_dict, args.verbose, args.function_signature)
+raw_tool_output, prefixes, func_dict, args.verbose, args.function_signature, args.check_attributes)
   else:
 print('The clang command line should include -emit-llvm as asm tests '
   'are discouraged in Clang testsuite.', file=sys.stderr)
Index: llvm/utils/update_analyze_test_checks.py
===
--- llvm/utils/update_analyze_test_checks.py
+++ llvm/utils/update_analyze_test_checks.py
@@ -122,7 +122,7 @@
   for raw_tool_output in re.split(r'Printing analysis ', raw_tool_outputs):
 common.build_function_body_dictionary(
   common.ANALYZE_FUNCTION_RE, common.scrub_body, [],
-  raw_tool_output, prefixes, func_dict, args.verbose, False)
+  raw_tool_output, prefixes, func_dict, args.verbose, False, False)
 
 is_in_function = False
 is_in_function_start = False
Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -142,7 +142,7 @@
 UTC_ADVERT = 'NOTE: Assertions have been autogenerated by '
 
 OPT_FUNCTION_RE = re.compile(
-r'^\s*define\s+(?:internal\s+)?[^@]*@(?P[\w.-]+?)\s*'
+r'^(\s*;\s*Function\sAttrs:\s(?P[\w\s]+?))?\s*define\s+(?:internal\s+)?[^@]*@(?P[\w.-]+?)\s*'
 r'(?P\((\)|(.*?[\w.-]+?)\))[^{]*)\{\n(?P.*?)^\}$',
 flags=(re.M | re.S))
 
@@ -218,11 +218,12 @@
 
 # Build up a dictionary of all the function bodies.
 class function_body(object):
-  def __init__(self, string, extra, args_and_sig):
+  def __

[PATCH] D67833: [OpenMP 5.0] Codegen support to pass user-defined mapper functions to runtime

2020-07-19 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Seems that it already has been applied ;-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67833



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


[PATCH] D83261: [OPENMP]Redesign of OMPExecutableDirective representation.

2020-07-19 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

AFAICS this extract out the handling of subnodes of OMPExecutableDirectives 
into the OMPChildren class which is made optional since `OMPChildren 
*OMPExecutableDirectives::Data` can be nullptr. However, since it also stores 
clauses, it seems that about every executable directive will need to have one 
anyway. Hence I don't see how it makes the representation of some executable 
directives more correct.

OMPChildren also handles clauses for OMPExecutableDirectives but not for 
declarative directives. Should handling of of clauses also be extracted into 
into its own class? That would make (de-)serialization easier for those as well.

There is no effect on D76342  (except a 
requiring a rebase), since the OMPTileDirective has children and thus does not 
profit from the functionality of `OMPChildren` becoming optional. Since I don't 
see a relation to D76342 , more , I am 
indifferent to whether this should be merged.

Trailing objects is a technique to ensure that all substmts are consecutive in 
memory (so `StmtIterator` can iterator over them). For OMPExeuctableDirectives, 
only the associated statement is returned by the `StmtIterator`, i.e. all the 
children could be made regular class members without the complication of 
computing the offset. I'd prefer that change over OMPChildren.




Comment at: clang/include/clang/AST/StmtOpenMP.h:147
+
+  Stmt *getRawStmt() {
+assert(HasAssociatedStmt &&

This looks like the equivalent to `ignoreCaptures` from D76342. Could you 
document it what it does differently from 
IgnoreContainers/getCapturedStmt/getInnermostCapturedStmt/getBody/getStructuredBlock?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83261



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


[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-19 Thread Logan Smith via Phabricator via cfe-commits
logan-5 added a comment.

In D82728#2161152 , @xbolva00 wrote:

> Is it possible to emit fixit note with "override" ?


This is a good idea, though unfortunately (after eyeballing the implementation 
of `modernize-use-override` in clang-tidy (UseOverrideCheck.cpp)), it looks 
non-trivial to figure out where exactly to insert `override`. There's some 
significant logic in the clang-tidy check involving re-lexing the relevant 
tokens, to find the insertion point in the presence of complexity like inline 
definitions, `= 0`, `= {delete|default}`, function try blocks, macros, and the 
list goes on.

The clang-tidy check has this FIXME comment to address the complexity 
(UseOverrideCheck.cpp:136):

  // FIXME: Instead of re-lexing and looking for specific macros such as
  // 'ABSTRACT', properly store the location of 'virtual' and '= 0' in each
  // FunctionDecl.

If this was done, the resulting information would presumably simplify the 
clang-tidy check as well as make it easier to add a fixit to this warning. This 
sounds like an interesting problem, but also like a sizable refactor, and I 
won't be upset if someone beats me to it. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[PATCH] D82728: [clang] Add -Wsuggest-override

2020-07-19 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Is it possible to emit fixit note with "override" ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728



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


[clang] cf11050 - [Utils][Fix] remove unnecessary ; at the end

2020-07-19 Thread via cfe-commits

Author: sstefan1
Date: 2020-07-19T20:48:28+02:00
New Revision: cf1105069648446d58adfb7a6cc590013d6886ba

URL: 
https://github.com/llvm/llvm-project/commit/cf1105069648446d58adfb7a6cc590013d6886ba
DIFF: 
https://github.com/llvm/llvm-project/commit/cf1105069648446d58adfb7a6cc590013d6886ba.diff

LOG: [Utils][Fix] remove unnecessary ; at the end

Added: 


Modified: 

clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected
llvm/utils/UpdateTestChecks/common.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
index 8809b9070ae5..4862de910a95 100644
--- 
a/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
@@ -11,7 +11,7 @@ struct ST {
   struct RT Z;
 };
 
-// CHECK: Function Attrs: noinline nounwind optnone;
+// CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: @_Z3fooP2ST(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[S_ADDR:%.*]] = alloca %struct.ST*, align 8

diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected
 
b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected
index 5e5ab3ce4e68..be84e7824377 100644
--- 
a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected
+++ 
b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected
@@ -8,14 +8,14 @@
 %struct.ST = type { i32, double, %struct.RT }
 
 define i32* @foo(%struct.ST* %s) nounwind uwtable readnone optsize ssp {
-; IS__TUNIT: Function Attrs: nofree nosync nounwind optsize readnone ssp 
uwtable willreturn;
+; IS__TUNIT: Function Attrs: nofree nosync nounwind optsize readnone ssp 
uwtable willreturn
 ; IS__TUNIT-LABEL: define {{[^@]+}}@foo
 ; IS__TUNIT-SAME: (%struct.ST* nofree readnone [[S:%.*]]) #0
 ; IS__TUNIT-NEXT:  entry:
 ; IS__TUNIT-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds 
[[STRUCT_ST:%.*]], %struct.ST* [[S]], i64 1, i32 2, i32 1, i64 5, i64 13
 ; IS__TUNIT-NEXT:ret i32* [[ARRAYIDX]]
 ;
-; IS__CGSCC: Function Attrs: nofree norecurse nosync nounwind optsize 
readnone ssp uwtable willreturn;
+; IS__CGSCC: Function Attrs: nofree norecurse nosync nounwind optsize 
readnone ssp uwtable willreturn
 ; IS__CGSCC-LABEL: define {{[^@]+}}@foo
 ; IS__CGSCC-SAME: (%struct.ST* nofree readnone [[S:%.*]]) #0
 ; IS__CGSCC-NEXT:  entry:

diff  --git a/llvm/utils/UpdateTestChecks/common.py 
b/llvm/utils/UpdateTestChecks/common.py
index b964bf3e7e91..17f738601f61 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -391,7 +391,7 @@ def add_checks(output_lines, comment_marker, prefix_list, 
func_dict, func_name,
   attrs = str(func_dict[checkprefix][func_name].attrs)
   attrs = '' if attrs == 'None' else attrs
   if attrs:
-output_lines.append('%s %s: Function Attrs: %s;' % (comment_marker, 
checkprefix, attrs))
+output_lines.append('%s %s: Function Attrs: %s' % (comment_marker, 
checkprefix, attrs))
   args_and_sig = str(func_dict[checkprefix][func_name].args_and_sig)
   args_and_sig = genericize_check_lines([args_and_sig], is_analyze, 
vars_seen)[0]
   if '[[' in args_and_sig:



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


[PATCH] D83629: [Utils] Check function attributes in update_test_checks

2020-07-19 Thread Stefan Stipanovic via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG937bad3594e7: [Utils] Check function attributes in 
update_test_checks (authored by sstefan1).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D83629?vs=278295&id=279102#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83629

Files:
  clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp
  
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
  
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.plain.expected
  clang/test/utils/update_cc_test_checks/check_attrs.test
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.plain.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/check_attrs.test
  llvm/utils/UpdateTestChecks/asm.py
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_analyze_test_checks.py
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_test_checks.py

Index: llvm/utils/update_test_checks.py
===
--- llvm/utils/update_test_checks.py
+++ llvm/utils/update_test_checks.py
@@ -52,6 +52,8 @@
   help='Keep function signature information around for the check line')
   parser.add_argument('--scrub-attributes', action='store_true',
   help='Remove attribute annotations (#0) from the end of check line')
+  parser.add_argument('--check-attributes', action='store_true',
+  help='Check "Function Attributes" for functions')
   parser.add_argument('tests', nargs='+')
   initial_args = common.parse_commandline_args(parser)
 
@@ -111,7 +113,7 @@
   common.build_function_body_dictionary(
   common.OPT_FUNCTION_RE, common.scrub_body, [],
   raw_tool_output, prefixes, func_dict, ti.args.verbose,
-  ti.args.function_signature)
+  ti.args.function_signature, ti.args.check_attributes)
 
 is_in_function = False
 is_in_function_start = False
Index: llvm/utils/update_cc_test_checks.py
===
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -131,6 +131,8 @@
   help='Use more regex for x86 matching to reduce diffs between various subtargets')
   parser.add_argument('--function-signature', action='store_true',
   help='Keep function signature information around for the check line')
+  parser.add_argument('--check-attributes', action='store_true',
+  help='Check "Function Attributes" for functions')
   parser.add_argument('tests', nargs='+')
   args = common.parse_commandline_args(parser)
 
@@ -189,7 +191,7 @@
   if '-emit-llvm' in clang_args:
 common.build_function_body_dictionary(
 common.OPT_FUNCTION_RE, common.scrub_body, [],
-raw_tool_output, prefixes, func_dict, args.verbose, args.function_signature)
+raw_tool_output, prefixes, func_dict, args.verbose, args.function_signature, args.check_attributes)
   else:
 print('The clang command line should include -emit-llvm as asm tests '
   'are discouraged in Clang testsuite.', file=sys.stderr)
Index: llvm/utils/update_analyze_test_checks.py
===
--- llvm/utils/update_analyze_test_checks.py
+++ llvm/utils/update_analyze_test_checks.py
@@ -122,7 +122,7 @@
   for raw_tool_output in re.split(r'Printing analysis ', raw_tool_outputs):
 common.build_function_body_dictionary(
   common.ANALYZE_FUNCTION_RE, common.scrub_body, [],
-  raw_tool_output, prefixes, func_dict, args.verbose, False)
+  raw_tool_output, prefixes, func_dict, args.verbose, False, False)
 
 is_in_function = False
 is_in_function_start = False
Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -142,7 +142,7 @@
 UTC_ADVERT = 'NOTE: Assertions have been autogenerated by '
 
 OPT_FUNCTION_RE = re.compile(
-r'^\s*define\s+(?:internal\s+)?[^@]*@(?P[\w.-]+?)\s*'
+r'^(\s*;\s*Function\sAttrs:\s(?P[\w\s]+?))?\s*define\s+(?:internal\s+)?[^@]*@(?P[\w.-]+?)\s*'
 r'(?P\((\)|(.*?[\w.-]+?)\))[^{]*)\{\n(?P.*?)^\}$',
 flags=(re.M | re.S))
 
@@ -218,11 +218,12 @@
 
 # Build up a dictionary of all the function bodies.
 class function_body(object):
-  def __init__(self, string, extra, args_and_sig):
+  def __init__(self, string, extra, args_and_sig, attrs):
 self

[clang] 937bad3 - [Utils] Check function attributes in update_test_checks

2020-07-19 Thread via cfe-commits

Author: sstefan1
Date: 2020-07-19T20:07:24+02:00
New Revision: 937bad3594e7cba44cddae4661e1bae911beba3e

URL: 
https://github.com/llvm/llvm-project/commit/937bad3594e7cba44cddae4661e1bae911beba3e
DIFF: 
https://github.com/llvm/llvm-project/commit/937bad3594e7cba44cddae4661e1bae911beba3e.diff

LOG: [Utils] Check function attributes in update_test_checks

Summary:
This introduces new flag to the update_test_checks and
update_cc_test_checks that allows for function attributes
to be checked in a check-line. If the flag is not set,
the behavior should remain the same.

Reviewers: jdoerfert

Subscribers: arichardson, llvm-commits

Tags: #llvm

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

Added: 
clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp

clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected

clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.plain.expected
clang/test/utils/update_cc_test_checks/check_attrs.test
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.plain.expected
llvm/test/tools/UpdateTestChecks/update_test_checks/check_attrs.test

Modified: 
llvm/utils/UpdateTestChecks/asm.py
llvm/utils/UpdateTestChecks/common.py
llvm/utils/update_analyze_test_checks.py
llvm/utils/update_cc_test_checks.py
llvm/utils/update_test_checks.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp 
b/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp
new file mode 100644
index ..9a80ab603c7e
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+struct RT {
+  char A;
+  int B[10][20];
+  char C;
+};
+struct ST {
+  int X;
+  double Y;
+  struct RT Z;
+};
+
+int *foo(struct ST *s) {
+  return &s[1].Z.B[5][13];
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
new file mode 100644
index ..8809b9070ae5
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.funcattrs.expected
@@ -0,0 +1,29 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-attributes
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+struct RT {
+  char A;
+  int B[10][20];
+  char C;
+};
+struct ST {
+  int X;
+  double Y;
+  struct RT Z;
+};
+
+// CHECK: Function Attrs: noinline nounwind optnone;
+// CHECK-LABEL: @_Z3fooP2ST(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[S_ADDR:%.*]] = alloca %struct.ST*, align 8
+// CHECK-NEXT:store %struct.ST* [[S:%.*]], %struct.ST** [[S_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load %struct.ST*, %struct.ST** [[S_ADDR]], 
align 8
+// CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_ST:%.*]], 
%struct.ST* [[TMP0]], i64 1
+// CHECK-NEXT:[[Z:%.*]] = getelementptr inbounds [[STRUCT_ST]], 
%struct.ST* [[ARRAYIDX]], i32 0, i32 2
+// CHECK-NEXT:[[B:%.*]] = getelementptr inbounds [[STRUCT_RT:%.*]], 
%struct.RT* [[Z]], i32 0, i32 1
+// CHECK-NEXT:[[ARRAYIDX1:%.*]] = getelementptr inbounds [10 x [20 x 
i32]], [10 x [20 x i32]]* [[B]], i64 0, i64 5
+// CHECK-NEXT:[[ARRAYIDX2:%.*]] = getelementptr inbounds [20 x i32], [20 x 
i32]* [[ARRAYIDX1]], i64 0, i64 13
+// CHECK-NEXT:ret i32* [[ARRAYIDX2]]
+//
+int *foo(struct ST *s) {
+  return &s[1].Z.B[5][13];
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.plain.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.plain.expected
new file mode 100644
index ..46dd0f63e064
--- /dev/null
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/check-attributes.cpp.plain.expected
@@ -0,0 +1,28 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+struct RT {
+  char A;
+  int B[10][20];
+  char C;
+};
+struct ST {
+  int X;
+  double Y;
+  struct RT Z;
+};
+
+// CHECK-LABEL: @_Z3fooP2ST(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[S_ADDR:%.*]] = alloca %struct.ST*, align 8
+// CHECK-NEXT:store %struct.ST* [[S:%.*]], %struct.ST** [[S_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load %struct.ST*, %struct.ST** [[S_ADDR]], 
align 8
+// CHECK-NEXT:[[ARRAYIDX:%.*]] = getelementptr inbounds [[STRUCT_ST:%.*]], 
%struct.ST* [[TMP0]], i64 1
+// CHECK-NEXT:[[Z:%.*]] = ge

[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-07-19 Thread Logan Smith via Phabricator via cfe-commits
logan-5 added a comment.

Pinging this. I believe all feedback from @EricWF was addressed back in my 
update to the patch in March.


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

https://reviews.llvm.org/D72282



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


[clang] 13316a7 - [clang] Disable a few formatting options for test/

2020-07-19 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-07-19T17:07:24+01:00
New Revision: 13316a77053514be552a0dad932e3455413b4f82

URL: 
https://github.com/llvm/llvm-project/commit/13316a77053514be552a0dad932e3455413b4f82
DIFF: 
https://github.com/llvm/llvm-project/commit/13316a77053514be552a0dad932e3455413b4f82.diff

LOG: [clang] Disable a few formatting options for test/

Hopefully this will make the bot a little less noisy. Rationale for each:

AlignTrailingComments: We don't want to force-align the various expected-error
   and friends.

CommentPragmas:   Tell clang-format to leave the "// CHECK:" and the
  "// expected-" alone.

AlwaysBreakTemplateDeclarations: Templates in tests often have no break between
 the template-head and the declaration.

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

Added: 


Modified: 
clang/test/.clang-format

Removed: 




diff  --git a/clang/test/.clang-format b/clang/test/.clang-format
index 4799b66f3e9a..a6176c2e0013 100644
--- a/clang/test/.clang-format
+++ b/clang/test/.clang-format
@@ -1,2 +1,5 @@
 BasedOnStyle: LLVM
 ColumnLimit: 0
+AlignTrailingComments: false
+CommentPragmas: "(^ ?CHECK|^ ?expected-)"
+AlwaysBreakTemplateDeclarations: No



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


[PATCH] D83901: [clang] Disable a few formatting options for test/

2020-07-19 Thread Bruno Ricci via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG13316a770535: [clang] Disable a few formatting options for 
test/ (authored by riccibruno).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83901

Files:
  clang/test/.clang-format


Index: clang/test/.clang-format
===
--- clang/test/.clang-format
+++ clang/test/.clang-format
@@ -1,2 +1,5 @@
 BasedOnStyle: LLVM
 ColumnLimit: 0
+AlignTrailingComments: false
+CommentPragmas: "(^ ?CHECK|^ ?expected-)"
+AlwaysBreakTemplateDeclarations: No


Index: clang/test/.clang-format
===
--- clang/test/.clang-format
+++ clang/test/.clang-format
@@ -1,2 +1,5 @@
 BasedOnStyle: LLVM
 ColumnLimit: 0
+AlignTrailingComments: false
+CommentPragmas: "(^ ?CHECK|^ ?expected-)"
+AlwaysBreakTemplateDeclarations: No
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 89ff9bf - [clang] Fix the warning for a non-void consteval function without a return value to actually say "consteval".

2020-07-19 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-07-19T17:08:17+01:00
New Revision: 89ff9bf061b4985d11cd4785958d8f8156d10f5d

URL: 
https://github.com/llvm/llvm-project/commit/89ff9bf061b4985d11cd4785958d8f8156d10f5d
DIFF: 
https://github.com/llvm/llvm-project/commit/89ff9bf061b4985d11cd4785958d8f8156d10f5d.diff

LOG: [clang] Fix the warning for a non-void consteval function without a return 
value to actually say "consteval".

This warning was modified in 796ed03b8412 to use the term "consteval"
for consteval functions. However the warning has never worked as
intended since the diagnostic's arguments are used in the wrong order.

This was unfortunately missed by 796ed03b8412 since no test did exercise
this specific warning.

Additionally send the NamedDecl* into the diagnostic instead of just the
IdentifierInfo* to correctly work with special names and template
arguments.

Added: 


Modified: 
clang/lib/Sema/SemaStmt.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/consteval-return-void.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 73f3183c163f..948c187804dc 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3766,25 +3766,26 @@ StmtResult Sema::BuildReturnStmt(SourceLocation 
ReturnLoc, Expr *RetValExp) {
   } else if (!RetValExp && !HasDependentReturnType) {
 FunctionDecl *FD = getCurFunctionDecl();
 
-unsigned DiagID;
 if (getLangOpts().CPlusPlus11 && FD && FD->isConstexpr()) {
   // C++11 [stmt.return]p2
-  DiagID = diag::err_constexpr_return_missing_expr;
+  Diag(ReturnLoc, diag::err_constexpr_return_missing_expr)
+  << FD << FD->isConsteval();
   FD->setInvalidDecl();
-} else if (getLangOpts().C99) {
-  // C99 6.8.6.4p1 (ext_ since GCC warns)
-  DiagID = diag::ext_return_missing_expr;
 } else {
+  // C99 6.8.6.4p1 (ext_ since GCC warns)
   // C90 6.6.6.4p4
-  DiagID = diag::warn_return_missing_expr;
+  unsigned DiagID = getLangOpts().C99 ? diag::ext_return_missing_expr
+  : diag::warn_return_missing_expr;
+  // Note that at this point one of getCurFunctionDecl() or
+  // getCurMethodDecl() must be non-null (see above).
+  assert((getCurFunctionDecl() || getCurMethodDecl()) &&
+ "Not in a FunctionDecl or ObjCMethodDecl?");
+  bool IsMethod = FD == nullptr;
+  const NamedDecl *ND =
+  IsMethod ? cast(getCurMethodDecl()) : cast(FD);
+  Diag(ReturnLoc, DiagID) << ND << IsMethod;
 }
 
-if (FD)
-  Diag(ReturnLoc, DiagID)
-  << FD->getIdentifier() << 0 /*fn*/ << FD->isConsteval();
-else
-  Diag(ReturnLoc, DiagID) << getCurMethodDecl()->getDeclName() << 
1/*meth*/;
-
 Result = ReturnStmt::Create(Context, ReturnLoc, /* RetExpr=*/nullptr,
 /* NRVOCandidate=*/nullptr);
   } else {

diff  --git a/clang/test/SemaCXX/constant-expression-cxx11.cpp 
b/clang/test/SemaCXX/constant-expression-cxx11.cpp
index 7ff260c37c69..eac0256c4fb2 100644
--- a/clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -2171,7 +2171,7 @@ namespace PR21859 {
   template  constexpr int FunT1() { return; } // expected-error 
{{non-void constexpr function 'FunT1' should return a value}}
   template  constexpr int FunT2() { return 0; }
   template <> constexpr int FunT2() { return 0; }
-  template <> constexpr int FunT2() { return; } // expected-error 
{{non-void constexpr function 'FunT2' should return a value}}
+  template <> constexpr int FunT2() { return; } // expected-error 
{{non-void constexpr function 'FunT2' should return a value}}
 }
 
 struct InvalidRedef {

diff  --git a/clang/test/SemaCXX/consteval-return-void.cpp 
b/clang/test/SemaCXX/consteval-return-void.cpp
index a5207f41bf2c..39e1418306f5 100644
--- a/clang/test/SemaCXX/consteval-return-void.cpp
+++ b/clang/test/SemaCXX/consteval-return-void.cpp
@@ -1,10 +1,20 @@
 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
 
-consteval int Fun() { return; } // expected-error {{non-void constexpr 
function 'Fun' should return a value}}
+consteval int Fun() { return; } // expected-error {{non-void consteval 
function 'Fun' should return a value}}
 
-// FIXME: The diagnostic is wrong; should be "consteval".
-
-template  consteval int FunT1() { return; } // expected-error 
{{non-void constexpr function 'FunT1' should return a value}}
+template  consteval int FunT1() { return; } // expected-error 
{{non-void consteval function 'FunT1' should return a value}}
 template  consteval int FunT2() { return 0; }
 template <> consteval int FunT2() { return 0; }
-template <> consteval int FunT2() { return; } // expected-error 
{{non-void constexpr function 'FunT2' should return a value}}
+template <> consteval int FunT2() { return; } // expected-err

[PATCH] D80514: [clang-tidy] modernize-use-trailing-return-type support for C++20 concepts and decltype

2020-07-19 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber updated this revision to Diff 279088.
bernhardmgruber marked 3 inline comments as done.
bernhardmgruber added a comment.

- Added two more tests with a macro supplied on the command line
- Rebased onto master


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

https://reviews.llvm.org/D80514

Files:
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/modernize-use-trailing-return-type.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type-cxx20.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++14,c++17 %s modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions
+// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions -DCOMMAND_LINE_INT=int
 // FIXME: Fix the checker to work in C++20 mode, it is performing a
 // use-of-uninitialized-value.
 
@@ -11,6 +11,8 @@
 
 class string;
 
+class ostream;
+
 template 
 auto declval() -> T;
 }
@@ -215,18 +217,28 @@
 // CHECK-FIXES: {{^}}auto e13() -> struct A;{{$}}
 
 //
-// decltype (unsupported if top level expression)
+// deduced return types
 //
 
+const auto ded1();
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto ded1() -> const auto;{{$}}
+const auto& ded2();
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto ded2() -> const auto&;{{$}}
+
+decltype(auto) ded3();
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto ded3() -> decltype(auto);{{$}}
+
+
 decltype(1 + 2) dec1() { return 1 + 2; }
 // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// TODO: source range of DecltypeTypeLoc not yet implemented
-// _HECK-FIXES: {{^}}auto dec1() -> decltype(1 + 2) { return 1 + 2; }{{$}}
+// CHECK-FIXES: {{^}}auto dec1() -> decltype(1 + 2) { return 1 + 2; }{{$}}
 template 
 decltype(std::declval(std::declval)) dec2(F f, T t) { return f(t); }
 // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// TODO: source range of DecltypeTypeLoc not yet implemented
-// _HECK-FIXES: {{^}}auto dec2(F f, T t) -> decltype(std::declval(std::declval)) { return f(t); }{{$}}
+// CHECK-FIXES: {{^}}auto dec2(F f, T t) -> decltype(std::declval(std::declval)) { return f(t); }{{$}}
 template 
 typename decltype(std::declval())::value_type dec3();
 // CHECK-MESSAGES: :[[@LINE-1]]:50: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
@@ -463,6 +475,13 @@
 CONST_F_MACRO int& h19();
 // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
 // CHECK-FIXES: {{^}}auto h19() -> CONST_F_MACRO int&;{{$}}
+// Macro COMMAND_LINE_INT is defined on the command line via: -DCOMMAND_LINE_INT=int
+const COMMAND_LINE_INT& h20();
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto h20() -> const COMMAND_LINE_INT&;{{$}}
+decltype(COMMAND_LINE_INT{}) h21();
+// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}auto h21() -> decltype(COMMAND_LINE_INT{});{{$}}
 
 //
 // Name collisions
@@ -531,6 +550,14 @@
 return {0};
 }
 
+//
+// bug 44206, no rewrite should happen due to collision with parameter name
+//
+
+using std::ostream;
+ostream& operator<<(ostream& ostream, int i);
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
+// CHECK-FIXES: {{^}}ostream& operator<<(ostream& ostream, int i);{{$}}
 
 //
 // Samples which do not trigger the check
@@ -544,7 +571,6 @@
 template  auto f(T t) -> int;
 
 auto ff();
-decltype(auto) fff();
 
 void c();
 void c(int arg);
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type-cxx20.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-u

[clang-tools-extra] 9791416 - Silence a "logical operation on address of string constant" via CMake instead.

2020-07-19 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-07-19T11:19:48-04:00
New Revision: 97914164f8454e745219566d58479b5762cccd51

URL: 
https://github.com/llvm/llvm-project/commit/97914164f8454e745219566d58479b5762cccd51
DIFF: 
https://github.com/llvm/llvm-project/commit/97914164f8454e745219566d58479b5762cccd51.diff

LOG: Silence a "logical operation on address of string constant" via CMake 
instead.

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index b3002b1d5698..8db6656e5291 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -28,6 +28,10 @@ set(LLVM_LINK_COMPONENTS
   Option
   )
 
+if(MSVC AND NOT CLANG_CL)
+ set_source_files_properties(CompileCommands.cpp PROPERTIES COMPILE_FLAGS 
-wd4130) # disables C4130: logical operation on address of string constant
+endif()
+
 add_clang_library(clangDaemon
   AST.cpp
   ClangdLSPServer.cpp



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


[clang-tools-extra] b79ca34 - Revert 7dfff42f019583076c55993d30a63889613922dd as it broke non-Windows builds.

2020-07-19 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-07-19T11:12:39-04:00
New Revision: b79ca34530e88c3a13a9c7afb1df42d7a622e3dd

URL: 
https://github.com/llvm/llvm-project/commit/b79ca34530e88c3a13a9c7afb1df42d7a622e3dd
DIFF: 
https://github.com/llvm/llvm-project/commit/b79ca34530e88c3a13a9c7afb1df42d7a622e3dd.diff

LOG: Revert 7dfff42f019583076c55993d30a63889613922dd as it broke non-Windows 
builds.

Added: 


Modified: 
clang-tools-extra/clangd/CompileCommands.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index 6df29bd82319..f6210a43b34e 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -354,7 +354,7 @@ llvm::ArrayRef 
ArgStripper::rulesFor(llvm::StringRef Arg) {
 #define PREFIX(NAME, VALUE) static const char *const NAME[] = VALUE;
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  
\
HELP, METAVAR, VALUES)  
\
-  if (DriverID::OPT_##ALIAS != DriverID::OPT_INVALID && !ALIASARGS)
\
+  if (DriverID::OPT_##ALIAS != DriverID::OPT_INVALID && ALIASARGS == nullptr)  
\
 AddAlias(DriverID::OPT_##ID, DriverID::OPT_##ALIAS);   
\
   Prefixes[DriverID::OPT_##ID] = PREFIX;
 #include "clang/Driver/Options.inc"



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


[clang-tools-extra] 7dfff42 - Silencing some 'logical operation on address of string constant diagnostics; NFC

2020-07-19 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-07-19T10:53:51-04:00
New Revision: 7dfff42f019583076c55993d30a63889613922dd

URL: 
https://github.com/llvm/llvm-project/commit/7dfff42f019583076c55993d30a63889613922dd
DIFF: 
https://github.com/llvm/llvm-project/commit/7dfff42f019583076c55993d30a63889613922dd.diff

LOG: Silencing some 'logical operation on address of string constant 
diagnostics; NFC

Added: 


Modified: 
clang-tools-extra/clangd/CompileCommands.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index f6210a43b34e..6df29bd82319 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -354,7 +354,7 @@ llvm::ArrayRef 
ArgStripper::rulesFor(llvm::StringRef Arg) {
 #define PREFIX(NAME, VALUE) static const char *const NAME[] = VALUE;
 #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  
\
HELP, METAVAR, VALUES)  
\
-  if (DriverID::OPT_##ALIAS != DriverID::OPT_INVALID && ALIASARGS == nullptr)  
\
+  if (DriverID::OPT_##ALIAS != DriverID::OPT_INVALID && !ALIASARGS)
\
 AddAlias(DriverID::OPT_##ID, DriverID::OPT_##ALIAS);   
\
   Prefixes[DriverID::OPT_##ID] = PREFIX;
 #include "clang/Driver/Options.inc"



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


[PATCH] D83645: Bump the default target CPU for i386-freebsd to i686

2020-07-19 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

In D83645#2160761 , @MaskRay wrote:

> @dim
>
> Hi, your git commit contains extra Phabricator tags. You can drop 
> `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` from the git 
> commit with the following script:
>
>   arcfilter () {
>   arc amend
>   git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
> /Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ 
> {sub(/^Summary: /,"");print}' | git commit --amend --date=now -F -
>   }
>   
>
> `Reviewed By: ` is considered important by some people. Please keep the tag. 
> (`--date=now` is my personal preference (author dates are usually not useful. 
> Using committer dates can make log almost monotonic in time))
>
> `llvm/utils/git/pre-push.py` can validate the message does not include 
> unneeded tags.


Hm, I think I just used `arc land` to land this revision. Does arc not do all 
that stuff? In any case, I can't change the commit message after it's been 
pushed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83645



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


[PATCH] D84090: [clang-format] Add SpaceAroundBitFieldColon option

2020-07-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Let’s do all 4, None, Both, Left, Right

Neither is an odd word for non English speakers

Also I before e can confuse the slightly  dyslexic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84090



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