[PATCH] D58404: [clang-format] Add basic support for formatting C# files

2019-02-25 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 188239.
MyDeveloperDay added a subscriber: llvm-commits.
MyDeveloperDay added a comment.

Fix a crash running clang-format over large C# code base
Add support for C# Null Coalescing


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

https://reviews.llvm.org/D58404

Files:
  docs/ClangFormat.rst
  docs/ClangFormatStyleOptions.rst
  docs/ReleaseNotes.rst
  include/clang/Basic/LangOptions.def
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TokenKinds.h
  include/clang/Format/Format.h
  lib/Format/ContinuationIndenter.cpp
  lib/Format/Format.cpp
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  lib/Format/FormatTokenLexer.h
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineParser.cpp
  lib/Lex/Lexer.cpp
  lib/Lex/LiteralSupport.cpp
  lib/Lex/TokenConcatenation.cpp
  tools/clang-format/ClangFormat.cpp
  unittests/Format/CMakeLists.txt
  unittests/Format/FormatTestCSharp.cpp

Index: unittests/Format/FormatTestCSharp.cpp
===
--- /dev/null
+++ unittests/Format/FormatTestCSharp.cpp
@@ -0,0 +1,176 @@
+//===- unittest/Format/FormatTestCSharp.cpp - Formatting tests for CSharp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "FormatTestUtils.h"
+#include "clang/Format/Format.h"
+#include "llvm/Support/Debug.h"
+#include "gtest/gtest.h"
+
+#define DEBUG_TYPE "format-test"
+
+namespace clang {
+namespace format {
+
+class FormatTestCSharp : public ::testing::Test {
+protected:
+  static std::string format(llvm::StringRef Code, unsigned Offset,
+unsigned Length, const FormatStyle &Style) {
+LLVM_DEBUG(llvm::errs() << "---\n");
+LLVM_DEBUG(llvm::errs() << Code << "\n\n");
+std::vector Ranges(1, tooling::Range(Offset, Length));
+tooling::Replacements Replaces = reformat(Style, Code, Ranges);
+auto Result = applyAllReplacements(Code, Replaces);
+EXPECT_TRUE(static_cast(Result));
+LLVM_DEBUG(llvm::errs() << "\n" << *Result << "\n\n");
+return *Result;
+  }
+
+  static std::string
+  format(llvm::StringRef Code,
+ const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_CSharp)) {
+return format(Code, 0, Code.size(), Style);
+  }
+
+  static FormatStyle getStyleWithColumns(unsigned ColumnLimit) {
+FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
+Style.ColumnLimit = ColumnLimit;
+return Style;
+  }
+
+  static void verifyFormat(
+  llvm::StringRef Code,
+  const FormatStyle &Style = getGoogleStyle(FormatStyle::LK_CSharp)) {
+EXPECT_EQ(Code.str(), format(Code, Style)) << "Expected code is not stable";
+EXPECT_EQ(Code.str(), format(test::messUp(Code), Style));
+  }
+};
+
+TEST_F(FormatTestCSharp, CSharpClass) {
+  verifyFormat("public class SomeClass {\n"
+   "  void f() {}\n"
+   "  int g() { return 0; }\n"
+   "  void h() {\n"
+   "while (true) f();\n"
+   "for (;;) f();\n"
+   "if (true) f();\n"
+   "  }\n"
+   "}");
+}
+
+TEST_F(FormatTestCSharp, AccessModifiers) {
+  verifyFormat("public String toString() {}");
+  verifyFormat("private String toString() {}");
+  verifyFormat("protected String toString() {}");
+  verifyFormat("internal String toString() {}");
+
+  verifyFormat("public override String toString() {}");
+  verifyFormat("private override String toString() {}");
+  verifyFormat("protected override String toString() {}");
+  verifyFormat("internal override String toString() {}");
+
+  verifyFormat("internal static String toString() {}");
+}
+
+TEST_F(FormatTestCSharp, NoStringLiteralBreaks) {
+  verifyFormat("foo("
+   "\"a"
+   "aa\");");
+}
+
+TEST_F(FormatTestCSharp, CSharpVerbatiumStringLiterals) {
+  verifyFormat("foo(@\"\\abc\\\");");
+  // @"ABC\" + ToString("B") - handle embedded \ in literal string at
+  // the end
+  verifyFormat("string s = @\"ABC\\\" + ToString(\"B\");");
+}
+
+TEST_F(FormatTestCSharp, CSharpInterpolatedStringLiterals) {
+  verifyFormat("foo($\"{aaa}\");");
+  verifyFormat("foo($\"{A}\");");
+  verifyFormat(
+  "foo($\"{A}"
+  "a\");");
+  verifyFormat("Name = $\"{firstName} {lastName}\";");
+
+  // $"ABC\" + ToString("B") - handle embedded \ in literal string at
+  // the end
+  verifyFormat("string s = $\"A{abc}BC\" + ToString(\"B\");");
+  verifyFormat("$\"{domain}{user}\"");
+  verifyFormat(
+  "var verbatimInterpolated 

r354817 - [OpenMP 5.0] Parsing/sema support for from clause with mapper modifier.

2019-02-25 Thread Michael Kruse via cfe-commits
Author: meinersbur
Date: Mon Feb 25 12:34:15 2019
New Revision: 354817

URL: http://llvm.org/viewvc/llvm-project?rev=354817&view=rev
Log:
[OpenMP 5.0] Parsing/sema support for from clause with mapper modifier.

This patch implements the parsing and sema support for the OpenMP
'from'-clause with potential user-defined mappers attached.
User-defined mappers are a new feature in OpenMP 5.0. A 'from'-clause
can have an explicit or implicit associated mapper, which instructs the
compiler to generate and use customized mapping functions. An example is
shown below:

struct S { int len; int *d; };
#pragma omp declare mapper(id: struct S s) map(s, s.d[0:s.len])
struct S ss;
#pragma omp target update from(mapper(id): ss) // use the mapper with name 
'id' to map ss from device

Contributed-by: Lingda Li 

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

Modified:
cfe/trunk/include/clang/AST/OpenMPClause.h
cfe/trunk/include/clang/Basic/OpenMPKinds.def
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/OpenMPClause.cpp
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Parse/ParseOpenMP.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/test/OpenMP/declare_mapper_ast_print.c
cfe/trunk/test/OpenMP/declare_mapper_ast_print.cpp
cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp
cfe/trunk/test/OpenMP/declare_mapper_messages.c
cfe/trunk/test/OpenMP/declare_mapper_messages.cpp

Modified: cfe/trunk/include/clang/AST/OpenMPClause.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenMPClause.h?rev=354817&r1=354816&r2=354817&view=diff
==
--- cfe/trunk/include/clang/AST/OpenMPClause.h (original)
+++ cfe/trunk/include/clang/AST/OpenMPClause.h Mon Feb 25 12:34:15 2019
@@ -5082,6 +5082,9 @@ class OMPFromClause final
 
   /// Build clause with number of variables \a NumVars.
   ///
+  /// \param MapperQualifierLoc C++ nested name specifier for the associated
+  /// user-defined mapper.
+  /// \param MapperIdInfo The identifier of associated user-defined mapper.
   /// \param Locs Locations needed to build a mappable clause. It includes 1)
   /// StartLoc: starting location of the clause (the clause keyword); 2)
   /// LParenLoc: location of '('; 3) EndLoc: ending location of the clause.
@@ -5090,9 +5093,12 @@ class OMPFromClause final
   /// NumUniqueDeclarations: number of unique base declarations in this clause;
   /// 3) NumComponentLists: number of component lists in this clause; and 4)
   /// NumComponents: total number of expression components in the clause.
-  explicit OMPFromClause(const OMPVarListLocTy &Locs,
+  explicit OMPFromClause(NestedNameSpecifierLoc MapperQualifierLoc,
+ DeclarationNameInfo MapperIdInfo,
+ const OMPVarListLocTy &Locs,
  const OMPMappableExprListSizeTy &Sizes)
-  : OMPMappableExprListClause(OMPC_from, Locs, Sizes) {}
+  : OMPMappableExprListClause(OMPC_from, Locs, Sizes, &MapperQualifierLoc,
+  &MapperIdInfo) {}
 
   /// Build an empty clause.
   ///
@@ -5107,7 +5113,9 @@ class OMPFromClause final
   /// Define the sizes of each trailing object array except the last one. This
   /// is required for TrailingObjects to work properly.
   size_t numTrailingObjects(OverloadToken) const {
-return varlist_size();
+// There are varlist_size() of expressions, and varlist_size() of
+// user-defined mappers.
+return 2 * varlist_size();
   }
   size_t numTrailingObjects(OverloadToken) const {
 return getUniqueDeclarationsNum();
@@ -5126,10 +5134,18 @@ public:
   /// \param Vars The original expression used in the clause.
   /// \param Declarations Declarations used in the clause.
   /// \param ComponentLists Component lists used in the clause.
+  /// \param UDMapperRefs References to user-defined mappers associated with
+  /// expressions used in the clause.
+  /// \param UDMQualifierLoc C++ nested name specifier for the associated
+  /// user-defined mapper.
+  /// \param MapperId The identifier of associated user-defined mapper.
   static OMPFromClause *Create(const ASTContext &C, const OMPVarListLocTy 
&Locs,
ArrayRef Vars,
ArrayRef Declarations,
-   MappableExprComponentListsRef ComponentLists);
+   MappableExprComponentListsRef ComponentLists,
+   ArrayRef UDMapperRefs,
+   NestedNameSpecifierLoc UDMQualifierLoc,
+   DeclarationNameInfo MapperId);
 
   /// Creates an empty clause with the place for \a NumVars variables.
   ///

Modified: c

[PATCH] D58638: [OpenMP 5.0] Parsing/sema support for from clause with mapper modifier

2019-02-25 Thread Michael Kruse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354817: [OpenMP 5.0] Parsing/sema support for from clause 
with mapper modifier. (authored by Meinersbur, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58638?vs=188215&id=188241#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58638

Files:
  cfe/trunk/include/clang/AST/OpenMPClause.h
  cfe/trunk/include/clang/Basic/OpenMPKinds.def
  cfe/trunk/include/clang/Basic/OpenMPKinds.h
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/AST/OpenMPClause.cpp
  cfe/trunk/lib/Basic/OpenMPKinds.cpp
  cfe/trunk/lib/Parse/ParseOpenMP.cpp
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/lib/Sema/TreeTransform.h
  cfe/trunk/lib/Serialization/ASTReader.cpp
  cfe/trunk/lib/Serialization/ASTWriter.cpp
  cfe/trunk/test/OpenMP/declare_mapper_ast_print.c
  cfe/trunk/test/OpenMP/declare_mapper_ast_print.cpp
  cfe/trunk/test/OpenMP/declare_mapper_codegen.cpp
  cfe/trunk/test/OpenMP/declare_mapper_messages.c
  cfe/trunk/test/OpenMP/declare_mapper_messages.cpp

Index: cfe/trunk/lib/Basic/OpenMPKinds.cpp
===
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp
@@ -122,6 +122,12 @@
   .Case(#Name, static_cast(OMPC_TO_MODIFIER_##Name))
 #include "clang/Basic/OpenMPKinds.def"
 .Default(OMPC_TO_MODIFIER_unknown);
+  case OMPC_from:
+return llvm::StringSwitch(Str)
+#define OPENMP_FROM_MODIFIER_KIND(Name) \
+  .Case(#Name, static_cast(OMPC_FROM_MODIFIER_##Name))
+#include "clang/Basic/OpenMPKinds.def"
+.Default(OMPC_FROM_MODIFIER_unknown);
   case OMPC_dist_schedule:
 return llvm::StringSwitch(Str)
 #define OPENMP_DIST_SCHEDULE_KIND(Name) .Case(#Name, OMPC_DIST_SCHEDULE_##Name)
@@ -180,7 +186,6 @@
   case OMPC_num_tasks:
   case OMPC_hint:
   case OMPC_uniform:
-  case OMPC_from:
   case OMPC_use_device_ptr:
   case OMPC_is_device_ptr:
   case OMPC_unified_address:
@@ -277,6 +282,18 @@
   break;
 }
 llvm_unreachable("Invalid OpenMP 'to' clause type");
+  case OMPC_from:
+switch (Type) {
+case OMPC_FROM_MODIFIER_unknown:
+  return "unknown";
+#define OPENMP_FROM_MODIFIER_KIND(Name)\
+  case OMPC_FROM_MODIFIER_##Name:  \
+return #Name;
+#include "clang/Basic/OpenMPKinds.def"
+default:
+  break;
+}
+llvm_unreachable("Invalid OpenMP 'from' clause type");
   case OMPC_dist_schedule:
 switch (Type) {
 case OMPC_DIST_SCHEDULE_unknown:
@@ -350,7 +367,6 @@
   case OMPC_num_tasks:
   case OMPC_hint:
   case OMPC_uniform:
-  case OMPC_from:
   case OMPC_use_device_ptr:
   case OMPC_is_device_ptr:
   case OMPC_unified_address:
Index: cfe/trunk/lib/Serialization/ASTReader.cpp
===
--- cfe/trunk/lib/Serialization/ASTReader.cpp
+++ cfe/trunk/lib/Serialization/ASTReader.cpp
@@ -12448,6 +12448,10 @@
 
 void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) {
   C->setLParenLoc(Record.readSourceLocation());
+  C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
+  DeclarationNameInfo DNI;
+  Record.readDeclarationNameInfo(DNI);
+  C->setMapperIdInfo(DNI);
   auto NumVars = C->varlist_size();
   auto UniqueDecls = C->getUniqueDeclarationsNum();
   auto TotalLists = C->getTotalComponentListNum();
@@ -12459,6 +12463,12 @@
 Vars.push_back(Record.readSubExpr());
   C->setVarRefs(Vars);
 
+  SmallVector UDMappers;
+  UDMappers.reserve(NumVars);
+  for (unsigned I = 0; I < NumVars; ++I)
+UDMappers.push_back(Record.readSubExpr());
+  C->setUDMapperRefs(UDMappers);
+
   SmallVector Decls;
   Decls.reserve(UniqueDecls);
   for (unsigned i = 0; i < UniqueDecls; ++i)
Index: cfe/trunk/lib/Serialization/ASTWriter.cpp
===
--- cfe/trunk/lib/Serialization/ASTWriter.cpp
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp
@@ -6885,8 +6885,12 @@
   Record.push_back(C->getTotalComponentListNum());
   Record.push_back(C->getTotalComponentsNum());
   Record.AddSourceLocation(C->getLParenLoc());
+  Record.AddNestedNameSpecifierLoc(C->getMapperQualifierLoc());
+  Record.AddDeclarationNameInfo(C->getMapperIdInfo());
   for (auto *E : C->varlists())
 Record.AddStmt(E);
+  for (auto *E : C->mapperlists())
+Record.AddStmt(E);
   for (auto *D : C->all_decls())
 Record.AddDeclRef(D);
   for (auto N : C->all_num_lists())
Index: cfe/trunk/lib/Parse/ParseOpenMP.cpp
===
--- cfe/trunk/lib/Parse/ParseOpenMP.cpp
+++ cfe/trunk/lib/Parse/ParseOpenMP.cpp
@@ -2161,13 +2161,20 @@
 
 if (Tok.is(tok::colon))
   Data.ColonLoc = ConsumeToken()

[PATCH] D58091: Customize warnings for missing built-in type

2019-02-25 Thread Brian Cain via Phabricator via cfe-commits
bcain added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:592
+: Warning<"declaration of built-in function '%0' requires the declaration"
+" of the 'jmp_buf' type, commonly proived in the header .">,
+  InGroup>;

"proived" should be "provided", I think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58091



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


r354823 - [libclang] Fix a trivial error introduced in D57946.

2019-02-25 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Mon Feb 25 13:15:34 2019
New Revision: 354823

URL: http://llvm.org/viewvc/llvm-project?rev=354823&view=rev
Log:
[libclang] Fix a trivial error introduced in D57946.

The value for CXCursor_ConvergentAttr is not 420. I'm not really sure how easy
it is to test this, and I'm not familiar with the python bindings, just noticed
the error while looking at D57946 to write D58570.

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=354823&r1=354822&r2=354823&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon Feb 25 13:15:34 2019
@@ -1342,7 +1342,7 @@ CursorKind.VISIBILITY_ATTR = CursorKind(
 
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
-CursorKind.CONVERGENT_ATTR = CursorKind(420)
+CursorKind.CONVERGENT_ATTR = CursorKind(438)
 
 ###
 # Preprocessing


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


[PATCH] D58571: [libclang] Fix a trivial error introduced in D57946.

2019-02-25 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354823: [libclang] Fix a trivial error introduced in D57946. 
(authored by emilio, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58571?vs=188027&id=188249#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58571

Files:
  cfe/trunk/bindings/python/clang/cindex.py


Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -1342,7 +1342,7 @@
 
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
-CursorKind.CONVERGENT_ATTR = CursorKind(420)
+CursorKind.CONVERGENT_ATTR = CursorKind(438)
 
 ###
 # Preprocessing


Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -1342,7 +1342,7 @@
 
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
-CursorKind.CONVERGENT_ATTR = CursorKind(420)
+CursorKind.CONVERGENT_ATTR = CursorKind(438)
 
 ###
 # Preprocessing
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r354824 - [libclang] Expose warn_unused and warn_unused_result attributes.

2019-02-25 Thread Emilio Cobos Alvarez via cfe-commits
Author: emilio
Date: Mon Feb 25 13:24:52 2019
New Revision: 354824

URL: http://llvm.org/viewvc/llvm-project?rev=354824&view=rev
Log:
[libclang] Expose warn_unused and warn_unused_result attributes.

This is helpful to properly detect them, and fixing issues like
https://github.com/rust-lang/rust-bindgen/issues/1518.

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/attributes.c
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=354824&r1=354823&r2=354824&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Mon Feb 25 13:24:52 2019
@@ -1343,6 +1343,8 @@ CursorKind.VISIBILITY_ATTR = CursorKind(
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
 CursorKind.CONVERGENT_ATTR = CursorKind(438)
+CursorKind.WARN_UNUSED_ATTR = CursorKind(439)
+CursorKind.WARN_UNUSED_RESULT_ATTR = CursorKind(440)
 
 ###
 # Preprocessing

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=354824&r1=354823&r2=354824&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Mon Feb 25 13:24:52 2019
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 51
+#define CINDEX_VERSION_MINOR 52
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -2587,7 +2587,9 @@ enum CXCursorKind {
   CXCursor_ObjCBoxable   = 436,
   CXCursor_FlagEnum  = 437,
   CXCursor_ConvergentAttr= 438,
-  CXCursor_LastAttr  = CXCursor_ConvergentAttr,
+  CXCursor_WarnUnusedAttr= 439,
+  CXCursor_WarnUnusedResultAttr  = 440,
+  CXCursor_LastAttr  = CXCursor_WarnUnusedResultAttr,
 
   /* Preprocessing */
   CXCursor_PreprocessingDirective= 500,

Modified: cfe/trunk/test/Index/attributes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/attributes.c?rev=354824&r1=354823&r2=354824&view=diff
==
--- cfe/trunk/test/Index/attributes.c (original)
+++ cfe/trunk/test/Index/attributes.c Mon Feb 25 13:24:52 2019
@@ -14,6 +14,12 @@ enum __attribute((flag_enum)) FlagEnum {
 
 void convergent_fn() __attribute__((convergent));
 
+int warn_unused_result_fn() __attribute__((warn_unused_result));
+
+struct __attribute__((warn_unused)) WarnUnused {
+  int b;
+};
+
 // CHECK: attributes.c:3:32: StructDecl=Test2:3:32 (Definition) Extent=[3:1 - 
5:2]
 // CHECK: attributes.c:3:23: attribute(packed)=packed Extent=[3:23 - 3:29]
 // CHECK: attributes.c:4:8: FieldDecl=a:4:8 (Definition) Extent=[4:3 - 4:9] 
[access=public]
@@ -29,3 +35,7 @@ void convergent_fn() __attribute__((conv
 // CHECK: attributes.c:12:3: EnumConstantDecl=Foo:12:3 (Definition) 
Extent=[12:3 - 12:6]
 // CHECK: attributes.c:15:6: FunctionDecl=convergent_fn:15:6 Extent=[15:1 - 
15:49]
 // CHECK: attributes.c:15:37: attribute(convergent)= Extent=[15:37 - 15:47]
+// CHECK: attributes.c:17:5: FunctionDecl=warn_unused_result_fn:17:5 
Extent=[17:1 - 17:64]
+// CHECK: attributes.c:17:44: attribute(warn_unused_result)= Extent=[17:44 - 
17:62]
+// CHECK: attributes.c:19:37: StructDecl=WarnUnused:19:37 (Definition) 
Extent=[19:1 - 21:2]
+// CHECK: attributes.c:19:23: attribute(warn_unused)= Extent=[19:23 - 19:34]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=354824&r1=354823&r2=354824&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Mon Feb 25 13:24:52 2019
@@ -5477,6 +5477,10 @@ CXString clang_getCursorKindSpelling(enu
   return cxstring::createRef("FriendDecl");
   case CXCursor_ConvergentAttr:
   return cxstring::createRef("attribute(convergent)");
+  case CXCursor_WarnUnusedAttr:
+  return cxstring::createRef("attribute(warn_unused)");
+  case CXCursor_WarnUnusedResultAttr:
+  return cxstring::createRef("attribute(warn_unused_result)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=354824&r1=354823&r2=354824&view=diff
=

[PATCH] D58570: [libclang] Expose warn_unused and warn_unused_result attributes.

2019-02-25 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354824: [libclang] Expose warn_unused and warn_unused_result 
attributes. (authored by emilio, committed by ).
Herald added a reviewer: serge-sans-paille.

Changed prior to commit:
  https://reviews.llvm.org/D58570?vs=188026&id=188251#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58570

Files:
  bindings/python/clang/cindex.py
  include/clang-c/Index.h
  test/Index/attributes.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -5477,6 +5477,10 @@
   return cxstring::createRef("FriendDecl");
   case CXCursor_ConvergentAttr:
   return cxstring::createRef("attribute(convergent)");
+  case CXCursor_WarnUnusedAttr:
+  return cxstring::createRef("attribute(warn_unused)");
+  case CXCursor_WarnUnusedResultAttr:
+  return cxstring::createRef("attribute(warn_unused_result)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");
Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -79,6 +79,8 @@
 case attr::ObjCBoxable: return CXCursor_ObjCBoxable;
 case attr::FlagEnum: return CXCursor_FlagEnum;
 case attr::Convergent: return CXCursor_ConvergentAttr;
+case attr::WarnUnused: return CXCursor_WarnUnusedAttr;
+case attr::WarnUnusedResult: return CXCursor_WarnUnusedResultAttr;
   }
 
   return CXCursor_UnexposedAttr;
Index: bindings/python/clang/cindex.py
===
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -1343,6 +1343,8 @@
 CursorKind.DLLEXPORT_ATTR = CursorKind(418)
 CursorKind.DLLIMPORT_ATTR = CursorKind(419)
 CursorKind.CONVERGENT_ATTR = CursorKind(438)
+CursorKind.WARN_UNUSED_ATTR = CursorKind(439)
+CursorKind.WARN_UNUSED_RESULT_ATTR = CursorKind(440)
 
 ###
 # Preprocessing
Index: include/clang-c/Index.h
===
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 51
+#define CINDEX_VERSION_MINOR 52
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
   ((major) * 1)   \
@@ -2587,7 +2587,9 @@
   CXCursor_ObjCBoxable   = 436,
   CXCursor_FlagEnum  = 437,
   CXCursor_ConvergentAttr= 438,
-  CXCursor_LastAttr  = CXCursor_ConvergentAttr,
+  CXCursor_WarnUnusedAttr= 439,
+  CXCursor_WarnUnusedResultAttr  = 440,
+  CXCursor_LastAttr  = CXCursor_WarnUnusedResultAttr,
 
   /* Preprocessing */
   CXCursor_PreprocessingDirective= 500,
Index: test/Index/attributes.c
===
--- test/Index/attributes.c
+++ test/Index/attributes.c
@@ -14,6 +14,12 @@
 
 void convergent_fn() __attribute__((convergent));
 
+int warn_unused_result_fn() __attribute__((warn_unused_result));
+
+struct __attribute__((warn_unused)) WarnUnused {
+  int b;
+};
+
 // CHECK: attributes.c:3:32: StructDecl=Test2:3:32 (Definition) Extent=[3:1 - 
5:2]
 // CHECK: attributes.c:3:23: attribute(packed)=packed Extent=[3:23 - 3:29]
 // CHECK: attributes.c:4:8: FieldDecl=a:4:8 (Definition) Extent=[4:3 - 4:9] 
[access=public]
@@ -29,3 +35,7 @@
 // CHECK: attributes.c:12:3: EnumConstantDecl=Foo:12:3 (Definition) 
Extent=[12:3 - 12:6]
 // CHECK: attributes.c:15:6: FunctionDecl=convergent_fn:15:6 Extent=[15:1 - 
15:49]
 // CHECK: attributes.c:15:37: attribute(convergent)= Extent=[15:37 - 15:47]
+// CHECK: attributes.c:17:5: FunctionDecl=warn_unused_result_fn:17:5 
Extent=[17:1 - 17:64]
+// CHECK: attributes.c:17:44: attribute(warn_unused_result)= Extent=[17:44 - 
17:62]
+// CHECK: attributes.c:19:37: StructDecl=WarnUnused:19:37 (Definition) 
Extent=[19:1 - 21:2]
+// CHECK: attributes.c:19:23: attribute(warn_unused)= Extent=[19:23 - 19:34]


Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -5477,6 +5477,10 @@
   return cxstring::createRef("FriendDecl");
   case CXCursor_ConvergentAttr:
   return cxstring::createRef("attribute(convergent)");
+  case CXCursor_WarnUnusedAttr:
+  return cxstring::createRef("attribute(warn_unused)");
+  case CXCursor_WarnUnusedResultAttr:
+  return cxstring::createRef("attribute(warn_unused_result)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");
Index: tools/libclang/CXCursor.cpp

[PATCH] D58570: [libclang] Expose warn_unused and warn_unused_result attributes.

2019-02-25 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

Landed with that change, thanks for the review @anastasia!


Repository:
  rC Clang

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

https://reviews.llvm.org/D58570



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


[PATCH] D58569: [libclang] Avoid crashing when getting layout info of an undeduced type.

2019-02-25 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio updated this revision to Diff 188254.
emilio marked an inline comment as done.
emilio added a comment.

Add CHECK tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58569

Files:
  clang/include/clang-c/Index.h
  clang/test/Index/print-type-size.cpp
  clang/tools/c-index-test/c-index-test.c
  clang/tools/libclang/CXType.cpp

Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -891,6 +891,9 @@
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
+  if (const auto *Deduced = dyn_cast(QT))
+if (Deduced->getDeducedType().isNull())
+  return CXTypeLayoutError_Undeduced;
   // Exceptions by GCC extension - see ASTContext.cpp:1313 getTypeInfoImpl
   // if (QT->isFunctionType()) return 4; // Bug #15511 - should be 1
   // if (QT->isVoidType()) return 1;
@@ -928,6 +931,9 @@
 return CXTypeLayoutError_Dependent;
   if (!QT->isConstantSizeType())
 return CXTypeLayoutError_NotConstantSize;
+  if (const auto *Deduced = dyn_cast(QT))
+if (Deduced->getDeducedType().isNull())
+  return CXTypeLayoutError_Undeduced;
   // [gcc extension] lib/AST/ExprConstant.cpp:1372
   // HandleSizeof : {voidtype,functype} == 1
   // not handled by ASTContext.cpp:1313 getTypeInfoImpl
Index: clang/tools/c-index-test/c-index-test.c
===
--- clang/tools/c-index-test/c-index-test.c
+++ clang/tools/c-index-test/c-index-test.c
@@ -1670,29 +1670,44 @@
   return CXChildVisit_Recurse;
 }
 
-static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
- CXClientData d) {
-  CXType T;
-  enum CXCursorKind K = clang_getCursorKind(cursor);
-  if (clang_isInvalid(K))
-return CXChildVisit_Recurse;
-  T = clang_getCursorType(cursor);
-  PrintCursor(cursor, NULL);
-  PrintTypeAndTypeKind(T, " [type=%s] [typekind=%s]");
+static void PrintSingleTypeSize(CXType T, const char *TypeKindFormat,
+const char *SizeFormat,
+const char *AlignFormat) {
+  PrintTypeAndTypeKind(T, TypeKindFormat);
   /* Print the type sizeof if applicable. */
   {
 long long Size = clang_Type_getSizeOf(T);
 if (Size >= 0 || Size < -1 ) {
-  printf(" [sizeof=%lld]", Size);
+  printf(SizeFormat, Size);
 }
   }
   /* Print the type alignof if applicable. */
   {
 long long Align = clang_Type_getAlignOf(T);
 if (Align >= 0 || Align < -1) {
-  printf(" [alignof=%lld]", Align);
+  printf(AlignFormat, Align);
 }
   }
+
+  /* Print the return type if it exists. */
+  {
+CXType RT = clang_getResultType(T);
+if (RT.kind != CXType_Invalid)
+  PrintSingleTypeSize(RT, " [resulttype=%s] [resulttypekind=%s]",
+  " [resultsizeof=%lld]", " [resultalignof=%lld]");
+  }
+}
+
+static enum CXChildVisitResult PrintTypeSize(CXCursor cursor, CXCursor p,
+ CXClientData d) {
+  CXType T;
+  enum CXCursorKind K = clang_getCursorKind(cursor);
+  if (clang_isInvalid(K))
+return CXChildVisit_Recurse;
+  T = clang_getCursorType(cursor);
+  PrintCursor(cursor, NULL);
+  PrintSingleTypeSize(T, " [type=%s] [typekind=%s]", " [sizeof=%lld]",
+  " [alignof=%lld]");
   /* Print the record field offset if applicable. */
   {
 CXString FieldSpelling = clang_getCursorSpelling(cursor);
@@ -1730,7 +1745,9 @@
 if (IsBitfield)
   printf(" [BitFieldSize=%d]", clang_getFieldDeclBitWidth(cursor));
   }
+
   printf("\n");
+
   return CXChildVisit_Recurse;
 }
 
Index: clang/test/Index/print-type-size.cpp
===
--- clang/test/Index/print-type-size.cpp
+++ clang/test/Index/print-type-size.cpp
@@ -400,4 +400,10 @@
 struct lastValid {
 };
 
+// CHECK64: CXXMethod=Tie:[[@LINE+3]]:8 (const) [type=auto (void *) const] [typekind=FunctionProto] [sizeof=1] [alignof=4] [resulttype=auto] [resulttypekind=Auto] [resultsizeof=-6] [resultalignof=-6]
+// CHECK32: CXXMethod=Tie:[[@LINE+2]]:8 (const) [type=auto (void *) const] [typekind=FunctionProto] [sizeof=1] [alignof=4] [resulttype=auto] [resulttypekind=Auto] [resultsizeof=-6] [resultalignof=-6]
+class BrowsingContext {
+  auto Tie(void*) const;
+};
+
 }
Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -3841,7 +3841,11 @@
   /**
* The Field name is not valid for this record.
*/
-  CXTypeLayoutError_InvalidFieldName = -5
+  CXTypeLayoutError_InvalidFieldName = -5,
+  /**
+   * The type is undeduced.
+   */
+  CXTypeLayoutError_Undeduced = -6
 };
 

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

2019-02-25 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 188256.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321

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

Index: clang/test/Driver/unstable-cxx-abi-vtables.cpp
===
--- /dev/null
+++ clang/test/Driver/unstable-cxx-abi-vtables.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang -flto -flto-relative-c++-abi-vtables -### %s 2>&1 | FileCheck -check-prefix=LTO-CLASSES %s
+// LTO-CLASSES: "-flto-relative-c++-abi-vtables"
Index: clang/test/CodeGenCXX/vtable-relative-abi.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/vtable-relative-abi.cpp
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 %s -flto -flto-unit -triple x86_64-unknown-linux-gnu -fvisibility hidden -flto-relative-c++-abi-vtables -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-ITANIUM %s
+// RUN: %clang_cc1 %s -flto -flto-unit -triple x86_64-unknown-windows-msvc -flto-relative-c++-abi-vtables -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-MS %s
+// RUN: %clang_cc1 %s -flto -flto-unit -triple x86_64-unknown-linux-gnu -fvisibility hidden -emit-llvm -o - | FileCheck --check-prefix=CHECK-NOABI %s
+
+// CHECK-ITANIUM: @_ZTV1S = hidden unnamed_addr constant { { i8*, i8*, i32, i32 } } { { i8*, i8*, i32, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1S to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32, i32 } }, { { i8*, i8*, i32, i32 } }* @_ZTV1S, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32, i32 } }, { { i8*, i8*, i32, i32 } }* @_ZTV1S, i32 0, i32 0, i32 3) to i64)) to i32) } }, align 8
+// CHECK-MS: @anon.[[NUM:[a-z0-9]+]].0 = private unnamed_addr constant { { i8*, i32, i32 } } { { i8*, i32, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"??_R4S@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"?f1@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i32, i32 } }, { { i8*, i32, i32 } }* @anon.[[NUM]].0, i32 0, i32 0, i32 1) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @"?f2@S@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i32, i32 } }, { { i8*, i32, i32 } }* @anon.[[NUM]].0, i32 0, i32 0, i32 2) to i64)) to i32) } }, comdat($"??_7S@@6B@")
+struct S {
+  S();
+  virtual void f1();
+  virtual void f2();
+};
+
+// CHECK-ITANIUM: @_ZTV1T = hidden unnamed_addr constant { { i8*, i8*, i32 } } { { i8*, i8*, i32 } { i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1T to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @_ZN1T1gEv to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32 } }, { { i8*, i8*, i32 } }* @_ZTV1T, i32 0, i32 0, i32 2) to i64)) to i32) } }, align 8
+// CHECK-MS: @anon.[[NUM]].1 = private unnamed_addr constant { { i8*, i32 } } { { i8*, i32 } { i8* bitcast (%rtti.CompleteObjectLocator* @"??_R4T@@6B@" to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.T*)* @"?g@T@@UEAAXXZ" to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i32 } }, { { i8*, i32 } }* @anon.[[NUM]].1, i32 0, i32 0, i32 1) to i64)) to i32) } }, comdat($"??_7T@@6B@")
+struct T {
+  T();
+  virtual void g();
+};
+
+// CHECK-ITANIUM: @_ZTV1U = hidden unnamed_addr constant { { i8*, i8*, i32, i32 }, { i8*, i8*, i32 } } { { i8*, i8*, i32, i32 } { i8* null, i8* bitcast ({ i8*, i8*, i32, i32, i8*, i64, i8*, i64 }* @_ZTI1U to i8*), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.U*)* @_ZN1U2f1Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*, i8*, i32, i32 }, { i8*, i8*, i32 } }, { { i8*, i8*, i32, i32 }, { i8*, i8*, i32 } }* @_ZTV1U, i32 0, i32 0, i32 2) to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint (void (%struct.S*)* @_ZN1S2f2Ev to i64), i64 ptrtoint (i32* getelementptr inbounds ({ { i8*

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

2019-02-25 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D58321#1407362 , @pcc wrote:

> Can we start with a patch that just exposes a flag that enables the relative 
> ABI unconditionally, and remove all the platform ABI compatibility stuff?


Done. Removed the checks requiring LTO, checks in `checkClassABI`, and relevant 
tests for them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321



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


[PATCH] D58089: Add missing library dependencies in CMakeLists.txt

2019-02-25 Thread Nicholas Allegra via Phabricator via cfe-commits
comex added a comment.

Ping.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58089



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


[PATCH] D58541: [CodeComplete] Propagate preferred type for function arguments in more cases

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

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58541



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


r354826 - [CodeGenObjC] Fix a nullptr dyn_cast

2019-02-25 Thread Erik Pilkington via cfe-commits
Author: epilk
Date: Mon Feb 25 13:35:14 2019
New Revision: 354826

URL: http://llvm.org/viewvc/llvm-project?rev=354826&view=rev
Log:
[CodeGenObjC] Fix a nullptr dyn_cast

ObjCMessageExpr::getInstanceReceiver returns nullptr if the receiver
is 'super'. Make this check more strict, since we don't care about
messages to super here.

rdar://48247290

Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/objc-alloc-init.m

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=354826&r1=354825&r2=354826&view=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Mon Feb 25 13:35:14 2019
@@ -433,8 +433,9 @@ tryEmitSpecializedAllocInit(CodeGenFunct
 
   // Match the exact pattern '[[MyClass alloc] init]'.
   Selector Sel = OME->getSelector();
-  if (!OME->isInstanceMessage() || !OME->getType()->isObjCObjectPointerType() 
||
-  !Sel.isUnarySelector() || Sel.getNameForSlot(0) != "init")
+  if (OME->getReceiverKind() != ObjCMessageExpr::Instance ||
+  !OME->getType()->isObjCObjectPointerType() || !Sel.isUnarySelector() ||
+  Sel.getNameForSlot(0) != "init")
 return None;
 
   // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]'.

Modified: cfe/trunk/test/CodeGenObjC/objc-alloc-init.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/objc-alloc-init.m?rev=354826&r1=354825&r2=354826&view=diff
==
--- cfe/trunk/test/CodeGenObjC/objc-alloc-init.m (original)
+++ cfe/trunk/test/CodeGenObjC/objc-alloc-init.m Mon Feb 25 13:35:14 2019
@@ -26,3 +26,16 @@ void f() {
   // EITHER: call {{.*}} @objc_msgSend
 }
 @end
+
+// rdar://48247290
+@interface Base
+-(instancetype)init;
+@end
+
+@interface Derived : Base
+@end
+@implementation Derived
+-(void)meth {
+  [super init];
+}
+@end


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


Re: r354795 - Make static counters in ASTContext non-static.

2019-02-25 Thread Alexander Kornienko via cfe-commits
Thank you for taking care of this! That's a bug indeed. Will recommit with
a fix.

On Mon, Feb 25, 2019 at 9:25 PM Vlad Tsyrklevich 
wrote:

> I've reverted this commit in r354812, it was causing MSan failures like
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29886/steps/check-clang%20msan/logs/stdio
>  Though
> these error reports don't clearly implicate this change, from your change
> it seems like the failure is occurring because you changed static
> (zero-initialized) variables to member (uninitialized) variables that were
> then never initialized before being used. The build recovered after the
> revert landed in
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29894
>
> On Mon, Feb 25, 2019 at 8:07 AM Alexander Kornienko via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: alexfh
>> Date: Mon Feb 25 08:08:46 2019
>> New Revision: 354795
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=354795&view=rev
>> Log:
>> Make static counters in ASTContext non-static.
>>
>> Summary:
>> Fixes a data race and makes it possible to run clang-based tools in
>> multithreaded environment with TSan.
>>
>> Reviewers: ilya-biryukov, riccibruno
>>
>> Reviewed By: riccibruno
>>
>> Subscribers: riccibruno, jfb, cfe-commits
>>
>> Tags: #clang
>>
>> Differential Revision: https://reviews.llvm.org/D58612
>>
>> Modified:
>> cfe/trunk/include/clang/AST/ASTContext.h
>> cfe/trunk/lib/AST/ASTContext.cpp
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/ASTContext.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354795&r1=354794&r2=354795&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 25 08:08:46 2019
>> @@ -2809,46 +2809,46 @@ public:
>>
>>  
>> //======//
>>
>>/// The number of implicitly-declared default constructors.
>> -  static unsigned NumImplicitDefaultConstructors;
>> +  unsigned NumImplicitDefaultConstructors;
>>
>>/// The number of implicitly-declared default constructors for
>>/// which declarations were built.
>> -  static unsigned NumImplicitDefaultConstructorsDeclared;
>> +  unsigned NumImplicitDefaultConstructorsDeclared;
>>
>>/// The number of implicitly-declared copy constructors.
>> -  static unsigned NumImplicitCopyConstructors;
>> +  unsigned NumImplicitCopyConstructors;
>>
>>/// The number of implicitly-declared copy constructors for
>>/// which declarations were built.
>> -  static unsigned NumImplicitCopyConstructorsDeclared;
>> +  unsigned NumImplicitCopyConstructorsDeclared;
>>
>>/// The number of implicitly-declared move constructors.
>> -  static unsigned NumImplicitMoveConstructors;
>> +  unsigned NumImplicitMoveConstructors;
>>
>>/// The number of implicitly-declared move constructors for
>>/// which declarations were built.
>> -  static unsigned NumImplicitMoveConstructorsDeclared;
>> +  unsigned NumImplicitMoveConstructorsDeclared;
>>
>>/// The number of implicitly-declared copy assignment operators.
>> -  static unsigned NumImplicitCopyAssignmentOperators;
>> +  unsigned NumImplicitCopyAssignmentOperators;
>>
>>/// The number of implicitly-declared copy assignment operators for
>>/// which declarations were built.
>> -  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
>> +  unsigned NumImplicitCopyAssignmentOperatorsDeclared;
>>
>>/// The number of implicitly-declared move assignment operators.
>> -  static unsigned NumImplicitMoveAssignmentOperators;
>> +  unsigned NumImplicitMoveAssignmentOperators;
>>
>>/// The number of implicitly-declared move assignment operators for
>>/// which declarations were built.
>> -  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
>> +  unsigned NumImplicitMoveAssignmentOperatorsDeclared;
>>
>>/// The number of implicitly-declared destructors.
>> -  static unsigned NumImplicitDestructors;
>> +  unsigned NumImplicitDestructors;
>>
>>/// The number of implicitly-declared destructors for which
>>/// declarations were built.
>> -  static unsigned NumImplicitDestructorsDeclared;
>> +  unsigned NumImplicitDestructorsDeclared;
>>
>>  public:
>>/// Initialize built-in types.
>>
>> Modified: cfe/trunk/lib/AST/ASTContext.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354795&r1=354794&r2=354795&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
>> +++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb 25 08:08:46 2019
>> @@ -94,19 +94,6 @@
>>
>>  using namespace clang;
>>
>> -unsigned ASTContext::NumImplicitDefaultConstructors;
>> -unsigned ASTContext::NumImplicitDefaultConstructor

r354827 - Reapply "Make static counters in ASTContext non-static." with fixes.

2019-02-25 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Feb 25 14:22:09 2019
New Revision: 354827

URL: http://llvm.org/viewvc/llvm-project?rev=354827&view=rev
Log:
Reapply "Make static counters in ASTContext non-static." with fixes.

This reverts commit e50038e4dc53caee1acc811362ac0b15e00ef5eb.

Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354827&r1=354826&r2=354827&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 25 14:22:09 2019
@@ -2809,46 +2809,46 @@ public:
   
//======//
 
   /// The number of implicitly-declared default constructors.
-  static unsigned NumImplicitDefaultConstructors;
+  unsigned NumImplicitDefaultConstructors = 0;
 
   /// The number of implicitly-declared default constructors for
   /// which declarations were built.
-  static unsigned NumImplicitDefaultConstructorsDeclared;
+  unsigned NumImplicitDefaultConstructorsDeclared = 0;
 
   /// The number of implicitly-declared copy constructors.
-  static unsigned NumImplicitCopyConstructors;
+  unsigned NumImplicitCopyConstructors = 0;
 
   /// The number of implicitly-declared copy constructors for
   /// which declarations were built.
-  static unsigned NumImplicitCopyConstructorsDeclared;
+  unsigned NumImplicitCopyConstructorsDeclared = 0;
 
   /// The number of implicitly-declared move constructors.
-  static unsigned NumImplicitMoveConstructors;
+  unsigned NumImplicitMoveConstructors = 0;
 
   /// The number of implicitly-declared move constructors for
   /// which declarations were built.
-  static unsigned NumImplicitMoveConstructorsDeclared;
+  unsigned NumImplicitMoveConstructorsDeclared = 0;
 
   /// The number of implicitly-declared copy assignment operators.
-  static unsigned NumImplicitCopyAssignmentOperators;
+  unsigned NumImplicitCopyAssignmentOperators = 0;
 
   /// The number of implicitly-declared copy assignment operators for
   /// which declarations were built.
-  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
+  unsigned NumImplicitCopyAssignmentOperatorsDeclared = 0;
 
   /// The number of implicitly-declared move assignment operators.
-  static unsigned NumImplicitMoveAssignmentOperators;
+  unsigned NumImplicitMoveAssignmentOperators = 0;
 
   /// The number of implicitly-declared move assignment operators for
   /// which declarations were built.
-  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
+  unsigned NumImplicitMoveAssignmentOperatorsDeclared = 0;
 
   /// The number of implicitly-declared destructors.
-  static unsigned NumImplicitDestructors;
+  unsigned NumImplicitDestructors = 0;
 
   /// The number of implicitly-declared destructors for which
   /// declarations were built.
-  static unsigned NumImplicitDestructorsDeclared;
+  unsigned NumImplicitDestructorsDeclared = 0;
 
 public:
   /// Initialize built-in types.

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354827&r1=354826&r2=354827&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb 25 14:22:09 2019
@@ -94,19 +94,6 @@
 
 using namespace clang;
 
-unsigned ASTContext::NumImplicitDefaultConstructors;
-unsigned ASTContext::NumImplicitDefaultConstructorsDeclared;
-unsigned ASTContext::NumImplicitCopyConstructors;
-unsigned ASTContext::NumImplicitCopyConstructorsDeclared;
-unsigned ASTContext::NumImplicitMoveConstructors;
-unsigned ASTContext::NumImplicitMoveConstructorsDeclared;
-unsigned ASTContext::NumImplicitCopyAssignmentOperators;
-unsigned ASTContext::NumImplicitCopyAssignmentOperatorsDeclared;
-unsigned ASTContext::NumImplicitMoveAssignmentOperators;
-unsigned ASTContext::NumImplicitMoveAssignmentOperatorsDeclared;
-unsigned ASTContext::NumImplicitDestructors;
-unsigned ASTContext::NumImplicitDestructorsDeclared;
-
 enum FloatingRank {
   Float16Rank, HalfRank, FloatRank, DoubleRank, LongDoubleRank, Float128Rank
 };

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=354827&r1=354826&r2=354827&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Feb 25 14:22:09 2019
@@ -7971,14 +7971,14 @@ void Sema::ActOnFinishCXXMemberSpecifica
 /// definition of the class is complete.
 void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) {
   if (ClassDecl->needsImplicitDefaultConstructor()) {
-   

Re: r354795 - Make static counters in ASTContext non-static.

2019-02-25 Thread Alexander Kornienko via cfe-commits
Done. r354827 should be better.

On Mon, Feb 25, 2019 at 11:18 PM Alexander Kornienko 
wrote:

> Thank you for taking care of this! That's a bug indeed. Will recommit with
> a fix.
>
> On Mon, Feb 25, 2019 at 9:25 PM Vlad Tsyrklevich 
> wrote:
>
>> I've reverted this commit in r354812, it was causing MSan failures like
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29886/steps/check-clang%20msan/logs/stdio
>>  Though
>> these error reports don't clearly implicate this change, from your change
>> it seems like the failure is occurring because you changed static
>> (zero-initialized) variables to member (uninitialized) variables that were
>> then never initialized before being used. The build recovered after the
>> revert landed in
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/29894
>>
>> On Mon, Feb 25, 2019 at 8:07 AM Alexander Kornienko via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: alexfh
>>> Date: Mon Feb 25 08:08:46 2019
>>> New Revision: 354795
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=354795&view=rev
>>> Log:
>>> Make static counters in ASTContext non-static.
>>>
>>> Summary:
>>> Fixes a data race and makes it possible to run clang-based tools in
>>> multithreaded environment with TSan.
>>>
>>> Reviewers: ilya-biryukov, riccibruno
>>>
>>> Reviewed By: riccibruno
>>>
>>> Subscribers: riccibruno, jfb, cfe-commits
>>>
>>> Tags: #clang
>>>
>>> Differential Revision: https://reviews.llvm.org/D58612
>>>
>>> Modified:
>>> cfe/trunk/include/clang/AST/ASTContext.h
>>> cfe/trunk/lib/AST/ASTContext.cpp
>>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/ASTContext.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=354795&r1=354794&r2=354795&view=diff
>>>
>>> ==
>>> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>>> +++ cfe/trunk/include/clang/AST/ASTContext.h Mon Feb 25 08:08:46 2019
>>> @@ -2809,46 +2809,46 @@ public:
>>>
>>>  
>>> //======//
>>>
>>>/// The number of implicitly-declared default constructors.
>>> -  static unsigned NumImplicitDefaultConstructors;
>>> +  unsigned NumImplicitDefaultConstructors;
>>>
>>>/// The number of implicitly-declared default constructors for
>>>/// which declarations were built.
>>> -  static unsigned NumImplicitDefaultConstructorsDeclared;
>>> +  unsigned NumImplicitDefaultConstructorsDeclared;
>>>
>>>/// The number of implicitly-declared copy constructors.
>>> -  static unsigned NumImplicitCopyConstructors;
>>> +  unsigned NumImplicitCopyConstructors;
>>>
>>>/// The number of implicitly-declared copy constructors for
>>>/// which declarations were built.
>>> -  static unsigned NumImplicitCopyConstructorsDeclared;
>>> +  unsigned NumImplicitCopyConstructorsDeclared;
>>>
>>>/// The number of implicitly-declared move constructors.
>>> -  static unsigned NumImplicitMoveConstructors;
>>> +  unsigned NumImplicitMoveConstructors;
>>>
>>>/// The number of implicitly-declared move constructors for
>>>/// which declarations were built.
>>> -  static unsigned NumImplicitMoveConstructorsDeclared;
>>> +  unsigned NumImplicitMoveConstructorsDeclared;
>>>
>>>/// The number of implicitly-declared copy assignment operators.
>>> -  static unsigned NumImplicitCopyAssignmentOperators;
>>> +  unsigned NumImplicitCopyAssignmentOperators;
>>>
>>>/// The number of implicitly-declared copy assignment operators for
>>>/// which declarations were built.
>>> -  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
>>> +  unsigned NumImplicitCopyAssignmentOperatorsDeclared;
>>>
>>>/// The number of implicitly-declared move assignment operators.
>>> -  static unsigned NumImplicitMoveAssignmentOperators;
>>> +  unsigned NumImplicitMoveAssignmentOperators;
>>>
>>>/// The number of implicitly-declared move assignment operators for
>>>/// which declarations were built.
>>> -  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
>>> +  unsigned NumImplicitMoveAssignmentOperatorsDeclared;
>>>
>>>/// The number of implicitly-declared destructors.
>>> -  static unsigned NumImplicitDestructors;
>>> +  unsigned NumImplicitDestructors;
>>>
>>>/// The number of implicitly-declared destructors for which
>>>/// declarations were built.
>>> -  static unsigned NumImplicitDestructorsDeclared;
>>> +  unsigned NumImplicitDestructorsDeclared;
>>>
>>>  public:
>>>/// Initialize built-in types.
>>>
>>> Modified: cfe/trunk/lib/AST/ASTContext.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=354795&r1=354794&r2=354795&view=diff
>>>
>>> ==
>>> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
>>> +++ cfe

[PATCH] D57898: CodeGen: Fix PR40605: split constant structures generated by -ftrivial-auto-var-init when emitting initializators

2019-02-25 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

I think (with test updates) this will be good to go once D58188 
 lands.




Comment at: tools/clang/lib/CodeGen/CGDecl.cpp:1158
+  llvm::StructType *STy = dyn_cast(Ty);
+  if (STy && (STy == Loc.getElementType()) &&
+  shouldSplitStructStore(CGM, ConstantSize)) {

Can you leave a FIXME here to handle `STY != Loc.getElementType()`, as well as 
another FIXME to handle non-struct aggregate types such as arrays? I'm happy to 
do them as a follow-up.


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

https://reviews.llvm.org/D57898



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


r354831 - [NFC] Reorder some mis-ordered tests

2019-02-25 Thread JF Bastien via cfe-commits
Author: jfb
Date: Mon Feb 25 15:09:34 2019
New Revision: 354831

URL: http://llvm.org/viewvc/llvm-project?rev=354831&view=rev
Log:
[NFC] Reorder some mis-ordered tests

I somehow had misaligned some of the tests when I originally wrote this. 
Re-order them properly.

Modified:
cfe/trunk/test/CodeGenCXX/auto-var-init.cpp

Modified: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/auto-var-init.cpp?rev=354831&r1=354830&r2=354831&view=diff
==
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp Mon Feb 25 15:09:34 2019
@@ -111,22 +111,22 @@ struct derived : public base {};
 struct virtualderived : public virtual base, public virtual derived {};
 // PATTERN: @__const.test_matching_uninit.uninit = private unnamed_addr 
constant %union.matching { i32 -1431655766 }, align 4
 // PATTERN: @__const.test_matching_custom.custom = private unnamed_addr 
constant { float } { float 6.145500e+04 }, align 4
+// ZERO: @__const.test_matching_custom.custom = private unnamed_addr constant 
{ float } { float 6.145500e+04 }, align 4
 union matching { int i; float f; };
 // PATTERN: @__const.test_matchingreverse_uninit.uninit = private unnamed_addr 
constant %union.matchingreverse { float 0xE000 }, align 4
 // PATTERN: @__const.test_matchingreverse_custom.custom = private unnamed_addr 
constant { i32 } { i32 61455 }, align 4
-// ZERO: @__const.test_matching_custom.custom = private unnamed_addr constant 
{ float } { float 6.145500e+04 }, align 4
+// ZERO: @__const.test_matchingreverse_custom.custom = private unnamed_addr 
constant { i32 } { i32 61455 }, align 4
 union matchingreverse { float f; int i; };
 // PATTERN: @__const.test_unmatched_uninit.uninit = private unnamed_addr 
constant %union.unmatched { i32 -1431655766 }, align 4
 // PATTERN: @__const.test_unmatched_custom.custom = private unnamed_addr 
constant %union.unmatched { i32 1001242351 }, align 4
-// ZERO: @__const.test_matchingreverse_custom.custom = private unnamed_addr 
constant { i32 } { i32 61455 }, align 4
+// ZERO: @__const.test_unmatched_custom.custom = private unnamed_addr constant 
%union.unmatched { i32 1001242351 }, align 4
 union unmatched { char c; int i; };
 // PATTERN: @__const.test_unmatchedreverse_uninit.uninit = private 
unnamed_addr constant %union.unmatchedreverse { i32 -1431655766 }, align 4
 // PATTERN: @__const.test_unmatchedreverse_custom.custom = private 
unnamed_addr constant { i8, [3 x i8] } { i8 42, [3 x i8] zeroinitializer }, 
align 4
-// ZERO: @__const.test_unmatched_custom.custom = private unnamed_addr constant 
%union.unmatched { i32 1001242351 }, align 4
+// ZERO: @__const.test_unmatchedreverse_custom.custom = private unnamed_addr 
constant { i8, [3 x i8] } { i8 42, [3 x i8] zeroinitializer }, align 4
 union unmatchedreverse { int i; char c; };
 // PATTERN: @__const.test_unmatchedfp_uninit.uninit = private unnamed_addr 
constant %union.unmatchedfp { double 0x }, align 8
 // PATTERN: @__const.test_unmatchedfp_custom.custom = private unnamed_addr 
constant %union.unmatchedfp { double 0x400921FB54442D18 }, align 8
-// ZERO: @__const.test_unmatchedreverse_custom.custom = private unnamed_addr 
constant { i8, [3 x i8] } { i8 42, [3 x i8] zeroinitializer }, align 4
 // ZERO: @__const.test_unmatchedfp_custom.custom = private unnamed_addr 
constant %union.unmatchedfp { double 0x400921FB54442D18 }, align 8
 union unmatchedfp { float f; double d; };
 enum emptyenum {};


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


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

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

Updating after switching to the git monorepo model.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58292

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

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -754,6 +754,11 @@
   EXPECT_TRUE(matches("int* i = nullptr;", cxxNullPtrLiteralExpr()));
 }
 
+TEST(Matcher, ChooseExpr) {
+  EXPECT_TRUE(matchesC("void f() { (void)__builtin_choose_expr(1, 2, 3); }",
+   chooseExpr()));
+}
+
 TEST(Matcher, GNUNullExpr) {
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -563,6 +563,34 @@
   stringLiteral(hasType(asString("const char [7]"));
 }
 
+TEST_P(ImportExpr, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  // This case tests C code that is not condition-dependent and has a true
+  // condition.
+  testImport(
+"void declToImport() { (void)__builtin_choose_expr(1, 2, 3); }",
+Lang_C, "", Lang_C, Verifier,
+functionDecl(hasDescendant(chooseExpr(;
+
+  ArgVector Args = getExtraArgs();
+  BindableMatcher Matcher =
+  functionTemplateDecl(hasDescendant(chooseExpr()));
+
+  // Don't try to match the template contents if template parsing is delayed.
+  if (llvm::find(Args, "-fdelayed-template-parsing") != Args.end()) {
+Matcher = functionTemplateDecl();
+  }
+
+  // Make sure that uses of (void)__builtin_choose_expr with dependent types in
+  // the condition are handled properly. This test triggers an assertion if the
+  // ASTImporter incorrectly tries to access isConditionTrue() when
+  // isConditionDependent() is true.
+  testImport("template void declToImport() { "
+ "(void)__builtin_choose_expr(N, 1, 0); }",
+ Lang_CXX, "", Lang_CXX, Verifier, Matcher);
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1312,6 +1340,27 @@
   ASSERT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportChooseExpr) {
+  // This tests the import of isConditionTrue directly to make sure the importer
+  // gets it right.
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+"void declToImport() { (void)__builtin_choose_expr(1, 0, 1); }",
+Lang_C, "", Lang_C);
+
+  auto ToResults = match(chooseExpr().bind("choose"), To->getASTContext());
+  auto FromResults = match(chooseExpr().bind("choose"), From->getASTContext());
+
+  const ChooseExpr *FromChooseExpr =
+  selectFirst("choose", FromResults);
+  ASSERT_TRUE(FromChooseExpr);
+
+  const ChooseExpr *ToChooseExpr = selectFirst("choose", ToResults);
+  ASSERT_TRUE(ToChooseExpr);
+
+  EXPECT_EQ(FromChooseExpr->isConditionTrue(), ToChooseExpr->isConditionTrue());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportFunctionWithBackReferringParameter) {
   Decl *From, *To;
Index: clang/test/ASTMerge/choose-expr/test.c
===
--- /dev/null
+++ clang/test/ASTMerge/choose-expr/test.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c11 -emit-pch -o %t.ast %S/Inputs/choose.c
+// RUN: %clang_cc1 -std=c11 -ast-merge %t.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
Index: clang/test/ASTMerge/choose-expr/Inputs/choose.c
===
--- /dev/null
+++ clang/test/ASTMerge/choose-expr/Inputs/choose.c
@@ -0,0 +1,2 @@
+_Static_assert(__builtin_choose_expr(1, 1, 0), "Incorrect semantics of __builtin_choose_expr");
+_Static_assert(__builtin_choose_expr(0, 0, 1), "Incorrect semantics of __builtin_choose_expr");
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -147,6 +147,7 @@
   REGISTER_MATCHER(caseStmt);
   REGISTER_MATCHER(castExpr);
   REGISTER_MATCHER(characterLiteral);
+  REGISTER_MATCHER(chooseExpr);
   REGISTER_MATCHER(classTemplateDecl);
   REGISTER_MATCHER(classTemplateSpecializationDecl);
   REGISTER_MATCHER(complexType);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.c

[PATCH] D58649: Fix inline assembler constraint validation

2019-02-25 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg created this revision.
joerg added a reviewer: compnerd.
Herald added a subscriber: eraman.

The current constraint logic is both too lax and too strict. It fails for input 
outside the [INT_MIN..INT_MAX] range, but it also implicitly accepts 0 as value 
when it should not. Adjust logic to handle both correctly.


https://reviews.llvm.org/D58649

Files:
  include/clang/Basic/TargetInfo.h
  test/Sema/inline-asm-validate-x86.c


Index: test/Sema/inline-asm-validate-x86.c
===
--- test/Sema/inline-asm-validate-x86.c
+++ test/Sema/inline-asm-validate-x86.c
@@ -55,6 +55,7 @@
 void L(int i, int j) {
   static const int Invalid1 = 1;
   static const int Invalid2 = 42;
+  static const int Invalid3 = 0;
   static const int Valid1 = 0xff;
   static const int Valid2 = 0x;
   static const int Valid3 = 0x;
@@ -69,6 +70,9 @@
   : "0"(i), "L"(Invalid2)); // expected-error{{value '42' out of range 
for constraint 'L'}}
   __asm__("xorl %0,%2"
   : "=r"(i)
+  : "0"(i), "L"(Invalid3)); // expected-error{{value '0' out of range 
for constraint 'L'}}
+  __asm__("xorl %0,%2"
+  : "=r"(i)
   : "0"(i), "L"(Valid1)); // expected-no-error
   __asm__("xorl %0,%2"
   : "=r"(i)
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -816,6 +816,7 @@
 struct {
   int Min;
   int Max;
+  bool isConstrained;
 } ImmRange;
 llvm::SmallSet ImmSet;
 
@@ -826,6 +827,7 @@
 : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
   Name(Name.str()) {
   ImmRange.Min = ImmRange.Max = 0;
+  ImmRange.isConstrained = false;
 }
 
 const std::string &getConstraintStr() const { return ConstraintStr; }
@@ -854,8 +856,9 @@
   return (Flags & CI_ImmediateConstant) != 0;
 }
 bool isValidAsmImmediate(const llvm::APInt &Value) const {
-  return (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)) ||
- ImmSet.count(Value.getZExtValue()) != 0;
+  if (!ImmSet.empty())
+return ImmSet.count(Value.getZExtValue()) != 0;
+  return !ImmRange.isConstrained || (Value.sge(ImmRange.Min) && 
Value.sle(ImmRange.Max));
 }
 
 void setIsReadWrite() { Flags |= CI_ReadWrite; }
@@ -867,6 +870,7 @@
   Flags |= CI_ImmediateConstant;
   ImmRange.Min = Min;
   ImmRange.Max = Max;
+  ImmRange.isConstrained = true;
 }
 void setRequiresImmediate(llvm::ArrayRef Exacts) {
   Flags |= CI_ImmediateConstant;
@@ -879,8 +883,6 @@
 }
 void setRequiresImmediate() {
   Flags |= CI_ImmediateConstant;
-  ImmRange.Min = INT_MIN;
-  ImmRange.Max = INT_MAX;
 }
 
 /// Indicate that this is an input operand that is tied to


Index: test/Sema/inline-asm-validate-x86.c
===
--- test/Sema/inline-asm-validate-x86.c
+++ test/Sema/inline-asm-validate-x86.c
@@ -55,6 +55,7 @@
 void L(int i, int j) {
   static const int Invalid1 = 1;
   static const int Invalid2 = 42;
+  static const int Invalid3 = 0;
   static const int Valid1 = 0xff;
   static const int Valid2 = 0x;
   static const int Valid3 = 0x;
@@ -69,6 +70,9 @@
   : "0"(i), "L"(Invalid2)); // expected-error{{value '42' out of range for constraint 'L'}}
   __asm__("xorl %0,%2"
   : "=r"(i)
+  : "0"(i), "L"(Invalid3)); // expected-error{{value '0' out of range for constraint 'L'}}
+  __asm__("xorl %0,%2"
+  : "=r"(i)
   : "0"(i), "L"(Valid1)); // expected-no-error
   __asm__("xorl %0,%2"
   : "=r"(i)
Index: include/clang/Basic/TargetInfo.h
===
--- include/clang/Basic/TargetInfo.h
+++ include/clang/Basic/TargetInfo.h
@@ -816,6 +816,7 @@
 struct {
   int Min;
   int Max;
+  bool isConstrained;
 } ImmRange;
 llvm::SmallSet ImmSet;
 
@@ -826,6 +827,7 @@
 : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
   Name(Name.str()) {
   ImmRange.Min = ImmRange.Max = 0;
+  ImmRange.isConstrained = false;
 }
 
 const std::string &getConstraintStr() const { return ConstraintStr; }
@@ -854,8 +856,9 @@
   return (Flags & CI_ImmediateConstant) != 0;
 }
 bool isValidAsmImmediate(const llvm::APInt &Value) const {
-  return (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)) ||
- ImmSet.count(Value.getZExtValue()) != 0;
+  if (!ImmSet.empty())
+return ImmSet.count(Value.getZExtValue()) != 0;
+  return !ImmRange.isConstrained || (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max));
 }
 
 void setIsReadWrite() { Flags |= CI_ReadWrite; }
@@ -867,6 +870,7 @@
   Flags |= CI_ImmediateConstant;
   ImmRange.Min = Min;
   ImmRange.Max = Max;
+  

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

2019-02-25 Thread Tom Roeder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354832: [ASTImporter] Add support for importing ChooseExpr 
AST nodes. (authored by tmroeder, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58292?vs=188262&id=188266#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58292

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

Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -788,6 +788,11 @@
 
 
 
+MatcherStmt>chooseExprMatcherChooseExpr>...
+Matches GNU __builtin_choose_expr.
+
+
+
 MatcherStmt>compoundLiteralExprMatcherCompoundLiteralExpr>...
 Matches compound (i.e. non-scalar) literals
 
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -2158,6 +2158,10 @@
 extern const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
 
+/// Matches GNU __builtin_choose_expr.
+extern const internal::VariadicDynCastAllOfMatcher
+chooseExpr;
+
 /// Matches GNU __null expression.
 extern const internal::VariadicDynCastAllOfMatcher
 gnuNullExpr;
Index: cfe/trunk/test/ASTMerge/choose-expr/Inputs/choose.c
===
--- cfe/trunk/test/ASTMerge/choose-expr/Inputs/choose.c
+++ cfe/trunk/test/ASTMerge/choose-expr/Inputs/choose.c
@@ -0,0 +1,2 @@
+_Static_assert(__builtin_choose_expr(1, 1, 0), "Incorrect semantics of __builtin_choose_expr");
+_Static_assert(__builtin_choose_expr(0, 0, 1), "Incorrect semantics of __builtin_choose_expr");
Index: cfe/trunk/test/ASTMerge/choose-expr/test.c
===
--- cfe/trunk/test/ASTMerge/choose-expr/test.c
+++ cfe/trunk/test/ASTMerge/choose-expr/test.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c11 -emit-pch -o %t.ast %S/Inputs/choose.c
+// RUN: %clang_cc1 -std=c11 -ast-merge %t.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -552,6 +552,7 @@
 // Importing expressions
 ExpectedStmt VisitExpr(Expr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
+ExpectedStmt VisitChooseExpr(ChooseExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
 ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
 ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E);
@@ -6135,6 +6136,33 @@
   E->isMicrosoftABI());
 }
 
+ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
+  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
+   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());
+  if (!Imp)
+return Imp.takeError();
+
+  Expr *ToCond;
+  Expr *ToLHS;
+  Expr *ToRHS;
+  SourceLocation ToBuiltinLoc, ToRParenLoc;
+  QualType ToType;
+  std::tie(ToCond, ToLHS, ToRHS, ToBuiltinLoc, ToRParenLoc, ToType) = *Imp;
+
+  ExprValueKind VK = E->getValueKind();
+  ExprObjectKind OK = E->getObjectKind();
+
+  bool TypeDependent = ToCond->isTypeDependent();
+  bool ValueDependent = ToCond->isValueDependent();
+
+  // The value of CondIsTrue only matters if the value is not
+  // condition-dependent.
+  bool CondIsTrue = !E->isConditionDependent() && E->isConditionTrue();
+
+  return new (Importer.getToContext())
+  ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType, VK, OK,
+ ToRParenLoc, CondIsTrue, TypeDependent, ValueDependent);
+}
 
 ExpectedStmt ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) {
   ExpectedType TypeOrErr = import(E->getType());
Index: cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
+++ cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -147,6 +147,7 @@
   REGISTER_MATCHER(caseStmt);
   REGI

[PATCH] D58658: [OpenCL] Fix assertion due to blocks

2019-02-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: Anastasia.
Herald added subscribers: kristof.beyls, javed.absar.

A recent change caused assertion in CodeGenFunction::EmitBlockCallExpr when a 
block is called.

There is code

  if (!isa(E->getCalleeDecl()))
Func = CGM.getOpenCLRuntime().getInvokeFunction(E->getCallee());

getCalleeDecl calls Expr::getReferencedDeclOfCallee, which does not handle
BlockExpr and returns nullptr, which causes isa to assert.

This patch fixes that.


https://reviews.llvm.org/D58658

Files:
  lib/AST/Expr.cpp
  test/CodeGenOpenCL/blocks.cl


Index: test/CodeGenOpenCL/blocks.cl
===
--- test/CodeGenOpenCL/blocks.cl
+++ test/CodeGenOpenCL/blocks.cl
@@ -90,6 +90,12 @@
   return blockArgFunc(^{return 42;});
 }
 
+// COMMON-LABEL: define {{.*}}@call_block
+// call {{.*}}@__call_block_block_invoke
+int call_block() {
+  return ^int(int num) { return num; } (11);
+}
+
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"
 
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1358,6 +1358,8 @@
 return DRE->getDecl();
   if (MemberExpr *ME = dyn_cast(CEE))
 return ME->getMemberDecl();
+  if (auto *BE = dyn_cast(CEE))
+return BE->getBlockDecl();
 
   return nullptr;
 }


