[PATCH] D69360: [NFC] Refactor representation of materialized temporaries

2019-11-16 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Reverted in c9276fbfdf0c7caf1576b2 
 for now. 
Please watch the bots after landing things, and revert if something breaks and 
it takes you a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69360



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


[clang] c9276fb - Revert "[NFC] Refactor representation of materialized temporaries"

2019-11-16 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2019-11-17T02:09:25-05:00
New Revision: c9276fbfdf0c7caf1576b2db562286d7cec7e53b

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

LOG: Revert "[NFC] Refactor representation of materialized temporaries"

This reverts commit 08ea1ee2db5f9d6460fef1d79d0d1d1a5eb78982.
It broke ./ClangdTests/FindExplicitReferencesTest.All
on the bots, see comments on https://reviews.llvm.org/D69360

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/include/clang/Basic/DeclNodes.td
clang/include/clang/Sema/Template.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/Analysis/CFG.cpp
clang/lib/Analysis/Consumed.cpp
clang/lib/Analysis/ThreadSafetyCommon.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/JumpDiagnostics.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
index 0780924f3557..a249b1216111 100644
--- a/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
@@ -24,7 +24,7 @@ AST_MATCHER_P(Stmt, IgnoringTemporaries, 
ast_matchers::internal::Matcher,
   const Stmt *E = 
   while (true) {
 if (const auto *MTE = dyn_cast(E))
-  E = MTE->getSubExpr();
+  E = MTE->getTemporary();
 if (const auto *BTE = dyn_cast(E))
   E = BTE->getSubExpr();
 if (const auto *ICE = dyn_cast(E))

diff  --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
index 2d4475c991ca..c51b6e86b3f6 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
@@ -53,7 +53,7 @@ buildBindArguments(const MatchFinder::MatchResult , 
const CallExpr *C) {
 const Expr *E = C->getArg(I);
 BindArgument B;
 if (const auto *M = dyn_cast(E)) {
-  const auto *TE = M->getSubExpr();
+  const auto *TE = M->GetTemporaryExpr();
   B.Kind = isa(TE) ? BK_CallExpr : BK_Temporary;
 }
 

diff  --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp 
b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
index 0389a6148954..03efd12ded21 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -177,7 +177,7 @@ const Expr *digThroughConstructors(const Expr *E) {
   return nullptr;
 E = ConstructExpr->getArg(0);
 if (const auto *Temp = dyn_cast(E))
-  E = Temp->getSubExpr();
+  E = Temp->GetTemporaryExpr();
 return digThroughConstructors(E);
   }
   return E;

diff  --git 
a/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
index a52065540917..e3b90d3b4279 100644
--- a/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
@@ -78,7 +78,7 @@ void ImplicitConversionInLoopCheck::check(
   // iterator returns a value instead of a reference, and the 

[PATCH] D67536: [clangd] Inactive regions support as an extension to semantic highlighting

2019-11-16 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 229707.
nridge added a comment.

Support preamble as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67536

Files:
  clang-tools-extra/clangd/CollectMacros.h
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -140,7 +140,7 @@
   }
   for (auto  : ExpectedLines)
 ExpectedLinePairHighlighting.push_back(
-{LineTokens.first, LineTokens.second});
+{LineTokens.first, LineTokens.second, /*IsInactive = */ false});
 
   std::vector ActualDiffed =
   diffHighlightings(NewTokens, OldTokens);
@@ -493,11 +493,11 @@
 
   #define $Macro[[test]]
   #undef $Macro[[test]]
-  #ifdef $Macro[[test]]
-  #endif
+$InactiveCode[[]]  #ifdef $Macro[[test]]
+$InactiveCode[[]]  #endif
 
-  #if defined($Macro[[test]])
-  #endif
+$InactiveCode[[]]  #if defined($Macro[[test]])
+$InactiveCode[[]]  #endif
 )cpp",
   R"cpp(
   struct $Class[[S]] {
@@ -589,6 +589,33 @@
   R"cpp(
   void $Function[[foo]]();
   using ::$Function[[foo]];
+)cpp",
+  // Inactive code highlighting
+  R"cpp(
+  // Code in the preamble.
+  // Inactive lines get an empty InactiveCode token at the beginning.
+$InactiveCode[[]]  #ifdef $Macro[[test]]
+$InactiveCode[[]]  #endif
+
+  // A declaration to cause the preamble to end.
+  int $Variable[[EndPreamble]];
+
+  // Code after the preamble.
+  // Code inside inactive blocks does not get regular highlightings
+  // because it's not part of the AST.
+$InactiveCode[[]]  #ifdef $Macro[[test]]
+$InactiveCode[[]]  int Inactive2;
+$InactiveCode[[]]  #endif
+
+  #ifndef $Macro[[test]]
+  int $Variable[[Active1]];
+  #endif
+
+$InactiveCode[[]]  #ifdef $Macro[[test]]
+$InactiveCode[[]]  int Inactive3;
+$InactiveCode[[]]  #else
+  int $Variable[[Active2]];
+  #endif
 )cpp"};
   for (const auto  : TestCases) {
 checkHighlightings(TestCase);
@@ -656,10 +683,12 @@
{{HighlightingKind::Variable,
  Range{CreatePosition(3, 8), CreatePosition(3, 12)}},
 {HighlightingKind::Function,
- Range{CreatePosition(3, 4), CreatePosition(3, 7),
+ Range{CreatePosition(3, 4), CreatePosition(3, 7)}}},
+   /* IsInactive = */ false},
   {1,
{{HighlightingKind::Variable,
- Range{CreatePosition(1, 1), CreatePosition(1, 5)};
+ Range{CreatePosition(1, 1), CreatePosition(1, 5)}}},
+   /* IsInactive = */ true}};
   std::vector ActualResults =
   toSemanticHighlightingInformation(Tokens);
   std::vector ExpectedResults = {
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -57,6 +57,9 @@
 # CHECK-NEXT:  ],
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.preprocessor.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"meta.disabled"
 # CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
@@ -66,6 +69,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"lines": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"isInactive": false,
 # CHECK-NEXT:"line": 0,
 # CHECK-NEXT:"tokens": "BAABAAA="
 # CHECK-NEXT:  }
@@ -81,10 +85,12 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"lines": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"isInactive": false,
 # CHECK-NEXT:"line": 0,
 # CHECK-NEXT:"tokens": "BAABAAA="
 # CHECK-NEXT:  }
 # CHECK-NEXT:  {
+# CHECK-NEXT:"isInactive": false,
 # CHECK-NEXT:"line": 1,
 # CHECK-NEXT:"tokens": "BAABAAA="
 # CHECK-NEXT:  }
@@ -100,6 +106,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"lines": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"isInactive": false,
 # CHECK-NEXT:"line": 1,
 # CHECK-NEXT:"tokens": "BAABAAA="
 # CHECK-NEXT:  }
@@ -115,6 +122,7 @@
 # CHECK-NEXT:  "params": {
 # CHECK-NEXT:"lines": [
 # CHECK-NEXT:  {
+# CHECK-NEXT:"isInactive": false,
 # CHECK-NEXT:"line": 1,
 # CHECK-NEXT:"tokens": ""
 # CHECK-NEXT:  }
Index: 

[PATCH] D67536: [clangd] Inactive regions support as an extension to semantic highlighting

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



Comment at: clang-tools-extra/clangd/ParsedAST.h:100
 
+  const std::vector () const {
+return SkippedRanges;

hokein wrote:
> hokein wrote:
> > Instead of adding new member and methods in `ParsedAST`, I think we can do 
> > it in `CollectMainFileMacros` (adding a new field SkippRanges in 
> > `MainFileMacros`), then we can get the skipped ranges for preamble region 
> > within the main file for free.
> This comment is undone.
My apologies, I overlooked this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67536



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


[PATCH] D70274: [clang][IFS] Driver pipeline change for clang-ifs: generate interface stubs after standard pipeline.

2019-11-16 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/lib/Driver/Driver.cpp:3493
+llvm::SmallVector  = PhaseList;
+types::getCompilationPhases(types::TY_IFS_CPP, PL);
+llvm::SmallVector CompilePhaseList;

The reference binding is odd.  Why not just pass `PhaseList`?



Comment at: clang/lib/Driver/Driver.cpp:3500
+  PL = CompilePhaseList;
+}
+

Do you use the `PhaseList` again?  Why not `erase_if`?



Comment at: clang/lib/Driver/Driver.cpp:3506
+  types::ID InputType = I.first;
+  const Arg *InputArg = I.second;
+

structured bindings ... so much.



Comment at: clang/lib/Driver/Driver.cpp:3508
+
+  if (InputType == types::TY_IFS ||
+  InputType == types::TY_PP_Asm ||

A comment explaining that we cannot inspect assembly yet and why ifs don't make 
sense would be nice



Comment at: clang/lib/Driver/Driver.cpp:3515
+
+  for (phases::ID Phase : PL) {
+if (Phase == phases::IfsMerge) {

`auto` would be fine too



Comment at: clang/lib/Driver/ToolChains/InterfaceStubs.cpp:34
+return Filename;
+  };
+

IIRC, `llvm::sys::path::replace_ext` or `stem` should do this?



Comment at: clang/lib/Driver/ToolChains/InterfaceStubs.cpp:45
+OutputFilename =
+TrimFileExt(OutputFilename, ".so") + (WriteBin ? ".ifso" : ".ifs");
+  CmdArgs.push_back(Args.MakeArgString(OutputFilename.c_str()));

`llvm::sys::fs::replace_ext`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70274



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


[PATCH] D54395: [clang-tidy] implement utility-function to add 'const' to variables

2019-11-16 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth updated this revision to Diff 229705.
JonasToth marked 2 inline comments as done.
JonasToth removed a subscriber: mgehre.
JonasToth added a comment.

- [Misc] port patch to monorepo
- add more test cases for the transformation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54395

Files:
  clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.h
  clang-tools-extra/clang-tidy/utils/LexerUtils.cpp
  clang-tools-extra/clang-tidy/utils/LexerUtils.h
  clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt

Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -7,6 +7,7 @@
 include_directories(${CLANG_LINT_SOURCE_DIR})
 
 add_extra_unittest(ClangTidyTests
+  AddConstTest.cpp
   ClangTidyDiagnosticConsumerTest.cpp
   ClangTidyOptionsTest.cpp
   IncludeInserterTest.cpp
Index: clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/AddConstTest.cpp
@@ -0,0 +1,982 @@
+#include "../clang-tidy/utils/FixItHintUtils.h"
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+
+namespace {
+using namespace clang::ast_matchers;
+using namespace utils::fixit;
+
+template 
+class ConstTransform : public ClangTidyCheck {
+public:
+  ConstTransform(StringRef CheckName, ClangTidyContext *Context)
+  : ClangTidyCheck(CheckName, Context) {}
+
+  void registerMatchers(MatchFinder *Finder) override {
+Finder->addMatcher(varDecl(hasName("target")).bind("var"), this);
+  }
+
+  void check(const MatchFinder::MatchResult ) override {
+const auto *D = Result.Nodes.getNodeAs("var");
+using utils::fixit::addQualifierToVarDecl;
+Optional Fix = addQualifierToVarDecl(*D, DeclSpec::TQ::TQ_const,
+CT, CP, Result.Context);
+auto Diag = diag(D->getBeginLoc(), "doing const transformation");
+if (Fix)
+  Diag << *Fix;
+  }
+};
+} // namespace
+
+namespace test {
+using PointeeLTransform =
+ConstTransform;
+using PointeeRTransform =
+ConstTransform;
+
+using ValueLTransform =
+ConstTransform;
+using ValueRTransform =
+ConstTransform;
+
+// 
+// Test Value-like types. Everything with indirection is done later.
+// 
+
+TEST(Values, Builtin) {
+  StringRef Snippet = "int target = 0;";
+
+  EXPECT_EQ("const int target = 0;", runCheckOnCode(Snippet));
+  EXPECT_EQ("const int target = 0;",
+runCheckOnCode(Snippet));
+
+  EXPECT_EQ("int const target = 0;", runCheckOnCode(Snippet));
+  EXPECT_EQ("int const target = 0;",
+runCheckOnCode(Snippet));
+}
+TEST(Values, TypedefBuiltin) {
+  StringRef T = "typedef int MyInt;";
+  StringRef S = "MyInt target = 0;";
+  auto Cat = [](StringRef S) { return (T + S).str(); };
+
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+}
+TEST(Values, TypedefBuiltinPointer) {
+  StringRef T = "typedef int* MyInt;";
+  StringRef S = "MyInt target = nullptr;";
+  auto Cat = [](StringRef S) { return (T + S).str(); };
+
+  EXPECT_EQ(Cat("const MyInt target = nullptr;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("const MyInt target = nullptr;"),
+runCheckOnCode(Cat(S)));
+
+  EXPECT_EQ(Cat("MyInt const target = nullptr;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("MyInt const target = nullptr;"),
+runCheckOnCode(Cat(S)));
+}
+TEST(Values, UsingBuiltin) {
+  StringRef T = "using MyInt = int;";
+  StringRef S = "MyInt target = 0;";
+  auto Cat = [](StringRef S) { return (T + S).str(); };
+
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+  EXPECT_EQ(Cat("const MyInt target = 0;"),
+runCheckOnCode(Cat(S)));
+
+  EXPECT_EQ(Cat("MyInt const target = 0;"),
+runCheckOnCode(Cat(S)));
+  

[PATCH] D54395: [clang-tidy] implement utility-function to add 'const' to variables

2019-11-16 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth marked 5 inline comments as done.
JonasToth added inline comments.
Herald added a subscriber: mgehre.



Comment at: clang-tidy/utils/FixItHintUtils.cpp:35
+static bool isValueType(QualType QT) { return isValueType(QT.getTypePtr()); }
+static bool isArrayType(QualType QT) { return isa(QT.getTypePtr()); 
}
+static bool isReferenceType(QualType QT) {

lebedev.ri wrote:
> JonasToth wrote:
> > aaron.ballman wrote:
> > > This file is replicating a bunch of functionality that exists on the 
> > > `Type*` already. Why do this rather than have the caller do 
> > > `QT->isArrayType()` and skip this function entirely? (Same exists 
> > > elsewhere here.)
> > I had the issue that typedefs are resolved, but shouldn't. If I am not 
> > mistaken `QT->isArrayType()` would go to the canconical type.
> > 
> > ```
> > using MyPtr = int*;
> > MyPtr foo = nullptr;
> > ```
> > Is treated wrong in that case.
> There is a test for that, right?
Yes, both `typedef` and `using`.



Comment at: unittests/clang-tidy/AddConstTest.cpp:733
+  StringRef T = "template  void f(T v) \n";
+  StringRef S = "{ T target = v; }";
+  auto Cat = [](StringRef S) { return (T + S).str(); };

lebedev.ri wrote:
> lebedev.ri wrote:
> > JonasToth wrote:
> > > alexfh wrote:
> > > > It would be interesting to see test cases with multiple instantiations 
> > > > of the template the fix applies to.
> > > I added test for a template function with many instantiations, but there 
> > > should not be a difference between the instantiations, because only the 
> > > original code would be transformed, and there the 'how it looks' counts, 
> > > so in this case it will be treated as a value.
> > > Did I misinterpret your question?
> > How about 
> > https://en.cppreference.com/w/cpp/language/function_template#Explicit_instantiation
> >  ?
> > I don't see any tests for that.
> Also, is there any test coverage missing for 
> https://en.cppreference.com/w/cpp/language/template_specialization
> and
> https://en.cppreference.com/w/cpp/language/partial_specialization
> ?
i added tests for specializations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54395



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


[PATCH] D70144: clang-tidy: modernize-use-equals-default avoid adding redundant semicolons

2019-11-16 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Hmm. I think this is fine, even though its not perfect.
@aaron.ballman wdyt?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70144



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


[PATCH] D69360: [NFC] Refactor representation of materialized temporaries

2019-11-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added subscribers: ilya-biryukov, sammccall.
sammccall added a comment.

This seems to have broken clangd tests e.g. 
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/58189/steps/test-check-all/logs/stdio

FindExplicitReferences now finds duplicate refs to `vector` in

   void foo() {
  -  for (int $0^x : $1^vector()) {
  -$2^x = 10;
  +  for (int $0^x : $1^$2^vector()) {
  +$3^x = 10;
 }
   }

`ninja check-clangd`, or `ninja ClangdTests && 
tools/clang/tools/extra/clangd/unittests/ClangdTests 
--gtest_filter=FindExplicitReferencesTest.All`

I don't have much context on this code, @ilya-biryukov may be able to advise 
next week


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69360



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


[PATCH] D70359: [clangd] Show values of more expressions on hover

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: fail - 60143 tests passed, 2 failed and 729 were skipped.

  failed: Clangd Unit Tests._/ClangdTests/FindExplicitReferencesTest.All
  failed: LLVM.Bindings/Go/go.test

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70359



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


[PATCH] D70359: [clangd] Show values of more expressions on hover

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70359

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -275,6 +275,7 @@
  {std::string("int"), std::string("T"), llvm::None},
  {std::string("bool"), std::string("B"), llvm::None},
  };
+ HI.Value = "false";
  return HI;
}},
   // Lambda variable
@@ -433,10 +434,23 @@
  HI.Definition = "GREEN";
  HI.Kind = SymbolKind::EnumMember;
  HI.Type = "enum Color";
- HI.Value = "1";
+ HI.Value = "1"; // Numeric when hovering on the enumerator name.
+   }},
+  {R"cpp(
+enum Color { RED, GREEN, };
+Color x = GREEN;
+Color y = [[^x]];
+   )cpp",
+   [](HoverInfo ) {
+ HI.Name = "x";
+ HI.NamespaceScope = "";
+ HI.Definition = "enum Color x = GREEN";
+ HI.Kind = SymbolKind::Variable;
+ HI.Type = "enum Color";
+ HI.Value = "GREEN"; // Symbolic when hovering on an expression.
}},
   // FIXME: We should use the Decl referenced, even if from an implicit
-  // instantiation. Then the scope would be Add<1, 2> and the value 3.
+  // instantiation. Then the scope would be Add<1, 2>.
   {R"cpp(
 template struct Add {
   static constexpr int result = a + b;
@@ -450,6 +464,21 @@
  HI.Type = "const int";
  HI.NamespaceScope = "";
  HI.LocalScope = "Add::";
+ HI.Value = "3";
+   }},
+  {R"cpp(
+constexpr int answer() { return 40 + 2; }
+int x = [[ans^wer]]();
+)cpp",
+   [](HoverInfo ) {
+ HI.Name = "answer";
+ HI.Definition = "constexpr int answer()";
+ HI.Kind = SymbolKind::Function;
+ HI.Type = "int ()";
+ HI.ReturnType = "int";
+ HI.Parameters.emplace();
+ HI.NamespaceScope = "";
+ HI.Value = "42";
}},
   {R"cpp(
 const char *[[ba^r]] = "1234";
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -16,6 +16,7 @@
 #include "SourceCode.h"
 #include "index/SymbolCollector.h"
 
+#include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/PrettyPrinter.h"
@@ -239,6 +240,45 @@
   // FIXME: handle variadics.
 }
 
+llvm::Optional printExprValue(const Expr *E, const ASTContext ) {
+  Expr::EvalResult Constant;
+  // Evaluating [[foo]]() as "" isn't useful, and prevents us walking up
+  // to the enclosing call.
+  if (E->getType()->isFunctionType() || E->getType()->isFunctionPointerType() ||
+  E->getType()->isFunctionReferenceType())
+return llvm::None;
+  // Attempt to evaluate. If expr is dependent, evaluation crashes!
+  if (E->isValueDependent() || !E->EvaluateAsRValue(Constant, Ctx))
+return llvm::None;
+
+  // Show enums symbolically, not numerically like APValue::printPretty().
+  if (E->getType()->isEnumeralType() &&
+  Constant.Val.getInt().getMinSignedBits() <= 64) {
+int64_t Val = Constant.Val.getInt().getExtValue();
+for (const EnumConstantDecl *ECD :
+ E->getType()->castAs()->getDecl()->enumerators())
+  if (ECD->getInitVal() == Val)
+return ECD->getNameAsString();
+  }
+  return Constant.Val.getAsString(Ctx, E->getType());
+}
+
+llvm::Optional printExprValue(const SelectionTree::Node *N,
+   const ASTContext ) {
+  for (; N; N = N->Parent) {
+// Try to evaluate the first evaluable enclosing expression.
+if (const Expr *E = N->ASTNode.get()) {
+  if (auto Val = printExprValue(E, Ctx))
+return Val;
+} else if (N->ASTNode.get() || N->ASTNode.get()) {
+  // Refuse to cross certain non-exprs. (TypeLoc are OK as part of Exprs).
+  // This tries to ensure we're showing a value related to the cursor.
+  break;
+}
+  }
+  return llvm::None;
+}
+
 /// Generate a \p Hover object given the declaration \p D.
 HoverInfo getHoverContents(const Decl *D, const SymbolIndex *Index) {
   HoverInfo HI;
@@ -282,18 +322,9 @@
   }
 
   // Fill in value with evaluated initializer if possible.
-  // FIXME(kadircet): Also set Value field for expressions like "sizeof" and
-  // function calls.
   if (const auto *Var = dyn_cast(D)) {
-if (const Expr *Init = Var->getInit()) {
-  Expr::EvalResult Result;
-  

[PATCH] D70358: Add Cursor.get_reference_name_range to clang python binding.

2019-11-16 Thread Arthur Peters via Phabricator via cfe-commits
arthurp added a comment.

This is my first new revision here, and I guessed on the review based solely on 
resent reviews of related code. Please correct me as needed. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70358



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


[PATCH] D70358: Add Cursor.get_reference_name_range to clang python binding.

2019-11-16 Thread Arthur Peters via Phabricator via cfe-commits
arthurp created this revision.
arthurp added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.
arthurp added a comment.

This is my first new revision here, and I guessed on the review based solely on 
resent reviews of related code. Please correct me as needed. Thanks.


Add a python method to Cursor to access clang_getCursorReferenceNameRange 
which was already included in the C function list of the python binding.
Also add required constants and a test.

This revision only changes the python binding and does not touch the
underlying C code at all.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70358

Files:
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/tests/cindex/test_cursor.py
  clang/bindings/python/tests/cindex/util.py

Index: clang/bindings/python/tests/cindex/util.py
===
--- clang/bindings/python/tests/cindex/util.py
+++ clang/bindings/python/tests/cindex/util.py
@@ -58,6 +58,18 @@
 
 return None
 
+
+def get_subcursor_by_path(cursor, *path):
+"""Obtain a cursor by following the path provided from cursor.
+
+path is a series of ints specifying which child to select.
+"""
+
+if path:
+return get_subcursor_by_path(list(cursor.get_children())[path[0]], *path[1:])
+else:
+return cursor
+
 def get_cursors(source, spelling):
 """Obtain all cursors from a source object with a specific spelling.
 
@@ -84,6 +96,7 @@
 __all__ = [
 'get_cursor',
 'get_cursors',
+'get_subcursor_by_path',
 'get_tu',
 'skip_if_no_fspath',
 'str_to_path',
Index: clang/bindings/python/tests/cindex/test_cursor.py
===
--- clang/bindings/python/tests/cindex/test_cursor.py
+++ clang/bindings/python/tests/cindex/test_cursor.py
@@ -9,10 +9,14 @@
 
 from clang.cindex import AvailabilityKind
 from clang.cindex import CursorKind
+from clang.cindex import Cursor
 from clang.cindex import TemplateArgumentKind
 from clang.cindex import TranslationUnit
 from clang.cindex import TypeKind
+from clang.cindex import SourceRange
+from clang.cindex import SourceLocation
 from .util import get_cursor
+from .util import get_subcursor_by_path
 from .util import get_cursors
 from .util import get_tu
 
@@ -53,6 +57,37 @@
 void foo<-7, float, true>();
 """
 
+kCPPReferenceNameRangeTest = """\
+void baz();
+
+class C {
+public:
+void foo();
+template 
+void bar(T v) { }
+int operator[](int i) { return i; }
+};
+
+void ref1() {
+baz();
+}
+
+void ref2() {
+C x;
+x.C::foo();
+}
+
+void ref3() {
+C x;
+x.bar("str");
+}
+
+void ref4() {
+C x;
+x[1];
+}
+"""
+
 class TestCursor(unittest.TestCase):
 def test_get_children(self):
 tu = get_tu(kInput)
@@ -554,6 +589,30 @@
 self.assertEqual(c.referenced.spelling, foo.spelling)
 break
 
+def test_get_reference_name_range(self):
+tu = get_tu(kCPPReferenceNameRangeTest, lang='cpp')
+
+c = get_subcursor_by_path(get_cursor(tu, 'ref1'), 0, 0)
+self.assertEqual(c.get_reference_name_range(0, 0),
+ tu.get_extent("t.cpp", ((12, 5), (12, 10
+
+c = get_subcursor_by_path(get_cursor(tu, 'ref2'), 0, 1)
+self.assertEqual(c.get_reference_name_range(Cursor.NAME_RANGE_WANT_QUALIFIER, 0),
+ tu.get_extent("t.cpp", ((17, 5), (17, 15
+
+c = get_subcursor_by_path(get_cursor(tu, 'ref3'), 0, 1)
+self.assertEqual(c.get_reference_name_range(Cursor.NAME_RANGE_WANT_TEMPLATE_ARGS, 0),
+ tu.get_extent("t.cpp", ((22, 5), (22, 30
+
+c = get_subcursor_by_path(get_cursor(tu, 'ref4'), 0, 1)
+self.assertEqual(c.get_reference_name_range(0, 0),
+ tu.get_extent("t.cpp", ((27, 6), (27, 7
+self.assertEqual(c.get_reference_name_range(0, 1),
+ tu.get_extent("t.cpp", ((27, 8), (27, 9
+self.assertEqual(c.get_reference_name_range(Cursor.NAME_RANGE_WANT_SINGLE_PIECE, 0),
+ tu.get_extent("t.cpp", ((27, 6), (27, 9
+
+
 def test_mangled_name(self):
 kInputForMangling = """\
 int foo(int, int);
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -1419,6 +1419,20 @@
 """
 _fields_ = [("_kind_id", c_int), ("xdata", c_int), ("data", c_void_p * 3)]
 
+# Include the nested-name-specifier, e.g. Foo:: in x.Foo::y, in the range.
+NAME_RANGE_WANT_QUALIFIER = 0x1
+
+# Include the explicit template arguments, e.g.  in x.f, in the range.
+NAME_RANGE_WANT_TEMPLATE_ARGS = 0x2
+
+# If the name is non-contiguous, return the full spanning range.
+ 

[PATCH] D64874: [Sema] Improve handling of function pointer conversions

2019-11-16 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

@rsmith I now have commit access so I can commit the patch. Any suggestions 
regarding the previous remark?


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

https://reviews.llvm.org/D64874



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


[PATCH] D10833: Retrieve BinaryOperator::getOpcode and BinaryOperator::getOpcodeStr via libclang and its python interface

2019-11-16 Thread Arthur Peters via Phabricator via cfe-commits
arthurp commandeered this revision.
arthurp added a reviewer: RedX2501.
arthurp added a comment.

I have been using this revision locally for 9 months in a system that uses 
libclang to parse C code and extract information. I'm commandeering this issue 
since the original author (@RedX2501) has not posted on this issue since 2016 
and I'm willing to make an attempt to get this merged. I have updated the 
revision to apply clearly on LLVM master 
(f897d087d09dbbccec3417f812109ed534b94248 
) and I 
have updated and run all the tests.

I am happy to make other changes if needed to make this revision mergeable. 
Just tell me what's needed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D10833



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


[PATCH] D70357: [clangd] Untangle Hover from XRefs, move into own file.

2019-11-16 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a subscriber: kuhnel.
sammccall added a comment.

@kuhnel: I think the premerge guards bot is acting up here: the first snapshot 
was definitely broken (missing files).
And even the second the ninja logs don't show building the new files. I think 
it might just be building the tree without patching? The console log shows 
errors around the arc patch step, and suspiciously few details about the patch 
being applied.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70357



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


[PATCH] D53250: [ToolChain] Use default linker if the toolchain uses a custom one

2019-11-16 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.
Herald added a project: clang.

Going through my old revisions, is this still something that we want?


Repository:
  rC Clang

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

https://reviews.llvm.org/D53250



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


[PATCH] D69360: [NFC] Refactor representation of materialized temporaries

2019-11-16 Thread Tyker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG08ea1ee2db5f: [NFC] Refactor representation of materialized 
temporaries (authored by Tyker).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69360

Files:
  clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
  clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Sema/Template.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/Consumed.cpp
  clang/lib/Analysis/ThreadSafetyCommon.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6313,6 +6313,7 @@
   case Decl::PragmaDetectMismatch:
   case Decl::UsingPack:
   case Decl::Concept:
+  case Decl::LifetimeExtendedTemporary:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -27,7 +27,7 @@
   ExplodedNode *Pred,
   ExplodedNodeSet ) {
   StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
-  const Expr *tempExpr = ME->GetTemporaryExpr()->IgnoreParens();
+  const Expr *tempExpr = ME->getSubExpr()->IgnoreParens();
   ProgramStateRef state = Pred->getState();
   const LocationContext *LCtx = Pred->getLocationContext();
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1427,7 +1427,7 @@
 
   bool IsTemporary = false;
   if (const auto *MTE = dyn_cast(ArgE)) {
-ArgE = MTE->GetTemporaryExpr();
+ArgE = MTE->getSubExpr();
 IsTemporary = true;
   }
 
Index: clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -800,8 +800,7 @@
 CheckerContext ) const {
   /* Transfer iterator state to temporary objects */
   auto State = C.getState();
-  const auto *Pos =
-  getIteratorPosition(State, C.getSVal(MTE->GetTemporaryExpr()));
+  const auto *Pos = getIteratorPosition(State, C.getSVal(MTE->getSubExpr()));
   if (!Pos)
 return;
   State = setIteratorPosition(State, C.getSVal(MTE), *Pos);
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1835,9 +1835,11 @@
 
 void ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
   VisitExpr(E);
-  Record.AddStmt(E->getTemporary());
-  Record.AddDeclRef(E->getExtendingDecl());
-  Record.push_back(E->getManglingNumber());
+  Record.push_back(static_cast(E->getLifetimeExtendedTemporaryDecl()));
+  if (E->getLifetimeExtendedTemporaryDecl())
+Record.AddDeclRef(E->getLifetimeExtendedTemporaryDecl());
+  

[clang-tools-extra] 08ea1ee - [NFC] Refactor representation of materialized temporaries

2019-11-16 Thread via cfe-commits

Author: Tyker
Date: 2019-11-16T17:56:09+01:00
New Revision: 08ea1ee2db5f9d6460fef1d79d0d1d1a5eb78982

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

LOG: [NFC] Refactor representation of materialized temporaries

Summary:
this patch refactor representation of materialized temporaries to prevent an 
issue raised by rsmith in https://reviews.llvm.org/D63640#inline-612718

Reviewers: rsmith, martong, shafik

Reviewed By: rsmith

Subscribers: rnkovacs, arphaman, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/include/clang/Basic/DeclNodes.td
clang/include/clang/Sema/Template.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/Analysis/CFG.cpp
clang/lib/Analysis/Consumed.cpp
clang/lib/Analysis/ThreadSafetyCommon.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/JumpDiagnostics.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
clang/tools/libclang/CIndex.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
index a249b1216111..0780924f3557 100644
--- a/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
@@ -24,7 +24,7 @@ AST_MATCHER_P(Stmt, IgnoringTemporaries, 
ast_matchers::internal::Matcher,
   const Stmt *E = 
   while (true) {
 if (const auto *MTE = dyn_cast(E))
-  E = MTE->getTemporary();
+  E = MTE->getSubExpr();
 if (const auto *BTE = dyn_cast(E))
   E = BTE->getSubExpr();
 if (const auto *ICE = dyn_cast(E))

diff  --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
index c51b6e86b3f6..2d4475c991ca 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
@@ -53,7 +53,7 @@ buildBindArguments(const MatchFinder::MatchResult , 
const CallExpr *C) {
 const Expr *E = C->getArg(I);
 BindArgument B;
 if (const auto *M = dyn_cast(E)) {
-  const auto *TE = M->GetTemporaryExpr();
+  const auto *TE = M->getSubExpr();
   B.Kind = isa(TE) ? BK_CallExpr : BK_Temporary;
 }
 

diff  --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp 
b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
index 03efd12ded21..0389a6148954 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -177,7 +177,7 @@ const Expr *digThroughConstructors(const Expr *E) {
   return nullptr;
 E = ConstructExpr->getArg(0);
 if (const auto *Temp = dyn_cast(E))
-  E = Temp->GetTemporaryExpr();
+  E = Temp->getSubExpr();
 return digThroughConstructors(E);
   }
   return E;

diff  --git 
a/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
index e3b90d3b4279..a52065540917 100644
--- a/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
+++ 

[PATCH] D70274: [clang][IFS] Driver pipeline change for clang-ifs: generate interface stubs after standard pipeline.

2019-11-16 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi marked an inline comment as done.
plotfi added inline comments.



Comment at: clang/test/InterfaceStubs/driver-test2.c:6
+// RUN: %clang -emit-interface-stubs -emit-merged-ifs \
+// RUN:   driver-test2.o object.o weak.o -S -o - | FileCheck %s
+

I would use -shared here, but many of the bots don't support that. Trying to 
figure out what else to do. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70274



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


[PATCH] D70274: [clang][IFS] Driver pipeline change for clang-ifs: generate interface stubs after standard pipeline.

2019-11-16 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 229698.
plotfi added a comment.

Adding test, and some additional features in the driver.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70274

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/InterfaceStubs.cpp
  clang/lib/Driver/Types.cpp
  clang/test/InterfaceStubs/driver-test.c
  clang/test/InterfaceStubs/driver-test2.c
  clang/test/InterfaceStubs/windows.cpp

Index: clang/test/InterfaceStubs/windows.cpp
===
--- clang/test/InterfaceStubs/windows.cpp
+++ clang/test/InterfaceStubs/windows.cpp
@@ -1,6 +1,7 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -o - %s -emit-interface-stubs | FileCheck -check-prefix=CHECK-CC1 %s
-// RUN: %clang -target x86_64-windows-msvc -o - %s -emit-interface-stubs -emit-merged-ifs | FileCheck -check-prefix=CHECK-IFS %s
+// RUN: %clang -target x86_64-windows-msvc -o - %s -emit-interface-stubs -emit-merged-ifs -S | FileCheck -check-prefix=CHECK-IFS %s
+// note: -S is added here to prevent clang from invoking link.exe
 
 // CHECK-CC1: Symbols:
 // CHECK-CC1-NEXT: ?helloWindowsMsvc@@YAHXZ
Index: clang/test/InterfaceStubs/driver-test2.c
===
--- /dev/null
+++ clang/test/InterfaceStubs/driver-test2.c
@@ -0,0 +1,14 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -c -emit-interface-stubs \
+// RUN:   %s %S/object.c %S/weak.cpp
+// RUN: %clang -emit-interface-stubs -emit-merged-ifs \
+// RUN:   driver-test2.o object.o weak.o -S -o - | FileCheck %s
+
+// CHECK-DAG: data
+// CHECK-DAG: bar
+// CHECK-DAG: strongFunc
+// CHECK-DAG: weakFunc
+
+int bar(int a) { return a; }
+int main() { return 0; }
Index: clang/test/InterfaceStubs/driver-test.c
===
--- clang/test/InterfaceStubs/driver-test.c
+++ clang/test/InterfaceStubs/driver-test.c
@@ -1,11 +1,13 @@
 // REQUIRES: x86-registered-target
 
-// RUN: %clang -target x86_64-unknown-linux-gnu -x c -o %t1.so -emit-interface-stubs %s %S/object.c %S/weak.cpp && \
-// RUN: llvm-nm %t1.so 2>&1 | FileCheck --check-prefix=CHECK-IFS %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -x c -o %t1 -emit-interface-stubs %s %S/object.c %S/weak.cpp
+// RUN: llvm-nm %t1   2>&1 | FileCheck %s
+// RUN: llvm-nm %t1.ifso 2>&1 | FileCheck %s
 
-// CHECK-IFS-DAG: data
-// CHECK-IFS-DAG: foo
-// CHECK-IFS-DAG: strongFunc
-// CHECK-IFS-DAG: weakFunc
+// CHECK-DAG: data
+// CHECK-DAG: foo
+// CHECK-DAG: strongFunc
+// CHECK-DAG: weakFunc
 
 int foo(int bar) { return 42 + 1844; }
+int main() { return foo(23); }
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -330,22 +330,6 @@
 llvm::copy_if(PhaseList, std::back_inserter(P),
   [](phases::ID Phase) { return Phase <= phases::Precompile; });
 
-  // Treat Interface Stubs like its own compilation mode.
-  else if (DAL.getLastArg(options::OPT_emit_interface_stubs)) {
-llvm::SmallVector IfsModePhaseList;
-llvm::SmallVector  = PhaseList;
-phases::ID LastPhase = phases::IfsMerge;
-if (Id != types::TY_IFS) {
-  if (DAL.hasArg(options::OPT_c))
-LastPhase = phases::Compile;
-  PL = IfsModePhaseList;
-  types::getCompilationPhases(types::TY_IFS_CPP, PL);
-}
-llvm::copy_if(PL, std::back_inserter(P), [&](phases::ID Phase) {
-  return Phase <= LastPhase;
-});
-  }
-
   // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
   else if (DAL.getLastArg(options::OPT_fsyntax_only) ||
DAL.getLastArg(options::OPT_print_supported_cpus) ||
Index: clang/lib/Driver/ToolChains/InterfaceStubs.cpp
===
--- clang/lib/Driver/ToolChains/InterfaceStubs.cpp
+++ clang/lib/Driver/ToolChains/InterfaceStubs.cpp
@@ -21,13 +21,36 @@
   std::string Merger = getToolChain().GetProgramPath(getShortName());
   llvm::opt::ArgStringList CmdArgs;
   CmdArgs.push_back("-action");
-  CmdArgs.push_back(Args.getLastArg(options::OPT_emit_merged_ifs)
-? "write-ifs"
-: "write-bin");
+  const bool WriteBin = !Args.getLastArg(options::OPT_emit_merged_ifs);
+  CmdArgs.push_back(WriteBin ? "write-bin" : "write-ifs");
   CmdArgs.push_back("-o");
-  CmdArgs.push_back(Output.getFilename());
-  for (const auto  : Inputs)
-CmdArgs.push_back(Input.getFilename());
+
+  auto TrimFileExt = [](std::string Filename, std::string Ext) {
+size_t TrimSize = Filename.size() - Ext.size();
+if (Filename.size() > Ext.size() &&
+std::equal(Filename.begin() + TrimSize, Filename.end(), Ext.begin()))
+  Filename = Filename.substr(0, TrimSize);
+

[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5

2019-11-16 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG423f541c1a32: [DWARF5]Addition of alignment atrribute in 
typedef DIE. (authored by SouraVX).

Changed prior to commit:
  https://reviews.llvm.org/D70111?vs=229544=229697#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70111

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-template-align.cpp
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp
  llvm/test/DebugInfo/X86/debug-info-template-align.ll
  llvm/tools/llvm-c-test/debuginfo.c

Index: llvm/tools/llvm-c-test/debuginfo.c
===
--- llvm/tools/llvm-c-test/debuginfo.c
+++ llvm/tools/llvm-c-test/debuginfo.c
@@ -69,7 +69,7 @@
   LLVMMetadataRef Int64Ty =
   LLVMDIBuilderCreateBasicType(DIB, "Int64", 5, 64, 0, LLVMDIFlagZero);
   LLVMMetadataRef Int64TypeDef =
-LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File);
+  LLVMDIBuilderCreateTypedef(DIB, Int64Ty, "int64_t", 7, File, 42, File, 0);
 
   LLVMMetadataRef GlobalVarValueExpr =
   LLVMDIBuilderCreateConstantValueExpression(DIB, 0);
Index: llvm/test/DebugInfo/X86/debug-info-template-align.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/debug-info-template-align.ll
@@ -0,0 +1,63 @@
+; RUN: llc %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+
+; C++ source to regenerate:
+
+;typedef char  __attribute__((__aligned__(64))) alchar;
+
+;int main(){
+;alchar newChar;
+;}
+; $ clang++ -O0 -g -gdwarf-5 debug-info-template-align.cpp -c
+
+; CHECK: .debug_abbrev contents:
+
+; CHECK: [5] DW_TAG_typedef  DW_CHILDREN_no
+; CHECK:  DW_AT_alignment DW_FORM_udata
+
+; CHECK: .debug_info contents:
+
+;CHECK: DW_TAG_typedef [5]
+;CHECK: DW_AT_name {{.*}} "alchar"
+;CHECK-NEXT: DW_AT_alignment [DW_FORM_udata] (64)
+
+
+; ModuleID = '/dir/test.cpp'
+source_filename = "/dir/test.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: noinline norecurse nounwind optnone uwtable
+define dso_local i32 @main() #0 !dbg !7 {
+entry:
+  %newChar = alloca i8, align 64
+  call void @llvm.dbg.declare(metadata i8* %newChar, metadata !12, metadata !DIExpression()), !dbg !15
+  ret i32 0, !dbg !16
+}
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+attributes #0 = { noinline norecurse nounwind optnone uwtable }
+attributes #1 = { nounwind readnone speculatable willreturn }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 10.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "/dir/test.cpp", directory: "/home/awpandey/tools/llvm/test/DebugInfo", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 5}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 10.0.0 "}
+!7 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 12, type: !9, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!8 = !DIFile(filename: "test.cpp", directory: "/dir", checksumkind: CSK_MD5, checksum: "872e252efdfcb9480b4bfaf8437f58ab")
+!9 = !DISubroutineType(types: !10)
+!10 = !{!11}
+!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!12 = !DILocalVariable(name: "newChar", scope: !7, file: !8, line: 13, type: !13)
+!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "alchar", file: !8, line: 10, baseType: !14, align: 512)
+!14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
+!15 = !DILocation(line: 13, column: 10, scope: !7)
+!16 = !DILocation(line: 14, column: 1, scope: !7)
Index: llvm/lib/IR/DebugInfo.cpp
===
--- llvm/lib/IR/DebugInfo.cpp
+++ llvm/lib/IR/DebugInfo.cpp
@@ -1108,11 +1108,10 @@
 LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type,
const char *Name, size_t NameLen,
LLVMMetadataRef File, unsigned LineNo,
-   LLVMMetadataRef Scope) {
+   LLVMMetadataRef Scope, uint32_t AlignInBits) {
   return wrap(unwrap(Builder)->createTypedef(
-  unwrapDI(Type), {Name, NameLen},
-  unwrapDI(File), LineNo,
-  unwrapDI(Scope)));
+  

[PATCH] D70340: Add a key method to Sema to optimize debug info size

2019-11-16 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D70340#1748712 , @thakis wrote:

> I don't see any reason not to do this. What's there to discuss? I'm probably 
> missing something obvious.


Eh, it's a bit quirky - adds production code (albeit a very small amount) only 
to improve debug build properties. I'm not super averse to it - though would 
like @rsmith to weigh in before committing to it.

> dblaikie added anchor functions in many places a while ago (but iirc for 
> vtables, not debug info).

Yeah, that was just following the rules (& a little pedantry/boredom): 
https://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers
 - it'd be interesting to see how much those are actually worth in object size 
with and without debug info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70340



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


[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5

2019-11-16 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX added a comment.

In D70111#1748765 , @awpandey wrote:

> Hi @aprantl. I had made the changes and my team member will commit this.


Thanks  @awpandey for working on this! as requested, I've committed / closed 
this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70111



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


[PATCH] D70274: [clang][IFS] Driver pipeline change for clang-ifs: generate interface stubs after standard pipeline.

2019-11-16 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 229699.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70274

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/InterfaceStubs.cpp
  clang/lib/Driver/Types.cpp
  clang/test/InterfaceStubs/driver-test.c
  clang/test/InterfaceStubs/driver-test2.c
  clang/test/InterfaceStubs/windows.cpp

Index: clang/test/InterfaceStubs/windows.cpp
===
--- clang/test/InterfaceStubs/windows.cpp
+++ clang/test/InterfaceStubs/windows.cpp
@@ -1,6 +1,7 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -o - %s -emit-interface-stubs | FileCheck -check-prefix=CHECK-CC1 %s
-// RUN: %clang -target x86_64-windows-msvc -o - %s -emit-interface-stubs -emit-merged-ifs | FileCheck -check-prefix=CHECK-IFS %s
+// RUN: %clang -target x86_64-windows-msvc -o - %s -emit-interface-stubs -emit-merged-ifs -S | FileCheck -check-prefix=CHECK-IFS %s
+// note: -S is added here to prevent clang from invoking link.exe
 
 // CHECK-CC1: Symbols:
 // CHECK-CC1-NEXT: ?helloWindowsMsvc@@YAHXZ
Index: clang/test/InterfaceStubs/driver-test2.c
===
--- /dev/null
+++ clang/test/InterfaceStubs/driver-test2.c
@@ -0,0 +1,14 @@
+// REQUIRES: x86-registered-target
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -c -emit-interface-stubs \
+// RUN:   %s %S/object.c %S/weak.cpp
+// RUN: %clang -emit-interface-stubs -emit-merged-ifs \
+// RUN:   driver-test2.o object.o weak.o -S -o - | FileCheck %s
+
+// CHECK-DAG: data
+// CHECK-DAG: bar
+// CHECK-DAG: strongFunc
+// CHECK-DAG: weakFunc
+
+int bar(int a) { return a; }
+int main() { return 0; }
Index: clang/test/InterfaceStubs/driver-test.c
===
--- clang/test/InterfaceStubs/driver-test.c
+++ clang/test/InterfaceStubs/driver-test.c
@@ -1,11 +1,13 @@
 // REQUIRES: x86-registered-target
 
-// RUN: %clang -target x86_64-unknown-linux-gnu -x c -o %t1.so -emit-interface-stubs %s %S/object.c %S/weak.cpp && \
-// RUN: llvm-nm %t1.so 2>&1 | FileCheck --check-prefix=CHECK-IFS %s
+// RUN: %clang -target x86_64-unknown-linux-gnu -x c -o %t1 -emit-interface-stubs %s %S/object.c %S/weak.cpp
+// RUN: llvm-nm %t1   2>&1 | FileCheck %s
+// RUN: llvm-nm %t1.ifso 2>&1 | FileCheck %s
 
-// CHECK-IFS-DAG: data
-// CHECK-IFS-DAG: foo
-// CHECK-IFS-DAG: strongFunc
-// CHECK-IFS-DAG: weakFunc
+// CHECK-DAG: data
+// CHECK-DAG: foo
+// CHECK-DAG: strongFunc
+// CHECK-DAG: weakFunc
 
 int foo(int bar) { return 42 + 1844; }
+int main() { return foo(23); }
Index: clang/lib/Driver/Types.cpp
===
--- clang/lib/Driver/Types.cpp
+++ clang/lib/Driver/Types.cpp
@@ -330,22 +330,6 @@
 llvm::copy_if(PhaseList, std::back_inserter(P),
   [](phases::ID Phase) { return Phase <= phases::Precompile; });
 
-  // Treat Interface Stubs like its own compilation mode.
-  else if (DAL.getLastArg(options::OPT_emit_interface_stubs)) {
-llvm::SmallVector IfsModePhaseList;
-llvm::SmallVector  = PhaseList;
-phases::ID LastPhase = phases::IfsMerge;
-if (Id != types::TY_IFS) {
-  if (DAL.hasArg(options::OPT_c))
-LastPhase = phases::Compile;
-  PL = IfsModePhaseList;
-  types::getCompilationPhases(types::TY_IFS_CPP, PL);
-}
-llvm::copy_if(PL, std::back_inserter(P), [&](phases::ID Phase) {
-  return Phase <= LastPhase;
-});
-  }
-
   // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
   else if (DAL.getLastArg(options::OPT_fsyntax_only) ||
DAL.getLastArg(options::OPT_print_supported_cpus) ||
Index: clang/lib/Driver/ToolChains/InterfaceStubs.cpp
===
--- clang/lib/Driver/ToolChains/InterfaceStubs.cpp
+++ clang/lib/Driver/ToolChains/InterfaceStubs.cpp
@@ -21,13 +21,40 @@
   std::string Merger = getToolChain().GetProgramPath(getShortName());
   llvm::opt::ArgStringList CmdArgs;
   CmdArgs.push_back("-action");
-  CmdArgs.push_back(Args.getLastArg(options::OPT_emit_merged_ifs)
-? "write-ifs"
-: "write-bin");
+  const bool WriteBin = !Args.getLastArg(options::OPT_emit_merged_ifs);
+  CmdArgs.push_back(WriteBin ? "write-bin" : "write-ifs");
   CmdArgs.push_back("-o");
-  CmdArgs.push_back(Output.getFilename());
-  for (const auto  : Inputs)
-CmdArgs.push_back(Input.getFilename());
+
+  auto TrimFileExt = [](std::string Filename, std::string Ext) {
+size_t TrimSize = Filename.size() - Ext.size();
+if (Filename.size() > Ext.size() &&
+std::equal(Filename.begin() + TrimSize, Filename.end(), Ext.begin()))
+  Filename = Filename.substr(0, TrimSize);
+return Filename;
+  };
+
+  // Normally we want to write to a side-car file ending 

[clang] 423f541 - [DWARF5]Addition of alignment atrribute in typedef DIE.

2019-11-16 Thread Sourabh Singh Tomar via cfe-commits

Author: Sourabh Singh Tomar
Date: 2019-11-16T21:56:53+05:30
New Revision: 423f541c1a322963cf482683fe9777ef0692082d

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

LOG: [DWARF5]Addition of alignment atrribute in typedef DIE.

This patch, adds support for DW_AT_alignment[DWARF5] attribute, to be emitted 
with typdef DIE.
When explicit alignment is specified.

Patch by Awanish Pandey 

Reviewers: aprantl, dblaikie, jini.susan.george, SouraVX, alok,
deadalinx

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

Added: 
clang/test/CodeGenCXX/debug-info-template-align.cpp
llvm/test/DebugInfo/X86/debug-info-template-align.ll

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
llvm/include/llvm-c/DebugInfo.h
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/DebugInfo.cpp
llvm/tools/llvm-c-test/debuginfo.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 75c4b2ae2339..f204b9716926 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1127,7 +1127,8 @@ llvm::DIType *CGDebugInfo::CreateType(const 
TemplateSpecializationType *Ty,
   SourceLocation Loc = AliasDecl->getLocation();
   return DBuilder.createTypedef(Src, OS.str(), getOrCreateFile(Loc),
 getLineNumber(Loc),
-getDeclContextDescriptor(AliasDecl));
+getDeclContextDescriptor(AliasDecl),
+/* Alignment */ None);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,
@@ -1143,9 +1144,10 @@ llvm::DIType *CGDebugInfo::CreateType(const TypedefType 
*Ty,
   SourceLocation Loc = Ty->getDecl()->getLocation();
 
   // Typedefs are derived from some other type.
-  return DBuilder.createTypedef(Underlying, Ty->getDecl()->getName(),
-getOrCreateFile(Loc), getLineNumber(Loc),
-getDeclContextDescriptor(Ty->getDecl()));
+  return DBuilder.createTypedef(
+  Underlying, Ty->getDecl()->getName(), getOrCreateFile(Loc),
+  getLineNumber(Loc), getDeclContextDescriptor(Ty->getDecl()),
+  getDeclAlignIfRequired(Ty->getDecl(), CGM.getContext()));
 }
 
 static unsigned getDwarfCC(CallingConv CC) {
@@ -2324,7 +2326,8 @@ llvm::DIType *CGDebugInfo::CreateType(const 
ObjCTypeParamType *Ty,
   return DBuilder.createTypedef(
   getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),
   Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),
-  getDeclContextDescriptor(Ty->getDecl()));
+  getDeclContextDescriptor(Ty->getDecl()),
+  /* Alignment */ None);
 }
 
 /// \return true if Getter has the default name for the property PD.

diff  --git a/clang/test/CodeGenCXX/debug-info-template-align.cpp 
b/clang/test/CodeGenCXX/debug-info-template-align.cpp
new file mode 100644
index ..42fdb269a30b
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-template-align.cpp
@@ -0,0 +1,14 @@
+//  Test for debug info related to DW_AT_alignment attribute in the typedef 
operator
+// Supported: -O0, standalone DI
+// RUN: %clang_cc1 -dwarf-version=5  -emit-llvm -triple x86_64-linux-gnu %s -o 
- \
+// RUN:   -O0 -disable-llvm-passes \
+// RUN:   -debug-info-kind=standalone \
+// RUN: | FileCheck %s
+
+// CHECK: DIDerivedType(tag: DW_TAG_typedef, {{.*}}, align: 512
+
+typedef char __attribute__((__aligned__(64))) alchar;
+
+int main() {
+  alchar newChar;
+}

diff  --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 41e9f96bbb92..891faedb636f 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -875,7 +875,7 @@ LLVMMetadataRef
 LLVMDIBuilderCreateTypedef(LLVMDIBuilderRef Builder, LLVMMetadataRef Type,
const char *Name, size_t NameLen,
LLVMMetadataRef File, unsigned LineNo,
-   LLVMMetadataRef Scope);
+   LLVMMetadataRef Scope, uint32_t AlignInBits);
 
 /**
  * Create debugging information entry to establish inheritance relationship

diff  --git a/llvm/include/llvm/IR/DIBuilder.h 
b/llvm/include/llvm/IR/DIBuilder.h
index ad9a35b55414..3c738b8a4f9f 100644
--- a/llvm/include/llvm/IR/DIBuilder.h
+++ b/llvm/include/llvm/IR/DIBuilder.h
@@ -237,8 +237,10 @@ namespace llvm {
 /// \param FileFile where this type is defined.
 /// \param LineNo  Line number.
 /// \param Context The surrounding context for the typedef.
+/// \param AlignInBits Alignment. (Optional)
 DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File,
- 

[PATCH] D70357: [clangd] Untangle Hover from XRefs, move into own file.

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60143 tests passed, 0 failed and 729 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70357



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


[PATCH] D70357: [clangd] Untangle Hover from XRefs, move into own file.

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60143 tests passed, 0 failed and 729 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70357



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


[clang-tools-extra] a7f97b0 - [clangd] Improve long and confusing preamble log message.

2019-11-16 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-11-16T17:13:02+01:00
New Revision: a7f97b02b4fa8b4b1824a7c9b14deb798f55e76a

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

LOG: [clangd] Improve long and confusing preamble log message.

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Preamble.cpp 
b/clang-tools-extra/clangd/Preamble.cpp
index 41e3c1368eb7..eca545fd09e4 100644
--- a/clang-tools-extra/clangd/Preamble.cpp
+++ b/clang-tools-extra/clangd/Preamble.cpp
@@ -102,10 +102,11 @@ buildPreamble(PathRef FileName, CompilerInvocation ,
   compileCommandsAreEqual(Inputs.CompileCommand, OldCompileCommand) &&
   OldPreamble->Preamble.CanReuse(CI, ContentsBuffer.get(), Bounds,
  Inputs.FS.get())) {
-vlog("Reusing preamble for file {0}", llvm::Twine(FileName));
+vlog("Reusing preamble for {0}", FileName);
 return OldPreamble;
   }
-  vlog("Preamble for file {0} cannot be reused. Attempting to rebuild it.",
+  vlog(OldPreamble ? "Rebuilding invalidated preamble for {0}"
+   : "Building first preamble for {0}",
FileName);
 
   trace::Span Tracer("BuildPreamble");



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


[PATCH] D69360: [NFC] Refactor representation of materialized temporaries

2019-11-16 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 229694.

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

https://reviews.llvm.org/D69360

Files:
  clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
  clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Sema/Template.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/Consumed.cpp
  clang/lib/Analysis/ThreadSafetyCommon.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6313,6 +6313,7 @@
   case Decl::PragmaDetectMismatch:
   case Decl::UsingPack:
   case Decl::Concept:
+  case Decl::LifetimeExtendedTemporary:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -27,7 +27,7 @@
   ExplodedNode *Pred,
   ExplodedNodeSet ) {
   StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
-  const Expr *tempExpr = ME->GetTemporaryExpr()->IgnoreParens();
+  const Expr *tempExpr = ME->getSubExpr()->IgnoreParens();
   ProgramStateRef state = Pred->getState();
   const LocationContext *LCtx = Pred->getLocationContext();
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1427,7 +1427,7 @@
 
   bool IsTemporary = false;
   if (const auto *MTE = dyn_cast(ArgE)) {
-ArgE = MTE->GetTemporaryExpr();
+ArgE = MTE->getSubExpr();
 IsTemporary = true;
   }
 
Index: clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -800,8 +800,7 @@
 CheckerContext ) const {
   /* Transfer iterator state to temporary objects */
   auto State = C.getState();
-  const auto *Pos =
-  getIteratorPosition(State, C.getSVal(MTE->GetTemporaryExpr()));
+  const auto *Pos = getIteratorPosition(State, C.getSVal(MTE->getSubExpr()));
   if (!Pos)
 return;
   State = setIteratorPosition(State, C.getSVal(MTE), *Pos);
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1835,9 +1835,11 @@
 
 void ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
   VisitExpr(E);
-  Record.AddStmt(E->getTemporary());
-  Record.AddDeclRef(E->getExtendingDecl());
-  Record.push_back(E->getManglingNumber());
+  Record.push_back(static_cast(E->getLifetimeExtendedTemporaryDecl()));
+  if (E->getLifetimeExtendedTemporaryDecl())
+Record.AddDeclRef(E->getLifetimeExtendedTemporaryDecl());
+  else
+Record.AddStmt(E->getSubExpr());
   Code = serialization::EXPR_MATERIALIZE_TEMPORARY;
 }
 
Index: clang/lib/Serialization/ASTWriterDecl.cpp

[clang] a4a7c12 - [clang-format] Add SpaceBeforeBrackets

2019-11-16 Thread via cfe-commits

Author: mydeveloperday
Date: 2019-11-16T11:54:21Z
New Revision: a4a7c1259e8a8f2d11fa29686a6c2834948c1358

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

LOG: [clang-format] Add SpaceBeforeBrackets

Summary: Adds a new option SpaceBeforeBrackets to add spaces before brackets 
(i.e. int a[23]; -> int a [23];)  This is present as an option in the Visual 
Studio C++ code formatting settings, but there was no matching setting in 
clang-format.

Reviewers: djasper, MyDeveloperDay, mitchell-stellar

Reviewed By: MyDeveloperDay

Subscribers: llvm-commits, cfe-commits, klimek

Patch by: Anteru

Tags: #clang, #clang-format, #llvm

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 1a9c5b8395f4..f438ec7f871b 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1432,6 +1432,10 @@ the configuration (without a prefix: ``Auto``).
  f(MyMap[{composite, key}]);f(MyMap[{ composite, key }]);
  new int[3]{1, 2, 3};   new int[3]{ 1, 2, 3 };
 
+**DeriveLineEnding** (``bool``)
+  Analyze the formatted file for the most used line ending (``\r\n``
+  or ``\n``). ``UseCRLF`` is only used as a fallback if none can be derived.
+
 **DerivePointerAlignment** (``bool``)
   If ``true``, analyze the formatted file for the most common
   alignment of ``&`` and ``*``.
@@ -2257,6 +2261,16 @@ the configuration (without a prefix: ``Auto``).
  true:  false:
  for (auto v : values) {}   vs. for(auto v: values) {}
 
+**SpaceBeforeSquareBrackets** (``bool``)
+  If ``true``, spaces will be before  ``[``.
+  Lambdas will not be affected. Only the first ``[`` will get a space added.
+
+  .. code-block:: c++
+
+ true:  false:
+ int a [5];vs.  int a[5];
+ int a [5][5]; vs.  int a[5][5];
+
 **SpaceInEmptyBlock** (``bool``)
   If ``true``, spaces will be inserted into ``{}``.
 
@@ -2409,6 +2423,10 @@ the configuration (without a prefix: ``Auto``).
 
   For example: OpenSSL STACK_OF, BSD LIST_ENTRY.
 
+**UseCRLF** (``bool``)
+  Use ``\r\n`` instead of ``\n`` for line breaks.
+  Also used as fallback if ``DeriveLineEnding`` is true.
+
 **UseTab** (``UseTabStyle``)
   The way to use tab characters in the resulting file.
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index f5c356fa2262..604a935f3a28 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1986,6 +1986,15 @@ struct FormatStyle {
   /// \endcode
   bool SpacesInSquareBrackets;
 
+  /// If ``true``, spaces will be before  ``[``.
+  /// Lambdas will not be affected. Only the first ``[`` will get a space 
added.
+  /// \code
+  ///true:  false:
+  ///int a [5];vs.  int a[5];
+  ///int a [5][5]; vs.  int a[5][5];
+  /// \endcode
+  bool SpaceBeforeSquareBrackets;
+
   /// Supported language standards for parsing and formatting C++ constructs.
   /// \code
   ///Latest:vector>
@@ -2150,10 +2159,10 @@ struct FormatStyle {
SpacesInCStyleCastParentheses == R.SpacesInCStyleCastParentheses &&
SpacesInParentheses == R.SpacesInParentheses &&
SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
+   SpaceBeforeSquareBrackets == R.SpaceBeforeSquareBrackets &&
Standard == R.Standard && TabWidth == R.TabWidth &&
StatementMacros == R.StatementMacros && UseTab == R.UseTab &&
-   UseCRLF == R.UseCRLF &&
-   TypenameMacros == R.TypenameMacros;
+   UseCRLF == R.UseCRLF && TypenameMacros == R.TypenameMacros;
   }
 
   llvm::Optional GetLanguageStyle(LanguageKind Language) const;

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
old mode 100644
new mode 100755
index 083c3a8f02fd..4e42bab56182
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -543,6 +543,8 @@ template <> struct MappingTraits {
Style.SpacesInCStyleCastParentheses);
 IO.mapOptional("SpacesInParentheses", Style.SpacesInParentheses);
 IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
+IO.mapOptional("SpaceBeforeSquareBrackets",
+   Style.SpaceBeforeSquareBrackets);
 

[PATCH] D70270: clang-tidy: modernize-use-using uses AST and now supports struct defintions and multiple types in a typedef

2019-11-16 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc added a comment.

> If there's a way to match only `CXXRecordDecl`s that are immediately followed 
> by a `TypedefDecl`...

Alternatively, within `check()` when we get the `TypedefDecl`, is there any way 
to navigate up the AST to find its immediately preceding sibling node in the 
AST and check whether it's a `CXXRecordDecl`? If so we could eliminate 
`Finder->addMatcher(cxxRecordDecl(unless(isImplicit())).bind("struct"), this);` 
altogether. I didn't see a way to do that though.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70270



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


[PATCH] D70306: clang: Exherbo multiarch ajustments

2019-11-16 Thread Marc-Antoine Perennou via Phabricator via cfe-commits
Keruspe updated this revision to Diff 229682.
Keruspe added a comment.
Herald added subscribers: ormris, atanasyan.

Mark some tests as XFAIL on exherbo because the filesystem layout is different


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

https://reviews.llvm.org/D70306

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/android-ndk-standalone.cpp
  clang/test/Driver/arm-multilibs.c
  clang/test/Driver/cross-linux.c
  clang/test/Driver/dyld-prefix.c
  clang/test/Driver/linux-header-search.cpp
  clang/test/Driver/linux-ld.c
  clang/test/Driver/mips-cs.cpp
  clang/test/Driver/mips-fsf.cpp
  clang/test/Driver/mips-img.cpp
  clang/test/Headers/arm-fp16-header.c
  clang/test/Headers/arm-neon-header.c
  clang/test/lit.cfg.py

Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -193,3 +193,6 @@
 
 if config.enable_shared:
 config.available_features.add("enable_shared")
+
+if os.path.exists('/etc/exherbo-release'):
+config.available_features.add('exherbo')
Index: clang/test/Headers/arm-neon-header.c
===
--- clang/test/Headers/arm-neon-header.c
+++ clang/test/Headers/arm-neon-header.c
@@ -1,3 +1,5 @@
+// XFAIL: exherbo
+
 // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversions -ffreestanding %s
 // RUN: %clang_cc1 -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -flax-vector-conversions=none -ffreestanding %s
 // RUN: %clang_cc1 -x c++ -triple thumbv7-apple-darwin10 -target-cpu cortex-a8 -fsyntax-only -Wvector-conversions -ffreestanding %s
Index: clang/test/Headers/arm-fp16-header.c
===
--- clang/test/Headers/arm-fp16-header.c
+++ clang/test/Headers/arm-fp16-header.c
@@ -1,3 +1,5 @@
+// XFAIL: exherbo
+
 // RUN: %clang -fsyntax-only  -ffreestanding  --target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c89 -xc %s
 // RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding --target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c99 -xc %s
 // RUN: %clang -fsyntax-only -Wall -Werror -ffreestanding --target=aarch64-none-eabi -march=armv8.2-a+fp16 -std=c11 -xc %s
Index: clang/test/Driver/mips-img.cpp
===
--- clang/test/Driver/mips-img.cpp
+++ clang/test/Driver/mips-img.cpp
@@ -1,4 +1,5 @@
 // REQUIRES: mips-registered-target
+// XFAIL: exherbo
 
 // Check frontend and linker invocations on the IMG MIPS toolchain.
 //
Index: clang/test/Driver/mips-fsf.cpp
===
--- clang/test/Driver/mips-fsf.cpp
+++ clang/test/Driver/mips-fsf.cpp
@@ -1,4 +1,5 @@
 // REQUIRES: mips-registered-target
+// XFAIL: exherbo
 
 // Check frontend and linker invocations on FSF MIPS toolchain.
 //
Index: clang/test/Driver/mips-cs.cpp
===
--- clang/test/Driver/mips-cs.cpp
+++ clang/test/Driver/mips-cs.cpp
@@ -1,4 +1,5 @@
 // REQUIRES: mips-registered-target
+// XFAIL: exherbo
 //
 // Check frontend and linker invocations on Mentor Graphics MIPS toolchain.
 //
Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1,3 +1,5 @@
+// XFAIL: exherbo
+
 // General tests that ld invocations on Linux targets sane. Note that we use
 // sysroot to make these tests independent of the host system.
 //
Index: clang/test/Driver/linux-header-search.cpp
===
--- clang/test/Driver/linux-header-search.cpp
+++ clang/test/Driver/linux-header-search.cpp
@@ -1,3 +1,5 @@
+// XFAIL: exherbo
+
 // General tests that the header search paths detected by the driver and passed
 // to CC1 are sane.
 //
Index: clang/test/Driver/dyld-prefix.c
===
--- clang/test/Driver/dyld-prefix.c
+++ clang/test/Driver/dyld-prefix.c
@@ -1,3 +1,5 @@
+// XFAIL: exherbo
+
 // RUN: touch %t.o
 
 // RUN: %clang -target i386-unknown-linux --dyld-prefix /foo -### %t.o 2>&1 | FileCheck --check-prefix=CHECK-32 %s
Index: clang/test/Driver/cross-linux.c
===
--- clang/test/Driver/cross-linux.c
+++ clang/test/Driver/cross-linux.c
@@ -1,3 +1,5 @@
+// XFAIL: exherbo
+
 // RUN: %clang -### -o %t %s 2>&1 -no-integrated-as -fuse-ld=ld \
 // RUN:   --gcc-toolchain=%S/Inputs/basic_cross_linux_tree/usr \
 // RUN:   --target=i386-unknown-linux-gnu \
Index: clang/test/Driver/arm-multilibs.c
===
--- clang/test/Driver/arm-multilibs.c
+++ clang/test/Driver/arm-multilibs.c
@@ -1,3 +1,5 @@
+// XFAIL: exherbo
+
 // RUN: 

[PATCH] D70355: [clang-format] [NFC] add recent changes to release notes

2019-11-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: klimek, mitchell-stellar, sylvestre.ledru, 
sammccall.
MyDeveloperDay added projects: clang-format, clang.
MyDeveloperDay added a subscriber: Eugene.Zelenko.
MyDeveloperDay added a comment.

@Eugene.Zelenko I've noticed you are always giving excellent review feedback in 
clang-tidy especially around the documentation, I'd appreciate your eyes on 
finding the right level of documentation here.


clang-tidy keeps nice release notes of what is added, have clang-format didn't 
do the same.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70355

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -319,6 +319,28 @@
   ``ClassImpl.hpp`` would not have the main include file put on top
   before any other include.
 
+- Options and ``DeriveLineEnding`` and  ``UseCRLF`` added to allow 
+  clang-format to control the newlines, ``DeriveLineEnding`` is by default 
+  ``true`` and reflects is the existing mechanism, which based is on majority
+  rule. The new options allows this to be turned off and UseCRLF to control 
+  the decision as to which sort of line ending to use.
+
+- Option ``SpaceBeforeSquareBrackets`` added to allow for a space before
+  array declarations.
+
+  .. code-block:: c++
+
+int a [5];vsint a[5];
+
+
+- Clang-format now supports JavaScript null operators.
+
+  .. code-block:: c++
+
+const x = foo ?? default;
+const z = foo?.bar?.baz;
+
+
 libclang
 
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -319,6 +319,28 @@
   ``ClassImpl.hpp`` would not have the main include file put on top
   before any other include.
 
+- Options and ``DeriveLineEnding`` and  ``UseCRLF`` added to allow 
+  clang-format to control the newlines, ``DeriveLineEnding`` is by default 
+  ``true`` and reflects is the existing mechanism, which based is on majority
+  rule. The new options allows this to be turned off and UseCRLF to control 
+  the decision as to which sort of line ending to use.
+
+- Option ``SpaceBeforeSquareBrackets`` added to allow for a space before
+  array declarations.
+
+  .. code-block:: c++
+
+int a [5];vsint a[5];
+
+
+- Clang-format now supports JavaScript null operators.
+
+  .. code-block:: c++
+
+const x = foo ?? default;
+const z = foo?.bar?.baz;
+
+
 libclang
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70355: [clang-format] [NFC] add recent changes to release notes

2019-11-16 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

General comments:

- Isn't //Option(s) ... was/were added// or //Option(s) ... had been added// 
are more correct from from point of view of English grammar? Same for older 
entries.
- It'll be great to nag developers to expand Release Notes when relevant code 
changes are made.




Comment at: clang/docs/ReleaseNotes.rst:322
 
+- Options and ``DeriveLineEnding`` and  ``UseCRLF`` added to allow 
+  clang-format to control the newlines, ``DeriveLineEnding`` is by default 

and between Options and DeriveLineEnding are not necessary.



Comment at: clang/docs/ReleaseNotes.rst:323
+- Options and ``DeriveLineEnding`` and  ``UseCRLF`` added to allow 
+  clang-format to control the newlines, ``DeriveLineEnding`` is by default 
+  ``true`` and reflects is the existing mechanism, which based is on majority

I would suggest to use dot after newlines.



Comment at: clang/docs/ReleaseNotes.rst:325
+  ``true`` and reflects is the existing mechanism, which based is on majority
+  rule. The new options allows this to be turned off and UseCRLF to control 
+  the decision as to which sort of line ending to use.

UseCRLF should be enclosed in double back-ticks.



Comment at: clang/docs/ReleaseNotes.rst:328
+
+- Option ``SpaceBeforeSquareBrackets`` added to allow for a space before
+  array declarations.

to //insert//?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70355



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


[PATCH] D70355: [clang-format] [NFC] add recent changes to release notes

2019-11-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a subscriber: Eugene.Zelenko.
MyDeveloperDay added a comment.

@Eugene.Zelenko I've noticed you are always giving excellent review feedback in 
clang-tidy especially around the documentation, I'd appreciate your eyes on 
finding the right level of documentation here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70355



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


[clang] 42effc1 - Add support of the next Ubuntu (Ubuntu 20.04 - Focal Fossa)

2019-11-16 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2019-11-16T12:21:54+01:00
New Revision: 42effc106966d45053abdd4e3d03ecfe256869b5

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

LOG: Add support of the next Ubuntu (Ubuntu 20.04 - Focal Fossa)

Added: 


Modified: 
clang/include/clang/Driver/Distro.h
clang/lib/Driver/Distro.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Distro.h 
b/clang/include/clang/Driver/Distro.h
index 67dc764fb7d1..da8f819dee96 100644
--- a/clang/include/clang/Driver/Distro.h
+++ b/clang/include/clang/Driver/Distro.h
@@ -65,6 +65,7 @@ class Distro {
 UbuntuCosmic,
 UbuntuDisco,
 UbuntuEoan,
+UbuntuFocal,
 UnknownDistro
   };
 
@@ -118,7 +119,7 @@ class Distro {
   }
 
   bool IsUbuntu() const {
-return DistroVal >= UbuntuHardy && DistroVal <= UbuntuEoan;
+return DistroVal >= UbuntuHardy && DistroVal <= UbuntuFocal;
   }
 
   bool IsAlpineLinux() const {

diff  --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
index f2a3074d1e70..92e04108a7e2 100644
--- a/clang/lib/Driver/Distro.cpp
+++ b/clang/lib/Driver/Distro.cpp
@@ -52,6 +52,7 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem 
) {
   .Case("cosmic", Distro::UbuntuCosmic)
   .Case("disco", Distro::UbuntuDisco)
   .Case("eoan", Distro::UbuntuEoan)
+  .Case("focal", Distro::UbuntuFocal)
   .Default(Distro::UnknownDistro);
 if (Version != Distro::UnknownDistro)
   return Version;



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


[PATCH] D6920: [clang-format] Add SpaceBeforeBrackets

2019-11-16 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa4a7c1259e8a: [clang-format] Add SpaceBeforeBrackets 
(authored by MyDeveloperDay).

Changed prior to commit:
  https://reviews.llvm.org/D6920?vs=229612=229686#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6920

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10643,6 +10643,41 @@
   verifyFormat("int foo = [ , = ]() {};", Spaces);
 }
 
+TEST_F(FormatTest, ConfigurableSpaceBeforeBrackets) {
+  FormatStyle NoSpaceStyle = getLLVMStyle();
+  verifyFormat("int a[5];", NoSpaceStyle);
+  verifyFormat("a[3] += 42;", NoSpaceStyle);
+
+  verifyFormat("int a[1];", NoSpaceStyle);
+  verifyFormat("int 1 [a];", NoSpaceStyle);
+  verifyFormat("int a[1][2];", NoSpaceStyle);
+  verifyFormat("a[7] = 5;", NoSpaceStyle);
+  verifyFormat("int a = (f())[23];", NoSpaceStyle);
+  verifyFormat("f([] {})", NoSpaceStyle);
+
+  FormatStyle Space = getLLVMStyle();
+  Space.SpaceBeforeSquareBrackets = true;
+  verifyFormat("int c = []() -> int { return 2; }();\n", Space);
+  verifyFormat("return [i, args...] {};", Space);
+
+  verifyFormat("int a [5];", Space);
+  verifyFormat("a [3] += 42;", Space);
+  verifyFormat("constexpr char hello []{\"hello\"};", Space);
+  verifyFormat("double [](int i) { return 0; }\n"
+   "int i;",
+   Space);
+  verifyFormat("std::unique_ptr foo() {}", Space);
+  verifyFormat("int i = a [a][a]->f();", Space);
+  verifyFormat("int i = (*b) [a]->f();", Space);
+
+  verifyFormat("int a [1];", Space);
+  verifyFormat("int 1 [a];", Space);
+  verifyFormat("int a [1][2];", Space);
+  verifyFormat("a [7] = 5;", Space);
+  verifyFormat("int a = (f()) [23];", Space);
+  verifyFormat("f([] {})", Space);
+}
+
 TEST_F(FormatTest, ConfigurableSpaceBeforeAssignmentOperators) {
   verifyFormat("int a = 5;");
   verifyFormat("a += 42;");
@@ -12529,6 +12564,7 @@
   CHECK_PARSE_BOOL(SpaceBeforeCtorInitializerColon);
   CHECK_PARSE_BOOL(SpaceBeforeInheritanceColon);
   CHECK_PARSE_BOOL(SpaceBeforeRangeBasedForLoopColon);
+  CHECK_PARSE_BOOL(SpaceBeforeSquareBrackets);
   CHECK_PARSE_BOOL(UseCRLF);
 
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, AfterCaseLabel);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2724,7 +2724,9 @@
   !Right.isOneOf(TT_ObjCMethodExpr, TT_LambdaLSquare,
  TT_DesignatedInitializerLSquare,
  TT_StructuredBindingLSquare, TT_AttributeSquare) &&
-  !Left.isOneOf(tok::numeric_constant, TT_DictLiteral))
+  !Left.isOneOf(tok::numeric_constant, TT_DictLiteral) &&
+  !(!Left.is(tok::r_square) && Style.SpaceBeforeSquareBrackets &&
+Right.is(TT_ArraySubscriptLSquare)))
 return false;
   if (Left.is(tok::l_brace) && Right.is(tok::r_brace))
 return !Left.Children.empty(); // No spaces in "{}".
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -543,6 +543,8 @@
Style.SpacesInCStyleCastParentheses);
 IO.mapOptional("SpacesInParentheses", Style.SpacesInParentheses);
 IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
+IO.mapOptional("SpaceBeforeSquareBrackets",
+   Style.SpaceBeforeSquareBrackets);
 IO.mapOptional("Standard", Style.Standard);
 IO.mapOptional("StatementMacros", Style.StatementMacros);
 IO.mapOptional("TabWidth", Style.TabWidth);
@@ -813,6 +815,7 @@
   LLVMStyle.SpaceBeforeRangeBasedForLoopColon = true;
   LLVMStyle.SpaceBeforeAssignmentOperators = true;
   LLVMStyle.SpaceBeforeCpp11BracedList = false;
+  LLVMStyle.SpaceBeforeSquareBrackets = false;
   LLVMStyle.SpacesInAngles = false;
 
   LLVMStyle.PenaltyBreakAssignment = prec::Assignment;
@@ -1354,10 +1357,11 @@
 
 WhitespaceManager Whitespaces(
 Env.getSourceManager(), Style,
-Style.DeriveLineEnding ?
-  inputUsesCRLF(Env.getSourceManager().getBufferData(Env.getFileID()),
-Style.UseCRLF) :
-  Style.UseCRLF);
+Style.DeriveLineEnding
+? inputUsesCRLF(
+  Env.getSourceManager().getBufferData(Env.getFileID()),
+  Style.UseCRLF)
+: Style.UseCRLF);
 ContinuationIndenter Indenter(Style, Tokens.getKeywords(),
   Env.getSourceManager(), 

[PATCH] D70196: [clang-include-fixer] Skip .rc files when finding symbols

2019-11-16 Thread Kim Gräsman via Phabricator via cfe-commits
kimgr added a comment.

I wonder if it would be better to look at the compile-command than the source 
file?

It's not unthinkable that someone would use another extension for an rc file, 
or use a .rc extension for a C or C++ source file. But if the compiler is 
rc.exe, the source file must be in rc format and should be ignored, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70196



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


[PATCH] D70340: Add a key method to Sema to optimize debug info size

2019-11-16 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

PS: nice find!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70340



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


[PATCH] D6920: [clang-format] Add SpaceBeforeBrackets

2019-11-16 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

Would be nice to add this to the release notes too ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6920



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


[PATCH] D70340: Add a key method to Sema to optimize debug info size

2019-11-16 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

I don't see any reason not to do this. What's there to discuss? I'm probably 
missing something obvious.

dblaikie added anchor functions in many places a while ago (but iirc for 
vtables, not debug info).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70340



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


[PATCH] D62953: [Syntax] Do not glue multiple empty PP expansions to a single mapping

2019-11-16 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added inline comments.



Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:447
+tryConsumeSpelledUntil(File, EndOffset + 1, SpelledIndex).hasValue();
+(void)HitMapping;
+assert(!HitMapping && "recursive macro expansion?");

chrish_ericsson_atx wrote:
> What is intended by this line?
Suppressing compiler warning for unused local variable.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62953



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


[PATCH] D70270: clang-tidy: modernize-use-using uses AST and now supports struct defintions and multiple types in a typedef

2019-11-16 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc marked 6 inline comments as done.
poelmanc added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp:30
+  // They appear in the AST just *prior* to the typedefs.
+  Finder->addMatcher(cxxRecordDecl().bind("struct"), this);
 }

aaron.ballman wrote:
> It's unfortunate that we can't restrict this matcher more -- there tend to be 
> a lot of struct declarations, so I am a bit worried about the performance of 
> this matching on so many of them. At a minimum, I think you can restrict it 
> to non-implicit structs here and simplify the code in `check()` a bit.
Done, thanks!

If there's a way to match only `CXXRecordDecl`s that are //immediately 
followed// by a `TypedefDecl`, that would cut down the matches just to the ones 
we need. That said, at least the amount of work done on each `check()` call for 
the non-implicit `CXXRecordDecl`s is minimal: it just stores its `SourceRange` 
and returns.



Comment at: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp:85
+ReplaceRange.setBegin(LastReplacementEnd);
+Using = "; using ";
+

aaron.ballman wrote:
> Should there be a newline here, to avoid putting all the using declarations 
> on the same line?
Done. Updated test cases and documentation to reflect this.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70270



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


[PATCH] D70355: [clang-format] [NFC] add recent changes to release notes

2019-11-16 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60143 tests passed, 0 failed and 729 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70355



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


[clang] 9b40a7f - Remove +x permission on some files

2019-11-16 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2019-11-16T14:47:20+01:00
New Revision: 9b40a7f3bf7198dd64403cbd83478087e72f994b

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

LOG: Remove +x permission on some files

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.h
clang/include/clang/Tooling/Refactoring/Extract/SourceExtraction.h
clang/lib/StaticAnalyzer/Checkers/Yaml.h
clang/test/Modules/lsv-debuginfo.cpp

lldb/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp
openmp/runtime/test/ompt/callback.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
old mode 100755
new mode 100644

diff  --git a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.h
old mode 100755
new mode 100644

diff  --git 
a/clang/include/clang/Tooling/Refactoring/Extract/SourceExtraction.h 
b/clang/include/clang/Tooling/Refactoring/Extract/SourceExtraction.h
old mode 100755
new mode 100644

diff  --git a/clang/lib/StaticAnalyzer/Checkers/Yaml.h 
b/clang/lib/StaticAnalyzer/Checkers/Yaml.h
old mode 100755
new mode 100644

diff  --git a/clang/test/Modules/lsv-debuginfo.cpp 
b/clang/test/Modules/lsv-debuginfo.cpp
old mode 100755
new mode 100644

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp
 
b/lldb/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp
old mode 100755
new mode 100644

diff  --git a/openmp/runtime/test/ompt/callback.h 
b/openmp/runtime/test/ompt/callback.h
old mode 100755
new mode 100644



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


[PATCH] D6920: [clang-format] Add SpaceBeforeBrackets

2019-11-16 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

fyi, +x permissions was added to clang/lib/Format/Format.cpp 
I reverted the change in a4a7c1259e8a8f2d11fa29686a6c2834948c1358 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6920



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


[clang-tools-extra] 9b40a7f - Remove +x permission on some files

2019-11-16 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2019-11-16T14:47:20+01:00
New Revision: 9b40a7f3bf7198dd64403cbd83478087e72f994b

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

LOG: Remove +x permission on some files

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.h
clang/include/clang/Tooling/Refactoring/Extract/SourceExtraction.h
clang/lib/StaticAnalyzer/Checkers/Yaml.h
clang/test/Modules/lsv-debuginfo.cpp

lldb/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp
openmp/runtime/test/ompt/callback.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
old mode 100755
new mode 100644

diff  --git a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.h 
b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.h
old mode 100755
new mode 100644

diff  --git 
a/clang/include/clang/Tooling/Refactoring/Extract/SourceExtraction.h 
b/clang/include/clang/Tooling/Refactoring/Extract/SourceExtraction.h
old mode 100755
new mode 100644

diff  --git a/clang/lib/StaticAnalyzer/Checkers/Yaml.h 
b/clang/lib/StaticAnalyzer/Checkers/Yaml.h
old mode 100755
new mode 100644

diff  --git a/clang/test/Modules/lsv-debuginfo.cpp 
b/clang/test/Modules/lsv-debuginfo.cpp
old mode 100755
new mode 100644

diff  --git 
a/lldb/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp
 
b/lldb/packages/Python/lldbsuite/test/functionalities/thread/backtrace_all/ParallelTask.cpp
old mode 100755
new mode 100644

diff  --git a/openmp/runtime/test/ompt/callback.h 
b/openmp/runtime/test/ompt/callback.h
old mode 100755
new mode 100644



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


[PATCH] D70305: clang-format: fix regression in middle pointer alignment

2019-11-16 Thread MyDeveloperDay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5987cc1bb5d5: [clang-format] fix regression in middle 
pointer alignment (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70305

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14970,6 +14970,28 @@
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Middle;
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator void *();", Style);
+  verifyFormat("Foo::operator()(void *);", Style);
+  verifyFormat("Foo::operator*(void *);", Style);
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("operator*(int (*)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator void &();", Style);
+  verifyFormat("Foo::operator()(void &);", Style);
+  verifyFormat("Foo::operator&(void &);", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("operator&(int (&)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator void &&();", Style);
+  verifyFormat("Foo::operator()(void &&);", Style);
+  verifyFormat("Foo::operator&&(void &&);", Style);
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
 }
 
 } // namespace
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2694,7 +2694,7 @@
 // Space between the type and the *
 // operator void*(), operator char*(), operator Foo*() dependant
 // on PointerAlignment style.
-return (Style.PointerAlignment == FormatStyle::PAS_Right);
+return (Style.PointerAlignment != FormatStyle::PAS_Left);
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken , const FormatStyle ) {
 return Style.SpacesInContainerLiterals ||


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14970,6 +14970,28 @@
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Middle;
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator void *();", Style);
+  verifyFormat("Foo::operator()(void *);", Style);
+  verifyFormat("Foo::operator*(void *);", Style);
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("operator*(int (*)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator void &();", Style);
+  verifyFormat("Foo::operator()(void &);", Style);
+  verifyFormat("Foo::operator&(void &);", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("operator&(int (&)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator void &&();", Style);
+  verifyFormat("Foo::operator()(void &&);", Style);
+  verifyFormat("Foo::operator&&(void &&);", Style);
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
 }
 
 } // namespace
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2694,7 +2694,7 @@
 // Space between the type and the *
 // operator void*(), operator char*(), operator Foo*() dependant
 // on PointerAlignment style.
-return (Style.PointerAlignment == FormatStyle::PAS_Right);
+return (Style.PointerAlignment != FormatStyle::PAS_Left);
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken , const FormatStyle ) {
 return Style.SpacesInContainerLiterals ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69145: Give readability-redundant-member-init an option IgnoreBaseInCopyConstructors to avoid breaking code with gcc -Werror=extra

2019-11-16 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc added a subscriber: mgehre.
poelmanc added a comment.

In D69145#1715611 , @mgehre wrote:

> Exactly due to the issue you are fixing here, we ended up disabling the 
> complete check because we didn't want to live with the warnings it produced 
> on -Wextra.
>  Therefore, I'm actually strongly in favor to enable the option by default.
>
> When others see that clang-tidy fixits introduce warnings (with -Wextra) or 
> even break their build (with -Werror), they might not look into check 
> options, but just disable the check directly.


Just pinging to see if anyone has any thoughts on moving forward with this. 
Thanks in advance for any feedback!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69145



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


[clang] d4819fe - Remove +x permission on clang/lib/Format/Format.cpp

2019-11-16 Thread Sylvestre Ledru via cfe-commits

Author: Sylvestre Ledru
Date: 2019-11-16T14:44:35+01:00
New Revision: d4819fe0ec1037e1a995dca911278fee46384922

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

LOG: Remove +x permission on clang/lib/Format/Format.cpp

Added: 


Modified: 
clang/lib/Format/Format.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
old mode 100755
new mode 100644



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


[clang] 5987cc1 - [clang-format] fix regression in middle pointer alignment

2019-11-16 Thread via cfe-commits

Author: mydeveloperday
Date: 2019-11-16T14:37:47Z
New Revision: 5987cc1bb5d5eb624135e76a6b3ade1aef94caf7

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

LOG: [clang-format] fix regression in middle pointer alignment

Summary:
a75f8d98d7ac introduced a regression with Middle pointer alignment,
which this patch fixes.

Reviewers: MyDeveloperDay, klimek, sammccall

Reviewed By: MyDeveloperDay, sammccall

Subscribers: cfe-commits, merge_guards_bot

Patch by: Typz

Tags: #clang

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

Added: 


Modified: 
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index dcdc6e6e3364..9fe7fdc9ce93 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2694,7 +2694,7 @@ bool TokenAnnotator::spaceRequiredBetween(const 
AnnotatedLine ,
 // Space between the type and the *
 // operator void*(), operator char*(), operator Foo*() dependant
 // on PointerAlignment style.
-return (Style.PointerAlignment == FormatStyle::PAS_Right);
+return (Style.PointerAlignment != FormatStyle::PAS_Left);
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken , const FormatStyle ) {
 return Style.SpacesInContainerLiterals ||

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index e900936a1e67..d89ad44e4577 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -14970,6 +14970,28 @@ TEST_F(FormatTest, OperatorSpacing) {
   verifyFormat("Foo::operator&&(void&&);", Style);
   verifyFormat("Foo::operator&&();", Style);
   verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Middle;
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator void *();", Style);
+  verifyFormat("Foo::operator()(void *);", Style);
+  verifyFormat("Foo::operator*(void *);", Style);
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("operator*(int (*)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator void &();", Style);
+  verifyFormat("Foo::operator()(void &);", Style);
+  verifyFormat("Foo::operator&(void &);", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("operator&(int (&)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator void &&();", Style);
+  verifyFormat("Foo::operator()(void &&);", Style);
+  verifyFormat("Foo::operator&&(void &&);", Style);
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
 }
 
 } // namespace



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


[PATCH] D70111: [DWARF5]Addition of alignment field in the typedef for dwarf5

2019-11-16 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey added a comment.

Hi @aprantl. I had made the changes and my team member will commit this.


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

https://reviews.llvm.org/D70111



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


[PATCH] D70355: [clang-format] [NFC] add recent changes to release notes

2019-11-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 229690.
MyDeveloperDay added a comment.

Address review comments
Remove excessive newlines
Remove trailing whitespace


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

https://reviews.llvm.org/D70355

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -58,7 +58,7 @@
   access to determine if two operand expressions are the same.
 - -Wtautological-bitwise-compare is a new warning group.  This group has the
   current warning which diagnoses the tautological comparison of a bitwise
-  operation and a constant.  The group also has the new warning which diagnoses
+  operation and a constant. The group also has the new warning which diagnoses
   when a bitwise-or with a non-negative value is converted to a bool, since
   that bool will always be true.
 - -Wbitwise-conditional-parentheses will warn on operator precedence issues
@@ -137,9 +137,6 @@
 
 error LNK2005: "bool const std::_Is_integral" 
(??$_Is_integral@H@std@@3_NB) already defined
 
-
-
-
 C Language Changes in Clang
 ---
 
@@ -295,13 +292,16 @@
   - ``Auto`` is the default and detects style from the code (this is 
unchanged).
 
   The previous values of ``Cpp03`` and ``Cpp11`` are deprecated. Note that
-  ``Cpp11`` is treated as ``Latest``, as this was always clang-format's 
behavior.
-  (One motivation for this change is the new name describes the behavior 
better).
+  ``Cpp11`` is treated as ``Latest``, as this was always clang-format's
+  behavior. (One motivation for this change is the new name describes the
+  behavior better).
 
-- clang-format gets a new option called ``--dry-run`` or ``-n`` to emit a
-  warning.
+- Clang-format has a new option called ``--dry-run`` or ``-n`` to emit a
+  warning for clang-format violations. This can be used together
+  with --ferror-limit=N to limit the number of warnings per file and --Werror
+  to make warnings into errors.
 
-- Option *IncludeIsMainSourceRegex* added to allow for additional
+- Option *IncludeIsMainSourceRegex* has been added to allow for additional
   suffixes and file extensions to be considered as a source file
   for execution of logic that looks for "main *include* file" to put
   it on top.
@@ -310,7 +310,7 @@
   they end with: ``.c``, ``.cc``, ``.cpp``, ``.c++``, ``.cxx``,
   ``.m`` or ``.mm`` extensions. This config option allows to
   extend this set of source files considered as "main".
-
+
   For example, if this option is configured to ``(Impl\.hpp)$``,
   then a file ``ClassImpl.hpp`` is considered "main" (in addition to
   ``Class.c``, ``Class.cc``, ``Class.cpp`` and so on) and "main
@@ -319,12 +319,31 @@
   ``ClassImpl.hpp`` would not have the main include file put on top
   before any other include.
 
+- Options ``DeriveLineEnding`` and  ``UseCRLF`` have been added to allow
+  clang-format to control the newlines. ``DeriveLineEnding`` is by default
+  ``true`` and reflects is the existing mechanism, which based is on majority
+  rule. The new options allows this to be turned off and ``UseCRLF`` to control
+  the decision as to which sort of line ending to use.
+
+- Option ``SpaceBeforeSquareBrackets`` has been added to insert a space before
+  array declarations.
+
+  .. code-block:: c++
+
+int a [5];vsint a[5];
+
+- Clang-format now supports JavaScript null operators.
+
+  .. code-block:: c++
+
+const x = foo ?? default;
+const z = foo?.bar?.baz;
+
 libclang
 
 
 - ...
 
-
 Static Analyzer
 ---
 
@@ -372,7 +391,6 @@
 return getelementpointer_inbounds(base, offset);
   }
 
-
 Core Analysis Improvements
 ==
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -58,7 +58,7 @@
   access to determine if two operand expressions are the same.
 - -Wtautological-bitwise-compare is a new warning group.  This group has the
   current warning which diagnoses the tautological comparison of a bitwise
-  operation and a constant.  The group also has the new warning which diagnoses
+  operation and a constant. The group also has the new warning which diagnoses
   when a bitwise-or with a non-negative value is converted to a bool, since
   that bool will always be true.
 - -Wbitwise-conditional-parentheses will warn on operator precedence issues
@@ -137,9 +137,6 @@
 
 error LNK2005: "bool const std::_Is_integral" (??$_Is_integral@H@std@@3_NB) already defined
 
-
-
-
 C Language Changes in Clang
 ---
 
@@ -295,13 +292,16 @@
   - ``Auto`` is the default and detects style from the code (this is unchanged).
 
   The previous values of ``Cpp03`` and ``Cpp11`` are deprecated. Note that
-  ``Cpp11`` is treated as 

[PATCH] D69145: Give readability-redundant-member-init an option IgnoreBaseInCopyConstructors to avoid breaking code with gcc -Werror=extra

2019-11-16 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D69145#1748716 , @poelmanc wrote:

> In D69145#1715611 , @mgehre wrote:
>
> > Exactly due to the issue you are fixing here, we ended up disabling the 
> > complete check because we didn't want to live with the warnings it produced 
> > on -Wextra.
> >  Therefore, I'm actually strongly in favor to enable the option by default.
> >
> > When others see that clang-tidy fixits introduce warnings (with -Wextra) or 
> > even break their build (with -Werror), they might not look into check 
> > options, but just disable the check directly.
>
>
> Just pinging to see if anyone has any thoughts on moving forward with this. 
> Thanks in advance for any feedback!


If this would default to off i'd signoff.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69145



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


[PATCH] D6920: [clang-format] Add SpaceBeforeBrackets

2019-11-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D6920#1748764 , @sylvestre.ledru 
wrote:

> Would be nice to add this to the release notes too ;)


Addressing this and other missing release notes in D70355: [clang-format] [NFC] 
add recent changes to release notes , want to 
try and bring about a change were new clang-format changes are always release 
noted as I've seen  done with `clang-tidy`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6920



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


[PATCH] D59516: [analyzer] Add custom filter functions for GenericTaintChecker

2019-11-16 Thread Borsik Gábor via Phabricator via cfe-commits
boga95 marked 2 inline comments as done.
boga95 added a comment.

I did the required changes and tried to commit it, but I couldn't. I heard the 
codebase was migrated to GitHub. Maybe it affected my commit access.


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

https://reviews.llvm.org/D59516



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


[PATCH] D6920: [clang-format] Add SpaceBeforeBrackets

2019-11-16 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

@Anteru thanks for the patch this got landed today, I got burnt by the 100755 
mode change on the file, but thanks to @sylvestre.ledru it got resolved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D6920



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


[PATCH] D70270: clang-tidy: modernize-use-using uses AST and now supports struct defintions and multiple types in a typedef

2019-11-16 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc updated this revision to Diff 229678.
poelmanc edited the summary of this revision.

Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D70270

Files:
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-using.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
  clang/include/clang/Basic/SourceLocation.h

Index: clang/include/clang/Basic/SourceLocation.h
===
--- clang/include/clang/Basic/SourceLocation.h
+++ clang/include/clang/Basic/SourceLocation.h
@@ -192,6 +192,18 @@
   return LHS.getRawEncoding() < RHS.getRawEncoding();
 }
 
+inline bool operator>(const SourceLocation , const SourceLocation ) {
+  return LHS.getRawEncoding() > RHS.getRawEncoding();
+}
+
+inline bool operator<=(const SourceLocation , const SourceLocation ) {
+  return !(LHS > RHS);
+}
+
+inline bool operator>=(const SourceLocation , const SourceLocation ) {
+  return !(LHS < RHS);
+}
+
 /// A trivial tuple used to represent a source range.
 class SourceRange {
   SourceLocation B;
@@ -219,6 +231,11 @@
 return B != X.B || E != X.E;
   }
 
+  // Returns true iff other is wholly contained within this range.
+  bool contains(const SourceRange ) const {
+return B <= other.B && E >= other.E;
+  }
+
   void print(raw_ostream , const SourceManager ) const;
   std::string printToString(const SourceManager ) const;
   void dump(const SourceManager ) const;
Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
@@ -84,7 +84,11 @@
 
 typedef int bla1, bla2, bla3;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef int bla1, bla2, bla3;
+// CHECK-MESSAGES: :[[@LINE-2]]:17: warning: use 'using' instead of 'typedef'
+// CHECK-MESSAGES: :[[@LINE-3]]:23: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using bla1 = int;
+// CHECK-FIXES-NEXT: using bla2 = int;
+// CHECK-FIXES-NEXT: using bla3 = int;
 
 #define CODE typedef int INT
 
@@ -136,16 +140,16 @@
 
 typedef struct Q1 { int a; } S1;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef struct Q1 { int a; } S1;
+// CHECK-FIXES: using S1 = struct Q1 { int a; };
 typedef struct { int b; } S2;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef struct { int b; } S2;
+// CHECK-FIXES: using S2 = struct { int b; };
 struct Q2 { int c; } typedef S3;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: struct Q2 { int c; } typedef S3;
+// CHECK-FIXES: using S3 = struct Q2 { int c; };
 struct { int d; } typedef S4;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: struct { int d; } typedef S4;
+// CHECK-FIXES: using S4 = struct { int d; };
 
 namespace my_space {
   class my_cclass {};
@@ -196,11 +200,15 @@
 
 typedef S<(0 > 0), int> S_t, *S_p;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef S<(0 > 0), int> S_t, *S_p;
+// CHECK-MESSAGES: :[[@LINE-2]]:28: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using S_t = S<(0 > 0), int>;
+// CHECK-FIXES-NEXT: using S_p = S_t*;
 
 typedef S<(0 < 0), int> S2_t, *S2_p;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef S<(0 < 0), int> S2_t, *S2_p;
+// CHECK-MESSAGES: :[[@LINE-2]]:29: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using S2_t = S<(0 < 0), int>;
+// CHECK-FIXES-NEXT: using S2_p = S2_t*;
 
 typedef S<(0 > 0 && (3 > 1) && (1 < 1)), int> S3_t;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
@@ -213,7 +221,9 @@
 
 typedef Q Q_t, *Q_p;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef Q Q_t, *Q_p;
+// CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Q_t = Q;
+// CHECK-FIXES-NEXT: using Q_p = Q_t*;
 
 typedef Q Q2_t;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
@@ -227,7 +237,9 @@
 
 typedef Q Q3_t, *Q3_p;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef Q Q3_t, *Q3_p;
+// CHECK-MESSAGES: :[[@LINE-2]]:27: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Q3_t = Q;
+// CHECK-FIXES-NEXT: using Q3_p = Q3_t*;
 
 typedef Q Q3_t;
 // CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 

[PATCH] D70245: [OPENMP50]Add device/kind context selector support.

2019-11-16 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: clang/test/OpenMP/declare_variant_device_kind_codegen.cpp:81
+#define SUBSET host, cpu
+#define WRONG cpu, gpu
+#endif // CPU

jdoerfert wrote:
> What is wrong about cpu, gpu together?
When several traits sre used, the logic and is applied. So, cpu,gpu means that 
the target is cpu and gpu at the same time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70245



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


[PATCH] D65410: [PassManager] First Pass implementation at -O1 pass pipeline

2019-11-16 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

LGTM to land this and iterate, but you likely want someone else to confirm :)




Comment at: llvm/test/Other/new-pm-defaults.ll:253
+; CHECK-Os-NEXT: Finished llvm::Function pass manager run.
+; CHECK-Oz-NEXT: Finished llvm::Function pass manager run.
 ; CHECK-EP-SCALAR-LATE-NEXT: Running pass: NoOpFunctionPass

Just a drive-by idea: you could have simplified the changes here with a new 
prefix: "CHECK-O23sz" that you could add to the non-O1 invocations.



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

https://reviews.llvm.org/D65410



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


[PATCH] D70245: [OPENMP50]Add device/kind context selector support.

2019-11-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:11247
+RHSIsSubsetOfLHS = true;
+  } else {
+for (const OMPContextSelectorData  : LHS) {

Nit: `bool RHSIsSubsetOfLHS = isStrictSubset(RHS, LHS)`
saves you a line later.



Comment at: clang/test/OpenMP/declare_variant_device_kind_codegen.cpp:81
+#define SUBSET host, cpu
+#define WRONG cpu, gpu
+#endif // CPU

What is wrong about cpu, gpu together?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70245



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


[PATCH] D70348: Add header guards for header files that should not be included on the PS4 platform

2019-11-16 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D70348#1748580 , @craig.topper 
wrote:

> You could probably just define add __ORBIS__ to every line and then rely on 
> the individual feature defines at the end of the line to re-enable the ones 
> that are really supported. I assume the target-cpu is set to btver for ps4?


Good point. I talked it over internally with a few other people and think this 
is a good way to go. I'll revise and upload a new patch later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70348



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


[PATCH] D70351: [clang][WIP][clang-scan-deps] Add an experimental C API.

2019-11-16 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese created this revision.
Bigcheese added reviewers: arphaman, kousikk.
Herald added subscribers: llvm-commits, cfe-commits, tschuett, dexonsmith, 
mgorny.
Herald added projects: clang, LLVM.
Bigcheese added a parent revision: D70268: [clang][clang-scan-deps] Aggregate 
the full dependency information..

This adds an experimental C API for clang-scan-deps. It provides both
the full module dependency graph along with a flattened list of
dependencies.

See clang/include/clang-c/Dependencies.h for the API and documentation.

You can test it out using:
c-index-test core --scan-deps  -- clang --cc1 

This will output a list of modules and then the direct dependencies of
the main translation unit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70351

Files:
  clang/include/clang-c/Dependencies.h
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/tools/c-index-test/CMakeLists.txt
  clang/tools/c-index-test/core_main.cpp
  clang/tools/libclang/CDependencies.cpp
  clang/tools/libclang/CMakeLists.txt
  clang/tools/libclang/CXString.cpp
  clang/tools/libclang/CXString.h
  clang/tools/libclang/libclang.exports
  llvm/include/llvm/ADT/FunctionExtras.h

Index: llvm/include/llvm/ADT/FunctionExtras.h
===
--- llvm/include/llvm/ADT/FunctionExtras.h
+++ llvm/include/llvm/ADT/FunctionExtras.h
@@ -287,6 +287,37 @@
   }
 };
 
+template  struct FunctionObjectCallback {
+  void *Context;
+  CallTy *Callback;
+};
+
+namespace detail {
+template 
+struct functionObjectToCCallbackRefImpl;
+
+template 
+struct functionObjectToCCallbackRefImpl {
+  static FunctionObjectCallback impl(FuncTy ) {
+auto Func = +[](void *C, Args... V) -> Ret {
+  return (*reinterpret_cast *>(C))(
+  std::forward(V)...);
+};
+
+return {, Func};
+  }
+};
+} // namespace detail
+
+/// Returns a function pointer and context pair suitable for use as a C
+/// callback.
+///
+/// \param F the function object to turn into a C callback. The returned
+///   callback has the same lifetime as F.
+template 
+auto functionObjectToCCallbackRef(FuncTy ) {
+  return detail::functionObjectToCCallbackRefImpl::impl(F);
+}
 } // end namespace llvm
 
 #endif // LLVM_ADT_FUNCTION_H
Index: clang/tools/libclang/libclang.exports
===
--- clang/tools/libclang/libclang.exports
+++ clang/tools/libclang/libclang.exports
@@ -157,6 +157,13 @@
 clang_equalRanges
 clang_equalTypes
 clang_executeOnThread
+clang_experimental_DependencyScannerService_create_v0
+clang_experimental_DependencyScannerService_dispose_v0
+clang_experimental_DependencyScannerWorker_create_v0
+clang_experimental_DependencyScannerWorker_dispose_v0
+clang_experimental_DependencyScannerWorker_getFileDependencies_v0
+clang_experimental_FileDependencies_dispose
+clang_experimental_ModuleDependencySet_dispose
 clang_findIncludesInFile
 clang_findIncludesInFileWithBlock
 clang_findReferencesInFile
Index: clang/tools/libclang/CXString.h
===
--- clang/tools/libclang/CXString.h
+++ clang/tools/libclang/CXString.h
@@ -17,6 +17,7 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Compiler.h"
 #include 
 #include 
@@ -69,6 +70,8 @@
 
 CXStringSet *createSet(const std::vector );
 
+CXStringSet *createSet(const llvm::StringSet<> );
+
 /// A string pool used for fast allocation/deallocation of strings.
 class CXStringPool {
 public:
Index: clang/tools/libclang/CXString.cpp
===
--- clang/tools/libclang/CXString.cpp
+++ clang/tools/libclang/CXString.cpp
@@ -119,6 +119,15 @@
   return Set;
 }
 
+CXStringSet *createSet(const llvm::StringSet<> ) {
+  CXStringSet *Set = new CXStringSet;
+  Set->Count = Strings.size();
+  Set->Strings = new CXString[Set->Count];
+  int I = 0;
+  for (auto SI = Strings.begin(), SE = Strings.end(); SI != SE; ++SI)
+Set->Strings[I++] = createDup(SI->getKey());
+  return Set;
+}
 
 //===--===//
 // String pools.
Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(SOURCES
   ARCMigrate.cpp
   BuildSystem.cpp
+  CDependencies.cpp
   CIndex.cpp
   CIndexCXX.cpp
   CIndexCodeCompletion.cpp
@@ -37,6 +38,7 @@
 set(LIBS
   clangAST
   clangBasic
+  clangDependencyScanning
   clangDriver
   clangFrontend
   clangIndex
Index: clang/tools/libclang/CDependencies.cpp
===
--- /dev/null
+++ 

[PATCH] D65410: [PassManager] First Pass implementation at -O1 pass pipeline

2019-11-16 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

Ping :)


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

https://reviews.llvm.org/D65410



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


[PATCH] D70348: Add header guards for header files that should not be included on the PS4 platform

2019-11-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

You could probably just define add __ORBIS__ to every line and then rely on the 
individual feature defines at the end of the line to re-enable the ones that 
are really supported. I assume the target-cpu is set to btver for ps4?




Comment at: clang/lib/Headers/immintrin.h:460
   defined(__AVX512VP2INTERSECT__)
 #include 
 #endif

you don't need this one either


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70348



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


[PATCH] D69292: Proposal to add -Wtautological-compare to -Wall

2019-11-16 Thread Richard Trieu via Phabricator via cfe-commits
rtrieu added a comment.

In D69292#1747062 , @mclow.lists wrote:

> Sorry I'm late to the party; I've been traveling for 3+ weeks.
>  I would like to be reassured that the following code will not warn:
>
>   `
>long foo = ...; // some calculation
>if (foo < std::numeric_limits::min() || foo > 
> std::numeric_limits::max()) .
>   
>
> This is important for systems where `sizeof(int) == sizeof(long)`


The question is whether there's a warning when a value is tautologically 
compared with the min or max of that value's type.  They fall under 
-Wtype-limits or -Wtautological-constant-in-range-compare.  Despite the 
"tautological" in the name, they do not fall under -Wtautological-compare.  
Therefore, your example code will not get any warnings with -Wall.

I checked the clang tests and this covered by 
test/Sema/tautological-constant-compare.c, testing both the warnings is active 
only when the specific warning groups are active (the #ifdef TEST sections) and 
that the warnings are off for no warning flags, just -Wextra, and just -Wall.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69292



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


[PATCH] D70342: [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

2019-11-16 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 229660.
xbolva00 added a comment.

Newline fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70342

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/deprecated-copy.cpp


Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -DDEPRECATED_COPY_DTOR 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wextra -verify
+
+#ifdef DEPRECATED_COPY_DTOR
+struct A {
+  int *ptr;
+  ~A() { delete ptr; } // expected-warning {{definition of implicit copy 
constructor for 'A' is deprecated because it has a user-declared destructor}}
+};
+
+void foo() {
+  A a{};
+  A b = a; // expected-note {{implicit copy constructor for 'A' first required 
here}}
+}
+#else
+struct B {
+  B =(const B &); // expected-warning {{definition of implicit copy 
constructor for 'B' is deprecated because it has a user-declared copy 
assignment operator}}
+};
+
+void bar() {
+  B b1, b2(b1); // expected-note {{implicit copy constructor for 'B' first 
required here}}
+}
+#endif
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -12434,9 +12434,10 @@
 
   if (UserDeclaredOperation) {
 S.Diag(UserDeclaredOperation->getLocation(),
- diag::warn_deprecated_copy_operation)
-  << RD << /*copy assignment*/!isa(CopyOp)
-  << /*destructor*/isa(UserDeclaredOperation);
+   isa(UserDeclaredOperation)
+   ? diag::warn_deprecated_copy_dtor_operation
+   : diag::warn_deprecated_copy_operation)
+<< RD << /*copy assignment*/ !isa(CopyOp);
   }
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -551,9 +551,13 @@
   "use using declarations instead">;
 def warn_deprecated_copy_operation : Warning<
   "definition of implicit copy %select{constructor|assignment operator}1 "
-  "for %0 is deprecated because it has a user-declared "
-  "%select{copy %select{assignment operator|constructor}1|destructor}2">,
-  InGroup, DefaultIgnore;
+  "for %0 is deprecated because it has a user-declared copy "
+  "%select{assignment operator|constructor}1">,
+  InGroup, DefaultIgnore;
+def warn_deprecated_copy_dtor_operation : Warning<
+  "definition of implicit copy %select{constructor|assignment operator}1 "
+  "for %0 is deprecated because it has a user-declared destructor">,
+  InGroup, DefaultIgnore;
 def warn_cxx17_compat_exception_spec_in_signature : Warning<
   "mangled name of %0 will change in C++17 due to non-throwing exception "
   "specification in function signature">, InGroup;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -128,6 +128,8 @@
 
 def DeprecatedAttributes : DiagGroup<"deprecated-attributes">;
 def DeprecatedCommaSubscript : DiagGroup<"deprecated-comma-subscript">;
+def DeprecatedCopy : DiagGroup<"deprecated-copy">;
+def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor">;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
 def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
 def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">;
@@ -147,6 +149,8 @@
 // FIXME: Why is DeprecatedImplementations not in this group?
 def Deprecated : DiagGroup<"deprecated", [DeprecatedAttributes,
   DeprecatedCommaSubscript,
+  DeprecatedCopy,
+  DeprecatedCopyDtor,
   DeprecatedDeclarations,
   DeprecatedDynamicExceptionSpec,
   DeprecatedIncrementBool,
@@ -812,6 +816,7 @@
   ]>;
 
 def Extra : DiagGroup<"extra", [
+DeprecatedCopy,
 MissingFieldInitializers,
 IgnoredQualifiers,
 InitializerOverrides,


Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -DDEPRECATED_COPY_DTOR -verify
+// RUN: %clang_cc1 -std=c++11 

[PATCH] D70342: [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

2019-11-16 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

In D70342#1748555 , @rsmith wrote:

> Generally OK, but I'm concerned about including this in `-Wextra`. In 
> particular, the deprecation of copy/move operations when a destructor is 
> explicitly declared has experimentally been found to have a high 
> false-positive rate. Does GCC include this in `-Wextra`? (Its documentation 
> doesn't seem to say so.)


Yes, right. Fixed. New revision should be OK.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70342



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


[PATCH] D70342: [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

2019-11-16 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 229658.
xbolva00 added a comment.

Added -Wdeprecated-copy-dtor (not part of -Wextra). Now we should be fully 
compatible with GCC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70342

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/deprecated-copy.cpp


Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -DDEPRECATED_COPY_DTOR 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wextra -verify
+
+#ifdef DEPRECATED_COPY_DTOR
+struct A {
+  int *ptr;
+  ~A() { delete ptr; } // expected-warning {{definition of implicit copy 
constructor for 'A' is deprecated because it has a user-declared destructor}}
+};
+
+void foo() {
+  A a{};
+  A b = a; // expected-note {{implicit copy constructor for 'A' first required 
here}}
+}
+#else
+struct B {
+  B =(const B &); // expected-warning {{definition of implicit copy 
constructor for 'B' is deprecated because it has a user-declared copy 
assignment operator}}
+};
+
+void bar() {
+  B b1, b2(b1); // expected-note {{implicit copy constructor for 'B' first 
required here}}
+}
+#endif
\ No newline at end of file
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -12434,9 +12434,10 @@
 
   if (UserDeclaredOperation) {
 S.Diag(UserDeclaredOperation->getLocation(),
- diag::warn_deprecated_copy_operation)
-  << RD << /*copy assignment*/!isa(CopyOp)
-  << /*destructor*/isa(UserDeclaredOperation);
+   isa(UserDeclaredOperation)
+   ? diag::warn_deprecated_copy_dtor_operation
+   : diag::warn_deprecated_copy_operation)
+<< RD << /*copy assignment*/ !isa(CopyOp);
   }
 }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -551,9 +551,13 @@
   "use using declarations instead">;
 def warn_deprecated_copy_operation : Warning<
   "definition of implicit copy %select{constructor|assignment operator}1 "
-  "for %0 is deprecated because it has a user-declared "
-  "%select{copy %select{assignment operator|constructor}1|destructor}2">,
-  InGroup, DefaultIgnore;
+  "for %0 is deprecated because it has a user-declared copy "
+  "%select{assignment operator|constructor}1">,
+  InGroup, DefaultIgnore;
+def warn_deprecated_copy_dtor_operation : Warning<
+  "definition of implicit copy %select{constructor|assignment operator}1 "
+  "for %0 is deprecated because it has a user-declared destructor">,
+  InGroup, DefaultIgnore;
 def warn_cxx17_compat_exception_spec_in_signature : Warning<
   "mangled name of %0 will change in C++17 due to non-throwing exception "
   "specification in function signature">, InGroup;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -128,6 +128,8 @@
 
 def DeprecatedAttributes : DiagGroup<"deprecated-attributes">;
 def DeprecatedCommaSubscript : DiagGroup<"deprecated-comma-subscript">;
+def DeprecatedCopy : DiagGroup<"deprecated-copy">;
+def DeprecatedCopyDtor : DiagGroup<"deprecated-copy-dtor">;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
 def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
 def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">;
@@ -147,6 +149,8 @@
 // FIXME: Why is DeprecatedImplementations not in this group?
 def Deprecated : DiagGroup<"deprecated", [DeprecatedAttributes,
   DeprecatedCommaSubscript,
+  DeprecatedCopy,
+  DeprecatedCopyDtor,
   DeprecatedDeclarations,
   DeprecatedDynamicExceptionSpec,
   DeprecatedIncrementBool,
@@ -812,6 +816,7 @@
   ]>;
 
 def Extra : DiagGroup<"extra", [
+DeprecatedCopy,
 MissingFieldInitializers,
 IgnoredQualifiers,
 InitializerOverrides,


Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
+// RUN: 

[PATCH] D70342: [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

2019-11-16 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Generally OK, but I'm concerned about including this in `-Wextra`. In 
particular, the deprecation of copy/move operations when a destructor is 
explicitly declared has experimentally been found to have a high false-positive 
rate. Does GCC include this in `-Wextra`? (Its documentation doesn't seem to 
say so.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70342



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


[PATCH] D70349: [Attr] Fix `-ast-print` for `asm` attribute

2019-11-16 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny created this revision.
jdenny added reviewers: erichkeane, aaron.ballman.
Herald added a project: clang.

Without this fix, the tests introduced here produce the following
assert fail:

  clang: /home/jdenny/llvm/clang/include/clang/Basic/AttributeCommonInfo.h:163: 
unsigned int clang::AttributeCommonInfo::getAttributeSpellingListIndex() const: 
Assertion `(isAttributeSpellingListCalculated() || AttrName) && "Spelling 
cannot be found"' failed.

The bug was introduced by D67368 , which 
caused `AsmLabelAttr`'s
spelling index to be set to `SpellingNotCalculated`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70349

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-print-attr.c


Index: clang/test/AST/ast-print-attr.c
===
--- clang/test/AST/ast-print-attr.c
+++ clang/test/AST/ast-print-attr.c
@@ -10,3 +10,8 @@
 // FIXME: Too many parens here!
 // CHECK: using C = int ((*))() __attribute__((cdecl));
 using C = int (*)() [[gnu::cdecl]];
+
+// CHECK: int fun_asm() asm("");
+int fun_asm() asm("");
+// CHECK: int var_asm asm("");
+int var_asm asm("");
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -7017,8 +7017,9 @@
   }
 }
 
-NewVD->addAttr(::new (Context) AsmLabelAttr(
-Context, SE->getStrTokenLoc(0), Label, /*IsLiteralLabel=*/true));
+NewVD->addAttr(AsmLabelAttr::Create(Context, Label,
+/*IsLiteralLabel=*/true,
+SE->getStrTokenLoc(0)));
   } else if (!ExtnameUndeclaredIdentifiers.empty()) {
 llvm::DenseMap::iterator I =
   ExtnameUndeclaredIdentifiers.find(NewVD->getIdentifier());
@@ -8921,9 +8922,9 @@
   if (Expr *E = (Expr*) D.getAsmLabel()) {
 // The parser guarantees this is a string.
 StringLiteral *SE = cast(E);
-NewFD->addAttr(::new (Context)
-   AsmLabelAttr(Context, SE->getStrTokenLoc(0),
-SE->getString(), /*IsLiteralLabel=*/true));
+NewFD->addAttr(AsmLabelAttr::Create(Context, SE->getString(),
+/*IsLiteralLabel=*/true,
+SE->getStrTokenLoc(0)));
   } else if (!ExtnameUndeclaredIdentifiers.empty()) {
 llvm::DenseMap::iterator I =
   ExtnameUndeclaredIdentifiers.find(NewFD->getIdentifier());


Index: clang/test/AST/ast-print-attr.c
===
--- clang/test/AST/ast-print-attr.c
+++ clang/test/AST/ast-print-attr.c
@@ -10,3 +10,8 @@
 // FIXME: Too many parens here!
 // CHECK: using C = int ((*))() __attribute__((cdecl));
 using C = int (*)() [[gnu::cdecl]];
+
+// CHECK: int fun_asm() asm("");
+int fun_asm() asm("");
+// CHECK: int var_asm asm("");
+int var_asm asm("");
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -7017,8 +7017,9 @@
   }
 }
 
-NewVD->addAttr(::new (Context) AsmLabelAttr(
-Context, SE->getStrTokenLoc(0), Label, /*IsLiteralLabel=*/true));
+NewVD->addAttr(AsmLabelAttr::Create(Context, Label,
+/*IsLiteralLabel=*/true,
+SE->getStrTokenLoc(0)));
   } else if (!ExtnameUndeclaredIdentifiers.empty()) {
 llvm::DenseMap::iterator I =
   ExtnameUndeclaredIdentifiers.find(NewVD->getIdentifier());
@@ -8921,9 +8922,9 @@
   if (Expr *E = (Expr*) D.getAsmLabel()) {
 // The parser guarantees this is a string.
 StringLiteral *SE = cast(E);
-NewFD->addAttr(::new (Context)
-   AsmLabelAttr(Context, SE->getStrTokenLoc(0),
-SE->getString(), /*IsLiteralLabel=*/true));
+NewFD->addAttr(AsmLabelAttr::Create(Context, SE->getString(),
+/*IsLiteralLabel=*/true,
+SE->getStrTokenLoc(0)));
   } else if (!ExtnameUndeclaredIdentifiers.empty()) {
 llvm::DenseMap::iterator I =
   ExtnameUndeclaredIdentifiers.find(NewFD->getIdentifier());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4516dc1 - Don't add optnone or noinline if the function is already marked as

2019-11-16 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2019-11-15T15:44:04-08:00
New Revision: 4516dc1c20d1e77f20a72e90be876506805b3978

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

LOG: Don't add optnone or noinline if the function is already marked as
always_inline.

The assertion in SetLLVMFunctionAttributesForDefinition used to fail
when there was attribute OptimizeNone on the AST function and attribute
always_inline on the IR function. This happens because base destructors
are annotated with always_inline when the code is compiled with
-fapple-kext (see r124757).

rdar://problem/57169694

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/apple-kext.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index b7db1f49c0e9..e253bbc19915 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1515,16 +1515,15 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
   !CodeGenOpts.DisableO0ImplyOptNone && CodeGenOpts.OptimizationLevel == 0;
   // We can't add optnone in the following cases, it won't pass the verifier.
   ShouldAddOptNone &= !D->hasAttr();
-  ShouldAddOptNone &= !F->hasFnAttribute(llvm::Attribute::AlwaysInline);
   ShouldAddOptNone &= !D->hasAttr();
 
-  if (ShouldAddOptNone || D->hasAttr()) {
+  // Add optnone, but do so only if the function isn't always_inline.
+  if ((ShouldAddOptNone || D->hasAttr()) &&
+  !F->hasFnAttribute(llvm::Attribute::AlwaysInline)) {
 B.addAttribute(llvm::Attribute::OptimizeNone);
 
 // OptimizeNone implies noinline; we should not be inlining such functions.
 B.addAttribute(llvm::Attribute::NoInline);
-assert(!F->hasFnAttribute(llvm::Attribute::AlwaysInline) &&
-   "OptimizeNone and AlwaysInline on same function!");
 
 // We still need to handle naked functions even though optnone subsumes
 // much of their semantics.
@@ -1540,7 +1539,8 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
 B.addAttribute(llvm::Attribute::NoInline);
   } else if (D->hasAttr()) {
 B.addAttribute(llvm::Attribute::NoDuplicate);
-  } else if (D->hasAttr()) {
+  } else if (D->hasAttr() && 
!F->hasFnAttribute(llvm::Attribute::AlwaysInline)) {
+// Add noinline if the function isn't always_inline.
 B.addAttribute(llvm::Attribute::NoInline);
   } else if (D->hasAttr() &&
  !F->hasFnAttribute(llvm::Attribute::NoInline)) {

diff  --git a/clang/test/CodeGenCXX/apple-kext.cpp 
b/clang/test/CodeGenCXX/apple-kext.cpp
index 0d7ccfb3be1a..990bc146c57c 100644
--- a/clang/test/CodeGenCXX/apple-kext.cpp
+++ b/clang/test/CodeGenCXX/apple-kext.cpp
@@ -4,6 +4,25 @@
 // CHECK: @llvm.global_ctors = appending global {{.*}} { i32 65535, void ()* 
[[CTOR0:@.*]], i8* null }
 // CHECK: @llvm.global_dtors = appending global {{.*}} { i32 65535, void ()* 
[[DTOR0:@.*]], i8* null }
 
+// Check that the base destructor is marked as always_inline when generating
+// code for kext.
+
+namespace testBaseDestructor {
+#pragma clang optimize off
+struct D {
+  virtual ~D();
+};
+
+D::~D() {}
+#pragma clang optimize on
+}
+
+// CHECK: define void @_ZN18testBaseDestructor1DD2Ev({{.*}}) unnamed_addr 
#[[ATTR0:.*]] align 2 {
+
+// CHECK: define void @_ZN18testBaseDestructor1DD1Ev({{.*}}) unnamed_addr 
#[[ATTR1:.*]] align 2 {
+
+// CHECK: define void @_ZN18testBaseDestructor1DD0Ev({{.*}}) unnamed_addr 
#[[ATTR1]] align 2 {
+
 // rdar://11241230
 namespace test0 {
   struct A { A(); ~A(); };
@@ -20,3 +39,6 @@ namespace test0 {
 // CHECK:define internal void [[DTOR0]]()
 // CHECK:  call void @_ZN5test01AD1Ev([[A]]* @_ZN5test01aE)
 // CHECK-NEXT: ret void
+
+// CHECK: attributes #[[ATTR0]] = { alwaysinline nounwind {{.*}} }
+// CHECK: attributes #[[ATTR1]] = { noinline nounwind {{.*}} }



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


[PATCH] D70348: Add header guards for header files that should not be included on the PS4 platform

2019-11-16 Thread Douglas Yung via Phabricator via cfe-commits
dyung created this revision.
dyung added a reviewer: craig.topper.
dyung added a project: clang.

For the PS4 platform, we want to exclude certain headers from being included 
because we do not support the features they provide. So for the headers we want 
to exclude, this change adds a check whether __ORBIS__ is defined and excludes 
the header from being included when it is. Compilers targeting the PS4 define 
__ORBIS__.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70348

Files:
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/x86intrin.h

Index: clang/lib/Headers/x86intrin.h
===
--- clang/lib/Headers/x86intrin.h
+++ clang/lib/Headers/x86intrin.h
@@ -38,15 +38,18 @@
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__LWP__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__LWP__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__MWAITX__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__MWAITX__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLZERO__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__CLZERO__)
 #include 
 #endif
 
Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -40,11 +40,13 @@
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLFLUSHOPT__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__CLFLUSHOPT__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLWB__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__CLWB__)
 #include 
 #endif
 
@@ -60,7 +62,8 @@
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__VPCLMULQDQ__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__VPCLMULQDQ__)
 #include 
 #endif
 
@@ -79,125 +82,143 @@
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__FMA__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__FMA__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512F__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__AVX512F__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VL__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__AVX512VL__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512BW__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__AVX512BW__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512BITALG__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__AVX512BITALG__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512CD__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__AVX512CD__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VPOPCNTDQ__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__AVX512VPOPCNTDQ__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || \
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
 (defined(__AVX512VL__) && defined(__AVX512VPOPCNTDQ__))
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512VNNI__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__AVX512VNNI__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || \
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
 (defined(__AVX512VL__) && defined(__AVX512VNNI__))
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512DQ__)
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
+defined(__AVX512DQ__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || \
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
 (defined(__AVX512VL__) && defined(__AVX512BITALG__))
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || \
+#if !(defined(_MSC_VER) || defined(__ORBIS__)) || __has_feature(modules) || \
 (defined(__AVX512VL__) && defined(__AVX512BW__))
 #include 
 #endif
 
-#if !defined(_MSC_VER) || 

[PATCH] D69238: Fix clang-tidy readability-redundant-string-init for c++17/c++2a

2019-11-16 Thread Mitchell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG06f3dabe4a2e: [clang-tidy] Fix 
readability-redundant-string-init for c++17/c++2a (authored by 
mitchell-stellar).

Changed prior to commit:
  https://reviews.llvm.org/D69238?vs=228556=229651#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69238

Files:
  clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-override.rst


Index: clang-tools-extra/docs/clang-tidy/checks/modernize-use-override.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/modernize-use-override.rst
+++ clang-tools-extra/docs/clang-tidy/checks/modernize-use-override.rst
@@ -27,6 +27,14 @@
 
If set to non-zero, this check will not diagnose destructors. Default is 
`0`.
 
+.. option:: AllowOverrideAndFinal
+
+   If set to non-zero, this check will not diagnose ``override`` as redundant
+   with ``final``. This is useful when code will be compiled by a compiler with
+   warning/error checking flags requiring ``override`` explicitly on overriden
+   members, such as ``gcc -Wsuggest-override``/``gcc 
-Werror=suggest-override``.
+   Default is `0`.
+
 .. option:: OverrideSpelling
 
Specifies a macro to use instead of ``override``. This is useful when
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -164,6 +164,12 @@
   Finds non-static member functions that can be made ``const``
   because the functions don't use ``this`` in a non-const way.
 
+- Improved :doc:`modernize-use-override
+  ` check.
+
+  The check now supports the ``AllowOverrideAndFinal`` option to eliminate
+  conflicts with ``gcc -Wsuggest-override`` or ``gcc 
-Werror=suggest-override``.
+
 Improvements to include-fixer
 -
 
Index: clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
===
--- clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
+++ clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
@@ -26,6 +26,7 @@
 
 private:
   const bool IgnoreDestructors;
+  const bool AllowOverrideAndFinal;
   const std::string OverrideSpelling;
   const std::string FinalSpelling;
 };
Index: clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
@@ -20,11 +20,13 @@
 UseOverrideCheck::UseOverrideCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   IgnoreDestructors(Options.get("IgnoreDestructors", false)),
+  AllowOverrideAndFinal(Options.get("AllowOverrideAndFinal", false)),
   OverrideSpelling(Options.get("OverrideSpelling", "override")),
   FinalSpelling(Options.get("FinalSpelling", "final")) {}
 
 void UseOverrideCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "IgnoreDestructors", IgnoreDestructors);
+  Options.store(Opts, "AllowOverrideAndFinal", AllowOverrideAndFinal);
   Options.store(Opts, "OverrideSpelling", OverrideSpelling);
   Options.store(Opts, "FinalSpelling", FinalSpelling);
 }
@@ -103,7 +105,8 @@
   bool OnlyVirtualSpecified = HasVirtual && !HasOverride && !HasFinal;
   unsigned KeywordCount = HasVirtual + HasOverride + HasFinal;
 
-  if (!OnlyVirtualSpecified && KeywordCount == 1)
+  if ((!OnlyVirtualSpecified && KeywordCount == 1) ||
+  (!HasVirtual && HasOverride && HasFinal && AllowOverrideAndFinal))
 return; // Nothing to do.
 
   std::string Message;
@@ -113,8 +116,9 @@
 Message = "annotate this function with '%0' or (rarely) '%1'";
   } else {
 StringRef Redundant =
-HasVirtual ? (HasOverride && HasFinal ? "'virtual' and '%0' are"
-  : "'virtual' is")
+HasVirtual ? (HasOverride && HasFinal && !AllowOverrideAndFinal
+  ? "'virtual' and '%0' are"
+  : "'virtual' is")
: "'%0' is";
 StringRef Correct = HasFinal ? "'%1'" : "'%0'";
 
@@ -211,7 +215,7 @@
 Diag << FixItHint::CreateInsertion(InsertLoc, ReplacementText);
   }
 
-  if (HasFinal && HasOverride) {
+  if (HasFinal && HasOverride && !AllowOverrideAndFinal) {
 SourceLocation OverrideLoc = 
Method->getAttr()->getLocation();
 Diag << FixItHint::CreateRemoval(
 CharSourceRange::getTokenRange(OverrideLoc, OverrideLoc));


Index: clang-tools-extra/docs/clang-tidy/checks/modernize-use-override.rst

[clang-tools-extra] 06f3dab - [clang-tidy] Fix readability-redundant-string-init for c++17/c++2a

2019-11-16 Thread Mitchell Balan via cfe-commits

Author: Mitchell Balan
Date: 2019-11-15T18:09:42-05:00
New Revision: 06f3dabe4a2e85a32ade27c0769b6084c828a206

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

LOG: [clang-tidy] Fix readability-redundant-string-init for c++17/c++2a

Summary:
`readability-redundant-string-init` was one of several clang-tidy checks 
documented as failing for C++17. (The failure mode in C++17 is that it changes 
`std::string Name = ""`; to `std::string Name = Name;`, which actually compiles 
but crashes at run-time.)

Analyzing the AST with `clang -Xclang -ast-dump` showed that the outer 
`CXXConstructExprs` that previously held the correct SourceRange were being 
elided in C++17/2a, but the containing `VarDecl` expressions still had all the 
relevant information. So this patch changes the fix to get its source ranges 
from `VarDecl`.

It adds one test `std::string g = "u", h = "", i = "uuu", j = "", k;` to 
confirm proper warnings and fixit replacements in a single `DeclStmt` where 
some strings require replacement and others don't. The 
readability-redundant-string-init.cpp and 
readability-redundant-string-init-msvc.cpp tests now pass for C++11/14/17/2a.

Reviewers: gribozavr, etienneb, alexfh, hokein, aaron.ballman, gribozavr2

Patch by: poelmanc

Subscribers: NoQ, MyDeveloperDay, Eugene.Zelenko, dylanmckay, cfe-commits

Tags: #clang, #clang-tools-extra

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/modernize-use-override.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
index 2f15213dca8c..8ee77ccd16ff 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
@@ -20,11 +20,13 @@ namespace modernize {
 UseOverrideCheck::UseOverrideCheck(StringRef Name, ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   IgnoreDestructors(Options.get("IgnoreDestructors", false)),
+  AllowOverrideAndFinal(Options.get("AllowOverrideAndFinal", false)),
   OverrideSpelling(Options.get("OverrideSpelling", "override")),
   FinalSpelling(Options.get("FinalSpelling", "final")) {}
 
 void UseOverrideCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   Options.store(Opts, "IgnoreDestructors", IgnoreDestructors);
+  Options.store(Opts, "AllowOverrideAndFinal", AllowOverrideAndFinal);
   Options.store(Opts, "OverrideSpelling", OverrideSpelling);
   Options.store(Opts, "FinalSpelling", FinalSpelling);
 }
@@ -103,7 +105,8 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult 
) {
   bool OnlyVirtualSpecified = HasVirtual && !HasOverride && !HasFinal;
   unsigned KeywordCount = HasVirtual + HasOverride + HasFinal;
 
-  if (!OnlyVirtualSpecified && KeywordCount == 1)
+  if ((!OnlyVirtualSpecified && KeywordCount == 1) ||
+  (!HasVirtual && HasOverride && HasFinal && AllowOverrideAndFinal))
 return; // Nothing to do.
 
   std::string Message;
@@ -113,8 +116,9 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult 
) {
 Message = "annotate this function with '%0' or (rarely) '%1'";
   } else {
 StringRef Redundant =
-HasVirtual ? (HasOverride && HasFinal ? "'virtual' and '%0' are"
-  : "'virtual' is")
+HasVirtual ? (HasOverride && HasFinal && !AllowOverrideAndFinal
+  ? "'virtual' and '%0' are"
+  : "'virtual' is")
: "'%0' is";
 StringRef Correct = HasFinal ? "'%1'" : "'%0'";
 
@@ -211,7 +215,7 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult 
) {
 Diag << FixItHint::CreateInsertion(InsertLoc, ReplacementText);
   }
 
-  if (HasFinal && HasOverride) {
+  if (HasFinal && HasOverride && !AllowOverrideAndFinal) {
 SourceLocation OverrideLoc = 
Method->getAttr()->getLocation();
 Diag << FixItHint::CreateRemoval(
 CharSourceRange::getTokenRange(OverrideLoc, OverrideLoc));

diff  --git a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
index ed163956ecdb..082778f2957c 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
@@ -26,6 +26,7 @@ class UseOverrideCheck : public ClangTidyCheck {
 
 private:
   const bool IgnoreDestructors;
+  const bool AllowOverrideAndFinal;
   const std::string OverrideSpelling;
   const std::string 

[PATCH] D70342: [Diagnostics] Put "deprecated copy" warnings into -Wdeprecated-copy

2019-11-16 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 created this revision.
xbolva00 added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

GCC 9 added -Wdeprecated-copy (as part of -Wextra). This diagnostic is already 
implemented in Clang too, just hidden under -Wdeprecated (not on by default).
This patch adds -Wdeprecated-copy and makes it compatible with GCC 9+.
This diagnostic is heavily tested in deprecated.cpp, so I added simple tests 
just to check we warn when new flag/-Wextra is enabled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70342

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/test/SemaCXX/deprecated-copy.cpp


Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++14 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++17 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++2a %s -Wdeprecated-copy -verify
+
+// RUN: %clang_cc1 -std=c++11 %s -Wextra -verify
+// RUN: %clang_cc1 -std=c++14 %s -Wextra -verify
+// RUN: %clang_cc1 -std=c++17 %s -Wextra -verify
+// RUN: %clang_cc1 -std=c++2a %s -Wextra -verify
+
+struct A {
+  int *ptr;
+  ~A() { delete ptr; } // expected-warning {{definition of implicit copy 
constructor for 'A' is deprecated because it has a user-declared destructor}}
+};
+
+struct B {
+  B =(const B &); // expected-warning {{definition of implicit copy 
constructor for 'B' is deprecated because it has a user-declared copy 
assignment operator}}
+};
+
+void foo() {
+  A a{};
+  A b = a;  // expected-note {{implicit copy constructor for 'A' first 
required here}}
+  B b1, b2(b1); // expected-note {{implicit copy constructor for 'B' first 
required here}}
+}
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -553,7 +553,7 @@
   "definition of implicit copy %select{constructor|assignment operator}1 "
   "for %0 is deprecated because it has a user-declared "
   "%select{copy %select{assignment operator|constructor}1|destructor}2">,
-  InGroup, DefaultIgnore;
+  InGroup, DefaultIgnore;
 def warn_cxx17_compat_exception_spec_in_signature : Warning<
   "mangled name of %0 will change in C++17 due to non-throwing exception "
   "specification in function signature">, InGroup;
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -128,6 +128,7 @@
 
 def DeprecatedAttributes : DiagGroup<"deprecated-attributes">;
 def DeprecatedCommaSubscript : DiagGroup<"deprecated-comma-subscript">;
+def DeprecatedCopy : DiagGroup<"deprecated-copy">;
 def DeprecatedDeclarations : DiagGroup<"deprecated-declarations">;
 def UnavailableDeclarations : DiagGroup<"unavailable-declarations">;
 def UnguardedAvailabilityNew : DiagGroup<"unguarded-availability-new">;
@@ -147,6 +148,7 @@
 // FIXME: Why is DeprecatedImplementations not in this group?
 def Deprecated : DiagGroup<"deprecated", [DeprecatedAttributes,
   DeprecatedCommaSubscript,
+  DeprecatedCopy,
   DeprecatedDeclarations,
   DeprecatedDynamicExceptionSpec,
   DeprecatedIncrementBool,
@@ -812,6 +814,7 @@
   ]>;
 
 def Extra : DiagGroup<"extra", [
+DeprecatedCopy,
 MissingFieldInitializers,
 IgnoredQualifiers,
 InitializerOverrides,


Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++14 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++17 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++2a %s -Wdeprecated-copy -verify
+
+// RUN: %clang_cc1 -std=c++11 %s -Wextra -verify
+// RUN: %clang_cc1 -std=c++14 %s -Wextra -verify
+// RUN: %clang_cc1 -std=c++17 %s -Wextra -verify
+// RUN: %clang_cc1 -std=c++2a %s -Wextra -verify
+
+struct A {
+  int *ptr;
+  ~A() { delete ptr; } // expected-warning {{definition of implicit copy constructor for 'A' is deprecated because it has a user-declared destructor}}
+};
+
+struct B {
+  B =(const B &); // expected-warning {{definition of implicit copy constructor for 'B' is deprecated because it has a user-declared copy assignment operator}}
+};
+
+void foo() {
+  A a{};
+  A b = a;  // expected-note {{implicit 

[PATCH] D68185: [Diagnostics] Warn when class implements a copy constructor/copy assignment operator, but missing the copy assignment operator/copy constructor

2019-11-16 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 abandoned this revision.
xbolva00 added a comment.

https://reviews.llvm.org/D70342


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

https://reviews.llvm.org/D68185



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


[clang] 9053574 - Don't use end-of-line comments for the DebugInfoKind enum, NFC

2019-11-16 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2019-11-15T14:06:23-08:00
New Revision: 905357440c98ae06aac692d7adbccc70f1ce9d28

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

LOG: Don't use end-of-line comments for the DebugInfoKind enum, NFC

These are long comments, and I find the new structure easier to read.

Added: 


Modified: 
clang/include/clang/Basic/DebugInfoOptions.h

Removed: 




diff  --git a/clang/include/clang/Basic/DebugInfoOptions.h 
b/clang/include/clang/Basic/DebugInfoOptions.h
index 91d3332103e9..ac18a3a4796c 100644
--- a/clang/include/clang/Basic/DebugInfoOptions.h
+++ b/clang/include/clang/Basic/DebugInfoOptions.h
@@ -18,24 +18,30 @@ enum DebugInfoFormat {
 };
 
 enum DebugInfoKind {
-  NoDebugInfo, /// Don't generate debug info.
-  LocTrackingOnly, /// Emit location information but do not generate
-   /// debug info in the output. This is useful in
-   /// cases where the backend wants to track source
-   /// locations for instructions without actually
-   /// emitting debug info for them (e.g., when -Rpass
-   /// is used).
-  DebugDirectivesOnly, /// Emit only debug directives with the line numbers 
data
-  DebugLineTablesOnly, /// Emit only debug info necessary for generating
-   /// line number tables (-gline-tables-only).
-  LimitedDebugInfo,/// Limit generated debug info to reduce size
-   /// (-fno-standalone-debug). This emits
-   /// forward decls for types that could be
-   /// replaced with forward decls in the source
-   /// code. For dynamic C++ classes type info
-   /// is only emitted into the module that
-   /// contains the classe's vtable.
-  FullDebugInfo/// Generate complete debug info.
+  /// Don't generate debug info.
+  NoDebugInfo,
+
+  /// Emit location information but do not generate debug info in the output.
+  /// This is useful in cases where the backend wants to track source
+  /// locations for instructions without actually emitting debug info for them
+  /// (e.g., when -Rpass is used).
+  LocTrackingOnly,
+
+  /// Emit only debug directives with the line numbers data
+  DebugDirectivesOnly,
+
+  /// Emit only debug info necessary for generating line number tables
+  /// (-gline-tables-only).
+  DebugLineTablesOnly,
+
+  /// Limit generated debug info to reduce size (-fno-standalone-debug). This
+  /// emits forward decls for types that could be replaced with forward decls 
in
+  /// the source code. For dynamic C++ classes type info is only emitted into
+  /// the module that contains the classe's vtable.
+  LimitedDebugInfo,
+
+  /// Generate complete debug info.
+  FullDebugInfo
 };
 
 } // end namespace codegenoptions



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


[PATCH] D70340: Add a key method to Sema to optimize debug info size

2019-11-16 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: dblaikie, hans, thakis, rsmith.
Herald added a subscriber: aprantl.
Herald added a project: clang.

DONOTSUBMIT, this patch is just for the purpose of discussion.

It turns out that the debug info describing the Sema class is an
appreciable percentage of the total object file size of objects in Sema.
By adding a key function, clang is able to optimize the debug info size
by emitting a forward declaration in TUs that do not define the key
function.

On Windows, with clang-cl, these are the total object file sizes before
and after this change when compiling with optimizations and debug info:

  before: 335,012 KB
  after:  278,116 KB
  delta:  -56,896 KB
  percent: -17.0%

The effect on link time was negligible, despite having ~56MB less input.

On Linux, with clang, these are the same sizes using DWARF -g and
optimizations:

  before: 603,756 KB
  after:  515,340 KB
  delta:  -88,416 KB
  percent: -14.6%

I didn't use type units, DWARF-5, fission, or any other special flags.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70340

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp


Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -189,6 +189,9 @@
   SemaPPCallbackHandler->set(*this);
 }
 
+// Anchor Sema's type info to this TU.
+void Sema::anchor() {}
+
 void Sema::addImplicitTypedef(StringRef Name, QualType T) {
   DeclarationName DN = (Name);
   if (IdResolver.begin(DN) == IdResolver.end())
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -329,6 +329,7 @@
 
 /// Sema - This implements semantic analysis and AST building for C.
 class Sema {
+  virtual void anchor();
   Sema(const Sema &) = delete;
   void operator=(const Sema &) = delete;
 


Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -189,6 +189,9 @@
   SemaPPCallbackHandler->set(*this);
 }
 
+// Anchor Sema's type info to this TU.
+void Sema::anchor() {}
+
 void Sema::addImplicitTypedef(StringRef Name, QualType T) {
   DeclarationName DN = (Name);
   if (IdResolver.begin(DN) == IdResolver.end())
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -329,6 +329,7 @@
 
 /// Sema - This implements semantic analysis and AST building for C.
 class Sema {
+  virtual void anchor();
   Sema(const Sema &) = delete;
   void operator=(const Sema &) = delete;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 47bd7c5 - Revert "[clang-tidy] Give readability-redundant-string-init a customizable list of string types to fix"

2019-11-16 Thread Mitchell Balan via cfe-commits

Author: Mitchell Balan
Date: 2019-11-15T16:46:58-05:00
New Revision: 47bd7c57e556e3a4db51566d59c2d796ce898c8f

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

LOG: Revert "[clang-tidy] Give readability-redundant-string-init a customizable 
list of string types to fix"

This reverts commit 96fbc32cb9ea23b1e7e3ff6906ec3ccda9500982.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.h
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
index 6bf0edb7231f..a140e17fabfd 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -8,7 +8,6 @@
 
 #include "RedundantStringInitCheck.h"
 #include "../utils/Matchers.h"
-#include "../utils/OptionsUtils.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 
 using namespace clang::ast_matchers;
@@ -18,43 +17,19 @@ namespace clang {
 namespace tidy {
 namespace readability {
 
-const char DefaultStringNames[] = "::std::basic_string";
-
-RedundantStringInitCheck::RedundantStringInitCheck(StringRef Name,
-   ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context),
-  StringNames(utils::options::parseStringList(
-  Options.get("StringNames", DefaultStringNames))) {}
-
-void RedundantStringInitCheck::storeOptions(ClangTidyOptions::OptionMap ) 
{
-  Options.store(Opts, "StringNames", DefaultStringNames);
-}
-
 void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
-  const auto hasStringTypeName = hasAnyName(
-  SmallVector(StringNames.begin(), StringNames.end()));
-
-  // Version of StringNames with namespaces removed
-  std::vector stringNamesNoNamespace;
-  for (const std::string  : StringNames) {
-std::string::size_type colonPos = name.rfind(':');
-stringNamesNoNamespace.push_back(
-name.substr(colonPos == std::string::npos ? 0 : colonPos + 1));
-  }
-  const auto hasStringCtorName = hasAnyName(SmallVector(
-  stringNamesNoNamespace.begin(), stringNamesNoNamespace.end()));
 
   // Match string constructor.
-  const auto StringConstructorExpr = expr(
-  anyOf(cxxConstructExpr(argumentCountIs(1),
- hasDeclaration(cxxMethodDecl(hasStringCtorName))),
-// If present, the second argument is the alloc object which must
-// not be present explicitly.
-cxxConstructExpr(argumentCountIs(2),
- hasDeclaration(cxxMethodDecl(hasStringCtorName)),
- hasArgument(1, cxxDefaultArgExpr();
+  const auto StringConstructorExpr = expr(anyOf(
+  cxxConstructExpr(argumentCountIs(1),
+   hasDeclaration(cxxMethodDecl(hasName("basic_string",
+  // If present, the second argument is the alloc object which must not
+  // be present explicitly.
+  cxxConstructExpr(argumentCountIs(2),
+   hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
+   hasArgument(1, cxxDefaultArgExpr();
 
   // Match a string constructor expression with an empty string literal.
   const auto EmptyStringCtorExpr = cxxConstructExpr(
@@ -73,7 +48,7 @@ void RedundantStringInitCheck::registerMatchers(MatchFinder 
*Finder) {
   namedDecl(
   varDecl(
   hasType(hasUnqualifiedDesugaredType(recordType(
-  hasDeclaration(cxxRecordDecl(hasStringTypeName),
+  hasDeclaration(cxxRecordDecl(hasName("basic_string")),
   hasInitializer(expr(ignoringImplicit(anyOf(
   EmptyStringCtorExpr, EmptyStringCtorExprWithTemporaries)
   .bind("vardecl"),

diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.h 
b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.h
index 9ab009aea84d..b1f551ed5607 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.h
@@ -10,8 +10,6 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANT_STRING_INIT_H
 
 #include "../ClangTidyCheck.h"
-#include 
-#include 
 
 namespace clang {
 namespace tidy {
@@ -20,13 +18,10 @@ namespace readability {
 

[PATCH] D6920: [clang-format] Add SpaceBeforeBrackets

2019-11-16 Thread Matthäus G. Chajdas via Phabricator via cfe-commits
Anteru added a comment.

Thanks a lot!


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

https://reviews.llvm.org/D6920



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


[PATCH] D70280: Remove Support/Options.h, it is unused

2019-11-16 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG631be5c0d411: Remove Support/Options.h, it is unused 
(authored by rnk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70280

Files:
  clang/tools/clang-scan-deps/ClangScanDeps.cpp
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/Support/Options.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/DebugCounter.cpp
  llvm/lib/Support/Options.cpp
  llvm/lib/Support/Signals.cpp
  llvm/lib/Transforms/Scalar/Scalarizer.cpp

Index: llvm/lib/Transforms/Scalar/Scalarizer.cpp
===
--- llvm/lib/Transforms/Scalar/Scalarizer.cpp
+++ llvm/lib/Transforms/Scalar/Scalarizer.cpp
@@ -38,8 +38,8 @@
 #include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MathExtras.h"
-#include "llvm/Support/Options.h"
 #include "llvm/Transforms/Scalar.h"
 #include 
 #include 
Index: llvm/lib/Support/Signals.cpp
===
--- llvm/lib/Support/Signals.cpp
+++ llvm/lib/Support/Signals.cpp
@@ -15,19 +15,19 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Config/llvm-config.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Format.h"
-#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/FormatAdapters.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Mutex.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/StringSaver.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/Options.h"
 #include 
 
 //===--===//
Index: llvm/lib/Support/Options.cpp
===
--- llvm/lib/Support/Options.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-//===- llvm/Support/Options.cpp - Debug options support -*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This file implements the helper objects for defining debug options using the
-// new API built on cl::opt, but not requiring the use of static globals.
-//
-//===--===//
-
-#include "llvm/Support/Options.h"
-#include "llvm/Support/ManagedStatic.h"
-
-using namespace llvm;
-
-OptionRegistry::~OptionRegistry() {
-  for (auto IT = Options.begin(); IT != Options.end(); ++IT)
-delete IT->second;
-}
-
-void OptionRegistry::addOption(void *Key, cl::Option *O) {
-  assert(Options.find(Key) == Options.end() &&
- "Argument with this key already registerd");
-  Options.insert(std::make_pair(Key, O));
-}
-
-static ManagedStatic OR;
-
-OptionRegistry ::instance() { return *OR; }
Index: llvm/lib/Support/DebugCounter.cpp
===
--- llvm/lib/Support/DebugCounter.cpp
+++ llvm/lib/Support/DebugCounter.cpp
@@ -2,7 +2,6 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Format.h"
 #include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/Options.h"
 
 using namespace llvm;
 
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -116,7 +116,6 @@
   MD5.cpp
   NativeFormatting.cpp
   Optional.cpp
-  Options.cpp
   Parallel.cpp
   PluginLoader.cpp
   PrettyStackTrace.cpp
Index: llvm/include/llvm/Support/Options.h
===
--- llvm/include/llvm/Support/Options.h
+++ /dev/null
@@ -1,119 +0,0 @@
-//===- llvm/Support/Options.h - Debug options support ---*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-/// \file
-/// This file declares helper objects for defining debug options that can be
-/// configured via the command line. The new API currently builds on the cl::opt
-/// API, but does not require the use of static globals.
-///
-/// With this API options are registered during initialization. For passes, this
-/// happens during pass initialization. 

[PATCH] D69548: Give clang-tidy readability-redundant-string-init a customizable list of string types to fix

2019-11-16 Thread Mitchell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG96fbc32cb9ea: [clang-tidy] Give 
readability-redundant-string-init a customizable list of… (authored by 
mitchell-stellar).

Changed prior to commit:
  https://reviews.llvm.org/D69548?vs=228769=229637#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69548

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
  clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
@@ -1,4 +1,9 @@
-// RUN: %check_clang_tidy %s readability-redundant-string-init %t
+// RUN: %check_clang_tidy -std=c++11,c++14 %s readability-redundant-string-init %t \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: readability-redundant-string-init.StringNames, \
+// RUN:   value: "::std::basic_string;our::TestString"}] \
+// RUN: }"
+// FIXME: Fix the checker to work in C++17 mode.
 
 namespace std {
 template 
@@ -143,3 +148,82 @@
 void Param3(std::string param = "") {}
 void Param4(STRING param = "") {}
 
+namespace our {
+struct TestString {
+  TestString();
+  TestString(const TestString &);
+  TestString(const char *);
+  ~TestString();
+};
+}
+
+void ourTestStringTests() {
+  our::TestString a = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:19: warning: redundant string initialization
+  // CHECK-FIXES: our::TestString a;
+  our::TestString b("");
+  // CHECK-MESSAGES: [[@LINE-1]]:19: warning: redundant string initialization
+  // CHECK-FIXES: our::TestString b;
+  our::TestString c = R"()";
+  // CHECK-MESSAGES: [[@LINE-1]]:19: warning: redundant string initialization
+  // CHECK-FIXES: our::TestString c;
+  our::TestString d(R"()");
+  // CHECK-MESSAGES: [[@LINE-1]]:19: warning: redundant string initialization
+  // CHECK-FIXES: our::TestString d;
+
+  our::TestString u = "u";
+  our::TestString w("w");
+  our::TestString x = R"(x)";
+  our::TestString y(R"(y)");
+  our::TestString z;
+}
+
+namespace their {
+using TestString = our::TestString;
+}
+
+// their::TestString is the same type so should warn / fix
+void theirTestStringTests() {
+  their::TestString a = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: redundant string initialization
+  // CHECK-FIXES: their::TestString a;
+  their::TestString b("");
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: redundant string initialization
+  // CHECK-FIXES: their::TestString b;
+}
+
+namespace other {
+// Identical declarations to above but different type
+struct TestString {
+  TestString();
+  TestString(const TestString &);
+  TestString(const char *);
+  ~TestString();
+};
+
+// Identical declarations to above but different type
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator>
+struct basic_string {
+  basic_string();
+  basic_string(const basic_string &);
+  basic_string(const C *, const A  = A());
+  ~basic_string();
+};
+typedef basic_string string;
+typedef basic_string wstring;
+}
+
+// other::TestString, other::string, other::wstring are unrelated to the types
+// being checked. No warnings / fixes should be produced for these types.
+void otherTestStringTests() {
+  other::TestString a = "";
+  other::TestString b("");
+  other::string c = "";
+  other::string d("");
+  other::wstring e = L"";
+  other::wstring f(L"");
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
@@ -5,7 +5,8 @@
 
 Finds unnecessary string initializations.
 
-Examples:
+Examples
+
 
 .. code-block:: c++
 
@@ -17,3 +18,15 @@
 
   std::string a;
   std::string b;
+
+Options
+---
+
+.. option:: StringNames
+
+Default is `::std::basic_string`.
+
+Semicolon-delimited list of class names to apply this check to.
+By default `::std::basic_string` applies to ``std::string`` and
+``std::wstring``. Set to e.g. `::std::basic_string;llvm::StringRef;QString`
+to perform this check on custom classes.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ 

[clang-tools-extra] 96fbc32 - [clang-tidy] Give readability-redundant-string-init a customizable list of string types to fix

2019-11-16 Thread Mitchell Balan via cfe-commits

Author: Mitchell Balan
Date: 2019-11-15T16:42:54-05:00
New Revision: 96fbc32cb9ea23b1e7e3ff6906ec3ccda9500982

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

LOG: [clang-tidy] Give readability-redundant-string-init a customizable list of 
string types to fix

Summary:
This patch adds a feature requested in https://reviews.llvm.org/D69238 to 
enable `readability-redundant-string-init` to take a list of strings to apply 
the fix to rather than hard-coding `basic_string`. It adds a `StringNames` 
option of semicolon-delimited names of string classes to which to apply this 
fix. Tests ensure this works with test class out::TestString as well as 
std::string and std::wstring as before. It should be applicable to 
llvm::StringRef, QString, etc.

Reviewers: MyDeveloperDay, aaron.ballman, hokein, alexfh, JonasToth, gribozavr2

Patch by: poelmanc

Subscribers: gribozavr2, xazax.hun, Eugene.Zelenko, cfe-commits

Tags: #clang-tools-extra, #clang

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.h
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
index a140e17fabfd..6bf0edb7231f 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -8,6 +8,7 @@
 
 #include "RedundantStringInitCheck.h"
 #include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 
 using namespace clang::ast_matchers;
@@ -17,19 +18,43 @@ namespace clang {
 namespace tidy {
 namespace readability {
 
+const char DefaultStringNames[] = "::std::basic_string";
+
+RedundantStringInitCheck::RedundantStringInitCheck(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  StringNames(utils::options::parseStringList(
+  Options.get("StringNames", DefaultStringNames))) {}
+
+void RedundantStringInitCheck::storeOptions(ClangTidyOptions::OptionMap ) 
{
+  Options.store(Opts, "StringNames", DefaultStringNames);
+}
+
 void RedundantStringInitCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
 return;
+  const auto hasStringTypeName = hasAnyName(
+  SmallVector(StringNames.begin(), StringNames.end()));
+
+  // Version of StringNames with namespaces removed
+  std::vector stringNamesNoNamespace;
+  for (const std::string  : StringNames) {
+std::string::size_type colonPos = name.rfind(':');
+stringNamesNoNamespace.push_back(
+name.substr(colonPos == std::string::npos ? 0 : colonPos + 1));
+  }
+  const auto hasStringCtorName = hasAnyName(SmallVector(
+  stringNamesNoNamespace.begin(), stringNamesNoNamespace.end()));
 
   // Match string constructor.
-  const auto StringConstructorExpr = expr(anyOf(
-  cxxConstructExpr(argumentCountIs(1),
-   hasDeclaration(cxxMethodDecl(hasName("basic_string",
-  // If present, the second argument is the alloc object which must not
-  // be present explicitly.
-  cxxConstructExpr(argumentCountIs(2),
-   hasDeclaration(cxxMethodDecl(hasName("basic_string"))),
-   hasArgument(1, cxxDefaultArgExpr();
+  const auto StringConstructorExpr = expr(
+  anyOf(cxxConstructExpr(argumentCountIs(1),
+ hasDeclaration(cxxMethodDecl(hasStringCtorName))),
+// If present, the second argument is the alloc object which must
+// not be present explicitly.
+cxxConstructExpr(argumentCountIs(2),
+ hasDeclaration(cxxMethodDecl(hasStringCtorName)),
+ hasArgument(1, cxxDefaultArgExpr();
 
   // Match a string constructor expression with an empty string literal.
   const auto EmptyStringCtorExpr = cxxConstructExpr(
@@ -48,7 +73,7 @@ void RedundantStringInitCheck::registerMatchers(MatchFinder 
*Finder) {
   namedDecl(
   varDecl(
   hasType(hasUnqualifiedDesugaredType(recordType(
-  hasDeclaration(cxxRecordDecl(hasName("basic_string")),
+  hasDeclaration(cxxRecordDecl(hasStringTypeName),
   hasInitializer(expr(ignoringImplicit(anyOf(
   

[PATCH] D70157: Align branches within 32-Byte boundary

2019-11-16 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Overall comment: this whole change needs more comments, everywhere. Both for 
the added functions, and for the test cases. There is almost no description of 
what's happening, and it could really use it.




Comment at: llvm/lib/MC/MCAssembler.cpp:1041
+
+void MCAssembler::moveSymbol(const MCFragment *Src, MCFragment *Dst) const {
+  if (!(Src && Dst && Dst->getKind() == MCFragment::FT_MachineDependent))

I think this is broken -- moving symbols around like this risks causing 
evaluations of symbol offsets which may have already happened to be wrong. 

Also it's ugly, and I can't tell why it's necessary, because there's no 
comments.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:418
+
+bool X86AsmBackend::isReturn(const MCInst ) const {
+  unsigned Opcode = MI.getOpcode();

This set of functions down to isIndirectBranch() seems unnecessary. Pushing one 
line
  const MCInstrDesc  = MCII.get(Inst.getOpcode());
into needAlign(const MCInst ), and then just using InstDesc.isReturn() 
etc. would be fine.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:463
+  const X86::SecondMFInstKind BranchKind = classifySecond(Jcc, MCII);
+  return X86::isMacroFused(CmpKind,BranchKind);
+  llvm_unreachable("unknown fusion type");

please run something like "git clang-format HEAD~1" to re-format your patch.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:467
+
+char X86AsmBackend::choosePrefixValue(const MCInst ) const {
+  for (const auto  : MI) {

Comment on why this is doing what it's doing?



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:532
+
+bool X86AsmBackend::needAlignBranch() const {
+  return AlignBoundarySize != 0 &&

Confusing name, and doesn't need to be a separate function than needAlign(const 
MCAssembler &, MCSection *). Just merge it into that.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:537
+
+bool X86AsmBackend::needAlignJcc() const {
+  return AlignBoundarySize != 0 &&

These functions are only used in one place, and it doesn't make it more 
readable to split them off. Just merge them into needAlign(const MCInst ) 
or alignBranchesBegin as appropriate.

But also -- AlignBoundarySize shouldn't even need to be checked here, since 
it's already be checked in needAlign(const MCAssembler &, MCSection *), which 
is always called first.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:567
+
+bool X86AsmBackend::needAlign(const MCAssembler ,
+  MCSection *Sec) const {

Doesn't need to have the same name as the next needAlign, clearer if these two 
overloads are given different names.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp:731-732
+char Prefix) const {
+  if (!(Prefix == 0x2e || Prefix == 0x36 || Prefix == 0x3e || Prefix == 0x26 ||
+Prefix == 0x64 || Prefix == 0x65))
+return false;

Why?



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h:106
+  // The classification for the first instruction in macro fusion.
+  enum class FirstMFInstKind {
+// TEST

"MF" is not a readable abbreviation here -- spell out "MacroFusion" instead. It 
was OK locally in the "X86MacroFusion.cpp" file, as the filename gave you a 
hint, but not here, where you have no such hint.



Comment at: llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h:134
+  /// macro-fusion.
+  inline FirstMFInstKind classifyFirstOpcode(unsigned Opcode) {
+switch (Opcode) {

This function is also named poorly, after being moved to this more-generic 
location. "Classify" doesn't tell me anything about this being related to 
macro-fusion.


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

https://reviews.llvm.org/D70157



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


[PATCH] D70165: clang-tidy: modernize-use-override new option AllowOverrideAndFinal

2019-11-16 Thread Mitchell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG50e99563fb04: [clang-tidy] modernize-use-override new option 
AllowOverrideAndFinal (authored by mitchell-stellar).

Changed prior to commit:
  https://reviews.llvm.org/D70165?vs=229012=229632#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70165

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s 
readability-redundant-string-init %t
-// FIXME: Fix the checker to work in C++17 mode.
+// RUN: %check_clang_tidy %s readability-redundant-string-init %t
 
 namespace std {
 template 
@@ -131,6 +130,11 @@
   // CHECK-FIXES: std::string a, b, c;
 
   std::string d = "u", e = "u", f = "u";
+
+  std::string g = "u", h = "", i = "uuu", j = "", k;
+  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: redundant string initialization
+  // CHECK-MESSAGES: [[@LINE-2]]:43: warning: redundant string initialization
+  // CHECK-FIXES: std::string g = "u", h, i = "uuu", j, k;
 }
 
 // These cases should not generate warnings.
Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s 
readability-redundant-string-init %t
-// FIXME: Fix the checker to work in C++17 mode.
+// RUN: %check_clang_tidy %s readability-redundant-string-init %t
 
 namespace std {
 template 
Index: clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -46,23 +46,23 @@
   // string bar("");
   Finder->addMatcher(
   namedDecl(
-  varDecl(hasType(hasUnqualifiedDesugaredType(recordType(
-  
hasDeclaration(cxxRecordDecl(hasName("basic_string")),
-  hasInitializer(expr(ignoringImplicit(anyOf(
-  EmptyStringCtorExpr,
-  EmptyStringCtorExprWithTemporaries)))
- .bind("expr"))),
-  unless(parmVarDecl()))
-  .bind("decl"),
+  varDecl(
+  hasType(hasUnqualifiedDesugaredType(recordType(
+  hasDeclaration(cxxRecordDecl(hasName("basic_string")),
+  hasInitializer(expr(ignoringImplicit(anyOf(
+  EmptyStringCtorExpr, EmptyStringCtorExprWithTemporaries)
+  .bind("vardecl"),
+  unless(parmVarDecl())),
   this);
 }
 
 void RedundantStringInitCheck::check(const MatchFinder::MatchResult ) {
-  const auto *CtorExpr = Result.Nodes.getNodeAs("expr");
-  const auto *Decl = Result.Nodes.getNodeAs("decl");
-  diag(CtorExpr->getExprLoc(), "redundant string initialization")
-  << FixItHint::CreateReplacement(CtorExpr->getSourceRange(),
-  Decl->getName());
+  const auto *VDecl = Result.Nodes.getNodeAs("vardecl");
+  // VarDecl's getSourceRange() spans 'string foo = ""' or 'string bar("")'.
+  // So start at getLocation() to span just 'foo = ""' or 'bar("")'.
+  SourceRange ReplaceRange(VDecl->getLocation(), VDecl->getEndLoc());
+  diag(VDecl->getLocation(), "redundant string initialization")
+  << FixItHint::CreateReplacement(ReplaceRange, VDecl->getName());
 }
 
 } // namespace readability


Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s readability-redundant-string-init %t
-// FIXME: Fix the checker to work in C++17 mode.
+// RUN: %check_clang_tidy %s readability-redundant-string-init %t
 
 namespace std {
 template 
@@ -131,6 +130,11 @@
   // CHECK-FIXES: std::string a, b, c;
 
   std::string 

[clang] 631be5c - Remove Support/Options.h, it is unused

2019-11-16 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2019-11-15T13:32:52-08:00
New Revision: 631be5c0d41161057d02fe08a7aeb4fbde1a91d6

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

LOG: Remove Support/Options.h, it is unused

It was added in 2014 in 732e0aa9fb84f1 with one use in Scalarizer.cpp.
That one use was then removed when porting to the new pass manager in
2018 in b6f76002d9158628e78.

While the RFC and the desire to get off of static initializers for
cl::opt all still stand, this code is now dead, and I think we should
delete this code until someone is ready to do the migration.

There were many clients of CommandLine.h that were it transitively
through LLVMContext.h, so I cleaned that up in 4c1a1d3cf97e1ede466.

Reviewers: beanz

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

Added: 


Modified: 
clang/tools/clang-scan-deps/ClangScanDeps.cpp
llvm/include/llvm/IR/LLVMContext.h
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/DebugCounter.cpp
llvm/lib/Support/Signals.cpp
llvm/lib/Transforms/Scalar/Scalarizer.cpp

Removed: 
llvm/include/llvm/Support/Options.h
llvm/lib/Support/Options.cpp



diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 3d3c76c7714a..bd463cbdeee9 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -12,8 +12,8 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/InitLLVM.h"
-#include "llvm/Support/Options.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/Threading.h"

diff  --git a/llvm/include/llvm/IR/LLVMContext.h 
b/llvm/include/llvm/IR/LLVMContext.h
index ea272740ba9d..39d19b7cffd9 100644
--- a/llvm/include/llvm/IR/LLVMContext.h
+++ b/llvm/include/llvm/IR/LLVMContext.h
@@ -17,7 +17,6 @@
 #include "llvm-c/Types.h"
 #include "llvm/IR/DiagnosticHandler.h"
 #include "llvm/Support/CBindingWrapping.h"
-#include "llvm/Support/Options.h"
 #include 
 #include 
 #include 
@@ -288,14 +287,6 @@ class LLVMContext {
   void emitError(const Instruction *I, const Twine );
   void emitError(const Twine );
 
-  /// Query for a debug option's value.
-  ///
-  /// This function returns typed data populated from command line parsing.
-  template 
-  ValT getOption() const {
-return OptionRegistry::instance().template get();
-  }
-
   /// Access the object which can disable optional passes and individual
   /// optimizations at compile time.
   OptPassGate () const;

diff  --git a/llvm/include/llvm/Support/Options.h 
b/llvm/include/llvm/Support/Options.h
deleted file mode 100644
index d02ef85a75bf..
--- a/llvm/include/llvm/Support/Options.h
+++ /dev/null
@@ -1,119 +0,0 @@
-//===- llvm/Support/Options.h - Debug options support ---*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-/// \file
-/// This file declares helper objects for defining debug options that can be
-/// configured via the command line. The new API currently builds on the 
cl::opt
-/// API, but does not require the use of static globals.
-///
-/// With this API options are registered during initialization. For passes, 
this
-/// happens during pass initialization. Passes with options will call a static
-/// registerOptions method during initialization that registers options with 
the
-/// OptionRegistry. An example implementation of registerOptions is:
-///
-/// static void registerOptions() {
-///   OptionRegistry::registerOption(
-///   "scalarize-load-store",
-///   "Allow the scalarizer pass to scalarize loads and store", false);
-/// }
-///
-/// When reading data for options the interface is via the LLVMContext. Option
-/// data for passes should be read from the context during doInitialization. An
-/// example of reading the above option would be:
-///
-/// ScalarizeLoadStore =
-///   M.getContext().getOption();
-///
-//===--===//
-
-#ifndef LLVM_SUPPORT_OPTIONS_H
-#define LLVM_SUPPORT_OPTIONS_H
-
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/Support/CommandLine.h"
-
-namespace llvm {
-
-namespace detail {
-
-// Options are keyed of the unique address of a static character synthesized
-// based on template arguments.
-template  class OptionKey {
-public:
- 

[clang] caf3166 - Revert "re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial"

2019-11-16 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2019-11-15T16:21:17-05:00
New Revision: caf3166d40ffbb0d61b29f423318ce6cfbcf4a9f

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

LOG: Revert "re-land [DebugInfo] Add debug location to stubs generated by 
CGDeclCXX and mark them as artificial"

This reverts commit 9c1baa23526c6d7d06eafefbf82d73bfe9bb3aaf.

Added: 


Modified: 
clang/include/clang/AST/GlobalDecl.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
clang/test/CodeGenCXX/debug-info-line.cpp

Removed: 
clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
clang/test/CodeGenCXX/debug-info-destroy-helper.cpp



diff  --git a/clang/include/clang/AST/GlobalDecl.h 
b/clang/include/clang/AST/GlobalDecl.h
index ab14d9678812..145e961a23a3 100644
--- a/clang/include/clang/AST/GlobalDecl.h
+++ b/clang/include/clang/AST/GlobalDecl.h
@@ -31,7 +31,6 @@ enum class DynamicInitKind : unsigned {
   NoStub = 0,
   Initializer,
   AtExit,
-  GlobalArrayDestructor
 };
 
 /// GlobalDecl - represents a global declaration. This can either be a

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 41459018a3bf..75c4b2ae2339 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1944,8 +1944,7 @@ StringRef CGDebugInfo::getDynamicInitializerName(const 
VarDecl *VD,
  llvm::Function *InitFn) {
   // If we're not emitting codeview, use the mangled name. For Itanium, this is
   // arbitrary.
-  if (!CGM.getCodeGenOpts().EmitCodeView ||
-  StubKind == DynamicInitKind::GlobalArrayDestructor)
+  if (!CGM.getCodeGenOpts().EmitCodeView)
 return InitFn->getName();
 
   // Print the normal qualified name for the variable, then break off the last
@@ -1970,7 +1969,6 @@ StringRef CGDebugInfo::getDynamicInitializerName(const 
VarDecl *VD,
 
   switch (StubKind) {
   case DynamicInitKind::NoStub:
-  case DynamicInitKind::GlobalArrayDestructor:
 llvm_unreachable("not an initializer");
   case DynamicInitKind::Initializer:
 OS << "`dynamic initializer for '";
@@ -3646,8 +3644,7 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, 
SourceLocation Loc,
   if (Name.startswith("\01"))
 Name = Name.substr(1);
 
-  if (!HasDecl || D->isImplicit() || D->hasAttr() ||
-  (isa(D) && GD.getDynamicInitKind() != DynamicInitKind::NoStub)) 
{
+  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
 Flags |= llvm::DINode::FlagArtificial;
 // Artificial functions should not silently reuse CurLoc.
 CurLoc = SourceLocation();

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 95bd00010395..5b172a3480be 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -244,8 +244,6 @@ llvm::Function *CodeGenFunction::createAtExitStub(const 
VarDecl ,
 
   CGF.StartFunction(GlobalDecl(, DynamicInitKind::AtExit),
 CGM.getContext().VoidTy, fn, FI, FunctionArgList());
-  // Emit an artificial location for this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(CGF);
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
 
@@ -646,9 +644,8 @@ void 
CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 
   StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
 getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
-FunctionArgList());
-  // Emit an artificial location for this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+FunctionArgList(), D->getLocation(),
+D->getInit()->getExprLoc());
 
   // Use guarded initialization if the global variable is weak. This
   // occurs for, e.g., instantiated static data members and
@@ -773,10 +770,7 @@ llvm::Function *CodeGenFunction::generateDestroyHelper(
 
   CurEHLocation = VD->getBeginLoc();
 
-  StartFunction(GlobalDecl(VD, DynamicInitKind::GlobalArrayDestructor),
-getContext().VoidTy, fn, FI, args);
-  // Emit an artificial location for this function.
-  auto AL = ApplyDebugLocation::CreateArtificial(*this);
+  StartFunction(VD, getContext().VoidTy, fn, FI, args);
 
   emitDestroy(addr, type, destroyer, useEHCleanupForArray);
 

diff  --git a/clang/test/CodeGenCXX/debug-info-atexit-stub.cpp 
b/clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
deleted file mode 100644
index 8ff2ca5d2f2c..
--- a/clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-windows-msvc -gcodeview 
-debug-info-kind=limited -o - | FileCheck %s
-
-struct a {
-  ~a();
-};
-template  struct c : a 

[PATCH] D70256: [FPEnv] clang support for constrained FP builtins

2019-11-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:357
+
+  if (ConstrainedIntrinsicID != Intrinsic::not_intrinsic &&
+  CGF.Builder.getIsFPConstrained()) {

I don't see any situation where `not_intrinsic` is passed in here; why all 
these checks?



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2302
+  return RValue::get(Builder.CreateCall(F, {Base, Exponent}));
+}
   }

What can this not use the standard path?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70256



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


[clang-tools-extra] 50e9956 - [clang-tidy] modernize-use-override new option AllowOverrideAndFinal

2019-11-16 Thread Mitchell Balan via cfe-commits

Author: Mitchell Balan
Date: 2019-11-15T16:16:07-05:00
New Revision: 50e99563fb0459f5160572eef3c4e6062b8ad3f2

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

LOG: [clang-tidy] modernize-use-override new option AllowOverrideAndFinal

Summary:
In addition to adding `override` wherever possible, clang-tidy's 
`modernize-use-override` nicely removes `virtual` when `override` or `final` is 
specified, and further removes override when final is specified. While this is 
great default behavior, when code needs to be compiled with gcc at high warning 
levels that include `gcc -Wsuggest-override` or `gcc -Werror=suggest-override`, 
clang-tidy's removal of the redundant `override` keyword causes gcc to emit a 
warning or error. This discrepancy / conflict has been noted by others 
including a comment on Stack Overflow and by Mozilla's Firefox developers.

This patch adds an AllowOverrideAndFinal option defaulting to 0 - thus 
preserving current behavior - that when enabled allows both `override` and 
`final` to co-exist, while still fixing all other issues.

The patch includes a test file verifying all combinations of 
virtual/override/final, and mentions the new option in the release notes.

Reviewers: alexfh, djasper, JonasToth

Patch by: poelmanc

Subscribers: JonasToth, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
index 9a9a3830201b..a140e17fabfd 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -46,23 +46,23 @@ void RedundantStringInitCheck::registerMatchers(MatchFinder 
*Finder) {
   // string bar("");
   Finder->addMatcher(
   namedDecl(
-  varDecl(hasType(hasUnqualifiedDesugaredType(recordType(
-  
hasDeclaration(cxxRecordDecl(hasName("basic_string")),
-  hasInitializer(expr(ignoringImplicit(anyOf(
-  EmptyStringCtorExpr,
-  EmptyStringCtorExprWithTemporaries)))
- .bind("expr"))),
-  unless(parmVarDecl()))
-  .bind("decl"),
+  varDecl(
+  hasType(hasUnqualifiedDesugaredType(recordType(
+  hasDeclaration(cxxRecordDecl(hasName("basic_string")),
+  hasInitializer(expr(ignoringImplicit(anyOf(
+  EmptyStringCtorExpr, EmptyStringCtorExprWithTemporaries)
+  .bind("vardecl"),
+  unless(parmVarDecl())),
   this);
 }
 
 void RedundantStringInitCheck::check(const MatchFinder::MatchResult ) {
-  const auto *CtorExpr = Result.Nodes.getNodeAs("expr");
-  const auto *Decl = Result.Nodes.getNodeAs("decl");
-  diag(CtorExpr->getExprLoc(), "redundant string initialization")
-  << FixItHint::CreateReplacement(CtorExpr->getSourceRange(),
-  Decl->getName());
+  const auto *VDecl = Result.Nodes.getNodeAs("vardecl");
+  // VarDecl's getSourceRange() spans 'string foo = ""' or 'string bar("")'.
+  // So start at getLocation() to span just 'foo = ""' or 'bar("")'.
+  SourceRange ReplaceRange(VDecl->getLocation(), VDecl->getEndLoc());
+  diag(VDecl->getLocation(), "redundant string initialization")
+  << FixItHint::CreateReplacement(ReplaceRange, VDecl->getName());
 }
 
 } // namespace readability

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp
index fe05845db663..0299519a508e 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init-msvc.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s 
readability-redundant-string-init %t
-// FIXME: Fix the checker to work in C++17 mode.
+// RUN: %check_clang_tidy %s readability-redundant-string-init %t
 
 namespace std {
 template 

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
index b88e4a0f4d62..76d1fe97e1b9 100644
--- 

[PATCH] D70285: Wrap C APIs with pragmas enforcing -Werror=strict-prototypes

2019-11-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith updated this revision to Diff 229624.
dexonsmith marked an inline comment as done.
dexonsmith added a comment.

s/C_STRING_PROTOTYPES_/C_STRICT_PROTOTYPES_/ to fix some typos.


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

https://reviews.llvm.org/D70285

Files:
  clang/include/clang-c/BuildSystem.h
  clang/include/clang-c/CXCompilationDatabase.h
  clang/include/clang-c/CXErrorCode.h
  clang/include/clang-c/CXString.h
  clang/include/clang-c/Documentation.h
  clang/include/clang-c/ExternC.h
  clang/include/clang-c/FatalErrorHandler.h
  clang/include/clang-c/Index.h
  clang/include/clang-c/Platform.h
  llvm/include/llvm-c/Analysis.h
  llvm/include/llvm-c/BitReader.h
  llvm/include/llvm-c/BitWriter.h
  llvm/include/llvm-c/Comdat.h
  llvm/include/llvm-c/Core.h
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm-c/Disassembler.h
  llvm/include/llvm-c/Error.h
  llvm/include/llvm-c/ErrorHandling.h
  llvm/include/llvm-c/ExecutionEngine.h
  llvm/include/llvm-c/ExternC.h
  llvm/include/llvm-c/IRReader.h
  llvm/include/llvm-c/Initialization.h
  llvm/include/llvm-c/LinkTimeOptimizer.h
  llvm/include/llvm-c/Linker.h
  llvm/include/llvm-c/Object.h
  llvm/include/llvm-c/OrcBindings.h
  llvm/include/llvm-c/Remarks.h
  llvm/include/llvm-c/Support.h
  llvm/include/llvm-c/Target.h
  llvm/include/llvm-c/TargetMachine.h
  llvm/include/llvm-c/Transforms/AggressiveInstCombine.h
  llvm/include/llvm-c/Transforms/Coroutines.h
  llvm/include/llvm-c/Transforms/IPO.h
  llvm/include/llvm-c/Transforms/InstCombine.h
  llvm/include/llvm-c/Transforms/PassManagerBuilder.h
  llvm/include/llvm-c/Transforms/Scalar.h
  llvm/include/llvm-c/Transforms/Utils.h
  llvm/include/llvm-c/Transforms/Vectorize.h
  llvm/include/llvm-c/Types.h
  llvm/include/llvm-c/lto.h

Index: llvm/include/llvm-c/lto.h
===
--- llvm/include/llvm-c/lto.h
+++ llvm/include/llvm-c/lto.h
@@ -16,6 +16,8 @@
 #ifndef LLVM_C_LTO_H
 #define LLVM_C_LTO_H
 
+#include "llvm-c/ExternC.h"
+
 #ifdef __cplusplus
 #include 
 #else
@@ -98,9 +100,7 @@
 /** opaque reference to a thin code generator */
 typedef struct LLVMOpaqueThinLTOCodeGenerator *thinlto_code_gen_t;
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_C_EXTERN_C_BEGIN
 
 /**
  * Returns a printable string.
@@ -900,8 +900,6 @@
  * @} // endgroup LLVMCTLTO_CACHING
  */
 
-#ifdef __cplusplus
-}
-#endif
+LLVM_C_EXTERN_C_END
 
 #endif /* LLVM_C_LTO_H */
Index: llvm/include/llvm-c/Types.h
===
--- llvm/include/llvm-c/Types.h
+++ llvm/include/llvm-c/Types.h
@@ -15,10 +15,9 @@
 #define LLVM_C_TYPES_H
 
 #include "llvm-c/DataTypes.h"
+#include "llvm-c/ExternC.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_C_EXTERN_C_BEGIN
 
 /**
  * @defgroup LLVMCSupportTypes Types and Enumerations
@@ -172,8 +171,6 @@
  * @}
  */
 
-#ifdef __cplusplus
-}
-#endif
+LLVM_C_EXTERN_C_END
 
 #endif
Index: llvm/include/llvm-c/Transforms/Vectorize.h
===
--- llvm/include/llvm-c/Transforms/Vectorize.h
+++ llvm/include/llvm-c/Transforms/Vectorize.h
@@ -20,11 +20,10 @@
 #ifndef LLVM_C_TRANSFORMS_VECTORIZE_H
 #define LLVM_C_TRANSFORMS_VECTORIZE_H
 
+#include "llvm-c/ExternC.h"
 #include "llvm-c/Types.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_C_EXTERN_C_BEGIN
 
 /**
  * @defgroup LLVMCTransformsVectorize Vectorization transformations
@@ -43,8 +42,6 @@
  * @}
  */
 
-#ifdef __cplusplus
-}
-#endif /* defined(__cplusplus) */
+LLVM_C_EXTERN_C_END
 
 #endif
Index: llvm/include/llvm-c/Transforms/Utils.h
===
--- llvm/include/llvm-c/Transforms/Utils.h
+++ llvm/include/llvm-c/Transforms/Utils.h
@@ -19,11 +19,10 @@
 #ifndef LLVM_C_TRANSFORMS_UTILS_H
 #define LLVM_C_TRANSFORMS_UTILS_H
 
+#include "llvm-c/ExternC.h"
 #include "llvm-c/Types.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_C_EXTERN_C_BEGIN
 
 /**
  * @defgroup LLVMCTransformsUtils Transformation Utilities
@@ -45,9 +44,7 @@
  * @}
  */
 
-#ifdef __cplusplus
-}
-#endif /* defined(__cplusplus) */
+LLVM_C_EXTERN_C_END
 
 #endif
 
Index: llvm/include/llvm-c/Transforms/Scalar.h
===
--- llvm/include/llvm-c/Transforms/Scalar.h
+++ llvm/include/llvm-c/Transforms/Scalar.h
@@ -19,11 +19,10 @@
 #ifndef LLVM_C_TRANSFORMS_SCALAR_H
 #define LLVM_C_TRANSFORMS_SCALAR_H
 
+#include "llvm-c/ExternC.h"
 #include "llvm-c/Types.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_C_EXTERN_C_BEGIN
 
 /**
  * @defgroup LLVMCTransformsScalar Scalar transformations
@@ -166,8 +165,6 @@
  * @}
  */
 
-#ifdef __cplusplus
-}
-#endif /* defined(__cplusplus) */
+LLVM_C_EXTERN_C_END
 
 #endif
Index: llvm/include/llvm-c/Transforms/PassManagerBuilder.h
===
--- llvm/include/llvm-c/Transforms/PassManagerBuilder.h
+++ 

[PATCH] D69991: Implement __attribute__((objc_direct)), __attribute__((objc_direct_members))

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

Okay.  This seems reasonable to me, then.


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

https://reviews.llvm.org/D69991



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


[PATCH] D70242: [OpenCL] Allow addr space qualifiers on lambda call expressions

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

Well that was easy.

Do we accept the address-space attribute in this position, or is that TBD?


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

https://reviews.llvm.org/D70242



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


[PATCH] D67460: clang-tidy: modernize-use-using work with multi-argument templates

2019-11-16 Thread Mitchell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG782392db8122: [clang-tidy] modernize-use-using work with 
multi-argument templates (authored by mitchell-stellar).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67460

Files:
  clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
@@ -183,3 +183,67 @@
   void f() override { super::f(); }
 };
 }
+
+template 
+class TwoArgTemplate {
+  typedef TwoArgTemplate self;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using self = TwoArgTemplate;
+};
+
+template 
+struct S {};
+
+typedef S<(0 > 0), int> S_t, *S_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef S<(0 > 0), int> S_t, *S_p;
+
+typedef S<(0 < 0), int> S2_t, *S2_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef S<(0 < 0), int> S2_t, *S2_p;
+
+typedef S<(0 > 0 && (3 > 1) && (1 < 1)), int> S3_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using S3_t = S<(0 > 0 && (3 > 1) && (1 < 1)), int>;
+
+template 
+struct Q {};
+
+constexpr bool b[1] = {true};
+
+typedef Q Q_t, *Q_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef Q Q_t, *Q_p;
+
+typedef Q Q2_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Q2_t = Q;
+
+struct T {
+  constexpr T(bool) {}
+
+  static constexpr bool b = true;
+};
+
+typedef Q Q3_t, *Q3_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef Q Q3_t, *Q3_p;
+
+typedef Q Q3_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Q3_t = Q;
+
+typedef TwoArgTemplate >, S<(0 < 0), Q > > Nested_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Nested_t = TwoArgTemplate >, S<(0 < 0), Q > >;
+
+template 
+class Variadic {};
+
+typedef Variadic >, S<(0 < 0), Variadic > > > Variadic_t;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: using Variadic_t = Variadic >, S<(0 < 0), Variadic > > >
+
+typedef Variadic >, S<(0 < 0), Variadic > > > Variadic_t, *Variadic_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef Variadic >, S<(0 < 0), Variadic > > > Variadic_t, *Variadic_p;
Index: clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -39,25 +39,46 @@
   File.begin(), TokenBegin, File.end());
 
   Token Tok;
-  int ParenLevel = 0;
+  int NestingLevel = 0; // Parens, braces, and square brackets
+  int AngleBracketLevel = 0;
   bool FoundTypedef = false;
 
   while (!DeclLexer.LexFromRawLexer(Tok) && !Tok.is(tok::semi)) {
 switch (Tok.getKind()) {
 case tok::l_brace:
-case tok::r_brace:
-  // This might be the `typedef struct {...} T;` case.
-  return false;
+  if (NestingLevel == 0 && AngleBracketLevel == 0) {
+// At top level, this might be the `typedef struct {...} T;` case.
+// Inside parens, square brackets, or angle brackets it's not.
+return false;
+  }
+  ++NestingLevel;
+  break;
 case tok::l_paren:
-  ParenLevel++;
+case tok::l_square:
+  ++NestingLevel;
   break;
+case tok::r_brace:
 case tok::r_paren:
-  ParenLevel--;
+case tok::r_square:
+  --NestingLevel;
+  break;
+case tok::less:
+  // If not nested in paren/brace/square bracket, treat as opening angle bracket.
+  if (NestingLevel == 0)
+++AngleBracketLevel;
+  break;
+case tok::greater:
+  // Per C++ 17 Draft N4659, Section 17.2/3
+  //   https://timsong-cpp.github.io/cppwp/n4659/temp.names#3:
+  // "When parsing a template-argument-list, the first non-nested > is
+  // taken as the ending delimiter rather than a greater-than operator."
+  // If not nested in paren/brace/square bracket, treat as closing angle bracket.
+  if (NestingLevel == 0)
+--AngleBracketLevel;
   break;
 case tok::comma:
-  if (ParenLevel == 0) {
-// If there is comma and we are not between open parenthesis then it is
-// two 

[PATCH] D70285: Wrap C APIs with pragmas enforcing -Werror=strict-prototypes

2019-11-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith marked 2 inline comments as done.
dexonsmith added inline comments.



Comment at: clang/include/clang-c/ExternC.h:18-19
+#define LLVM_CLANG_C_STRING_PROTOTYPES_BEGIN   
\
+  _Pragma("clang diagnostic push") 
\
+  _Pragma("clang diagnostic error \"-Wstrict-prototypes\"")
+#define LLVM_CLANG_C_STRING_PROTOTYPES_END _Pragma("clang diagnostic pop")

aaron.ballman wrote:
> I think this needs some extra compiler guards, unfortunately. I don't think 
> MSVC supports `_Pragma` (IIRC, they rather oddly decided to call it 
> `__pragma` instead). Do we want to restrict this pragma to only clang 
> compilers? Do we need to do something to support GCC as well?
Thanks for pointing this out; guarded against `_MSC_VER` in the updated diff.

Supporting GCC as a follow-up sounds nice to me if someone is interested in 
sorting that out, but covering it in Clang like this is sufficient to get our 
bots to reject commits that regress.


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

https://reviews.llvm.org/D70285



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


[clang-tools-extra] 782392d - [clang-tidy] modernize-use-using work with multi-argument templates

2019-11-16 Thread Mitchell Balan via cfe-commits

Author: Mitchell Balan
Date: 2019-11-15T16:09:10-05:00
New Revision: 782392db8122cafb5e0e4ad5fe0c24c46f11b2b7

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

LOG: [clang-tidy] modernize-use-using work with multi-argument templates

Summary:
If clang-tidy's modernize-use-using feature finds any commas that are not 
within parentheses, it won't create a fix. That means it won't change lines 
like:
  typedef std::pair Point;
to
  using Point = std::pair;
or even:
  typedef std::map MyMap;
  typedef std::vector> MyVector;

This patch allows the fix to apply to lines with commas if they are within 
parentheses or angle brackets that were not themselves within parentheses.

Reviewers: alexfh, hokein, aaron.ballman

Patch by: poelmanc

Subscribers: jonathanmeier, cfe-commits

Tags: #clang, #clang-tools-extra

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index bd234623d9ec..c9ca8a6114a5 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -39,25 +39,46 @@ static bool CheckRemoval(SourceManager , SourceLocation 
StartLoc,
   File.begin(), TokenBegin, File.end());
 
   Token Tok;
-  int ParenLevel = 0;
+  int NestingLevel = 0; // Parens, braces, and square brackets
+  int AngleBracketLevel = 0;
   bool FoundTypedef = false;
 
   while (!DeclLexer.LexFromRawLexer(Tok) && !Tok.is(tok::semi)) {
 switch (Tok.getKind()) {
 case tok::l_brace:
-case tok::r_brace:
-  // This might be the `typedef struct {...} T;` case.
-  return false;
+  if (NestingLevel == 0 && AngleBracketLevel == 0) {
+// At top level, this might be the `typedef struct {...} T;` case.
+// Inside parens, square brackets, or angle brackets it's not.
+return false;
+  }
+  ++NestingLevel;
+  break;
 case tok::l_paren:
-  ParenLevel++;
+case tok::l_square:
+  ++NestingLevel;
   break;
+case tok::r_brace:
 case tok::r_paren:
-  ParenLevel--;
+case tok::r_square:
+  --NestingLevel;
+  break;
+case tok::less:
+  // If not nested in paren/brace/square bracket, treat as opening angle 
bracket.
+  if (NestingLevel == 0)
+++AngleBracketLevel;
+  break;
+case tok::greater:
+  // Per C++ 17 Draft N4659, Section 17.2/3
+  //   https://timsong-cpp.github.io/cppwp/n4659/temp.names#3:
+  // "When parsing a template-argument-list, the first non-nested > is
+  // taken as the ending delimiter rather than a greater-than operator."
+  // If not nested in paren/brace/square bracket, treat as closing angle 
bracket.
+  if (NestingLevel == 0)
+--AngleBracketLevel;
   break;
 case tok::comma:
-  if (ParenLevel == 0) {
-// If there is comma and we are not between open parenthesis then it is
-// two or more declarations in this chain.
+  if (NestingLevel == 0 && AngleBracketLevel == 0) {
+// If there is a non-nested comma we have two or more declarations in 
this chain.
 return false;
   }
   break;
@@ -88,8 +109,7 @@ void UseUsingCheck::check(const MatchFinder::MatchResult 
) {
   if (StartLoc.isMacroID() && IgnoreMacros)
 return;
 
-  auto Diag =
-  diag(StartLoc, "use 'using' instead of 'typedef'");
+  auto Diag = diag(StartLoc, "use 'using' instead of 'typedef'");
 
   // do not fix if there is macro or array
   if (MatchedDecl->getUnderlyingType()->isArrayType() || StartLoc.isMacroID())

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
index efa4030d001e..73fd2701bbdf 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-using.cpp
@@ -183,3 +183,67 @@ class E : public C {
   void f() override { super::f(); }
 };
 }
+
+template 
+class TwoArgTemplate {
+  typedef TwoArgTemplate self;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+  // CHECK-FIXES: using self = TwoArgTemplate;
+};
+
+template 
+struct S {};
+
+typedef S<(0 > 0), int> S_t, *S_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// CHECK-FIXES: typedef S<(0 > 0), int> S_t, *S_p;
+
+typedef S<(0 < 0), int> S2_t, *S2_p;
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
+// 

[PATCH] D70285: Wrap C APIs with pragmas enforcing -Werror=strict-prototypes

2019-11-16 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith updated this revision to Diff 229621.
dexonsmith added a comment.

Adding guards for `_MSC_VER`.


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

https://reviews.llvm.org/D70285

Files:
  clang/include/clang-c/BuildSystem.h
  clang/include/clang-c/CXCompilationDatabase.h
  clang/include/clang-c/CXErrorCode.h
  clang/include/clang-c/CXString.h
  clang/include/clang-c/Documentation.h
  clang/include/clang-c/ExternC.h
  clang/include/clang-c/FatalErrorHandler.h
  clang/include/clang-c/Index.h
  clang/include/clang-c/Platform.h
  llvm/include/llvm-c/Analysis.h
  llvm/include/llvm-c/BitReader.h
  llvm/include/llvm-c/BitWriter.h
  llvm/include/llvm-c/Comdat.h
  llvm/include/llvm-c/Core.h
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm-c/Disassembler.h
  llvm/include/llvm-c/Error.h
  llvm/include/llvm-c/ErrorHandling.h
  llvm/include/llvm-c/ExecutionEngine.h
  llvm/include/llvm-c/ExternC.h
  llvm/include/llvm-c/IRReader.h
  llvm/include/llvm-c/Initialization.h
  llvm/include/llvm-c/LinkTimeOptimizer.h
  llvm/include/llvm-c/Linker.h
  llvm/include/llvm-c/Object.h
  llvm/include/llvm-c/OrcBindings.h
  llvm/include/llvm-c/Remarks.h
  llvm/include/llvm-c/Support.h
  llvm/include/llvm-c/Target.h
  llvm/include/llvm-c/TargetMachine.h
  llvm/include/llvm-c/Transforms/AggressiveInstCombine.h
  llvm/include/llvm-c/Transforms/Coroutines.h
  llvm/include/llvm-c/Transforms/IPO.h
  llvm/include/llvm-c/Transforms/InstCombine.h
  llvm/include/llvm-c/Transforms/PassManagerBuilder.h
  llvm/include/llvm-c/Transforms/Scalar.h
  llvm/include/llvm-c/Transforms/Utils.h
  llvm/include/llvm-c/Transforms/Vectorize.h
  llvm/include/llvm-c/Types.h
  llvm/include/llvm-c/lto.h

Index: llvm/include/llvm-c/lto.h
===
--- llvm/include/llvm-c/lto.h
+++ llvm/include/llvm-c/lto.h
@@ -16,6 +16,8 @@
 #ifndef LLVM_C_LTO_H
 #define LLVM_C_LTO_H
 
+#include "llvm-c/ExternC.h"
+
 #ifdef __cplusplus
 #include 
 #else
@@ -98,9 +100,7 @@
 /** opaque reference to a thin code generator */
 typedef struct LLVMOpaqueThinLTOCodeGenerator *thinlto_code_gen_t;
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_C_EXTERN_C_BEGIN
 
 /**
  * Returns a printable string.
@@ -900,8 +900,6 @@
  * @} // endgroup LLVMCTLTO_CACHING
  */
 
-#ifdef __cplusplus
-}
-#endif
+LLVM_C_EXTERN_C_END
 
 #endif /* LLVM_C_LTO_H */
Index: llvm/include/llvm-c/Types.h
===
--- llvm/include/llvm-c/Types.h
+++ llvm/include/llvm-c/Types.h
@@ -15,10 +15,9 @@
 #define LLVM_C_TYPES_H
 
 #include "llvm-c/DataTypes.h"
+#include "llvm-c/ExternC.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_C_EXTERN_C_BEGIN
 
 /**
  * @defgroup LLVMCSupportTypes Types and Enumerations
@@ -172,8 +171,6 @@
  * @}
  */
 
-#ifdef __cplusplus
-}
-#endif
+LLVM_C_EXTERN_C_END
 
 #endif
Index: llvm/include/llvm-c/Transforms/Vectorize.h
===
--- llvm/include/llvm-c/Transforms/Vectorize.h
+++ llvm/include/llvm-c/Transforms/Vectorize.h
@@ -20,11 +20,10 @@
 #ifndef LLVM_C_TRANSFORMS_VECTORIZE_H
 #define LLVM_C_TRANSFORMS_VECTORIZE_H
 
+#include "llvm-c/ExternC.h"
 #include "llvm-c/Types.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_C_EXTERN_C_BEGIN
 
 /**
  * @defgroup LLVMCTransformsVectorize Vectorization transformations
@@ -43,8 +42,6 @@
  * @}
  */
 
-#ifdef __cplusplus
-}
-#endif /* defined(__cplusplus) */
+LLVM_C_EXTERN_C_END
 
 #endif
Index: llvm/include/llvm-c/Transforms/Utils.h
===
--- llvm/include/llvm-c/Transforms/Utils.h
+++ llvm/include/llvm-c/Transforms/Utils.h
@@ -19,11 +19,10 @@
 #ifndef LLVM_C_TRANSFORMS_UTILS_H
 #define LLVM_C_TRANSFORMS_UTILS_H
 
+#include "llvm-c/ExternC.h"
 #include "llvm-c/Types.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_C_EXTERN_C_BEGIN
 
 /**
  * @defgroup LLVMCTransformsUtils Transformation Utilities
@@ -45,9 +44,7 @@
  * @}
  */
 
-#ifdef __cplusplus
-}
-#endif /* defined(__cplusplus) */
+LLVM_C_EXTERN_C_END
 
 #endif
 
Index: llvm/include/llvm-c/Transforms/Scalar.h
===
--- llvm/include/llvm-c/Transforms/Scalar.h
+++ llvm/include/llvm-c/Transforms/Scalar.h
@@ -19,11 +19,10 @@
 #ifndef LLVM_C_TRANSFORMS_SCALAR_H
 #define LLVM_C_TRANSFORMS_SCALAR_H
 
+#include "llvm-c/ExternC.h"
 #include "llvm-c/Types.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+LLVM_C_EXTERN_C_BEGIN
 
 /**
  * @defgroup LLVMCTransformsScalar Scalar transformations
@@ -166,8 +165,6 @@
  * @}
  */
 
-#ifdef __cplusplus
-}
-#endif /* defined(__cplusplus) */
+LLVM_C_EXTERN_C_END
 
 #endif
Index: llvm/include/llvm-c/Transforms/PassManagerBuilder.h
===
--- llvm/include/llvm-c/Transforms/PassManagerBuilder.h
+++ llvm/include/llvm-c/Transforms/PassManagerBuilder.h
@@ -14,13 +14,12 @@
 

[clang] 9c1baa2 - re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and mark them as artificial

2019-11-16 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2019-11-15T16:01:39-05:00
New Revision: 9c1baa23526c6d7d06eafefbf82d73bfe9bb3aaf

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

LOG: re-land [DebugInfo] Add debug location to stubs generated by CGDeclCXX and 
mark them as artificial

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

Added: 
clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
clang/test/CodeGenCXX/debug-info-destroy-helper.cpp

Modified: 
clang/include/clang/AST/GlobalDecl.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
clang/test/CodeGenCXX/debug-info-line.cpp

Removed: 




diff  --git a/clang/include/clang/AST/GlobalDecl.h 
b/clang/include/clang/AST/GlobalDecl.h
index 145e961a23a3..ab14d9678812 100644
--- a/clang/include/clang/AST/GlobalDecl.h
+++ b/clang/include/clang/AST/GlobalDecl.h
@@ -31,6 +31,7 @@ enum class DynamicInitKind : unsigned {
   NoStub = 0,
   Initializer,
   AtExit,
+  GlobalArrayDestructor
 };
 
 /// GlobalDecl - represents a global declaration. This can either be a

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 75c4b2ae2339..41459018a3bf 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1944,7 +1944,8 @@ StringRef CGDebugInfo::getDynamicInitializerName(const 
VarDecl *VD,
  llvm::Function *InitFn) {
   // If we're not emitting codeview, use the mangled name. For Itanium, this is
   // arbitrary.
-  if (!CGM.getCodeGenOpts().EmitCodeView)
+  if (!CGM.getCodeGenOpts().EmitCodeView ||
+  StubKind == DynamicInitKind::GlobalArrayDestructor)
 return InitFn->getName();
 
   // Print the normal qualified name for the variable, then break off the last
@@ -1969,6 +1970,7 @@ StringRef CGDebugInfo::getDynamicInitializerName(const 
VarDecl *VD,
 
   switch (StubKind) {
   case DynamicInitKind::NoStub:
+  case DynamicInitKind::GlobalArrayDestructor:
 llvm_unreachable("not an initializer");
   case DynamicInitKind::Initializer:
 OS << "`dynamic initializer for '";
@@ -3644,7 +3646,8 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, 
SourceLocation Loc,
   if (Name.startswith("\01"))
 Name = Name.substr(1);
 
-  if (!HasDecl || D->isImplicit() || D->hasAttr()) {
+  if (!HasDecl || D->isImplicit() || D->hasAttr() ||
+  (isa(D) && GD.getDynamicInitKind() != DynamicInitKind::NoStub)) 
{
 Flags |= llvm::DINode::FlagArtificial;
 // Artificial functions should not silently reuse CurLoc.
 CurLoc = SourceLocation();

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 5b172a3480be..95bd00010395 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -244,6 +244,8 @@ llvm::Function *CodeGenFunction::createAtExitStub(const 
VarDecl ,
 
   CGF.StartFunction(GlobalDecl(, DynamicInitKind::AtExit),
 CGM.getContext().VoidTy, fn, FI, FunctionArgList());
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(CGF);
 
   llvm::CallInst *call = CGF.Builder.CreateCall(dtor, addr);
 
@@ -644,8 +646,9 @@ void 
CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 
   StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
 getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
-FunctionArgList(), D->getLocation(),
-D->getInit()->getExprLoc());
+FunctionArgList());
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   // Use guarded initialization if the global variable is weak. This
   // occurs for, e.g., instantiated static data members and
@@ -770,7 +773,10 @@ llvm::Function *CodeGenFunction::generateDestroyHelper(
 
   CurEHLocation = VD->getBeginLoc();
 
-  StartFunction(VD, getContext().VoidTy, fn, FI, args);
+  StartFunction(GlobalDecl(VD, DynamicInitKind::GlobalArrayDestructor),
+getContext().VoidTy, fn, FI, args);
+  // Emit an artificial location for this function.
+  auto AL = ApplyDebugLocation::CreateArtificial(*this);
 
   emitDestroy(addr, type, destroyer, useEHCleanupForArray);
 

diff  --git a/clang/test/CodeGenCXX/debug-info-atexit-stub.cpp 
b/clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
new file mode 100644
index ..8ff2ca5d2f2c
--- /dev/null
+++ b/clang/test/CodeGenCXX/debug-info-atexit-stub.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-windows-msvc -gcodeview 
-debug-info-kind=limited -o - | FileCheck %s
+
+struct a {
+  ~a();
+};
+template  struct c : a {
+  c(void 

[PATCH] D69564: Include the mangled name in -ast-dump=json

2019-11-16 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69564



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


  1   2   3   >