Index: test/CodeGenOpenCL/blocks.cl
===
--- test/CodeGenOpenCL/blocks.cl
+++ test/CodeGenOpenCL/blocks.cl
@@ -90,6 +90,12 @@
   return blockArgFunc(^{return 42;});
 }
 
+// COMMON-LABEL: define {{.*}}@call_block
+// call {{.*}}@__call_block_block_invoke
+int call_block() {
+  return ^int(int num) { return num; } (11);
+}
+
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__size"
 // CHECK-DEBUG: !DIDerivedType(tag: DW_TAG_member, name: "__align"
 
Index: lib/AST/Expr.cpp
===
--- lib/AST/Expr.cpp
+++ lib/AST/Expr.cpp
@@ -1358,6 +1358,8 @@
 return DRE->getDecl();
   if (MemberExpr *ME = dyn_cast(CEE))
 return ME->getMemberDecl();
+  if (auto *BE = dyn_cast(CEE))
+return BE->getBlockDecl();
 
   return nullptr;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58659: [Sema] Fix assertion when `auto` parameter in lambda has an attribute.

2019-02-25 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: rsmith, arphaman.
Herald added subscribers: jdoerfert, dexonsmith, jkorous.

Fixes the assertion

> no Attr* for AttributedType*
>  UNREACHABLE executed at llvm-project/clang/lib/Sema/SemaType.cpp:298!

In `TypeProcessingState::getAttributedType` we put into `AttrsForTypes`
types with `auto` but later in
`TypeProcessingState::takeAttrForAttributedType` we use transformed
types and that's why cannot find `Attr` corresponding to
`AttributedType`.

Fix by keeping `AttrsForTypes` up to date after replacing `AutoType`.

rdar://problem/47689465


https://reviews.llvm.org/D58659

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/auto-cxx0x.cpp


Index: clang/test/SemaCXX/auto-cxx0x.cpp
===
--- clang/test/SemaCXX/auto-cxx0x.cpp
+++ clang/test/SemaCXX/auto-cxx0x.cpp
@@ -15,3 +15,11 @@
   // expected-error@-2 {{'auto' not allowed in lambda parameter}}
 #endif
 }
+
+void rdar47689465() {
+  int x = 0;
+  [](auto __attribute__((noderef)) *){}(&x);
+#if __cplusplus == 201103L
+  // expected-error@-2 {{'auto' not allowed in lambda parameter}}
+#endif
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -255,6 +255,23 @@
   return T;
 }
 
+/// Completely replace the \c auto in \p TypeWithAuto by
+/// \p Replacement. Also replace \p TypeWithAuto in \c TypeAttrPair if
+/// necessary.
+QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement) {
+  QualType T = sema.ReplaceAutoType(TypeWithAuto, Replacement);
+  if (auto *AttrTy = TypeWithAuto->getAs()) {
+// Attributed type still should be an attributed type after 
replacement.
+auto *NewAttrTy = cast(T.getTypePtr());
+for (TypeAttrPair &A : AttrsForTypes) {
+  if (A.first == AttrTy)
+A.first = NewAttrTy;
+}
+AttrsForTypesSorted = false;
+  }
+  return T;
+}
+
 /// Extract and remove the Attr* for a given attributed type.
 const Attr *takeAttrForAttributedType(const AttributedType *AT) {
   if (!AttrsForTypesSorted) {
@@ -2935,7 +2952,7 @@
 // template type parameter.
 // FIXME: Retain some type sugar to indicate that this was written
 // as 'auto'.
-T = SemaRef.ReplaceAutoType(
+T = state.ReplaceAutoType(
 T, QualType(CorrespondingTemplateParam->getTypeForDecl(), 0));
   }
   break;


Index: clang/test/SemaCXX/auto-cxx0x.cpp
===
--- clang/test/SemaCXX/auto-cxx0x.cpp
+++ clang/test/SemaCXX/auto-cxx0x.cpp
@@ -15,3 +15,11 @@
   // expected-error@-2 {{'auto' not allowed in lambda parameter}}
 #endif
 }
+
+void rdar47689465() {
+  int x = 0;
+  [](auto __attribute__((noderef)) *){}(&x);
+#if __cplusplus == 201103L
+  // expected-error@-2 {{'auto' not allowed in lambda parameter}}
+#endif
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -255,6 +255,23 @@
   return T;
 }
 
+/// Completely replace the \c auto in \p TypeWithAuto by
+/// \p Replacement. Also replace \p TypeWithAuto in \c TypeAttrPair if
+/// necessary.
+QualType ReplaceAutoType(QualType TypeWithAuto, QualType Replacement) {
+  QualType T = sema.ReplaceAutoType(TypeWithAuto, Replacement);
+  if (auto *AttrTy = TypeWithAuto->getAs()) {
+// Attributed type still should be an attributed type after replacement.
+auto *NewAttrTy = cast(T.getTypePtr());
+for (TypeAttrPair &A : AttrsForTypes) {
+  if (A.first == AttrTy)
+A.first = NewAttrTy;
+}
+AttrsForTypesSorted = false;
+  }
+  return T;
+}
+
 /// Extract and remove the Attr* for a given attributed type.
 const Attr *takeAttrForAttributedType(const AttributedType *AT) {
   if (!AttrsForTypesSorted) {
@@ -2935,7 +2952,7 @@
 // template type parameter.
 // FIXME: Retain some type sugar to indicate that this was written
 // as 'auto'.
-T = SemaRef.ReplaceAutoType(
+T = state.ReplaceAutoType(
 T, QualType(CorrespondingTemplateParam->getTypeForDecl(), 0));
   }
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58659: [Sema] Fix assertion when `auto` parameter in lambda has an attribute.

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

Have doubts that checking only the outermost type for being `AttributedType` 
after `Sema::ReplaceAutoType` is sufficient but haven't found a counterexample 
yet. Decided to post the proposed fix to see if others have any ideas.


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

https://reviews.llvm.org/D58659



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


[PATCH] D58137: [clang-tidy] Add the abseil-time-subtraction check

2019-02-25 Thread Hyrum Wright via Phabricator via cfe-commits
hwright updated this revision to Diff 188289.
hwright marked 5 inline comments as done.

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

https://reviews.llvm.org/D58137

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationRewriter.cpp
  clang-tidy/abseil/DurationRewriter.h
  clang-tidy/abseil/TimeSubtractionCheck.cpp
  clang-tidy/abseil/TimeSubtractionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-time-subtraction.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/Inputs/absl/time/time.h
  test/clang-tidy/abseil-time-subtraction.cpp

Index: test/clang-tidy/abseil-time-subtraction.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-time-subtraction.cpp
@@ -0,0 +1,117 @@
+// RUN: %check_clang_tidy %s abseil-time-subtraction %t -- -- -I%S/Inputs
+
+#include "absl/time/time.h"
+
+void g(absl::Duration d);
+
+void f() {
+  absl::Time t;
+  int x, y;
+  absl::Duration d;
+
+  d = absl::Hours(absl::ToUnixHours(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixHours(x));
+  d = absl::Minutes(absl::ToUnixMinutes(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMinutes(x));
+  d = absl::Seconds(absl::ToUnixSeconds(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixSeconds(x));
+  d = absl::Milliseconds(absl::ToUnixMillis(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMillis(x));
+  d = absl::Microseconds(absl::ToUnixMicros(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixMicros(x));
+  d = absl::Nanoseconds(absl::ToUnixNanos(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixNanos(x));
+
+  y = x - absl::ToUnixHours(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Hours(absl::FromUnixHours(x) - t);
+  y = x - absl::ToUnixMinutes(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Minutes(absl::FromUnixMinutes(x) - t);
+  y = x - absl::ToUnixSeconds(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Seconds(absl::FromUnixSeconds(x) - t);
+  y = x - absl::ToUnixMillis(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Milliseconds(absl::FromUnixMillis(x) - t);
+  y = x - absl::ToUnixMicros(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Microseconds(absl::FromUnixMicros(x) - t);
+  y = x - absl::ToUnixNanos(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: y = absl::ToInt64Nanoseconds(absl::FromUnixNanos(x) - t);
+
+  // Check parenthesis placement
+  d = 5 * absl::Seconds(absl::ToUnixSeconds(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = 5 * (t - absl::FromUnixSeconds(x));
+  d = absl::Seconds(absl::ToUnixSeconds(t) - x) / 5;
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixSeconds(x)) / 5;
+
+  // No extra parens around arguments
+  g(absl::Seconds(absl::ToUnixSeconds(t) - x));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: g(t - absl::FromUnixSeconds(x));
+  g(absl::Seconds(x - absl::ToUnixSeconds(t)));
+  // CHECK-MESSAGES: [[@LINE-1]]:5: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: g(absl::FromUnixSeconds(x) - t);
+
+  // More complex subexpressions
+  d = absl::Hours(absl::ToUnixHours(t) - 5 * x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time domain [abseil-time-subtraction]
+  // CHECK-FIXES: d = (t - absl::FromUnixHours(5 * x));
+
+  // These should not trigger; they are likely bugs
+  d = absl::Milliseconds(absl::ToUnixSeconds(t) - x);
+  d = absl::Seconds(

[PATCH] D58137: [clang-tidy] Add the abseil-time-subtraction check

2019-02-25 Thread Hyrum Wright via Phabricator via cfe-commits
hwright added inline comments.



Comment at: clang-tidy/abseil/TimeSubtractionCheck.cpp:97
+void TimeSubtractionCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *BinOp = Result.Nodes.getNodeAs("binop");
+  std::string inverse_name =

JonasToth wrote:
> hwright wrote:
> > JonasToth wrote:
> > > Could you please split this function up into smaller ones. There are 
> > > three or four distinct cases that are easier to comprehend in isolation.
> > The actual bodies of these if-statements are only one or two separate 
> > statements themselves.  Moving those to separate functions seems like it 
> > would just obfuscate things a bit.
> IMHO they are complicated statements and hide what is being done. Wrapping 
> them in a function with a name that states what is done seems appropriate.
I would agree that they are complicated statements, which is why there are 
multi-line comments explaining what is being doing.  Moving a two-line compound 
statement into a separate function which is only called once seems more 
confusing than simplifying.  More information can be expressed in a prose 
comment than a single concise function name, no?



Comment at: test/clang-tidy/abseil-time-subtraction.cpp:12
+
+  d = absl::Hours(absl::ToUnixHours(t) - x);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: perform subtraction in the time 
domain [abseil-time-subtraction]

JonasToth wrote:
> hwright wrote:
> > JonasToth wrote:
> > > please add tests where `x` itself is a calculation with different 
> > > precedence of its operators (multiplication, addition) to ensure these 
> > > cases are transformed properly as well.
> > This doesn't actually matter in this case: `x` will be wrapped in a 
> > function call.
> > 
> > It does matter in the case where we //unwrap// the first argument (below) 
> > and I've already got a test which uses multiplication in this case.  I've 
> > also added one for division.
> Yes, it should not matter if `x` is an expr itself or just a variable. Thats 
> why it should be tested its actually true.
Added, though this seems more a test of the matcher infrastructure than the 
tool itself.


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

https://reviews.llvm.org/D58137



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


r354838 - [MS] Fix for Bug 8446, template instantiation without a 'typename' keyword

2019-02-25 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Feb 25 18:22:17 2019
New Revision: 354838

URL: http://llvm.org/viewvc/llvm-project?rev=354838&view=rev
Log:
[MS] Fix for Bug 8446, template instantiation without a 'typename' keyword

Patch by Zahira Ammarguellat!

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

Added:
cfe/trunk/test/SemaTemplate/missing-typename.cpp
Modified:
cfe/trunk/lib/Parse/ParseTentative.cpp

Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=354838&r1=354837&r2=354838&view=diff
==
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Mon Feb 25 18:22:17 2019
@@ -1498,6 +1498,17 @@ Parser::isCXXDeclarationSpecifier(Parser
 // expression.
 *HasMissingTypename = true;
 return TPResult::Ambiguous;
+  } else {
+// In MS mode, if HasMissingTypename is not provided, and the 
tokens
+// are or the form *) or &) *> or &> &&>, this can't be an 
expression.
+// The typename must be missing.
+if (getLangOpts().MSVCCompat) {
+  if (((Tok.is(tok::amp) || Tok.is(tok::star)) &&
+   (NextToken().is(tok::r_paren) ||
+NextToken().is(tok::greater))) ||
+  (Tok.is(tok::ampamp) && NextToken().is(tok::greater)))
+return TPResult::True;
+}
   }
 } else {
   // Try to resolve the name. If it doesn't exist, assume it was

Added: cfe/trunk/test/SemaTemplate/missing-typename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/missing-typename.cpp?rev=354838&view=auto
==
--- cfe/trunk/test/SemaTemplate/missing-typename.cpp (added)
+++ cfe/trunk/test/SemaTemplate/missing-typename.cpp Mon Feb 25 18:22:17 2019
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-unused
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-unused 
-fms-compatibility -DMSVC
+
+namespace PR8446_1 {
+struct A {
+  typedef int BASE_VALUE;
+};
+
+void g(int &y) {}
+
+template 
+void f(int &rValue) {
+#if MSVC
+// expected-warning@+4 {{missing 'typename' prior to dependent type name 
'BASE_CLASS::BASE_VALUE'}}
+#else
+  // expected-error@+2 {{expected expression}}
+#endif
+  return g((BASE_CLASS::BASE_VALUE &)rValue);
+}
+
+int main() {
+  int x;
+  f(x);
+  return 0;
+}
+} // namespace PR8446_1
+
+
+namespace PR8446_2 {
+struct site_symmetry_ops {};
+
+template 
+struct class_ {
+  template 
+  void def(A1 const &a1) {}
+};
+
+template 
+struct init {
+  init() {}
+};
+
+struct special_position_site_parameter {
+  typedef char scatterer_type;
+};
+
+template 
+struct valued_asu_parameter_heir_wrapper {
+  static class_ wrap(char const *name) {
+return class_();
+  }
+};
+
+template 
+struct special_position_wrapper {
+  static void wrap(char const *name) {
+valued_asu_parameter_heir_wrapper::wrap(name)
+#if MSVC
+// expected-warning@+4 {{missing 'typename' prior to dependent type name 
'wt::scatterer_type'}}
+#else
+// expected-error@+2 {{expected expression}}
+#endif
+.def(init());
+  }
+};
+
+void wrap_special_position() {
+  
special_position_wrapper::wrap("special_position_site_parameter");
+}
+} // namespace PR8446_2
+
+namespace PR8446_3 {
+int g(int);
+template 
+int f1(int x) {
+  return g((T::InnerName & x) & x);
+}
+
+template 
+int f2(int x) {
+  return g((T::InnerName & 3) & x);
+}
+
+template 
+int f3(int x) {
+  return g((T::InnerName & (3)));
+}
+
+template 
+int f4(int x) {
+  return g((T::InnerName * 3) & x);
+}
+struct A {
+  static const int InnerName = 42;
+};
+int main() {
+  f1(0);
+  f2(0);
+  f3(0);
+  return f4(0);
+}
+} // namespace PR8446_3


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


r354839 - Revert r354832 "[ASTImporter] Add support for importing ChooseExpr AST nodes."

2019-02-25 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Feb 25 18:22:22 2019
New Revision: 354839

URL: http://llvm.org/viewvc/llvm-project?rev=354839&view=rev
Log:
Revert r354832 "[ASTImporter] Add support for importing ChooseExpr AST nodes."

Test does not pass on Windows

Removed:
cfe/trunk/test/ASTMerge/
Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=354839&r1=354838&r2=354839&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Feb 25 18:22:22 2019
@@ -788,11 +788,6 @@ Example matches 'a', L'a'
 
 
 
-MatcherStmt>chooseExprMatcherChooseExpr>...
-Matches GNU 
__builtin_choose_expr.
-
-
-
 MatcherStmt>compoundLiteralExprMatcherCompoundLiteralExpr>...
 Matches 
compound (i.e. non-scalar) literals
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=354839&r1=354838&r2=354839&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Feb 25 18:22:22 2019
@@ -2158,10 +2158,6 @@ extern const internal::VariadicDynCastAl
 extern const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
 
-/// Matches GNU __builtin_choose_expr.
-extern const internal::VariadicDynCastAllOfMatcher
-chooseExpr;
-
 /// Matches GNU __null expression.
 extern const internal::VariadicDynCastAllOfMatcher
 gnuNullExpr;

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=354839&r1=354838&r2=354839&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Feb 25 18:22:22 2019
@@ -552,7 +552,6 @@ namespace clang {
 // Importing expressions
 ExpectedStmt VisitExpr(Expr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
-ExpectedStmt VisitChooseExpr(ChooseExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
 ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
 ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E);
@@ -6136,33 +6135,6 @@ ExpectedStmt ASTNodeImporter::VisitVAArg
   E->isMicrosoftABI());
 }
 
-ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
-  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
-   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());
-  if (!Imp)
-return Imp.takeError();
-
-  Expr *ToCond;
-  Expr *ToLHS;
-  Expr *ToRHS;
-  SourceLocation ToBuiltinLoc, ToRParenLoc;
-  QualType ToType;
-  std::tie(ToCond, ToLHS, ToRHS, ToBuiltinLoc, ToRParenLoc, ToType) = *Imp;
-
-  ExprValueKind VK = E->getValueKind();
-  ExprObjectKind OK = E->getObjectKind();
-
-  bool TypeDependent = ToCond->isTypeDependent();
-  bool ValueDependent = ToCond->isValueDependent();
-
-  // The value of CondIsTrue only matters if the value is not
-  // condition-dependent.
-  bool CondIsTrue = !E->isConditionDependent() && E->isConditionTrue();
-
-  return new (Importer.getToContext())
-  ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType, VK, OK,
- ToRParenLoc, CondIsTrue, TypeDependent, ValueDependent);
-}
 
 ExpectedStmt ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) {
   ExpectedType TypeOrErr = import(E->getType());

Modified: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp?rev=354839&r1=354838&r2=354839&view=diff
==
--- cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp (original)
+++ cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp Mon Feb 25 18:22:22 2019
@@ -727,7 +727,6 @@ const internal::VariadicDynCastAllOfMatc
 compoundLiteralExpr;
 const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
-const internal::VariadicDynCastAllOfMatcher chooseExpr;
 const internal::VariadicDynCastAllOfMatcher gnuNullExpr;
 const internal::VariadicDynCastAllOfMatcher atomicExpr;
 const

[PATCH] D41950: Fix for Bug 8446. Template instantiation without a 'typename' keyword.

2019-02-25 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354838: [MS] Fix for Bug 8446, template instantiation 
without a 'typename' keyword (authored by rnk, committed by ).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

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

https://reviews.llvm.org/D41950

Files:
  lib/Parse/ParseTentative.cpp
  test/SemaTemplate/missing-typename.cpp

Index: test/SemaTemplate/missing-typename.cpp
===
--- test/SemaTemplate/missing-typename.cpp
+++ test/SemaTemplate/missing-typename.cpp
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-unused
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-unused -fms-compatibility -DMSVC
+
+namespace PR8446_1 {
+struct A {
+  typedef int BASE_VALUE;
+};
+
+void g(int &y) {}
+
+template 
+void f(int &rValue) {
+#if MSVC
+// expected-warning@+4 {{missing 'typename' prior to dependent type name 'BASE_CLASS::BASE_VALUE'}}
+#else
+  // expected-error@+2 {{expected expression}}
+#endif
+  return g((BASE_CLASS::BASE_VALUE &)rValue);
+}
+
+int main() {
+  int x;
+  f(x);
+  return 0;
+}
+} // namespace PR8446_1
+
+
+namespace PR8446_2 {
+struct site_symmetry_ops {};
+
+template 
+struct class_ {
+  template 
+  void def(A1 const &a1) {}
+};
+
+template 
+struct init {
+  init() {}
+};
+
+struct special_position_site_parameter {
+  typedef char scatterer_type;
+};
+
+template 
+struct valued_asu_parameter_heir_wrapper {
+  static class_ wrap(char const *name) {
+return class_();
+  }
+};
+
+template 
+struct special_position_wrapper {
+  static void wrap(char const *name) {
+valued_asu_parameter_heir_wrapper::wrap(name)
+#if MSVC
+// expected-warning@+4 {{missing 'typename' prior to dependent type name 'wt::scatterer_type'}}
+#else
+// expected-error@+2 {{expected expression}}
+#endif
+.def(init());
+  }
+};
+
+void wrap_special_position() {
+  special_position_wrapper::wrap("special_position_site_parameter");
+}
+} // namespace PR8446_2
+
+namespace PR8446_3 {
+int g(int);
+template 
+int f1(int x) {
+  return g((T::InnerName & x) & x);
+}
+
+template 
+int f2(int x) {
+  return g((T::InnerName & 3) & x);
+}
+
+template 
+int f3(int x) {
+  return g((T::InnerName & (3)));
+}
+
+template 
+int f4(int x) {
+  return g((T::InnerName * 3) & x);
+}
+struct A {
+  static const int InnerName = 42;
+};
+int main() {
+  f1(0);
+  f2(0);
+  f3(0);
+  return f4(0);
+}
+} // namespace PR8446_3
Index: lib/Parse/ParseTentative.cpp
===
--- lib/Parse/ParseTentative.cpp
+++ lib/Parse/ParseTentative.cpp
@@ -1498,6 +1498,17 @@
 // expression.
 *HasMissingTypename = true;
 return TPResult::Ambiguous;
+  } else {
+// In MS mode, if HasMissingTypename is not provided, and the tokens
+// are or the form *) or &) *> or &> &&>, this can't be an expression.
+// The typename must be missing.
+if (getLangOpts().MSVCCompat) {
+  if (((Tok.is(tok::amp) || Tok.is(tok::star)) &&
+   (NextToken().is(tok::r_paren) ||
+NextToken().is(tok::greater))) ||
+  (Tok.is(tok::ampamp) && NextToken().is(tok::greater)))
+return TPResult::True;
+}
   }
 } else {
   // Try to resolve the name. If it doesn't exist, assume it was
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2019-02-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I had to revert this in rL354839  because 
one of the tests didn't pass on Windows:
http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/4641


Repository:
  rL LLVM

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

https://reviews.llvm.org/D58292



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


[PATCH] D41950: Fix for Bug 8446. Template instantiation without a 'typename' keyword.

2019-02-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D41950#1409332 , @zahiraam wrote:

> I don't think I have commit right can you please commit it. Thanks.


Sure, done!


Repository:
  rC Clang

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

https://reviews.llvm.org/D41950



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


[PATCH] D58530: Add PragmaHandler for MSVC pragma execution_character_set

2019-02-25 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Looks good and thorough, but it needs tests.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58530



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


[PATCH] D37994: Implement LWG2946: More ambiguity in `string` vs. `string_view`

2019-02-25 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists abandoned this revision.
mclow.lists added a comment.
Herald added a subscriber: jdoerfert.

This appears to have been applied in a slightly different form. Certainly the 
functionality is there. Closing.


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

https://reviews.llvm.org/D37994



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


r354832 - [ASTImporter] Add support for importing ChooseExpr AST nodes.

2019-02-25 Thread Tom Roeder via cfe-commits
Author: tmroeder
Date: Mon Feb 25 15:24:58 2019
New Revision: 354832

URL: http://llvm.org/viewvc/llvm-project?rev=354832&view=rev
Log:
[ASTImporter] Add support for importing ChooseExpr AST nodes.

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

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

Reviewers: shafik, a_sidorin, martong, aaron.ballman

Subscribers: aaron.ballman, rnkovacs, jdoerfert, cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/ASTMerge/choose-expr/
cfe/trunk/test/ASTMerge/choose-expr/Inputs/
cfe/trunk/test/ASTMerge/choose-expr/Inputs/choose.c
cfe/trunk/test/ASTMerge/choose-expr/test.c
Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/AST/ASTImporterTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=354832&r1=354831&r2=354832&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Mon Feb 25 15:24:58 2019
@@ -788,6 +788,11 @@ Example matches 'a', L'a'
 
 
 
+MatcherStmt>chooseExprMatcherChooseExpr>...
+Matches GNU 
__builtin_choose_expr.
+
+
+
 MatcherStmt>compoundLiteralExprMatcherCompoundLiteralExpr>...
 Matches 
compound (i.e. non-scalar) literals
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=354832&r1=354831&r2=354832&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Feb 25 15:24:58 2019
@@ -2158,6 +2158,10 @@ extern const internal::VariadicDynCastAl
 extern const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
 
+/// Matches GNU __builtin_choose_expr.
+extern const internal::VariadicDynCastAllOfMatcher
+chooseExpr;
+
 /// Matches GNU __null expression.
 extern const internal::VariadicDynCastAllOfMatcher
 gnuNullExpr;

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=354832&r1=354831&r2=354832&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Mon Feb 25 15:24:58 2019
@@ -552,6 +552,7 @@ namespace clang {
 // Importing expressions
 ExpectedStmt VisitExpr(Expr *E);
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
+ExpectedStmt VisitChooseExpr(ChooseExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
 ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
 ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E);
@@ -6135,6 +6136,33 @@ ExpectedStmt ASTNodeImporter::VisitVAArg
   E->isMicrosoftABI());
 }
 
+ExpectedStmt ASTNodeImporter::VisitChooseExpr(ChooseExpr *E) {
+  auto Imp = importSeq(E->getCond(), E->getLHS(), E->getRHS(),
+   E->getBuiltinLoc(), E->getRParenLoc(), E->getType());
+  if (!Imp)
+return Imp.takeError();
+
+  Expr *ToCond;
+  Expr *ToLHS;
+  Expr *ToRHS;
+  SourceLocation ToBuiltinLoc, ToRParenLoc;
+  QualType ToType;
+  std::tie(ToCond, ToLHS, ToRHS, ToBuiltinLoc, ToRParenLoc, ToType) = *Imp;
+
+  ExprValueKind VK = E->getValueKind();
+  ExprObjectKind OK = E->getObjectKind();
+
+  bool TypeDependent = ToCond->isTypeDependent();
+  bool ValueDependent = ToCond->isValueDependent();
+
+  // The value of CondIsTrue only matters if the value is not
+  // condition-dependent.
+  bool CondIsTrue = !E->isConditionDependent() && E->isConditionTrue();
+
+  return new (Importer.getToContext())
+  ChooseExpr(ToBuiltinLoc, ToCond, ToLHS, ToRHS, ToType, VK, OK,
+ ToRParenLoc, CondIsTrue, TypeDependent, ValueDependent);
+}
 
 ExpectedStmt ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) {
   ExpectedType TypeOrErr = import(E->getType());

Modified: cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp
URL: 
http://llvm.

r354843 - [CGDebugInfo] Set NonTrivial DIFlag to a c++ record if it's not trivial

2019-02-25 Thread Aaron Smith via cfe-commits
Author: asmith
Date: Mon Feb 25 19:49:05 2019
New Revision: 354843

URL: http://llvm.org/viewvc/llvm-project?rev=354843&view=rev
Log:
[CGDebugInfo] Set NonTrivial DIFlag to a c++ record if it's not trivial

This goes with https://reviews.llvm.org/D44406


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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=354843&r1=354842&r2=354843&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Feb 25 19:49:05 2019
@@ -3031,6 +3031,8 @@ llvm::DICompositeType *CGDebugInfo::Crea
 // Record if a C++ record is trivial type.
 if (CXXRD->isTrivial())
   Flags |= llvm::DINode::FlagTrivial;
+else
+  Flags |= llvm::DINode::FlagNonTrivial;
   }
 
   llvm::DICompositeType *RealDecl = DBuilder.createReplaceableCompositeType(


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


[PATCH] D52956: Support `-fno-visibility-inlines-hidden`

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

I tried committing this for you, but it doesn't apply to master. Could you 
rebase?


Repository:
  rC Clang

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

https://reviews.llvm.org/D52956



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


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

2019-02-25 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder created this revision.
tmroeder added reviewers: shafik, a_sidorin, martong, aaron.ballman, rnk.
tmroeder added a project: clang.
Herald added a reviewer: a.sidorin.

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

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

This was originally reviewed and approved in
https://reviews.llvm.org/D58292 and submitted as r354832. It was
reverted in r354839 due to failures on the Windows CI builds.

This version fixes the test failures on Windows, caused by differences
in the behavior of -fms-compatibility between Linux and MSVC builds. In
MSVC builds, -fms-compatibility delays template evaluation for the C++
test case in clang/unittests/AST/ASTImporter.cpp, and that causes the
matcher to fail to match chooseExpr().

The only difference between this patch and r354839 is that the unit test
now checks for "-fms-compatibility" and treats it like
"-fdelayed-template-parsing": it doesn't try to match chooseExpr().


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58663

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

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -754,6 +754,11 @@
   EXPECT_TRUE(matches("int* i = nullptr;", cxxNullPtrLiteralExpr()));
 }
 
+TEST(Matcher, ChooseExpr) {
+  EXPECT_TRUE(matchesC("void f() { (void)__builtin_choose_expr(1, 2, 3); }",
+   chooseExpr()));
+}
+
 TEST(Matcher, GNUNullExpr) {
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -563,6 +563,36 @@
   stringLiteral(hasType(asString("const char [7]"));
 }
 
+TEST_P(ImportExpr, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  // This case tests C code that is not condition-dependent and has a true
+  // condition.
+  testImport(
+"void declToImport() { (void)__builtin_choose_expr(1, 2, 3); }",
+Lang_C, "", Lang_C, Verifier,
+functionDecl(hasDescendant(chooseExpr(;
+
+  ArgVector Args = getExtraArgs();
+  BindableMatcher Matcher =
+  functionTemplateDecl(hasDescendant(chooseExpr()));
+
+  // Don't try to match the template contents if template parsing. The
+  // -fms-compatibility flag delays template parsing on Windows.
+  if (llvm::find(Args, "-fdelayed-template-parsing") != Args.end() ||
+  llvm::find(Args, "-fms-compatibility") != Args.end()) {
+Matcher = functionTemplateDecl();
+  }
+
+  // Make sure that uses of (void)__builtin_choose_expr with dependent types in
+  // the condition are handled properly. This test triggers an assertion if the
+  // ASTImporter incorrectly tries to access isConditionTrue() when
+  // isConditionDependent() is true.
+  testImport("template void declToImport() { "
+ "(void)__builtin_choose_expr(N, 1, 0); }",
+ Lang_CXX, "", Lang_CXX, Verifier, Matcher);
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1312,6 +1342,27 @@
   ASSERT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportChooseExpr) {
+  // This tests the import of isConditionTrue directly to make sure the importer
+  // gets it right.
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+"void declToImport() { (void)__builtin_choose_expr(1, 0, 1); }",
+Lang_C, "", Lang_C);
+
+  auto ToResults = match(chooseExpr().bind("choose"), To->getASTContext());
+  auto FromResults = match(chooseExpr().bind("choose"), From->getASTContext());
+
+  const ChooseExpr *FromChooseExpr =
+  selectFirst("choose", FromResults);
+  ASSERT_TRUE(FromChooseExpr);
+
+  const ChooseExpr *ToChooseExpr = selectFirst("choose", ToResults);
+  ASSERT_TRUE(ToChooseExpr);
+
+  EXPECT_EQ(FromChooseExpr->isConditionTrue(), ToChooseExpr->isConditionTrue());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportFunctionWithBackReferringParameter) {
   Decl *From, *To;
Index: clang/test/ASTMerge/choose-expr/test.c
===
--- /dev/null
+++ clang/

[PATCH] D58514: Avoid needlessly copying blocks that initialize or are assigned to local auto variables to the heap

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

Okay, one last minor request, then LGTM.




Comment at: lib/CodeGen/CGObjC.cpp:2953
+  return asImpl().visitExpr(e);
+}
+

Oh, I'd forgotten this wasn't a normal expression visitor.  Well, okay, this 
isn't too bad.



Comment at: lib/Sema/SemaExpr.cpp:12461
+  if (auto *BE = dyn_cast(RHS.get()->IgnoreParens()))
+if (auto *DRE = dyn_cast(LHS.get()))
+  if (auto *VD = dyn_cast(DRE->getDecl()))

You should `IgnoreParens` on the LHS as well.  In general, you should always 
`IgnoreParens`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D58514



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


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

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

Dropped the C++ part of the ImportChooseExpr test entirely.

This is the part that was breaking the tests on Windows, and after further 
experimentation, it turns out that clang on Windows never expands the template 
under the conditions of the test. Dropping this test doesn't reduce coverage of 
the logic regression discussed in the original review. This is explained in the 
revised summary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58663

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

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -754,6 +754,11 @@
   EXPECT_TRUE(matches("int* i = nullptr;", cxxNullPtrLiteralExpr()));
 }
 
+TEST(Matcher, ChooseExpr) {
+  EXPECT_TRUE(matchesC("void f() { (void)__builtin_choose_expr(1, 2, 3); }",
+   chooseExpr()));
+}
+
 TEST(Matcher, GNUNullExpr) {
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -563,6 +563,17 @@
   stringLiteral(hasType(asString("const char [7]"));
 }
 
+TEST_P(ImportExpr, ImportChooseExpr) {
+  MatchVerifier Verifier;
+
+  // This case tests C code that is not condition-dependent and has a true
+  // condition.
+  testImport(
+"void declToImport() { (void)__builtin_choose_expr(1, 2, 3); }",
+Lang_C, "", Lang_C, Verifier,
+functionDecl(hasDescendant(chooseExpr(;
+}
+
 TEST_P(ImportExpr, ImportGNUNullExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1312,6 +1323,27 @@
   ASSERT_EQ(ToTemplated1, ToTemplated);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportChooseExpr) {
+  // This tests the import of isConditionTrue directly to make sure the importer
+  // gets it right.
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+"void declToImport() { (void)__builtin_choose_expr(1, 0, 1); }",
+Lang_C, "", Lang_C);
+
+  auto ToResults = match(chooseExpr().bind("choose"), To->getASTContext());
+  auto FromResults = match(chooseExpr().bind("choose"), From->getASTContext());
+
+  const ChooseExpr *FromChooseExpr =
+  selectFirst("choose", FromResults);
+  ASSERT_TRUE(FromChooseExpr);
+
+  const ChooseExpr *ToChooseExpr = selectFirst("choose", ToResults);
+  ASSERT_TRUE(ToChooseExpr);
+
+  EXPECT_EQ(FromChooseExpr->isConditionTrue(), ToChooseExpr->isConditionTrue());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportFunctionWithBackReferringParameter) {
   Decl *From, *To;
Index: clang/test/ASTMerge/choose-expr/test.c
===
--- /dev/null
+++ clang/test/ASTMerge/choose-expr/test.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c11 -emit-pch -o %t.ast %S/Inputs/choose.c
+// RUN: %clang_cc1 -std=c11 -ast-merge %t.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
Index: clang/test/ASTMerge/choose-expr/Inputs/choose.c
===
--- /dev/null
+++ clang/test/ASTMerge/choose-expr/Inputs/choose.c
@@ -0,0 +1,2 @@
+_Static_assert(__builtin_choose_expr(1, 1, 0), "Incorrect semantics of __builtin_choose_expr");
+_Static_assert(__builtin_choose_expr(0, 0, 1), "Incorrect semantics of __builtin_choose_expr");
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -147,6 +147,7 @@
   REGISTER_MATCHER(caseStmt);
   REGISTER_MATCHER(castExpr);
   REGISTER_MATCHER(characterLiteral);
+  REGISTER_MATCHER(chooseExpr);
   REGISTER_MATCHER(classTemplateDecl);
   REGISTER_MATCHER(classTemplateSpecializationDecl);
   REGISTER_MATCHER(complexType);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -727,6 +727,7 @@
 compoundLiteralExpr;
 const internal::VariadicDynCastAllOfMatcher
 cxxNullPtrLiteralExpr;
+const internal::VariadicDynCastAllOfMatcher chooseExpr;
 const internal::VariadicDynCastAllOfMatcher gnuNullExpr;
 const

[PATCH] D58634: [PR40778] Generate address space conversion when binding reference to a temporary value in different address space

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



Comment at: lib/CodeGen/CGCall.cpp:4067
+  IRFuncTy->getParamType(FirstIRArg)->isPointerTy())
+V = Builder.CreatePointerBitCastOrAddrSpaceCast(
+V, IRFuncTy->getParamType(FirstIRArg));

Anastasia wrote:
> We have started using `performAddrSpaceCast` for those but, however, I was 
> very confused about how to get address space of the Clang types correctly 
> here.
> 
> I was using this function in a couple of places before but I must admit I am 
> still a bit confused about the purpose of it. Mainly I was wondering if we 
> could drop `LangAS` parameters from it? It would simplify its use a lot in 
> multiple places. As far as I can see they are not used in the function at the 
> moment. I am not sure if they are reserved for some development in the future 
> though?
> 
> Altogether I quite like using `IRBuilder` directly because in combination 
> with target address space map it allows to do what's needed here and keep 
> consistent with the rest. Perhaps, I am missing some background info. I have 
> tried to dig out a bit but no much success.
We want to allow language address spaces to be arbitrarily mapped to IR address 
spaces during lowering, which might include e.g. changing the null value.  
That's why we pass language address spaces down.

You should be getting the language address space from the appropriate type.  I 
wouldn't expect that to include address-space conversions at this point, 
though; is there maybe a missing implicit conversions somewhere?


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

https://reviews.llvm.org/D58634



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


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

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

In D56411#1406212 , @yaxunl wrote:

> I would like to fix the validation issue only and leave the overload 
> resolution issue for future.


As I understand it, the "validation issue" is just that you'd like a diagnostic 
to be emitted when resolving the template argument in order to force SFINAE to 
pick a different template.  I think that's actually just the 
overload-resolution issue.


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

https://reviews.llvm.org/D56411



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


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

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



Comment at: clang/include/clang/Driver/Options.td:1250
+  Group, Flags<[CC1Option]>,
+  HelpText<"Use the unstable C++ class ABI for classes with hidden LTO 
visibility">;
 def flto_jobs_EQ : Joined<["-"], "flto-jobs=">,

Please make this a `-cc1` option or otherwise mark it clearly experimental.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321



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


[PATCH] D58569: [libclang] Avoid crashing when getting layout info of an undeduced type.

2019-02-25 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio marked 2 inline comments as done.
emilio added a comment.

Huh, somehow forgot to press "Submit" this morning :)




Comment at: clang/tools/c-index-test/c-index-test.c:1695
+CXType RT = clang_getResultType(T);
+if (RT.kind != CXType_Invalid)
+  PrintSingleTypeSize(RT, " [resulttype=%s] [resulttypekind=%s]",

Anastasia wrote:
> emilio wrote:
> > Anastasia wrote:
> > > Should it not return undeduced error in the other case?
> > I'm not sure what you mean, can you clarify?
> > 
> > The undeduced error is only returned when you try to access the `Auto` type 
> > which is the return value, not the function type, which has a known layout.
> > 
> > So in the error case, `T` here is the `auto Tie(void*) const;` type, and 
> > `RT` is the undeduced `auto` type, which is what crashed.
> > 
> > We had no way to exercise this in `c-index-test`, so I changed it to 
> > exercise this codepath too. I can add a `CHECK` for the error code if you 
> > want.
> Yep, error check would be good since it's covers better changes in your patch.
Alrighty, done!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58569



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


[PATCH] D58609: [clang-tidy] bugprone-string-integer-assignment: Reduce false positives.

2019-02-25 Thread Clement Courbet via Phabricator via cfe-commits
courbet updated this revision to Diff 188316.
courbet added a comment.

- more tests


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58609

Files:
  clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
  test/clang-tidy/bugprone-string-integer-assignment.cpp


Index: test/clang-tidy/bugprone-string-integer-assignment.cpp
===
--- test/clang-tidy/bugprone-string-integer-assignment.cpp
+++ test/clang-tidy/bugprone-string-integer-assignment.cpp
@@ -59,4 +59,11 @@
   s += toupper(x);
   s += tolower(x);
   s += std::tolower(x);
+
+  // Likely character expressions.
+  s += x & 0xff;
+  s += 0xff & x;
+
+  s += 'a' + (x % 26);
+  s += (x % 10) + 'b';
 }
Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -40,11 +40,44 @@
   this);
 }
 
+static bool isLikelyCharExpression(const Expr *Argument,
+   const ASTContext &Ctx) {
+  const auto *BinOp = dyn_cast(Argument);
+  if (!BinOp) {
+return false;
+  }
+  const auto *LHS = BinOp->getLHS()->IgnoreParenImpCasts();
+  const auto *RHS = BinOp->getRHS()->IgnoreParenImpCasts();
+  //  & , mask is a compile time constant.
+  Expr::EvalResult RHSVal;
+  if (BinOp->getOpcode() == BO_And &&
+  (RHS->EvaluateAsInt(RHSVal, Ctx, Expr::SE_AllowSideEffects) ||
+   LHS->EvaluateAsInt(RHSVal, Ctx, Expr::SE_AllowSideEffects))) {
+return true;
+  }
+  //  + ( % ), where  is a char literal.
+  const auto IsCharPlusModExpr = [](const Expr *L, const Expr *R) {
+const auto *ROp = dyn_cast(R);
+return ROp && ROp->getOpcode() == BO_Rem && isa(L);
+  };
+  if (BinOp->getOpcode() == BO_Add) {
+if (IsCharPlusModExpr(LHS, RHS) || IsCharPlusModExpr(RHS, LHS)) {
+  return true;
+}
+  }
+  return false;
+}
+
 void StringIntegerAssignmentCheck::check(
 const MatchFinder::MatchResult &Result) {
   const auto *Argument = Result.Nodes.getNodeAs("expr");
   SourceLocation Loc = Argument->getBeginLoc();
 
+  // Try to detect a few common expressions to reduce false positives.
+  if (isLikelyCharExpression(Argument, *Result.Context)) {
+return;
+  }
+
   auto Diag =
   diag(Loc, "an integer is interpreted as a character code when assigning "
 "it to a string; if this is intended, cast the integer to the "


Index: test/clang-tidy/bugprone-string-integer-assignment.cpp
===
--- test/clang-tidy/bugprone-string-integer-assignment.cpp
+++ test/clang-tidy/bugprone-string-integer-assignment.cpp
@@ -59,4 +59,11 @@
   s += toupper(x);
   s += tolower(x);
   s += std::tolower(x);
+
+  // Likely character expressions.
+  s += x & 0xff;
+  s += 0xff & x;
+
+  s += 'a' + (x % 26);
+  s += (x % 10) + 'b';
 }
Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -40,11 +40,44 @@
   this);
 }
 
+static bool isLikelyCharExpression(const Expr *Argument,
+   const ASTContext &Ctx) {
+  const auto *BinOp = dyn_cast(Argument);
+  if (!BinOp) {
+return false;
+  }
+  const auto *LHS = BinOp->getLHS()->IgnoreParenImpCasts();
+  const auto *RHS = BinOp->getRHS()->IgnoreParenImpCasts();
+  //  & , mask is a compile time constant.
+  Expr::EvalResult RHSVal;
+  if (BinOp->getOpcode() == BO_And &&
+  (RHS->EvaluateAsInt(RHSVal, Ctx, Expr::SE_AllowSideEffects) ||
+   LHS->EvaluateAsInt(RHSVal, Ctx, Expr::SE_AllowSideEffects))) {
+return true;
+  }
+  //  + ( % ), where  is a char literal.
+  const auto IsCharPlusModExpr = [](const Expr *L, const Expr *R) {
+const auto *ROp = dyn_cast(R);
+return ROp && ROp->getOpcode() == BO_Rem && isa(L);
+  };
+  if (BinOp->getOpcode() == BO_Add) {
+if (IsCharPlusModExpr(LHS, RHS) || IsCharPlusModExpr(RHS, LHS)) {
+  return true;
+}
+  }
+  return false;
+}
+
 void StringIntegerAssignmentCheck::check(
 const MatchFinder::MatchResult &Result) {
   const auto *Argument = Result.Nodes.getNodeAs("expr");
   SourceLocation Loc = Argument->getBeginLoc();
 
+  // Try to detect a few common expressions to reduce false positives.
+  if (isLikelyCharExpression(Argument, *Result.Context)) {
+return;
+  }
+
   auto Diag =
   diag(Loc, "an integer is interpreted as a character code when assigning "
 "it to a string; if this is intended, cast the integer to the "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r354765 - [clangd] Add thread priority lowering for MacOS as well

2019-02-25 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Mon Feb 25 01:19:26 2019
New Revision: 354765

URL: http://llvm.org/viewvc/llvm-project?rev=354765&view=rev
Log:
[clangd] Add thread priority lowering for MacOS as well

Reviewers: ilya-biryukov

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

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clangd/Threading.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Threading.cpp?rev=354765&r1=354764&r2=354765&view=diff
==
--- clang-tools-extra/trunk/clangd/Threading.cpp (original)
+++ clang-tools-extra/trunk/clangd/Threading.cpp Mon Feb 25 01:19:26 2019
@@ -7,6 +7,8 @@
 #include 
 #ifdef __USE_POSIX
 #include 
+#elif defined(__APPLE__)
+#include 
 #endif
 
 namespace clang {
@@ -121,6 +123,12 @@ void setCurrentThreadPriority(ThreadPrio
   Priority == ThreadPriority::Low && !AvoidThreadStarvation ? SCHED_IDLE
 : SCHED_OTHER,
   &priority);
+#elif defined(__APPLE__)
+  // 
https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpriority.2.html
+  setpriority(PRIO_DARWIN_THREAD, 0,
+  Priority == ThreadPriority::Low && !AvoidThreadStarvation
+  ? PRIO_DARWIN_BG
+  : 0);
 #endif
 }
 


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


[PATCH] D58492: [clangd] Add thread priority lowering for MacOS as well

2019-02-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE354765: [clangd] Add thread priority lowering for MacOS as 
well (authored by kadircet, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58492?vs=187908&id=188106#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58492

Files:
  clangd/Threading.cpp


Index: clangd/Threading.cpp
===
--- clangd/Threading.cpp
+++ clangd/Threading.cpp
@@ -7,6 +7,8 @@
 #include 
 #ifdef __USE_POSIX
 #include 
+#elif defined(__APPLE__)
+#include 
 #endif
 
 namespace clang {
@@ -121,6 +123,12 @@
   Priority == ThreadPriority::Low && !AvoidThreadStarvation ? SCHED_IDLE
 : SCHED_OTHER,
   &priority);
+#elif defined(__APPLE__)
+  // 
https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpriority.2.html
+  setpriority(PRIO_DARWIN_THREAD, 0,
+  Priority == ThreadPriority::Low && !AvoidThreadStarvation
+  ? PRIO_DARWIN_BG
+  : 0);
 #endif
 }
 


Index: clangd/Threading.cpp
===
--- clangd/Threading.cpp
+++ clangd/Threading.cpp
@@ -7,6 +7,8 @@
 #include 
 #ifdef __USE_POSIX
 #include 
+#elif defined(__APPLE__)
+#include 
 #endif
 
 namespace clang {
@@ -121,6 +123,12 @@
   Priority == ThreadPriority::Low && !AvoidThreadStarvation ? SCHED_IDLE
 : SCHED_OTHER,
   &priority);
+#elif defined(__APPLE__)
+  // https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/getpriority.2.html
+  setpriority(PRIO_DARWIN_THREAD, 0,
+  Priority == ThreadPriority::Low && !AvoidThreadStarvation
+  ? PRIO_DARWIN_BG
+  : 0);
 #endif
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-02-25 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro marked an inline comment as done.
djtodoro added a comment.

> I'm not quite sure what this differential is about, but i feel like 
> mentioning ExprMutationAnalyzer lib in clang-tidy / clang-tools-extra.



>> Alternatively perhaps you could re-use getMemoryLocation() from D57660 
>> . It would handle for you members, 
>> references, structured bindings +more in a relatively self-contained code.

@lebedev.ri, @riccibruno Thanks for your advices! We'll check this also.




Comment at: lib/Sema/SemaExpr.cpp:11301
+EmitArgumentsValueModification(E);
+
   SourceLocation OrigLoc = Loc;

lebedev.ri wrote:
> riccibruno wrote:
> > Comments:
> > 
> > 1. Shouldn't you mark the variable to be modified only if 
> > `CheckForModifiableLvalue` returns true ?
> > 
> > 2. I think that you need to handle way more than just member expressions. 
> > For example are you handling `(x, y)` (comma operator) ? But hard-coding 
> > every cases here is probably not ideal. It would be nice if there was 
> > already some code somewhere that could help you do this.
> > 
> > 3. I believe that a `MemberExpr` has always a base. Similarly 
> > `DeclRefExpr`s always have a referenced declaration (so you can omit the 
> > `if`).
> I'm not quite sure what this differential is about, but i feel like 
> mentioning ExprMutationAnalyzer lib in clang-tidy / clang-tools-extra.
@riccibruno Please find inlined replies:

>1. Shouldn't you mark the variable to be modified only if 
>CheckForModifiableLvalue returns true ?

Hmm, we should avoid marking variables modification if this emits an error. 
But, we should emit it if `CheckForModifiableLvalue ` returns `false`, since in 
the case of returning `true` an error will be emitted.

>2. I think that you need to handle way more than just member expressions. For 
>example are you handling (x, y) (comma operator) ? But hard-coding every cases 
>here is probably not ideal. It would be nice if there was already some code 
>somewhere that could help you do this.

Hard coding all cases is not good idea. I agree. Since we are only looking for 
declaration references, we could make just a function that traverses any `Expr` 
and find declaration ref.

>3. I believe that a MemberExpr has always a base. Similarly DeclRefExprs 
>always have a referenced declaration (so you can omit the if).

I think you are right. Thanks!




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

https://reviews.llvm.org/D58035



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


[PATCH] D57883: [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-25 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added subscribers: dyung, bjope.
bjope added inline comments.
Herald added a subscriber: Charusso.



Comment at: clang-tidy/utils/ExceptionAnalyzer.h:112
+/// throw, if it's unknown or if it won't throw.
+enum State Behaviour : 2;
+

(post-commit comments)

I've seen that @dyung did some VS2015 fixes related to this in 
https://reviews.llvm.org/rCTE354545.

But I think there also is some history of problems with typed enums used in 
bitfields with GCC (I'm not sure about the details, but it might be discussed 
here https://reviews.llvm.org/D24289, and there have been workarounds applied 
before, for example here https://reviews.llvm.org/rCTE319608).

I do not know if we actually have a goal to workaround such problems (no 
warnings when using GCC), nor do I know if GCC produce correct code despite all 
the warnings we see with GCC (7.4.0) after this patch, such as

```
../tools/clang/tools/extra/clang-tidy/bugprone/../utils/ExceptionAnalyzer.h:112:23:
 warning: 'clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::Behaviour' is 
too small to hold all values of 'enum class 
clang::tidy::utils::ExceptionAnalyzer::State'
  State Behaviour : 2;
^
../tools/clang/tools/extra/clang-tidy/bugprone/../utils/ExceptionAnalyzer.h:112:23:
 warning: 'clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::Behaviour' is 
too small to hold all values of 'enum class 
clang::tidy::utils::ExceptionAnalyzer::State'
 State Behaviour : 2;
   ^
In file included from 
../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.cpp:9:0:
../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.h:112:23: 
warning: 'clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::Behaviour' is 
too small to hold all values of 'enum class 
clang::tidy::utils::ExceptionAnalyzer::State'
 State Behaviour : 2;
   ^
../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.cpp: In member 
function 'clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo& 
clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::merge(const 
clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo&)':
../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.cpp:40:28: 
warning: comparison is always false due to limited range of data type 
[-Wtype-limits]
   else if (Other.Behaviour == State::Unknown && Behaviour == 
State::NotThrowing)
^~~~
../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.cpp:41:24: 
warning: overflow in implicit constant conversion [-Woverflow]
 Behaviour = State::Unknown;
^~~
../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.cpp: In member 
function 'void 
clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::reevaluateBehaviour()':
../tools/clang/tools/extra/clang-tidy/utils/ExceptionAnalyzer.cpp:105:26: 
warning: overflow in implicit constant conversion [-Woverflow]
   Behaviour = State::Unknown;
  ^~~
```

To sum up:
The warning are a little bit annoying (but maybe something we have to live with 
if this is known bugs in gcc).
It seems like we have done other workarounds in the past (writing ugly code to 
satisfy MSVC and GCC). So should we do that here as well?
Might wanna check if GCC produce correct code for this.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57883



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


[PATCH] D57883: [clang-tidy] refactor ExceptionAnalyzer further to give ternary answer

2019-02-25 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a subscriber: sammccall.
bjope added a comment.

Maybe @sammccall remembers why it was decided to rewrite the enum into 
constexpr:s in https://reviews.llvm.org/rCTE319608 ? Do we need a similar 
solution here?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D57883



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


[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

2019-02-25 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 188110.
djtodoro added a comment.
Herald added a subscriber: jdoerfert.

- Handle all kinds of expressions when mark a param's modification


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

https://reviews.llvm.org/D58035

Files:
  include/clang/AST/Decl.h
  lib/CodeGen/CGDebugInfo.cpp
  lib/Sema/SemaExpr.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGen/dbginfo-var-change-templates.cpp
  test/CodeGen/debug-info-varchange.c

Index: test/CodeGen/debug-info-varchange.c
===
--- /dev/null
+++ test/CodeGen/debug-info-varchange.c
@@ -0,0 +1,35 @@
+// RUN: %clang -femit-param-entry-values -emit-llvm -S -g %s -o - | FileCheck %s
+
+// CHECK: !DILocalVariable(name: "a", arg: 1, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+// CHECK: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "test_s", arg: 3, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+// CHECK: !DILocalVariable(name: "test_s2", arg: 4, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "x", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "y", scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+
+typedef struct s {
+  int m;
+  int n;
+}S;
+
+void foo (int a, int b,
+  S test_s, S test_s2)
+{
+  b++;
+  b = a + 1;
+  if (b>4)
+test_s2.m = 434;
+}
+
+int main()
+{
+  S test_s = {4, 5};
+
+  int x = 5;
+  int y = 6;
+
+  foo(x , y, test_s, test_s);
+
+  return 0;
+}
+
Index: test/CodeGen/dbginfo-var-change-templates.cpp
===
--- /dev/null
+++ test/CodeGen/dbginfo-var-change-templates.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang -femit-param-entry-values -emit-llvm -S -g %s -o - | FileCheck %s
+// CHECK: !DILocalVariable(name: "a", arg: 1, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
+// CHECK: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
+
+template 
+__attribute__((noinline))
+T GetMin (T a, T b) {
+  T result;
+  ++a;
+  result = (a < b) ? a : b;
+  return result;
+}
+
+int baa () {
+  int i=5, j=6, k;
+  k=GetMin(i,j);
+
+  if (i == k)
+++k;
+  else
+--k;
+
+  return k;
+}
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -1033,6 +1033,7 @@
   Record.push_back(D->hasUninstantiatedDefaultArg());
   if (D->hasUninstantiatedDefaultArg())
 Record.AddStmt(D->getUninstantiatedDefaultArg());
+  Record.push_back(D->isArgumentKnownToBeModified());
   Code = serialization::DECL_PARM_VAR;
 
   assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
@@ -1046,6 +1047,7 @@
   !D->isImplicit() &&
   !D->isUsed(false) &&
   !D->isInvalidDecl() &&
+  !D->isArgumentKnownToBeModified() &&
   !D->isReferenced() &&
   D->getAccess() == AS_none &&
   !D->isModulePrivate() &&
@@ -2011,6 +2013,7 @@
   Abv->Add(BitCodeAbbrevOp(0));   // KNRPromoted
   Abv->Add(BitCodeAbbrevOp(0));   // HasInheritedDefaultArg
   Abv->Add(BitCodeAbbrevOp(0));   // HasUninstantiatedDefaultArg
+  Abv->Add(BitCodeAbbrevOp(0));   // IsArgumentKnownToBeModified
   // Type Source Info
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // TypeLoc
Index: lib/Serialization/ASTReaderDecl.cpp
===
--- lib/Serialization/ASTReaderDecl.cpp
+++ lib/Serialization/ASTReaderDecl.cpp
@@ -1441,7 +1441,7 @@
   PD->ParmVarDeclBits.HasInheritedDefaultArg = Record.readInt();
   if (Record.readInt()) // hasUninstantiatedDefaultArg.
 PD->setUninstantiatedDefaultArg(Record.readExpr());
-
+  PD->ParmVarDeclBits.IsArgumentKnownToBeModified = Record.readInt();
   // FIXME: If this is a redeclaration of a function from another module, handle
   // inheritance of default arguments.
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -16,6 +16,7 @@
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/ASTMutationListener.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -11276,6 +11277,30 @@
 DiagnoseConstAssignment(S, E, Loc);
 }
 
+/// Traverse an expression and find declaration ref, if any.
+static bool HasDeclRef(const E

[PATCH] D58600: [clangd] Emit source to Diagnostic.

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

Set "clang", "clang-tidy" as the source to the diagnostics, so that
client can distinguish diagnostics from clang-tidy.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58600

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

Index: unittests/clangd/DiagnosticsTests.cpp
===
--- unittests/clangd/DiagnosticsTests.cpp
+++ unittests/clangd/DiagnosticsTests.cpp
@@ -58,6 +58,10 @@
  std::tie(LSPDiag.range, LSPDiag.severity, LSPDiag.message);
 }
 
+MATCHER_P(DiagSource, Source, "") {
+  return arg.Source == Source;
+}
+
 MATCHER_P(EqualToFix, Fix, "LSP fix " + llvm::to_string(Fix)) {
   if (arg.Message != Fix.Message)
 return false;
@@ -102,6 +106,7 @@
   // This range spans lines.
   AllOf(Diag(Test.range("typo"),
  "use of undeclared identifier 'goo'; did you mean 'foo'?"),
+DiagSource("clang"),
 WithFix(
 Fix(Test.range("typo"), "foo", "change 'go\\ o' to 'foo'")),
 // This is a pretty normal range.
@@ -159,6 +164,7 @@
   AllOf(Diag(Test.range("deprecated"),
  "inclusion of deprecated C++ header 'assert.h'; consider "
  "using 'cassert' instead [modernize-deprecated-headers]"),
+DiagSource("clang-tidy"),
 WithFix(Fix(Test.range("deprecated"), "",
 "change '\"assert.h\"' to ''"))),
   Diag(Test.range("doubled"),
@@ -168,6 +174,7 @@
   Diag(Test.range("macroarg"),
"side effects in the 1st macro argument 'X' are repeated in "
"macro expansion [bugprone-macro-repeated-side-effects]"),
+  DiagSource("clang-tidy"),
   WithNote(Diag(Test.range("macrodef"),
 "macro 'SQUARE' defined here "
 "[bugprone-macro-repeated-side-effects]"))),
Index: test/clangd/fixits-embed-in-diagnostic.test
===
--- test/clangd/fixits-embed-in-diagnostic.test
+++ test/clangd/fixits-embed-in-diagnostic.test
@@ -42,7 +42,8 @@
 # CHECK-NEXT:"line": 0
 # CHECK-NEXT:  }
 # CHECK-NEXT:},
-# CHECK-NEXT:"severity": 1
+# CHECK-NEXT:"severity": 1,
+# CHECK-NEXT:"source": "clang"
 # CHECK-NEXT:  },
 # CHECK-NEXT:  {
 # CHECK-NEXT:"message": "Previous use is here\n\nfoo.c:1:18: error: use of 'Point' with tag type that does not match previous declaration",
Index: test/clangd/fixits-command.test
===
--- test/clangd/fixits-command.test
+++ test/clangd/fixits-command.test
@@ -17,7 +17,8 @@
 # CHECK-NEXT:"line": 0
 # CHECK-NEXT:  }
 # CHECK-NEXT:},
-# CHECK-NEXT:"severity": 2
+# CHECK-NEXT:"severity": 2,
+# CHECK-NEXT:"source": "clang"
 # CHECK-NEXT:  }
 # CHECK-NEXT:],
 # CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
Index: test/clangd/fixits-codeaction.test
===
--- test/clangd/fixits-codeaction.test
+++ test/clangd/fixits-codeaction.test
@@ -17,7 +17,8 @@
 # CHECK-NEXT:"line": 0
 # CHECK-NEXT:  }
 # CHECK-NEXT:},
-# CHECK-NEXT:"severity": 2
+# CHECK-NEXT:"severity": 2,
+# CHECK-NEXT:"source": "clang"
 # CHECK-NEXT:  }
 # CHECK-NEXT:],
 # CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
Index: test/clangd/execute-command.test
===
--- test/clangd/execute-command.test
+++ test/clangd/execute-command.test
@@ -17,7 +17,8 @@
 # CHECK-NEXT:"line": 0
 # CHECK-NEXT:  }
 # CHECK-NEXT:},
-# CHECK-NEXT:"severity": 2
+# CHECK-NEXT:"severity": 2,
+# CHECK-NEXT:"source": "clang"
 # CHECK-NEXT:  }
 # CHECK-NEXT:],
 # CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
Index: test/clangd/did-change-configuration-params.test
===
--- test/clangd/did-change-configuration-params.test
+++ test/clangd/did-change-configuration-params.test
@@ -35,7 +35,8 @@
 # CHECK-NEXT:"line": 0
 # CHECK-NEXT:  }
 # CHECK-NEXT:},
-# CHECK-NEX

[PATCH] D58541: [CodeComplete] Propagate preferred type for function arguments in more cases

2019-02-25 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.
Herald added a subscriber: Charusso.



Comment at: clang/include/clang/Sema/Sema.h:294
+  /// function_ref, clients should make sure all calls to get() with the same
+  /// location happen while function_ref is alive.
+  void enterFunctionArgument(SourceLocation Tok,

Is it only to avoid copy costs?



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:3490
-  CalledSignatureHelp = true;
-  Actions.CodeCompleteExpression(getCurScope(), PreferredType);
 })) {

IIUC, deleting this call is safe, since it is going to be called in 
`ParseAssignmentExpression`. Could you add a comment stating that?(same for 
other deleted call sites of this function.)



Comment at: clang/unittests/Sema/CodeCompleteTest.cpp:457
+void test() {
+  foo(^(^(^(^vector().^data();
+  bar(^(^(^(^vector().^data();

Can you also try in the middle of an identifier, like `vec^tor()`



Comment at: clang/unittests/Sema/CodeCompleteTest.cpp:458
+  foo(^(^(^(^vector().^data();
+  bar(^(^(^(^vector().^data();
+}

maybe add a test for second parameter as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58541



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


[PATCH] D58571: [libclang] Fix a trivial error introduced in D57946.

2019-02-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.
Herald added a subscriber: Charusso.

LGTM! Thanks! I guess we are missing a python test? No idea why we are not 
testing it though...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58571



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


[PATCH] D58541: [CodeComplete] Propagate preferred type for function arguments in more cases

2019-02-25 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:494
   default:
 assert(false && "unhnalded unary op");
 return QualType();

Typo?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58541



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


[PATCH] D58570: [libclang] Expose warn_unused and warn_unused_result attributes.

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

LGTM! Although for consistency we could add this into python bindings too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58570



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


[PATCH] D58601: Fixed grammar in index.rst

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
Herald added a subscriber: arphaman.
Herald added a project: clang.
gribozavr added a reviewer: ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58601

Files:
  clang-tools-extra/docs/index.rst


Index: clang-tools-extra/docs/index.rst
===
--- clang-tools-extra/docs/index.rst
+++ clang-tools-extra/docs/index.rst
@@ -8,7 +8,7 @@
 Introduction
 
 Welcome to the clang-tools-extra project which contains extra tools built using
-Clang's tooling API's.
+Clang's tooling APIs.
 
 .. toctree::
:maxdepth: 1


Index: clang-tools-extra/docs/index.rst
===
--- clang-tools-extra/docs/index.rst
+++ clang-tools-extra/docs/index.rst
@@ -8,7 +8,7 @@
 Introduction
 
 Welcome to the clang-tools-extra project which contains extra tools built using
-Clang's tooling API's.
+Clang's tooling APIs.
 
 .. toctree::
:maxdepth: 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58602: Removed an unhelpful comment in index.rst

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added a reviewer: ilya-biryukov.
Herald added subscribers: jdoerfert, arphaman.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58602

Files:
  clang-tools-extra/docs/index.rst


Index: clang-tools-extra/docs/index.rst
===
--- clang-tools-extra/docs/index.rst
+++ clang-tools-extra/docs/index.rst
@@ -1,8 +1,3 @@
-.. Extra Clang Tools documentation master file, created by
-   sphinx-quickstart on Wed Feb 13 10:00:18 2013.
-   You can adapt this file completely to your liking, but it should at least
-   contain the root `toctree` directive.
-
 .. title:: Welcome to Extra Clang Tools's documentation!
 
 Introduction


Index: clang-tools-extra/docs/index.rst
===
--- clang-tools-extra/docs/index.rst
+++ clang-tools-extra/docs/index.rst
@@ -1,8 +1,3 @@
-.. Extra Clang Tools documentation master file, created by
-   sphinx-quickstart on Wed Feb 13 10:00:18 2013.
-   You can adapt this file completely to your liking, but it should at least
-   contain the root `toctree` directive.
-
 .. title:: Welcome to Extra Clang Tools's documentation!
 
 Introduction
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58603: Updated the documentation build instructions for the current CMake build system

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added a reviewer: ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58603

Files:
  clang-tools-extra/docs/README.txt


Index: clang-tools-extra/docs/README.txt
===
--- clang-tools-extra/docs/README.txt
+++ clang-tools-extra/docs/README.txt
@@ -1,11 +1,10 @@
--
-Documentation for the tools of clang-tools-extra repo project
--
+--
+Documentation in clang-tools-extra
+--
 
-Sphinx and doxygen documentation is generated by executing make.
+You can generate documentation in HTML format from files in
+clang-tools-extra/docs by building the docs-clang-tools-html target.
 
-Sphinx html files can be generated separately using make html.
+You can generate documentation from the source code using Doxygen by building
+the doxygen-clang-tools target.
 
-Doxygen html files can also be generated using make doxygen.
-
-The generated documentation will be placed in _build/html.


Index: clang-tools-extra/docs/README.txt
===
--- clang-tools-extra/docs/README.txt
+++ clang-tools-extra/docs/README.txt
@@ -1,11 +1,10 @@
--
-Documentation for the tools of clang-tools-extra repo project
--
+--
+Documentation in clang-tools-extra
+--
 
-Sphinx and doxygen documentation is generated by executing make.
+You can generate documentation in HTML format from files in
+clang-tools-extra/docs by building the docs-clang-tools-html target.
 
-Sphinx html files can be generated separately using make html.
+You can generate documentation from the source code using Doxygen by building
+the doxygen-clang-tools target.
 
-Doxygen html files can also be generated using make doxygen.
-
-The generated documentation will be placed in _build/html.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58569: [libclang] Avoid crashing when getting layout info of an undeduced type.

2019-02-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/tools/c-index-test/c-index-test.c:1695
+CXType RT = clang_getResultType(T);
+if (RT.kind != CXType_Invalid)
+  PrintSingleTypeSize(RT, " [resulttype=%s] [resulttypekind=%s]",

Should it not return undeduced error in the other case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58569



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


[PATCH] D58504: [OpenCL][8.0.0 Release] Notes for OpenCL

2019-02-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 188122.
Anastasia added a comment.

Updated the section title!


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

https://reviews.llvm.org/D58504

Files:
  docs/ReleaseNotes.rst


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -11,7 +11,7 @@
 Introduction
 
 
-This document contains the release notes for the Clang C/C++/Objective-C
+This document contains the release notes for the Clang C/C++/Objective-C/OpenCL
 frontend, part of the LLVM Compiler Infrastructure, release 8.0.0. Here we
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
@@ -225,10 +225,59 @@
 
 ...
 
-OpenCL C Language Changes in Clang
+OpenCL Kernel Language Changes in Clang
 --
+Misc:
+
+- Improved address space support with Clang builtins.
+
+- Improved various diagnostics for vectors with element types from extensions
+  and attribute values; duplicate address spaces.
+
+- Allow blocks to capture arrays.
+
+- Allow zero assignment and comparisons between variables of queue_t type.
+
+- Improved diagnostics of formatting specifiers and argument promotions for
+  vector types in printf.
+
+- Fixed return type of enqueued kernel and pipe builtins.
+
+- Fixed address space of clk_event_t generated in the IR.
+
+- Fixed address space when passing/returning structs.
+
+Header file fixes:
+
+- Added missing extension guards around several builtin function overloads.
+
+- Fixed serialization support when registering vendor extensions using pragmas.
+
+- Fixed OpenCL version in declarations of builtin functions with with
+  sampler-less image acesses.
+
+New vendor extensions added:
+
+- ``cl_intel_planar_yuv``
+
+- ``cl_intel_device_side_avc_motion_estimation``
+
+
+C++ for OpenCL:
+
+- Added support of address space conversions in C style casts.
+
+- Enabled address spaces for references.
+
+- Fixed use of address spaces in templates: deduction and diagnostics.
+
+- Changed default address space to work with C++ specific concepts: class 
members,
+  template parameters, etc.
+
+- Added generic address space by default to the generated hidden 'this' 
parameter.
+
+- Extend overload ranking rules for address spaces.
 
-...
 
 ABI Changes in Clang
 


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -11,7 +11,7 @@
 Introduction
 
 
-This document contains the release notes for the Clang C/C++/Objective-C
+This document contains the release notes for the Clang C/C++/Objective-C/OpenCL
 frontend, part of the LLVM Compiler Infrastructure, release 8.0.0. Here we
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
@@ -225,10 +225,59 @@
 
 ...
 
-OpenCL C Language Changes in Clang
+OpenCL Kernel Language Changes in Clang
 --
+Misc:
+
+- Improved address space support with Clang builtins.
+
+- Improved various diagnostics for vectors with element types from extensions
+  and attribute values; duplicate address spaces.
+
+- Allow blocks to capture arrays.
+
+- Allow zero assignment and comparisons between variables of queue_t type.
+
+- Improved diagnostics of formatting specifiers and argument promotions for
+  vector types in printf.
+
+- Fixed return type of enqueued kernel and pipe builtins.
+
+- Fixed address space of clk_event_t generated in the IR.
+
+- Fixed address space when passing/returning structs.
+
+Header file fixes:
+
+- Added missing extension guards around several builtin function overloads.
+
+- Fixed serialization support when registering vendor extensions using pragmas.
+
+- Fixed OpenCL version in declarations of builtin functions with with
+  sampler-less image acesses.
+
+New vendor extensions added:
+
+- ``cl_intel_planar_yuv``
+
+- ``cl_intel_device_side_avc_motion_estimation``
+
+
+C++ for OpenCL:
+
+- Added support of address space conversions in C style casts.
+
+- Enabled address spaces for references.
+
+- Fixed use of address spaces in templates: deduction and diagnostics.
+
+- Changed default address space to work with C++ specific concepts: class members,
+  template parameters, etc.
+
+- Added generic address space by default to the generated hidden 'this' parameter.
+
+- Extend overload ranking rules for address spaces.
 
-...
 
 ABI Changes in Clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58504: [OpenCL][8.0.0 Release] Notes for OpenCL

2019-02-25 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: docs/ReleaseNotes.rst:228
 
-OpenCL C Language Changes in Clang
+OpenCL Language Changes in Clang
 --

Anastasia wrote:
> AlexeySotkin wrote:
> > AlexeySotkin wrote:
> > > Why the "C" is removed ?
> > Should we call the section like: "OpenCL Support in Clang"?
> I would like to leave "Changes" in as it described the difference in this 
> release. And I think "Language" should stay to be more precise that this 
> doesn't cover libraries or runtime.
> 
> So I was think of either:
> `OpenCL Kernel Language Change in Clang`
>  or
> `'OpenCL C/C++ Language Changes in Clang'`
> 
> I am a bit worried about the last one since it might link to the OpenCL C++ 
> spec... even though it was used in the past release notes... but now that the 
> direction has been changed I am not sure. Any opinion?
We might need to finalize this quickly. @hans when is the last day to commit 
this to the release branch?


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

https://reviews.llvm.org/D58504



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


r354773 - [SYCL] Add clang front-end option to enable SYCL device compilation flow.

2019-02-25 Thread Alexey Bader via cfe-commits
Author: bader
Date: Mon Feb 25 03:48:48 2019
New Revision: 354773

URL: http://llvm.org/viewvc/llvm-project?rev=354773&view=rev
Log:
[SYCL] Add clang front-end option to enable SYCL device compilation flow.

Patch by Mariya Podchishchaeva 

Added:
cfe/trunk/test/Preprocessor/sycl-macro.cpp   (with props)
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=354773&r1=354772&r2=354773&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Mon Feb 25 03:48:48 2019
@@ -217,6 +217,8 @@ LANGOPT(CUDAHostDeviceConstexpr, 1, 1, "
 LANGOPT(CUDADeviceApproxTranscendentals, 1, 0, "using approximate 
transcendental functions")
 LANGOPT(GPURelocatableDeviceCode, 1, 0, "generate relocatable device code")
 
+LANGOPT(SYCLIsDevice  , 1, 0, "Generate code for SYCL device")
+
 LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
 LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are 
unavailable")

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=354773&r1=354772&r2=354773&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Feb 25 03:48:48 2019
@@ -836,8 +836,14 @@ def fopenmp_is_device : Flag<["-"], "fop
 def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">,
   HelpText<"Path to the IR file produced by the frontend for the host.">;
 
-} // let Flags = [CC1Option]
+//===--===//
+// SYCL Options
+//===--===//
 
+def fsycl_is_device : Flag<["-"], "fsycl-is-device">,
+  HelpText<"Generate code for SYCL device.">;
+
+} // let Flags = [CC1Option]
 
 
//===--===//
 // cc1as-only Options

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=354773&r1=354772&r2=354773&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Feb 25 03:48:48 2019
@@ -2879,6 +2879,8 @@ static void ParseLangArgs(LangOptions &O
   << Opts.OMPHostIRFile;
   }
 
+  Opts.SYCLIsDevice = Args.hasArg(options::OPT_fsycl_is_device);
+
   // Set CUDA mode for OpenMP target NVPTX if specified in options
   Opts.OpenMPCUDAMode = Opts.OpenMPIsDevice && T.isNVPTX() &&
 Args.hasArg(options::OPT_fopenmp_cuda_mode);

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=354773&r1=354772&r2=354773&view=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon Feb 25 03:48:48 2019
@@ -1057,6 +1057,12 @@ static void InitializePredefinedMacros(c
 Builder.defineMacro("__CLANG_CUDA_APPROX_TRANSCENDENTALS__");
   }
 
+  // Define a macro indicating that the source file is being compiled with a
+  // SYCL device compiler which doesn't produce host binary.
+  if (LangOpts.SYCLIsDevice) {
+Builder.defineMacro("__SYCL_DEVICE_ONLY__", "1");
+  }
+
   // OpenCL definitions.
   if (LangOpts.OpenCL) {
 #define OPENCLEXT(Ext) 
\

Added: cfe/trunk/test/Preprocessor/sycl-macro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/sycl-macro.cpp?rev=354773&view=auto
==
--- cfe/trunk/test/Preprocessor/sycl-macro.cpp (added)
+++ cfe/trunk/test/Preprocessor/sycl-macro.cpp Mon Feb 25 03:48:48 2019
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 %s -E -dM | FileCheck %s
+// RUN: %clang_cc1 %s -fsycl-is-device -E -dM | FileCheck 
--check-prefix=CHECK-SYCL %s
+
+// CHECK-NOT:#define __SYCL_DEVICE_ONLY__ 1
+// CHECK-SYCL:#define __SYCL_DEVICE_ONLY__ 1

Propchange: cfe/trunk/test/Preprocessor/sycl-macro.cpp
--
svn:eol-style = native

Propchange: cfe/trunk/test/Preprocessor/sycl-macro.cpp

[PATCH] D57768: [SYCL] Add clang front-end option to enable SYCL device compilation flow.

2019-02-25 Thread Alexey Bader via Phabricator via cfe-commits
bader closed this revision.
bader added a comment.

Committed: https://reviews.llvm.org/rL354773


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57768



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


[PATCH] D58604: [clang-tidy] misc-string-integer-assignment: ignore toupper/tolower

2019-02-25 Thread Clement Courbet via Phabricator via cfe-commits
courbet created this revision.
courbet added reviewers: xazax.hun, alexfh.
Herald added subscribers: cfe-commits, rnkovacs.
Herald added a project: clang.

Tis represents ~20% of false positives. See PR27723.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58604

Files:
  clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
  test/clang-tidy/bugprone-string-integer-assignment.cpp


Index: test/clang-tidy/bugprone-string-integer-assignment.cpp
===
--- test/clang-tidy/bugprone-string-integer-assignment.cpp
+++ test/clang-tidy/bugprone-string-integer-assignment.cpp
@@ -11,8 +11,14 @@
 
 typedef basic_string string;
 typedef basic_string wstring;
+
+int tolower(int i);
+int toupper(int i);
 }
 
+int tolower(int i);
+int toupper(int i);
+
 typedef int MyArcaneChar;
 
 int main() {
@@ -50,4 +56,7 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: an integer is interpreted as a 
chara
 // CHECK-FIXES: {{^}}  as = 6;{{$}}
 
+  s += toupper(x);
+  s += tolower(x);
+  s += std::tolower(x);
 }
Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -27,10 +27,15 @@
   callee(cxxMethodDecl(ofClass(classTemplateSpecializationDecl(
   hasName("::std::basic_string"),
   hasTemplateArgument(0, 
refersToType(qualType().bind("type"))),
-  hasArgument(1,
-  ignoringImpCasts(expr(hasType(isInteger()),
-unless(hasType(isAnyCharacter(
-   .bind("expr"))),
+  hasArgument(
+  1,
+  ignoringImpCasts(
+  expr(hasType(isInteger()), unless(hasType(isAnyCharacter())),
+   // Ignore calls to tolower/toupper (see PR27723).
+   unless(callExpr(callee(functionDecl(
+   hasAnyName("tolower", "std::tolower", "toupper",
+  "std::toupper"))
+  .bind("expr"))),
   unless(isInTemplateInstantiation())),
   this);
 }


Index: test/clang-tidy/bugprone-string-integer-assignment.cpp
===
--- test/clang-tidy/bugprone-string-integer-assignment.cpp
+++ test/clang-tidy/bugprone-string-integer-assignment.cpp
@@ -11,8 +11,14 @@
 
 typedef basic_string string;
 typedef basic_string wstring;
+
+int tolower(int i);
+int toupper(int i);
 }
 
+int tolower(int i);
+int toupper(int i);
+
 typedef int MyArcaneChar;
 
 int main() {
@@ -50,4 +56,7 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: an integer is interpreted as a chara
 // CHECK-FIXES: {{^}}  as = 6;{{$}}
 
+  s += toupper(x);
+  s += tolower(x);
+  s += std::tolower(x);
 }
Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -27,10 +27,15 @@
   callee(cxxMethodDecl(ofClass(classTemplateSpecializationDecl(
   hasName("::std::basic_string"),
   hasTemplateArgument(0, refersToType(qualType().bind("type"))),
-  hasArgument(1,
-  ignoringImpCasts(expr(hasType(isInteger()),
-unless(hasType(isAnyCharacter(
-   .bind("expr"))),
+  hasArgument(
+  1,
+  ignoringImpCasts(
+  expr(hasType(isInteger()), unless(hasType(isAnyCharacter())),
+   // Ignore calls to tolower/toupper (see PR27723).
+   unless(callExpr(callee(functionDecl(
+   hasAnyName("tolower", "std::tolower", "toupper",
+  "std::toupper"))
+  .bind("expr"))),
   unless(isInTemplateInstantiation())),
   this);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D57914: [Driver] Allow enum SanitizerOrdinal to represent more than 64 different sanitizer checks, NFC.

2019-02-25 Thread pierre gousseau via Phabricator via cfe-commits
pgousseau updated this revision to Diff 188128.
pgousseau added a comment.
Herald added a subscriber: jfb.

Fix bad use of reference as pointed out, aliased SanitizerKind to 
SanitizerMasks<> instead.


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

https://reviews.llvm.org/D57914

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/Sanitizers.def
  include/clang/Basic/Sanitizers.h
  include/clang/Driver/ToolChain.h
  lib/Basic/SanitizerSpecialCaseList.cpp
  lib/Basic/Sanitizers.cpp
  lib/CodeGen/CGExpr.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaDeclAttr.cpp

Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -6211,7 +6211,8 @@
 if (!S.checkStringLiteralArgumentAttr(AL, I, SanitizerName, &LiteralLoc))
   return;
 
-if (parseSanitizerValue(SanitizerName, /*AllowGroups=*/true) == 0)
+if (parseSanitizerValue(SanitizerName, /*AllowGroups=*/true) ==
+SanitizerMask())
   S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
 else if (isGlobalVar(D) && SanitizerName != "address")
   S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -551,7 +551,7 @@
 DiagnosticsEngine &Diags, SanitizerSet &S) {
   for (const auto &Sanitizer : Sanitizers) {
 SanitizerMask K = parseSanitizerValue(Sanitizer, /*AllowGroups=*/false);
-if (K == 0)
+if (K == SanitizerMask())
   Diags.Report(diag::err_drv_invalid_value) << FlagName << Sanitizer;
 else
   S.set(K, true);
Index: lib/Driver/ToolChain.cpp
===
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -818,21 +818,23 @@
   // Return sanitizers which don't require runtime support and are not
   // platform dependent.
 
-  using namespace SanitizerKind;
-
-  SanitizerMask Res = (Undefined & ~Vptr & ~Function) | (CFI & ~CFIICall) |
-  CFICastStrict | UnsignedIntegerOverflow |
-  ImplicitConversion | Nullability | LocalBounds;
+  SanitizerMask Res = (SanitizerKind::Undefined & ~SanitizerKind::Vptr &
+   ~SanitizerKind::Function) |
+  (SanitizerKind::CFI & ~SanitizerKind::CFIICall) |
+  SanitizerKind::CFICastStrict |
+  SanitizerKind::UnsignedIntegerOverflow |
+  SanitizerKind::ImplicitConversion |
+  SanitizerKind::Nullability | SanitizerKind::LocalBounds;
   if (getTriple().getArch() == llvm::Triple::x86 ||
   getTriple().getArch() == llvm::Triple::x86_64 ||
   getTriple().getArch() == llvm::Triple::arm ||
   getTriple().getArch() == llvm::Triple::aarch64 ||
   getTriple().getArch() == llvm::Triple::wasm32 ||
   getTriple().getArch() == llvm::Triple::wasm64)
-Res |= CFIICall;
+Res |= SanitizerKind::CFIICall;
   if (getTriple().getArch() == llvm::Triple::x86_64 ||
   getTriple().getArch() == llvm::Triple::aarch64)
-Res |= ShadowCallStack;
+Res |= SanitizerKind::ShadowCallStack;
   return Res;
 }
 
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -21,33 +21,52 @@
 #include 
 
 using namespace clang;
-using namespace clang::SanitizerKind;
 using namespace clang::driver;
 using namespace llvm::opt;
 
-enum : SanitizerMask {
-  NeedsUbsanRt = Undefined | Integer | ImplicitConversion | Nullability | CFI,
-  NeedsUbsanCxxRt = Vptr | CFI,
-  NotAllowedWithTrap = Vptr,
-  NotAllowedWithMinimalRuntime = Vptr,
-  RequiresPIE = DataFlow | HWAddress | Scudo,
-  NeedsUnwindTables = Address | HWAddress | Thread | Memory | DataFlow,
-  SupportsCoverage = Address | HWAddress | KernelAddress | KernelHWAddress |
- Memory | KernelMemory | Leak | Undefined | Integer |
- ImplicitConversion | Nullability | DataFlow | Fuzzer |
- FuzzerNoLink,
-  RecoverableByDefault = Undefined | Integer | ImplicitConversion | Nullability,
-  Unrecoverable = Unreachable | Return,
-  AlwaysRecoverable = KernelAddress | KernelHWAddress,
-  LegacyFsanitizeRecoverMask = Undefined | Integer,
-  NeedsLTO = CFI,
-  TrappingSupported = (Undefined & ~Vptr) | UnsignedIntegerOverflow |
-  ImplicitConversion | Nullability | LocalBounds | CFI,
-  TrappingDefault = CFI,
-  CFIClasses =
-  CFIVCall | CFINVCall | CFIMFCall | CFIDerivedCast | CFIUnrelatedCast,
-  CompatibleWithMinimalRuntime = TrappingSupported | Scudo | ShadowCallStack,
-};
+static co

[PATCH] D58341: [clangd] Index UsingDecls

2019-02-25 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the explanation.

In D58341#1401365 , @ilya-biryukov 
wrote:

> In D58341#1401295 , @hokein wrote:
>
> > std::strcmp is a fair case here. Sema seems not returning using-decls as 
> > part of code completion results, it this an intended behavior?
>
>
> Yeah, I think it is. There's an explicit code path that takes the target 
> decls of a using. Arguably, that's good if you to show signatures of the 
> methods.
>
> > Is it possible for us to extend Sema to support it?
>
> We could, but then we'd loose the signatures of the targets functions, which 
> is sad :-(
>
> > If we decide to provide using-decl results from index, I think we should 
> > make sure the code completion information (e.g. signature) is correct.
>
> The problem is that using-decls have multiple signatures. They can introduce 
> more than one name into the scope, so the question is which one should we 
> pick and how should we store them.


I think for most cases, the using-decl has only one shadow decl,  anyway it is 
out scope of this patch.

> In any case, it feels like any solution we can come up with would require 
> storing using declarations in the index in one form or the other, so this 
> patch definitely makes sense: it gives us hooks we can use to handle usings 
> in clangd.




Comment at: unittests/clangd/SymbolCollectorTests.cpp:1126
+TEST_F(SymbolCollectorTest, UsingDecl) {
+  auto completions = [](const Annotations &Test, SymbolSlab SS) {
+class IgnoreDiagnostics : public DiagnosticsConsumer {

ilya-biryukov wrote:
> That's definitely too much setup for such a simple test.
> I thought it's possible to wire up a real index in the completion tests, but 
> it seems that's not the case. So let's not bother to run an actual completion 
> here, ignore my previous comment about adding a test.
> 
> I thought it's possible to wire up a real index in the completion tests, but 
> it seems that's not the case. So let's not bother to run an actual completion 
> here, ignore my previous comment about adding a test.

Adding completions to `SymbolCollectorTest` is overweight, but I think this is 
possible (and worthy) to add one to CodeCompleteTest without too much effort. 
We have `TU.index()` to build a real index.

I understand the problem better now, we are missing some decls from sema 
because we avoid deserialization in preamble, I think we should document it 
somewhere, can't think a better place, maybe at the completion test?



Comment at: unittests/clangd/SymbolCollectorTests.cpp:14
 #include "TestTU.h"
+#include "index/Index.h"
+#include "index/MemIndex.h"

These includes are not needed.



Comment at: unittests/clangd/SymbolCollectorTests.cpp:57
 }
+MATCHER_P(CompletionQName, Name, "") { return (arg.Scope + arg.Name) == Name; }
 MATCHER_P(QName, Name, "") { return (arg.Scope + arg.Name).str() == Name; }

here as well.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58341



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


[PATCH] D58606: [clang-tidy] misc-string-integer-assignment: fix false positive

2019-02-25 Thread Clement Courbet via Phabricator via cfe-commits
courbet created this revision.
courbet added reviewers: xazax.hun, alexfh.
Herald added subscribers: cfe-commits, rnkovacs.
Herald added a project: clang.

using CodePoint = uint32_t;
CodePoint cp;
casic_string s;
s += cp;


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58606

Files:
  clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp


Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -29,7 +29,9 @@
   hasTemplateArgument(0, 
refersToType(qualType().bind("type"))),
   hasArgument(1,
   ignoringImpCasts(expr(hasType(isInteger()),
-unless(hasType(isAnyCharacter(
+unless(hasType(isAnyCharacter())),
+// Do not warn if assigning e.g. 
`CodePoint` to `basic_string`
+
unless(hasType(type(equalsBoundNode("type")
.bind("expr"))),
   unless(isInTemplateInstantiation())),
   this);


Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -29,7 +29,9 @@
   hasTemplateArgument(0, refersToType(qualType().bind("type"))),
   hasArgument(1,
   ignoringImpCasts(expr(hasType(isInteger()),
-unless(hasType(isAnyCharacter(
+unless(hasType(isAnyCharacter())),
+// Do not warn if assigning e.g. `CodePoint` to `basic_string`
+unless(hasType(type(equalsBoundNode("type")
.bind("expr"))),
   unless(isInTemplateInstantiation())),
   this);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58607: Moved clangd docs to a separate directory in preparation to restructure them into multiple files

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added a reviewer: ilya-biryukov.
Herald added subscribers: jdoerfert, kadircet, arphaman, jkorous, MaskRay, 
ioeric.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58607

Files:
  clang-tools-extra/docs/clangd.rst
  clang-tools-extra/docs/clangd/index.rst
  clang-tools-extra/docs/index.rst

Index: clang-tools-extra/docs/index.rst
===
--- clang-tools-extra/docs/index.rst
+++ clang-tools-extra/docs/index.rst
@@ -25,7 +25,7 @@
modularize
pp-trace
clang-rename
-   clangd
+   clangd/index
clang-doc
 
 
Index: clang-tools-extra/docs/clangd.rst
===
--- clang-tools-extra/docs/clangd.rst
+++ clang-tools-extra/docs/clangd.rst
@@ -1,180 +1,3 @@
-
-Clangd
-
+:orphan:
 
-.. contents::
-
-.. toctree::
-   :maxdepth: 1
-
-:program:`Clangd` is an implementation of the `Language Server Protocol
-`_ leveraging Clang.
-Clangd's goal is to provide language "smartness" features like code completion,
-find references, etc. for clients such as C/C++ Editors.
-
-Using Clangd
-==
-
-:program:`Clangd` is not meant to be used by C/C++ developers directly but
-rather from a client implementing the protocol. A client would be typically
-implemented in an IDE or an editor.
-
-At the moment, `Visual Studio Code `_ is mainly
-used in order to test :program:`Clangd` but more clients are likely to make
-use of :program:`Clangd` in the future as it matures and becomes a production
-quality tool. If you are interested in trying :program:`Clangd` in combination
-with Visual Studio Code, you can start by `installing Clangd`_ or
-`building Clangd`_, then open Visual Studio Code in the clangd-vscode folder and
-launch the extension.
-
-Installing Clangd
-==
-
-Packages are available for debian-based distributions, see the `LLVM packages
-page `_. :program:`Clangd` is included in the
-`clang-tools` package.
-However, it is a good idea to check your distribution's packaging system first
-as it might already be available.
-
-Otherwise, you can install :program:`Clangd` by `building Clangd`_ first.
-
-Building Clangd
-==
-
-You can follow the instructions for `building Clang
-`_ but "extra Clang tools" is **not**
-optional.
-
-Current Status
-==
-
-Many features could be implemented in :program:`Clangd`.
-Here is a list of features that could be useful with the status of whether or
-not they are already implemented in :program:`Clangd` and specified in the
-Language Server Protocol. Note that for some of the features, it is not clear
-whether or not they should be part of the Language Server Protocol, so those
-features might be eventually developed outside :program:`Clangd` or as an
-extension to the protocol.
-
-+-++--+
-| C/C++ Editor feature|  LSP   |  Clangd  |
-+=++==+
-| Formatting  | Yes|   Yes|
-+-++--+
-| Completion  | Yes|   Yes|
-+-++--+
-| Diagnostics | Yes|   Yes|
-+-++--+
-| Fix-its | Yes|   Yes|
-+-++--+
-| Go to Definition| Yes|   Yes|
-+-++--+
-| Signature Help  | Yes|   Yes|
-+-++--+
-| Document Highlights | Yes|   Yes|
-+-++--+
-| Rename  | Yes|   Yes|
-+-++--+
-| Source hover| Yes|   Yes|
-+-++--+
-| Find References | Yes|   No |
-+-++--+
-| Code Lens   | Yes|   No |
-+-++--+
-| Document Symbols| Yes|   Yes|
-+-++--+
-| Workspace Symbols   | Yes|   Yes|
-+-++--+
-| Syntax and Semanti

[PATCH] D58607: Moved clangd docs to a separate directory in preparation to restructure them into multiple files

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/docs/clangd.rst:1
-
-Clangd
-
+:orphan:
 

Having this does page not seem useful in the long-run.
Do we plan to remove it later? Or maybe there a way to create a redirect 
instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58607



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


[PATCH] D58607: Moved clangd docs to a separate directory in preparation to restructure them into multiple files

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr marked an inline comment as done.
gribozavr added inline comments.



Comment at: clang-tools-extra/docs/clangd.rst:1
-
-Clangd
-
+:orphan:
 

ilya-biryukov wrote:
> Having this does page not seem useful in the long-run.
> Do we plan to remove it later? Or maybe there a way to create a redirect 
> instead?
Yes, it should be eventually removed.  It is supposed to be a redirect -- it is 
the best we can do in plain HTML without access to HTTP headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58607



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


[PATCH] D58602: Removed an unhelpful comment in index.rst

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58602



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


[PATCH] D58603: Updated the documentation build instructions for the current CMake build system

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/docs/README.txt:5
 
-Sphinx and doxygen documentation is generated by executing make.
+You can generate documentation in HTML format from files in
+clang-tools-extra/docs by building the docs-clang-tools-html target.

NIT: maybe use an imperative form? Arguably looks more concise:
```
To generate documentation in HTML format execute the `docs-clang-tools-html` 
target.
```



Comment at: clang-tools-extra/docs/README.txt:6
+You can generate documentation in HTML format from files in
+clang-tools-extra/docs by building the docs-clang-tools-html target.
 

Could we mark 'docs-clang-tools-html' in a way that would produce a monospace 
font?
(Not sure how this is done in Sphinx, backticks?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58603



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


[PATCH] D58601: Fixed grammar in index.rst

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58601



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


[PATCH] D58603: Updated the documentation build instructions for the current CMake build system

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr updated this revision to Diff 188133.
gribozavr marked 2 inline comments as done.
gribozavr added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58603

Files:
  clang-tools-extra/docs/README.txt


Index: clang-tools-extra/docs/README.txt
===
--- clang-tools-extra/docs/README.txt
+++ clang-tools-extra/docs/README.txt
@@ -1,11 +1,10 @@
--
-Documentation for the tools of clang-tools-extra repo project
--
+--
+Documentation in clang-tools-extra
+--
 
-Sphinx and doxygen documentation is generated by executing make.
+To generate documentation in HTML format from files in clang-tools-extra/docs,
+build the docs-clang-tools-html target.
 
-Sphinx html files can be generated separately using make html.
+To generate documentation from the source code using Doxygen, build the
+doxygen-clang-tools target.
 
-Doxygen html files can also be generated using make doxygen.
-
-The generated documentation will be placed in _build/html.


Index: clang-tools-extra/docs/README.txt
===
--- clang-tools-extra/docs/README.txt
+++ clang-tools-extra/docs/README.txt
@@ -1,11 +1,10 @@
--
-Documentation for the tools of clang-tools-extra repo project
--
+--
+Documentation in clang-tools-extra
+--
 
-Sphinx and doxygen documentation is generated by executing make.
+To generate documentation in HTML format from files in clang-tools-extra/docs,
+build the docs-clang-tools-html target.
 
-Sphinx html files can be generated separately using make html.
+To generate documentation from the source code using Doxygen, build the
+doxygen-clang-tools target.
 
-Doxygen html files can also be generated using make doxygen.
-
-The generated documentation will be placed in _build/html.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58603: Updated the documentation build instructions for the current CMake build system

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/docs/README.txt:6
+You can generate documentation in HTML format from files in
+clang-tools-extra/docs by building the docs-clang-tools-html target.
 

ilya-biryukov wrote:
> Could we mark 'docs-clang-tools-html' in a way that would produce a monospace 
> font?
> (Not sure how this is done in Sphinx, backticks?)
Ah, this is txt file. Ignore the comment please.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58603



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


[clang-tools-extra] r354777 - Removed an unhelpful comment in index.rst

2019-02-25 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Mon Feb 25 04:48:52 2019
New Revision: 354777

URL: http://llvm.org/viewvc/llvm-project?rev=354777&view=rev
Log:
Removed an unhelpful comment in index.rst

Reviewers: ilya-biryukov

Subscribers: arphaman, jdoerfert, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/docs/index.rst

Modified: clang-tools-extra/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/index.rst?rev=354777&r1=354776&r2=354777&view=diff
==
--- clang-tools-extra/trunk/docs/index.rst (original)
+++ clang-tools-extra/trunk/docs/index.rst Mon Feb 25 04:48:52 2019
@@ -1,8 +1,3 @@
-.. Extra Clang Tools documentation master file, created by
-   sphinx-quickstart on Wed Feb 13 10:00:18 2013.
-   You can adapt this file completely to your liking, but it should at least
-   contain the root `toctree` directive.
-
 .. title:: Welcome to Extra Clang Tools's documentation!
 
 Introduction


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


[clang-tools-extra] r354778 - Fixed grammar in index.rst

2019-02-25 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Mon Feb 25 04:49:27 2019
New Revision: 354778

URL: http://llvm.org/viewvc/llvm-project?rev=354778&view=rev
Log:
Fixed grammar in index.rst

Subscribers: arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/docs/index.rst

Modified: clang-tools-extra/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/index.rst?rev=354778&r1=354777&r2=354778&view=diff
==
--- clang-tools-extra/trunk/docs/index.rst (original)
+++ clang-tools-extra/trunk/docs/index.rst Mon Feb 25 04:49:27 2019
@@ -3,7 +3,7 @@
 Introduction
 
 Welcome to the clang-tools-extra project which contains extra tools built using
-Clang's tooling API's.
+Clang's tooling APIs.
 
 .. toctree::
:maxdepth: 1


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


[PATCH] D58606: [clang-tidy] misc-string-integer-assignment: fix false positive

2019-02-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

The change looks good but it would be great to have a regression test as well.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58606



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


[PATCH] D58602: Removed an unhelpful comment in index.rst

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354777: Removed an unhelpful comment in index.rst (authored 
by gribozavr, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58602?vs=188119&id=188134#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58602

Files:
  clang-tools-extra/trunk/docs/index.rst


Index: clang-tools-extra/trunk/docs/index.rst
===
--- clang-tools-extra/trunk/docs/index.rst
+++ clang-tools-extra/trunk/docs/index.rst
@@ -1,8 +1,3 @@
-.. Extra Clang Tools documentation master file, created by
-   sphinx-quickstart on Wed Feb 13 10:00:18 2013.
-   You can adapt this file completely to your liking, but it should at least
-   contain the root `toctree` directive.
-
 .. title:: Welcome to Extra Clang Tools's documentation!
 
 Introduction


Index: clang-tools-extra/trunk/docs/index.rst
===
--- clang-tools-extra/trunk/docs/index.rst
+++ clang-tools-extra/trunk/docs/index.rst
@@ -1,8 +1,3 @@
-.. Extra Clang Tools documentation master file, created by
-   sphinx-quickstart on Wed Feb 13 10:00:18 2013.
-   You can adapt this file completely to your liking, but it should at least
-   contain the root `toctree` directive.
-
 .. title:: Welcome to Extra Clang Tools's documentation!
 
 Introduction
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58601: Fixed grammar in index.rst

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE354778: Fixed grammar in index.rst (authored by gribozavr, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58601?vs=188117&id=188135#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58601

Files:
  docs/index.rst


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -3,7 +3,7 @@
 Introduction
 
 Welcome to the clang-tools-extra project which contains extra tools built using
-Clang's tooling API's.
+Clang's tooling APIs.
 
 .. toctree::
:maxdepth: 1


Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -3,7 +3,7 @@
 Introduction
 
 Welcome to the clang-tools-extra project which contains extra tools built using
-Clang's tooling API's.
+Clang's tooling APIs.
 
 .. toctree::
:maxdepth: 1
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58603: Updated the documentation build instructions for the current CMake build system

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang-tools-extra/docs/README.txt:6
+You can generate documentation in HTML format from files in
+clang-tools-extra/docs by building the docs-clang-tools-html target.
 

ilya-biryukov wrote:
> ilya-biryukov wrote:
> > Could we mark 'docs-clang-tools-html' in a way that would produce a 
> > monospace font?
> > (Not sure how this is done in Sphinx, backticks?)
> Ah, this is txt file. Ignore the comment please.
This is a `.txt`...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58603



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


[PATCH] D58604: [clang-tidy] misc-string-integer-assignment: ignore toupper/tolower

2019-02-25 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks for working on this.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58604



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


[clang-tools-extra] r354779 - Updated the documentation build instructions for the current CMake build system

2019-02-25 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Mon Feb 25 05:03:44 2019
New Revision: 354779

URL: http://llvm.org/viewvc/llvm-project?rev=354779&view=rev
Log:
Updated the documentation build instructions for the current CMake build system

Reviewers: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/docs/README.txt

Modified: clang-tools-extra/trunk/docs/README.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/README.txt?rev=354779&r1=354778&r2=354779&view=diff
==
--- clang-tools-extra/trunk/docs/README.txt (original)
+++ clang-tools-extra/trunk/docs/README.txt Mon Feb 25 05:03:44 2019
@@ -1,11 +1,10 @@
--
-Documentation for the tools of clang-tools-extra repo project
--
+--
+Documentation in clang-tools-extra
+--
 
-Sphinx and doxygen documentation is generated by executing make.
+To generate documentation in HTML format from files in clang-tools-extra/docs,
+build the docs-clang-tools-html target.
 
-Sphinx html files can be generated separately using make html.
+To generate documentation from the source code using Doxygen, build the
+doxygen-clang-tools target.
 
-Doxygen html files can also be generated using make doxygen.
-
-The generated documentation will be placed in _build/html.


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


[PATCH] D58607: Moved clangd docs to a separate directory in preparation to restructure them into multiple files

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang-tools-extra/docs/clangd.rst:1
-
-Clangd
-
+:orphan:
 

gribozavr wrote:
> ilya-biryukov wrote:
> > Having this does page not seem useful in the long-run.
> > Do we plan to remove it later? Or maybe there a way to create a redirect 
> > instead?
> Yes, it should be eventually removed.  It is supposed to be a redirect -- it 
> is the best we can do in plain HTML without access to HTTP headers.
Yeah, looks like it's the best we can do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58607



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


[PATCH] D58603: Updated the documentation build instructions for the current CMake build system

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58603



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


[PATCH] D58603: Updated the documentation build instructions for the current CMake build system

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354779: Updated the documentation build instructions for the 
current CMake build system (authored by gribozavr, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58603?vs=188133&id=188136#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58603

Files:
  clang-tools-extra/trunk/docs/README.txt


Index: clang-tools-extra/trunk/docs/README.txt
===
--- clang-tools-extra/trunk/docs/README.txt
+++ clang-tools-extra/trunk/docs/README.txt
@@ -1,11 +1,10 @@
--
-Documentation for the tools of clang-tools-extra repo project
--
+--
+Documentation in clang-tools-extra
+--
 
-Sphinx and doxygen documentation is generated by executing make.
+To generate documentation in HTML format from files in clang-tools-extra/docs,
+build the docs-clang-tools-html target.
 
-Sphinx html files can be generated separately using make html.
+To generate documentation from the source code using Doxygen, build the
+doxygen-clang-tools target.
 
-Doxygen html files can also be generated using make doxygen.
-
-The generated documentation will be placed in _build/html.


Index: clang-tools-extra/trunk/docs/README.txt
===
--- clang-tools-extra/trunk/docs/README.txt
+++ clang-tools-extra/trunk/docs/README.txt
@@ -1,11 +1,10 @@
--
-Documentation for the tools of clang-tools-extra repo project
--
+--
+Documentation in clang-tools-extra
+--
 
-Sphinx and doxygen documentation is generated by executing make.
+To generate documentation in HTML format from files in clang-tools-extra/docs,
+build the docs-clang-tools-html target.
 
-Sphinx html files can be generated separately using make html.
+To generate documentation from the source code using Doxygen, build the
+doxygen-clang-tools target.
 
-Doxygen html files can also be generated using make doxygen.
-
-The generated documentation will be placed in _build/html.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58609: [clang-tidy] bugprone-string-integer-assignment: Reduce false positives.

2019-02-25 Thread Clement Courbet via Phabricator via cfe-commits
courbet created this revision.
courbet added reviewers: xazax.hun, alexfh.
Herald added subscribers: cfe-commits, jdoerfert, rnkovacs.
Herald added a project: clang.

Detect a few expressions as likely character expressions, see PR27723.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D58609

Files:
  clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
  test/clang-tidy/bugprone-string-integer-assignment.cpp


Index: test/clang-tidy/bugprone-string-integer-assignment.cpp
===
--- test/clang-tidy/bugprone-string-integer-assignment.cpp
+++ test/clang-tidy/bugprone-string-integer-assignment.cpp
@@ -50,4 +50,8 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: an integer is interpreted as a 
chara
 // CHECK-FIXES: {{^}}  as = 6;{{$}}
 
+  // Likely character expressions.
+  s += x & 0xff;
+
+  s += 'a' + (x % 26);
 }
Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -35,11 +35,42 @@
   this);
 }
 
+static bool isLikelyCharExpression(const Expr* Argument, const ASTContext 
&Ctx) {
+  const auto* BinOp = dyn_cast(Argument);
+  if (!BinOp) {
+return false;
+  }
+  const auto* LHS = BinOp->getLHS()->IgnoreParenImpCasts();
+  const auto* RHS = BinOp->getRHS()->IgnoreParenImpCasts();
+  //  & , mask is a compile time constant.
+  Expr::EvalResult RHSVal;
+  if (BinOp->getOpcode() == BO_And &&
+  BinOp->getRHS()->EvaluateAsInt(RHSVal, Ctx, Expr::SE_AllowSideEffects)) {
+  return true;
+  }
+  //  + ( % ), where  is a char literal.
+  BinOp->dump();
+  llvm::errs() << "A " << isa(LHS) << " " << 
(BinOp->getOpcode() == BO_Add)<< "\n";
+  if (isa(LHS) && BinOp->getOpcode() == BO_Add) {
+const auto* RHSOp = dyn_cast(RHS);
+llvm::errs() << "B " << RHSOp << " " << (RHSOp ? RHSOp->getOpcode() == 
BO_Rem : false)<< "\n";
+if (RHSOp && RHSOp->getOpcode() == BO_Rem) {
+  return true;
+}
+  }
+  return false;
+}
+
 void StringIntegerAssignmentCheck::check(
 const MatchFinder::MatchResult &Result) {
   const auto *Argument = Result.Nodes.getNodeAs("expr");
   SourceLocation Loc = Argument->getBeginLoc();
 
+  // Try to detect a few common expressions to reduce false positives.
+  if (isLikelyCharExpression(Argument, *Result.Context)) {
+return;
+  }
+
   auto Diag =
   diag(Loc, "an integer is interpreted as a character code when assigning "
 "it to a string; if this is intended, cast the integer to the "


Index: test/clang-tidy/bugprone-string-integer-assignment.cpp
===
--- test/clang-tidy/bugprone-string-integer-assignment.cpp
+++ test/clang-tidy/bugprone-string-integer-assignment.cpp
@@ -50,4 +50,8 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: an integer is interpreted as a chara
 // CHECK-FIXES: {{^}}  as = 6;{{$}}
 
+  // Likely character expressions.
+  s += x & 0xff;
+
+  s += 'a' + (x % 26);
 }
Index: clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -35,11 +35,42 @@
   this);
 }
 
+static bool isLikelyCharExpression(const Expr* Argument, const ASTContext &Ctx) {
+  const auto* BinOp = dyn_cast(Argument);
+  if (!BinOp) {
+return false;
+  }
+  const auto* LHS = BinOp->getLHS()->IgnoreParenImpCasts();
+  const auto* RHS = BinOp->getRHS()->IgnoreParenImpCasts();
+  //  & , mask is a compile time constant.
+  Expr::EvalResult RHSVal;
+  if (BinOp->getOpcode() == BO_And &&
+  BinOp->getRHS()->EvaluateAsInt(RHSVal, Ctx, Expr::SE_AllowSideEffects)) {
+  return true;
+  }
+  //  + ( % ), where  is a char literal.
+  BinOp->dump();
+  llvm::errs() << "A " << isa(LHS) << " " << (BinOp->getOpcode() == BO_Add)<< "\n";
+  if (isa(LHS) && BinOp->getOpcode() == BO_Add) {
+const auto* RHSOp = dyn_cast(RHS);
+llvm::errs() << "B " << RHSOp << " " << (RHSOp ? RHSOp->getOpcode() == BO_Rem : false)<< "\n";
+if (RHSOp && RHSOp->getOpcode() == BO_Rem) {
+  return true;
+}
+  }
+  return false;
+}
+
 void StringIntegerAssignmentCheck::check(
 const MatchFinder::MatchResult &Result) {
   const auto *Argument = Result.Nodes.getNodeAs("expr");
   SourceLocation Loc = Argument->getBeginLoc();
 
+  // Try to detect a few common expressions to reduce false positives.
+  if (isLikelyCharExpression(Argument, *Result.Context)) {
+return;
+  }
+
   auto Diag =
   diag(Loc, "an integer is interpreted as a character code when assigning "
 "it to a string; if this is intended, cast the integer to the "
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lis

[clang-tools-extra] r354780 - [clang-tidy] misc-string-integer-assignment: ignore toupper/tolower

2019-02-25 Thread Clement Courbet via cfe-commits
Author: courbet
Date: Mon Feb 25 05:09:02 2019
New Revision: 354780

URL: http://llvm.org/viewvc/llvm-project?rev=354780&view=rev
Log:
[clang-tidy] misc-string-integer-assignment: ignore toupper/tolower

Summary: Tis represents ~20% of false positives. See PR27723.

Reviewers: xazax.hun, alexfh

Subscribers: rnkovacs, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp?rev=354780&r1=354779&r2=354780&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp 
Mon Feb 25 05:09:02 2019
@@ -27,10 +27,15 @@ void StringIntegerAssignmentCheck::regis
   callee(cxxMethodDecl(ofClass(classTemplateSpecializationDecl(
   hasName("::std::basic_string"),
   hasTemplateArgument(0, 
refersToType(qualType().bind("type"))),
-  hasArgument(1,
-  ignoringImpCasts(expr(hasType(isInteger()),
-unless(hasType(isAnyCharacter(
-   .bind("expr"))),
+  hasArgument(
+  1,
+  ignoringImpCasts(
+  expr(hasType(isInteger()), unless(hasType(isAnyCharacter())),
+   // Ignore calls to tolower/toupper (see PR27723).
+   unless(callExpr(callee(functionDecl(
+   hasAnyName("tolower", "std::tolower", "toupper",
+  "std::toupper"))
+  .bind("expr"))),
   unless(isInTemplateInstantiation())),
   this);
 }

Modified: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp?rev=354780&r1=354779&r2=354780&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp 
(original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp 
Mon Feb 25 05:09:02 2019
@@ -11,8 +11,14 @@ struct basic_string {
 
 typedef basic_string string;
 typedef basic_string wstring;
+
+int tolower(int i);
+int toupper(int i);
 }
 
+int tolower(int i);
+int toupper(int i);
+
 typedef int MyArcaneChar;
 
 int main() {
@@ -50,4 +56,7 @@ int main() {
 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: an integer is interpreted as a 
chara
 // CHECK-FIXES: {{^}}  as = 6;{{$}}
 
+  s += toupper(x);
+  s += tolower(x);
+  s += std::tolower(x);
 }


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


[PATCH] D58604: [clang-tidy] misc-string-integer-assignment: ignore toupper/tolower

2019-02-25 Thread Clement Courbet via Phabricator via cfe-commits
courbet added a comment.

Thanks.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58604



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


[PATCH] D58604: [clang-tidy] misc-string-integer-assignment: ignore toupper/tolower

2019-02-25 Thread Clement Courbet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354780: [clang-tidy] misc-string-integer-assignment: ignore 
toupper/tolower (authored by courbet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58604

Files:
  clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp


Index: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp
@@ -11,8 +11,14 @@
 
 typedef basic_string string;
 typedef basic_string wstring;
+
+int tolower(int i);
+int toupper(int i);
 }
 
+int tolower(int i);
+int toupper(int i);
+
 typedef int MyArcaneChar;
 
 int main() {
@@ -50,4 +56,7 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: an integer is interpreted as a 
chara
 // CHECK-FIXES: {{^}}  as = 6;{{$}}
 
+  s += toupper(x);
+  s += tolower(x);
+  s += std::tolower(x);
 }
Index: 
clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -27,10 +27,15 @@
   callee(cxxMethodDecl(ofClass(classTemplateSpecializationDecl(
   hasName("::std::basic_string"),
   hasTemplateArgument(0, 
refersToType(qualType().bind("type"))),
-  hasArgument(1,
-  ignoringImpCasts(expr(hasType(isInteger()),
-unless(hasType(isAnyCharacter(
-   .bind("expr"))),
+  hasArgument(
+  1,
+  ignoringImpCasts(
+  expr(hasType(isInteger()), unless(hasType(isAnyCharacter())),
+   // Ignore calls to tolower/toupper (see PR27723).
+   unless(callExpr(callee(functionDecl(
+   hasAnyName("tolower", "std::tolower", "toupper",
+  "std::toupper"))
+  .bind("expr"))),
   unless(isInTemplateInstantiation())),
   this);
 }


Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-string-integer-assignment.cpp
@@ -11,8 +11,14 @@
 
 typedef basic_string string;
 typedef basic_string wstring;
+
+int tolower(int i);
+int toupper(int i);
 }
 
+int tolower(int i);
+int toupper(int i);
+
 typedef int MyArcaneChar;
 
 int main() {
@@ -50,4 +56,7 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: an integer is interpreted as a chara
 // CHECK-FIXES: {{^}}  as = 6;{{$}}
 
+  s += toupper(x);
+  s += tolower(x);
+  s += std::tolower(x);
 }
Index: clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -27,10 +27,15 @@
   callee(cxxMethodDecl(ofClass(classTemplateSpecializationDecl(
   hasName("::std::basic_string"),
   hasTemplateArgument(0, refersToType(qualType().bind("type"))),
-  hasArgument(1,
-  ignoringImpCasts(expr(hasType(isInteger()),
-unless(hasType(isAnyCharacter(
-   .bind("expr"))),
+  hasArgument(
+  1,
+  ignoringImpCasts(
+  expr(hasType(isInteger()), unless(hasType(isAnyCharacter())),
+   // Ignore calls to tolower/toupper (see PR27723).
+   unless(callExpr(callee(functionDecl(
+   hasAnyName("tolower", "std::tolower", "toupper",
+  "std::toupper"))
+  .bind("expr"))),
   unless(isInTemplateInstantiation())),
   this);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58611: Fixed typos in tests: s/CHEKC/CHECK/

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr created this revision.
gribozavr added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, jsji, javed.absar, nemanjai.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58611

Files:
  clang/test/CodeGenObjC/dllstorage.m
  clang/test/CodeGenObjC/gnustep2-category-protocol.m
  llvm/test/CodeGen/AArch64/nonlazybind.ll
  llvm/test/CodeGen/ARM/cmpxchg.mir
  llvm/test/CodeGen/ARM/peephole-phi.mir
  llvm/test/CodeGen/PowerPC/scavenging.mir


Index: llvm/test/CodeGen/PowerPC/scavenging.mir
===
--- llvm/test/CodeGen/PowerPC/scavenging.mir
+++ llvm/test/CodeGen/PowerPC/scavenging.mir
@@ -157,7 +157,7 @@
 # CHECK: [[REG]] = LIS8 0
 # CHECK: [[REG]] = ORI8 killed [[REG]], 48
 # CHECK: NOP implicit killed [[REG]]
-# CHEKC: [[REG]] = LD{{.*}}(load 8 from %stack.{{[0-9]+}})
+# CHECK: [[REG]] = LD{{.*}}(load 8 from %stack.{{[0-9]+}})
 name: spill_at_begin
 tracksRegLiveness: true
 stack:
Index: llvm/test/CodeGen/ARM/peephole-phi.mir
===
--- llvm/test/CodeGen/ARM/peephole-phi.mir
+++ llvm/test/CodeGen/ARM/peephole-phi.mir
@@ -44,7 +44,7 @@
 
 # CHECK-LABEL: name: func1
 # CHECK:%6:spr = PHI %0, %bb.1, %2, %bb.2
-# CHEKC:%7:spr = COPY %6
+# CHECK:%7:spr = COPY %6
 ---
 name: func1
 tracksRegLiveness: true
Index: llvm/test/CodeGen/ARM/cmpxchg.mir
===
--- llvm/test/CodeGen/ARM/cmpxchg.mir
+++ llvm/test/CodeGen/ARM/cmpxchg.mir
@@ -10,7 +10,7 @@
 ; CHECK: bb.0:
 ; CHECK:   liveins: $r0_r1, $r4_r5, $r3, $lr
 ; CHECK: bb.1:
-; CHEKC:   liveins: $r4_r5, $r3
+; CHECK:   liveins: $r4_r5, $r3
 ; CHECK:   $r0_r1 = LDREXD $r3, 14, $noreg
 ; CHECK:   CMPrr killed $r0, $r4, 14, $noreg, implicit-def $cpsr
 ; CHECK:   CMPrr killed $r1, $r5, 0, killed $cpsr, implicit-def $cpsr
Index: llvm/test/CodeGen/AArch64/nonlazybind.ll
===
--- llvm/test/CodeGen/AArch64/nonlazybind.ll
+++ llvm/test/CodeGen/AArch64/nonlazybind.ll
@@ -18,7 +18,7 @@
 
 ; CHECK-NORMAL-LABEL: test_laziness:
 ; CHECK-NORMAL: bl _local
-; CHEKC-NORMAL: bl _nonlocal
+; CHECK-NORMAL: bl _nonlocal
 
   call void @local()
   call void @nonlocal()
Index: clang/test/CodeGenObjC/gnustep2-category-protocol.m
===
--- clang/test/CodeGenObjC/gnustep2-category-protocol.m
+++ clang/test/CodeGenObjC/gnustep2-category-protocol.m
@@ -5,7 +5,7 @@
 // to a protocol in a binary.
 
 // CHECK: @._OBJC_PROTOCOL_Y = global 
-// CHEKC-SAME: section "__objc_protocols", comdat, align 8
+// CHECK-SAME: section "__objc_protocols", comdat, align 8
 
 
 @interface X
Index: clang/test/CodeGenObjC/dllstorage.m
===
--- clang/test/CodeGenObjC/dllstorage.m
+++ clang/test/CodeGenObjC/dllstorage.m
@@ -85,7 +85,7 @@
 }
 @end
 
-// CHEKC-FW-DAG: @_OBJC_CLASS_M = external dllimport global i32
+// CHECK-FW-DAG: @_OBJC_CLASS_M = external dllimport global i32
 
 // CHECK-IR-DAG: @"OBJC_IVAR_$_M._ivar" = external dllimport global i32
 


Index: llvm/test/CodeGen/PowerPC/scavenging.mir
===
--- llvm/test/CodeGen/PowerPC/scavenging.mir
+++ llvm/test/CodeGen/PowerPC/scavenging.mir
@@ -157,7 +157,7 @@
 # CHECK: [[REG]] = LIS8 0
 # CHECK: [[REG]] = ORI8 killed [[REG]], 48
 # CHECK: NOP implicit killed [[REG]]
-# CHEKC: [[REG]] = LD{{.*}}(load 8 from %stack.{{[0-9]+}})
+# CHECK: [[REG]] = LD{{.*}}(load 8 from %stack.{{[0-9]+}})
 name: spill_at_begin
 tracksRegLiveness: true
 stack:
Index: llvm/test/CodeGen/ARM/peephole-phi.mir
===
--- llvm/test/CodeGen/ARM/peephole-phi.mir
+++ llvm/test/CodeGen/ARM/peephole-phi.mir
@@ -44,7 +44,7 @@
 
 # CHECK-LABEL: name: func1
 # CHECK:%6:spr = PHI %0, %bb.1, %2, %bb.2
-# CHEKC:%7:spr = COPY %6
+# CHECK:%7:spr = COPY %6
 ---
 name: func1
 tracksRegLiveness: true
Index: llvm/test/CodeGen/ARM/cmpxchg.mir
===
--- llvm/test/CodeGen/ARM/cmpxchg.mir
+++ llvm/test/CodeGen/ARM/cmpxchg.mir
@@ -10,7 +10,7 @@
 ; CHECK: bb.0:
 ; CHECK:   liveins: $r0_r1, $r4_r5, $r3, $lr
 ; CHECK: bb.1:
-; CHEKC:   liveins: $r4_r5, $r3
+; CHECK:   liveins: $r4_r5, $r3
 ; CHECK:   $r0_r1 = LDREXD $r3, 14, $noreg
 ; CHECK:   CMPrr killed $r0, $r4, 14, $noreg, implicit-def $cpsr
 ; CHECK:   CMPrr killed $r1, $r5, 0, killed $cpsr, implicit-def $cpsr
Index: llvm/test/CodeGen/AArch64/nonlazybind.ll
===
--- llvm/test/CodeGen/AArch64/nonlazybind.ll
+++ llvm/test/CodeGen/AArch64/nonlazybind.ll
@@ -18,7 +18,7 @@
 
 ; CHECK-NORMAL-LABEL: te

[PATCH] D58611: Fixed typos in tests: s/CHEKC/CHECK/

2019-02-25 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58611



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


[PATCH] D58612: Use std::atomic<> for static counters.

2019-02-25 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh created this revision.
alexfh added a reviewer: ilya-biryukov.
Herald added a subscriber: jfb.
Herald added a project: clang.

Fixes a data race and makes it possible to run clang-based tools in
multithreaded environment with TSan.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D58612

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

Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -94,18 +94,18 @@
 
 using namespace clang;
 
-unsigned ASTContext::NumImplicitDefaultConstructors;
-unsigned ASTContext::NumImplicitDefaultConstructorsDeclared;
-unsigned ASTContext::NumImplicitCopyConstructors;
-unsigned ASTContext::NumImplicitCopyConstructorsDeclared;
-unsigned ASTContext::NumImplicitMoveConstructors;
-unsigned ASTContext::NumImplicitMoveConstructorsDeclared;
-unsigned ASTContext::NumImplicitCopyAssignmentOperators;
-unsigned ASTContext::NumImplicitCopyAssignmentOperatorsDeclared;
-unsigned ASTContext::NumImplicitMoveAssignmentOperators;
-unsigned ASTContext::NumImplicitMoveAssignmentOperatorsDeclared;
-unsigned ASTContext::NumImplicitDestructors;
-unsigned ASTContext::NumImplicitDestructorsDeclared;
+std::atomic ASTContext::NumImplicitDefaultConstructors;
+std::atomic ASTContext::NumImplicitDefaultConstructorsDeclared;
+std::atomic ASTContext::NumImplicitCopyConstructors;
+std::atomic ASTContext::NumImplicitCopyConstructorsDeclared;
+std::atomic ASTContext::NumImplicitMoveConstructors;
+std::atomic ASTContext::NumImplicitMoveConstructorsDeclared;
+std::atomic ASTContext::NumImplicitCopyAssignmentOperators;
+std::atomic ASTContext::NumImplicitCopyAssignmentOperatorsDeclared;
+std::atomic ASTContext::NumImplicitMoveAssignmentOperators;
+std::atomic ASTContext::NumImplicitMoveAssignmentOperatorsDeclared;
+std::atomic ASTContext::NumImplicitDestructors;
+std::atomic ASTContext::NumImplicitDestructorsDeclared;
 
 enum FloatingRank {
   Float16Rank, HalfRank, FloatRank, DoubleRank, LongDoubleRank, Float128Rank
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -63,6 +63,7 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
+#include 
 #include 
 #include 
 #include 
@@ -2809,46 +2810,46 @@
   //======//
 
   /// The number of implicitly-declared default constructors.
-  static unsigned NumImplicitDefaultConstructors;
+  static std::atomic NumImplicitDefaultConstructors;
 
   /// The number of implicitly-declared default constructors for
   /// which declarations were built.
-  static unsigned NumImplicitDefaultConstructorsDeclared;
+  static std::atomic NumImplicitDefaultConstructorsDeclared;
 
   /// The number of implicitly-declared copy constructors.
-  static unsigned NumImplicitCopyConstructors;
+  static std::atomic NumImplicitCopyConstructors;
 
   /// The number of implicitly-declared copy constructors for
   /// which declarations were built.
-  static unsigned NumImplicitCopyConstructorsDeclared;
+  static std::atomic NumImplicitCopyConstructorsDeclared;
 
   /// The number of implicitly-declared move constructors.
-  static unsigned NumImplicitMoveConstructors;
+  static std::atomic NumImplicitMoveConstructors;
 
   /// The number of implicitly-declared move constructors for
   /// which declarations were built.
-  static unsigned NumImplicitMoveConstructorsDeclared;
+  static std::atomic NumImplicitMoveConstructorsDeclared;
 
   /// The number of implicitly-declared copy assignment operators.
-  static unsigned NumImplicitCopyAssignmentOperators;
+  static std::atomic NumImplicitCopyAssignmentOperators;
 
   /// The number of implicitly-declared copy assignment operators for
   /// which declarations were built.
-  static unsigned NumImplicitCopyAssignmentOperatorsDeclared;
+  static std::atomic NumImplicitCopyAssignmentOperatorsDeclared;
 
   /// The number of implicitly-declared move assignment operators.
-  static unsigned NumImplicitMoveAssignmentOperators;
+  static std::atomic NumImplicitMoveAssignmentOperators;
 
   /// The number of implicitly-declared move assignment operators for
   /// which declarations were built.
-  static unsigned NumImplicitMoveAssignmentOperatorsDeclared;
+  static std::atomic NumImplicitMoveAssignmentOperatorsDeclared;
 
   /// The number of implicitly-declared destructors.
-  static unsigned NumImplicitDestructors;
+  static std::atomic NumImplicitDestructors;
 
   /// The number of implicitly-declared destructors for which
   /// declarations were built.
-  static unsigned NumImplicitDestructorsDeclared;
+  static std::atomic NumImplicitDestructorsDeclared;
 
 public:
   /// Initialize built-in types.
__

r354785 - Fixed typos in tests: s/CHEKC/CHECK/

2019-02-25 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Mon Feb 25 05:41:59 2019
New Revision: 354785

URL: http://llvm.org/viewvc/llvm-project?rev=354785&view=rev
Log:
Fixed typos in tests: s/CHEKC/CHECK/

Reviewers: ilya-biryukov

Subscribers: nemanjai, javed.absar, jsji, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Modified:
cfe/trunk/test/CodeGenObjC/dllstorage.m
cfe/trunk/test/CodeGenObjC/gnustep2-category-protocol.m

Modified: cfe/trunk/test/CodeGenObjC/dllstorage.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/dllstorage.m?rev=354785&r1=354784&r2=354785&view=diff
==
--- cfe/trunk/test/CodeGenObjC/dllstorage.m (original)
+++ cfe/trunk/test/CodeGenObjC/dllstorage.m Mon Feb 25 05:41:59 2019
@@ -85,7 +85,7 @@ __declspec(dllimport)
 }
 @end
 
-// CHEKC-FW-DAG: @_OBJC_CLASS_M = external dllimport global i32
+// CHECK-FW-DAG: @_OBJC_CLASS_M = external dllimport global i32
 
 // CHECK-IR-DAG: @"OBJC_IVAR_$_M._ivar" = external dllimport global i32
 

Modified: cfe/trunk/test/CodeGenObjC/gnustep2-category-protocol.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/gnustep2-category-protocol.m?rev=354785&r1=354784&r2=354785&view=diff
==
--- cfe/trunk/test/CodeGenObjC/gnustep2-category-protocol.m (original)
+++ cfe/trunk/test/CodeGenObjC/gnustep2-category-protocol.m Mon Feb 25 05:41:59 
2019
@@ -5,7 +5,7 @@
 // to a protocol in a binary.
 
 // CHECK: @._OBJC_PROTOCOL_Y = global 
-// CHEKC-SAME: section "__objc_protocols", comdat, align 8
+// CHECK-SAME: section "__objc_protocols", comdat, align 8
 
 
 @interface X


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


[PATCH] D58612: Use std::atomic<> for static counters.

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

Hmm. These are not the only static variables which are used for statistics (eg: 
in `DeclBase.cpp`). Would it make sense instead to keep all of the statistics 
in the AST context (without making them atomic) ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58612



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


[clang-tools-extra] r354786 - Moved clangd docs to a separate directory in preparation to restructure them into multiple files

2019-02-25 Thread Dmitri Gribenko via cfe-commits
Author: gribozavr
Date: Mon Feb 25 05:43:48 2019
New Revision: 354786

URL: http://llvm.org/viewvc/llvm-project?rev=354786&view=rev
Log:
Moved clangd docs to a separate directory in preparation to restructure them 
into multiple files

Reviewers: ilya-biryukov

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

Tags: #clang

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

Added:
clang-tools-extra/trunk/docs/clangd/
clang-tools-extra/trunk/docs/clangd/index.rst
Modified:
clang-tools-extra/trunk/docs/clangd.rst
clang-tools-extra/trunk/docs/index.rst

Modified: clang-tools-extra/trunk/docs/clangd.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clangd.rst?rev=354786&r1=354785&r2=354786&view=diff
==
--- clang-tools-extra/trunk/docs/clangd.rst (original)
+++ clang-tools-extra/trunk/docs/clangd.rst Mon Feb 25 05:43:48 2019
@@ -1,180 +1,3 @@
-
-Clangd
-
+:orphan:
 
-.. contents::
-
-.. toctree::
-   :maxdepth: 1
-
-:program:`Clangd` is an implementation of the `Language Server Protocol
-`_ leveraging Clang.
-Clangd's goal is to provide language "smartness" features like code completion,
-find references, etc. for clients such as C/C++ Editors.
-
-Using Clangd
-==
-
-:program:`Clangd` is not meant to be used by C/C++ developers directly but
-rather from a client implementing the protocol. A client would be typically
-implemented in an IDE or an editor.
-
-At the moment, `Visual Studio Code `_ is mainly
-used in order to test :program:`Clangd` but more clients are likely to make
-use of :program:`Clangd` in the future as it matures and becomes a production
-quality tool. If you are interested in trying :program:`Clangd` in combination
-with Visual Studio Code, you can start by `installing Clangd`_ or
-`building Clangd`_, then open Visual Studio Code in the clangd-vscode folder 
and
-launch the extension.
-
-Installing Clangd
-==
-
-Packages are available for debian-based distributions, see the `LLVM packages
-page `_. :program:`Clangd` is included in the
-`clang-tools` package.
-However, it is a good idea to check your distribution's packaging system first
-as it might already be available.
-
-Otherwise, you can install :program:`Clangd` by `building Clangd`_ first.
-
-Building Clangd
-==
-
-You can follow the instructions for `building Clang
-`_ but "extra Clang tools" is **not**
-optional.
-
-Current Status
-==
-
-Many features could be implemented in :program:`Clangd`.
-Here is a list of features that could be useful with the status of whether or
-not they are already implemented in :program:`Clangd` and specified in the
-Language Server Protocol. Note that for some of the features, it is not clear
-whether or not they should be part of the Language Server Protocol, so those
-features might be eventually developed outside :program:`Clangd` or as an
-extension to the protocol.
-
-+-++--+
-| C/C++ Editor feature|  LSP   |  Clangd  |
-+=++==+
-| Formatting  | Yes|   Yes|
-+-++--+
-| Completion  | Yes|   Yes|
-+-++--+
-| Diagnostics | Yes|   Yes|
-+-++--+
-| Fix-its | Yes|   Yes|
-+-++--+
-| Go to Definition| Yes|   Yes|
-+-++--+
-| Signature Help  | Yes|   Yes|
-+-++--+
-| Document Highlights | Yes|   Yes|
-+-++--+
-| Rename  | Yes|   Yes|
-+-++--+
-| Source hover| Yes|   Yes|
-+-++--+
-| Find References | Yes|   No |
-+-++--+
-| Code Lens   | Yes|   No |
-+-++--+
-| Document Symbols| Yes|   Yes|
-+-++--+
-| Workspace Symbols   

[PATCH] D58611: Fixed typos in tests: s/CHEKC/CHECK/

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC354785: Fixed typos in tests: s/CHEKC/CHECK/ (authored by 
gribozavr, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58611?vs=188143&id=188150#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58611

Files:
  test/CodeGenObjC/dllstorage.m
  test/CodeGenObjC/gnustep2-category-protocol.m


Index: test/CodeGenObjC/dllstorage.m
===
--- test/CodeGenObjC/dllstorage.m
+++ test/CodeGenObjC/dllstorage.m
@@ -85,7 +85,7 @@
 }
 @end
 
-// CHEKC-FW-DAG: @_OBJC_CLASS_M = external dllimport global i32
+// CHECK-FW-DAG: @_OBJC_CLASS_M = external dllimport global i32
 
 // CHECK-IR-DAG: @"OBJC_IVAR_$_M._ivar" = external dllimport global i32
 
Index: test/CodeGenObjC/gnustep2-category-protocol.m
===
--- test/CodeGenObjC/gnustep2-category-protocol.m
+++ test/CodeGenObjC/gnustep2-category-protocol.m
@@ -5,7 +5,7 @@
 // to a protocol in a binary.
 
 // CHECK: @._OBJC_PROTOCOL_Y = global 
-// CHEKC-SAME: section "__objc_protocols", comdat, align 8
+// CHECK-SAME: section "__objc_protocols", comdat, align 8
 
 
 @interface X


Index: test/CodeGenObjC/dllstorage.m
===
--- test/CodeGenObjC/dllstorage.m
+++ test/CodeGenObjC/dllstorage.m
@@ -85,7 +85,7 @@
 }
 @end
 
-// CHEKC-FW-DAG: @_OBJC_CLASS_M = external dllimport global i32
+// CHECK-FW-DAG: @_OBJC_CLASS_M = external dllimport global i32
 
 // CHECK-IR-DAG: @"OBJC_IVAR_$_M._ivar" = external dllimport global i32
 
Index: test/CodeGenObjC/gnustep2-category-protocol.m
===
--- test/CodeGenObjC/gnustep2-category-protocol.m
+++ test/CodeGenObjC/gnustep2-category-protocol.m
@@ -5,7 +5,7 @@
 // to a protocol in a binary.
 
 // CHECK: @._OBJC_PROTOCOL_Y = global 
-// CHEKC-SAME: section "__objc_protocols", comdat, align 8
+// CHECK-SAME: section "__objc_protocols", comdat, align 8
 
 
 @interface X
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58607: Moved clangd docs to a separate directory in preparation to restructure them into multiple files

2019-02-25 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rCTE354786: Moved clangd docs to a separate directory in 
preparation to restructure them… (authored by gribozavr, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58607?vs=188131&id=188151#toc

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D58607

Files:
  docs/clangd.rst
  docs/clangd/index.rst
  docs/index.rst

Index: docs/clangd/index.rst
===
--- docs/clangd/index.rst
+++ docs/clangd/index.rst
@@ -0,0 +1,180 @@
+
+Clangd
+
+
+.. contents::
+
+.. toctree::
+   :maxdepth: 1
+
+:program:`Clangd` is an implementation of the `Language Server Protocol
+`_ leveraging Clang.
+Clangd's goal is to provide language "smartness" features like code completion,
+find references, etc. for clients such as C/C++ Editors.
+
+Using Clangd
+==
+
+:program:`Clangd` is not meant to be used by C/C++ developers directly but
+rather from a client implementing the protocol. A client would be typically
+implemented in an IDE or an editor.
+
+At the moment, `Visual Studio Code `_ is mainly
+used in order to test :program:`Clangd` but more clients are likely to make
+use of :program:`Clangd` in the future as it matures and becomes a production
+quality tool. If you are interested in trying :program:`Clangd` in combination
+with Visual Studio Code, you can start by `installing Clangd`_ or
+`building Clangd`_, then open Visual Studio Code in the clangd-vscode folder and
+launch the extension.
+
+Installing Clangd
+==
+
+Packages are available for debian-based distributions, see the `LLVM packages
+page `_. :program:`Clangd` is included in the
+`clang-tools` package.
+However, it is a good idea to check your distribution's packaging system first
+as it might already be available.
+
+Otherwise, you can install :program:`Clangd` by `building Clangd`_ first.
+
+Building Clangd
+==
+
+You can follow the instructions for `building Clang
+`_ but "extra Clang tools" is **not**
+optional.
+
+Current Status
+==
+
+Many features could be implemented in :program:`Clangd`.
+Here is a list of features that could be useful with the status of whether or
+not they are already implemented in :program:`Clangd` and specified in the
+Language Server Protocol. Note that for some of the features, it is not clear
+whether or not they should be part of the Language Server Protocol, so those
+features might be eventually developed outside :program:`Clangd` or as an
+extension to the protocol.
+
++-++--+
+| C/C++ Editor feature|  LSP   |  Clangd  |
++=++==+
+| Formatting  | Yes|   Yes|
++-++--+
+| Completion  | Yes|   Yes|
++-++--+
+| Diagnostics | Yes|   Yes|
++-++--+
+| Fix-its | Yes|   Yes|
++-++--+
+| Go to Definition| Yes|   Yes|
++-++--+
+| Signature Help  | Yes|   Yes|
++-++--+
+| Document Highlights | Yes|   Yes|
++-++--+
+| Rename  | Yes|   Yes|
++-++--+
+| Source hover| Yes|   Yes|
++-++--+
+| Find References | Yes|   No |
++-++--+
+| Code Lens   | Yes|   No |
++-++--+
+| Document Symbols| Yes|   Yes|
++-++--+
+| Workspace Symbols   | Yes|   Yes|
++-++--+
+| Syntax and Semantic Coloring| No |   No |
++-++--+
+| Code folding| No |   No |
++---

  1   2   >